From a0e8d1bbff7a02f538be76e852aa233324bd8810 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期五, 03 一月 2025 13:31:51 +0800
Subject: [PATCH] 赋码
---
flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java | 96 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 70 insertions(+), 26 deletions(-)
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 67e0bc3..26a400d 100644
--- a/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
+++ b/flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -4,6 +4,7 @@
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.common.constant.ProcessConstants;
import com.ycl.common.core.domain.AjaxResult;
@@ -17,6 +18,7 @@
import com.ycl.domain.dto.FlowNextDto;
import com.ycl.domain.dto.FlowTaskDto;
import com.ycl.domain.dto.FlowViewerDto;
+import com.ycl.domain.entity.ProcessCoding;
import com.ycl.domain.entity.SysForm;
import com.ycl.domain.vo.FlowQueryVo;
import com.ycl.domain.vo.FlowTaskVo;
@@ -25,6 +27,7 @@
import com.ycl.flow.CustomProcessDiagramGenerator;
import com.ycl.flow.FindNextNodeUtil;
import com.ycl.flow.FlowableUtils;
+import com.ycl.mapper.ProcessCodingMapper;
import com.ycl.service.IFlowTaskService;
import com.ycl.service.ISysDeployFormService;
import com.ycl.service.ISysFormService;
@@ -71,6 +74,9 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
+import static com.ycl.common.constant.ProcessOverTimeConstants.RED;
+import static com.ycl.common.constant.ProcessOverTimeConstants.YELLOW;
+
/**
* @author Tony
* @date 2021-04-03
@@ -86,6 +92,7 @@
private final ISysDeployFormService sysInstanceFormService;
private final ISysFormService sysFormService;
private final TaskCommonService taskCommonService;
+ private final ProcessCodingMapper processCodingMapper;
/**
* 瀹屾垚瀹℃牳浠诲姟
@@ -114,8 +121,8 @@
/**
* 瀹屾垚琛ㄥ崟鎻愪氦浠诲姟/鏅�氫换鍔�
*
- * @param taskId 浠诲姟id
- * @param variables 琛ㄥ崟鏁版嵁
+ * @param taskId 浠诲姟id
+ * @param variables 琛ㄥ崟鏁版嵁
* @return
*/
@Override
@@ -126,7 +133,7 @@
return AjaxResult.error("浠诲姟涓嶅瓨鍦�");
}
Map<String, Object> newV = new HashMap<>(2);
- if (! org.springframework.util.CollectionUtils.isEmpty(variables)) {
+ if (!org.springframework.util.CollectionUtils.isEmpty(variables)) {
for (String key : variables.keySet()) {
newV.put(task.getTaskDefinitionKey() + "&" + key, variables.get(key));
// if (ProcessConstants.TASK_FORM_KEY.equals(key)) {
@@ -310,7 +317,6 @@
if (!isSequential) {
throw new CustomException("褰撳墠鑺傜偣鐩稿浜庣洰鏍囪妭鐐癸紝涓嶅睘浜庝覆琛屽叧绯伙紝鏃犳硶鍥為��");
}
-
// 鑾峰彇鎵�鏈夋甯歌繘琛岀殑浠诲姟鑺傜偣 Key锛岃繖浜涗换鍔′笉鑳界洿鎺ヤ娇鐢紝闇�瑕佹壘鍑哄叾涓渶瑕佹挙鍥炵殑浠诲姟
List<Task> runTaskList = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId()).list();
@@ -792,6 +798,11 @@
.processInstanceId(procInsId)
.orderByHistoricActivityInstanceStartTime()
.desc().list();
+ Date now = new Date();
+ //鎵╁睍 鑾峰彇杩欎釜娴佺▼瀹炰緥鐨勭洃鎺т俊鎭� key:TaskId value:瀹炰綋绫�
+ Map<String, ProcessCoding> processCodingMap = processCodingMapper.selectList(new QueryWrapper<ProcessCoding>().eq("process_ins_id", procInsId))
+ .stream()
+ .collect(Collectors.toMap(ProcessCoding::getTaskId, Function.identity()));
List<FlowTaskDto> hisFlowList = new ArrayList<>();
for (HistoricActivityInstance histIns : list) {
// 灞曠ず寮�濮嬭妭鐐�
@@ -850,6 +861,21 @@
}
flowTask.setDuration(histIns.getDurationInMillis() == null || histIns.getDurationInMillis() == 0 ? null : getDate(histIns.getDurationInMillis()));
+ //鎵╁睍 鍒ゆ柇鏄惁瓒呮椂
+ ProcessCoding processCoding = processCodingMap.get(histIns.getTaskId());
+ if(processCoding!=null){
+ //濡傛灉浠诲姟鏄唬鍔炶妭鐐�
+ if (flowTask.getDuration() == null) {
+ if(RED.equals(processCoding.getStatus()) || YELLOW.equals(processCoding.getStatus())){
+ flowTask.setOvertime(processCoding.getStatus());
+ }
+ }else {
+ //濡傛灉浠诲姟鑺傜偣灞炰簬鍘嗗彶鑺傜偣
+ if(RED.equals(processCoding.getStatus())){
+ flowTask.setOvertime(processCoding.getStatus());
+ };
+ }
+ }
// 鑾峰彇鎰忚璇勮鍐呭
List<Comment> commentList = taskService.getProcessInstanceComments(histIns.getProcessInstanceId());
commentList.forEach(comment -> {
@@ -1095,6 +1121,7 @@
@Override
public AjaxResult flowXmlAndNode(String procInsId, String deployId) {
try {
+
List<FlowViewerDto> flowViewerList = new ArrayList<>();
// 鑾峰彇宸茬粡瀹屾垚鐨勮妭鐐�
List<HistoricActivityInstance> listFinished = historyService.createHistoricActivityInstanceQuery()
@@ -1102,11 +1129,21 @@
.finished()
.list();
+ //鑾峰彇杩欎釜娴佺▼瀹炰緥鐨勭洃鎺т俊鎭� key:TaskId value:瀹炰綋绫�
+ Map<String, ProcessCoding> processCodingMap = processCodingMapper.selectList(new QueryWrapper<ProcessCoding>().eq("process_ins_id", procInsId))
+ .stream()
+ .collect(Collectors.toMap(ProcessCoding::getTaskId, Function.identity()));
// 淇濆瓨宸茬粡瀹屾垚鐨勬祦绋嬭妭鐐圭紪鍙�
listFinished.forEach(s -> {
FlowViewerDto flowViewerDto = new FlowViewerDto();
flowViewerDto.setKey(s.getActivityId());
flowViewerDto.setCompleted(true);
+ //鎵╁睍鍐呭 涓嶅弽overtime鍓嶇榛樿鏄豢鑹�
+ ProcessCoding processCoding = processCodingMap.get(s.getTaskId());
+ //濡傛灉鏈夌洃鎺ф暟鎹�, 鍘嗗彶鑺傜偣鍙垽鏂孩鐮�
+ if (processCoding != null && RED.equals(processCoding.getStatus())) {
+ flowViewerDto.setOvertime(processCoding.getStatus());
+ }
// 閫�鍥炶妭鐐逛笉杩涜灞曠ず
if (StringUtils.isBlank(s.getDeleteReason())) {
flowViewerList.add(flowViewerDto);
@@ -1118,7 +1155,6 @@
.processInstanceId(procInsId)
.unfinished()
.list();
-
// 淇濆瓨闇�瑕佷唬鍔炵殑鑺傜偣缂栧彿
listUnFinished.forEach(s -> {
// 鍒犻櫎宸查��鍥炶妭鐐�
@@ -1126,6 +1162,12 @@
FlowViewerDto flowViewerDto = new FlowViewerDto();
flowViewerDto.setKey(s.getActivityId());
flowViewerDto.setCompleted(false);
+ // 鎵╁睍鍐呭 浠e姙鐨勯�氳繃褰撳墠鏃堕棿浣滀负endTime
+ ProcessCoding processCoding = processCodingMap.get(s.getTaskId());
+ //濡傛灉鏈夌洃鎺ф暟鎹� 涓嶅弽鐨勮瘽鍓嶇榛樿鏄繘琛屼腑(钃濊壊)
+ if (processCoding != null && (RED.equals(processCoding.getStatus()) || YELLOW.equals(processCoding.getStatus()))) {
+ flowViewerDto.setOvertime(processCoding.getStatus());
+ }
flowViewerList.add(flowViewerDto);
});
Map<String, Object> result = new HashMap();
@@ -1137,6 +1179,7 @@
result.put("xmlData", xmlData);
return AjaxResult.success(result);
} catch (Exception e) {
+ e.printStackTrace();
return AjaxResult.error("楂樹寒鍘嗗彶浠诲姟澶辫触");
}
}
@@ -1186,15 +1229,15 @@
/**
* 鑾峰彇褰撳墠鑺傜偣鍜屼笂涓�鑺傜偣鐨勮〃鍗曞唴瀹�
*
- * @param parameters 鏍规嵁浠诲姟鏌ユ壘鍑烘潵鐨勫弬鏁�
- * @param formKey task鑷韩鍏宠仈鐨勮〃鍗昳d
- * @param taskName task鑷韩鐨勪换鍔″悕
- * @param processDefId 娴佺▼瀹氫箟id
+ * @param parameters 鏍规嵁浠诲姟鏌ユ壘鍑烘潵鐨勫弬鏁�
+ * @param formKey task鑷韩鍏宠仈鐨勮〃鍗昳d
+ * @param taskName task鑷韩鐨勪换鍔″悕
+ * @param processDefId 娴佺▼瀹氫箟id
* @param processDefKey 娴佺▼瀹炰緥id
* @return
*/
private List<FormDetailVO> getBeforeNodeForm(Map<String, Object> parameters, String formKey, String taskName, String processDefId, String processDefKey, Boolean currentNeedData) {
- if (! parameters.keySet().stream().anyMatch(key -> key.contains(ProcessConstants.TASK_FORM_KEY))) {
+ if (!parameters.keySet().stream().anyMatch(key -> key.contains(ProcessConstants.TASK_FORM_KEY))) {
// 濡傛灉鏄┖鐨勶紝浣跨敤formId鍘绘煡
if (StringUtils.isNotBlank(formKey)) {
SysForm sysForm = sysFormService.selectSysFormById(Long.parseLong(formKey));
@@ -1213,28 +1256,29 @@
}
}
// 杩欓噷鍙渶瑕佹煡鑷韩浠ュ強涓婁竴涓妭鐐�(濡傛灉骞惰鐨勬湁澶氫釜)鐨勮〃鍗曟暟鎹�
- List<FormDetailVO> beforeNodes = taskCommonService.getBeforeNodeDefId(processDefId, processDefKey, sysFormService, Boolean.TRUE);
+ List<FormDetailVO> beforeNodes = taskCommonService.getBeforeNodeDefInfo(processDefId, processDefKey, sysFormService, Boolean.TRUE);
List<String> beforeNodeDefIds = beforeNodes.stream().filter(item -> !item.getCurrent() || currentNeedData).map(FormDetailVO::getBeforeNodeDefId).collect(Collectors.toList());
- Map<String, Object> newP = new HashMap<>();
- if (CollectionUtils.isNotEmpty(beforeNodeDefIds)) {
- for (String key : parameters.keySet()) {
- // 杩囨护鐩爣鏁版嵁锛屽皢鐩爣琛ㄥ崟鏁版嵁鏀惧埌鏂癿ap涓�
- if (beforeNodeDefIds.stream().anyMatch(defId -> key.startsWith(defId))) {
- if (key.contains(ProcessConstants.TASK_FORM_KEY)) {
- newP.put(key, parameters.get(key));
- }
- else {
- newP.put(key.split("&")[1], parameters.get(key));
- }
- }
- }
- }
- // 鎷垮埌鐩爣琛ㄥ崟鍚庯紝鍐嶅鐞嗘瘡涓〃鍗曠殑鏁版嵁
+ // 澶勭悊姣忎釜琛ㄥ崟鐨勬暟鎹�
for (FormDetailVO formDetailVO : beforeNodes) {
if (formDetailVO.getCurrent() && !currentNeedData) {
continue; // 璺宠繃褰撳墠鑺傜偣锛屽洜涓哄綋鍓嶈妭鐐瑰湪鑾峰彇鍓嶇疆鑺傜偣鏃跺凡缁忚缃繃浜�(浣嗚〃鍗曟暟鎹病鏈夌粰)
}
+
+ Map<String, Object> newP = new HashMap<>();
+ if (CollectionUtils.isNotEmpty(beforeNodeDefIds)) {
+ for (String key : parameters.keySet()) {
+ // 杩囨护鎷垮埌鐩爣琛ㄥ崟鏁版嵁锛屽皢鐩爣琛ㄥ崟鏁版嵁鏀惧埌鏂癿ap涓�
+ if (key.startsWith(formDetailVO.getBeforeNodeDefId())) {
+ if (key.contains(ProcessConstants.TASK_FORM_KEY)) {
+ newP.put(key, parameters.get(key));
+ } else {
+ newP.put(key.split("&")[1], parameters.get(key));
+ }
+ }
+ }
+ }
+
Object form = newP.get(formDetailVO.getBeforeNodeDefId() + "&" + ProcessConstants.TASK_FORM_KEY);
if (Objects.nonNull(form)) {
JSONObject formJson = JSONObject.parseObject(JSON.toJSONString(form));
--
Gitblit v1.8.0