Browse Source

feat(all): 修改金牌回推逻辑

1 增加末端仓卸车扫描回推工厂逻辑
visual
zhaoqiaobo 5 months ago
parent
commit
598da2e909
  1. 151
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/NodeDataPushListener.java

151
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/NodeDataPushListener.java

@ -97,13 +97,17 @@ public class NodeDataPushListener {
if (NodeNeedEnums.UNLOAD_INCOMING_WAREHOUSE.getCode().equals(workNodeEnums.getCode())) {
content = content.stream().filter(item -> ObjectUtil.equal(item.getWarehouseName(), item.getDestinationWarehouse())).collect(Collectors.toList());
}
// 按订单分组
Map<String, List<PushData>> orderGroup = content.stream().collect(Collectors.groupingBy(PushData::getOrderCode));
// 查询出本次操作的所有订单
Set<String> orderCodes = content.stream().map(PushData::getOrderCode).collect(Collectors.toSet());
if (CollUtil.isEmpty(orderCodes)) {
log.info("订单数据为空,不处理:{}", JSONUtil.toJsonStr(content));
return;
}
for (String sendOrderCode : orderCodes) {
for (Map.Entry<String, List<PushData>> stringListEntry : orderGroup.entrySet()) {
String sendOrderCode = stringListEntry.getKey();
List<PushData> values = stringListEntry.getValue();
// 先从新系统查,如果查不到,去老系统查一次
List<PushOrderDetailEntity> orderDetailEntities = null;
// List<PushOrderDetailEntity> orderDetailEntities = pushOrderDetailService.list(Wrappers.<PushOrderDetailEntity>lambdaQuery()
@ -141,19 +145,21 @@ public class NodeDataPushListener {
}
// 订单 warehouse 不为空为干线,否则为仓配,推送干线的同时回推仓配
// Map<String, String> orderCodeMap = orderDetailEntities.stream().collect(Collectors.toMap(PushOrderDetailEntity::getOrderId, PushOrderDetailEntity::getCustomItemNo));
Map<String, PushOrderDetailEntity> detailEntityMap = orderDetailEntities.stream().collect(Collectors.toMap(PushOrderDetailEntity::getCustomItemNo, v -> v));
// Map<String, PushOrderDetailEntity> detailEntityMap = orderDetailEntities.stream().collect(Collectors.toMap(PushOrderDetailEntity::getCustomItemNo, v -> v));
Map<String, List<PushOrderDetailEntity>> detailEntityMap = orderDetailEntities.stream()
.collect(Collectors.groupingBy(PushOrderDetailEntity::getCustomItemNo));
// List<String> orderIds = orderDetailEntities.stream().map(PushOrderDetailEntity::getOrderId).collect(Collectors.toList());
// Map<String, PushOrderEntity> pushOrderEntityMap = new HashMap<>();
// if (CollUtil.isNotEmpty(orderIds)) {
// List<PushOrderEntity> pushOrderEntities = pushOrderService.listByIds(orderIds);
// if (CollUtil.isNotEmpty(pushOrderEntities)) {
// pushOrderEntities.forEach(pushOrderEntity -> {
// pushOrderEntityMap.put(orderCodeMap.get(pushOrderEntity.getId().toString()), pushOrderEntity);
// });
// }
// List<PushOrderEntity> pushOrderEntities = pushOrderService.listByIds(orderIds);
// if (CollUtil.isNotEmpty(pushOrderEntities)) {
// pushOrderEntities.forEach(pushOrderEntity -> {
// pushOrderEntityMap.put(orderCodeMap.get(pushOrderEntity.getId().toString()), pushOrderEntity);
// });
// }
// }
List<FactoryNodePushEntity> pushEntities = factoryNodePushService.list(Wrappers.<FactoryNodePushEntity>lambdaQuery()
.in(FactoryNodePushEntity::getOrderCode, orderCodes)
.eq(FactoryNodePushEntity::getOrderCode, sendOrderCode)
);
// 到站还是入库
@ -167,67 +173,67 @@ public class NodeDataPushListener {
JSONObject mainJson = JSONUtil.parseObj(main);
// 到站 一个订单只发送一次
// for (String orderCode : orderCodes) {
if (pushEntityMap.containsKey(sendOrderCode)) {
continue;
}
String arriveFor = "carrier";
// PushOrderEntity pushOrderEntity = pushOrderEntityMap.get(orderCode);
if (ObjectUtil.isNotEmpty(pushOrderEntity) && StrUtil.isNotEmpty(pushOrderEntity.getWarehouse())) {
arriveFor = "stock";
}
PushOrderDetailEntity pushOrderDetailEntity = detailEntityMap.get(sendOrderCode);
String boxCodeList = pushOrderDetailEntity.getBoxCodeList();
JSONArray boxCodeListJson = JSONUtil.parseArray(boxCodeList);
// JSONArray details = new JSONArray();
JSONObject detail = new JSONObject();
boxCodeListJson.forEach(item -> {
// JSONObject jsonObject = new JSONObject();
detail.set(item.toString(), 1);
// details.add(jsonObject);
});
if (!CollUtil.contains(pushEntityMap.keySet(), sendOrderCode)) {
JSONObject js = new JSONObject();
js.set("extOrderNo", sendOrderCode);
js.set("extWaybillNO", mainJson.getStr("serviceNumber"));
js.set("detail", detail);
// js.set("shipNo", mainJson.getStr("waybillNumber"));
js.set("shipNo", pushOrderDetailEntity.getShipNo());
js.set("targetNo", pushOrderEntity.getTransportNo());
js.set("targetType", 1);
js.set("doType", 32);
js.set("doLocation", "");
js.set("doTime", DateUtil.now());
js.set("sendSite", mainJson.getStr("sendWarehouseName"));
js.set("endSite", mainJson.getStr("warehouseName"));
js.set("passSite", mainJson.getStr("acceptWarehouseName"));
js.set("doRemark", "");
js.set("reqSn", (RandomUtil.randomLong(100000000000000000L,999999999999999999L)) +"");
js.set("syscode", "huitong");
js.set("carNo", mainJson.getStr("carNumber"));
js.set("carHangNo", "");
js.set("driverName", mainJson.getStr("driverName"));
js.set("driverPhone", mainJson.getStr("driverMobile"));
js.set("carType", "A");
js.set("carSize", "1");
js.set("arriveFor", arriveFor);
log.info("推送工厂:{}", js);
String url = jinPaiProperties.getOldSystemHost() + jinPaiProperties.getOldSystemArrivedUrl();
try {
if (jinPaiProperties.getEnable()) {
String result = HttpUtil.post(url, JSONUtil.toJsonStr(js));
log.info("推送工厂结果:{}", result);
// 保存推送记录
factoryNodePushService.save(FactoryNodePushEntity.builder()
.orderCode(sendOrderCode)
.node(FactoryNodeEnums.FINAL_NET_ARRIVE_CAR.getCode().toString())
.content(JSONUtil.toJsonStr(js))
.resultContent(result)
.build());
}
} catch (Exception e) {
log.error("推送工厂失败:{}", e);
if (pushEntityMap.containsKey(sendOrderCode)) {
continue;
}
String arriveFor = "carrier";
// PushOrderEntity pushOrderEntity = pushOrderEntityMap.get(orderCode);
if (ObjectUtil.isNotEmpty(pushOrderEntity) && StrUtil.isNotEmpty(pushOrderEntity.getWarehouse())) {
arriveFor = "stock";
}
PushOrderDetailEntity pushOrderDetailEntity = detailEntityMap.get(sendOrderCode).get(0);
String boxCodeList = pushOrderDetailEntity.getBoxCodeList();
JSONArray boxCodeListJson = JSONUtil.parseArray(boxCodeList);
// JSONArray details = new JSONArray();
JSONObject detail = new JSONObject();
boxCodeListJson.forEach(item -> {
// JSONObject jsonObject = new JSONObject();
detail.set(item.toString(), 1);
// details.add(jsonObject);
});
if (!CollUtil.contains(pushEntityMap.keySet(), sendOrderCode)) {
JSONObject js = new JSONObject();
js.set("extOrderNo", sendOrderCode);
js.set("extWaybillNO", mainJson.getStr("serviceNumber"));
js.set("detail", detail);
// js.set("shipNo", mainJson.getStr("waybillNumber"));
js.set("shipNo", pushOrderDetailEntity.getShipNo());
js.set("targetNo", pushOrderEntity.getTransportNo());
js.set("targetType", 1);
js.set("doType", 32);
js.set("doLocation", "");
js.set("doTime", DateUtil.now());
js.set("sendSite", mainJson.getStr("sendWarehouseName"));
js.set("endSite", mainJson.getStr("warehouseName"));
js.set("passSite", mainJson.getStr("acceptWarehouseName"));
js.set("doRemark", "");
js.set("reqSn", (RandomUtil.randomLong(100000000000000000L, 999999999999999999L)) + "");
js.set("syscode", "huitong");
js.set("carNo", mainJson.getStr("carNumber"));
js.set("carHangNo", "");
js.set("driverName", mainJson.getStr("driverName"));
js.set("driverPhone", mainJson.getStr("driverMobile"));
js.set("carType", "A");
js.set("carSize", "1");
js.set("arriveFor", arriveFor);
log.info("推送工厂:{}", js);
String url = jinPaiProperties.getOldSystemHost() + jinPaiProperties.getOldSystemArrivedUrl();
try {
if (jinPaiProperties.getEnable()) {
String result = HttpUtil.post(url, JSONUtil.toJsonStr(js));
log.info("推送工厂结果:{}", result);
// 保存推送记录
factoryNodePushService.save(FactoryNodePushEntity.builder()
.orderCode(sendOrderCode)
.node(FactoryNodeEnums.FINAL_NET_ARRIVE_CAR.getCode().toString())
.content(JSONUtil.toJsonStr(js))
.resultContent(result)
.build());
}
} catch (Exception e) {
log.error("推送工厂失败:{}", e);
}
}
// }
} else {
// 入库一个包件一次
@ -237,8 +243,9 @@ public class NodeDataPushListener {
return StrUtil.equals(pushEntity.getNode(), FactoryNodeEnums.END_WAREHOUSE_UNLOADING.getCode().toString());
}).collect(Collectors.toMap(FactoryNodePushEntity::getPackageCode, v -> v));
}
for (PushData pushData : content) {
for (PushData pushData : values) {
if (!CollUtil.contains(pushEntityMap.keySet(), pushData.getPackageCode())) {
String arriveFor = "stock";
// PushOrderEntity pushOrderEntity = pushOrderEntityMap.get(pushData.getOrderCode());
if (StrUtil.isEmpty(pushOrderEntity.getWarehouse())) {
@ -246,18 +253,18 @@ public class NodeDataPushListener {
}
JSONObject js = new JSONObject();
js.set("extOrderNo", pushData.getOrderCode());
js.set("extWaybillNO", detailEntityMap.get(pushData.getOrderCode()).getCustomOrderNo());
js.set("extWaybillNO", detailEntityMap.get(pushData.getOrderCode()).get(0).getCustomOrderNo());
// js.set("transportNo", pushOrderEntityMap.get(pushData.getOrderCode()).getTransportNo());
js.set("transportNo", pushOrderEntity.getTransportNo());
js.set("doTime", entries.getStr("operatorTime"));
js.set("syscode", "huitong");
js.set("reqSn", (RandomUtil.randomLong(100000000000000000L,999999999999999999L)) +"");
js.set("reqSn", (RandomUtil.randomLong(100000000000000000L, 999999999999999999L)) + "");
// js.set("reqSn", detailEntityMap.get(pushData.getOrderCode()).getShipNo());
js.set("arriveFor", arriveFor);
JSONObject detailJson = new JSONObject();
detailJson.set(pushData.getPackageCode(), 1);
js.set("detail", detailJson);
js.set("shipNo", detailEntityMap.get(pushData.getOrderCode()).getShipNo());
js.set("shipNo", detailEntityMap.get(pushData.getOrderCode()).get(0).getShipNo());
log.info("推送工厂:{}", js);
String url = jinPaiProperties.getOldSystemHost() + jinPaiProperties.getOldSystemAlreadyStockedUrl();
try {

Loading…
Cancel
Save