瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

大数据与最优化研究所 1 年之前
父節點
當前提交
2ca58b781a

+ 2 - 2
src/main/java/com/xjrsoft/module/workflow/controller/WorkflowExecuteController.java

@@ -358,9 +358,9 @@ public class WorkflowExecuteController {
 
     @GetMapping("/my-examine")
     @ApiOperation(value = "我的审批")
-    public RT myExamine(@Valid MyExaminePageDto dto){
+    public RT<PageOutput<PendingTaskVo>> myExamine(@Valid MyExaminePageDto dto){
         Page<PendingTaskVo> voPage = workflowExecuteService.myExamine(new Page<>(dto.getLimit(), dto.getSize()), dto);
-        PageOutput<MyExaminePageDto> pageOutput = ConventPage.getPageOutput(voPage, MyExaminePageDto.class);
+        PageOutput<PendingTaskVo> pageOutput = ConventPage.getPageOutput(voPage, PendingTaskVo.class);
         return RT.ok(pageOutput);
     }
 

+ 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);
 

+ 13 - 11
src/main/java/com/xjrsoft/module/workflow/service/impl/WorkflowExecuteServiceImpl.java

@@ -195,12 +195,14 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -1230,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);
 
@@ -1293,10 +1296,6 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                     session.quietRollback();
                 }
                 throw new MyException("【表单id: " + formConfig.getFormId() + "】 提交错误, 请联系管理员!");
-            }finally {
-                for (Session session : sessionList) {
-                    session.close();
-                }
             }
 
         }
@@ -1335,6 +1334,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             for (Session session : sessionList) {
                 session.getConnection().setAutoCommit(Boolean.FALSE);
                 session.commit();
+                session.close();
             }
 
             return result;
@@ -1398,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);
 
@@ -1458,10 +1458,6 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                     session.quietRollback();
                 }
                 throw new MyException("【表单id: " + formConfig.getFormId() + "】 提交错误, 请联系管理员!");
-            }finally {
-                for (Session session : sessionList) {
-                    session.close();
-                }
             }
 
         }
@@ -1497,6 +1493,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             for (Session session : sessionList) {
                 session.getConnection().setAutoCommit(Boolean.FALSE);
                 session.commit();
+                session.close();
             }
 
             HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(dto.getProcessId()).singleResult();
@@ -1534,6 +1531,10 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             } else {
                 throw new MyException("表单提交错误, 请联系系统管理员!");
             }
+        }finally {
+            for (Session session : sessionList) {
+                session.close();
+            }
         }
 
     }
@@ -1618,7 +1619,6 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
         if (taskIds.size() > 0) {
 
             List<WorkflowExtra> workflowExtras = workflowExtraMapper.selectList(Wrappers.lambdaQuery(WorkflowExtra.class).in(WorkflowExtra::getTaskId, taskIds));
-
             for (Task task : tasks) {
                 PendingTaskVo vo = new PendingTaskVo();
                 Optional<WorkflowExtra> extra = workflowExtras.stream().filter(x -> x.getTaskId().equals(task.getId())).findFirst();
@@ -2102,6 +2102,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             for (Session session : sessionList) {
                 session.getConnection().setAutoCommit(Boolean.FALSE);
                 session.commit();
+                session.close();
             }
 
         } catch (Exception e) {
@@ -2427,6 +2428,7 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                 //TODO  如果审批接口 出现Can't call commit when autocommit=true 错误  也可以像这样设置解决
                 session.getConnection().setAutoCommit(false);
                 session.commit();
+                session.close();
             }
         } catch (Exception e) {
             for (Session session : sessionList) {

+ 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);

+ 15 - 1
src/main/java/com/xjrsoft/module/workflow/vo/PendingTaskVo.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.workflow.vo;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.time.LocalDateTime;
@@ -11,36 +12,49 @@ import java.time.LocalDateTime;
  */
 @Data
 public class PendingTaskVo {
-
+    @ApiModelProperty("主键编号")
     private Long id;
 
+    @ApiModelProperty("流水号")
     private Long serialNumber;
 
+    @ApiModelProperty("任务id")
     private String taskId;
 
+    @ApiModelProperty("流程名称")
     private String processName;
 
+    @ApiModelProperty("任务名称")
     private String taskName;
 
+    @ApiModelProperty("任务key")
     private String taskKey;
 
+    @ApiModelProperty("当前进度")
     private Integer currentProgress;
 
     private Long schemaId;
 
     private String schemaName;
 
+    @ApiModelProperty("流程id")
     private String processId;
 
+    @ApiModelProperty("发起人id")
     private Long startUserId;
 
+    @ApiModelProperty("发起人名称")
     private String startUserName;
 
+    @ApiModelProperty("创建时间")
     private LocalDateTime startTime;
 
+    @ApiModelProperty("审批时间")
     private LocalDateTime endTime;
 
+    @ApiModelProperty("任务发起时间")
     private LocalDateTime launchTime;
 
+    @ApiModelProperty("审批人id")
     private String approveUserIds;
 }

+ 4 - 4
src/main/resources/mapper/ledger/WfSubscriptionMapper.xml

@@ -7,9 +7,9 @@
         select t1.id,t2.name as org_name,t3.name as user_name,t1.shen_qing_ri_qi4752,t1.folder_id,t1.number,t1.total_amount from wf_subscription t1
         left join xjr_department t2 on t1.application_department = t2.id
         left join xjr_user t3 on t1.user_id = t3.id
-        where 1 = 1
+        where t1.status = 1
         <if test="dto.orgId != null">
-            and t1.id = #{dto.orgId}
+            and t2.id = #{dto.orgId}
         </if>
         <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != ''">
             and t1.shen_qing_ri_qi4752 between #{dto.startDate} and #{dto.endDate}
@@ -24,9 +24,9 @@
         select t1.id,t2.name as org_name,t3.name as user_name,t1.shen_qing_ri_qi4752, t1.folder_id,t1.number,t1.total_amount from wf_subscription t1
         left join xjr_department t2 on t1.application_department = t2.id
         left join xjr_user t3 on t1.user_id = t3.id
-        where 1 = 1
+        where t1.status = 1
         <if test="dto.orgId != null">
-            and t1.id = #{dto.orgId}
+            and t2.id = #{dto.orgId}
         </if>
         <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != ''">
             and t1.shen_qing_ri_qi4752 between #{dto.startDate} and #{dto.endDate}