Просмотр исходного кода

优化审批流

release_toaliyun_real
luozukai 7 лет назад
Родитель
Сommit
8c958f2801
11 измененных файлов: 174 добавлений и 53 удалений
  1. +15
    -7
      mallinkAdmin/src/main/java/com/iformall/flowable/ContractTaskFinishHandler.java
  2. +2
    -2
      mallinkAdmin/src/main/resources/application-dev.yml
  3. +2
    -0
      mallinkAdmin/src/main/resources/application-prod.yml
  4. +2
    -0
      mallinkAdmin/src/main/resources/application-test.yml
  5. +11
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java
  6. +1
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java
  7. +7
    -0
      mallinkService/src/main/java/com/iformall/service/WxFlowService.java
  8. +3
    -1
      mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java
  9. +123
    -37
      mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java
  10. +2
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java
  11. +6
    -2
      mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml

+ 15
- 7
mallinkAdmin/src/main/java/com/iformall/flowable/ContractTaskFinishHandler.java Просмотреть файл

@@ -1,12 +1,15 @@
package com.iformall.flowable;

import com.iformall.domain.po.WxRentContract;
import com.iformall.enums.EnumRentContractAppStatus;
import com.iformall.service.WxRentContractService;
import com.iformall.service.WxFlowService;
import com.iformall.service.impl.WxFlowServiceImpl;
import org.apache.commons.lang3.StringUtils;
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;
import java.util.List;
import java.util.Map;

