Commit 56d033c87ba0fcd21eec2aaac5229c917a73f80a

Authored by yeqianyong
1 parent 48b3414a

楚江erp:订货单确认变更逻辑调整(增加消息通知)

... ... @@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.handlers;
3 3 import com.lframework.starter.bpm.dto.FlowInstanceExtDto;
4 4 import com.lframework.starter.bpm.enums.FlowInstanceStatus;
5 5 import com.lframework.starter.bpm.service.BusinessDataHandlerService;
  6 +import com.lframework.starter.common.exceptions.impl.DefaultClientException;
6 7 import com.lframework.starter.common.utils.CollectionUtil;
7 8 import com.lframework.starter.mq.core.service.MqProducerService;
8 9 import com.lframework.starter.web.core.components.redis.RedisHandler;
... ... @@ -10,6 +11,8 @@ import com.lframework.starter.web.core.components.security.SecurityUtil;
10 11 import com.lframework.starter.web.core.utils.IdUtil;
11 12 import com.lframework.starter.web.core.utils.JsonUtil;
12 13 import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
  14 +import com.lframework.xingyun.basedata.entity.Workshop;
  15 +import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
13 16 import com.lframework.xingyun.sc.entity.*;
14 17 import com.lframework.xingyun.sc.enums.CustomerDevelopStatus;
15 18 import com.lframework.xingyun.sc.service.contract.ContractDistributorStandardService;
... ... @@ -94,7 +97,10 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
94 97 private DelayedShipmentDetailService delayedShipmentDetailService;
95 98 @Resource
96 99 private CarRequestPlanService carRequestPlanService;
97   -
  100 + @Resource
  101 + private WorkshopService workshopService;
  102 + @Resource
  103 + private MessageHandler messageHandler;
98 104
99 105
100 106 /**
... ... @@ -145,7 +151,7 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
145 151 break;
146 152 case "SPEC_CHANGE_SUBMIT":
147 153 case "SPEC_CHANGE_CONFIRM":
148   - handleOrderSpecChangeData(flowStatus, businessId);
  154 + handleOrderSpecChangeData(flowStatus, businessId, businessType);
149 155 break;
150 156 case "SPEC_LOCK_DELAY":
151 157 handleSpecLockDelayAuditData(flowStatus, businessId);
... ... @@ -429,10 +435,14 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
429 435 * @param flowStatus 审核结果
430 436 * @param businessId 业务ID
431 437 */
432   - private void handleOrderSpecChangeData(String flowStatus, String businessId) {
  438 + private void handleOrderSpecChangeData(String flowStatus, String businessId, String businessType) {
433 439 if (FlowInstanceStatus.APPROVE_PASS.getCode().equals(flowStatus)
434 440 || FlowInstanceStatus.FINISH.getCode().equals(flowStatus)) {
435 441 orderChangeRecordService.reviewPass(businessId);
  442 + if ("SPEC_CHANGE_CONFIRM".equals(businessType)) {
  443 + // 通知生产科计划员
  444 + noticeProductDept(businessId, businessType);
  445 + }
436 446 } else if (FlowInstanceStatus.REVOKE.getCode().equals(flowStatus)
437 447 || FlowInstanceStatus.REFUSE.getCode().equals(flowStatus)
438 448 || FlowInstanceStatus.TERMINATION.getCode().equals(flowStatus)) {
... ... @@ -557,4 +567,34 @@ public class BusinessDataHandlerServiceImpl implements BusinessDataHandlerServic
557 567 delayedShipmentService.updateStatus(businessId, "REFUSE");
558 568 }
559 569 }
  570 +
  571 +
  572 + /**
  573 + * 通知生产科计划员
  574 + *
  575 + * @param businessId 业务数据ID
  576 + * @param businessType 业务数据类型
  577 + */
  578 + private void noticeProductDept(String businessId, String businessType) {
  579 + OrderInfoChangeRecord record = orderChangeRecordService.findById(businessId);
  580 + if (record == null) {
  581 + throw new DefaultClientException("订货单变更记录不存在!");
  582 + }
  583 + String workshopId = record.getWorkshopId();
  584 + Workshop workshop = workshopService.findById(workshopId);
  585 + if (workshop != null) {
  586 + log.info("===================== noticeProductDept 所属分厂编号:{}", workshop.getCode());
  587 + List<String> roleCodes = new ArrayList<>();
  588 + if ("yfc".equals(workshop.getCode())) {
  589 + roleCodes.add("yfcsckjhy");
  590 + } else if ("efc".equals(workshop.getCode())) {
  591 + roleCodes.add("efcsckjhy");
  592 + } else if ("sfc".equals(workshop.getCode())) {
  593 + roleCodes.add("sfcsckjhy");
  594 + } else if ("ztfc".equals(workshop.getCode())) {
  595 + roleCodes.add("ztfcsckjhy");
  596 + }
  597 + messageHandler.sendMsg(null, roleCodes, businessType, businessId, null);
  598 + }
  599 + }
560 600 }
... ...
... ... @@ -32,7 +32,7 @@ public class MessageHandler {
32 32 * @param roleCodes 角色编号集合
33 33 * @param userId 人员ID
34 34 */
35   - public void sendMsg(String userId, List<String> roleCodes, String businessType, String sendUserId) {
  35 + public void sendMsg(String userId, List<String> roleCodes, String businessType, String businessId, String sendUserId) {
36 36 log.info("================== MessageHandler sendMsg invoke start, userId:{}, roleCodes:{}", userId, JsonUtil.toJsonString(roleCodes));
37 37 List<String> receiveUserIds = new ArrayList<>();
38 38 if (StringUtils.isNotBlank(userId)) {
... ... @@ -58,7 +58,11 @@ public class MessageHandler {
58 58 if ("SPEC_CHANGE_SUBMIT".equals(businessType)) {
59 59 title = "已产出,有损消息通知";
60 60 content = "已产出,有损消息通知";
61   - bizKey = IdUtil.getUUID();
  61 + bizKey = businessId;
  62 + } else if ("SPEC_CHANGE_CONFIRM".equals(businessType)) {
  63 + title = "确认变更消息通知";
  64 + content = "已确认需要变更,请及时执行变更计划!";
  65 + bizKey = businessId;
62 66 }
63 67 sendMsg(receiveUserIds, title, content, bizKey, sendUserId);
64 68 log.info("================== MessageHandler sendMsg invoke end!");
... ... @@ -75,6 +79,7 @@ public class MessageHandler {
75 79 */
76 80 public void sendMsg(List<String> userIds, String title, String content, String bizKey, String sendUserId) {
77 81 if (CollectionUtils.isEmpty(userIds)) {
  82 + log.info("====================== MessageHandler sendMsg userIds is empty!");
78 83 return;
79 84 }
80 85 SysSiteMessageDto siteMessageDto = new SysSiteMessageDto();
... ...
... ... @@ -419,7 +419,7 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR
419 419 }
420 420 }
421 421 // 消息通知
422   - messageHandler.sendMsg(record.getCreateById(), roleCodes, "SPEC_CHANGE_SUBMIT", null);
  422 + messageHandler.sendMsg(record.getCreateById(), roleCodes, "SPEC_CHANGE_SUBMIT", id, null);
423 423 }
424 424
425 425 @Override
... ...