From 41a2646a71c2d4fb6e2588dd14de45a78918265d Mon Sep 17 00:00:00 2001 From: zhaoqiaobo Date: Fri, 12 Apr 2024 16:40:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(service):=20=E5=BF=97=E9=82=A6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BF=85=E9=A1=BB=E8=8A=82=E7=82=B9=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1=E6=97=B6=E8=87=AA=E5=8A=A8=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/ZbFactoryNodePushFailEntity.java | 22 +++++ .../zbom/mq/ZbomNodeDataPushListener.java | 90 ++++++++++++------- 2 files changed, 80 insertions(+), 32 deletions(-) diff --git a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java index 1bea2ed05..6cd896836 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/entity/ZbFactoryNodePushFailEntity.java @@ -50,6 +50,28 @@ public class ZbFactoryNodePushFailEntity extends BaseEntity { */ @ApiModelProperty(name = "预留5", notes = "") private String reserve5; + + /** + * 发车单号 + */ + @ApiModelProperty(name = "发车单号", notes = "") + private String departCode; + /** + * 加盟商单号 + */ + @ApiModelProperty(name = "加盟商单号", notes = "") + private String platformOrderCode; + /** + * 节点 + */ + @ApiModelProperty(name = "节点", notes = "") + private String node; + /** + * 包条码 + */ + @ApiModelProperty(name = "包条码", notes = "") + private String packageCode; + /** * 内容 */ diff --git a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/mq/ZbomNodeDataPushListener.java b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/mq/ZbomNodeDataPushListener.java index 56e69a9d2..9b6d5c204 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/mq/ZbomNodeDataPushListener.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-zbom/src/main/java/com/logpm/factorydata/zbom/mq/ZbomNodeDataPushListener.java @@ -9,7 +9,6 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.logpm.factorydata.enums.BrandEnums; -import org.springblade.common.constant.WorkNodeEnums; import com.logpm.factorydata.feign.IFactoryDataClient; import com.logpm.factorydata.vo.NodePushMsg; import com.logpm.factorydata.vo.SendMsg; @@ -33,6 +32,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.springblade.common.constant.WorkNodeEnums; import org.springblade.common.constant.factorydata.FactoryDataConstants; import org.springblade.common.utils.HutoolConfigUtil; import org.springframework.amqp.core.ExchangeTypes; @@ -145,7 +145,16 @@ public class ZbomNodeDataPushListener { } log.info("zb节点推送数据:参数{},返回值{}。", body, result); if (StrUtil.isNotBlank(result)) { - ZbFactoryNodePushFailEntity build = ZbFactoryNodePushFailEntity.builder().content(body).resultContent(result).build(); + NodeDataDTO nodeDataDTO = nodeDataMap.get(key); + String packageCode = nodeDataDTO.getPackageCode(); + ZbFactoryNodePushFailEntity build = ZbFactoryNodePushFailEntity.builder() + .content(body) + .resultContent(result) + .departCode(nodeConfirmParam.getDepartCode()) + .platformOrderCode(nodeConfirmParam.getPlatformOrderCode()) + .node(nodeConfirmParam.getNode()) + .packageCode(packageCode) + .build(); if (!StrUtil.contains(result, "code")) { // 推送失败 nodePushFailService.save(build); @@ -156,8 +165,6 @@ public class ZbomNodeDataPushListener { // 推送失败 nodePushFailService.save(build); } - NodeDataDTO nodeDataDTO = nodeDataMap.get(key); - String packageCode = nodeDataDTO.getPackageCode(); if (ObjectUtil.isEmpty(packageCode)) { continue; } @@ -228,42 +235,21 @@ public class ZbomNodeDataPushListener { log.info("key:{},签收数量:{}", departCode + "_" + platformOrderCode, signNumber); // 签收环节上一个节点是在途,说明缺少一个送货抵达,需要补一个节点 - if (ObjectUtil.isEmpty(nodeOrderEntity) || ObjectUtil.equal(nodeOrderEntity.getCurrentNode(), ZbomNodeEnums.INTRANSIT.getIndex())) { - + if (ObjectUtil.isEmpty(nodeOrderEntity.getPushNode()) || !StrUtil.contains(nodeOrderEntity.getPushNode(), ZbomNodeEnums.DELIVERY_ARRIVAL.getCode())) { // 第一次签收,节点改为送货抵达 - paramDTO.setNode(ZbomNodeEnums.DELIVERY_ARRIVAL.getCode()); currentNode = ZbomNodeEnums.DELIVERY_ARRIVAL; - List js = new ArrayList<>(); - for (String s : nodeData.getPackageCode().split(",")) { - JSONObject entries1 = new JSONObject(); - entries1.set("packageCode", s); - js.add(entries1); - } - NodePushMsg nodePushMsg = NodePushMsg.builder() - .node(WorkNodeEnums.CLERK_REVIEW) - .operator(paramDTO.getOperator()) - .operatorTime(DateUtil.parseDateTime(paramDTO.getOperatorTime())) - .address(paramDTO.getAddress()) - .brand(BrandEnums.ZB) - .content(js) - .build(); - SendMsg message = SendMsg.builder() - .delay(30 * 60 * 1000) - .exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED) - .routingKey(FactoryDataConstants.Mq.RoutingKeys.ZBOM_NODE_DATA_PUSH) - .message(JSONUtil.toJsonStr(nodePushMsg, HutoolConfigUtil.jsonConfigByDataTimeFormat())) - .build(); - sendMsgMap.put(key, message); + Integer nodeDelay = 15 * 60 * 1000; + buildSendMag(sendMsgMap, nodeData, key, paramDTO, node, nodeDelay); } else { // 查询当前未签收的数量与当前签收数量比较,如果未签收数较大,则是部分签收 - paramDTO.setNode(ZbomNodeMappingEnums.getZbomByNodeAndStatus(workNodeEnums, ZbomConstants.Status.SIGN_FOR_SECTION_STATUS).getCode()); + currentNode = ZbomNodeEnums.PARTIAL_RECEIPT; paramDTO.setSignQty(nodeData.getSignQty()); if (ObjectUtil.isNotEmpty(noSignNumberMap) && noSignNumberMap.containsKey(key)) { Integer noSignNum = noSignNumberMap.get(key); if (noSignNum <= signNumber) { // 全部签收 log.info("{} 全部签收", platformOrderCode); - paramDTO.setNode(ZbomNodeMappingEnums.getZbomByNodeAndStatus(workNodeEnums, ZbomConstants.Status.SIGN_FOR_ALL_STATUS).getCode()); + currentNode = ZbomNodeEnums.SIGN_FOR; } } else { continue; @@ -272,21 +258,61 @@ public class ZbomNodeDataPushListener { // 如果之前发送的是部分签收,则之后的所有签收节点都发部分签收 if (StrUtil.isNotEmpty(pushNode) && pushNode.contains(ZbomNodeEnums.PARTIAL_RECEIPT.getIndex().toString())) { log.info("{} 部分签收", platformOrderCode); - paramDTO.setNode(ZbomNodeMappingEnums.getZbomByNodeAndStatus(workNodeEnums, ZbomConstants.Status.SIGN_FOR_SECTION_STATUS).getCode()); + currentNode = ZbomNodeEnums.PARTIAL_RECEIPT; } - currentNode = ZbomNodeEnums.getByCode(paramDTO.getNode()); } } Integer index = currentNode.getIndex(); + Integer startNodeDelay = 15 * 60 * 1000; + // 历史必须节点需要补发 + if (ObjectUtil.isEmpty(nodeOrderEntity.getPushNode())) { + // 历史不存在,当前节点不是第一个节点,则需要补发第一个节点 + if (!ObjectUtil.equal(index, ZbomNodeEnums.STATION_DEPART.getIndex())) { + currentNode = ZbomNodeEnums.STATION_DEPART; + buildSendMag(sendMsgMap, nodeData, key, paramDTO, node, startNodeDelay); + } + } else { + // 历史节点存在,但是历史节点中不包含第一个节点,且当前节点不是第一个节点,则需要补发第一个节点 + if (!ObjectUtil.equal(index, ZbomNodeEnums.STATION_DEPART.getIndex()) + && !StrUtil.contains(nodeOrderEntity.getPushNode(), ZbomNodeEnums.STATION_DEPART.getIndex().toString())) { + currentNode = ZbomNodeEnums.STATION_DEPART; + buildSendMag(sendMsgMap, nodeData, key, paramDTO, node, startNodeDelay); + } + } // 组装历史节点数据 if (buildNodeOrder(nodeOrderEntity, currentNode, departCode, platformOrderCode, index, nodeOrderMap)) { continue; } + paramDTO.setNode(currentNode.getCode()); nodeConfirmLsit.add(paramDTO); } } } + private void buildSendMag(Map sendMsgMap, NodeDataDTO nodeData, String key, NodeConfirmParamDTO paramDTO, String node, Integer delay) { + List js = new ArrayList<>(); + for (String s : nodeData.getPackageCode().split(",")) { + JSONObject entries1 = new JSONObject(); + entries1.set("packageCode", s); + js.add(entries1); + } + NodePushMsg nodePushMsg = NodePushMsg.builder() + .node(EnumUtil.fromString(WorkNodeEnums.class, node)) + .operator(paramDTO.getOperator()) + .operatorTime(DateUtil.parseDateTime(paramDTO.getOperatorTime())) + .address(paramDTO.getAddress()) + .brand(BrandEnums.ZB) + .content(js) + .build(); + SendMsg message = SendMsg.builder() + .delay(delay) + .exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED) + .routingKey(FactoryDataConstants.Mq.RoutingKeys.ZBOM_NODE_DATA_PUSH) + .message(JSONUtil.toJsonStr(nodePushMsg, HutoolConfigUtil.jsonConfigByDataTimeFormat())) + .build(); + sendMsgMap.put(key, message); + } + private boolean buildNodeOrder(ZbFactoryNodeOrderEntity nodeOrderEntity, ZbomNodeEnums zbNode, String departCode, String platformOrderCode, Integer index, Map nodeOrderEntityMap) { if (ObjectUtil.isNotEmpty(nodeOrderEntity)) { Integer currentNode = nodeOrderEntity.getCurrentNode();