| @@ -1,14 +1,17 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxRentContract; | |||||
| import com.iformall.enums.EnumFlowKey; | 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.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.collections.map.HashedMap; | import org.apache.commons.collections.map.HashedMap; | ||||
| import org.flowable.bpmn.model.BpmnModel; | import org.flowable.bpmn.model.BpmnModel; | ||||
| import org.flowable.common.engine.impl.identity.Authentication; | import org.flowable.common.engine.impl.identity.Authentication; | ||||
| import org.flowable.engine.*; | import org.flowable.engine.*; | ||||
| import org.flowable.engine.history.HistoricProcessInstance; | |||||
| import org.flowable.engine.runtime.Execution; | import org.flowable.engine.runtime.Execution; | ||||
| import org.flowable.engine.runtime.ProcessInstance; | import org.flowable.engine.runtime.ProcessInstance; | ||||
| import org.flowable.engine.task.Comment; | import org.flowable.engine.task.Comment; | ||||
| @@ -38,6 +41,22 @@ public class FlowAbleController extends BaseController { | |||||
| private RepositoryService repositoryService; | private RepositoryService repositoryService; | ||||
| @Autowired | @Autowired | ||||
| private ProcessEngine processEngine; | 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("启动流程") | @ApiOperation("启动流程") | ||||
| @PostMapping("/start") | @PostMapping("/start") | ||||
| @@ -50,6 +69,8 @@ public class FlowAbleController extends BaseController { | |||||
| String firstTaskUserId = params.get("firstTaskUserId"); | String firstTaskUserId = params.get("firstTaskUserId"); | ||||
| String secondTaskUserId = params.get("secondTaskUserId"); | String secondTaskUserId = params.get("secondTaskUserId"); | ||||
| String remark = params.get("remark"); | 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<>(); | HashMap<String, Object> map = new HashMap<>(); | ||||
| // 设置节点处理人 | // 设置节点处理人 | ||||
| @@ -60,9 +81,16 @@ public class FlowAbleController extends BaseController { | |||||
| map.put("starter", super.getUser().getName()); | map.put("starter", super.getUser().getName()); | ||||
| map.put("startTime",new Date().getTime()); | map.put("startTime",new Date().getTime()); | ||||
| map.put("remark",remark); | 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()); | logger.debug("流程启动,流程id:{}",processInstance.getId()); | ||||
| // 合同审核状态改为审核中 | |||||
| WxRentContract wxRentContract = new WxRentContract(); | |||||
| wxRentContract.setId(businessId); | |||||
| wxRentContract.setApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); | |||||
| wxRentContractService.updateApplyStatus(wxRentContract); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| }catch (Exception e){ | }catch (Exception e){ | ||||
| logger.error("启动流程发生错误",e); | logger.error("启动流程发生错误",e); | ||||
| @@ -80,13 +108,8 @@ public class FlowAbleController extends BaseController { | |||||
| @ResponseBody | @ResponseBody | ||||
| public Object list(@RequestBody Map<String, Object> params) { | public Object list(@RequestBody Map<String, Object> params) { | ||||
| String userId = (String)params.get("userId"); | 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<Task> tasks = taskService.createTaskQuery().processDefinitionKey(flowKey).taskCandidateUser(userId).orderByTaskCreateTime().desc().list(); | ||||
| List<Map<String,Object>> result = new ArrayList<>(); | List<Map<String,Object>> result = new ArrayList<>(); | ||||
| @@ -130,9 +153,17 @@ public class FlowAbleController extends BaseController { | |||||
| String taskId = params.get("taskId"); | String taskId = params.get("taskId"); | ||||
| String processInstanceId = params.get("processInstanceId"); | String processInstanceId = params.get("processInstanceId"); | ||||
| String remark = params.get("remark"); | String remark = params.get("remark"); | ||||
| String businessId = params.get("businessId"); | |||||
| taskService.addComment(taskId,processInstanceId,remark); | taskService.addComment(taskId,processInstanceId,remark); | ||||
| runtimeService.deleteProcessInstance(processInstanceId, "驳回"); | runtimeService.deleteProcessInstance(processInstanceId, "驳回"); | ||||
| // 修改合同审核状态为驳回 | |||||
| WxRentContract wxRentContract = new WxRentContract(); | |||||
| wxRentContract.setId(Long.parseLong(businessId)); | |||||
| wxRentContract.setApplyStatus(EnumRentContractAppStatus.REJECT.getCode()); | |||||
| wxRentContractService.updateApplyStatus(wxRentContract); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -142,7 +173,7 @@ public class FlowAbleController extends BaseController { | |||||
| * @param processInstanceId 流程实例ID | * @param processInstanceId 流程实例ID | ||||
| */ | */ | ||||
| @ApiOperation("审批记录") | @ApiOperation("审批记录") | ||||
| @PostMapping(value = "applyHistory") | |||||
| @GetMapping(value = "applyHistory") | |||||
| @ResponseBody | @ResponseBody | ||||
| public String applyHistory(String processInstanceId) { | public String applyHistory(String processInstanceId) { | ||||
| List<HistoricTaskInstance> list = processEngine.getHistoryService() | List<HistoricTaskInstance> list = processEngine.getHistoryService() | ||||
| @@ -162,6 +193,7 @@ public class FlowAbleController extends BaseController { | |||||
| System.out.println("===================================="); | System.out.println("===================================="); | ||||
| } | } | ||||
| } | } | ||||
| return "ok!"; | return "ok!"; | ||||
| } | } | ||||
| @@ -1,12 +0,0 @@ | |||||
| package com.iformall.flowable; | |||||
| import org.flowable.engine.delegate.TaskListener; | |||||
| import org.flowable.task.service.delegate.DelegateTask; | |||||
| public class BossTaskHandler implements TaskListener { | |||||
| @Override | |||||
| public void notify(DelegateTask delegateTask) { | |||||
| delegateTask.setAssignee("老板"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,28 @@ | |||||
| package com.iformall.flowable; | |||||
| import com.iformall.domain.po.WxRentContract; | |||||
| import com.iformall.enums.EnumRentContractAppStatus; | |||||
| import com.iformall.service.WxRentContractService; | |||||
| import org.flowable.engine.delegate.TaskListener; | |||||
| import org.flowable.task.service.delegate.DelegateTask; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * 合同审批完成,修改状态 | |||||
| */ | |||||
| @Component(value="contractTaskFinishListener") | |||||
| public class ContractTaskFinishHandler implements TaskListener { | |||||
| @Autowired | |||||
| private WxRentContractService wxRentContractService; | |||||
| @Override | |||||
| public void notify(DelegateTask delegateTask) { | |||||
| Long businessId = (Long)delegateTask.getVariable("businessId"); | |||||
| WxRentContract wxRentContract = new WxRentContract(); | |||||
| wxRentContract.setId(businessId); | |||||
| wxRentContract.setApplyStatus(EnumRentContractAppStatus.FINISH.getCode()); | |||||
| wxRentContractService.updateApplyStatus(wxRentContract); | |||||
| } | |||||
| } | |||||
| @@ -1,13 +0,0 @@ | |||||
| package com.iformall.flowable; | |||||
| import org.flowable.engine.delegate.TaskListener; | |||||
| import org.flowable.task.service.delegate.DelegateTask; | |||||
| public class ManagerTaskHandler implements TaskListener { | |||||
| @Override | |||||
| public void notify(DelegateTask delegateTask) { | |||||
| delegateTask.setAssignee("经理"); | |||||
| } | |||||
| } | |||||
| @@ -23,7 +23,7 @@ | |||||
| <userTask id="bossTask" name="老板审批"> | <userTask id="bossTask" name="老板审批"> | ||||
| <extensionElements> | <extensionElements> | ||||
| <flowable:taskListener event="create" | <flowable:taskListener event="create" | ||||
| class="com.iformall.flowable.BossTaskHandler"></flowable:taskListener> | |||||
| class="com.iformall.flowable.ContractTaskFinishHandler"></flowable:taskListener> | |||||
| </extensionElements> | </extensionElements> | ||||
| </userTask> | </userTask> | ||||
| <endEvent id="end" name="结束"></endEvent> | <endEvent id="end" name="结束"></endEvent> | ||||
| @@ -12,6 +12,9 @@ | |||||
| <sequenceFlow id="sid-9FCAF465-99E7-4EFE-BEEA-7D59481E684C" sourceRef="secondTask" targetRef="sid-9692A856-E39A-4B8C-95C2-7C04A3646D6F"></sequenceFlow> | <sequenceFlow id="sid-9FCAF465-99E7-4EFE-BEEA-7D59481E684C" sourceRef="secondTask" targetRef="sid-9692A856-E39A-4B8C-95C2-7C04A3646D6F"></sequenceFlow> | ||||
| <userTask id="secondTask" name="复审" flowable:candidateUsers="${secondTaskUser}"> | <userTask id="secondTask" name="复审" flowable:candidateUsers="${secondTaskUser}"> | ||||
| <documentation>复审</documentation> | <documentation>复审</documentation> | ||||
| <extensionElements> | |||||
| <flowable:taskListener event="complete" delegateExpression="${contractTaskFinishListener}"></flowable:taskListener> | |||||
| </extensionElements> | |||||
| </userTask> | </userTask> | ||||
| </process> | </process> | ||||
| <bpmndi:BPMNDiagram id="BPMNDiagram_contract_flow"> | <bpmndi:BPMNDiagram id="BPMNDiagram_contract_flow"> | ||||
| @@ -180,6 +180,17 @@ public class WxRentContract implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value = "起租结束时间", name = "rentalEndDate") | @io.swagger.annotations.ApiModelProperty(value = "起租结束时间", name = "rentalEndDate") | ||||
| private Date endDate; | private Date endDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "审核状态", name = "applyStatus") | |||||
| private Integer applyStatus; | |||||
| public Integer getApplyStatus() { | |||||
| return applyStatus; | |||||
| } | |||||
| public void setApplyStatus(Integer applyStatus) { | |||||
| this.applyStatus = applyStatus; | |||||
| } | |||||
| public Long getMerchantId() { | public Long getMerchantId() { | ||||
| return merchantId; | return merchantId; | ||||
| } | } | ||||
| @@ -0,0 +1,38 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by luozukai | |||||
| * 合同工作流审核状态 | |||||
| */ | |||||
| public enum EnumRentContractAppStatus { | |||||
| DEFAULT(0, "未审核"), | |||||
| APPLYING(1, "审核中"), | |||||
| FINISH(2, "审核完成"), | |||||
| REJECT(3, "驳回") | |||||
| ; | |||||
| public static EnumRentContractAppStatus getEnum(Integer code) { | |||||
| for (EnumRentContractAppStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumRentContractAppStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -37,4 +37,6 @@ public interface WxRentContractMapper extends CommonMapper<WxRentContract, Strin | |||||
| void updateStatusForUnsign(WxRentContract wxRentContract); | void updateStatusForUnsign(WxRentContract wxRentContract); | ||||
| void updateApplyStatus(WxRentContract wxRentContract); | |||||
| } | } | ||||
| @@ -63,4 +63,6 @@ public interface WxRentContractService { | |||||
| ResultData updateRentContractStatus(Long id); | ResultData updateRentContractStatus(Long id); | ||||
| void updateApplyStatus(WxRentContract wxRentContract); | |||||
| } | } | ||||
| @@ -1190,4 +1190,8 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||||
| return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); | return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整"); | ||||
| } | } | ||||
| @Override | |||||
| public void updateApplyStatus(WxRentContract wxRentContract) { | |||||
| wxRentContractMapper.updateApplyStatus(wxRentContract); | |||||
| } | |||||
| } | } | ||||
| @@ -35,7 +35,8 @@ | |||||
| <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/> | <result column="pay_ratio" jdbcType="INTEGER" property="payRatio"/> | ||||
| <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/> | <result column="start_date" jdbcType="TIMESTAMP" property="startDate"/> | ||||
| <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/> | <result column="end_date" jdbcType="TIMESTAMP" property="endDate"/> | ||||
| <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| @@ -43,7 +44,7 @@ | |||||
| `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`, | `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`, | ||||
| `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`, | `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`, | ||||
| `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`, | `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`, | ||||
| `start_date`,`end_date` | |||||
| `start_date`,`end_date`,`apply_status` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -148,7 +149,12 @@ | |||||
| <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract"> | <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract"> | ||||
| update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status!=7 and merchant_id is null | update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status!=7 and merchant_id is null | ||||
| </update> | </update> | ||||
| <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract"> | |||||
| update wx_rent_contract set apply_status=#{applyStatus} where id=#{id} | |||||
| </update> | |||||
| <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract"> | <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract"> | ||||
| update wx_rent_contract set status=#{status} where shop_id in ( | update wx_rent_contract set status=#{status} where shop_id in ( | ||||
| select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4) | select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4) | ||||