Bläddra i källkod

加入流程表设计

wangliang 1 år sedan
förälder
incheckning
b5ea9080af

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TFCustomFlowMapper.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.sop.business.entity.TFCustomFlow;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * <p>
  * 自定义流程表 Mapper 接口
@@ -23,4 +25,11 @@ public interface TFCustomFlowMapper extends BaseMapper<TFCustomFlow> {
      * @return
      */
     TFCustomFlow findMaxVersion(@Param("orgId") Long orgId, @Param("flowName") String flowName, @Param("type") String type);
+
+    /**
+     * 查询流程部署信息
+     *
+     * @return
+     */
+    List<TFCustomFlow> findFlowDeploymentList();
 }

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TFCustomFlowService.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.entity.TFCustomFlow;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 
+import java.util.List;
+
 /**
  * <p>
  * 自定义流程表 服务类
@@ -23,4 +25,11 @@ public interface TFCustomFlowService extends IService<TFCustomFlow> {
      * @return
      */
     TFCustomFlow findMaxVersion(Long orgId, String flowName, TFCustomTypeEnum type);
+
+    /**
+     * 查询流程部署信息
+     *
+     * @return
+     */
+    List<TFCustomFlow> findFlowDeploymentList();
 }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TFCustomFlowServiceImpl.java

@@ -7,6 +7,7 @@ import com.qmth.sop.business.service.TFCustomFlowService;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -32,4 +33,14 @@ public class TFCustomFlowServiceImpl extends ServiceImpl<TFCustomFlowMapper, TFC
     public TFCustomFlow findMaxVersion(Long orgId, String flowName, TFCustomTypeEnum type) {
         return this.baseMapper.findMaxVersion(orgId, flowName, Objects.nonNull(type) ? type.name() : null);
     }
+
+    /**
+     * 查询流程部署信息
+     *
+     * @return
+     */
+    @Override
+    public List<TFCustomFlow> findFlowDeploymentList() {
+        return this.baseMapper.findFlowDeploymentList();
+    }
 }

+ 18 - 0
sop-business/src/main/resources/mapper/TFCustomFlowMapper.xml

@@ -34,4 +34,22 @@
             and tfcf.publish = 1
         </where>
     </select>
+
+    <select id="findFlowDeploymentList" resultType="com.qmth.sop.business.entity.TFCustomFlow">
+        select t.* from t_f_custom_flow t
+                join
+            (
+                select
+                    max(tfcf.id) as id,
+                    tfcf.type,
+                    tfcf.name
+                from
+                    t_f_custom_flow tfcf
+                where
+                    tfcf.enable = 1
+                  and tfcf.publish = 1
+                group by tfcf.type,tfcf.name) temp on
+                temp.id = t.id
+            order by t.create_time
+    </select>
 </mapper>

+ 48 - 60
sop-server/src/main/java/com/qmth/sop/server/api/ActivitiFromHtmlController.java

@@ -1,12 +1,17 @@
 package com.qmth.sop.server.api;
 
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.sop.business.bean.FormPropertyBean;
 import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
+import com.qmth.sop.business.bean.result.FlowResult;
+import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.entity.TFCustomFlow;
 import com.qmth.sop.business.service.ActivitiConsumerService;
 import com.qmth.sop.business.service.TFCustomFlowService;
+import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.JacksonUtil;
 import io.swagger.annotations.*;
 import org.activiti.engine.FormService;