/**
* 合同审批完成,修改状态
@@ -14,15 +17,20 @@ import org.springframework.stereotype.Component;
@Component(value="contractTaskFinishListener")
public class ContractTaskFinishHandler implements TaskListener {
@Autowired
private WxRentContractService wxRentContractService;
private WxFlowService wxFlowService;

@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);
List<Map<String,String>> variables = (List)delegateTask.getVariable("variables");
Integer flowType = (Integer)delegateTask.getVariable("businessType");

Integer contractType = 0;
String str = WxFlowServiceImpl.getVariableByKey(variables,"contractType");
if(StringUtils.isNotBlank(str)){
contractType = Integer.parseInt(str);
}
wxFlowService.updateBusinessStatus(businessId,flowType,contractType,EnumRentContractAppStatus.FINISH.getCode());
}

}

+ 2
- 2
mallinkAdmin/src/main/resources/application-dev.yml Просмотреть файл

@@ -22,8 +22,8 @@ spring:
connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000"
#jackson:
#date-format: yyyy-MM-dd HH:mm:ss
flowable:
async-executor-activate: false
flowable:
async-executor-activate: false

# REDIS
redis:


+ 2
- 0
mallinkAdmin/src/main/resources/application-prod.yml Просмотреть файл

@@ -46,6 +46,8 @@ spring:
auth: true
starttls:
enable: true
flowable:
async-executor-activate: false

aws:
clientRegion: cn-northwest-1


+ 2
- 0
mallinkAdmin/src/main/resources/application-test.yml Просмотреть файл

@@ -46,6 +46,8 @@ spring:
auth: true
starttls:
enable: true
flowable:
async-executor-activate: false

aws:
clientRegion: cn-northwest-1


+ 11
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxPropertyContract.java Просмотреть файл

@@ -17,6 +17,9 @@ public class WxPropertyContract implements Serializable {
@Id
protected Long id;

// 审核状态,0未审核 1审核中 2审核完成 3驳回 4合同作废
private Integer applyStatus;
@Transient
protected List<Long> ids;
@@ -150,6 +153,14 @@ public class WxPropertyContract implements Serializable {
@io.swagger.annotations.ApiModelProperty(value = "起租结束时间", name = "rentalEndDate")
private Date endDate;

public Integer getApplyStatus() {
return applyStatus;
}

public void setApplyStatus(Integer applyStatus) {
this.applyStatus = applyStatus;
}

public Long getMerchantId() {
return merchantId;
}


+ 1
- 1
mallinkService/src/main/java/com/iformall/mapper/WxPropertyContractMapper.java Просмотреть файл

@@ -36,7 +36,7 @@ public interface WxPropertyContractMapper extends CommonMapper<WxPropertyContrac

List<WxRentContract> getRentContractList(Map<String, Object> params);

void updateApplyStatus(WxPropertyContract wxPropertyContract);
}

+ 7
- 0
mallinkService/src/main/java/com/iformall/service/WxFlowService.java Просмотреть файл

@@ -11,6 +11,13 @@ import java.util.Map;
*/
public interface WxFlowService {

/**
* 更新业务数据状态
* @param businessId
* @param flowType
*/
void updateBusinessStatus(Long businessId,Integer flowType,Integer contractType,Integer applyStatus);

ResultData getTaskStatusList(Long businessId,String tenantId);

/**


+ 3
- 1
mallinkService/src/main/java/com/iformall/service/impl/DataTowerServiceImpl.java Просмотреть файл

@@ -510,7 +510,9 @@ public class DataTowerServiceImpl implements DataTowerService {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<Date> days = DateUtils.dateToWeek(new Date());
String oneWeekStartdate = sdf.format(days.get(0));
String oneWeekSystemTime = sdf.format(days.get(days.size()-1));
String oneWeekEndDate = sdf.format(days.get(days.size()-1));
params.put("startdate", oneWeekStartdate + " 00:00:00");
params.put("enddate", oneWeekEndDate + " 23:59:59");

List<Map<String, Object>> oneWeekHistorylist = wxCarCmdLogMapper.queryHistory(params);
Map<Object, Object> oneWeekCollect = oneWeekHistorylist.stream().collect(Collectors.toMap(m -> {


+ 123
- 37
mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java Просмотреть файл

@@ -4,15 +4,13 @@ import com.github.pagehelper.PageInfo;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxFlowRecord;
import com.iformall.domain.po.WxMsgValidationcode;
import com.iformall.domain.po.WxRentContract;
import com.iformall.domain.po.*;
import com.iformall.enums.EnumFlowKey;
import com.iformall.enums.EnumFlowRecordStatus;
import com.iformall.enums.EnumMsgModelType;
import com.iformall.enums.EnumRentContractAppStatus;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxPropertyContractMapper;
import com.iformall.mapper.WxRentContractMapper;
import com.iformall.service.*;
import com.iformall.utils.Constant;
@@ -62,6 +60,8 @@ public class WxFlowServiceImpl implements WxFlowService {
private WxMsgValidationcodeService wxMsgValidationcodeService;
@Autowired
private WxRentContractMapper wxRentContractMapper;
@Autowired
private WxPropertyContractMapper wxPropertyContractMapper;

/**
* 获取流程key,1合同 2账单
@@ -77,6 +77,28 @@ public class WxFlowServiceImpl implements WxFlowService {
return null;
}

/**
* 更新业务数据状态
* @param businessId
* @param flowType
*/
@Override
public void updateBusinessStatus(Long businessId,Integer flowType,Integer contractType,Integer applyStatus){
if(1 == flowType){
WxRentContract rent = new WxRentContract();
rent.setId(businessId);
rent.setApplyStatus(applyStatus);
wxRentContractService.updateApplyStatus(rent);

// 1租赁2点位wx_rent_contract 3物业wx_property_contract
if(contractType == 3){
WxPropertyContract wxPropertyContract = new WxPropertyContract();
wxPropertyContract.setId(businessId);
wxPropertyContractMapper.updateApplyStatus(wxPropertyContract);
}
}
}

@Override
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = {Exception.class})
public ResultData start(Map<String, Object> params,Long userId,String userName,String tenantId) {
@@ -84,6 +106,7 @@ public class WxFlowServiceImpl implements WxFlowService {
Long businessId = Long.parseLong((String)params.get("businessId"));
Integer flowType = (Integer)params.get("businessType");
List<Map<String,String>> taskAssignee = (List)params.get("taskAssignee");
List<Map<String,String>> variables = (List)params.get("variables");

// 查询合同信息
WxRentContract wxRentContract = wxRentContractMapper.selectByPrimaryKey(businessId);
@@ -104,15 +127,18 @@ public class WxFlowServiceImpl implements WxFlowService {
map.put("flowType",flowType);
map.put("taskAssignee",taskAssignee);
map.put("contractNumber",wxRentContract.getContractNumber());
map.put("variables",variables);

ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(getFlowKeyByType(flowType), map);
logger.debug("流程启动,流程id:{}",processInstance.getId());

// 合同审核状态改为审核中
WxRentContract rent = new WxRentContract();
rent.setId(businessId);
rent.setApplyStatus(EnumRentContractAppStatus.APPLYING.getCode());
wxRentContractService.updateApplyStatus(rent);
Integer contractType = 0;
String str = getVariableByKey(variables,"contractType");
if(StringUtils.isNotBlank(str)){
contractType = Integer.parseInt(str);
}
updateBusinessStatus(businessId,flowType,contractType,EnumRentContractAppStatus.APPLYING.getCode());

// 保存wx_flow_record表审批记录
WxFlowRecord wxFlowRecord = new WxFlowRecord();
@@ -161,6 +187,10 @@ public class WxFlowServiceImpl implements WxFlowService {
taskInfoMap.put("taskId",task.getId());
taskInfoMap.put("businessId",mapInfo.get("businessId"));
taskInfoMap.put("contractNumber",mapInfo.get("contractNumber"));
List<Map<String,String>> variables = (List)mapInfo.get("variables"); //定制variables,回传
for (Map<String,String> m:variables) {
taskInfoMap.putAll(m);
}
result.add(taskInfoMap);
}
PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(result,pageSize);
@@ -202,7 +232,7 @@ public class WxFlowServiceImpl implements WxFlowService {
Map<String,Object> mapInfo = taskService.getVariables(task.getId());
List<Map<String,String>> taskAssigneeList = (List)mapInfo.get("taskAssignee");

for (int i = 0; i < taskAssigneeList.size()-1; i++) {
for (int i = 0; i < taskAssigneeList.size(); i++) {
Map<String,String> assignee = taskAssigneeList.get(i);
if(task.getTaskDefinitionKey().equals(assignee.get("taskKey"))){
//设置当前节点代办人信息
@@ -262,8 +292,6 @@ public class WxFlowServiceImpl implements WxFlowService {
Map<String,Object> mapInfo = taskService.getVariables(task.getId());
Long businessId = (Long)mapInfo.get("businessId");
Integer flowType = (Integer)mapInfo.get("flowType");
MallUserInfo starter = (MallUserInfo)mapInfo.get("starter");

taskService.complete(taskId);

//保存wx_flow_record表审批记录
@@ -280,37 +308,60 @@ public class WxFlowServiceImpl implements WxFlowService {
wxFlowRecord.setTaskKey(taskKey);
wxFlowRecordService.saveOrUpdate(wxFlowRecord);

// 判断流程是否结束,并发送短信通知
isEndAndSendMsg(mapInfo,taskKey,processInstanceId,tenantId,userName);

return new ResultData();
}

/**
* 判断流程是否结束,并发送短信通知
* @param taskKey
* @param processInstanceId
* @param tenantId
*/
public void isEndAndSendMsg(Map<String,Object> mapInfo,String taskKey,String processInstanceId,String tenantId,String userName){
// 发送短信
Map<String,String> msgReplaceMap = new HashedMap();
WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode();
wxMsgValidationcode.setTenantId(tenantId);
wxMsgValidationcode.setType(EnumMsgModelType.FLOW.getCode());
// 判断流程是否结束
MallUserInfo starter = (MallUserInfo)mapInfo.get("starter");
List<Map<String,String>> taskAssigneeList = (List)mapInfo.get("taskAssignee");
Long businessId = (Long)mapInfo.get("businessId");

// 判断下个节点是否有设置审批人,没有,直接通过,有,发短信通知
if(!isEnded(processInstanceId)){
String assignee = "";
// 给代办人发送通知短信
List<MallUserInfo> mallUserInfoList = getUserByProcessInstanceId(processInstanceId);
for (MallUserInfo mallUserInfo:mallUserInfoList) {
msgReplaceMap.put("userName",mallUserInfo.getName());
if(hasAssignee(taskAssigneeList,taskKey,processInstanceId)){
// 给代办人发送通知短信
String assignee = "";
List<MallUserInfo> mallUserInfoList = getUserByProcessInstanceId(processInstanceId);
for (MallUserInfo mallUserInfo:mallUserInfoList) {
msgReplaceMap.put("userName",mallUserInfo.getName());
msgReplaceMap.put("page",Constant.adminPage);
msgReplaceMap.put("modelName","代办通知");

assignee += mallUserInfo.getName()+" ";
wxMsgValidationcode.setPhone(mallUserInfo.getPhone());
wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap);
}

// 给发起人发送短信
msgReplaceMap = new HashedMap();
msgReplaceMap.put("userName",userName);
msgReplaceMap.put("page",Constant.adminPage);
msgReplaceMap.put("modelName","代办通知");
msgReplaceMap.put("modelName","审批通知");
msgReplaceMap.put("contract",businessId+"");
msgReplaceMap.put("toUserName",assignee.trim());

assignee += mallUserInfo.getName()+" ";
wxMsgValidationcode.setPhone(mallUserInfo.getPhone());
wxMsgValidationcode = new WxMsgValidationcode();
wxMsgValidationcode.setPhone(starter.getPhone());
wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap);
}else{
//todo 需要测下三节点
//继续递归判断
isEndAndSendMsg(mapInfo,taskKey,processInstanceId,tenantId,userName);
}

// 给发起人发送短信
msgReplaceMap = new HashedMap();
msgReplaceMap.put("userName",userName);
msgReplaceMap.put("page",Constant.adminPage);
msgReplaceMap.put("modelName","审批通知");
msgReplaceMap.put("contract",businessId+"");
msgReplaceMap.put("toUserName",assignee.trim());

wxMsgValidationcode = new WxMsgValidationcode();
wxMsgValidationcode.setPhone(starter.getPhone());
wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap);
}else{
// 给发起人发送审批通过消息
msgReplaceMap = new HashedMap();
@@ -322,8 +373,31 @@ public class WxFlowServiceImpl implements WxFlowService {
wxMsgValidationcode.setPhone(starter.getPhone());
wxMsgValidationcodeService.sendWorkFlowNodify(wxMsgValidationcode,msgReplaceMap);
}
}

return new ResultData();
/**
* 判断下个节点是否有设置审批人,没有,直接通过
* @param
* @param taskKey
* @param processInstanceId
*/
public boolean hasAssignee(List<Map<String,String>> taskAssigneeList,String taskKey,String processInstanceId){
boolean has = true;
for (int i = 0; i < taskAssigneeList.size(); i++) {
Map<String,String> taskAssignee = taskAssigneeList.get(i);
if(taskAssignee.get("taskKey").equals(taskKey)){
if(i != taskAssigneeList.size() -1){
Map<String,String> nextTaskAssignee = taskAssigneeList.get(i+1);
if(StringUtils.isBlank(nextTaskAssignee.get("assignee"))){
Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
taskService.complete(task.getId());
has = false;
break;
}
}
}
}
return has;
}

@Override
@@ -337,6 +411,7 @@ public class WxFlowServiceImpl implements WxFlowService {
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");

String taskName;
String taskKey;
@@ -350,10 +425,12 @@ public class WxFlowServiceImpl implements WxFlowService {
runtimeService.deleteProcessInstance(processInstanceId, "驳回");

// 修改合同审核状态为驳回
WxRentContract wxRentContract = new WxRentContract();
wxRentContract.setId(businessId);
wxRentContract.setApplyStatus(EnumRentContractAppStatus.REJECT.getCode());
wxRentContractService.updateApplyStatus(wxRentContract);
Integer contractType = 0;
String str = getVariableByKey(variables,"contractType");
if(StringUtils.isNotBlank(str)){
contractType = Integer.parseInt(str);
}
updateBusinessStatus(businessId,flowType,contractType,EnumRentContractAppStatus.REJECT.getCode());

//保存wx_flow_record表审批记录
WxFlowRecord wxFlowRecord = new WxFlowRecord();
@@ -498,4 +575,13 @@ public class WxFlowServiceImpl implements WxFlowService {
}
}

public static String getVariableByKey(List<Map<String,String>> variables,String key){
for (Map<String,String> map:variables) {
if(map.get("key").equals(key)){
return map.get("value");
}
}
return null;
}

}

+ 2
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java Просмотреть файл

@@ -13,7 +13,6 @@ import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.*;
import com.iformall.service.WxFlowRecordService;
import com.iformall.service.WxFlowService;
import com.iformall.service.WxMerchantService;
import com.iformall.service.WxRentContractService;
import com.iformall.utils.Constant;
@@ -29,7 +28,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@@ -274,7 +272,8 @@ public class WxRentContractServiceImpl implements WxRentContractService {
logger.error("更新租赁合同信息失败,e:" + e.getMessage());
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage());
}
return new ResultData(Result.SUCCESS, "更新租赁合同信息成功");
// return new ResultData(Result.SUCCESS, "更新租赁合同信息成功");
return new ResultData(Result.SUCCESS, "保存租赁合同信息成功", wxRentContract);
}




+ 6
- 2
mallinkService/src/main/resources/mapper/WxPropertyContractMapper.xml Просмотреть файл

@@ -32,6 +32,8 @@
<result column="rent_contract_id" jdbcType="BIGINT" property="rentContractId"/>
<result column="start_date" jdbcType="TIMESTAMP" property="startDate"/>
<result column="end_date" jdbcType="TIMESTAMP" property="endDate"/>
<result column="apply_status" property="applyStatus"/>

</resultMap>
<sql id="allColumns">
@@ -40,7 +42,7 @@
`deposit`,`pay_date`,`is_del`,`merchant_name`,`brand`,`business_id`,
`shop_type`,`shop_id`,`updatetime`,`createtime`,`rent_area`,
`link_person`,`link_phone`,`pay_account`,`filename`,`lease`,`rent_contract_id`,
`start_date`,`end_date`
`start_date`,`end_date`,`apply_status`
</sql>
<sql id="dynamicWhereConditions">
@@ -166,5 +168,7 @@
</select>


<update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxPropertyContract">
update wx_property_contract set apply_status=#{applyStatus} where id=#{id}
</update>
</mapper>

Загрузка…
Отмена
Сохранить