From d45592a030c9df56ee8d7faece5601cad528d478 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Fri, 17 Jan 2025 21:38:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E9=87=91=E7=89=8C=E5=B7=A5?= =?UTF-8?q?=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 优化金牌回传失败问题 --- .../factorydata/jinpai/job/AuthPushJob.java | 53 +++++++++++++++++++ .../jinpai/mq/NodeDataPushListener.java | 12 +++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AuthPushJob.java b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AuthPushJob.java index 7368adb7f..5ff1d208d 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AuthPushJob.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/job/AuthPushJob.java @@ -2,9 +2,15 @@ package com.logpm.factorydata.jinpai.job; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.factorydata.jinpai.entity.CustomPushEntity; +import com.logpm.factorydata.jinpai.entity.FactoryNodePushEntity; +import com.logpm.factorydata.jinpai.pros.JinPaiProperties; import com.logpm.factorydata.jinpai.service.CustomPushService; +import com.logpm.factorydata.jinpai.service.FactoryNodePushService; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.AllArgsConstructor; @@ -29,6 +35,8 @@ public class AuthPushJob { private final CustomPushService customPushService; private final RabbitTemplate rabbitTemplate; + private final FactoryNodePushService factoryNodePushService; + private final JinPaiProperties jinPaiProperties; /** * 自定义回传工厂节点作业数据 @@ -59,4 +67,49 @@ public class AuthPushJob { return ReturnT.SUCCESS; } + /** + * 字段缺失重新推送 + * + * @param param + * @return + * @throws Exception + */ + @XxlJob("rePush") + public ReturnT rePush(String param) throws Exception { + // 查出数据,回推工厂 + List list = factoryNodePushService.list(Wrappers.lambdaQuery() + .eq(FactoryNodePushEntity::getReserve1, "0").last(" limit 1")); + if (CollUtil.isNotEmpty(list)) { + FactoryNodePushEntity factoryNodePushEntity = list.get(0); + String content = factoryNodePushEntity.getContent(); + JSONObject entries = JSONUtil.parseObj(content); + entries.set("passSite", entries.getStr("endSite")); + String url = jinPaiProperties.getOldSystemHost() + jinPaiProperties.getOldSystemArrivedUrl(); + log.info("字段缺失重新推送:{}", JSONUtil.toJsonStr(entries)); + String result = HttpUtil.post(url, JSONUtil.toJsonStr(entries)); + FactoryNodePushEntity factoryNodePushEntity1 = new FactoryNodePushEntity(); + factoryNodePushEntity1.setContent(JSONUtil.toJsonStr(entries)); + factoryNodePushEntity1.setId(factoryNodePushEntity.getId()); + factoryNodePushEntity1.setReserve1("1"); + factoryNodePushEntity1.setResultContent(result); + factoryNodePushService.updateById(factoryNodePushEntity1); + List list1 = factoryNodePushService.list(Wrappers.lambdaQuery() + .eq(FactoryNodePushEntity::getTransportNo, factoryNodePushEntity.getTransportNo()) + .eq(FactoryNodePushEntity::getOrderCode, factoryNodePushEntity.getOrderCode())); + if(CollUtil.isNotEmpty(list1)){ + for (FactoryNodePushEntity nodePushEntity : list1) { + String content1 = nodePushEntity.getContent(); + String url1 = jinPaiProperties.getOldSystemHost() + jinPaiProperties.getOldSystemArrivedUrl(); + log.info("字段缺失重新推送:{}", JSONUtil.toJsonStr(entries)); + String result1 = HttpUtil.post(url1, content1); + FactoryNodePushEntity factoryNodePushEntity2 = new FactoryNodePushEntity(); + factoryNodePushEntity2.setResultContent(result1); + factoryNodePushEntity2.setId(nodePushEntity.getId()); + factoryNodePushService.updateById(factoryNodePushEntity2); + } + } + } + return ReturnT.SUCCESS; + } + } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/NodeDataPushListener.java b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/NodeDataPushListener.java index 4369248d9..bf8a46510 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/NodeDataPushListener.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/NodeDataPushListener.java @@ -252,7 +252,11 @@ public class NodeDataPushListener { js.set("doTime", entries.getStr("operatorTime")); js.set("sendSite", filterDatum.getWaybillStartWarehouse()); js.set("endSite", filterDatum.getWarehouseName()); - js.set("passSite", filterDatum.getDestinationWarehouse()); + if (StrUtil.isNotEmpty(filterDatum.getDestinationWarehouse())) { + js.set("passSite", filterDatum.getDestinationWarehouse()); + } else { + js.set("passSite", filterDatum.getWarehouseName()); + } js.set("doRemark", ""); js.set("reqSn", (RandomUtil.randomLong(100000000000000000L, 999999999999999999L)) + ""); js.set("syscode", "huitong"); @@ -297,9 +301,9 @@ public class NodeDataPushListener { .content(objects) .build(); factoryDataClient.sendMessage(SendMsg.builder() - .exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED) - .routingKey(FactoryDataConstants.Mq.RoutingKeys.JP_NODE_DATA_PUSH) - .message(JSONUtil.toJsonStr(nodePushMsg, HutoolConfigUtil.jsonConfigByDataTimeFormat())) + .exchange(FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED) + .routingKey(FactoryDataConstants.Mq.RoutingKeys.JP_NODE_DATA_PUSH) + .message(JSONUtil.toJsonStr(nodePushMsg, HutoolConfigUtil.jsonConfigByDataTimeFormat())) // 30-109秒随机 .delay(1000 * RandomUtil.randomInt(30, 110)) .build());