|
|
|
@@ -84,15 +84,21 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新业务数据状态 |
|
|
|
* @param businessId 业务id |
|
|
|
* @param flowType 1合同审批流 2账单审批流 3终止合同 |
|
|
|
* @param contractType 1租赁合同 2点位合同wx_rent_contract 3物业wx_property_contract 4点位物业合同 |
|
|
|
* @param applyStatus 状态 |
|
|
|
* @param supplement 是否补录 |
|
|
|
* @param mapInfo |
|
|
|
* @param applyStatus |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void updateBusinessStatus(Long businessId,Integer flowType,Integer contractType,Integer applyStatus,Boolean supplement){ |
|
|
|
logger.info("businessId:{},supplement:{}",businessId.toString(),supplement); |
|
|
|
public void updateBusinessStatus(Map<String, Object> mapInfo,Integer applyStatus){ |
|
|
|
Long businessId = (Long)mapInfo.get("businessId"); |
|
|
|
Integer flowType = (Integer)mapInfo.get("businessType"); |
|
|
|
List<Map<String,String>> variables = (List)mapInfo.get("variables"); |
|
|
|
Boolean supplement = (Boolean)mapInfo.get("supplement"); |
|
|
|
Integer contractType = 0; |
|
|
|
String str = getVariableByKey(variables,"contractType"); |
|
|
|
if(StringUtils.isNotBlank(str)){ |
|
|
|
contractType = Integer.parseInt(str); |
|
|
|
} |
|
|
|
|
|
|
|
if(1 == flowType){ |
|
|
|
if(contractType.intValue() == 1 || contractType.intValue() == 2){ |
|
|
|
WxRentContract rent = new WxRentContract(); |
|
|
|
@@ -128,6 +134,13 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
updateRentContract.setId(businessId); |
|
|
|
updateRentContract.setStatus(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()); |
|
|
|
wxRentContractMapper.updateStatus(updateRentContract); |
|
|
|
|
|
|
|
//终止租赁合同,同时终止物业合同 |
|
|
|
String endProperty = getVariableByKey(variables,"endProperty"); |
|
|
|
if("1".equals(endProperty)){ |
|
|
|
|
|
|
|
} |
|
|
|
// todo 账单失效 |
|
|
|
} |
|
|
|
}else if(contractType.intValue() == 3 || contractType.intValue() == 4){ |
|
|
|
WxPropertyContract wxPropertyContract = new WxPropertyContract(); |
|
|
|
@@ -140,6 +153,8 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
updateRentContract.setId(businessId); |
|
|
|
updateRentContract.setStatus(EnumRentContractStatus.CONTRACT_TERMINATE.getCode()); |
|
|
|
wxPropertyContractMapper.updateStatus(updateRentContract); |
|
|
|
|
|
|
|
// todo 账单失效 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -173,13 +188,7 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(getFlowKeyByType(flowType), map); |
|
|
|
logger.debug("流程启动,流程id:{}",processInstance.getId()); |
|
|
|
|
|
|
|
// 合同审核状态改为审核中 |
|
|
|
Integer contractType = 0; |
|
|
|
String str = getVariableByKey(variables,"contractType"); |
|
|
|
if(StringUtils.isNotBlank(str)){ |
|
|
|
contractType = Integer.parseInt(str); |
|
|
|
} |
|
|
|
updateBusinessStatus(businessId,flowType,contractType,EnumRentContractAppStatus.APPLYING.getCode(),supplement); |
|
|
|
updateBusinessStatus(params,EnumRentContractAppStatus.APPLYING.getCode()); |
|
|
|
|
|
|
|
// 保存wx_flow_record表审批记录 |
|
|
|
WxFlowRecord wxFlowRecord = new WxFlowRecord(); |
|
|
|
@@ -191,7 +200,7 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
wxFlowRecord.setUserName(userName); |
|
|
|
wxFlowRecord.setStatus(EnumFlowRecordStatus.NEW.getCode()); |
|
|
|
wxFlowRecord.setTaskName("发起"); |
|
|
|
wxFlowRecord.setCurrStatus(EnumFlowRecordStatus.NEW.getCode()); |
|
|
|
wxFlowRecord.setCurrStatus(EnumRentContractAppStatus.APPLYING.getCode()); |
|
|
|
wxFlowRecordService.saveOrUpdate(wxFlowRecord); |
|
|
|
|
|
|
|
// 给审批人发送代办通知短信 |
|
|
|
@@ -365,7 +374,7 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
taskService.complete(taskId); |
|
|
|
|
|
|
|
// 判断流程是否结束,并发送短信通知 |
|
|
|
isEndAndSendMsg(mapInfo,taskKey,processInstanceId,tenantId,userName); |
|
|
|
boolean end = isEndAndSendMsg(mapInfo,taskKey,processInstanceId,tenantId,userName); |
|
|
|
|
|
|
|
//保存wx_flow_record表审批记录 |
|
|
|
WxFlowRecord wxFlowRecord = new WxFlowRecord(); |
|
|
|
@@ -380,9 +389,13 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
wxFlowRecord.setTaskName(taskName); |
|
|
|
wxFlowRecord.setTaskKey(taskKey); |
|
|
|
wxFlowRecordService.saveOrUpdate(wxFlowRecord); |
|
|
|
//修改记录表当前状态 |
|
|
|
wxFlowRecordMapper.updateCurrStatus(new WxFlowRecord(processInstanceId,EnumFlowRecordStatus.APPLY.getCode())); |
|
|
|
|
|
|
|
//修改记录表当前状态 |
|
|
|
if(end){ |
|
|
|
wxFlowRecordMapper.updateCurrStatus(new WxFlowRecord(processInstanceId,EnumRentContractAppStatus.FINISH.getCode())); |
|
|
|
}else{ |
|
|
|
wxFlowRecordMapper.updateCurrStatus(new WxFlowRecord(processInstanceId,EnumRentContractAppStatus.APPLYING.getCode())); |
|
|
|
} |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -392,7 +405,7 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
* @param processInstanceId |
|
|
|
* @param tenantId |
|
|
|
*/ |
|
|
|
public void isEndAndSendMsg(Map<String,Object> mapInfo,String taskKey,String processInstanceId,String tenantId,String userName){ |
|
|
|
public boolean isEndAndSendMsg(Map<String,Object> mapInfo,String taskKey,String processInstanceId,String tenantId,String userName){ |
|
|
|
// 发送短信 |
|
|
|
Map<String,String> msgReplaceMap = new HashedMap(); |
|
|
|
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); |
|
|
|
@@ -400,7 +413,6 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
MallUserInfo starter = (MallUserInfo)mapInfo.get("starter"); |
|
|
|
List<Map<String,String>> taskAssigneeList = (List)mapInfo.get("taskAssignee"); |
|
|
|
Long businessId = (Long)mapInfo.get("businessId"); |
|
|
|
Boolean supplement = (Boolean)mapInfo.get("supplement"); |
|
|
|
|
|
|
|
// 判断下个节点是否有设置审批人,没有,直接通过,有,发短信通知 |
|
|
|
if(!isEnded(processInstanceId)){ |
|
|
|
@@ -409,7 +421,7 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
String assignee = ""; |
|
|
|
List<MallUserInfo> mallUserInfoList = getUserByProcessInstanceId(processInstanceId); |
|
|
|
for (MallUserInfo mallUserInfo:mallUserInfoList) { |
|
|
|
msgReplaceMap.put("userName",mallUserInfo.getName()); |
|
|
|
msgReplaceMap.put("userName",userName); |
|
|
|
msgReplaceMap.put("page",Constant.adminPage); |
|
|
|
|
|
|
|
assignee += mallUserInfo.getName()+" "; |
|
|
|
@@ -429,20 +441,13 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
wxMsgValidationcode.setPhone(starter.getPhone()); |
|
|
|
wxMsgValidationcode.setType(EnumMsgModel.FLOW_APPLY_NODIFY.getCode()); |
|
|
|
wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap); |
|
|
|
return false; |
|
|
|
}else{ |
|
|
|
//继续递归判断 |
|
|
|
isEndAndSendMsg(mapInfo,taskKey,processInstanceId,tenantId,userName); |
|
|
|
return isEndAndSendMsg(mapInfo,taskKey,processInstanceId,tenantId,userName); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
// 完成,修改业务状态 |
|
|
|
Integer flowType = (Integer)mapInfo.get("flowType"); |
|
|
|
List<Map<String,String>> variables = (List)mapInfo.get("variables"); |
|
|
|
Integer contractType = 0; |
|
|
|
String str = getVariableByKey(variables,"contractType"); |
|
|
|
if(StringUtils.isNotBlank(str)){ |
|
|
|
contractType = Integer.parseInt(str); |
|
|
|
} |
|
|
|
updateBusinessStatus(businessId,flowType,contractType,EnumRentContractAppStatus.FINISH.getCode(),supplement); |
|
|
|
updateBusinessStatus(mapInfo,EnumRentContractAppStatus.FINISH.getCode()); |
|
|
|
|
|
|
|
// 给发起人发送审批通过消息 |
|
|
|
msgReplaceMap = new HashedMap(); |
|
|
|
@@ -452,6 +457,7 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
wxMsgValidationcode.setPhone(starter.getPhone()); |
|
|
|
wxMsgValidationcode.setType(EnumMsgModel.FLOW_PASS_NODIFY.getCode()); |
|
|
|
wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -482,17 +488,14 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class}) |
|
|
|
public ResultData reject(Map<String, String> params,Long userId,String userName,String tenantId) { |
|
|
|
String taskId = params.get("taskId"); |
|
|
|
String processInstanceId = params.get("processInstanceId"); |
|
|
|
String remark = params.get("remark"); |
|
|
|
|
|
|
|
public ResultData reject(Map<String, Object> params,Long userId,String userName,String tenantId) { |
|
|
|
String taskId = (String)params.get("taskId"); |
|
|
|
String processInstanceId = (String)params.get("processInstanceId"); |
|
|
|
String remark = (String)params.get("remark"); |
|
|
|
Map<String,Object> mapInfo = taskService.getVariables(taskId); |
|
|
|
Long businessId = (Long)mapInfo.get("businessId"); |
|
|
|
Integer flowType = (Integer)mapInfo.get("flowType"); |
|
|
|
MallUserInfo starter = (MallUserInfo)mapInfo.get("starter"); |
|
|
|
List<Map<String,String>> variables = (List)mapInfo.get("variables"); |
|
|
|
Boolean supplement = (Boolean)mapInfo.get("supplement"); |
|
|
|
|
|
|
|
String taskName; |
|
|
|
String taskKey; |
|
|
|
@@ -506,12 +509,9 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
runtimeService.deleteProcessInstance(processInstanceId, "驳回"); |
|
|
|
|
|
|
|
// 修改合同审核状态为驳回 |
|
|
|
Integer contractType = 0; |
|
|
|
String str = getVariableByKey(variables,"contractType"); |
|
|
|
if(StringUtils.isNotBlank(str)){ |
|
|
|
contractType = Integer.parseInt(str); |
|
|
|
} |
|
|
|
updateBusinessStatus(businessId,flowType,contractType,EnumRentContractAppStatus.REJECT.getCode(),supplement); |
|
|
|
params.putAll(mapInfo); |
|
|
|
params.put("businessType",flowType); |
|
|
|
updateBusinessStatus(params,EnumRentContractAppStatus.REJECT.getCode()); |
|
|
|
|
|
|
|
//保存wx_flow_record表审批记录 |
|
|
|
WxFlowRecord wxFlowRecord = new WxFlowRecord(); |
|
|
|
@@ -543,6 +543,53 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class}) |
|
|
|
public ResultData setBack(Map<String, Object> params,Long userId,String userName) { |
|
|
|
String taskId = (String)params.get("taskId"); |
|
|
|
String processInstanceId = (String)params.get("processInstanceId"); |
|
|
|
String remark = (String)params.get("remark"); |
|
|
|
|
|
|
|
Map<String,Object> mapInfo = taskService.getVariables(taskId); |
|
|
|
Long businessId = (Long)mapInfo.get("businessId"); |
|
|
|
Integer flowType = (Integer)mapInfo.get("flowType"); |
|
|
|
|
|
|
|
String taskName; |
|
|
|
String taskKey; |
|
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
|
|
|
if (task == null) { |
|
|
|
return new ResultData(ErrorCode.FLOW_INST_NOT_EXIST.getCode(), "任务不存在"); |
|
|
|
} |
|
|
|
taskName = task.getName(); |
|
|
|
taskKey = task.getTaskDefinitionKey(); |
|
|
|
|
|
|
|
runtimeService.deleteProcessInstance(processInstanceId, "撤回"); |
|
|
|
|
|
|
|
// 修改合同审核状态为撤回 |
|
|
|
params.putAll(mapInfo); |
|
|
|
params.put("businessType",flowType); |
|
|
|
updateBusinessStatus(params,EnumRentContractAppStatus.SETBACK.getCode()); |
|
|
|
|
|
|
|
//保存wx_flow_record表审批记录 |
|
|
|
WxFlowRecord wxFlowRecord = new WxFlowRecord(); |
|
|
|
wxFlowRecord.setBusinessId(businessId); |
|
|
|
wxFlowRecord.setTaskId(taskId); |
|
|
|
wxFlowRecord.setProcessInstanceId(processInstanceId); |
|
|
|
wxFlowRecord.setRemark(remark); |
|
|
|
wxFlowRecord.setUserId(userId); |
|
|
|
wxFlowRecord.setStatus(EnumFlowRecordStatus.SETBACK.getCode()); |
|
|
|
wxFlowRecord.setBusinessType(flowType); |
|
|
|
wxFlowRecord.setUserName(userName); |
|
|
|
wxFlowRecord.setTaskKey(taskKey); |
|
|
|
wxFlowRecord.setTaskName(taskName); |
|
|
|
wxFlowRecordService.saveOrUpdate(wxFlowRecord); |
|
|
|
//修改记录表当前状态 |
|
|
|
wxFlowRecordMapper.updateCurrStatus(new WxFlowRecord(processInstanceId,EnumFlowRecordStatus.SETBACK.getCode())); |
|
|
|
|
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 判断流程是否结束 |
|
|
|
* @param processInstanceId |
|
|
|
@@ -603,13 +650,8 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultData myApplyList(Integer pageNum, Integer pageSize, Long userId,String tenantId) { |
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
WxFlowRecord flowRecord = new WxFlowRecord(); |
|
|
|
flowRecord.setUserId(userId); |
|
|
|
flowRecord.setStatus(EnumFlowRecordStatus.NEW.getCode()); |
|
|
|
List<WxFlowRecord> recordList = wxFlowRecordMapper.findList(flowRecord); |
|
|
|
return new ResultData(recordList); |
|
|
|
public PageInfo<WxFlowRecord> listAsPage(WxFlowRecord record, Integer pageIndex, Integer pageSize) { |
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxFlowRecordMapper.findList(record)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@@ -666,6 +708,7 @@ public class WxFlowServiceImpl implements WxFlowService { |
|
|
|
} |
|
|
|
|
|
|
|
public static String getVariableByKey(List<Map<String,String>> variables,String key){ |
|
|
|
if(variables == null) return null; |
|
|
|
for (Map<String,String> map:variables) { |
|
|
|
if(map.get("key").equals(key)){ |
|
|
|
return map.get("value"); |
|
|
|
|