|
|
|
@ -1,8 +1,22 @@
|
|
|
|
|
package com.engine.sship.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.service.HrmCommonService;
|
|
|
|
|
import com.engine.common.service.impl.HrmCommonServiceImpl;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.sship.entity.ChartChildrensVO;
|
|
|
|
|
import com.engine.sship.entity.*;
|
|
|
|
|
import com.engine.sship.service.OrgChartService;
|
|
|
|
|
import com.weaver.general.BaseBean;
|
|
|
|
|
import com.weaver.general.Util;
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.hrm.company.DepartmentComInfo;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -13,9 +27,192 @@ import com.engine.sship.service.OrgChartService;
|
|
|
|
|
*/
|
|
|
|
|
public class OrgChartServiceImpl extends Service implements OrgChartService {
|
|
|
|
|
|
|
|
|
|
private HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean selectIdsByRole(String roleId,String rolelevel) {
|
|
|
|
|
String roleMemberIds = hrmCommonService.getRoleMemberIds(roleId, rolelevel);
|
|
|
|
|
List<String> roleMemberList = Arrays.stream(roleMemberIds.split(","))
|
|
|
|
|
.filter(s -> !s.isEmpty())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
return roleMemberList.stream()
|
|
|
|
|
.anyMatch(s -> Integer.parseInt(s) == user.getUID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TreeDataVO selectResourceChart() {
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
String roleId = bb.getPropValue("sship", "roleId");
|
|
|
|
|
String rolelevel = bb.getPropValue("sship", "rolelevel");
|
|
|
|
|
boolean isExsit = selectIdsByRole(roleId, rolelevel);
|
|
|
|
|
if (isExsit || (user.getUID() == 1)) {
|
|
|
|
|
return getAllTreeData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getBaseTreeData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ChartChildrensVO selectResourceChart() {
|
|
|
|
|
public List<Integer> selectCusSiteHead() {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
String fieldid = bb.getPropValue("sship", "fieldid");
|
|
|
|
|
List<Integer> ids = new ArrayList<>();
|
|
|
|
|
rs.executeQuery("select id from cus_fielddata where "+fieldid+" = 3 and scopeid = 3 and scope = 'HrmCustomFieldByInfoType'");
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
ids.add(Util.getIntValue(rs.getString("id")));
|
|
|
|
|
}
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
@Override
|
|
|
|
|
public List<PersonTableVO> selectPerson(PersonTableParam personTableParam) {
|
|
|
|
|
List<PersonTablePO> poList;
|
|
|
|
|
ResourceComInfo rInfo = new ResourceComInfo();
|
|
|
|
|
switch(personTableParam.getId()){
|
|
|
|
|
case "S-1":
|
|
|
|
|
poList = selectByLevel(5);
|
|
|
|
|
break;
|
|
|
|
|
case "C-1":
|
|
|
|
|
poList = selectByLevel(4);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
poList = selectByDeptId(personTableParam.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return poList.stream()
|
|
|
|
|
.map(po -> new PersonTableVO(po.getId(), po.getLastname(), po.getWorkcode(),
|
|
|
|
|
po.getSex() == 0 ? "男" : "女",
|
|
|
|
|
po.getManagerid() != null ? rInfo.getLastname(String.valueOf(po.getManagerid())) : "",
|
|
|
|
|
po.getLoginid()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<PersonTablePO> selectByLevel(Integer level) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
List<PersonTablePO> poList = new ArrayList<>();
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
//String fieldid = bb.getPropValue("sship.properties", "fieldid");
|
|
|
|
|
String fieldid = "field19";
|
|
|
|
|
rs.executeQuery("select h.id,h.lastname,h.workcode,h.sex,h.managerid,h.loginid from hrmresource h\n" +
|
|
|
|
|
" left join cus_fielddata c on h.id = c.id\n" +
|
|
|
|
|
" where c.scopeid = 3 and c.scope = 'HrmCustomFieldByInfoType' and c."+fieldid+" = ?",level);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
poList.add(
|
|
|
|
|
PersonTablePO.builder()
|
|
|
|
|
.id(Util.getIntValue(rs.getString("id")))
|
|
|
|
|
.lastname(Util.null2String(rs.getString("lastname")))
|
|
|
|
|
.workcode(Util.null2String(rs.getString("workcode")))
|
|
|
|
|
.sex(Util.getIntValue(rs.getString("sex")))
|
|
|
|
|
.managerid(Util.getIntValue(rs.getString("managerid")))
|
|
|
|
|
.loginid(Util.null2String(rs.getString("loginid")))
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return poList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<PersonTablePO> selectByDeptId(String id) {
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
List<PersonTablePO> poList = new ArrayList<>();
|
|
|
|
|
rs.executeQuery("select id,lastname,workcode,sex,managerid,loginid from hrmresource where status < 4 and departmentid = ?",id);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
poList.add(
|
|
|
|
|
PersonTablePO.builder()
|
|
|
|
|
.id(Util.getIntValue(rs.getString("id")))
|
|
|
|
|
.lastname(Util.null2String(rs.getString("lastname")))
|
|
|
|
|
.workcode(Util.null2String(rs.getString("workcode")))
|
|
|
|
|
.sex(Util.getIntValue(rs.getString("sex")))
|
|
|
|
|
.managerid(Util.getIntValue(rs.getString("managerid")))
|
|
|
|
|
.loginid(Util.null2String(rs.getString("loginid")))
|
|
|
|
|
.build()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return poList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取指定组织树
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private TreeDataVO getBaseTreeData() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取全量组织树
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private TreeDataVO getAllTreeData() {
|
|
|
|
|
//1.股东及委员会层级指定
|
|
|
|
|
ChartChildrensVO committee = ChartChildrensVO.builder().id("C-1")
|
|
|
|
|
.pid("S-1")
|
|
|
|
|
.label("Committee")
|
|
|
|
|
.childrens(getSiteHead())
|
|
|
|
|
.build();
|
|
|
|
|
List<ChartChildrensVO> committeeList = Collections.singletonList(committee);
|
|
|
|
|
|
|
|
|
|
return TreeDataVO.builder().id("S-1")
|
|
|
|
|
.label("Shareholder")
|
|
|
|
|
.childrens(committeeList)
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
private List<ChartChildrensVO> getSiteHead() {
|
|
|
|
|
List<Integer> idList = selectCusSiteHead();
|
|
|
|
|
List<ChartChildrensVO> siteHeadList = new ArrayList<>();
|
|
|
|
|
DepartmentComInfo dInfo = new DepartmentComInfo();
|
|
|
|
|
ResourceComInfo rInfo = new ResourceComInfo();
|
|
|
|
|
idList.forEach(item -> {
|
|
|
|
|
String departmentId = rInfo.getDepartmentID(String.valueOf(item));
|
|
|
|
|
ChartChildrensVO build = ChartChildrensVO.builder()
|
|
|
|
|
.id(departmentId)
|
|
|
|
|
.pid("C-1")
|
|
|
|
|
.label(dInfo.getDepartmentmark(departmentId))
|
|
|
|
|
.build();
|
|
|
|
|
boolean manager = hrmCommonService.isManager(item);
|
|
|
|
|
if (manager) {
|
|
|
|
|
build.setChildrens(recursionDepartment(item));
|
|
|
|
|
}
|
|
|
|
|
siteHeadList.add(build);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return siteHeadList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归获取
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
private List<ChartChildrensVO> recursionDepartment(Integer id) {
|
|
|
|
|
List<ChartChildrensVO> vos = new ArrayList<>();
|
|
|
|
|
DepartmentComInfo dInfo = new DepartmentComInfo();
|
|
|
|
|
ResourceComInfo rInfo = new ResourceComInfo();
|
|
|
|
|
String underling = hrmCommonService.getUnderling(id);
|
|
|
|
|
//获取直接下属
|
|
|
|
|
List<String> underList = Arrays.stream(underling.split(","))
|
|
|
|
|
.filter(s -> !s.isEmpty())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
underList.forEach(item -> {
|
|
|
|
|
String departmentId = rInfo.getDepartmentID(String.valueOf(item));
|
|
|
|
|
ChartChildrensVO build = ChartChildrensVO.builder()
|
|
|
|
|
.id(departmentId)
|
|
|
|
|
.pid(item)
|
|
|
|
|
.label(dInfo.getDepartmentmark(departmentId))
|
|
|
|
|
.build();
|
|
|
|
|
boolean manager = hrmCommonService.isManager(Integer.valueOf(item));
|
|
|
|
|
if (manager) {
|
|
|
|
|
build.setChildrens(recursionDepartment(Integer.valueOf(item)));
|
|
|
|
|
}
|
|
|
|
|
vos.add(build);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return vos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|