Commit bfa0d97c by 丁伟峰

组织树,将请求的参数都返回,方便前端进行页面处理

1 parent aa88abae
package com.dituhui.pea.order.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
@lombok.Data
@Accessors(chain = true)
public class OrganizationTreeRespDTO {
private List<?> clusters;
public class OrganizationTreeDTO {
@Data
public static class Request {
private String levelType;
private String levelValue;
}
@lombok.Data
@Accessors(chain = true)
public static class Result {
private String levelType;
private String levelValue;
private List<?> clusters;
}
@lombok.Data
@Accessors(chain = true)
......@@ -74,4 +88,3 @@ public class OrganizationTreeRespDTO {
private String type;
}
}
package com.dituhui.pea.order.dto;
@lombok.Data
public class OrganizationTreeReqDTO {
private String levelType;
private String levelValue;
}
......@@ -57,7 +57,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
Map<String, OrderRequestEntity> mapOrderRequest = getOrdersByOrderIds(orderIds);
HashMap<String, List<EngineersGanttDTO.Order>> mapEngineers = new HashMap<>();
for (OrderAppointmentEntity e : orderAppointments) {
log.info("===== order_id: [{}]", e.getOrderId());
// log.info("===== order_id: [{}]", e.getOrderId());
EngineersGanttDTO.Order order = new EngineersGanttDTO.Order();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order.setStartTime(e.getExpectStartTime()).setEndTime(e.getExpectEndTime());
......@@ -89,7 +89,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
if (capacityEngineerStat == null) {
log.warn("技术员当日的容量数据不存在,{}{}", engineerCode, reqDTO.getDate());
} else {
log.info("====== {} ==== {} ", capacityEngineerStat.getCapTotal(), capacityEngineerStat.getCapUsed());
log.info("====== {}", capacityEngineerStat);
engineer.setCapTotal(capacityEngineerStat.getCapTotal().toString()).setCapUsed(capacityEngineerStat.getCapUsed().toString());
}
if (mapEngineers.containsKey(engineerCode)) {
......
......@@ -31,13 +31,14 @@ public class OrganizationServiceImpl implements OrganizationService {
private EngineerInfoDao engineerInfoDao;
@Autowired
private OrgTeamDao orgTeamDao;
@Autowired
private EngineerUtils engineerUtils;
@Override
public Result<?> getOrganizationTree(String levelType, String levelValue) {
// 如果传递了精确的id,只返回对应的tree内容;如果没有传递,返回所有tree内容
OrganizationTreeDTO.Result rs = new OrganizationTreeDTO.Result();
rs.setLevelType(levelType).setLevelValue(levelValue);
if ("group".equals(levelType)) {
OrgGroupEntity orgGroupEntity = orgGroupDao.getByGroupId(levelValue);
if (orgGroupEntity == null) {
......@@ -48,7 +49,7 @@ public class OrganizationServiceImpl implements OrganizationService {
List<?> branchs = new ArrayList<>(Collections.singletonList(branchEntityh2Dto(orgBranchEntity).setChildren(groups)));
OrgClusterEntity orgClusterEntity = orgClusterDao.getByClusterId(orgGroupEntity.getClusterId());
List<?> clusters = new ArrayList<>(Collections.singletonList(clusterEntity2Dto(orgClusterEntity).setChildren(branchs)));
return Result.success(new OrganizationTreeRespDTO().setClusters(clusters));
rs.setClusters(clusters);
} else if ("branch".equals(levelType)) {
OrgBranchEntity orgBranchEntity = orgBranchDao.getByBranchId(levelValue);
if (orgBranchEntity == null) {
......@@ -58,7 +59,7 @@ public class OrganizationServiceImpl implements OrganizationService {
List<?> groups = getChildByBranch(levelValue);
List<?> branchs = new ArrayList<>(Collections.singletonList(branchEntityh2Dto(orgBranchEntity).setChildren(groups)));
List<?> clusters = new ArrayList<>(Collections.singletonList(clusterEntity2Dto(orgClusterEntity).setChildren(branchs)));
return Result.success(new OrganizationTreeRespDTO().setClusters(clusters));
rs.setClusters(clusters);
} else if ("cluster".equals(levelType)) {
OrgClusterEntity orgClusterEntity = orgClusterDao.getByClusterId(levelValue);
if (orgClusterEntity == null) {
......@@ -66,10 +67,11 @@ public class OrganizationServiceImpl implements OrganizationService {
}
List<?> branchs = getChildByCluster(levelValue);
List<?> clusters = new ArrayList<>(Collections.singletonList(clusterEntity2Dto(orgClusterEntity).setChildren(branchs)));
return Result.success(new OrganizationTreeRespDTO().setClusters(clusters));
rs.setClusters(clusters);
} else {
return Result.success(new OrganizationTreeRespDTO().setClusters(getTreeByRoot()));
rs.setClusters(getTreeByRoot());
}
return Result.success(rs);
}
@Override
......@@ -128,7 +130,7 @@ public class OrganizationServiceImpl implements OrganizationService {
}
private List<?> getTreeByRoot() {
List<OrganizationTreeRespDTO.Cluster> clusters = new ArrayList<>();
List<OrganizationTreeDTO.Cluster> clusters = new ArrayList<>();
for (OrgClusterEntity c : orgClusterDao.findAll()) {
clusters.add(clusterEntity2Dto(c).setChildren(getChildByCluster(c.getClusterId())));
}
......@@ -136,7 +138,7 @@ public class OrganizationServiceImpl implements OrganizationService {
}
private List<?> getChildByCluster(String clusterId) {
List<OrganizationTreeRespDTO.Branch> branches = new ArrayList<>();
List<OrganizationTreeDTO.Branch> branches = new ArrayList<>();
for (OrgBranchEntity b : orgBranchDao.findAllByClusterId(clusterId)) {
branches.add(branchEntityh2Dto(b).setChildren(getChildByBranch(b.getBranchId())));
}
......@@ -145,30 +147,29 @@ public class OrganizationServiceImpl implements OrganizationService {
private List<?> getChildByBranch(String branchId) {
// 获取branch及下面的group
List<OrganizationTreeRespDTO.Group> groups = new ArrayList<>();
List<OrganizationTreeDTO.Group> groups = new ArrayList<>();
for (OrgGroupEntity g : orgGroupDao.findAllByBranchId(branchId)) {
groups.add(groupEntity2Dto(g));
}
return groups;
}
private OrganizationTreeRespDTO.Group groupEntity2Dto(OrgGroupEntity orgGroupEntity) {
return new OrganizationTreeRespDTO.Group()
private OrganizationTreeDTO.Group groupEntity2Dto(OrgGroupEntity orgGroupEntity) {
return new OrganizationTreeDTO.Group()
.setType("group")
.setId(orgGroupEntity.getGroupId())
.setTitle(orgGroupEntity.getGroupName());
}
private OrganizationTreeRespDTO.Branch branchEntityh2Dto(OrgBranchEntity orgBranchEntity) {
return new OrganizationTreeRespDTO.Branch()
private OrganizationTreeDTO.Branch branchEntityh2Dto(OrgBranchEntity orgBranchEntity) {
return new OrganizationTreeDTO.Branch()
.setType("branch")
.setId(orgBranchEntity.getBranchId())
.setTitle(orgBranchEntity.getBranchName());
}
private OrganizationTreeRespDTO.Cluster clusterEntity2Dto(OrgClusterEntity orgClusterEntity) {
return new OrganizationTreeRespDTO.Cluster()
private OrganizationTreeDTO.Cluster clusterEntity2Dto(OrgClusterEntity orgClusterEntity) {
return new OrganizationTreeDTO.Cluster()
.setType("cluster")
.setId(orgClusterEntity.getClusterId())
.setTitle(orgClusterEntity.getName());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!