Преглед изворни кода

流程表中 加入部署ID

java110 пре 5 година
родитељ
комит
a9ca1391df

+ 11 - 0
java110-bean/src/main/java/com/java110/dto/workflow/WorkflowDto.java

@@ -24,6 +24,8 @@ public class WorkflowDto extends PageDto implements Serializable {
     public static final String FLOW_TYPE_PURCHASE= "30003";
     public static final String DEFAULT_SKIP_LEVEL = "1";
 
+    public static final String DEFAULT_PROCESS = "java110_" ;
+
     private String skipLevel;
     private String describle;
     private String communityId;
@@ -32,6 +34,7 @@ public class WorkflowDto extends PageDto implements Serializable {
     private String flowName;
     private String flowType;
     private String flowTypeName;
+    private String processDefinitionKey;
 
 
     private Date createTime;
@@ -130,4 +133,12 @@ public class WorkflowDto extends PageDto implements Serializable {
     public void setWorkflowSteps(List<WorkflowStepDto> workflowSteps) {
         this.workflowSteps = workflowSteps;
     }
+
+    public String getProcessDefinitionKey() {
+        return processDefinitionKey;
+    }
+
+    public void setProcessDefinitionKey(String processDefinitionKey) {
+        this.processDefinitionKey = processDefinitionKey;
+    }
 }

+ 7 - 0
java110-bean/src/main/java/com/java110/po/workflow/WorkflowPo.java

@@ -11,6 +11,7 @@ public class WorkflowPo implements Serializable {
     private String flowId;
     private String flowName;
     private String flowType;
+    private String processDefinitionKey;
 
     public String getSkipLevel() {
         return skipLevel;
@@ -68,5 +69,11 @@ public class WorkflowPo implements Serializable {
         this.flowType = flowType;
     }
 
+    public String getProcessDefinitionKey() {
+        return processDefinitionKey;
+    }
 
+    public void setProcessDefinitionKey(String processDefinitionKey) {
+        this.processDefinitionKey = processDefinitionKey;
+    }
 }

+ 1 - 1
java110-core/src/main/java/com/java110/core/smo/common/IWorkflowInnerServiceSMO.java

@@ -45,5 +45,5 @@ public interface IWorkflowInnerServiceSMO {
      * @Description:创建流程并部署
      */
     @RequestMapping(value = "/addFlowDeployment", method = RequestMethod.POST)
-    void addFlowDeployment(@RequestBody WorkflowDto workflowDto);
+    WorkflowDto addFlowDeployment(@RequestBody WorkflowDto workflowDto);
 }

+ 11 - 6
java110-db/src/main/resources/mapper/common/WorkflowServiceDaoImplMapper.xml

@@ -7,9 +7,9 @@
     <!-- 保存工作流信息 add by wuxw 2018-07-03 -->
     <insert id="saveBusinessWorkflowInfo" parameterType="Map">
         insert into business_workflow(
-        skip_level,operate,describle,b_id,community_id,store_id,flow_id,flow_name,flow_type
+        skip_level,operate,describle,b_id,community_id,store_id,flow_id,flow_name,flow_type,process_definition_key
         ) values (
-        #{skipLevel},#{operate},#{describle},#{bId},#{communityId},#{storeId},#{flowId},#{flowName},#{flowType}
+        #{skipLevel},#{operate},#{describle},#{bId},#{communityId},#{storeId},#{flowId},#{flowName},#{flowType},#{processDefinitionKey}
         )
     </insert>
 
@@ -18,7 +18,7 @@
     <select id="getBusinessWorkflowInfo" parameterType="Map" resultType="Map">
         select t.skip_level,t.skip_level skipLevel,t.operate,t.describle,t.b_id,t.b_id bId,t.community_id,t.community_id
         communityId,t.store_id,t.store_id storeId,t.flow_id,t.flow_id flowId,t.flow_name,t.flow_name
-        flowName,t.flow_type,t.flow_type flowType
+        flowName,t.flow_type,t.flow_type flowType,t.process_definition_key,t.process_definition_key processDefinitionKey
         from business_workflow t
         where 1 =1
         <if test="skipLevel !=null and skipLevel != ''">
@@ -55,8 +55,9 @@
     <!-- 保存工作流信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveWorkflowInfoInstance" parameterType="Map">
         insert into workflow(
-        skip_level,describle,status_cd,b_id,community_id,store_id,flow_id,flow_name,flow_type
-        ) select t.skip_level,t.describle,'0',t.b_id,t.community_id,t.store_id,t.flow_id,t.flow_name,t.flow_type from
+        skip_level,describle,status_cd,b_id,community_id,store_id,flow_id,flow_name,flow_type,process_definition_key
+        ) select t.skip_level,t.describle,'0',t.b_id,t.community_id,t.store_id,t.flow_id,t.flow_name,t.flow_type ,t.process_definition_key
+        from
         business_workflow t where 1=1
         <if test="skipLevel !=null and skipLevel != ''">
             and t.skip_level= #{skipLevel}
@@ -91,7 +92,8 @@
     <select id="getWorkflowInfo" parameterType="Map" resultType="Map">
         select t.skip_level,t.skip_level skipLevel,t.describle,t.status_cd,t.status_cd statusCd,t.b_id,t.b_id
         bId,t.community_id,t.community_id communityId,t.store_id,t.store_id storeId,t.flow_id,t.flow_id
-        flowId,t.flow_name,t.flow_name flowName,t.flow_type,t.flow_type flowType,t.create_time createTime,d.name flowTypeName
+        flowId,t.flow_name,t.flow_name flowName,t.flow_type,t.flow_type flowType,t.create_time createTime,d.name flowTypeName,
+        t.process_definition_key,t.process_definition_key processDefinitionKey
         from workflow t
         left join t_dict d on t.flow_type = d.status_cd and d.table_name = 'workflow' and d.table_columns = 'flow_type'
         where 1 =1
@@ -154,6 +156,9 @@
         <if test="flowType !=null and flowType != ''">
             , t.flow_type= #{flowType}
         </if>
+        <if test="processDefinitionKey !=null and processDefinitionKey != ''">
+            , t.process_definition_key= #{processDefinitionKey}
+        </if>
         where 1=1
         <if test="bId !=null and bId != ''">
             and t.b_id= #{bId}

+ 6 - 10
service-api/src/main/java/com/java110/api/listener/workflow/UpdateWorkflowListener.java

@@ -23,10 +23,8 @@ import com.java110.utils.constant.BusinessTypeConstant;
 import com.java110.utils.constant.ServiceCodeWorkflowConstant;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
-import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -132,9 +130,7 @@ public class UpdateWorkflowListener extends AbstractServiceApiPlusListener {
         workflowPo.setFlowName(reqJson.getString("flowName"));
         workflowPo.setCommunityId(reqJson.getString("communityId"));
         workflowPo.setDescrible(reqJson.getString("describle"));
-        super.update(context, workflowPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_WORKFLOW);
 
-        WorkflowDto workflowDto = BeanConvertUtil.covertBean(workflowPo, WorkflowDto.class);
 
         //保存 工作流程步骤
         JSONArray steps = reqJson.getJSONArray("steps");
@@ -184,15 +180,15 @@ public class UpdateWorkflowListener extends AbstractServiceApiPlusListener {
             tmpWorkflowStepDtos.add(tmpWorkflowStepDto);
         }
         //提交
-        commit(context);
+        //commit(context);
 
-        if (context.getResponseEntity().getStatusCode() != HttpStatus.OK) {
-            return;
-        }
 
+        WorkflowDto workflowDto = BeanConvertUtil.covertBean(workflowPo, WorkflowDto.class);
+        WorkflowDto tmpWorkflowDto = workflowInnerServiceSMOImpl.addFlowDeployment(workflowDto);
+        workflowPo.setProcessDefinitionKey(tmpWorkflowDto.getProcessDefinitionKey());
+        super.update(context, workflowPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_WORKFLOW);
         workflowDto.setWorkflowSteps(tmpWorkflowStepDtos);
-        workflowInnerServiceSMOImpl.addFlowDeployment(workflowDto);
-        context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_OK, ResultVo.MSG_OK));
+
     }
 
     private void deleteWorkflowStepAndStaff(DataFlowContext context, JSONObject reqJson, WorkflowStepDto workflowStepDto) {

+ 3 - 0
service-common/src/main/java/com/java110/common/listener/workflow/AbstractWorkflowBusinessServiceDataFlowListener.java

@@ -47,6 +47,8 @@ public abstract class AbstractWorkflowBusinessServiceDataFlowListener extends Ab
         businessWorkflowInfo.put("flowType", businessWorkflowInfo.get("flow_type"));
         businessWorkflowInfo.remove("bId");
         businessWorkflowInfo.put("statusCd", statusCd);
+        businessWorkflowInfo.put("processDefinitionKey", businessWorkflowInfo.get("process_definition_key"));
+
     }
 
 
