From 16d4c2e94790188c59dac9f22bfc65354f634527 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期一, 13 一月 2025 13:50:41 +0800 Subject: [PATCH] 审核提交注入流转条件字段 --- flowable/src/main/java/com/ycl/service/common/TaskCommonService.java | 40 +++++++++----------- flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java | 27 +++++++++---- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/flowable/src/main/java/com/ycl/service/common/TaskCommonService.java b/flowable/src/main/java/com/ycl/service/common/TaskCommonService.java index 0385cd7..e5abf8c 100644 --- a/flowable/src/main/java/com/ycl/service/common/TaskCommonService.java +++ b/flowable/src/main/java/com/ycl/service/common/TaskCommonService.java @@ -43,9 +43,9 @@ /** * 閫氳繃褰撳墠鑺傜偣瀹氫箟key锛岃幏鍙栧叾涓婁竴涓妭鐐圭殑淇℃伅锛屽鏋滃墠闈㈡槸骞惰鐨勪細杩斿洖澶氫釜(鍖呭惈褰撳墠鑺傜偣) * - * @param processDefId 娴佺▼瀹氫箟id - * @param currentNodeDefId 褰撳墠鑺傜偣瀹氫箟id - * @param sysFormService 琛ㄥ崟鏈嶅姟灞� + * @param processDefId 娴佺▼瀹氫箟id + * @param currentNodeDefId 褰撳墠鑺傜偣瀹氫箟id + * @param sysFormService 琛ㄥ崟鏈嶅姟灞� * @param needInitCurrentForm 鏄惁闇�瑕佸垵濮嬪寲褰撳墠鑺傜偣鐨勮〃鍗曟暟鎹紝涓�鑸煡璇㈠凡瀹屾垚鐨勪换鍔¤鎯呴渶瑕� * @return */ @@ -82,11 +82,11 @@ // 鑾峰彇褰撳墠鑺傜偣鐨勮緭鍏� List<FormDetailVO> defKeys = new ArrayList<>(2); + FormDetailVO formDetailVO = new FormDetailVO(); + formDetailVO.setCurrent(Boolean.TRUE); + formDetailVO.setBeforeNodeDefId(currentElement.getId()); + formDetailVO.setBeforeNodeName(currentElement.getName()); if (StringUtils.hasText(currentElement.getFormKey())) { - FormDetailVO formDetailVO = new FormDetailVO(); - formDetailVO.setBeforeNodeDefId(currentElement.getId()); - formDetailVO.setBeforeNodeName(currentElement.getName()); - formDetailVO.setCurrent(Boolean.TRUE); if (needInitCurrentForm) { SysForm sysForm = sysFormService.selectSysFormById(Long.parseLong(currentElement.getFormKey())); @@ -95,12 +95,10 @@ } Map<String, Object> data = new HashMap<>(1); data.put(ProcessConstants.TASK_FORM_KEY, JSONObject.parseObject(sysForm.getFormContent())); - formDetailVO.setFormJsonObj(data); } - - defKeys.add(formDetailVO); } + defKeys.add(formDetailVO); this.beforeNodeInfo(currentElement, defKeys); return defKeys; @@ -161,7 +159,7 @@ private void beforeNodeInfo(FlowElement currentElement, List<FormDetailVO> defKeys) { if (currentElement instanceof UserTask) { UserTask userTask = (UserTask) currentElement; - if (! CollectionUtils.isEmpty(userTask.getIncomingFlows())) { + if (!CollectionUtils.isEmpty(userTask.getIncomingFlows())) { for (SequenceFlow incomingFlow : userTask.getIncomingFlows()) { if (incomingFlow.getSourceFlowElement() instanceof UserTask) { FormDetailVO formDetailVO = new FormDetailVO(); @@ -173,9 +171,9 @@ } } } - } else if (currentElement instanceof Gateway ){ + } else if (currentElement instanceof Gateway) { Gateway gateway = (Gateway) currentElement; - if (! CollectionUtils.isEmpty(gateway.getIncomingFlows())) { + if (!CollectionUtils.isEmpty(gateway.getIncomingFlows())) { for (SequenceFlow incomingFlow : gateway.getIncomingFlows()) { if (incomingFlow.getSourceFlowElement() instanceof UserTask) { FormDetailVO formDetailVO = new FormDetailVO(); @@ -194,7 +192,7 @@ /** * 鑾峰彇褰撳墠鑺傜偣鐨勪笂涓�鑺傜偣id锛屼笉鍙嶆倲褰撳墠鑺傜偣淇℃伅锛屽鏋滃墠闈㈡槸骞惰锛岄偅涔堜細杩斿洖澶氫釜 * - * @param processDefId 娴佺▼瀹氫箟id + * @param processDefId 娴佺▼瀹氫箟id * @param currentNodeDefId 褰撳墠鑺傜偣瀹氫箟id * @return */ @@ -253,7 +251,7 @@ } else { // 鍚﹀垯鍏堟煡鏈韩鐨勫睘鎬ф湁涓嶆湁锛氶渶瑕佸鏍� 鐨勫睘鎬э紝娌℃湁涔熸槸閫掑綊child if (extensionElement.getAttributes().get("name").stream().anyMatch(attribute -> ProcessConstants.EXTENSION_PROPERTY_NEED_AUDITING_TEXT.equals(attribute.getValue())) - && extensionElement.getAttributes().get("value").stream().anyMatch(attribute -> ProcessConstants.EXTENSION_PROPERTY_NEED_AUDITING_VALUE.equals(attribute.getValue())) + && extensionElement.getAttributes().get("value").stream().anyMatch(attribute -> ProcessConstants.EXTENSION_PROPERTY_NEED_AUDITING_VALUE.equals(attribute.getValue())) ) { return Boolean.TRUE; } else { @@ -269,10 +267,10 @@ * 椹冲洖浠诲姟 * * @param rejectedTaskDefKey 琚┏鍥炵殑浠诲姟key - * @param rejectTaskDefKey 鎵ц椹冲洖鎿嶄綔鎵�鍦ㄧ殑浠诲姟key - * @param processInsId 娴佺▼瀹炰緥id - * @param taskId 褰撳墠浠诲姟id - * @param msg 瀹℃牳鎰忚 + * @param rejectTaskDefKey 鎵ц椹冲洖鎿嶄綔鎵�鍦ㄧ殑浠诲姟key + * @param processInsId 娴佺▼瀹炰緥id + * @param taskId 褰撳墠浠诲姟id + * @param msg 瀹℃牳鎰忚 */ public void reject(String rejectedTaskDefKey, String rejectTaskDefKey, String processInsId, String taskId, String msg) { // 椹冲洖鐨勬牳蹇僡pi锛歳untimeService.createChangeActivityStateBuilder().moveXXX 鐨刟pi锛屽彲浠ヨ缃粠褰撳墠鑺傜偣绉诲姩鍒扮洰鏍囪妭鐐� @@ -289,13 +287,11 @@ // 璁剧疆涓ゆ潯璇勮 List<HistoricTaskInstance> rejectedTaskList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInsId).taskDefinitionKey(rejectedTaskDefKey).orderByHistoricTaskInstanceStartTime().desc().list(); String msg1 = "椹冲洖浜嗭細銆�" + rejectedTaskList.get(0).getName() + "銆戯紝椹冲洖鍘熷洜锛�"; - taskService.addComment(taskId, processInsId, FlowComment.REJECT.getType(), msg1 + msg); + taskService.addComment(taskId, processInsId, FlowComment.REJECT.getType(), msg1 + msg); // TODO 鐩存帴浣跨敤杩欎釜api濂藉儚鏈夐棶棰� runtimeService.createChangeActivityStateBuilder().processInstanceId(processInsId).moveActivityIdTo(rejectTaskDefKey, rejectedTaskDefKey).changeState(); runtimeService.createChangeActivityStateBuilder().processInstanceId(processInsId).moveExecutionToActivityId(rejectTaskDefKey, rejectedTaskDefKey).changeState(); } - - } diff --git a/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java b/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java index 485553f..6cf3937 100644 --- a/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java +++ b/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java @@ -9,6 +9,7 @@ import com.ycl.common.constant.ProcessConstants; import com.ycl.common.core.domain.AjaxResult; import com.ycl.common.core.domain.entity.SysDept; +import com.ycl.common.core.domain.entity.SysDictData; import com.ycl.common.core.domain.entity.SysRole; import com.ycl.common.core.domain.entity.SysUser; import com.ycl.common.enums.FlowComment; @@ -33,9 +34,7 @@ import com.ycl.service.ISysDeployFormService; import com.ycl.service.ISysFormService; import com.ycl.service.common.TaskCommonService; -import com.ycl.system.service.ISysDeptService; -import com.ycl.system.service.ISysRoleService; -import com.ycl.system.service.ISysUserService; +import com.ycl.system.service.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -90,6 +89,7 @@ private final ISysUserService sysUserService; private final ISysRoleService sysRoleService; private final ISysDeptService sysDeptService; + private final ISysDictTypeService sysDictDService; private final ISysDeployFormService sysInstanceFormService; private final ISysFormService sysFormService; private final TaskCommonService taskCommonService; @@ -134,12 +134,22 @@ if (Objects.isNull(task)) { return AjaxResult.error("浠诲姟涓嶅瓨鍦�"); } + + Map<String, Object> processVariables = new HashMap<>(); + //鏌ュ嚭瀛楀吀涓渶瑕佹敞鍏ョ殑瀛楁淇℃伅 + List<String> dictList = sysDictDService.selectDictDataByType("flow_variables").stream().map(SysDictData::getDictValue).collect(Collectors.toList()); Map<String, Object> newV = new HashMap<>(2); if (!org.springframework.util.CollectionUtils.isEmpty(variables)) { for (String key : variables.keySet()) { newV.put(task.getTaskDefinitionKey() + "&" + key, variables.get(key)); + //瀛楀吀閲屾湁灏辨斁鍏ユ祦绋嬪彉閲忎腑 + if (!CollectionUtils.isEmpty(dictList) && dictList.contains(key)) { + processVariables.put(key,variables.get(key)); + } } } + //娣诲姞娴佺▼鍙橀噺 + if(!processVariables.isEmpty()) taskService.setVariables(taskId,processVariables); taskService.addComment(taskId, task.getProcessInstanceId(), FlowComment.SUBMIT.getType(), "瀹屾垚鎻愪氦"); // 鍒ゆ柇褰撳墠浠诲姟鏄笉鏄浆鍔炶繃鐨� Boolean delegation = flowLogService.taskDelegation(task.getProcessInstanceId(), task.getId()); @@ -865,18 +875,19 @@ flowTask.setDuration(histIns.getDurationInMillis() == null || histIns.getDurationInMillis() == 0 ? null : getDate(histIns.getDurationInMillis())); //鎵╁睍 鍒ゆ柇鏄惁瓒呮椂 ProcessCoding processCoding = processCodingMap.get(histIns.getTaskId()); - if(processCoding!=null){ + if (processCoding != null) { //閫氳繃鑰楁椂鍒ゆ柇鏄惁鏄唬鍔炶妭鐐� //濡傛灉浠诲姟鏄唬鍔炶妭鐐� if (flowTask.getDuration() == null) { - if(RED.equals(processCoding.getStatus()) || YELLOW.equals(processCoding.getStatus())){ + if (RED.equals(processCoding.getStatus()) || YELLOW.equals(processCoding.getStatus())) { flowTask.setOvertime(processCoding.getStatus()); } - }else { + } else { //濡傛灉浠诲姟鑺傜偣灞炰簬鍘嗗彶鑺傜偣 - if(RED.equals(processCoding.getStatus())){ + if (RED.equals(processCoding.getStatus())) { flowTask.setOvertime(processCoding.getStatus()); - }; + } + ; } } // 鑾峰彇鎰忚璇勮鍐呭 -- Gitblit v1.8.0