@@ -65,18 +70,20 @@ public class ActivitiFromHtmlController {
         ClassPathResource resource = new ClassPathResource("testform1.zip");
         ZipInputStream zip = new ZipInputStream(resource.getInputStream());
         builder.addZipInputStream(zip);
-        return getFlowStartFormData(builder.deploy().getId());
+        return flowStart(builder.deploy().getId());
+    }
+
+    @ApiOperation(value = "获取流程部署信息")
+    @RequestMapping(value = "/flow/deployment/data", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Map<String, Object> getFlowData() {
+        return Collections.singletonMap("data", tfCustomFlowService.findFlowDeploymentList());
     }
 
-    /**
-     * 获取流程提交表单属性接口
-     *
-     * @return
-     */
     @ApiOperation(value = "获取流程提交表单属性接口")
-    @RequestMapping(value = "/getFlowStartFormData", method = RequestMethod.POST)
+    @RequestMapping(value = "/flow/start", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Map<String, Object> getFlowStartFormData(@ApiParam(value = "部署流程id", required = true) @RequestParam String deploymentId) {
+    public Map<String, Object> flowStart(@ApiParam(value = "部署流程id", required = true) @RequestParam String deploymentId) {
         Map<String, Object> map = new HashMap<>();
         String processDefinitionId = activitiConsumerService.findProcessDefinitionIdByDeploymentId(deploymentId);
 //        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
@@ -109,53 +116,51 @@ public class ActivitiFromHtmlController {
 //            List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
 //            map.put("FormProperty", new FormPropertyBean(null, null, list));
 //        }
-        map.put("FormPropertys", tfCustomFlow.getFlowProcessVar());
-        map.put("processDefinitionId", processDefinitionId);
-        map.put("deploymentId", deploymentId);
+        Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程没有部署数据!"));
+        FlowResult flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
+        Map<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+        for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
+            FlowTaskResult flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
+            if (flowTaskResultTemp.getSetup().intValue() == 1) {
+                map.put("setup", flowTaskResultTemp.getSetup());
+                map.put("formProperties", flowTaskResultTemp.getFormProperty());
+                break;
+            }
+        }
         return map;
     }
 
-    /**
-     * 获取流程提交表单属性接口
-     *
-     * @return
-     */
     @ApiOperation(value = "获取流程表单属性接口")
     @RequestMapping(value = "/getFlowFormData", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
     public Map<String, Object> getFlowFormData(@ApiParam(value = "流程id") @RequestParam(required = false) String flowId,
                                                @ApiParam(value = "流程任务id") @RequestParam(required = false) String taskId) {
-        List<Task> taskList = null;
-        if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
-            taskList = taskService.createTaskQuery().processInstanceId(flowId).list();
-        } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
-            taskList = taskService.createTaskQuery().taskId(taskId).list();
-        }
+//        List<Task> taskList = null;
+//        if (Objects.nonNull(flowId) && !Objects.equals(flowId, "")) {
+//            taskList = taskService.createTaskQuery().processInstanceId(flowId).list();
+//        } else if (Objects.nonNull(taskId) && !Objects.equals(taskId, "")) {
+//            taskList = taskService.createTaskQuery().taskId(taskId).list();
+//        }
         Map<String, Object> varMap = new HashMap<>();
-        if (!CollectionUtils.isEmpty(taskList)) {
-            List<FormPropertyBean> formPropertyList = new LinkedList<>();
-            for (Task t : taskList) {
-                String flowTaskId = t.getId();
-                String processInstanceId = t.getProcessInstanceId();
-                Object o = formService.getRenderedTaskForm(flowTaskId);
-//                List<FormProperty> formProperties = taskFormData.getFormProperties();
-                log.info("taskId:{},flowId:{}", flowTaskId, processInstanceId);
-                if (Objects.nonNull(o)) {
-                    log.info("task formProperties:{}", JacksonUtil.parseJson(o));
-                    List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
-                    formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), list));
-                }
-            }
-            varMap.put("formProperties", formPropertyList);
-        }
+//        if (!CollectionUtils.isEmpty(taskList)) {
+//            List<FormPropertyBean> formPropertyList = new LinkedList<>();
+//            for (Task t : taskList) {
+//                String flowTaskId = t.getId();
+//                String processInstanceId = t.getProcessInstanceId();
+//                Object o = formService.getRenderedTaskForm(flowTaskId);
+////                List<FormProperty> formProperties = taskFormData.getFormProperties();
+//                log.info("taskId:{},flowId:{}", flowTaskId, processInstanceId);
+//                if (Objects.nonNull(o)) {
+//                    log.info("task formProperties:{}", JacksonUtil.parseJson(o));
+//                    List<FlowFormWidgetResult> list = JSONArray.parseArray(o.toString(), FlowFormWidgetResult.class);
+//                    formPropertyList.add(new FormPropertyBean(processInstanceId, flowTaskId, t.getAssignee(), list));
+//                }
+//            }
+//            varMap.put("formProperties", formPropertyList);
+//        }
         return varMap;
     }
 
-    /**
-     * 启动流程
-     *
-     * @return
-     */
     @ApiOperation(value = "启动流程接口")
     @RequestMapping(value = "/startActivityDemo", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
@@ -196,11 +201,6 @@ public class ActivitiFromHtmlController {
         return varMap;
     }
 
-    /**
-     * 获取待办
-     *
-     * @return
-     */
     @ApiOperation(value = "获取待办接口")
     @RequestMapping(value = "/getTaskList", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
@@ -228,12 +228,6 @@ public class ActivitiFromHtmlController {
         return varMap;
     }
 
-    /**
-     * 提交
-     *
-     * @param taskId
-     * @return
-     */
     @ApiOperation(value = "流程提交接口")
     @RequestMapping(value = "/complete", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
@@ -272,12 +266,6 @@ public class ActivitiFromHtmlController {
         return varMap;
     }
 
-    /**
-     * 根据流程id直接结束流程
-     *
-     * @return
-     * @paramru
-     */
     @ApiOperation(value = "结束流程接口")
     @RequestMapping(value = "/deleteProcessInstance", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})