From 83d226c7a803616d948bd40c9e325c914d1be610 Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Wed, 6 Nov 2024 14:19:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E6=9E=97=E6=B0=8F=E5=AE=B6?= =?UTF-8?q?=E5=B1=85=E5=B7=A5=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 增加林氏工厂自定义回传逻辑 2 修改林氏工厂回传逻辑,兼容始发仓=末端仓的情况 --- .../linsy/config/XxlJobConfig.java | 74 ++++++++ .../linsy/entity/CustomPushEntity.java | 51 ++++++ .../linsy/enums/NodeMappingEnums.java | 3 +- .../linsy/enums/NodeNeedEnums.java | 1 + .../factorydata/linsy/job/CustomPushJob.java | 173 ++++++++++++++++++ .../linsy/mapper/CustomPushMapper.java | 16 ++ .../linsy/mapper/CustomPushMapper.xml | 5 + .../linsy/mq/NodeDataPushListener.java | 118 +++++++++--- .../linsy/service/CustomPushService.java | 14 ++ .../service/impl/CustomPushServiceImpl.java | 22 +++ 10 files changed, 451 insertions(+), 26 deletions(-) create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/XxlJobConfig.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/CustomPushEntity.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/job/CustomPushJob.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.xml create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/CustomPushService.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/CustomPushServiceImpl.java diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/XxlJobConfig.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/XxlJobConfig.java new file mode 100644 index 000000000..e00bca0c8 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/config/XxlJobConfig.java @@ -0,0 +1,74 @@ +package com.logpm.factorydata.linsy.config; + +import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * xxl-job config + * + * @author xuxueli 2017-04-28 + */ +@Configuration(proxyBeanMethods = false) +public class XxlJobConfig { + private final Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); + + @Value("${xxl.job.admin.addresses}") + private String adminAddresses; + + @Value("${xxl.job.executor.appname}") + private String appName; + + @Value("${xxl.job.executor.ip}") + private String ip; + + @Value("${xxl.job.executor.port}") + private int port; + + @Value("${xxl.job.accessToken}") + private String accessToken; + + @Value("${xxl.job.executor.logpath}") + private String logPath; + + @Value("${xxl.job.executor.logretentiondays}") + private int logRetentionDays; + + + @Bean + public XxlJobSpringExecutor xxlJobExecutor() { + logger.info(">>>>>>>>>>> xxl-job config init."); + XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); + xxlJobSpringExecutor.setAdminAddresses(adminAddresses); + xxlJobSpringExecutor.setAppName(appName); + xxlJobSpringExecutor.setIp(ip); + xxlJobSpringExecutor.setPort(port); + xxlJobSpringExecutor.setAccessToken(accessToken); + xxlJobSpringExecutor.setLogPath(logPath); + xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); + + return xxlJobSpringExecutor; + } + + /** + * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP; + * + * 1、引入依赖: + * + * org.springframework.cloud + * spring-cloud-commons + * ${version} + * + * + * 2、配置文件,或者容器启动变量 + * spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.' + * + * 3、获取IP + * String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); + */ + + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/CustomPushEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/CustomPushEntity.java new file mode 100644 index 000000000..349870707 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/entity/CustomPushEntity.java @@ -0,0 +1,51 @@ +package com.logpm.factorydata.linsy.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * 林氏自定义回传 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@TableName("linsy_custom_push") +@ApiModel(value = "林氏自定义回传", description = "林氏自定义回传") +@EqualsAndHashCode(callSuper = true) +public class CustomPushEntity extends BaseEntity { + + @ApiModelProperty(name = "订单号", notes = "") + private String orderCode; + + @ApiModelProperty(name = "仓库", notes = "") + private String departureWarehouseName; + + @ApiModelProperty(name = "包件码", notes = "") + private String destinationWarehouseName; + + @ApiModelProperty(name = "返回内容", notes = "") + private String result; + + @ApiModelProperty(name = "返回码", notes = "") + private String resultCode; + + @ApiModelProperty(name = "状态 1已发送 0未发送", notes = "") + private Integer sendStatus; + + @ApiModelProperty(name = "预留1", notes = "") + private String reserve1; + @ApiModelProperty(name = "预留2", notes = "") + private String reserve2; + @ApiModelProperty(name = "预留3", notes = "") + private String reserve3; + @ApiModelProperty(name = "预留4", notes = "") + private String reserve4; + @ApiModelProperty(name = "预留5", notes = "") + private String reserve5; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java index 068297675..46463f92e 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeMappingEnums.java @@ -20,7 +20,8 @@ public enum NodeMappingEnums { /** * 收货完成 */ - END_WAREHOUSE_UNLOADING(FactoryNodeEnums.END_WAREHOUSE_UNLOADING, WorkNodeEnums.END_WAREHOUSE_UNLOADING, 1); + END_WAREHOUSE_UNLOADING(FactoryNodeEnums.END_WAREHOUSE_UNLOADING, WorkNodeEnums.END_WAREHOUSE_UNLOADING, 1), + OPEN_ORDER(FactoryNodeEnums.END_WAREHOUSE_UNLOADING, WorkNodeEnums.OPEN_ORDER, 1); /** * 系统作业节点 diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java index 899169bbc..c6688d251 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/enums/NodeNeedEnums.java @@ -17,6 +17,7 @@ public enum NodeNeedEnums implements Serializable { * 始发仓入库 */ INITIAL_WAREHOUSE_ENTRY(101020, "始发仓入库"), + OPEN_ORDER(102010, "开单"), /** * 末端仓卸车确认 */ diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/job/CustomPushJob.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/job/CustomPushJob.java new file mode 100644 index 000000000..6b5f516d0 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/job/CustomPushJob.java @@ -0,0 +1,173 @@ +package com.logpm.factorydata.linsy.job; + +import cn.hutool.core.collection.CollUtil; +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.linsy.entity.CustomPushEntity; +import com.logpm.factorydata.linsy.entity.FactoryNodePushEntity; +import com.logpm.factorydata.linsy.entity.PackageInfoEntity; +import com.logpm.factorydata.linsy.enums.FactoryNodeEnums; +import com.logpm.factorydata.linsy.pros.LinsyProperties; +import com.logpm.factorydata.linsy.service.CustomPushService; +import com.logpm.factorydata.linsy.service.FactoryNodePushService; +import com.logpm.factorydata.linsy.service.PackageInfoService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 自动回传工厂 + * + * @author zhaoqiaobo + * @create 2024-04-02 + */ +@AllArgsConstructor +@Component +@Slf4j +public class CustomPushJob { + + private final CustomPushService customPushService; + private final PackageInfoService packageInfoService; + private final LinsyProperties linsyProperties; + private final FactoryNodePushService factoryNodePushService; + + /** + * 自定义回传交接 + * + * @param param + * @return + * @throws Exception + */ + @XxlJob("customPushFactoryDataOne") + public ReturnT customPushFactoryDataOne(String param) throws Exception { + List list = customPushService.list(Wrappers.lambdaQuery() + .lt(CustomPushEntity::getSendStatus, 10) + .last(" limit 1 ") + ); + if (CollUtil.isNotEmpty(list)) { + CustomPushEntity customPushEntity = list.get(0); + String orderCode = customPushEntity.getOrderCode(); + List list1 = packageInfoService.list(Wrappers.lambdaQuery() + .eq(PackageInfoEntity::getOrderCode, orderCode) + ); + if (CollUtil.isNotEmpty(list1)) { + PackageInfoEntity infoEntity = list1.get(0); + JSONObject sendObj = new JSONObject(); + sendObj.set("billCode", infoEntity.getBillCode()); + sendObj.set("status", FactoryNodeEnums.INITIAL_WAREHOUSE_ENTRY.getText()); + sendObj.set("packages", list1.stream().map(packageInfoEntity -> { + JSONObject jsonObject = new JSONObject(); + jsonObject.set("barcode", packageInfoEntity.getBarcode()); + return jsonObject; + }).collect(Collectors.toList())); + log.info("推送工厂:{}", JSONUtil.toJsonStr(sendObj)); + String url = linsyProperties.getHost() + linsyProperties.getPushNodeUrl(); + try { + if (linsyProperties.getEnable()) { + String result = HttpUtil.post(url, JSONUtil.toJsonStr(sendObj)); + log.info("推送工厂结果:{}", result); + // 保存推送记录 + factoryNodePushService.save(FactoryNodePushEntity.builder() + .billCode(orderCode) + .node(FactoryNodeEnums.INITIAL_WAREHOUSE_ENTRY.getCode().toString()) + .content(JSONUtil.toJsonStr(sendObj)) + .resultContent(result) + .build()); + customPushService.update(Wrappers.lambdaUpdate() + .set(CustomPushEntity::getSendStatus, 10) + .set(CustomPushEntity::getResult, result) + .eq(CustomPushEntity::getOrderCode, customPushEntity.getOrderCode()) + ); + // 封装需要修改作业节点状态的数据 + packageInfoService.update(Wrappers.lambdaUpdate() + .set(PackageInfoEntity::getWorkedNodeCode, FactoryNodeEnums.INITIAL_WAREHOUSE_ENTRY.getCode().toString()) + .eq(PackageInfoEntity::getOrderCode, orderCode)); + } + } catch (Exception e) { + log.error("推送工厂失败:{}", e); + } + }else{ + customPushService.update(Wrappers.lambdaUpdate() + .set(CustomPushEntity::getSendStatus, 10) + .set(CustomPushEntity::getResult, "未查询到订单包件") + .eq(CustomPushEntity::getOrderCode, customPushEntity.getOrderCode()) + ); + } + } + return ReturnT.SUCCESS; + } + + /** + * 自定义回传收货 + * + * @param param + * @return + * @throws Exception + */ + @XxlJob("customPushFactoryDataTwo") + public ReturnT customPushFactoryDataTwo(String param) throws Exception { + List list = customPushService.list(Wrappers.lambdaQuery() + .lt(CustomPushEntity::getSendStatus, 20) + .last(" limit 1 ") + ); + if (CollUtil.isNotEmpty(list)) { + CustomPushEntity customPushEntity = list.get(0); + String orderCode = customPushEntity.getOrderCode(); + List list1 = packageInfoService.list(Wrappers.lambdaQuery() + .eq(PackageInfoEntity::getOrderCode, orderCode) + ); + if (CollUtil.isNotEmpty(list1)) { + PackageInfoEntity infoEntity = list1.get(0); + JSONObject sendObj = new JSONObject(); + sendObj.set("billCode", infoEntity.getBillCode()); + sendObj.set("status", FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getText()); + sendObj.set("packages", list1.stream().map(packageInfoEntity -> { + JSONObject jsonObject = new JSONObject(); + jsonObject.set("barcode", packageInfoEntity.getBarcode()); + return jsonObject; + }).collect(Collectors.toList())); + log.info("推送工厂:{}", JSONUtil.toJsonStr(sendObj)); + String url = linsyProperties.getHost() + linsyProperties.getPushNodeUrl(); + try { + if (linsyProperties.getEnable()) { + String result = HttpUtil.post(url, JSONUtil.toJsonStr(sendObj)); + log.info("推送工厂结果:{}", result); + // 保存推送记录 + factoryNodePushService.save(FactoryNodePushEntity.builder() + .billCode(orderCode) + .node(FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode().toString()) + .content(JSONUtil.toJsonStr(sendObj)) + .resultContent(result) + .build()); + customPushService.update(Wrappers.lambdaUpdate() + .set(CustomPushEntity::getSendStatus, 20) + .set(CustomPushEntity::getResult, result) + .eq(CustomPushEntity::getOrderCode, customPushEntity.getOrderCode()) + ); + // 封装需要修改作业节点状态的数据 + packageInfoService.update(Wrappers.lambdaUpdate() + .set(PackageInfoEntity::getWorkedNodeCode, FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode().toString()) + .eq(PackageInfoEntity::getOrderCode, orderCode)); + } + } catch (Exception e) { + log.error("推送工厂失败:{}", e); + } + }else{ + customPushService.update(Wrappers.lambdaUpdate() + .set(CustomPushEntity::getSendStatus, 20) + .set(CustomPushEntity::getResult, "未查询到订单包件") + .eq(CustomPushEntity::getOrderCode, customPushEntity.getOrderCode()) + ); + } + } + return ReturnT.SUCCESS; + } + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.java new file mode 100644 index 000000000..c6c418b34 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.java @@ -0,0 +1,16 @@ +package com.logpm.factorydata.linsy.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.factorydata.linsy.entity.CustomPushEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 自定义回传 mapper + * + * @author zqb + * @since 2024-03-26 + */ +@Mapper +public interface CustomPushMapper extends BaseMapper { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.xml b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.xml new file mode 100644 index 000000000..fedc6c4bc --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mapper/CustomPushMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java index f095bf6a3..28446f7c8 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/NodeDataPushListener.java @@ -3,6 +3,7 @@ package com.logpm.factorydata.linsy.mq; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.EnumUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpUtil; @@ -83,6 +84,8 @@ public class NodeDataPushListener { JSONObject entries = JSONUtil.parseObj(msg); // 节点 String node = entries.getStr("node"); + + WorkNodeEnums workNodeEnums = EnumUtil.fromString(WorkNodeEnums.class, node); // 2 获取业务数据 List content = entries.getBeanList("content", PushData.class); @@ -107,6 +110,42 @@ public class NodeDataPushListener { List list = factoryNodePushService.list(Wrappers.lambdaQuery() .in(FactoryNodePushEntity::getBillCode, groupByOrder.keySet()) ); + // 开单 始发仓=目的仓 如果没有推送记录 则不处理 + if (NumberUtil.equals(workNodeEnums.getCode(), WorkNodeEnums.OPEN_ORDER.getCode())) { + log.info("开单节点--------"); + String main = entries.getStr("main"); + if (StrUtil.isNotEmpty(main)) { + JSONObject entries1 = JSONUtil.parseObj(main); + String departureWarehouseName = entries1.getStr("departureWarehouseName"); + String destinationWarehouseName = entries1.getStr("destinationWarehouseName"); + if (StrUtil.isNotEmpty(destinationWarehouseName) && StrUtil.isNotEmpty(departureWarehouseName)) { + if (StrUtil.equals(departureWarehouseName, destinationWarehouseName)) { + if (CollUtil.isEmpty(list)) { + log.info("始发仓=目的仓,无推送记录,不处理:{},{}", departureWarehouseName, destinationWarehouseName); + return; + } else { + // 让包件齐套,推送收货 + for (Map.Entry> entry : packageInfoMap.entrySet()) { + List value = entry.getValue(); + for (PackageInfoEntity infoEntity : value) { + infoEntity.setWorkedNodeCode(FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode()); + } + } + } + } else { + log.info("开单节点--------始发仓!=目的仓 不处理"); + return; + } + } else { + log.info("开单节点--------没有始发仓和目的仓 不处理"); + return; + } + } else { + log.info("开单节点--------没有main"); + return; + } + } + // 已经推过的最大的节点 Map maxNodeMap = new HashMap<>(); if (CollUtil.isNotEmpty(list)) { list.forEach(factoryNodePushEntity -> { @@ -127,7 +166,7 @@ public class NodeDataPushListener { List updateList = new ArrayList<>(); for (Map.Entry> entry : groupByOrder.entrySet()) { String orderCode = entry.getKey(); - Integer code = workNodeEnums.getCode(); + Integer code = NodeMappingEnums.getFactoryByNodeAndStatus(workNodeEnums).getCode(); // 当前的节点小于已经推送的最大节点,则跳过 Integer maxCode = 0; if (maxNodeMap.containsKey(orderCode)) { @@ -149,6 +188,7 @@ public class NodeDataPushListener { .filter(packageInfoEntity -> packageInfoEntity.getWorkedNodeCode() < code) .collect(Collectors.toList()); FactoryNodeEnums factoryByNodeAndStatus = NodeMappingEnums.getFactoryByNodeAndStatus(workNodeEnums); + // 入库时 始发仓=目的仓。 同时推送交接和收货 if (CollUtil.isEmpty(workerList)) { // 齐套 推送工厂 // 6 必传的节点中 必须大于 maxCode 并且 小于当前节点编码 并且 数值最小的一条数据 @@ -174,39 +214,39 @@ public class NodeDataPushListener { factoryDataClient.sendMessage(sendMsg); } // 推送工厂 - JSONObject sendObj = new JSONObject(); - sendObj.set("billCode", billCode); - sendObj.set("status", factoryByNodeAndStatus.getText()); - sendObj.set("packages", entities.stream().map(packageInfoEntity -> { - JSONObject jsonObject = new JSONObject(); - jsonObject.set("barcode", packageInfoEntity.getBarcode()); - return jsonObject; - }).collect(Collectors.toList())); - log.info("推送工厂:{}", JSONUtil.toJsonStr(sendObj)); - String url = linsyProperties.getHost() + linsyProperties.getPushNodeUrl(); - try { - if (linsyProperties.getEnable()) { - String result = HttpUtil.post(url, JSONUtil.toJsonStr(sendObj)); - log.info("推送工厂结果:{}", result); - // 保存推送记录 - factoryNodePushService.save(FactoryNodePushEntity.builder() - .billCode(orderCode) - .node(factoryByNodeAndStatus.getCode().toString()) - .content(JSONUtil.toJsonStr(sendObj)) - .resultContent(result) - .build()); + sendFactory(billCode, factoryByNodeAndStatus, entities, orderCode); + // 始发仓入库 始发仓= 目的仓,推送交接和入库 + if (ObjectUtil.equal(workNodeEnums, WorkNodeEnums.INITIAL_WAREHOUSE_ENTRY)) { + String main = entries.getStr("main"); + if (StrUtil.isNotEmpty(main)) { + JSONObject entries1 = JSONUtil.parseObj(main); + String departureWarehouseName = entries1.getStr("departureWarehouseName"); + String destinationWarehouseName = entries1.getStr("destinationWarehouseName"); + if (StrUtil.isNotEmpty(destinationWarehouseName) && StrUtil.isNotEmpty(departureWarehouseName)) { + if (StrUtil.equals(departureWarehouseName, destinationWarehouseName)) { + sendFactory(billCode, FactoryNodeEnums.END_WAREHOUSE_UNLOADING, entities, orderCode); + updateList.addAll(entities.stream() + .filter(data -> collect.contains(data.getBarcode())) + .map(packageInfoEntity -> { + PackageInfoEntity entity = new PackageInfoEntity(); + entity.setId(packageInfoEntity.getId()); + entity.setWorkedNodeCode(FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode()); + return entity; + }) + .collect(Collectors.toList())); + } + } } - } catch (Exception e) { - log.error("推送工厂失败:{}", e); } } // 封装需要修改作业节点状态的数据 + FactoryNodeEnums finalFactoryByNodeAndStatus = factoryByNodeAndStatus; updateList.addAll(entities.stream() .filter(data -> collect.contains(data.getBarcode())) .map(packageInfoEntity -> { PackageInfoEntity entity = new PackageInfoEntity(); entity.setId(packageInfoEntity.getId()); - entity.setWorkedNodeCode(workNodeEnums.getCode()); + entity.setWorkedNodeCode(finalFactoryByNodeAndStatus.getCode()); return entity; }) .collect(Collectors.toList())); @@ -218,6 +258,34 @@ public class NodeDataPushListener { } } + private void sendFactory(String billCode, FactoryNodeEnums factoryByNodeAndStatus, List entities, String orderCode) { + JSONObject sendObj = new JSONObject(); + sendObj.set("billCode", billCode); + sendObj.set("status", factoryByNodeAndStatus.getText()); + sendObj.set("packages", entities.stream().map(packageInfoEntity -> { + JSONObject jsonObject = new JSONObject(); + jsonObject.set("barcode", packageInfoEntity.getBarcode()); + return jsonObject; + }).collect(Collectors.toList())); + log.info("推送工厂:{}", JSONUtil.toJsonStr(sendObj)); + String url = linsyProperties.getHost() + linsyProperties.getPushNodeUrl(); + try { + if (linsyProperties.getEnable()) { + String result = HttpUtil.post(url, JSONUtil.toJsonStr(sendObj)); + log.info("推送工厂结果:{}", result); + // 保存推送记录 + factoryNodePushService.save(FactoryNodePushEntity.builder() + .billCode(orderCode) + .node(factoryByNodeAndStatus.getCode().toString()) + .content(JSONUtil.toJsonStr(sendObj)) + .resultContent(result) + .build()); + } + } catch (Exception e) { + log.error("推送工厂失败:{}", e); + } + } + private boolean checkData(String msg) { if (StrUtil.isEmpty(msg)) { return true; diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/CustomPushService.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/CustomPushService.java new file mode 100644 index 000000000..8143b2c3b --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/CustomPushService.java @@ -0,0 +1,14 @@ +package com.logpm.factorydata.linsy.service; + +import com.logpm.factorydata.linsy.entity.CustomPushEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * 自定义回传 服务类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +public interface CustomPushService extends BaseService { + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/CustomPushServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/CustomPushServiceImpl.java new file mode 100644 index 000000000..852660f52 --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/CustomPushServiceImpl.java @@ -0,0 +1,22 @@ +package com.logpm.factorydata.linsy.service.impl; + +import com.logpm.factorydata.linsy.entity.CustomPushEntity; +import com.logpm.factorydata.linsy.mapper.CustomPushMapper; +import com.logpm.factorydata.linsy.service.CustomPushService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 自定义回传 业务实现类 + * + * @Author zqb + * @Date 2024/4/26 + **/ +@Slf4j +@Service +@AllArgsConstructor +public class CustomPushServiceImpl extends BaseServiceImpl implements CustomPushService { + +}