|
|
@ -2,6 +2,7 @@ package com.engine.jhsecond.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.jhsecond.entity.vo.OrganizationChartVo;
|
|
|
|
import com.engine.jhsecond.entity.vo.OrganizationChartVo;
|
|
|
|
|
|
|
|
import com.engine.jhsecond.entity.vo.PersonInfoVo;
|
|
|
|
import com.engine.jhsecond.service.OrganizationChartService;
|
|
|
|
import com.engine.jhsecond.service.OrganizationChartService;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
import weaver.general.BaseBean;
|
|
|
@ -9,10 +10,7 @@ import weaver.general.Util;
|
|
|
|
import weaver.hrm.company.DepartmentComInfo;
|
|
|
|
import weaver.hrm.company.DepartmentComInfo;
|
|
|
|
import weaver.hrm.job.JobTitlesComInfo;
|
|
|
|
import weaver.hrm.job.JobTitlesComInfo;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -36,7 +34,7 @@ public class OrganizationChartServiceImpl extends Service implements Organizatio
|
|
|
|
String superId = bb.getPropValue("jhsecond", "superId");
|
|
|
|
String superId = bb.getPropValue("jhsecond", "superId");
|
|
|
|
String halfNodeId = bb.getPropValue("jhsecond", "halfNodeId");
|
|
|
|
String halfNodeId = bb.getPropValue("jhsecond", "halfNodeId");
|
|
|
|
|
|
|
|
|
|
|
|
//1.获取当前有效人员数据 todo 正式去除分部参数
|
|
|
|
//1.获取当前有效人员数据
|
|
|
|
rs.executeQuery("select a.id,a.departmentid,a.lastname,a.jobtitle,a.resourceimageid,b."+superId+",b."+halfNodeId+" from " +
|
|
|
|
rs.executeQuery("select a.id,a.departmentid,a.lastname,a.jobtitle,a.resourceimageid,b."+superId+",b."+halfNodeId+" from " +
|
|
|
|
" hrmresource a left join cus_fielddata b on a.id = b.id and b.scopeid = 3 where status < 4");
|
|
|
|
" hrmresource a left join cus_fielddata b on a.id = b.id and b.scopeid = 3 where status < 4");
|
|
|
|
|
|
|
|
|
|
|
@ -71,7 +69,59 @@ public class OrganizationChartServiceImpl extends Service implements Organizatio
|
|
|
|
//4.递归处理
|
|
|
|
//4.递归处理
|
|
|
|
buildHierarchy(voList,parentNode);
|
|
|
|
buildHierarchy(voList,parentNode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.put("result",parentNode);
|
|
|
|
|
|
|
|
data.put("halfResult",filteredList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Map<String, Object> selectChart(Map<String, Object> request2Map) {
|
|
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
Map<String,Object> data = new HashMap<>(4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String topId = bb.getPropValue("jhsecond", "topId");
|
|
|
|
|
|
|
|
String halfId = bb.getPropValue("jhsecond", "halfId");
|
|
|
|
|
|
|
|
String jobId = bb.getPropValue("jhsecond", "jobId");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//1.获取建模组织架构图数据
|
|
|
|
|
|
|
|
rs.executeQuery("select a.gwszbm,a.zzjggw,b.zzjgtgw,a.zzjggwsj,a.sfbj,a.gjsx,a.sfycx from uf_zzjgdygx a left join uf_zzjggw b on a.zzjggw = b.id");
|
|
|
|
|
|
|
|
List<OrganizationChartVo> voList = new ArrayList<>();
|
|
|
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
|
|
|
PersonInfoVo personInfoVo = selectPersonInfo(Util.null2String(rs.getString("zzjggw")), jobId);
|
|
|
|
|
|
|
|
OrganizationChartVo build = OrganizationChartVo.builder()
|
|
|
|
|
|
|
|
.id(Util.getIntValue(rs.getString("zzjggw")))
|
|
|
|
|
|
|
|
.deptName(Util.null2String(rs.getString("gwszbm")))
|
|
|
|
|
|
|
|
.lastName(personInfoVo.getLastName())
|
|
|
|
|
|
|
|
.jobName(Util.null2String(rs.getString("zzjgtgw")))
|
|
|
|
|
|
|
|
.photoUrl(personInfoVo.getPhotoUrl())
|
|
|
|
|
|
|
|
.pId(Util.getIntValue(rs.getString("zzjggwsj")))
|
|
|
|
|
|
|
|
.orderId(Util.getIntValue(rs.getString("gjsx"),999))
|
|
|
|
|
|
|
|
.addLine("0".equals(Util.null2String(rs.getString("sfycx"))) ? "true" : "false")
|
|
|
|
|
|
|
|
.type("0".equals(Util.null2String(rs.getString("sfbj"))) ? "tag" : "")
|
|
|
|
|
|
|
|
.show(personInfoVo.getLastName() == null ? 1 : 0)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
voList.add(build);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//2.筛选出顶部节点
|
|
|
|
|
|
|
|
OrganizationChartVo parentNode = voList.stream()
|
|
|
|
|
|
|
|
.filter(vo -> vo.getId() == Integer.parseInt(topId))
|
|
|
|
|
|
|
|
.findFirst()
|
|
|
|
|
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3.设置半节点存在下级属性值并获取下级
|
|
|
|
|
|
|
|
voList.stream()
|
|
|
|
|
|
|
|
.filter(vo -> vo.getId() == Integer.parseInt(halfId))
|
|
|
|
|
|
|
|
.forEach(vo -> vo.setHalfType("true"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<OrganizationChartVo> filteredList = voList.stream()
|
|
|
|
|
|
|
|
.filter(vo -> vo.getPId() != null && vo.getPId() == Integer.parseInt(halfId))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//4.递归处理
|
|
|
|
|
|
|
|
buildHierarchyChart(voList,parentNode);
|
|
|
|
|
|
|
|
|
|
|
|
data.put("result",parentNode);
|
|
|
|
data.put("result",parentNode);
|
|
|
|
data.put("halfResult",filteredList);
|
|
|
|
data.put("halfResult",filteredList);
|
|
|
@ -79,6 +129,39 @@ public class OrganizationChartServiceImpl extends Service implements Organizatio
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void buildHierarchyChart(List<OrganizationChartVo> list, OrganizationChartVo parentNode) {
|
|
|
|
|
|
|
|
List<OrganizationChartVo> children = list.stream()
|
|
|
|
|
|
|
|
.filter(vo -> vo.getPId().equals(parentNode.getId()))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//排序处理
|
|
|
|
|
|
|
|
children = children.stream()
|
|
|
|
|
|
|
|
.sorted(Comparator.comparingInt(OrganizationChartVo::getOrderId))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (OrganizationChartVo child : children) {
|
|
|
|
|
|
|
|
buildHierarchyChart(list, child);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parentNode.setChildren(children);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private PersonInfoVo selectPersonInfo(String zzjggw, String jobId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PersonInfoVo personInfo = new PersonInfoVo();
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
//rs.getDBType().equals("")
|
|
|
|
|
|
|
|
rs.executeQuery("select a.id,a."+jobId+",b.lastname,b.resourceimageid from cus_fielddata a left join hrmresource b on a.id = b.id \n" +
|
|
|
|
|
|
|
|
" and a.scopeid = 3 where b.status < 4 and a."+jobId+" = ?",zzjggw);
|
|
|
|
|
|
|
|
if (rs.next()) {
|
|
|
|
|
|
|
|
personInfo.setLastName(Util.null2String(rs.getString("lastname")));
|
|
|
|
|
|
|
|
personInfo.setPhotoUrl(getPhotoUrl(Util.null2String(rs.getString("resourceimageid"))));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return personInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 递归处理
|
|
|
|
* 递归处理
|
|
|
|
* @param list
|
|
|
|
* @param list
|
|
|
@ -96,6 +179,8 @@ public class OrganizationChartServiceImpl extends Service implements Organizatio
|
|
|
|
parentNode.setChildren(children);
|
|
|
|
parentNode.setChildren(children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 部门名称
|
|
|
|
* 部门名称
|
|
|
|
* @param departmentId
|
|
|
|
* @param departmentId
|
|
|
|