五院杭州中心 引入产品功能 岗位矩阵图接口

五院杭州中心
Chengliang 3 months ago
parent ddb6e038a2
commit 671df80a9c

@ -1,6 +1,6 @@
<component name="ArtifactManager"> <component name="ArtifactManager">
<artifact type="jar" name="weaver-develop:jar"> <artifact type="jar" name="weaver-develop:jar">
<output-path>$PROJECT_DIR$/out/artifacts/weaver_develop_jar</output-path> <output-path>$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib</output-path>
<root id="archive" name="weaver-develop.jar"> <root id="archive" name="weaver-develop.jar">
<element id="module-output" name="weaver-develop" /> <element id="module-output" name="weaver-develop" />
</root> </root>

@ -1,5 +0,0 @@
package com.api.wysecond.web;
public class PersonelResumeAction {
}

@ -0,0 +1,7 @@
package com.api.wysecond.web;
import javax.ws.rs.Path;
@Path("/wysecond/postion")
public class PostionMatrixAction extends com.engine.wysecond.web.PostionMatrixAction {
}

@ -0,0 +1,27 @@
package com.engine.wysecond.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.LinkedList;
/**
* @Author liang.cheng
* @Date 2025/2/27 13:44
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PeopleSums {
private String type;
private LinkedList<Integer> datas;
}

@ -0,0 +1,24 @@
package com.engine.wysecond.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2025/2/27 13:32
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PeoplesAndNames {
private Integer peoples;
private String names;
}

@ -0,0 +1,27 @@
package com.engine.wysecond.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2025/2/27 13:27
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Postion {
private String id;
private Integer postionType;
private String postionName;
}

@ -0,0 +1,29 @@
package com.engine.wysecond.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.LinkedList;
/**
* @Author liang.cheng
* @Date 2025/2/27 10:36
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PostionMatrixVo {
private LinkedList<Postion> tops;
private LinkedList<PostionPeople> centers;
private LinkedList<PeopleSums> footers;
}

@ -0,0 +1,35 @@
package com.engine.wysecond.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.LinkedList;
/**
* @Author liang.cheng
* @Date 2025/2/27 13:30
* @Description:
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PostionPeople {
private String name;
private Integer row;
private Integer fsum;
private Integer ssum;
private LinkedList<PeoplesAndNames> fdatas;
private LinkedList<PeoplesAndNames> sdatas;
}

@ -0,0 +1,34 @@
package com.engine.wysecond.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author liang.cheng
* @Date 2025/2/27 10:08
* @Description: uf_ywzwxx
* @Version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourcesPo {
private String resourceId;
private String resource;
private String department;
private String postionType;
private String postion;
/**
*
*/
private String workDate;
}

@ -0,0 +1,23 @@
package com.engine.wysecond.service;
import com.engine.wysecond.entity.PostionMatrixVo;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2025/2/26 10:03
* @Description:
* @Version 1.0
*/
public interface PostionMatrixService {
/**
* @Description:
* @Author: liang.cheng
* @Date: 2025/2/26 10:09
* @param: []
* @return: java.util.Map<java.lang.String,java.lang.Object>
*/
PostionMatrixVo postionMatrix();
}

