فهرست منبع

流程自定义名称调整

dzx 1 سال پیش
والد
کامیت
262760727c

+ 2 - 2
src/main/java/com/xjrsoft/module/workflow/listener/ExecutionDelegate.java

@@ -1022,7 +1022,7 @@ public class ExecutionDelegate implements ExecutionListener {
                     .putValue(WorkflowConstant.PROCESS_SERIAL_NUMBER_KEY, count + 2);
 
             //根据规则生成流程名称
-            String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 2);
+            String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 2, null);
             //根据规则生成流程名称
             variableMap.putValue(WorkflowConstant.PROCESS_NAME, processName);
 
@@ -1075,7 +1075,7 @@ public class ExecutionDelegate implements ExecutionListener {
                     .putValue(WorkflowConstant.PROCESS_ISRECYCLE_FLAG_KEY, WorkflowIsRecycleType.NO.getCode());
 
             //根据规则生成流程名称
-            String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 2);
+            String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 2, null);
             //根据规则生成流程名称
             variableMap.putValue(WorkflowConstant.PROCESS_NAME, processName);
 

+ 3 - 2
src/main/java/com/xjrsoft/module/workflow/service/impl/WorkflowExecuteServiceImpl.java

@@ -1232,9 +1232,10 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
 
         //构建流程默认参数 (全局变量 发起人id、发起人名、模板id 、模板名、页面配置参数值、流水号)等
         VariableMap variableMap = initDefaultParam(workflowSchema, processParam, count);
+        FormTemplate formTemplate = formTemplateMapper.selectById(workflowSchema.getFormId());
 
         //根据规则生成流程名称
-        String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 1);
+        String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 1, dto);
         //根据规则生成流程名称
         variableMap.putValue(WorkflowConstant.PROCESS_NAME, processName);
 
@@ -1397,7 +1398,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
         VariableMap variableMap = initDefaultParam(workflowSchema, processParam, count);
 
         //根据规则生成流程名称
-        String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 1);
+        String processName = WorkFlowUtil.generatorProcessName(workflowSchema, workflowSchemaConfig, count + 1, null);
         //根据规则生成流程名称
         variableMap.putValue(WorkflowConstant.PROCESS_NAME, processName);
 

+ 77 - 6
src/main/java/com/xjrsoft/module/workflow/utils/WorkFlowUtil.java

@@ -13,26 +13,64 @@ import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.db.Db;
 import cn.hutool.extra.spring.SpringUtil;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fasterxml.jackson.core.type.TypeReference;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import com.xjrsoft.common.constant.GlobalConstant;
-import com.xjrsoft.common.enums.*;
+import com.xjrsoft.common.enums.ParamAssignmentType;
+import com.xjrsoft.common.enums.WorkflowAuth;
+import com.xjrsoft.common.enums.WorkflowEventType;
+import com.xjrsoft.common.enums.WorkflowMemberType;
+import com.xjrsoft.common.enums.WorkflowNoticePolicyType;
+import com.xjrsoft.common.enums.WorkflowParamType;
+import com.xjrsoft.common.utils.DatasourceUtil;
 import com.xjrsoft.common.utils.RedisUtil;
+import com.xjrsoft.module.form.entity.FormTemplate;
 import com.xjrsoft.module.magicapi.service.IMagicApiService;
 import com.xjrsoft.module.magicapi.vo.MagicApiInfoVo;
 import com.xjrsoft.module.oa.utils.SendMessageUtil;
-import com.xjrsoft.module.organization.entity.*;
+import com.xjrsoft.module.organization.entity.Department;
+import com.xjrsoft.module.organization.entity.Post;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserDeptRelation;
+import com.xjrsoft.module.organization.entity.UserPostRelation;
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 import com.xjrsoft.module.workflow.constant.WorkflowConstant;
+import com.xjrsoft.module.workflow.dto.LaunchDto;
 import com.xjrsoft.module.workflow.entity.WorkflowApproveRecord;
 import com.xjrsoft.module.workflow.entity.WorkflowDelegate;
 import com.xjrsoft.module.workflow.entity.WorkflowSchema;
