Commit 87670dcb18e635a269d23050d39290eac702f825

Authored by yeqianyong
1 parent 2109e5cd

楚江ERP-订货单规格变更流程相关功能开发

@@ -15,10 +15,7 @@ import com.lframework.xingyun.sc.service.customer.CorePersonnelHistoryService; @@ -15,10 +15,7 @@ import com.lframework.xingyun.sc.service.customer.CorePersonnelHistoryService;
15 import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService; 15 import com.lframework.xingyun.sc.service.customer.CustomerCreditHistoryService;
16 import com.lframework.xingyun.sc.service.customer.CustomerCreditService; 16 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
17 import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService; 17 import com.lframework.xingyun.sc.service.customer.CustomerDevelopPlanService;
18 -import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;  
19 -import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;  
20 -import com.lframework.xingyun.sc.service.order.PurchaseOrderRevokeLineService;  
21 -import com.lframework.xingyun.sc.service.order.PurchaseOrderRevokeService; 18 +import com.lframework.xingyun.sc.service.order.*;
22 import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelHistoryVo; 19 import com.lframework.xingyun.sc.vo.customer.credit.QueryCorePersonnelHistoryVo;
23 import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo; 20 import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo;
24 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo; 21 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo;
@@ -63,6 +60,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -63,6 +60,8 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
63 private PurchaseOrderRevokeService purchaseOrderRevokeService; 60 private PurchaseOrderRevokeService purchaseOrderRevokeService;
64 @Resource 61 @Resource
65 private PurchaseOrderRevokeLineService purchaseOrderRevokeLineService; 62 private PurchaseOrderRevokeLineService purchaseOrderRevokeLineService;
  63 + @Resource
  64 + private OrderSpecificationChangeRecordService orderSpecificationChangeRecordService;
66 65
67 66
68 /** 67 /**
@@ -111,6 +110,12 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -111,6 +110,12 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
111 case "ORDER_CANCELLATION": 110 case "ORDER_CANCELLATION":
112 handlePurchaseOrderRevokeData(flowStatus, businessId); 111 handlePurchaseOrderRevokeData(flowStatus, businessId);
113 break; 112 break;
  113 + case "SPEC_CHANGE_SUBMIT":
  114 + handleOrderSpecChangeData(flowStatus, businessId, true, true);
  115 + break;
  116 + case "SPEC_CHANGE_CONFIRM":
  117 + handleOrderSpecChangeData(flowStatus, businessId, null, false);
  118 + break;
114 default: 119 default:
115 break; 120 break;
116 } 121 }
@@ -291,4 +296,24 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic @@ -291,4 +296,24 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
291 } 296 }
292 } 297 }
293 298
  299 + /**
  300 + * 处理订货单规格变更相关数据
  301 + *
  302 + * @param flowStatus 审核结果
  303 + * @param businessId 业务ID
  304 + */
  305 + private void handleOrderSpecChangeData(String flowStatus, String businessId, Boolean output, boolean notice) {
  306 + if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
  307 + || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
  308 + orderSpecificationChangeRecordService.reviewPass(businessId);
  309 + } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
  310 + || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)) {
  311 + orderSpecificationChangeRecordService.reviewRefuse(businessId, output);
  312 + if (notice) {
  313 + // todo 消息通知
  314 + }
  315 + } else if (FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
  316 + orderSpecificationChangeRecordService.updateStatus(businessId, "REFUSE");
  317 + }
  318 + }
294 } 319 }
@@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.impl.order; @@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.impl.order;
3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 3 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 import com.baomidou.mybatisplus.core.toolkit.Wrappers; 4 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 import com.github.pagehelper.PageInfo; 5 import com.github.pagehelper.PageInfo;
  6 +import com.lframework.starter.bpm.service.FlowInstanceWrapperService;
6 import com.lframework.starter.web.core.components.security.SecurityUtil; 7 import com.lframework.starter.web.core.components.security.SecurityUtil;
7 import com.lframework.starter.web.core.utils.*; 8 import com.lframework.starter.web.core.utils.*;
8 import com.lframework.starter.web.inner.entity.SysUser; 9 import com.lframework.starter.web.inner.entity.SysUser;
@@ -21,6 +22,7 @@ import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService; @@ -21,6 +22,7 @@ import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
21 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService; 22 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
22 import com.lframework.xingyun.sc.vo.order.change.*; 23 import com.lframework.xingyun.sc.vo.order.change.*;
23 import org.apache.commons.collections4.CollectionUtils; 24 import org.apache.commons.collections4.CollectionUtils;
  25 +import org.apache.commons.lang3.BooleanUtils;
