上海中远重工组织架构图开发
parent
6154ece836
commit
fca321abeb
@ -0,0 +1,25 @@
|
||||
package com.engine.organization.entity.chart.params;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/4/24 2:04 PM
|
||||
* @Description: TODO
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class ModeHrmResourceParam {
|
||||
|
||||
private String departmentId;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.chart.params.ModeHrmResourceParam;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/4/24 2:00 PM
|
||||
* @Description: 上海中远重工建模人员档案
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface ModeHrmResourceService {
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 列表人员
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2024/4/24 2:05 PM
|
||||
* @param: [modeHrmResourceParam]
|
||||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
Map<String, Object> chartResourceList(ModeHrmResourceParam modeHrmResourceParam);
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 架构图人员
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2024/4/24 2:06 PM
|
||||
* @param: [modeHrmResourceParam]
|
||||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
Map<String, Object> chartResourceChart(ModeHrmResourceParam modeHrmResourceParam);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,277 @@
|
||||
package com.engine.organization.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.chart.ChartPO;
|
||||
import com.engine.organization.entity.chart.ResourceListColumns;
|
||||
import com.engine.organization.entity.chart.params.ModeHrmResourceParam;
|
||||
import com.engine.organization.entity.hrmresource.po.ResourceChartPO;
|
||||
import com.engine.organization.entity.hrmresource.vo.ResourceChartVO;
|
||||
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
|
||||
import com.engine.organization.service.ModeHrmResourceService;
|
||||
import com.engine.organization.util.db.MapperProxyFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.company.DepartmentComInfo;
|
||||
import weaver.hrm.company.SubCompanyComInfo;
|
||||
import weaver.hrm.resource.ResourceComInfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2024/4/24 2:01 PM
|
||||
* @Description: uf_zsygrzbdd 正式员工档案 uf_qlwbrydngljmb 外部人员档案
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ModeHrmResourceServiceImpl extends Service implements ModeHrmResourceService {
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> chartResourceList(ModeHrmResourceParam param) {
|
||||
Map<String, Object> dataMap = new HashMap<>(4);
|
||||
List<ResourceListColumns> resourceListColumns = getTableColumns();
|
||||
List<Integer> allSupDepartment = getAllSupDepartment(param.getDepartmentId());
|
||||
List<ResourceChartPO> resourceChartPOS = new ArrayList<>();
|
||||
|
||||
resourceChartPOS.addAll(selectNbPerson(allSupDepartment));
|
||||
resourceChartPOS.addAll(selectWbPerson(allSupDepartment));
|
||||
|
||||
|
||||
List<ResourceChartVO> resourceChartVOS = convertToVO(resourceChartPOS);
|
||||
dataMap.put("columns", resourceListColumns);
|
||||
dataMap.put("dataSource", resourceChartVOS);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> chartResourceChart(ModeHrmResourceParam param) {
|
||||
List<ChartPO> dataList = new ArrayList<>();
|
||||
String departmentId = param.getDepartmentId();
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select a.id,a.departmentname as name,b.bmfzr\n" +
|
||||
"from hrmdepartment a left join hrmdepartmentdefined b on a.id = b.deptid \n" +
|
||||
"where a.id = ?",param.getDepartmentId());
|
||||
|
||||
//部门
|
||||
ChartPO departmentChartPO = new ChartPO();
|
||||
if (rs.next()) {
|
||||
String fLeader = Util.null2String(rs.getString("bmfzr"));
|
||||
departmentChartPO.setFtype("2");
|
||||
departmentChartPO.setFobjid(departmentId);
|
||||
departmentChartPO.setExpand("1");
|
||||
departmentChartPO.setId("d_"+departmentId);
|
||||
departmentChartPO.setFname(rs.getString("name"));
|
||||
departmentChartPO.setFleader(getDepartmentLeader(fLeader));
|
||||
try {
|
||||
departmentChartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(fLeader));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//人员
|
||||
List<Integer> allSupDepartment = getAllSupDepartment(param.getDepartmentId());
|
||||
List<ResourceChartPO> resourceChartPOS = new ArrayList<>();
|
||||
resourceChartPOS.addAll(selectNbPerson(allSupDepartment));
|
||||
resourceChartPOS.addAll(selectWbPerson(allSupDepartment));
|
||||
List<ResourceChartVO> resourceChartVOS = convertToVO(resourceChartPOS);
|
||||
|
||||
resourceChartVOS.forEach(item -> {
|
||||
ChartPO chartPO = getResourceChartPO(item,departmentChartPO.getId());
|
||||
dataList.add(chartPO);
|
||||
});
|
||||
|
||||
|
||||
|
||||
departmentChartPO.setFonjob(resourceChartVOS.size());
|
||||
dataList.add(departmentChartPO);
|
||||
|
||||
|
||||
Map<String, Object> result = new HashMap<>(4);
|
||||
result.put("api_status", true);
|
||||
result.put("data", dataList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 正式员工
|
||||
* @param allSupDepartment
|
||||
* @return
|
||||
*/
|
||||
private List<ResourceChartPO> selectNbPerson(Collection<Integer> allSupDepartment) {
|
||||
RecordSet rs = new RecordSet();
|
||||
List<ResourceChartPO> resourceChartPOS = new ArrayList<>();
|
||||
String join = CollectionUtil.join(allSupDepartment, ",");
|
||||
rs.executeQuery("select id, gh,xm,xb,bm,gw,sjhm from uf_zsygrzbdd where bm in ("+join+")");
|
||||
while (rs.next()) {
|
||||
ResourceChartPO build = ResourceChartPO.builder()
|
||||
.id((long) Util.getIntValue(rs.getString("id")))
|
||||
.workCode(Util.null2String(rs.getString("gh")))
|
||||
.lastName(Util.null2String(rs.getString("xm")))
|
||||
.sex(Util.null2String(rs.getString("xb")))
|
||||
.departmentId(Util.getIntValue(rs.getString("bm")))
|
||||
.jobBrowser(Util.null2String(rs.getString("gw")))
|
||||
.mobile(Util.null2String(rs.getString("sjhm")))
|
||||
.build();
|
||||
resourceChartPOS.add(build);
|
||||
}
|
||||
|
||||
return resourceChartPOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部员工
|
||||
* @param allSupDepartment
|
||||
* @return
|
||||
*/
|
||||
private List<ResourceChartPO> selectWbPerson(Collection<Integer> allSupDepartment) {
|
||||
RecordSet rs = new RecordSet();
|
||||
List<ResourceChartPO> resourceChartPOS = new ArrayList<>();
|
||||
String join = CollectionUtil.join(allSupDepartment, ",");
|
||||
rs.executeQuery("select id, gh,xm,xb,bmbz,gw,lxfs from uf_qlwbrydngljmb where bmbz in ("+join+")");
|
||||
while (rs.next()) {
|
||||
ResourceChartPO build = ResourceChartPO.builder()
|
||||
.id((long) Util.getIntValue(rs.getString("id")))
|
||||
.workCode(Util.null2String(rs.getString("gh")))
|
||||
.lastName(Util.null2String(rs.getString("xm")))
|
||||
.sex(Util.null2String(rs.getString("xb")))
|
||||
.departmentId(Util.getIntValue(rs.getString("bmbz")))
|
||||
.jobBrowser(Util.null2String(rs.getString("gw")))
|
||||
.mobile(Util.null2String(rs.getString("lxfs")))
|
||||
.build();
|
||||
resourceChartPOS.add(build);
|
||||
}
|
||||
|
||||
return resourceChartPOS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 列表表头
|
||||
* @return
|
||||
*/
|
||||
private List<ResourceListColumns> getTableColumns() {
|
||||
List<ResourceListColumns> list = new ArrayList<>();
|
||||
list.add(ResourceListColumns.builder().title("序号").dataIndex("id").key("id").build());
|
||||
list.add(ResourceListColumns.builder().title("工号").dataIndex("workCode").key("workCode").build());
|
||||
list.add(ResourceListColumns.builder().title("姓名").dataIndex("lastName").key("lastName").build());
|
||||
list.add(ResourceListColumns.builder().title("性别").dataIndex("sex").key("sex").build());
|
||||
list.add(ResourceListColumns.builder().title("部门").dataIndex("departmentName").key("departmentName").build());
|
||||
list.add(ResourceListColumns.builder().title("分部").dataIndex("subcompanyName").key("subcompanyName").build());
|
||||
list.add(ResourceListColumns.builder().title("岗位").dataIndex("jobTitle").key("jobTitle").build());
|
||||
list.add(ResourceListColumns.builder().title("手机号").dataIndex("mobile").key("mobile").build());
|
||||
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有子部门和当前部门集合
|
||||
* @param departmentId
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
private List<Integer> getAllSupDepartment(String departmentId){
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
ArrayList subList = new ArrayList();
|
||||
departmentComInfo.getAllChildDeptByDepId(subList, departmentId);
|
||||
subList.add(departmentId);
|
||||
|
||||
return subList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换
|
||||
* @param resourceChartPOS
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
private List<ResourceChartVO> convertToVO(List<ResourceChartPO> resourceChartPOS) {
|
||||
List<ResourceChartVO> resourceChartVOS = new ArrayList<>();
|
||||
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
|
||||
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
|
||||
for (ResourceChartPO item : resourceChartPOS) {
|
||||
ResourceChartVO resourceChartVO = new ResourceChartVO();
|
||||
String departmentId =String.valueOf(item.getDepartmentId());
|
||||
String subCompanyname = subCompanyComInfo.getSubCompanyname(departmentComInfo.getSubcompanyid1(departmentId));
|
||||
|
||||
resourceChartVO.setId(item.getId());
|
||||
resourceChartVO.setWorkCode(item.getWorkCode());
|
||||
resourceChartVO.setLastName(item.getLastName());
|
||||
resourceChartVO.setSex("1".equals(item.getSex()) ? "女" : "男");
|
||||
resourceChartVO.setDepartmentName(departmentComInfo.getDepartmentName(departmentId));
|
||||
resourceChartVO.setSubcompanyName(subCompanyname);
|
||||
resourceChartVO.setJobTitle(getJobBrowserName(item.getJobBrowser()));
|
||||
resourceChartVO.setStatus(item.getStatus());
|
||||
resourceChartVO.setMobile(item.getMobile());
|
||||
resourceChartVOS.add(resourceChartVO);
|
||||
}
|
||||
return resourceChartVOS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义岗位名称
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
private String getJobBrowserName(String code){
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select gwmc from uf_gwmc where gwbm = ?",code);
|
||||
rs.next();
|
||||
return Util.null2String(rs.getString("gwmc"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门负责人
|
||||
*
|
||||
* @param ids 部门负责人ID
|
||||
* @return 人员名称
|
||||
*/
|
||||
private String getDepartmentLeader(String ids) {
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
return "";
|
||||
}
|
||||
List<String> leaderList = new ArrayList<>();
|
||||
String[] split = ids.split(",");
|
||||
for (String s : split) {
|
||||
String lastName = MapperProxyFactory.getProxy(SystemDataMapper.class).getScHrmResourceNameById(s);
|
||||
if (StringUtils.isNotBlank(lastName)) {
|
||||
leaderList.add(lastName);
|
||||
}
|
||||
}
|
||||
return StringUtils.join(leaderList, ",");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建人员图谱元素
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
private ChartPO getResourceChartPO(ResourceChartVO item,String parentId) {
|
||||
ChartPO chartPO = new ChartPO();
|
||||
chartPO.setFtype("4");
|
||||
chartPO.setFobjid(String.valueOf(item.getId()));
|
||||
chartPO.setId(chartPO.getFobjid());
|
||||
chartPO.setFname(item.getLastName());
|
||||
chartPO.setParentId(parentId);
|
||||
chartPO.setLocalDeptName(item.getDepartmentName());
|
||||
chartPO.setJobTitle(item.getJobTitle());
|
||||
chartPO.setExpand("1");
|
||||
chartPO.setHasChildren("0");
|
||||
try {
|
||||
chartPO.setFleaderimg(new ResourceComInfo().getMessagerUrls(chartPO.getId()));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return chartPO;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue