Compare commits

...

14 Commits

@ -0,0 +1,27 @@
package com.engine.organization.entity.chart;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2024/4/2 4:22 PM
* @Description:
* @Version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ChartDepartmentModeVO {
private String leaderId;
private String leaderName;
private Integer colorCheck;
private String jobType;
}

@ -34,13 +34,27 @@ public class ChartPO {
// 部门负责人
private String fleader;
// 人员主次账号
private Integer colorCheck;
//人员主次账号
private String belongto;
// 人员工龄
//人员工龄
private String companyWorkYear;
// 人员头像
//人员头像
private String fleaderimg;
private String jobTitle;
private String jobResponsibility;
private String managerId;
private String level;
private String jobType;
private String id;
private String key;

@ -22,6 +22,9 @@ public class CompanyTreePO {
private boolean isLeaf;
private String key;
private boolean disabled;
private int level;
private int depth;
private int showorder;
public boolean getIsLeaf() {
return isLeaf;

@ -24,6 +24,8 @@ public class ResourceChartPO {
private String lastName;
private String managerId;
private String sex;
private Integer departmentId;

@ -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<String, Object> chartResourceList(Integer departmentId,String versionId,String dimension);
/**
* @Description:
* @Author: liang.cheng
* @Date: 2024/5/11 5:47 PM
* @param: [departmentId]
* @return: java.util.List<java.lang.Integer>
*/
List<Integer> getAllSubDepartment(String departmentId);
}

@ -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;
@ -26,13 +27,13 @@ import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.resource.ResourceComInfo;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
/**
@ -85,13 +86,17 @@ public class ChartServiceImpl extends Service implements ChartService {
return result;
}
Map<String, String> map = getRootAndFclass();
// 根结点
String root = Util.null2String(params.get("root"));
root = StringUtils.isBlank(root) ? "0" : root;
// 维度
String dimension = Util.null2String(params.get("fclass"));
dimension = StringUtils.isBlank(dimension) ? "0" : dimension;
//dimension = StringUtils.isBlank(dimension) ? "0" : dimension;
dimension = StringUtils.isBlank(dimension) ? map.get("fclass") : dimension;
// 是否展示虚拟组织
String isVirtual = Util.null2String(params.get("fisvitual"));
@ -102,11 +107,15 @@ public class ChartServiceImpl extends Service implements ChartService {
//版本id
String id = Util.null2String(params.get("id"));
//顺胜二开 虚拟维度增加部门根节点 查询时以部门根节点为主
String department = Util.null2String(params.get("department"));
boolean hideDepartment = "1".equals(Util.null2String(params.get("hidedept")));
// 初始化表名
initTableNameByClass(dimension, id);
RecordSet rs = new RecordSet();
List<ChartPO> dataList = new ArrayList<>();
String sql = "";
@ -114,7 +123,7 @@ public class ChartServiceImpl extends Service implements ChartService {
ChartPO topChartPO = null;
//查询当前实际数据
if (isRealTime) {
sql = getRealTimeTopSql(root, dimension);
sql = getRealTimeTopSql(root, dimension,department);
} else {
sql = getLastTimeTopSql(root, dimension, id);
}
@ -133,15 +142,29 @@ public class ChartServiceImpl extends Service implements ChartService {
topChartPO.setExpand("1");
topChartPO.setFisvitual(rs.getString("isvitual"));
topChartPO.setHasChildren(getHasChildren(topChartPO.getFtype(), topChartPO.getFobjid()).toString());
if (!isRealDimension && "2".equals(topChartPO.getFtype())){
ChartDepartmentModeVO departmentModeVO = selectModeInfo(rs.getString("id"));
topChartPO.setColorCheck(departmentModeVO.getColorCheck());
topChartPO.setFleader(departmentModeVO.getLeaderName());
topChartPO.setJobType(departmentModeVO.getJobType());
}
filterAndAddData(dataList, topChartPO, hideDepartment);
//dataList.add(topChartPO);
}
// 向下查询数据
if (null != topChartPO) {
findChildData(topChartPO, dataList, Integer.parseInt(depth), id, hideDepartment);
// 向下查询数据 (顺胜区分)
if (isRealDimension) {
if (null != topChartPO) {
findChildData(topChartPO, dataList, Integer.parseInt(depth), id, hideDepartment);
}
}else {
if (null != topChartPO && !"2".equals(depth)) {
topChartPO.setDepartmentDepth(1);
findChildData(topChartPO, dataList, Integer.parseInt(depth), id, hideDepartment);
}
}
result.put("api_status", true);
result.put("data", dataList);
return result;
@ -200,8 +223,13 @@ public class ChartServiceImpl extends Service implements ChartService {
chartPO.setOnJobNum(isRealTime ? Util.getIntValue(rs.getString("on_job_num"),0) : Util.getIntValue(rs.getString("job_num"),0));
chartPO.setStaffNum(Util.getIntValue(rs.getString("staff_num"),0));
filterAndAddData(dataList, chartPO, hideDepartment);
//dataList.add(chartPO);
//顺胜二开 虚拟维度部门颜色设置
if (!isRealDimension && "2".equals(chartPO.getFtype())){
ChartDepartmentModeVO departmentModeVO = selectModeInfo(rs.getString("id"));
chartPO.setColorCheck(departmentModeVO.getColorCheck());
chartPO.setFleader(departmentModeVO.getLeaderName());
chartPO.setJobType(departmentModeVO.getJobType());
}
}
}
}
@ -215,6 +243,7 @@ public class ChartServiceImpl extends Service implements ChartService {
@Override
public Map<String, Object> getDepartmentDetail(Map<String, Object> params) {
String rootId = Util.null2String(params.get("rootId"));
// 维度
String dimension = Util.null2String(params.get("fclass"));
dimension = StringUtils.isBlank(dimension) ? "0" : dimension;
@ -233,7 +262,6 @@ public class ChartServiceImpl extends Service implements ChartService {
return ServiceUtil.getService(HrmResourceServiceImpl.class, user).chartResourceList(Integer.parseInt(departmentId), versionId, dimension);
}
// 初始化表名
initTableNameByClass(dimension, versionId);
@ -249,7 +277,7 @@ public class ChartServiceImpl extends Service implements ChartService {
if (hasVirtualFields) {
sql = "select a.id,a.departmentname as name,b.bmfzr,b.bmlx as isvitual from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = '" + departmentId + "'";
} else {
sql = "select a.id,a.departmentname as name,b.bmfzr from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = '" + departmentId + "'";
sql = "select a.id,a.departmentmark as name,b.bmfzr from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid where a.id = '" + departmentId + "'";
}
} else {
if (hasVirtualFields) {
@ -270,11 +298,28 @@ public class ChartServiceImpl extends Service implements ChartService {
departmentChartPO.setExpand("1");
departmentChartPO.setFisvitual(rs.getString("isvitual"));
// 部门负责人
departmentChartPO.setFleader(getDepartmentLeader(fLeader));
//顺胜项目二开 虚拟维度增加建模部门负责人
if (!isRealDimension){
ChartDepartmentModeVO chartDepartmentModeVO = selectModeInfo(departmentId);
departmentChartPO.setFleader(chartDepartmentModeVO.getLeaderName());
departmentChartPO.setColorCheck(chartDepartmentModeVO.getColorCheck());
try {
departmentChartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartDepartmentModeVO.getLeaderId()));
} catch (Exception e) {
throw new RuntimeException(e);
}
}else {
// 部门负责人 非虚拟维度部门负责人多个 不设置图像
departmentChartPO.setFleader(getDepartmentLeader(fLeader));
}
dataList.add(departmentChartPO);
}
String propValue = new BaseBean().getPropValue("hrmOrganization", "levelFieldId");
String levelFieldId = "field"+propValue;
if (showJob) {
// 查询部门下的岗位
if (isRealTime) {
@ -299,7 +344,7 @@ public class ChartServiceImpl extends Service implements ChartService {
// 遍历岗位、查询对应岗位下的人员
if (isRealTime) {
if (isRealDimension) {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? and a.jobtitle = ?";
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear,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 = ? and a.jobtitle = ?";
} else {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? and a.jobtitle = ?";
}
@ -311,7 +356,7 @@ public class ChartServiceImpl extends Service implements ChartService {
rs.executeQuery(sql, departmentId, jobTitlePO.getFobjid());
String parentId = departmentId + "_" + jobTitlePO.getFobjid();
while (rs.next()) {
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear"));
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), parentId, rs.getString("belongto"), rs.getString("companyworkyear"),isRealDimension,rs.getString("levelvalue"));
resourceNum++;
dataList.add(chartPO);
}
@ -321,24 +366,89 @@ public class ChartServiceImpl extends Service implements ChartService {
}
departmentChartPO.setHasChildren(CollectionUtils.isNotEmpty(jobTitleList) ? "1" : "0");
} else {
// 直接查询岗位下的人员
// 直接查询部门下的人员
if (isRealTime) {
if (isRealDimension) {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a where a.status < 4 and a.departmentid = ? ";
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 {
sql = "select a.id,a.lastname as name ,a.belongto ,a.companyworkyear from hrmresource a inner join hrmresourcevirtual b on a.id = b.resourceid where a.status < 4 and b.departmentid = ? ";
//v4 汇报关系类型获取
rs.executeQuery("select hbgxlx from uf_wdlj where wd = ?",dimension);
rs.next();
String hbgxlx = Util.null2String(rs.getString("hbgxlx"));
if ("".equals(hbgxlx)) {
//不显示人员
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 = 99999";
}else if ("0".equals(hbgxlx)){
//直接上级
List<Integer> 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 in ("+join+")";
}else if ("1".equals(hbgxlx)) {
//专业上级
String professionalSuperId = new BaseBean().getPropValue("hrmOrganization", "professionalSuperId");
List<Integer> 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,c."+professionalSuperId+" as 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 in ("+join+")";
}else if ("2".equals(hbgxlx)) {
//仅展示本部门
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 = "+departmentId;
}
rs.executeQuery(sql);
}
} else {
sql = "select a.resourceid as id,a.lastname as name ,a.belongto ,a.companyworkyear from jcl_chart_resource a where a.status < 4 and a.departmentid = ? and versionid = " + versionId;
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;
}
rs.executeQuery(sql, departmentId);
List<ChartPO> personList = new ArrayList<>();
if (isRealDimension) {
rs.executeQuery(sql, departmentId);
}
while (rs.next()) {
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear"));
dataList.add(chartPO);
String managerId;
if (isRealTime) {
managerId = Util.null2String(rs.getString("managerid"));
}else {
managerId = Util.null2String(rs.getString("manager"));
}
ChartPO chartPO = getResourceChartPO(rs.getString("id"), rs.getString("name"), rootId, rs.getString("belongto"), rs.getString("companyworkyear"),isRealDimension,rs.getString("levelvalue"));
chartPO.setManagerId(managerId);
personList.add(chartPO);
departmentOnJob++;
}
//顺胜二开 直接上级单独节点
Map<String, ChartPO> map = personList.stream()
.collect(Collectors.toMap(ChartPO::getFobjid,
chartPO -> chartPO,
(existing, replacement) -> existing));
personList = new ArrayList<>(map.values());
List<ChartPO> finalPersonList = personList;
personList.forEach(element -> finalPersonList.stream()
.filter(other -> element.getManagerId().equals(other.getId()))
.findFirst()
.ifPresent(matched -> element.setParentId(matched.getId())));
personList.sort(Comparator.comparing(ChartServiceImpl::safeConvertToInteger, Comparator.nullsLast(Comparator.reverseOrder()))
.thenComparing(ChartServiceImpl::safeConvertToDouble, Comparator.nullsLast(Comparator.reverseOrder())));
dataList.addAll(personList);
departmentChartPO.setFonjob(personList.size());
}
if (isRealDimension) {
departmentChartPO.setFonjob(departmentOnJob);
}
departmentChartPO.setFonjob(departmentOnJob);
Map<String, Object> result = new HashMap<>();
@ -347,6 +457,30 @@ public class ChartServiceImpl extends Service implements ChartService {
return result;
}
private static Integer safeConvertToInteger(ChartPO chartPO) {
String level = chartPO.getLevel();
if (level == null || !level.matches("-?\\d+")) {
return null;
}
try {
return Integer.parseInt(level);
} catch (NumberFormatException e) {
return null;
}
}
private static Double safeConvertToDouble(ChartPO chartPO) {
String companyWorkYear = chartPO.getCompanyWorkYear();
if (companyWorkYear == null) {
return null;
}
try {
return Double.parseDouble(companyWorkYear);
} catch (NumberFormatException e) {
return null;
}
}
@Override
public String selectVersionDate(String id) {
RecordSet rs = new RecordSet();
@ -365,18 +499,31 @@ public class ChartServiceImpl extends Service implements ChartService {
* @param companyWorkYear
* @return
*/
private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear) {
@SneakyThrows
private ChartPO getResourceChartPO(String id, String name, String parentId, String belongTo, String companyWorkYear, boolean isRealDimension,String levelValue) {
ChartPO chartPO = new ChartPO();
RecordSet rs = new RecordSet();
ResourceComInfo comInfo = new ResourceComInfo();
JobTitlesComInfo jobInfo = new JobTitlesComInfo();
chartPO.setFtype("4");
chartPO.setFobjid(id);
chartPO.setId(chartPO.getFobjid());
chartPO.setFname(name);
// 岗位处理后的ID
chartPO.setParentId(parentId);
chartPO.setExpand("0");
chartPO.setExpand(isRealDimension ? "0" : "1");
chartPO.setHasChildren("0");
chartPO.setBelongto(Util.null2String(belongTo));
chartPO.setCompanyWorkYear(companyWorkYear);
chartPO.setJobTitle(jobInfo.getJobTitlesname(comInfo.getJobTitle(id)));
chartPO.setJobResponsibility(jobInfo.getJobresponsibility(comInfo.getJobTitle(id)));
String propValue = new BaseBean().getPropValue("hrmOrganization", "levelFieldId");
if (StringUtils.isNotEmpty(levelValue)) {
rs.executeQuery("select selectname from cus_selectitem where fieldid = ? and selectvalue = ?",propValue,levelValue);
if (rs.next()) {
chartPO.setLevel(Util.null2String(rs.getString("selectname")));
}
}
try {
chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId()));
} catch (Exception e) {
@ -385,6 +532,8 @@ public class ChartServiceImpl extends Service implements ChartService {
return chartPO;
}
/**
* sql
*
@ -470,22 +619,66 @@ public class ChartServiceImpl extends Service implements ChartService {
RecordSet rs = new RecordSet();
List<CompanyTreePO> departmentTree = new ArrayList<>();
List<CompanyTreePO> topDepartmentTree = new ArrayList<>();
String subCompany = Util.null2String(params.get("subcompany"));
String dimension = Util.null2String(params.get("fclass"));
String versionId = Util.null2String(params.get("id"));
if (StringUtils.isBlank(subCompany)) {
subCompany = "0";
}
String sql = getDepartmentTreeSql(versionId, dimension, subCompany);
DBType dbType = DBType.get(new RecordSet().getDBType());
// 根据分部查询顶级部门
String sql = "select id as id, id as value, departmentname as title, subcompanyid1 as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and (supdepid is null or supdepid =0) and" + dbType.ifNull("subcompanyid1", "0") + " = " + subCompany;
rs.executeQuery(sql);
while (rs.next()) {
departmentTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).disabled(!rs.getString("id").startsWith("d")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(versionId, dimension, rs.getString("id"))).build());
topDepartmentTree.add(
CompanyTreePO.builder()
.id(rs.getString("id"))
.pId(rs.getString("pId"))
.disabled(false)
.value(rs.getString("value"))
.title(rs.getString("title"))
.isLeaf(false)
//.isLeaf(judgeTreeLeaf(versionId, dimension, rs.getString("id")))
.level(1)
.build()
);
}
if (CollectionUtils.isNotEmpty(topDepartmentTree)) {
sql = "select id as id, id as value, departmentname as title, supdepid as pId from hrmdepartmentvirtual where (canceled is null or canceled != '1') and " + dbType.ifNull("supdepid", "0") + " = ?";
for (CompanyTreePO department : topDepartmentTree) {
getChildDepartment(department, sql, departmentTree);
}
}
result.put("departmentTree", departmentTree);
result.put("api_status", true);
return result;
}
private void getChildDepartment(CompanyTreePO parentDepartment, String sql, List<CompanyTreePO> departmentTree) {
RecordSet rs = new RecordSet();
rs.executeQuery(sql, parentDepartment.getId());
int depth=1;
while (rs.next()) {
CompanyTreePO build = CompanyTreePO.builder()
.id(rs.getString("id"))
.pId(rs.getString("pId"))
.disabled(false)
.value(rs.getString("value"))
.title(rs.getString("title"))
.level(parentDepartment.getLevel() + 1)
.isLeaf(true)
.build();
getChildDepartment(build, sql, departmentTree);
parentDepartment.setLeaf(false);
depth = build.getDepth()+1;
}
parentDepartment.setDepth(depth);
departmentTree.add(parentDepartment);
}
@Override
public Map<String, Object> getMovingTree(Map<String, Object> params) {
RecordSet rs = new RecordSet();
@ -1261,7 +1454,7 @@ public class ChartServiceImpl extends Service implements ChartService {
* @param dimension ID
* @return SQL
*/
private String getRealTimeTopSql(String root, String dimension) {
private String getRealTimeTopSql(String root, String dimension,String department) {
if ("0".equals(root)) {
// 查询集团数据
if (isRealDimension) {
@ -1280,7 +1473,8 @@ public class ChartServiceImpl extends Service implements ChartService {
}
} else {
return "select a.id,a.subcompanyname as name,'1' as type,b.on_job_num,b.staff_num from " + SUB_COMPANY_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=1 where a.id = '" + root + "' order by a.showorder,a.id";
//return "select a.id,a.subcompanyname as name,'1' as type,b.on_job_num,b.staff_num from " + SUB_COMPANY_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=1 where a.id = '" + root + "' order by a.showorder,a.id";
return "select a.id,a.departmentname as name,'2' as type,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where a.id = '" + department + "' order by a.showorder,a.id";
}
}
}
@ -1320,14 +1514,14 @@ public class ChartServiceImpl extends Service implements ChartService {
if (hasVirtualFields) {
if (showVirtual) {
sql = "select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,showorder,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 where (a.canceled is null or a.canceled != '1') and a.supsubcomid = '" + fObjId + "'" +
" union select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and subcompanyid1 = '" + fObjId + "'";
" union select a.id,a.departmentmark as name,'2' as type ,b.bmlx as isvitual,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and subcompanyid1 = '" + fObjId + "'";
} else {
sql = "select a.id,a.subcompanyname as name,'1' as type ,b.fblx as isvitual,showorder,c.on_job_num,c.staff_num from " + SUB_COMPANY_TABLE + " a left join " + SUB_COMPANY_DEFINED_TABLE + " b on a.id = b.subcomid left join jcl_org_onjob c on a.id=c.data_id and c.type=1 where (a.canceled is null or a.canceled != '1') and (b.fblx is null or b.fblx != '1') and a.supsubcomid = '" + fObjId + "'" +
" union select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,showorder,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join " + DEPARTMENT_DEFINED_TABLE + " b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (a.canceled is null or a.canceled != '1') and (a.supdepid is null or a.supdepid = '0') and (b.bmlx is null or b.bmlx != '1') and subcompanyid1 = '" + fObjId + "'";
}
} else {
sql = "select a.id,a.subcompanyname as name,'1' as type,showorder,b.on_job_num,b.staff_num from " + SUB_COMPANY_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=1 where (canceled is null or canceled != '1') and supsubcomid = '" + fObjId + "'" +
" union select a.id,a.departmentname as name,'2' as type,showorder,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'";
" union select a.id,a.departmentmark as name,'2' as type,showorder,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where (canceled is null or canceled != '1') and (supdepid is null or supdepid = '0') and subcompanyid1 = '" + fObjId + "'";
}
break;
case "2":
@ -1338,7 +1532,7 @@ public class ChartServiceImpl extends Service implements ChartService {
sql = "select a.id,a.departmentname as name,'2' as type ,b.bmlx as isvitual,c.on_job_num,c.staff_num from " + DEPARTMENT_TABLE + " a left join hrmdepartmentdefined b on a.id = b.deptid left join jcl_org_onjob c on a.id=c.data_id and c.type=2 where (canceled is null or canceled != '1') and (b.bmlx is null or b.bmlx != '1') and a.supdepid = '" + fObjId + "'";
}
} else {
sql = "select a.id,a.departmentname as name,'2' as type,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'";
sql = "select a.id,a.departmentmark as name,'2' as type,b.on_job_num,b.staff_num from " + DEPARTMENT_TABLE + " a left join jcl_org_onjob b on a.id=b.data_id and b.type=2 where (canceled is null or canceled != '1') and supdepid = '" + fObjId + "'";
}
break;
default:
@ -1439,10 +1633,16 @@ public class ChartServiceImpl extends Service implements ChartService {
chartPO.setFisvitual(recordSet.getString("isvitual"));
chartPO.setHasChildren(getHasChildren(chartPO.getFtype(), chartPO.getFobjid()).toString());
chartPO.setDepartmentDepth(getDepartmentDepth(chartPO, topChartPO));
//顺胜二开 虚拟维度部门颜色设置
if (!isRealDimension && "2".equals(chartPO.getFtype())){
ChartDepartmentModeVO departmentModeVO = selectModeInfo(recordSet.getString("id"));
chartPO.setColorCheck(departmentModeVO.getColorCheck());
chartPO.setFleader(departmentModeVO.getLeaderName());
chartPO.setJobType(departmentModeVO.getJobType());
}
// 小于、等于所选层级元素展开
chartPO.setExpand(inDepth(selectDepth, chartPO.getDepartmentDepth()) ? "1" : "0");
filterAndAddData(currentList, chartPO, hideDepartment);
//currentList.add(chartPO);
}
@ -1585,7 +1785,11 @@ public class ChartServiceImpl extends Service implements ChartService {
if (selectDepth == 1) {
return true;
}
return currentDepth < selectDepth + 1;
if(isRealDimension) {
return currentDepth < selectDepth + 1;
}
return currentDepth < selectDepth;
}
/**
@ -1697,7 +1901,66 @@ public class ChartServiceImpl extends Service implements ChartService {
return;
}
}
currentList.add(chartPO);
}
/**
* uf_xnbmfzr
* @param departmentId
* @return
*/
@SneakyThrows
private ChartDepartmentModeVO selectModeInfo(String departmentId) {
RecordSet rs = new RecordSet();
ResourceComInfo com = new ResourceComInfo();
int colorCheck = 1;
String leaderId = "";
String leaderName = "";
String jobType = "";
rs.executeQuery("select bmfzrid,bjtp,rzlx from uf_xnbmfzr where xnzzid = ?",departmentId);
if (rs.next()){
colorCheck = Util.getIntValue(rs.getString("bjtp"),1);
leaderId = Util.null2String(rs.getString("bmfzrid"));
leaderName = com.getLastname(leaderId);
jobType = Util.null2String(rs.getString("rzlx"));
}
if (StringUtils.isNotEmpty(jobType)) {
String propValue = new BaseBean().getPropValue("hrmOrganization", "jobTypeField");
rs.executeQuery("select selectname from workflow_selectitem where fieldid = ? and selectvalue = ?",propValue,jobType);
if (rs.next()) {
jobType = Util.null2String(rs.getString("selectname"));
}
}
return ChartDepartmentModeVO.builder()
.leaderId(leaderId)
.leaderName(leaderName)
.colorCheck(colorCheck)
.jobType(jobType)
.build();
}
/**
* showorder
* @return
*/
private Map<String,String> getRootAndFclass(){
Map<String,String> map = new HashMap<>();
RecordSet rs = new RecordSet();
String fclass = "0";
rs.executeQuery("select id from HrmCompanyVirtual order by showorder asc");
if(rs.next()) {
fclass = Util.null2String(rs.getString("id"));
map.put("fclass",fclass);
}
rs.executeQuery("select id from hrmsubcompanyvirtual where companyid = ? order by showorder asc",fclass);
if (rs.next()) {
map.put("root",Util.null2String(rs.getString("id")));
}
return map;
}
}

@ -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;
@ -9,6 +10,7 @@ import com.api.hrm.util.HrmFieldSearchConditionComInfo;
import com.cloudstore.eccom.constant.WeaBoolAttr;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrm.util.face.HrmFaceCheckManager;
import com.engine.organization.component.OrganizationWeaTable;
@ -52,6 +54,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 +64,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 +73,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 +494,41 @@ 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);
String sql = "";
//v4 汇报关系类型获取
rs.executeQuery("select hbgxlx from uf_wdlj where wd = ?",dimension);
rs.next();
String hbgxlx = Util.null2String(rs.getString("hbgxlx"));
if ("".equals(hbgxlx)) {
//不显示人员
sql = "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 = 99999";
}else if ("0".equals(hbgxlx)){
//直接上级
List<Integer> allSubDepartment = getAllSubDepartment(String.valueOf(departmentId));
String join = CollectionUtil.join(allSubDepartment, ",");
sql = "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+")";
}else if ("1".equals(hbgxlx)) {
//专业上级
List<Integer> allSubDepartment = getAllSubDepartment(String.valueOf(departmentId));
String join = CollectionUtil.join(allSubDepartment, ",");
sql = "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+")";
}else if ("2".equals(hbgxlx)) {
//仅展示本部门
sql = "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 ="+departmentId;
}
rs.executeQuery(sql, dimension);
while (rs.next()) {
ResourceChartPO build = ResourceChartPO.builder()
.id((long) Util.getIntValue(rs.getString("id")))
@ -508,6 +544,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
resourceChartPOS.add(build);
}
resourceChartVOS = ResourceChartBO.convertToVO(resourceChartPOS);
//虚拟维度去重
Map<Long, ResourceChartVO> map = resourceChartVOS.stream()
.collect(Collectors.toMap(ResourceChartVO::getId,
resourceChartVO -> resourceChartVO,
(existing, replacement) -> existing));
resourceChartVOS = new ArrayList<>(map.values());
}
dataMap.put("columns", resourceListColumns);
@ -1343,4 +1386,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
return selectKeys;
}
@Override
public List<Integer> getAllSubDepartment(String departmentId){
DepartmentVirtualComInfo comInfo = new DepartmentVirtualComInfo();
ArrayList subList = new ArrayList();
comInfo.getAllChildDeptByDepId(subList, departmentId);
subList.add(departmentId);
return subList;
}
}

