From b1851d7364f375a818b70e1b052d08f0801d56bd Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 21 May 2025 16:08:26 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20IT=E6=9C=8D=E5=8A=A1-?= =?UTF-8?q?=E5=B0=86=E6=AD=A5=E9=AA=A4=E6=B5=81=E8=BD=AC=E6=97=B6=E6=8C=87?= =?UTF-8?q?=E6=B4=BE=E6=AD=A5=E9=AA=A4=E5=A4=84=E7=90=86=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=B7=BB=E5=8A=A0=E5=88=B0=E6=97=B6=E9=97=B4=E7=BA=BF?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1425218084503552]IT服务-将步骤流转时指派步骤处理人信息添加到时间线中 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1425218084503552 --- .../handler/AssignWorkerListAuditHandler.java | 139 ++++++++++++++++++ .../service/ProcessStepHandlerUtil.java | 1 + 2 files changed, 140 insertions(+) create mode 100644 src/main/java/neatlogic/module/process/audithandler/handler/AssignWorkerListAuditHandler.java diff --git a/src/main/java/neatlogic/module/process/audithandler/handler/AssignWorkerListAuditHandler.java b/src/main/java/neatlogic/module/process/audithandler/handler/AssignWorkerListAuditHandler.java new file mode 100644 index 000000000..bfcac31c5 --- /dev/null +++ b/src/main/java/neatlogic/module/process/audithandler/handler/AssignWorkerListAuditHandler.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.module.process.audithandler.handler; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.common.constvalue.GroupSearch; +import neatlogic.framework.dao.mapper.RoleMapper; +import neatlogic.framework.dao.mapper.TeamMapper; +import neatlogic.framework.dao.mapper.UserMapper; +import neatlogic.framework.dto.RoleVo; +import neatlogic.framework.dto.TeamVo; +import neatlogic.framework.dto.UserVo; +import neatlogic.framework.process.audithandler.core.IProcessTaskStepAuditDetailHandler; +import neatlogic.framework.process.constvalue.ProcessTaskAuditDetailType; +import neatlogic.framework.process.dto.ProcessTaskStepAuditDetailVo; +import neatlogic.framework.process.dto.ProcessTaskStepVo; +import neatlogic.module.process.dao.mapper.processtask.ProcessTaskMapper; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class AssignWorkerListAuditHandler implements IProcessTaskStepAuditDetailHandler { + + @Resource + private ProcessTaskMapper processTaskMapper; + + @Resource + private UserMapper userMapper; + + @Resource + private TeamMapper teamMapper; + + @Resource + private RoleMapper roleMapper; + + @Override + public String getType() { + return ProcessTaskAuditDetailType.ASSIGNWORKERLIST.getValue(); + } + + @Override + public int handle(ProcessTaskStepAuditDetailVo processTaskStepAuditDetailVo) { + String oldContent = processTaskStepAuditDetailVo.getOldContent(); + if(StringUtils.isNotBlank(oldContent)) { + processTaskStepAuditDetailVo.setOldContent(parse(oldContent)); + } + String newContent = processTaskStepAuditDetailVo.getNewContent(); + if(StringUtils.isNotBlank(newContent)) { + processTaskStepAuditDetailVo.setNewContent(parse(newContent)); + } + return 1; + } + + private String parse(String content) { + JSONArray assignWorkerList = new JSONArray(); + JSONArray assignWorkerArray = JSONArray.parseArray(content); + if (CollectionUtils.isNotEmpty(assignWorkerArray)) { + for (int i = 0; i < assignWorkerArray.size(); i++) { + JSONObject assignWorkerObj = assignWorkerArray.getJSONObject(i); + if (MapUtils.isNotEmpty(assignWorkerObj)) { + JSONObject assignWorker = new JSONObject(); + Long processTaskStepId = assignWorkerObj.getLong("processTaskStepId"); + ProcessTaskStepVo processTaskStepVo = processTaskMapper.getProcessTaskStepBaseInfoById(processTaskStepId); + if (processTaskStepVo != null) { + assignWorker.put("processTaskStepName", processTaskStepVo.getName()); + } +// String processStepUuid = assignWorkerObj.getString("processStepUuid"); + JSONArray workerArray = assignWorkerObj.getJSONArray("workerList"); + if (CollectionUtils.isNotEmpty(workerArray)) { + List> workerList = new ArrayList<>(); + for(int j = 0; j < workerArray.size(); j++) { + String worker = workerArray.getString(j); + String[] split = worker.split("#"); + if(GroupSearch.USER.getValue().equals(split[0])) { + UserVo userVo = userMapper.getUserBaseInfoByUuid(split[1]); + if(userVo != null) { + Map userMap = new HashMap<>(); + userMap.put("initType", GroupSearch.USER.getValue()); + userMap.put("uuid", userVo.getUuid()); + userMap.put("name", userVo.getUserName()); + workerList.add(userMap); + } + }else if(GroupSearch.TEAM.getValue().equals(split[0])) { + TeamVo teamVo = teamMapper.getTeamByUuid(split[1]); + if(teamVo != null) { + Map teamMap = new HashMap<>(); + teamMap.put("initType", GroupSearch.TEAM.getValue()); + teamMap.put("uuid", teamVo.getUuid()); + teamMap.put("name", teamVo.getName()); + workerList.add(teamMap); + } + }else if(GroupSearch.ROLE.getValue().equals(split[0])) { + RoleVo roleVo = roleMapper.getRoleByUuid(split[1]); + if(roleVo != null) { + Map roleMap = new HashMap<>(); + roleMap.put("initType", GroupSearch.ROLE.getValue()); + roleMap.put("uuid", roleVo.getUuid()); + roleMap.put("name", roleVo.getName()); + workerList.add(roleMap); + } + } + } + assignWorker.put("workerList", workerList); + } + assignWorkerList.add(assignWorker); + } + } + } + if(CollectionUtils.isNotEmpty(assignWorkerList)){ + return JSON.toJSONString(assignWorkerList); + } + return null; + } +} diff --git a/src/main/java/neatlogic/module/process/service/ProcessStepHandlerUtil.java b/src/main/java/neatlogic/module/process/service/ProcessStepHandlerUtil.java index 72e044611..bc9a2dde1 100644 --- a/src/main/java/neatlogic/module/process/service/ProcessStepHandlerUtil.java +++ b/src/main/java/neatlogic/module/process/service/ProcessStepHandlerUtil.java @@ -358,6 +358,7 @@ public class ProcessStepHandlerUtil implements IProcessStepHandlerUtil, IProcess ProcessTaskStepVo processTaskStepVo = processTaskMapper.getProcessTaskStepBaseInfoByProcessTaskIdAndProcessStepUuid(processTaskId, processStepUuid); if (processTaskStepVo != null) { processTaskStepId = processTaskStepVo.getId(); + assignWorker.put("processTaskStepId", processTaskStepId); } } } -- Gitee