-import com.xjrsoft.module.workflow.model.*;
+import com.xjrsoft.module.workflow.model.ApiConfig;
+import com.xjrsoft.module.workflow.model.ApiRequestParamsConfig;
+import com.xjrsoft.module.workflow.model.AssignmentConfig;
+import com.xjrsoft.module.workflow.model.AuthConfig;
+import com.xjrsoft.module.workflow.model.ConditionConfig;
+import com.xjrsoft.module.workflow.model.FormAssignmentConfig;
+import com.xjrsoft.module.workflow.model.FormAssignmentSourceConfig;
+import com.xjrsoft.module.workflow.model.FormConfig;
+import com.xjrsoft.module.workflow.model.FormFieldConfig;
+import com.xjrsoft.module.workflow.model.LeaderConfig;
+import com.xjrsoft.module.workflow.model.MemberConfig;
+import com.xjrsoft.module.workflow.model.NameRuleConfig;
+import com.xjrsoft.module.workflow.model.NodeBasicConfig;
+import com.xjrsoft.module.workflow.model.NoticePolicyParam;
+import com.xjrsoft.module.workflow.model.ParamAssignmentConfig;
+import com.xjrsoft.module.workflow.model.ProcessParamConfig;
+import com.xjrsoft.module.workflow.model.SequenceFlowConfig;
+import com.xjrsoft.module.workflow.model.UserTaskConfig;
+import com.xjrsoft.module.workflow.model.WorkflowSchemaConfig;
 import com.xjrsoft.module.workflow.service.IWorkflowApproveRecordService;
+import com.yomahub.liteflow.util.JsonUtil;
 import lombok.SneakyThrows;
 import org.camunda.bpm.engine.HistoryService;
 import org.camunda.bpm.engine.ProcessEngines;
@@ -40,12 +78,28 @@ import org.camunda.bpm.engine.RepositoryService;
 import org.camunda.bpm.engine.RuntimeService;
 import org.camunda.bpm.engine.history.HistoricVariableInstance;
 import org.camunda.bpm.engine.variable.VariableMap;
-import org.camunda.bpm.model.bpmn.instance.*;
+import org.camunda.bpm.model.bpmn.instance.BaseElement;
+import org.camunda.bpm.model.bpmn.instance.ConditionExpression;
+import org.camunda.bpm.model.bpmn.instance.FlowNode;
+import org.camunda.bpm.model.bpmn.instance.Gateway;
+import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
 import org.camunda.bpm.model.xml.instance.ModelElementInstance;
 import org.ssssssss.magicapi.core.service.MagicAPIService;
 
+import javax.sql.DataSource;
 import java.time.LocalDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
@@ -165,11 +219,28 @@ public class WorkFlowUtil {
      * @param workflowSerialNumber
      * @return
      */
-    public static String generatorProcessName(WorkflowSchema workflowSchema, WorkflowSchemaConfig workflowSchemaConfig, Long workflowSerialNumber) {
+    public static String generatorProcessName(WorkflowSchema workflowSchema, WorkflowSchemaConfig workflowSchemaConfig, Long workflowSerialNumber, LaunchDto dto) {
 
         if (workflowSchemaConfig.getProcessConfig().getNameRuleConfigs().size() == 0) {
             return workflowSchema.getName();
         }
+        if(dto.getFormData() != null){
+            Map<String, Map<String, Object>> formData = dto.getFormData();
+            String title_last = null;
+            for (Map<String, Object> value : formData.values()) {
+                if(title_last != null){
+                    continue;
+                }
+                for (Object o : value.values()) {
+                    if(title_last != null){
+                        continue;
+                    }
+                    title_last = o.toString();
+                }
+            }
+            return "【" + workflowSchema.getName() + "】" + title_last;
+        }
+
         String nameTemplate = workflowSchemaConfig.getProcessConfig().getNameRuleConfigs().stream().map(NameRuleConfig::getKey).map(String::valueOf).collect(Collectors.joining(StringPool.SPACE));
 
         return WorkFlowUtil.replacePlaceHolder(nameTemplate, workflowSchema, workflowSerialNumber, workflowSerialNumber);