24 import org.apache.commons.lang3.StringUtils; 26 import org.apache.commons.lang3.StringUtils;
25 import org.springframework.transaction.annotation.Transactional; 27 import org.springframework.transaction.annotation.Transactional;
26 import com.lframework.xingyun.sc.mappers.OrderSpecificationChangeRecordMapper; 28 import com.lframework.xingyun.sc.mappers.OrderSpecificationChangeRecordMapper;
@@ -35,12 +37,17 @@ import java.util.*; @@ -35,12 +37,17 @@ import java.util.*;
35 public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl<OrderSpecificationChangeRecordMapper, OrderSpecificationChangeRecord> implements OrderSpecificationChangeRecordService { 37 public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl<OrderSpecificationChangeRecordMapper, OrderSpecificationChangeRecord> implements OrderSpecificationChangeRecordService {
36 38
37 39
  40 + private static final String BPM_FLAG = "SPEC_CHANGE_SUBMIT";
  41 +
  42 +
38 @Resource 43 @Resource
39 private PurchaseOrderLineService purchaseOrderLineService; 44 private PurchaseOrderLineService purchaseOrderLineService;
40 @Resource 45 @Resource
41 private SysUserService sysUserService; 46 private SysUserService sysUserService;
42 @Resource 47 @Resource
43 private PurchaseOrderInfoService purchaseOrderInfoService; 48 private PurchaseOrderInfoService purchaseOrderInfoService;
  49 + @Resource
  50 + private FlowInstanceWrapperService flowInstanceWrapperService;
44 51
45 52
46 @Override 53 @Override
@@ -160,6 +167,8 @@ public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl @@ -160,6 +167,8 @@ public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl
160 purchaseOrderLineService.batchAdd(orderLineList); 167 purchaseOrderLineService.batchAdd(orderLineList);
161 // 更新订货单规格变更状态 168 // 更新订货单规格变更状态
162 purchaseOrderInfoService.updateSpecChangeStatus(vo.getOrderId(), OrderSpecChangeStatus.IN_PROGRESS.getCode()); 169 purchaseOrderInfoService.updateSpecChangeStatus(vo.getOrderId(), OrderSpecChangeStatus.IN_PROGRESS.getCode());
  170 + // 发起流程
  171 + flowInstanceWrapperService.startInstance("SPEC_CHANGE_SUBMIT", id, BPM_FLAG, data);
163 172
164 OpLogUtil.setVariable("id", data.getId()); 173 OpLogUtil.setVariable("id", data.getId());
165 OpLogUtil.setExtra(vo); 174 OpLogUtil.setExtra(vo);
@@ -203,6 +212,14 @@ public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl @@ -203,6 +212,14 @@ public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl
203 } 212 }
204 getBaseMapper().update(updateWrapper); 213 getBaseMapper().update(updateWrapper);
205 purchaseOrderLineService.batchUpdate(orderLineList); 214 purchaseOrderLineService.batchUpdate(orderLineList);
  215 + // 重新发起流程
  216 + JsonUtil.parseObject(JsonUtil.toJsonString(data), PurchaseOrderLine.class);
  217 + Boolean output = data.getOutput();
  218 + if (BooleanUtils.isTrue(output)) {
  219 + flowInstanceWrapperService.startInstance("SPEC_CHANGE_CONFIRM", vo.getId(), BPM_FLAG, data);
  220 + } else {
  221 + flowInstanceWrapperService.startInstance("SPEC_CHANGE_SUBMIT", vo.getId(), BPM_FLAG, data);
  222 + }
