五院杭州中心 引入产品功能 岗位数据更新人员卡片
This commit is contained in:
parent
671df80a9c
commit
93ee7661b5
|
|
@ -0,0 +1,5 @@
|
|||
#\u4E1A\u52A1\u804C\u52A1\u5E8F\u5217
|
||||
postionType=field49
|
||||
|
||||
#\u4E1A\u52A1\u804C\u52A1\u5C42\u7EA7
|
||||
postion=field50
|
||||
|
|
@ -17,6 +17,8 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
public class ResourcesPo {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String resourceId;
|
||||
|
||||
private String resource;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.engine.wysecond.service;
|
||||
|
||||
import com.engine.wysecond.entity.PostionMatrixVo;
|
||||
import com.engine.wysecond.entity.ResourcesPo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -20,4 +22,24 @@ public interface PostionMatrixService {
|
|||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
PostionMatrixVo postionMatrix();
|
||||
|
||||
|
||||
/** 建模人员业务职务信息
|
||||
* @Description:
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2025/2/28 16:41
|
||||
* @param: []
|
||||
* @return: java.util.List<com.engine.wysecond.entity.ResourcesPo>
|
||||
*/
|
||||
List<ResourcesPo> postionPeoples();
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 按照起始时间过滤
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2025/3/3 10:42
|
||||
* @param: [resourcesPos]
|
||||
* @return: java.util.List<com.engine.wysecond.entity.ResourcesPo>
|
||||
*/
|
||||
List<ResourcesPo> filterClosestWorkDate(List<ResourcesPo> resourcesPos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.engine.wysecond.service;
|
||||
|
||||
import com.engine.wysecond.entity.ResourcesPo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/2/28 16:18
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface ResourceCardService {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 更新人员卡片工作信息自定义字段 (存在导入全量更新)
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2025/2/28 16:22
|
||||
* @param: [resourcesPo]
|
||||
* @return: int
|
||||
*/
|
||||
int upDateCard(List<ResourcesPo> resourcesPo);
|
||||
}
|
||||
|
|
@ -30,22 +30,7 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe
|
|||
|
||||
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);
|
||||
List<ResourcesPo> resourcesPoList = postionPeoples();
|
||||
|
||||
//2.报表岗位层级数据
|
||||
LinkedList<Postion> tops = new LinkedList<>();
|
||||
|
|
@ -74,19 +59,21 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe
|
|||
.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("、"));
|
||||
if (fDatasAll.size() > 0) {
|
||||
for (int i = 0; i < tops.size(); i++) {
|
||||
Postion postion = tops.get(i);
|
||||
List<ResourcesPo> collect = fDatasAll.stream()
|
||||
.filter(po -> postion.getId().equals(po.getPostion()))
|
||||
.collect(Collectors.toList());
|
||||
String names = collect.stream()
|
||||
.map(ResourcesPo::getResource)
|
||||
.collect(Collectors.joining("、"));
|
||||
|
||||
fDatas.add(PeoplesAndNames.builder()
|
||||
.peoples(collect.size())
|
||||
.names(names)
|
||||
.build());
|
||||
fDatas.add(PeoplesAndNames.builder()
|
||||
.peoples(collect.size())
|
||||
.names(names)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
//专业技术序列
|
||||
|
|
@ -94,19 +81,21 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe
|
|||
.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("、"));
|
||||
if (sDatasAll.size() > 0) {
|
||||
for (int i = 0; i < tops.size(); i++) {
|
||||
Postion postion = tops.get(i);
|
||||
List<ResourcesPo> collect = sDatasAll.stream()
|
||||
.filter(po -> postion.getId().equals(po.getPostion()))
|
||||
.collect(Collectors.toList());
|
||||
String names = collect.stream()
|
||||
.map(ResourcesPo::getResource)
|
||||
.collect(Collectors.joining("、"));
|
||||
|
||||
sDatas.add(PeoplesAndNames.builder()
|
||||
.peoples(collect.size())
|
||||
.names(names)
|
||||
.build());
|
||||
sDatas.add(PeoplesAndNames.builder()
|
||||
.peoples(collect.size())
|
||||
.names(names)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
int row = 1;
|
||||
|
|
@ -127,6 +116,7 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe
|
|||
//4.底部合计数据
|
||||
LinkedList<PeopleSums> footers = new LinkedList<>();
|
||||
//1.职能管理序列
|
||||
int znSums = 0;
|
||||
LinkedList<Integer> zndatas = new LinkedList<>();
|
||||
for (int i = 0; i < tops.size(); i++) {
|
||||
Postion postion = tops.get(i);
|
||||
|
|
@ -144,13 +134,47 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe
|
|||
//名单列 增加null代替不展示
|
||||
zndatas.add(null);
|
||||
if (i == tops.size() - 1) {
|
||||
//增加合计值 todo
|
||||
zndatas.add(null);
|
||||
rs.executeQuery("select count(DISTINCT xm) as sums from uf_ywzwxx where ywzwxl = 1 and rbywzwcjqssj is not null");
|
||||
if (rs.next()) {
|
||||
znSums = Util.getIntValue(rs.getString("sums"),0);
|
||||
}
|
||||
zndatas.add(znSums);
|
||||
}
|
||||
|
||||
};
|
||||
footers.add(PeopleSums.builder().type("职能管理序列").datas(zndatas).build());
|
||||
|
||||
|
||||
|
||||
//3.总计
|
||||
LinkedList<Integer> zjdatas = new LinkedList<>();
|
||||
int zjSums = 0;
|
||||
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) {
|
||||
rs.executeQuery("select count(DISTINCT xm) as sums from uf_ywzwxx where rbywzwcjqssj is not null");
|
||||
if (rs.next()) {
|
||||
zjSums = Util.getIntValue(rs.getString("sums"),0);
|
||||
}
|
||||
zjdatas.add(zjSums);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//2.专业管理序列
|
||||
LinkedList<Integer> zydatas = new LinkedList<>();
|
||||
for (int i = 0; i < tops.size(); i++) {
|
||||
|
|
@ -169,42 +193,41 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe
|
|||
//名单列 增加null代替不展示
|
||||
zydatas.add(null);
|
||||
if (i == tops.size() - 1) {
|
||||
//增加合计值 todo
|
||||
zydatas.add(null);
|
||||
zydatas.add(zjSums - znSums);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
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) {
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public List<ResourcesPo> postionPeoples() {
|
||||
RecordSet rs = new RecordSet();
|
||||
List<ResourcesPo> resourcesList = new ArrayList<>();
|
||||
ResourceComInfo resource = new ResourceComInfo();
|
||||
rs.executeQuery("select id,xm,szbm,ywzwxl,ywzwcj,rbywzwcjqssj from uf_ywzwxx where rbywzwcjqssj is not null");
|
||||
while (rs.next()) {
|
||||
resourcesList.add(ResourcesPo.builder()
|
||||
.id(Util.getIntValue(rs.getString("id")))
|
||||
.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());
|
||||
}
|
||||
|
||||
//过滤后数据
|
||||
return filterClosestWorkDate(resourcesList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResourcesPo> filterClosestWorkDate(List<ResourcesPo> resourcesPos) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// 按 resourceId 分组
|
||||
Map<String, List<ResourcesPo>> groupedByResource = resourcesPos.stream()
|
||||
|
|
@ -216,13 +239,13 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe
|
|||
try {
|
||||
// 找出该分组中 workDate 最大(最近)的元素
|
||||
Optional<ResourcesPo> maxDatePo = group.stream()
|
||||
.max(Comparator.comparing(po -> {
|
||||
.max(Comparator.comparing((ResourcesPo po) -> {
|
||||
try {
|
||||
return sdf.parse(po.getWorkDate());
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}));
|
||||
}).thenComparingInt(ResourcesPo::getId));
|
||||
maxDatePo.ifPresent(result::add);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package com.engine.wysecond.service.impl;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.wysecond.entity.ResourcesPo;
|
||||
import com.engine.wysecond.service.PostionMatrixService;
|
||||
import com.engine.wysecond.service.ResourceCardService;
|
||||
import com.weaver.general.Util;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/2/28 16:18
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class ResourceCardServiceImpl extends Service implements ResourceCardService {
|
||||
|
||||
private PostionMatrixService getService(User user) {
|
||||
return ServiceUtil.getService(PostionMatrixServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int upDateCard(List<ResourcesPo> resourcesPo) {
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
List<ResourcesPo> resourcesPoList = getService(user).postionPeoples();
|
||||
|
||||
String postionType = rs.getPropValue("wysecond", "postionType");
|
||||
String postion = rs.getPropValue("wysecond", "postion");
|
||||
resourcesPoList.forEach(resources -> {
|
||||
rs.executeQuery("select count(1) as sums from cus_fielddata where id = ? and scopeid =3 and scope = 'HrmCustomFieldByInfoType'",resources.getResourceId());
|
||||
rs.next();
|
||||
|
||||
int sums = Util.getIntValue(rs.getString("sums"));
|
||||
if (sums > 0) {
|
||||
//更新
|
||||
rs.executeUpdate("update cus_fielddata set " + postionType + "= ?," + postion + "= ? where id = ? and scopeid =3 and scope = 'HrmCustomFieldByInfoType'", resources.getPostionType(),
|
||||
resources.getPostion(), resources.getResourceId());
|
||||
|
||||
|
||||
}else {
|
||||
//插入
|
||||
rs.executeUpdate("insert into cus_fielddata(id,scopeid,scope,"+postionType+","+postion+") values(?,?,?,?,?)",resources.getResourceId(),
|
||||
3,"HrmCustomFieldByInfoType",resources.getPostionType(),resources.getPostion());
|
||||
}
|
||||
|
||||
});
|
||||
return resourcesPoList.size();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package weaver.formmode.customjavacode.modeexpand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.wysecond.entity.ResourcesPo;
|
||||
import com.engine.wysecond.service.PostionMatrixService;
|
||||
import com.engine.wysecond.service.ResourceCardService;
|
||||
import com.engine.wysecond.service.impl.PostionMatrixServiceImpl;
|
||||
import com.engine.wysecond.service.impl.ResourceCardServiceImpl;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/2/28 17:44
|
||||
* @Description: 建模卡片按钮扩展
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class PostionModeExpand extends AbstractModeExpandJavaCodeNew {
|
||||
|
||||
private ResourceCardService getCardService(User user) {
|
||||
return ServiceUtil.getService(ResourceCardServiceImpl.class, user);
|
||||
}
|
||||
|
||||
private PostionMatrixService getMatrixService(User user) {
|
||||
return ServiceUtil.getService(PostionMatrixServiceImpl.class, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> doModeExpand(Map<String, Object> param) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
try {
|
||||
User user = (User)param.get("user");
|
||||
RecordSet rs = new RecordSet();
|
||||
RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
|
||||
if(requestInfo != null){
|
||||
int billid = Util.getIntValue(requestInfo.getRequestid());
|
||||
int modeid = Util.getIntValue(requestInfo.getWorkflowid());
|
||||
if(billid > 0 && modeid > 0){
|
||||
rs.executeQuery("select xm from uf_ywzwxx where id = ?",billid);
|
||||
rs.next();
|
||||
String xm = Util.null2String(rs.getString("xm"));
|
||||
|
||||
String sql = "select id,xm,ywzwxl,ywzwcj,rbywzwcjqssj from uf_ywzwxx where rbywzwcjqssj is not null and xm = ?";
|
||||
rs.executeQuery(sql,xm);
|
||||
List<ResourcesPo> resourcesList = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
resourcesList.add(ResourcesPo.builder()
|
||||
.id(Util.getIntValue(rs.getString("id")))
|
||||
.resourceId(Util.null2String(rs.getString("xm")))
|
||||
.postionType(Util.null2String(rs.getString("ywzwxl")))
|
||||
.postion(Util.null2String(rs.getString("ywzwcj")))
|
||||
.workDate(Util.null2String(rs.getString("rbywzwcjqssj")))
|
||||
.build());
|
||||
}
|
||||
|
||||
List<ResourcesPo> resourcesPos = getMatrixService(user).filterClosestWorkDate(resourcesList);
|
||||
|
||||
//更新
|
||||
getCardService(user).upDateCard(resourcesPos);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.put("errmsg","业务职务信息更新人员卡片失败");
|
||||
result.put("flag", "false");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue