From 93ee7661b5715447b177b18881daccc1fb2f024a Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Mon, 3 Mar 2025 17:02:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=94=E9=99=A2=E6=9D=AD=E5=B7=9E=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=20=E5=BC=95=E5=85=A5=E4=BA=A7=E5=93=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=E5=B2=97=E4=BD=8D=E6=95=B0=E6=8D=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=BA=E5=91=98=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB-INF/prop/wysecond.properties | 5 + .../engine/wysecond/entity/ResourcesPo.java | 2 + .../service/PostionMatrixService.java | 22 +++ .../wysecond/service/ResourceCardService.java | 25 +++ .../impl/PostionMatrixServiceImpl.java | 167 ++++++++++-------- .../service/impl/ResourceCardServiceImpl.java | 55 ++++++ .../modeexpand/PostionModeExpand.java | 76 ++++++++ 7 files changed, 280 insertions(+), 72 deletions(-) create mode 100644 WEB-INF/prop/wysecond.properties create mode 100644 src/com/engine/wysecond/service/ResourceCardService.java create mode 100644 src/com/engine/wysecond/service/impl/ResourceCardServiceImpl.java create mode 100644 src/weaver/formmode/customjavacode/modeexpand/PostionModeExpand.java diff --git a/WEB-INF/prop/wysecond.properties b/WEB-INF/prop/wysecond.properties new file mode 100644 index 0000000..f3d1124 --- /dev/null +++ b/WEB-INF/prop/wysecond.properties @@ -0,0 +1,5 @@ +#\u4E1A\u52A1\u804C\u52A1\u5E8F\u5217 +postionType=field49 + +#\u4E1A\u52A1\u804C\u52A1\u5C42\u7EA7 +postion=field50 diff --git a/src/com/engine/wysecond/entity/ResourcesPo.java b/src/com/engine/wysecond/entity/ResourcesPo.java index d64f3f2..a5d9263 100644 --- a/src/com/engine/wysecond/entity/ResourcesPo.java +++ b/src/com/engine/wysecond/entity/ResourcesPo.java @@ -17,6 +17,8 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class ResourcesPo { + private Integer id; + private String resourceId; private String resource; diff --git a/src/com/engine/wysecond/service/PostionMatrixService.java b/src/com/engine/wysecond/service/PostionMatrixService.java index 144e5c1..3923418 100644 --- a/src/com/engine/wysecond/service/PostionMatrixService.java +++ b/src/com/engine/wysecond/service/PostionMatrixService.java @@ -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 */ PostionMatrixVo postionMatrix(); + + + /** 建模人员业务职务信息 + * @Description: + * @Author: liang.cheng + * @Date: 2025/2/28 16:41 + * @param: [] + * @return: java.util.List + */ + List postionPeoples(); + + + /** + * @Description: 按照起始时间过滤 + * @Author: liang.cheng + * @Date: 2025/3/3 10:42 + * @param: [resourcesPos] + * @return: java.util.List + */ + List filterClosestWorkDate(List resourcesPos); } diff --git a/src/com/engine/wysecond/service/ResourceCardService.java b/src/com/engine/wysecond/service/ResourceCardService.java new file mode 100644 index 0000000..4e4d54d --- /dev/null +++ b/src/com/engine/wysecond/service/ResourceCardService.java @@ -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); +} diff --git a/src/com/engine/wysecond/service/impl/PostionMatrixServiceImpl.java b/src/com/engine/wysecond/service/impl/PostionMatrixServiceImpl.java index 00f4842..4581a6e 100644 --- a/src/com/engine/wysecond/service/impl/PostionMatrixServiceImpl.java +++ b/src/com/engine/wysecond/service/impl/PostionMatrixServiceImpl.java @@ -30,22 +30,7 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe RecordSet rs = new RecordSet(); //1.人员信息获取 - List 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 resourcesPoList = filterClosestWorkDate(resourcesList); + List resourcesPoList = postionPeoples(); //2.报表岗位层级数据 LinkedList tops = new LinkedList<>(); @@ -74,19 +59,21 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe .collect(Collectors.toList()); LinkedList fDatas = new LinkedList<>(); - for (int i = 0; i < tops.size(); i++) { - Postion postion = tops.get(i); - List 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 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 sDatas = new LinkedList<>(); - for (int i = 0; i < tops.size(); i++) { - Postion postion = tops.get(i); - List 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 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 footers = new LinkedList<>(); //1.职能管理序列 + int znSums = 0; LinkedList 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 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 resourcesPos = new ArrayList<>(); + while (rs.next()) { + resourcesPos.add(ResourcesPo.builder() + .resourceId(Util.null2String(rs.getString("xm"))) + .workDate(Util.null2String(rs.getString("rbywzwcjqssj"))).build()); + } + + List 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 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 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 resourcesPos = new ArrayList<>(); - while (rs.next()) { - resourcesPos.add(ResourcesPo.builder() - .resourceId(Util.null2String(rs.getString("xm"))) - .workDate(Util.null2String(rs.getString("rbywzwcjqssj"))).build()); - } - - List 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 filterClosestWorkDate(List resourcesPos) { + @Override + @SneakyThrows + public List postionPeoples() { + RecordSet rs = new RecordSet(); + List 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 filterClosestWorkDate(List resourcesPos) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // 按 resourceId 分组 Map> groupedByResource = resourcesPos.stream() @@ -216,13 +239,13 @@ public class PostionMatrixServiceImpl extends Service implements PostionMatrixSe try { // 找出该分组中 workDate 最大(最近)的元素 Optional 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(); diff --git a/src/com/engine/wysecond/service/impl/ResourceCardServiceImpl.java b/src/com/engine/wysecond/service/impl/ResourceCardServiceImpl.java new file mode 100644 index 0000000..4742f7f --- /dev/null +++ b/src/com/engine/wysecond/service/impl/ResourceCardServiceImpl.java @@ -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) { + + RecordSet rs = new RecordSet(); + + List 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(); + } +} diff --git a/src/weaver/formmode/customjavacode/modeexpand/PostionModeExpand.java b/src/weaver/formmode/customjavacode/modeexpand/PostionModeExpand.java new file mode 100644 index 0000000..61ca5e5 --- /dev/null +++ b/src/weaver/formmode/customjavacode/modeexpand/PostionModeExpand.java @@ -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 doModeExpand(Map param) { + Map 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 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 resourcesPos = getMatrixService(user).filterClosestWorkDate(resourcesList); + + //更新 + getCardService(user).upDateCard(resourcesPos); + } + } + } catch (Exception e) { + result.put("errmsg","业务职务信息更新人员卡片失败"); + result.put("flag", "false"); + } + return result; + } +}