206 223
207 OpLogUtil.setVariable("id", data.getId()); 224 OpLogUtil.setVariable("id", data.getId());
208 OpLogUtil.setExtra(vo); 225 OpLogUtil.setExtra(vo);
@@ -234,9 +251,44 @@ public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl @@ -234,9 +251,44 @@ public class OrderSpecificationChangeRecordServiceImpl extends BaseMpServiceImpl
234 updateWrapper.set(OrderSpecificationChangeRecord::getStatus, status) 251 updateWrapper.set(OrderSpecificationChangeRecord::getStatus, status)
235 .eq(OrderSpecificationChangeRecord::getId, id); 252 .eq(OrderSpecificationChangeRecord::getId, id);
236 getBaseMapper().update(updateWrapper); 253 getBaseMapper().update(updateWrapper);
237 - if (OrderSpecChangeStatus.CANCEL.getCode().equals(status)) { 254 + if (OrderSpecChangeStatus.CANCEL.getCode().equals(status)
  255 + || OrderSpecChangeStatus.COMPLETED.getCode().equals(status)) {
238 // 更新订货单规格变更状态 256 // 更新订货单规格变更状态
239 purchaseOrderInfoService.updateSpecChangeStatus(record.getOrderId(), status); 257 purchaseOrderInfoService.updateSpecChangeStatus(record.getOrderId(), status);
240 } 258 }
241 } 259 }
  260 +
  261 + @Override
  262 + public void reviewPass(String id) {
  263 + if (StringUtils.isBlank(id)) {
  264 + return;
  265 + }
  266 + OrderSpecificationChangeRecord record = findById(id);
  267 + if (record == null) {
  268 + throw new DefaultClientException("规格变更记录不存在!");
  269 + }
  270 + // 更新状态
  271 + updateStatus(id, "PASS");
  272 + // 更新订货单规格数据
  273 + purchaseOrderLineService.updateByChangeId(id, record.getOrderId());
  274 + }
  275 +
  276 + @Override
  277 + public void reviewRefuse(String id, Boolean output) {
  278 + if (StringUtils.isBlank(id)) {
  279 + return;
  280 + }
  281 + OrderSpecificationChangeRecord record = findById(id);
  282 + if (record == null) {
  283 + throw new DefaultClientException("规格变更记录不存在!");
  284 + }
  285 + // 更新状态
  286 + LambdaUpdateWrapper<OrderSpecificationChangeRecord> updateWrapper = Wrappers.lambdaUpdate(OrderSpecificationChangeRecord.class);
  287 + updateWrapper.set(OrderSpecificationChangeRecord::getStatus, "REFUSE")
  288 + .eq(OrderSpecificationChangeRecord::getId, id);
  289 + if (output != null) {
  290 + updateWrapper.set(OrderSpecificationChangeRecord::getOutput, output);
  291 + }
  292 + getBaseMapper().update(updateWrapper);
  293 + }
242 } 294 }
@@ -246,6 +246,19 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde @@ -246,6 +246,19 @@ public class PurchaseOrderLineServiceImpl extends BaseMpServiceImpl<PurchaseOrde
246 getBaseMapper().batchUpdate(specList); 246 getBaseMapper().batchUpdate(specList);
247 } 247 }
248 248
  249 + /**
  250 + * 根据变更记录ID更新
  251 + *
  252 + * @param changeId 变更记录ID
  253 + */
  254 + @Override
  255 + public void updateByChangeId(String changeId, String orderId) {
  256 + if (StringUtil.isBlank(changeId)) {
  257 + return;
  258 + }
  259 + // todo 更新订货单规格数据
  260 + }
  261 +
249 @Override 262 @Override
250 public void cleanCacheByKey(Serializable key) { 263 public void cleanCacheByKey(Serializable key) {
251 264
@@ -65,4 +65,18 @@ public interface OrderSpecificationChangeRecordService extends BaseMpService<Ord @@ -65,4 +65,18 @@ public interface OrderSpecificationChangeRecordService extends BaseMpService<Ord
65 * @param status 状态 65 * @param status 状态
66 */ 66 */
67 void updateStatus(String id, String status); 67 void updateStatus(String id, String status);
  68 +
  69 + /**
  70 + * 审批通过
  71 + *
  72 + * @param id 主键ID
  73 + */
  74 + void reviewPass(String id);
  75 +
  76 + /**
  77 + * 审批拒绝
  78 + *
  79 + * @param id 主键ID
  80 + */
  81 + void reviewRefuse(String id, Boolean output);
68 } 82 }
@@ -93,4 +93,11 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin @@ -93,4 +93,11 @@ public interface PurchaseOrderLineService extends BaseMpService<PurchaseOrderLin
93 * @param specList 数据集合 93 * @param specList 数据集合
94 */ 94 */
95 void batchUpdate(List<PurchaseOrderLine> specList); 95 void batchUpdate(List<PurchaseOrderLine> specList);
  96 +
  97 + /**
  98 + * 根据变更记录ID更新
  99 + *
  100 + * @param changeId 变更记录ID
  101 + */
  102 + void updateByChangeId(String changeId, String orderId);
96 } 103 }