From 8c85bd0ceef4b1c7ba6c6b5a109d15c74d9e0176 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期三, 01 四月 2026 14:14:06 +0800
Subject: [PATCH] 兼容postgresql
---
business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java | 146 ++++++++++++++++++++++++++++++++----------------
1 files changed, 97 insertions(+), 49 deletions(-)
diff --git a/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java b/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
index bf9dcf8..11abb1c 100644
--- a/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -20,6 +20,7 @@
import com.ycl.common.enums.business.TaskStatusEnum;
import com.ycl.common.exception.CustomException;
import com.ycl.common.utils.SecurityUtils;
+import com.ycl.constant.ProjectConstant;
import com.ycl.domain.dto.FlowCommentDto;
import com.ycl.domain.dto.FlowNextDto;
import com.ycl.domain.dto.FlowTaskDto;
@@ -73,6 +74,7 @@
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -109,6 +111,9 @@
private final ProcessLogService processLogService;
private final ApplicationEventPublisher publisher;
private final ProjectProcessMapper projectProcessMapper;
+
+ @Value("${targetIp}")
+ private String targetIp;
/**
* 瀹屾垚瀹℃牳浠诲姟
@@ -1445,7 +1450,6 @@
public AjaxResult currentFlowTaskForm(String taskId) {
// 娴佺▼鍙橀噺
List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
- .includeProcessVariables()
.finished()
.taskId(taskId)
.orderByHistoricTaskInstanceStartTime()
@@ -1455,7 +1459,19 @@
return AjaxResult.error("鏈壘鍒拌浠诲姟淇℃伅");
}
HistoricTaskInstance historicTaskInstance = hisTaskList.get(0);
- Map<String, Object> parameters = historicTaskInstance.getProcessVariables();
+ ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(historicTaskInstance.getProcessInstanceId()).singleResult();
+ Map<String, Object> parameters = new HashMap<>();
+ if (Objects.nonNull(processInstance)) {
+ parameters = processInstance.getProcessVariables();
+ } else {
+ // 濡傛灉涓虹┖锛岃〃鏄庢祦绋嬪凡缁忕粨鏉�
+ HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processInstanceId(historicTaskInstance.getProcessInstanceId()).singleResult();
+ if (Objects.isNull(historicProcessInstance)) {
+ throw new RuntimeException("娴佺▼涓嶅瓨鍦�");
+ }
+ parameters = historicProcessInstance.getProcessVariables();
+ }
+
String processInsId = historicTaskInstance.getProcessInstanceId();
List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters,
historicTaskInstance.getFormKey(),
@@ -1504,36 +1520,55 @@
@Override
public AjaxResult flowTaskForm(String taskId) throws Exception {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
- // 娴佺▼鍙橀噺
- Map<String, Object> parameters = new HashMap<>();
- List<FormDetailVO> beforeNodes = new ArrayList<>();
+ // 1. 鑾峰彇鍒板彉閲忎俊鎭紝鍥犱负浠诲姟鍙兘鏄繍琛屼腑鐨勪篃鍙兘鏄巻鍙蹭换鍔�
String processInsId = "";
- List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
- .includeProcessVariables()
- .finished()
- .taskId(taskId)
- .orderByHistoricTaskInstanceStartTime()
- .desc()
- .list();
- if (CollectionUtils.isNotEmpty(hisTaskList) && Objects.nonNull(hisTaskList.get(0))) {
- parameters = hisTaskList.get(0).getProcessVariables();
- processInsId = hisTaskList.get(0).getProcessInstanceId();
- beforeNodes = this.getBeforeNodeForm(parameters,
- hisTaskList.get(0).getFormKey(),
- hisTaskList.get(0).getName(),
- hisTaskList.get(0).getProcessDefinitionId(),
- hisTaskList.get(0).getTaskDefinitionKey(),
- Boolean.FALSE, Boolean.TRUE);
+ String processDefId = "";
+ String formKey = "";
+ String taskName = "";
+ String taskDefKey = "";
+ if (Objects.isNull(task)) {
+ List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+ .finished()
+ .taskId(taskId)
+ .orderByHistoricTaskInstanceStartTime()
+ .desc()
+ .list();
+ if (CollectionUtils.isEmpty(hisTaskList) || Objects.isNull(hisTaskList.get(0))) {
+ return AjaxResult.error("浠诲姟涓嶅瓨鍦�");
+ }
+ HistoricTaskInstance hisTask = hisTaskList.get(0);
+ processInsId = hisTask.getProcessInstanceId();
+ processDefId = hisTask.getProcessDefinitionId();
+ formKey = hisTask.getFormKey();
+ taskName = hisTask.getName();
+ taskDefKey = hisTask.getTaskDefinitionKey();
} else {
- parameters = taskService.getVariables(taskId);
processInsId = task.getProcessInstanceId();
- beforeNodes = this.getBeforeNodeForm(parameters,
- task.getFormKey(),
- task.getName(),
- task.getProcessDefinitionId(),
- task.getTaskDefinitionKey(),
- Boolean.FALSE, Boolean.TRUE);
+ processDefId = task.getProcessDefinitionId();
+ formKey = task.getFormKey();
+ taskName = task.getName();
+ taskDefKey = task.getTaskDefinitionKey();
}
+ // 2. 鑾峰彇娴佺▼鍙橀噺
+ ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(processInsId).singleResult();
+ Map<String, Object> parameters = new HashMap<>();
+ if (Objects.nonNull(processInstance)) {
+ parameters = processInstance.getProcessVariables();
+ } else {
+ // 濡傛灉涓虹┖锛岃〃鏄庢祦绋嬪凡缁忕粨鏉�
+ HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processInstanceId(processInsId).singleResult();
+ if (Objects.isNull(historicProcessInstance)) {
+ throw new RuntimeException("娴佺▼涓嶅瓨鍦�");
+ }
+ parameters = historicProcessInstance.getProcessVariables();
+ }
+ List<FormDetailVO> beforeNodes = new ArrayList<>();
+ beforeNodes = this.getBeforeNodeForm(parameters,
+ formKey,
+ taskName,
+ processDefId,
+ taskDefKey,
+ Boolean.TRUE, Boolean.FALSE);
// 鍒ゆ柇鍓嶇疆浠诲姟鏄笉鏄拰褰撳墠浠诲姟涓哄悓涓�涓猠xecuteId
// 鍒ゆ柇褰撳墠浠诲姟鏄惁琚寕璧蜂腑
String finalProcessInsId = processInsId;
@@ -1782,6 +1817,7 @@
// 澶勭悊姣忎釜琛ㄥ崟鐨勬暟鎹�
for (FormDetailVO formDetailVO : beforeNodes) {
if (formDetailVO.getCurrent() && !currentNeedData) {
+ // 褰撳墠鑺傜偣鐨勮〃鍗曚篃瑕佸鐞唅p闂
continue; // 璺宠繃褰撳墠鑺傜偣锛屽洜涓哄綋鍓嶈妭鐐瑰湪鑾峰彇鍓嶇疆鑺傜偣鏃跺凡缁忚缃繃浜�(浣嗚〃鍗曟暟鎹病鏈夌粰)
}
@@ -1807,35 +1843,47 @@
if(CollectionUtils.isNotEmpty(oldFields)) {
// 璁剧疆宸插~鍐欑殑琛ㄥ崟涓虹鐢ㄧ姸鎬�
- if (disableInput) {
- for (JSONObject oldField : oldFields) {
- JSONObject options = oldField.getJSONObject("options");
+ for (JSONObject oldField : oldFields) {
+ JSONObject options = oldField.getJSONObject("options");
+ if (disableInput) {
options.put("disabled", true);
}
+ // 澶勭悊鏂囦欢涓婁紶ip闂
+ if ("file-upload".equals(oldField.get("type"))) {
+ options.put("uploadURL", String.format("http://%s:10076/common/upload", this.targetIp));
+ }
}
+
formJson.put(ProcessConstants.WIDGET_LIST, oldFields);
newP.put(ProcessConstants.TASK_FORM_KEY, formJson);
newP.remove(formDetailVO.getBeforeNodeDefId() + "&" + ProcessConstants.TASK_FORM_KEY);
+ // 澶勭悊宸茬粡涓婁紶鐨勬枃浠剁殑ip鍦板潃
+ for (String s : newP.keySet()) {
+ if (ProcessConstants.TASK_FORM_KEY.equals(s)) {
+ continue;
+ }
+ if (s.startsWith("fileupload")) {
+ Object o = newP.get(s);
+ log.info("杈撳嚭object------------銆媨}",JSON.toJSONString(o));
+ if (Objects.isNull(o)) {
+ continue;
+ }
+ List files = (List) o;
+ for (Object file : files) {
+ LinkedHashMap<String, String> fileMap = (LinkedHashMap<String, String>) file;
+ String url = fileMap.get("url");
+ if (StringUtils.isBlank(url)) {
+ continue;
+ }
+ fileMap.put("url", url.replace("42.193.1.25", this.targetIp));
+ if (url.contains("119.6.246.90")){
+ fileMap.put("url", url.replace("119.6.246.90", this.targetIp));
+ }
+ }
+ }
+ }
formDetailVO.setFormJsonObj(newP);
}
- // TODO 鏆傛椂鍙鐞嗙敤鎴蜂换鍔′笂鐨勮〃鍗�
-// if (StringUtils.isNotBlank(task.getFormKey())) {
-// SysForm sysForm = sysFormService.selectSysFormById(Long.parseLong(task.getFormKey()));
-// JSONObject data = JSONObject.parseObject(sysForm.getFormContent());
-// List<JSONObject> newFields = JSON.parseObject(JSON.toJSONString(data.get(ProcessConstants.WIDGET_LIST)), new TypeReference<List<JSONObject>>() {
-// });
-// // 琛ㄥ崟鍥炴樉鏃� 鍔犲叆瀛愯〃鍗曚俊鎭埌娴佺▼鍙橀噺涓�
-// for (JSONObject newField : newFields) {
-// String key = newField.getString("id");
-// // 澶勭悊鍥剧墖涓婁紶缁勪欢鍥炴樉闂
-// if ("picture-upload".equals(newField.getString("type"))) {
-// parameters.put(key, new ArrayList<>());
-// } else {
-// parameters.put(key, null);
-// }
-// }
-// oldFields.addAll(newFields);
-// }
}
}
--
Gitblit v1.8.0