|
|
|
@@ -1,14 +1,17 @@ |
|
|
|
package com.iformall.controller; |
|
|
|
|
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.domain.po.WxRentContract; |
|
|
|
import com.iformall.enums.EnumFlowKey; |
|
|
|
import com.iformall.service.FlowableService; |
|
|
|
import com.iformall.enums.EnumRentContractAppStatus; |
|
|
|
import com.iformall.service.WxRentContractService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.collections.map.HashedMap; |
|
|
|
import org.flowable.bpmn.model.BpmnModel; |
|
|
|
import org.flowable.common.engine.impl.identity.Authentication; |
|
|
|
import org.flowable.engine.*; |
|
|
|
import org.flowable.engine.history.HistoricProcessInstance; |
|
|
|
import org.flowable.engine.runtime.Execution; |
|
|
|
import org.flowable.engine.runtime.ProcessInstance; |
|
|
|
import org.flowable.engine.task.Comment; |
|
|
|
@@ -38,6 +41,22 @@ public class FlowAbleController extends BaseController { |
|
|
|
private RepositoryService repositoryService; |
|
|
|
@Autowired |
|
|
|
private ProcessEngine processEngine; |
|
|
|
@Autowired |
|
|
|
private WxRentContractService wxRentContractService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 1合同 2账单 |
|
|
|
* @param flowType |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String getFlowKeyByType(int flowType){ |
|
|
|
if(1 == flowType){ |
|
|
|
return EnumFlowKey.CONTRACT.getCode(); |
|
|
|
}else if(2 == flowType){ |
|
|
|
return EnumFlowKey.BILL.getCode(); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("启动流程") |
|
|
|
@PostMapping("/start") |
|
|
|
@@ -50,6 +69,8 @@ public class FlowAbleController extends BaseController { |
|
|
|
String firstTaskUserId = params.get("firstTaskUserId"); |
|
|
|
String secondTaskUserId = params.get("secondTaskUserId"); |
|
|
|
String remark = params.get("remark"); |
|
|
|
Long businessId = Long.parseLong(params.get("businessId")); |
|
|
|
Integer flowType = Integer.parseInt(params.get("flowType")); |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
// 设置节点处理人 |
|
|
|
@@ -60,9 +81,16 @@ public class FlowAbleController extends BaseController { |
|
|
|
map.put("starter", super.getUser().getName()); |
|
|
|
map.put("startTime",new Date().getTime()); |
|
|
|
map.put("remark",remark); |
|
|
|
map.put("businessId",businessId); |
|
|
|
|
|
|
|
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(EnumFlowKey.CONTRACT.getCode(), map); |
|
|
|
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(getFlowKeyByType(flowType), map); |
|
|
|
logger.debug("流程启动,流程id:{}",processInstance.getId()); |
|
|
|
|
|
|
|
// 合同审核状态改为审核中 |
|
|
|
WxRentContract wxRentContract = new WxRentContract(); |
|
|
|
wxRentContract.setId(businessId); |
|
|
|
wxRentContract.setApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); |
|
|
|
wxRentContractService.updateApplyStatus(wxRentContract); |
|
|
|
return new ResultData(); |
|
|
|
}catch (Exception e){ |
|
|
|
logger.error("启动流程发生错误",e); |
|
|
|
@@ -80,13 +108,8 @@ public class FlowAbleController extends BaseController { |
|
|
|
@ResponseBody |
|
|
|
public Object list(@RequestBody Map<String, Object> params) { |
|
|
|
String userId = (String)params.get("userId"); |
|
|
|
Integer flowType = (Integer)params.get("flowType"); //1合同审批 2账单审批 |
|
|
|
String flowKey = ""; |
|
|
|
if(1 == flowType){ |
|
|
|
flowKey = EnumFlowKey.CONTRACT.getCode(); |
|
|
|
}else if(2 == flowType){ |
|
|
|
flowKey = EnumFlowKey.BILL.getCode(); |
|
|
|
} |
|
|
|
Integer flowType = (Integer)params.get("flowType"); |
|
|
|
String flowKey = getFlowKeyByType(flowType); |
|
|
|
|
|
|
|
List<Task> tasks = taskService.createTaskQuery().processDefinitionKey(flowKey).taskCandidateUser(userId).orderByTaskCreateTime().desc().list(); |
|
|
|
List<Map<String,Object>> result = new ArrayList<>(); |
|
|
|
@@ -130,9 +153,17 @@ public class FlowAbleController extends BaseController { |
|
|
|
String taskId = params.get("taskId"); |
|
|
|
String processInstanceId = params.get("processInstanceId"); |
|
|
|
String remark = params.get("remark"); |
|
|
|
String businessId = params.get("businessId"); |
|
|
|
|
|
|
|
taskService.addComment(taskId,processInstanceId,remark); |
|
|
|
runtimeService.deleteProcessInstance(processInstanceId, "驳回"); |
|
|
|
|
|
|
|
// 修改合同审核状态为驳回 |
|
|
|
WxRentContract wxRentContract = new WxRentContract(); |
|
|
|
wxRentContract.setId(Long.parseLong(businessId)); |
|
|
|
wxRentContract.setApplyStatus(EnumRentContractAppStatus.REJECT.getCode()); |
|
|
|
wxRentContractService.updateApplyStatus(wxRentContract); |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -142,7 +173,7 @@ public class FlowAbleController extends BaseController { |
|
|
|
* @param processInstanceId 流程实例ID |
|
|
|
*/ |
|
|
|
@ApiOperation("审批记录") |
|
|
|
@PostMapping(value = "applyHistory") |
|
|
|
@GetMapping(value = "applyHistory") |
|
|
|
@ResponseBody |
|
|
|
public String applyHistory(String processInstanceId) { |
|
|
|
List<HistoricTaskInstance> list = processEngine.getHistoryService() |
|
|
|
@@ -162,6 +193,7 @@ public class FlowAbleController extends BaseController { |
|
|
|
System.out.println("===================================="); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return "ok!"; |
|
|
|
} |
|
|
|
|
|
|
|
|