@@ -77,6 +79,7 @@ public abstract class AbstractWorkflowBusinessServiceDataFlowListener extends Ab
         currentWorkflowInfo.put("flowId", currentWorkflowInfo.get("flow_id"));
         currentWorkflowInfo.put("flowName", currentWorkflowInfo.get("flow_name"));
         currentWorkflowInfo.put("flowType", currentWorkflowInfo.get("flow_type"));
+        currentWorkflowInfo.put("processDefinitionKey", currentWorkflowInfo.get("process_definition_key"));
 
 
         currentWorkflowInfo.put("operate", StatusConstant.OPERATE_DEL);

+ 1 - 0
service-common/src/main/java/com/java110/common/smo/impl/ComplaintUserInnerServiceSMOImpl.java

@@ -65,6 +65,7 @@ public class ComplaintUserInnerServiceSMOImpl extends BaseServiceSMO implements
         variables.put("complaintDto", complaintDto);
         variables.put("userId", complaintDto.getCurrentUserId());
         //开启流程
+        //WorkflowDto.DEFAULT_PROCESS + workflowDto.getFlowId()
         ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("complaint", complaintDto.getComplaintId(), variables);
         //将得到的实例流程id值赋给之前设置的变量
         String processInstanceId = processInstance.getId();

+ 4 - 4
service-common/src/main/java/com/java110/common/smo/impl/WorkflowInnerServiceSMOImpl.java