@ -41,44 +41,42 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
public Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user) {
Map<String, Object> result = new HashMap<>();
RecordSet rs = new RecordSet();
Map<String, Object> defaultItem = new HashMap<>();
Map<String, Object> defaultItem = new HashMap<>(4);
rs.executeQuery("select companyname from hrmcompany");
rs.next();
int fkey = 0;
defaultItem.put("key", fkey++);
defaultItem.put("id", "0");
defaultItem.put("companyname", Util.null2String(rs.getString("companyname")));
rs.executeQuery("select id, companyname from HrmCompanyVirtual order by id");
rs.executeQuery("select id, companyname,showorder from HrmCompanyVirtual order by id");
List<Map<String, Object>> fclasslist = new ArrayList<>();
fclasslist.add(defaultItem);
while (rs.next()) {
Map<String, Object> item = new HashMap<>();
Map<String, Object> item = new HashMap<>(4);
item.put("key", fkey++);
item.put("id", rs.getString("id"));
item.put("companyname", rs.getString("companyname"));
float showorder = Util.getFloatValue(rs.getString("showorder"));
item.put("showorder", (int) showorder);
fclasslist.add(item);
}
List<CompanyTreePO> companyTree = new ArrayList<>();
String sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '0'";
// 一级分部数据分权处理
String dimension = Util.null2String(request2Map.get("fclass"));
//版本id
String id = Util.null2String(request2Map.get("id"));
boolean isRealDimension = StringUtils.isBlank(dimension) || "0".equals(dimension);
boolean isRealTime = StringUtils.isBlank(id) || "0".equals(id);
if (isRealTime && user.getUID() != 1 && isRealDimension) {
DetachUtil detachUtil = new DetachUtil(user);
if(detachUtil.isDETACH()) {
String ids = detachUtil.getJclRoleLevels();
sql = sql + " and id in (" + ids + ")";
}
}
Optional<Map<String, Object>> minCompany = fclasslist.stream()
.filter(map -> map.containsKey("showorder"))
.min(Comparator.comparingInt(map -> (int) map.get("showorder")));
minCompany.ifPresent(map -> result.put("fclass", map.get("id")));
Map<String, Object> params = new HashMap<>(2);
params.put("fclass",result.get("fclass"));
Map<String, Object> subCompanyTree = getSubCompanyTree(params);
List<CompanyTreePO> companyTree = (List<CompanyTreePO>)subCompanyTree.get("companyTree");
Optional<CompanyTreePO> minElement = companyTree.stream()
.min(Comparator.comparingInt(CompanyTreePO::getShoworder));
minElement.ifPresent(companyTreePO -> result.put("root",companyTreePO.getId()));
rs.executeQuery(sql);
while (rs.next()) {
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf("select id from hrmsubcompany where (canceled is null or canceled != '1') and supsubcomid = ?", rs.getString("id"))).build());
}
result.put("api_status", true);
result.put("fclasslist", fclasslist);
result.put("companyTree", companyTree);
@ -116,7 +114,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
}
if (StringUtils.isNotBlank(fclass) && !"0".equals(fclass)) {
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = ? and companyid = '" + fclass + "'";
sql = "select id as id, id as value, subcompanyname as title, supsubcomid as pId,showorder from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = ? and companyid = '" + fclass + "'";
}
} else {
sql = "select subcompanyid as id, id as value, subcompanyname as title, supsubcompanyid as pId from jcl_chart_subcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcompanyid", "0") + " = ? ";
@ -129,8 +127,11 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
}
rs.executeQuery(sql, subcompany);
while (rs.next()) {
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(judgeTreeLeafSql, rs.getString("id"))).build());
float showorder = Util.getFloatValue(rs.getString("showorder"));
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).isLeaf(judgeTreeLeaf(judgeTreeLeafSql, rs.getString("id"))).showorder((int)showorder).build());
}
result.put("companyTree", companyTree);
return result;
}

Loading…
Cancel
Save