diff --git a/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java b/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java index 63868f50..6f2f5056 100644 --- a/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java +++ b/src/com/engine/organization/entity/hrmresource/po/ResourceChartPO.java @@ -24,6 +24,8 @@ public class ResourceChartPO { private String lastName; + private String managerId; + private String sex; private Integer departmentId; diff --git a/src/com/engine/organization/service/HrmResourceService.java b/src/com/engine/organization/service/HrmResourceService.java index a6a3fc7f..d5a90b26 100644 --- a/src/com/engine/organization/service/HrmResourceService.java +++ b/src/com/engine/organization/service/HrmResourceService.java @@ -4,6 +4,7 @@ import com.engine.organization.entity.hrmresource.param.HrmRelationSaveParam; import com.engine.organization.entity.hrmresource.param.SearchTemplateParam; import com.engine.organization.entity.searchtree.SearchTreeParams; +import java.util.List; import java.util.Map; /** @@ -179,4 +180,14 @@ public interface HrmResourceService { Map chartResourceList(Integer departmentId,String versionId,String dimension); + /** + * @Description: 获取虚拟维度 所有子部门和当前部门集合 + * @Author: liang.cheng + * @Date: 2024/5/11 5:47 PM + * @param: [departmentId] + * @return: java.util.List + */ + List getAllSubDepartment(String departmentId); + + } diff --git a/src/com/engine/organization/service/impl/ChartServiceImpl.java b/src/com/engine/organization/service/impl/ChartServiceImpl.java index a67f48f4..d67cda70 100644 --- a/src/com/engine/organization/service/impl/ChartServiceImpl.java +++ b/src/com/engine/organization/service/impl/ChartServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.organization.service.impl; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.thread.ThreadUtil; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; @@ -368,15 +369,21 @@ public class ChartServiceImpl extends Service implements ChartService { if (isRealDimension) { sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.managerid,b."+levelFieldId+" as levelvalue from hrmresource a left join cus_fielddata b on a.id = b.id and scopeid = 3 where a.status < 4 and a.departmentid = ? "; } else { + List allSubDepartment = ServiceUtil.getService(HrmResourceServiceImpl.class, user).getAllSubDepartment(departmentId); + String join = CollectionUtil.join(allSubDepartment, ","); sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,a.managerid,c."+levelFieldId+" as levelvalue from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid " + - " left join cus_fielddata c on b.resourceid = c.id and scopeid = 3 where a.status < 4 and b.departmentid = ? "; + " left join cus_fielddata c on b.resourceid = c.id and scopeid = 3 where a.status < 4 and b.departmentid in ("+join+")"; + rs.executeQuery(sql); } } else { sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear,a.manager from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and versionid = " + versionId; } List personList = new ArrayList<>(); - rs.executeQuery(sql, departmentId); + if (isRealDimension) { + rs.executeQuery(sql, departmentId); + } + while (rs.next()) { String managerId; if (isRealTime) { @@ -393,19 +400,31 @@ public class ChartServiceImpl extends Service implements ChartService { //Map managerToFobjidMap = personList.stream() // .collect(Collectors.toMap(ChartPO::getManagerId, ChartPO::getFobjid,(existingValue, newValue) -> newValue)); + Map map = personList.stream() + .collect(Collectors.toMap(ChartPO::getFobjid, + chartPO -> chartPO, + (existing, replacement) -> existing)); + personList = new ArrayList<>(map.values()); + Map managerToFobjidMap = personList.stream() .collect(Collectors.toMap(ChartPO::getFobjid, ChartPO::getManagerId)); +// Map managerToFobjidMap = personList.stream().collect(Collectors.toMap(ChartPO::getManagerId, ChartPO::getFobjid,(oldValue, newValue) -> newValue)); + personList.forEach(chart -> { - String managerId = managerToFobjidMap.get(chart.getManagerId()); - if (StringUtils.isNotEmpty(managerId)) { + String fobjId = managerToFobjidMap.get(chart.getManagerId()); + if (StringUtils.isNotEmpty(fobjId)) { chart.setParentId(chart.getManagerId()); } }); dataList.addAll(personList); + departmentChartPO.setFonjob(personList.size()); + } + + if (isRealDimension) { + departmentChartPO.setFonjob(departmentOnJob); } - departmentChartPO.setFonjob(departmentOnJob); Map result = new HashMap<>(); diff --git a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java index ef7db662..4bd57d35 100644 --- a/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java +++ b/src/com/engine/organization/service/impl/HrmResourceServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.organization.service.impl; +import cn.hutool.core.collection.CollectionUtil; import com.api.browser.bean.SearchConditionGroup; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; @@ -52,6 +53,7 @@ import com.engine.organization.util.db.MapperProxyFactory; import com.engine.organization.util.detach.DetachUtil; import com.engine.organization.util.page.PageUtil; import com.engine.organization.util.tree.SearchTreeUtil; +import lombok.SneakyThrows; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.json.JSONException; @@ -61,6 +63,7 @@ import weaver.conn.RecordSet; import weaver.general.StringUtil; import weaver.general.TimeUtil; import weaver.general.Util; +import weaver.hrm.companyvirtual.DepartmentVirtualComInfo; import weaver.hrm.definedfield.HrmFieldManager; import java.math.BigDecimal; @@ -69,7 +72,6 @@ import java.time.LocalDate; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import java.util.stream.IntStream; import static weaver.general.Util.getIntValue; @@ -491,8 +493,10 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic } } } else { - rs.executeQuery("select h.id,h.workcode,h.lastname,h.sex,h.departmentid,h.subcompanyid1,h.jobtitle,h.status,h.mobile " + - " from hrmresourcevirtual v inner join hrmresource h on v.resourceid = h.id and v.virtualtype = ? and v.departmentid = ?", dimension, departmentId); + List allSubDepartment = getAllSubDepartment(String.valueOf(departmentId)); + String join = CollectionUtil.join(allSubDepartment, ","); + rs.executeQuery("select h.id,h.workcode,h.lastname,h.sex,h.departmentid,h.subcompanyid1,h.jobtitle,h.status,h.mobile,h.managerid " + + " from hrmresourcevirtual v inner join hrmresource h on v.resourceid = h.id and v.virtualtype = ? and v.departmentid in ("+join+")", dimension); while (rs.next()) { ResourceChartPO build = ResourceChartPO.builder() .id((long) Util.getIntValue(rs.getString("id"))) @@ -508,6 +512,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic resourceChartPOS.add(build); } resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS); + + //虚拟维度去重 + Map map = resourceChartVOS.stream() + .collect(Collectors.toMap(ResourceChartVO::getId, + resourceChartVO -> resourceChartVO, + (existing, replacement) -> existing)); + resourceChartVOS = new ArrayList<>(map.values()); } dataMap.put("columns", resourceListColumns); @@ -1343,4 +1354,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic return selectKeys; } + @Override + public List getAllSubDepartment(String departmentId){ + DepartmentVirtualComInfo comInfo = new DepartmentVirtualComInfo(); + ArrayList subList = new ArrayList(); + comInfo.getAllChildDeptByDepId(subList, departmentId); + subList.add(departmentId); + return subList; + } + }