@@ -23,7 +23,6 @@ import org.activiti.bpmn.model.StartEvent;
 import org.activiti.bpmn.model.UserTask;
 import org.activiti.engine.ProcessEngine;
 import org.activiti.engine.ProcessEngines;
-import org.activiti.engine.RepositoryService;
 import org.activiti.engine.repository.Deployment;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -109,7 +108,7 @@ public class WorkflowInnerServiceSMOImpl extends BaseServiceSMO implements IWork
      * @Date:2017/11/24
      * @Description:创建流程并部署
      */
-    public void addFlowDeployment(@RequestBody WorkflowDto workflowDto) {
+    public WorkflowDto addFlowDeployment(@RequestBody WorkflowDto workflowDto) {
 
         ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
 //
@@ -120,9 +119,10 @@ public class WorkflowInnerServiceSMOImpl extends BaseServiceSMO implements IWork
         BpmnModel model = new BpmnModel();
         Process process = new Process();
         model.addProcess(process);
-        process.setId("java110_" + workflowDto.getFlowId());
+        process.setId(WorkflowDto.DEFAULT_PROCESS + workflowDto.getFlowId());
         process.setName(workflowDto.getFlowName());
         process.setDocumentation(workflowDto.getDescrible());
+        workflowDto.setProcessDefinitionKey(process.getId());
         //添加流程
         //开始节点
         process.addFlowElement(createStartEvent());
@@ -234,7 +234,7 @@ public class WorkflowInnerServiceSMOImpl extends BaseServiceSMO implements IWork
 //            e.printStackTrace();
 //        }
 
-        System.out.println(".........end...");
+        return workflowDto;
     }