Commit d54412fcc63d3e4eb3b8cd4162dad967daa094c9

Authored by 杨鸣坤
1 parent da45f861

楚江ERP:锁价无规格操作申请单 提交审批以及审批完成通知

... ... @@ -11,6 +11,7 @@ import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
11 11 import com.lframework.xingyun.sc.entity.*;
12 12 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
13 13 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
  14 +import com.lframework.xingyun.sc.service.contract.SpecLockDelayApplicationService;
14 15 import com.lframework.xingyun.sc.service.customer.CorePersonnelHistoryService;
15 16 import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService;
16 17 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
... ... @@ -66,6 +67,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
66 67 private MqProducerService mqProducerService;
67 68 @Resource
68 69 private TransactorHandler transactorHandler;
  70 + @Resource
  71 + private SpecLockDelayApplicationService specLockDelayApplicationService;
69 72
70 73
71 74 /**
... ... @@ -118,6 +121,9 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
118 121 case "SPEC_CHANGE_CONFIRM":
119 122 handleOrderSpecChangeData(flowStatus, businessId);
120 123 break;
  124 + case "SPEC_LOCK_DELAY":
  125 + handleSpecLockDelayAuditData(flowStatus, businessId);
  126 + break;
121 127 default:
122 128 break;
123 129 }
... ... @@ -150,6 +156,19 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
150 156 }
151 157 }
152 158
  159 + private void handleSpecLockDelayAuditData(String flowStatus, String businessId) {
  160 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  161 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  162 + specLockDelayApplicationService.updateAuditStatus(businessId, "PASS");
  163 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  164 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
  165 + || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
  166 + specLockDelayApplicationService.updateAuditStatus(businessId, "REFUSE");
  167 + } else if (FlowInstanceStatus.UNDO.getCode().equals(flowStatus)) {
  168 + specLockDelayApplicationService.updateAuditStatus(businessId, "CANCEL");
  169 + }
  170 + }
  171 +
153 172 /**
154 173 * 客户开发业务数据处理
155 174 *
... ... @@ -347,8 +366,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
347 366 /**
348 367 * 处理订货单变更相关数据
349 368 *
350   - * @param flowStatus 审核结果
351   - * @param businessId 业务ID
  369 + * @param flowStatus 审核结果
  370 + * @param businessId 业务ID
352 371 */
353 372 private void handleOrderSpecChangeData(String flowStatus, String businessId) {
354 373 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
... ...
1 1 package com.lframework.xingyun.sc.impl.contract;
2 2
  3 +import com.baomidou.mybatisplus.core.conditions.Wrapper;
3 4 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 5 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 6 import com.github.pagehelper.PageInfo;
  7 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
6 8 import com.lframework.starter.common.exceptions.impl.DefaultClientException;
7 9 import com.lframework.starter.common.utils.Assert;
8 10 import com.lframework.starter.common.utils.ObjectUtil;
9 11 import com.lframework.starter.web.core.annotations.oplog.OpLog;
10 12 import com.lframework.starter.web.core.components.resp.PageResult;
  13 +import com.lframework.starter.web.core.components.security.SecurityUtil;
11 14 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
12 15 import com.lframework.starter.web.core.utils.IdUtil;
13 16 import com.lframework.starter.web.core.utils.OpLogUtil;
... ... @@ -20,17 +23,25 @@ import com.lframework.xingyun.sc.service.contract.SpecLockDelayApplicationServic
20 23 import com.lframework.xingyun.sc.vo.contract.createVo.CreateSpecLockDelayApplicationVo;
21 24 import com.lframework.xingyun.sc.vo.contract.queryVo.QuerySpecLockDelayApplicationVo;
22 25 import com.lframework.xingyun.sc.vo.contract.updateVo.UpdateSpecLockDelayApplicationVo;
  26 +import org.apache.commons.lang3.StringUtils;
  27 +import org.springframework.beans.factory.annotation.Autowired;
23 28 import org.springframework.cache.annotation.CacheEvict;
24 29 import org.springframework.cache.annotation.Cacheable;
25 30 import org.springframework.stereotype.Service;
26 31 import org.springframework.transaction.annotation.Transactional;
27 32
28 33 import java.io.Serializable;
  34 +import java.time.LocalDateTime;
29 35 import java.util.List;
30 36
31 37 @Service
32 38 public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecLockDelayApplicationMapper, SpecLockDelayApplication> implements SpecLockDelayApplicationService {
33 39
  40 + private static final String SPEC_LOCK_DELAY_FLAY = "SPEC_LOCK_DELAY"; // 未锁规格申请单审批
  41 +
  42 + @Autowired
  43 + private FlowInstanceWrapperService flowInstanceWrapperService;
  44 +
34 45 @Override
35 46 public PageResult<SpecLockDelayApplication> query(Integer pageIndex, Integer pageSize, QuerySpecLockDelayApplicationVo vo) {
36 47
... ... @@ -74,6 +85,8 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL
74 85 OpLogUtil.setVariable("id", data.getId());
75 86 OpLogUtil.setExtra(vo);
76 87
  88 + // 开启审核
  89 + flowInstanceWrapperService.startInstance(SPEC_LOCK_DELAY_FLAY, data.getId(), SPEC_LOCK_DELAY_FLAY, data);
77 90 return data.getId();
78 91 }
79 92
... ... @@ -101,6 +114,34 @@ public class SpecLockDelayApplicationServiceImpl extends BaseMpServiceImpl<SpecL
101 114 OpLogUtil.setExtra(vo);
102 115 }
103 116
  117 + @Override
  118 + @OpLog(type = OtherOpLogType.class, name = "锁价无规格操作申请单审批完成,ID:{}, 审批状态:{}", params = {"#id", "#approvedStatus"})
  119 + @Transactional(rollbackFor = Exception.class)
  120 + public void updateAuditStatus(String id, String approvedStatus) {
  121 + if (StringUtils.isBlank(id) || StringUtils.isBlank(approvedStatus)) {
  122 + return;
  123 + }
  124 +
  125 + Wrapper<SpecLockDelayApplication> wrapper = Wrappers.lambdaUpdate(SpecLockDelayApplication.class)
  126 + .set(SpecLockDelayApplication::getApprovalStatus, approvedStatus)
  127 + .set(SpecLockDelayApplication::getApprovedAt, LocalDateTime.now())
  128 + .set(SpecLockDelayApplication::getApproverId, SecurityUtil.getCurrentUser().getId())
  129 + .eq(SpecLockDelayApplication::getId, id);
  130 +
  131 + getBaseMapper().update(wrapper);
  132 +
  133 + UpdateSpecLockDelayApplicationVo vo = new UpdateSpecLockDelayApplicationVo();
  134 + vo.setId(id);
  135 + vo.setApprovalStatus(approvedStatus);
  136 + vo.setApprovedAt(LocalDateTime.now());
  137 + vo.setApproverId(SecurityUtil.getCurrentUser().getId());
  138 +
  139 + OpLogUtil.setVariable("id", id);
  140 + OpLogUtil.setExtra(vo);
  141 +
  142 + cleanCacheByKey(id);
  143 + }
  144 +
104 145 @CacheEvict(value = SpecLockDelayApplication.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
105 146 @Override
106 147 public void cleanCacheByKey(Serializable key) {
... ...
... ... @@ -52,5 +52,13 @@ public interface SpecLockDelayApplicationService extends BaseMpService<SpecLockD
52 52 */
53 53 void update(UpdateSpecLockDelayApplicationVo vo);
54 54
  55 + /**
  56 + * 更新审核状态
  57 + *
  58 + * @param id
  59 + * @param approvedStatus
  60 + */
  61 + void updateAuditStatus(String id, String approvedStatus);
  62 +
55 63 }
56 64
... ...
... ... @@ -8,6 +8,7 @@ import org.hibernate.validator.constraints.Length;
8 8
9 9 import java.io.Serializable;
10 10 import java.time.LocalDate;
  11 +import java.time.LocalDateTime;
11 12
12 13 @Data
13 14 public class UpdateSpecLockDelayApplicationVo implements BaseVo, Serializable {
... ... @@ -55,4 +56,15 @@ public class UpdateSpecLockDelayApplicationVo implements BaseVo, Serializable {
55 56 @Length(message = "审核状态最多允许50个字符!")
56 57 private String approvalStatus;
57 58
  59 + /**
  60 + * 审核人
  61 + */
  62 + @ApiModelProperty(value = "审核人")
  63 + private String approverId;
  64 +
  65 + /**
  66 + * 审核时间
  67 + */
  68 + @ApiModelProperty(value = "审核时间")
  69 + private LocalDateTime approvedAt;
58 70 }
... ...