@ -0,0 +1,234 @@
package com.engine.wysecond.service.impl;
import com.engine.core.impl.Service;
import com.engine.wysecond.entity.*;
import com.engine.wysecond.service.PostionMatrixService;
import com.weaver.general.Util;
import lombok.SneakyThrows;
import weaver.conn.RecordSet;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author liang.cheng
* @Date 2025/2/26 10:04
* @Description:
* @Version 1.0
*/
public class PostionMatrixServiceImpl extends Service implements PostionMatrixService {
@SneakyThrows
@Override
public PostionMatrixVo postionMatrix() {
PostionMatrixVo postionMatrixVo = new PostionMatrixVo();
RecordSet rs = new RecordSet();
//1.人员信息获取
List<ResourcesPo> resourcesList = new ArrayList<>();
ResourceComInfo resource = new ResourceComInfo();
rs.executeQuery("select xm,szbm,ywzwxl,ywzwcj,rbywzwcjqssj from uf_ywzwxx where rbywzwcjqssj is not null");
while (rs.next()) {
resourcesList.add(ResourcesPo.builder()
.resourceId(Util.null2String(rs.getString("xm")))
.resource(resource.getLastname(Util.null2String(rs.getString("xm"))))
.department(Util.null2String(rs.getString("szbm")))
.postionType(Util.null2String(rs.getString("ywzwxl")))
.postion(Util.null2String(rs.getString("ywzwcj")))
.workDate(Util.null2String(rs.getString("rbywzwcjqssj")))
.build());
}
//过滤后数据
List<ResourcesPo> resourcesPoList = filterClosestWorkDate(resourcesList);
//2.报表岗位层级数据
LinkedList<Postion> tops = new LinkedList<>();
rs.executeQuery("select id,ywzwxl,ywzwcj from uf_ywzwcj");
while (rs.next()) {
tops.add(Postion.builder()
.id(Util.null2String(rs.getString("id")))
.postionType(Util.getIntValue(rs.getString("ywzwxl")))
.postionName(Util.null2String(rs.getString("ywzwcj")))
.build());
}
//3.双层循环构造中间数据
LinkedList<PostionPeople> centers = new LinkedList<>();
DepartmentComInfo dept = new DepartmentComInfo();
Map<String, List<ResourcesPo>> groupedByDepartment = resourcesPoList.stream()
.collect(Collectors.groupingBy(ResourcesPo::getDepartment));
for (Map.Entry<String, List<ResourcesPo>> entry : groupedByDepartment.entrySet()) {
String department = entry.getKey();
List<ResourcesPo> poList = entry.getValue();
//职能管理序列
List<ResourcesPo> fDatasAll = poList.stream()
.filter(po -> ("1".equals(po.getPostionType()) && department.equals(po.getDepartment())))
.collect(Collectors.toList());
LinkedList<PeoplesAndNames> fDatas = new LinkedList<>();
for (int i = 0; i < tops.size(); i++) {
Postion postion = tops.get(i);
List<ResourcesPo> collect = fDatasAll.stream()
.filter(po -> postion.getId().equals(po.getPostionType()))
.collect(Collectors.toList());
String names = collect.stream()
.map(ResourcesPo::getResource)
.collect(Collectors.joining("、"));
fDatas.add(PeoplesAndNames.builder()
.peoples(collect.size())
.names(names)
.build());
}
//专业技术序列
List<ResourcesPo> sDatasAll = poList.stream()
.filter(po -> ("2".equals(po.getPostionType()) && department.equals(po.getDepartment())))
.collect(Collectors.toList());
LinkedList<PeoplesAndNames> sDatas = new LinkedList<>();
for (int i = 0; i < tops.size(); i++) {
Postion postion = tops.get(i);
List<ResourcesPo> collect = sDatasAll.stream()
.filter(po -> postion.getId().equals(po.getPostionType()))
.collect(Collectors.toList());
String names = collect.stream()
.map(ResourcesPo::getResource)
.collect(Collectors.joining("、"));
sDatas.add(PeoplesAndNames.builder()
.peoples(collect.size())
.names(names)
.build());
}
int row = 1;
if (fDatasAll.size() > 0 && sDatasAll.size() > 0) {
row = 2;
}
centers.add(PostionPeople.builder()
.name(dept.getDepartmentName(department))
.row(row)
.fsum(fDatasAll.size())
.ssum(sDatasAll.size())
.fdatas(fDatas)
.sdatas(sDatas)
.build());
}
//4.底部合计数据
LinkedList<PeopleSums> footers = new LinkedList<>();
//1.职能管理序列
LinkedList<Integer> zndatas = new LinkedList<>();
for (int i = 0; i < tops.size(); i++) {
Postion postion = tops.get(i);
rs.executeQuery("select xm,rbywzwcjqssj from uf_ywzwxx where ywzwxl = 1 " +
" and ywzwcj = ? and rbywzwcjqssj is not null",postion.getId());
List<ResourcesPo> resourcesPos = new ArrayList<>();
while (rs.next()) {
resourcesPos.add(ResourcesPo.builder()
.resourceId(Util.null2String(rs.getString("xm")))
.workDate(Util.null2String(rs.getString("rbywzwcjqssj"))).build());
}
List<ResourcesPo> filterAll = filterClosestWorkDate(resourcesPos);
zndatas.add(filterAll.size());
//名单列 增加null代替不展示
zndatas.add(null);
if (i == tops.size() - 1) {
//增加合计值 todo
zndatas.add(null);
}
};
footers.add(PeopleSums.builder().type("职能管理序列").datas(zndatas).build());
//2.专业管理序列
LinkedList<Integer> zydatas = new LinkedList<>();
for (int i = 0; i < tops.size(); i++) {
Postion postion = tops.get(i);
rs.executeQuery("select xm,rbywzwcjqssj from uf_ywzwxx where ywzwxl = 2 " +
" and ywzwcj = ? and rbywzwcjqssj is not null",postion.getId());
List<ResourcesPo> resourcesPos = new ArrayList<>();
while (rs.next()) {
resourcesPos.add(ResourcesPo.builder()
.resourceId(Util.null2String(rs.getString("xm")))
.workDate(Util.null2String(rs.getString("rbywzwcjqssj"))).build());
}
List<ResourcesPo> filterAll = filterClosestWorkDate(resourcesPos);
zydatas.add(filterAll.size());
//名单列 增加null代替不展示
zydatas.add(null);
if (i == tops.size() - 1) {
//增加合计值 todo
zydatas.add(null);
}
};
footers.add(PeopleSums.builder().type("专业技术序列").datas(zydatas).build());
//3.总计
LinkedList<Integer> zjdatas = new LinkedList<>();
for (int i = 0; i < tops.size(); i++) {
Postion postion = tops.get(i);
rs.executeQuery("select xm,rbywzwcjqssj from uf_ywzwxx where ywzwcj = ? and rbywzwcjqssj is not null",postion.getId());
List<ResourcesPo> resourcesPos = new ArrayList<>();
while (rs.next()) {
resourcesPos.add(ResourcesPo.builder()
.resourceId(Util.null2String(rs.getString("xm")))
.workDate(Util.null2String(rs.getString("rbywzwcjqssj"))).build());
}
List<ResourcesPo> filterAll = filterClosestWorkDate(resourcesPos);
zjdatas.add(filterAll.size());
//名单列 增加null代替不展示
zjdatas.add(null);
if (i == tops.size() - 1) {
//增加合计值 todo
zjdatas.add(null);
}
};
footers.add(PeopleSums.builder().type("总计").datas(zjdatas).build());
return PostionMatrixVo.builder().tops(tops).centers(centers).footers(footers).build();
}
private static List<ResourcesPo> filterClosestWorkDate(List<ResourcesPo> resourcesPos) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 按 resourceId 分组
Map<String, List<ResourcesPo>> groupedByResource = resourcesPos.stream()
.collect(Collectors.groupingBy(ResourcesPo::getResourceId));
List<ResourcesPo> result = new ArrayList<>();
// 遍历分组结果
groupedByResource.forEach((resource, group) -> {
try {
// 找出该分组中 workDate 最大(最近)的元素
Optional<ResourcesPo> maxDatePo = group.stream()
.max(Comparator.comparing(po -> {
try {
return sdf.parse(po.getWorkDate());
} catch (ParseException e) {
throw new RuntimeException(e);
}
}));
maxDatePo.ifPresent(result::add);
} catch (Exception e) {
e.printStackTrace();
}
});
return result;
}
}

@ -1,10 +0,0 @@
package com.engine.wysecond.web;
/**
* @Author liang.cheng
* @Date 2025/2/21 11:11
* @Description: TODO
* @Version 1.0
*/
public class PersonelResumeAction {
}

@ -0,0 +1,48 @@
package com.engine.wysecond.web;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.common.util.ServiceUtil;
import com.engine.wysecond.service.PostionMatrixService;
import com.engine.wysecond.service.impl.PostionMatrixServiceImpl;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2025/2/21 11:11
* @Description:
* @Version 1.0
*/
public class PostionMatrixAction {
private PostionMatrixService getService(User user) {
return ServiceUtil.getService(PostionMatrixServiceImpl.class, user);
}
@GET
@Path("/matrix")
@Produces(MediaType.TEXT_PLAIN)
public String postionMatrix(@Context HttpServletRequest request, @Context HttpServletResponse response){
Map<String, Object> data = new HashMap<>(8);
try {
User user = HrmUserVarify.getUser(request, response);
data.put("postionList",getService(user).postionMatrix());
data.put("api_status", true);
} catch (Exception e) {
data.put("api_status", false);
data.put("msg", "catch exception : " + e.getMessage());
}
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
}
}
Loading…
Cancel
Save