Commit 0a43e5429cf812384dedcb1d9980f189bb601a43

Authored by 杨鸣坤
2 parents 2cbcfa66 63ca974a

Merge remote-tracking branch 'origin/master_0929' into master_0929

1 1 package com.lframework.xingyun.sc.handlers;
2 2
  3 +import com.lframework.starter.mq.core.service.MqProducerService;
3 4 import com.lframework.starter.web.core.utils.JsonUtil;
4   -import com.lframework.starter.web.inner.mappers.system.SysUserRoleMapper;
5   -import com.lframework.starter.web.inner.service.system.SysUserDeptService;
6   -import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
  5 +import com.lframework.starter.web.inner.dto.message.SysSiteMessageDto;
  6 +import com.lframework.starter.web.inner.service.system.SysUserRoleService;
7 7 import lombok.extern.slf4j.Slf4j;
  8 +import org.apache.commons.collections4.CollectionUtils;
  9 +import org.apache.commons.lang3.StringUtils;
8 10 import org.springframework.stereotype.Component;
9 11
10 12 import javax.annotation.Resource;
  13 +import java.util.ArrayList;
11 14 import java.util.List;
  15 +import java.util.stream.Collectors;
12 16
13 17 @Component
14 18 @Slf4j
15 19 public class MessageHandler {
16 20
17 21
  22 + @Resource
  23 + private SysUserRoleService sysUserRoleService;
  24 + @Resource
  25 + private MqProducerService mqProducerService;
  26 +
  27 +
18 28 /**
19 29 * 消息通知
20 30 *
21 31 * @param roleCodes 角色编号集合
22 32 * @param userId 人员ID
23   - * @return List<String>
24 33 */
25   - public List<String> sendMsg(String userId, List<String> roleCodes) {
  34 + public void sendMsg(String userId, List<String> roleCodes, String businessType, String sendUserId) {
26 35 log.info("================== MessageHandler sendMsg invoke start, userId:{}, roleCodes:{}", userId, JsonUtil.toJsonString(roleCodes));
  36 + List<String> receiveUserIds = new ArrayList<>();
  37 + if (StringUtils.isBlank(userId)) {
  38 + receiveUserIds.add(userId);
  39 + }
  40 + if (CollectionUtils.isEmpty(roleCodes)) {
  41 + // 获取角色下人员ID
  42 + List<String> userIds = sysUserRoleService.listUserIdByRoleCodes(roleCodes);
  43 + if (CollectionUtils.isNotEmpty(userIds)) {
  44 + receiveUserIds.addAll(userIds);
  45 + }
  46 + }
  47 + if (CollectionUtils.isEmpty(receiveUserIds)) {
  48 + return;
  49 + }
  50 + // 去重
  51 + receiveUserIds = receiveUserIds.stream().distinct().collect(Collectors.toList());
  52 + log.info("================== MessageHandler sendMsg receiveUserIds size:{}", receiveUserIds.size());
  53 + SysSiteMessageDto siteMessageDto = new SysSiteMessageDto();
  54 + siteMessageDto.setUserIdList(receiveUserIds);
  55 + // todo 完善消息标题、内容
  56 + String title = "";
  57 + String content = "";
  58 + String bizKey = "";
  59 + if ("SPEC_CHANGE_SUBMIT".equals(businessType)) {
  60 + }
  61 + siteMessageDto.setTitle(title);
  62 + siteMessageDto.setContent(content);
  63 + siteMessageDto.setBizKey(bizKey);
  64 + if (StringUtils.isBlank(sendUserId)) {
  65 + // 系统自动发送
  66 + siteMessageDto.setCreateUserId(null);
  67 + } else {
  68 + siteMessageDto.setCreateUserId(sendUserId);
  69 + }
27 70
28   - return null;
  71 + mqProducerService.createSysSiteMessage(siteMessageDto);
  72 + log.info("================== MessageHandler sendMsg invoke end!");
29 73 }
30 74 }
... ...
... ... @@ -3,6 +3,7 @@ package com.lframework.xingyun.sc.handlers;
3 3 import com.lframework.starter.web.core.utils.JsonUtil;
4 4 import com.lframework.starter.web.inner.mappers.system.SysUserRoleMapper;
5 5 import com.lframework.starter.web.inner.service.system.SysUserDeptService;
  6 +import com.lframework.starter.web.inner.service.system.SysUserRoleService;
6 7 import com.lframework.xingyun.basedata.entity.Workshop;
7 8 import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
8 9 import lombok.extern.slf4j.Slf4j;
... ... @@ -11,6 +12,7 @@ import org.springframework.stereotype.Component;
11 12
12 13 import javax.annotation.Resource;
13 14 import java.util.ArrayList;
  15 +import java.util.Collections;
14 16 import java.util.List;
15 17 import java.util.Map;
16 18
... ... @@ -21,7 +23,7 @@ public class TransactorHandler {
21 23 @Resource
22 24 private SysUserDeptService userDeptService;
23 25 @Resource
24   - private SysUserRoleMapper sysUserRoleMapper;
  26 + private SysUserRoleService sysUserRoleService;
25 27 @Resource
26 28 private WorkshopService workshopService;
27 29
... ... @@ -36,7 +38,7 @@ public class TransactorHandler {
36 38 public List<String> listTransactorsByRoleCode(String roleCode, String userId) {
37 39 log.info("================== listTransactorsByRoleCode invoke start, roleCode:{}, userId:{}", roleCode, userId);
38 40 // 获取角色下人员
39   - List<String> userIdList = sysUserRoleMapper.listUserIdByRoleCode(roleCode);
  41 + List<String> userIdList = sysUserRoleService.listUserIdByRoleCodes(Collections.singletonList(roleCode));
40 42 if (CollectionUtils.isEmpty(userIdList)) {
41 43 return new ArrayList<>();
42 44 }
... ... @@ -73,7 +75,7 @@ public class TransactorHandler {
73 75 }
74 76 String workshopName = workshop.getName();
75 77 // 获取角色下人员
76   - List<String> userIdList = sysUserRoleMapper.listUserIdByRoleCode(roleCode);
  78 + List<String> userIdList = sysUserRoleService.listUserIdByRoleCodes(Collections.singletonList(roleCode));
77 79 if (CollectionUtils.isEmpty(userIdList)) {
78 80 return new ArrayList<>();
79 81 }
... ...
... ... @@ -21,6 +21,7 @@ import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
21 21 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
22 22 import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
23 23 import com.lframework.xingyun.sc.enums.OrderSpecChangeStatus;
  24 +import com.lframework.xingyun.sc.handlers.MessageHandler;
24 25 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
25 26 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
26 27 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
... ... @@ -60,6 +61,8 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR
60 61 private CustomerCreditService customerCreditService;
61 62 @Resource
62 63 private RedisHandler redisHandler;
  64 + @Resource
  65 + private MessageHandler messageHandler;
63 66
64 67
65 68 @Override
... ... @@ -289,4 +292,21 @@ public class OrderChangeRecordServiceImpl extends BaseMpServiceImpl<OrderChangeR
289 292 // 更新订货单物料行数据
290 293 purchaseOrderLineService.update(record.getOrderId(), record.getAfterChangeSpecList());
291 294 }
  295 +
  296 + @Override
  297 + public void output(String id) {
  298 + if (StringUtils.isBlank(id)) {
  299 + return;
  300 + }
  301 + OrderInfoChangeRecord record = getById(id);
  302 + if (record == null) {
  303 + throw new DefaultClientException("订货单变更记录不存在!");
  304 + }
  305 + LambdaUpdateWrapper<OrderInfoChangeRecord> updateWrapper = Wrappers.lambdaUpdate(OrderInfoChangeRecord.class);
  306 + updateWrapper.set(OrderInfoChangeRecord::getOutput, true)
  307 + .eq(OrderInfoChangeRecord::getId, id);
  308 + getBaseMapper().update(updateWrapper);
  309 + // 消息通知
  310 + messageHandler.sendMsg(record.getCreateById(), Collections.singletonList("jybjhy"), "SPEC_CHANGE_SUBMIT", null);
  311 + }
292 312 }
... ...
1 1 package com.lframework.xingyun.sc.listeners.flow;
2 2
3 3 import com.lframework.starter.bpm.dto.FlowInstanceExtDto;
  4 +import com.lframework.starter.bpm.enums.FlowInstanceStatus;
4 5 import com.lframework.starter.web.core.components.security.SecurityUtil;
5 6 import com.lframework.starter.web.core.utils.JsonUtil;
6 7 import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
  8 +import com.lframework.xingyun.sc.service.order.OrderChangeRecordService;
7 9 import com.lframework.xingyun.sc.vo.customer.credit.UpdateCustomerCreditVo;
8 10 import lombok.extern.slf4j.Slf4j;
9 11 import org.apache.commons.collections4.MapUtils;
... ... @@ -23,6 +25,8 @@ public class NodeFinishListener implements Listener {
23 25
24 26 @Resource
25 27 private CustomerCreditService customerCreditService;
  28 + @Resource
  29 + private OrderChangeRecordService orderChangeRecordService;
26 30
27 31
28 32 /**
... ... @@ -52,6 +56,7 @@ public class NodeFinishListener implements Listener {
52 56 FlowInstanceExtDto flowInstanceExtDto = JsonUtil.parseObject(ext, FlowInstanceExtDto.class);
53 57 businessType = flowInstanceExtDto.getBizFlag();
54 58 }
  59 + String flowStatus = instance.getFlowStatus();
55 60 if ("CUSTOMER_CREDIT".equals(businessType)) {
56 61 // 更新业务数据
57 62 switch (nodeCode) {
... ... @@ -74,6 +79,13 @@ public class NodeFinishListener implements Listener {
74 79 default:
75 80 break;
76 81 }
  82 + } else if ("SPEC_CHANGE_SUBMIT".equals(businessType)) {
  83 + // 订货单变更提交
  84 + if ("final_node".equals(nodeCode)
  85 + && (FlowInstanceStatus.REFUSE.getCode().equals(flowStatus) || FlowInstanceStatus.REVOKE.getCode().equals(flowStatus))) {
  86 + // 标识订货单已产出
  87 + orderChangeRecordService.output(businessId);
  88 + }
77 89 }
78 90 log.info("==================== 流程节点完成监听器结束......");
79 91 }
... ...
... ... @@ -72,4 +72,11 @@ public interface OrderChangeRecordService extends BaseMpService<OrderInfoChangeR
72 72 * @param id 主键ID
73 73 */
74 74 void reviewPass(String id);
  75 +
  76 + /**
  77 + * 已产出,有损
  78 + *
  79 + * @param id 主键ID
  80 + */
  81 + void output(String id);
75 82 }
... ...
... ... @@ -31,6 +31,12 @@ public class QueryCustomerDevelopPlanVo extends SortPageVo implements BaseVo, Se
31 31 private String customerId;
32 32
33 33 /**
  34 + * 客户名称
  35 + */
  36 + @ApiModelProperty("客户名称")
  37 + private String customerName;
  38 +
  39 + /**
34 40 * 厂房ID
35 41 */
36 42 @ApiModelProperty("厂房ID")
... ...
... ... @@ -88,6 +88,15 @@
88 88 #{item}
89 89 </foreach>
90 90 </if>
  91 + <if test="vo.createStartTime != null">
  92 + AND tb.create_time >= #{vo.createStartTime}
  93 + </if>
  94 + <if test="vo.createEndTime != null">
  95 + AND tb.create_time &lt;= #{vo.createEndTime}
  96 + </if>
  97 + <if test="vo.customerName != null and vo.customerName != ''">
  98 + AND c.name LIKE CONCAT('%', #{vo.customerName}, '%')
  99 + </if>
91 100 </where>
92 101 </sql>
93 102
... ...