Browse Source

feat(all): 增加金牌干线回推逻辑

master
zhaoqiaobo 9 months ago
parent
commit
0f5071b0cb
  1. 79
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/FactoryNodePushEntity.java
  2. 52
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/FactoryNodeEnums.java
  3. 63
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/NodeMappingEnums.java
  4. 34
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/NodeNeedEnums.java
  5. 16
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/FactoryNodePushMapper.java
  6. 5
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/FactoryNodePushMapper.xml
  7. 261
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mq/NodeDataPushListener.java
  8. 65
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/pros/JinPaiProperties.java
  9. 14
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/FactoryNodePushService.java
  10. 22
      blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/FactoryNodePushServiceImpl.java
  11. 53
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

79
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/entity/FactoryNodePushEntity.java

@ -0,0 +1,79 @@
package com.logpm.factorydata.jinpai.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springblade.core.mp.base.BaseEntity;
/**
* 节点数据推送成功数据
*
* @Author zqb
* @Date 2024/3/26
**/
@Builder
@Data
@TableName("jinpai_factory_node_push")
@ApiModel(value = "节点数据推送成功数据", description = "节点数据推送成功数据")
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class FactoryNodePushEntity extends BaseEntity {
/**
* 预留1
*/
@ApiModelProperty(name = "预留1", notes = "")
private String reserve1;
/**
* 预留2
*/
@ApiModelProperty(name = "预留2", notes = "")
private String reserve2;
/**
* 预留3
*/
@ApiModelProperty(name = "预留3", notes = "")
private String reserve3;
/**
* 预留4
*/
@ApiModelProperty(name = "预留4", notes = "")
private String reserve4;
/**
* 预留5
*/
@ApiModelProperty(name = "预留5", notes = "")
private String reserve5;
/**
* 订单号
*/
@ApiModelProperty(name = "订单号", notes = "")
private String orderCode;
/**
* 节点
*/
@ApiModelProperty(name = "节点", notes = "")
private String node;
/**
* 包件
*/
@ApiModelProperty(name = "包件", notes = "")
private String packageCode;
/**
* 内容
*/
@ApiModelProperty(name = "内容", notes = "")
private String content;
/**
* 返回值
*/
@ApiModelProperty(name = "返回值", notes = "")
private String resultContent;
}

52
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/FactoryNodeEnums.java

@ -0,0 +1,52 @@
package com.logpm.factorydata.jinpai.enums;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
/**
* 工厂节点枚举
*
* @author zhaoqiaobo
* @create 2024-03-20 15:19
*/
@Getter
public enum FactoryNodeEnums {
/**
* 到达目的站
*/
FINAL_NET_ARRIVE_CAR(1030100,"到达目的站", 1),
/**
* 包件入库
*/
UNLOAD_INCOMING_WAREHOUSE(105010,"包件入库", 1)
;
private Integer code;
private String text;
private Integer mustPush;
FactoryNodeEnums(Integer code, String text, Integer mustPush) {
this.code = code;
this.text = text;
this.mustPush = mustPush;
}
/**
* 获取所有必推节点的编码
*
* @return
*/
public static List<Integer> getMustPushCode() {
List<Integer> list = new ArrayList<>();
for (FactoryNodeEnums value : FactoryNodeEnums.values()) {
if (value.getMustPush() == 1) {
list.add(value.getCode());
}
}
return list;
}
}

63
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/NodeMappingEnums.java

@ -0,0 +1,63 @@
package com.logpm.factorydata.jinpai.enums;
import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;
import org.springblade.common.constant.WorkNodeEnums;
/**
* 系统和工厂节点映射枚举
*
* @author zhaoqiaobo
* @create 2024-03-20 15:19
*/
@Getter
public enum NodeMappingEnums {
/**
* 到达目的站
*/
FINAL_NET_ARRIVE_CAR(FactoryNodeEnums.FINAL_NET_ARRIVE_CAR, WorkNodeEnums.FINAL_NET_ARRIVE_CAR, 1),
/**
* 包件入库
*/
UNLOAD_INCOMING_WAREHOUSE(FactoryNodeEnums.UNLOAD_INCOMING_WAREHOUSE, WorkNodeEnums.UNLOAD_INCOMING_WAREHOUSE, 1),
;
/**
* 系统作业节点
*/
private WorkNodeEnums workNodeEnums;
/**
* 工厂作业节点
*/
private FactoryNodeEnums factoryNodeEnums;
/**
* 状态码
* 存在我们系统同一个作业节点对应工厂多个节点的情况通过状态码区分
*/
private Integer status;
NodeMappingEnums(FactoryNodeEnums factoryNodeEnums, WorkNodeEnums workNodeEnums, Integer status) {
this.workNodeEnums = workNodeEnums;
this.factoryNodeEnums = factoryNodeEnums;
this.status = status;
}
public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums) {
return getFactoryByNodeAndStatus(workNodeEnums, 1);
}
public static FactoryNodeEnums getFactoryByNodeAndStatus(WorkNodeEnums workNodeEnums, Integer status) {
NodeMappingEnums[] values = values();
for (NodeMappingEnums value : values) {
WorkNodeEnums workNodeEnums1 = value.getWorkNodeEnums();
Integer status1 = value.getStatus();
FactoryNodeEnums factoryNodeEnums = value.getFactoryNodeEnums();
if (ObjectUtil.equal(workNodeEnums1, workNodeEnums) && ObjectUtil.equal(status1, status)) {
return factoryNodeEnums;
}
}
return null;
}
}

34
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/enums/NodeNeedEnums.java

@ -0,0 +1,34 @@
package com.logpm.factorydata.jinpai.enums;
import lombok.Getter;
import java.io.Serializable;
/**
* 作业节点枚举
*
* @author zhaoqiaobo
* @create 2024-03-20 15:19
*/
@Getter
public enum NodeNeedEnums implements Serializable {
/**
* 到达目的站
*/
FINAL_NET_ARRIVE_CAR(1030100,"到达目的站"),
/**
* 包件入库
*/
UNLOAD_INCOMING_WAREHOUSE(105010,"包件入库")
;
private Integer code;
private String value;
NodeNeedEnums(Integer code, String value) {
this.code = code;
this.value = value;
}
}

16
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/FactoryNodePushMapper.java

@ -0,0 +1,16 @@
package com.logpm.factorydata.jinpai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factorydata.jinpai.entity.FactoryNodePushEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 装箱包信息 mapper
*
* @author zqb
* @since 2024-03-26
*/
@Mapper
public interface FactoryNodePushMapper extends BaseMapper<FactoryNodePushEntity> {
}

5
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/mapper/FactoryNodePushMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.logpm.factorydata.jinpai.mapper.FactoryNodePushMapper">
</mapper>

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

@ -0,0 +1,261 @@
package com.logpm.factorydata.jinpai.mq;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.jinpai.entity.FactoryNodePushEntity;
import com.logpm.factorydata.jinpai.entity.PushOrderDetailEntity;
import com.logpm.factorydata.jinpai.entity.PushOrderEntity;
import com.logpm.factorydata.jinpai.enums.FactoryNodeEnums;
import com.logpm.factorydata.jinpai.enums.NodeNeedEnums;
import com.logpm.factorydata.jinpai.pros.JinPaiProperties;
import com.logpm.factorydata.jinpai.service.FactoryNodePushService;
import com.logpm.factorydata.jinpai.service.PushOrderDetailService;
import com.logpm.factorydata.jinpai.service.PushOrderService;
import com.logpm.factorydata.vo.PushData;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.WorkNodeEnums;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 监听业务系统推送给工厂的节点数据
*
* @author zhaoqiaobo
* @create 2024-03-18 0:02
*/
@Slf4j
@Component
@AllArgsConstructor
public class NodeDataPushListener {
private final IFactoryDataClient factoryDataClient;
private final PushOrderDetailService pushOrderDetailService;
private final PushOrderService pushOrderService;
private final FactoryNodePushService factoryNodePushService;
private final JinPaiProperties jinPaiProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FactoryDataConstants.Mq.Queues.JP_NODE_DATA_PUSH, durable = "true"),
exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH_DELAYED, type = ExchangeTypes.TOPIC
, delayed = FactoryDataConstants.Mq.DELAYED),
key = FactoryDataConstants.Mq.RoutingKeys.JP_NODE_DATA_PUSH
))
public void nodeDataPushDelayed(String msg) {
// 直接调用nodeDataPush方法处理接收到的消息
nodeDataPush(msg);
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FactoryDataConstants.Mq.Queues.JP_NODE_DATA_PUSH, durable = "true"),
exchange = @Exchange(name = FactoryDataConstants.Mq.Exchanges.NODE_DATA_PUSH, type = ExchangeTypes.TOPIC),
key = FactoryDataConstants.Mq.RoutingKeys.JP_NODE_DATA_PUSH
))
@Transactional(rollbackFor = Exception.class)
public void nodeDataPush(String msg) {
// {"brand":"ZBOM","node":"TRANSFER_WAREHOUSE_DEPART","operator":"","operatorTime":"","content":[{"packageCode":"1423090693445"}]}
log.info("接收到节点数据推送:{}", msg);
// 1 校验数据
if (checkData(msg)) {
return;
}
JSONObject entries = JSONUtil.parseObj(msg);
// 节点
String node = entries.getStr("node");
String main = entries.getStr("main");
WorkNodeEnums workNodeEnums = EnumUtil.fromString(WorkNodeEnums.class, node);
// 2 获取业务数据
List<PushData> content = entries.getBeanList("content", PushData.class);
// 数据按订单分组
// 3 拿到所有必推节点的code
List<Integer> mustPushCode = FactoryNodeEnums.getMustPushCode();
if (CollUtil.isNotEmpty(content)) {
// 查询出本次操作的所有订单
Set<String> orderCodes = content.stream().map(PushData::getOrderCode).collect(Collectors.toSet());
if (CollUtil.isEmpty(orderCodes)) {
log.info("订单数据为空,不处理:{}", JSONUtil.toJsonStr(content));
return;
}
List<PushOrderDetailEntity> orderDetailEntities = pushOrderDetailService.list(Wrappers.<PushOrderDetailEntity>lambdaQuery()
.in(PushOrderDetailEntity::getCustomItemNo, orderCodes)
);
if (CollUtil.isEmpty(orderDetailEntities)) {
log.info("未查到包件数据,不处理:{}", JSONUtil.toJsonStr(content));
return;
}
Map<Long, String> orderCodeMap = orderDetailEntities.stream().collect(Collectors.toMap(PushOrderDetailEntity::getId, PushOrderDetailEntity::getCustomItemNo));
Map<String, PushOrderDetailEntity> detailEntityMap = orderDetailEntities.stream().collect(Collectors.toMap(PushOrderDetailEntity::getCustomItemNo, v -> v));
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()), pushOrderEntity);
});
}
}
List<FactoryNodePushEntity> pushEntities = factoryNodePushService.list(Wrappers.<FactoryNodePushEntity>lambdaQuery()
.in(FactoryNodePushEntity::getOrderCode, orderCodes)
);
// 到站还是入库
if (workNodeEnums.equals(WorkNodeEnums.FINAL_NET_ARRIVE_CAR)) {
Map<String, FactoryNodePushEntity> pushEntityMap = new HashMap<>();
if (CollUtil.isNotEmpty(pushEntities)) {
pushEntityMap = pushEntities.stream().filter(pushEntity -> {
return pushEntity.getNode().equals(FactoryNodeEnums.FINAL_NET_ARRIVE_CAR.getCode());
}).collect(Collectors.toMap(FactoryNodePushEntity::getOrderCode, v -> v));
}
JSONObject mainJson = JSONUtil.parseObj(main);
// 到站 一个订单只发送一次
for (String orderCode : orderCodes) {
if (pushEntityMap.containsKey(orderCode)) {
continue;
}
PushOrderDetailEntity pushOrderDetailEntity = detailEntityMap.get(orderCode);
String boxCodeList = pushOrderDetailEntity.getBoxCodeList();
JSONArray boxCodeListJson = JSONUtil.parseArray(boxCodeList);
JSONArray details = new JSONArray();
boxCodeListJson.forEach(item -> {
JSONObject jsonObject = new JSONObject();
jsonObject.set(item.toString(), 1);
details.add(jsonObject);
});
if (!CollUtil.contains(pushEntityMap.keySet(), orderCode)) {
JSONObject js = new JSONObject();
js.set("extOrderNo", orderCode);
js.set("extWaybillNO", mainJson.getStr("serviceNumber"));
js.set("detail", details);
js.set("shipNo", mainJson.getStr("waybillNumber"));
js.set("targetNo", pushOrderEntityMap.get(orderCode).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", pushOrderEntityMap.get(orderCode).getId());
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", "");
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(orderCode)
.node(FactoryNodeEnums.FINAL_NET_ARRIVE_CAR.getCode().toString())
.content(JSONUtil.toJsonStr(js))
.resultContent(result)
.build());
}
} catch (Exception e) {
log.error("推送工厂失败:{}", e);
}
}
}
} else {
// 入库一个包件一次
Map<String, FactoryNodePushEntity> pushEntityMap = new HashMap<>();
if (CollUtil.isNotEmpty(pushEntities)) {
pushEntityMap = pushEntities.stream().filter(pushEntity -> {
return pushEntity.getNode().equals(FactoryNodeEnums.UNLOAD_INCOMING_WAREHOUSE.getCode());
}).collect(Collectors.toMap(FactoryNodePushEntity::getPackageCode, v -> v));
}
for (PushData pushData : content) {
if (!CollUtil.contains(pushEntityMap.keySet(), pushData.getPackageCode())) {
JSONObject js = new JSONObject();
js.set("extOrderNo", pushData.getOrderCode());
js.set("extWaybillNO", detailEntityMap.get(pushData.getOrderCode()).getCustomOrderNo());
js.set("transportNo", pushOrderEntityMap.get(pushData.getOrderCode()).getTransportNo());
js.set("doTime", entries.getStr("operatorTime"));
js.set("syscode", "huitong");
js.set("reqSn", UUID.randomUUID());
// js.set("arriveFor", "");
JSONObject detailJson = new JSONObject();
detailJson.set(pushData.getPackageCode(), 1);
js.set("detail", detailJson.toString());
js.set("shipNo", pushData.getWaybillNumber());
log.info("推送工厂:{}", js);
String url = jinPaiProperties.getOldSystemHost() + jinPaiProperties.getOldSystemAlreadyStockedUrl();
try {
if (jinPaiProperties.getEnable()) {
String result = HttpUtil.post(url, JSONUtil.toJsonStr(js));
log.info("推送工厂结果:{}", result);
// 保存推送记录
factoryNodePushService.save(FactoryNodePushEntity.builder()
.orderCode(pushData.getOrderCode())
.node(FactoryNodeEnums.UNLOAD_INCOMING_WAREHOUSE.getCode().toString())
.content(JSONUtil.toJsonStr(js))
.resultContent(result)
.build());
}
} catch (Exception e) {
log.error("推送工厂失败:{}", e);
}
}
}
}
}
}
private boolean checkData(String msg) {
if (StrUtil.isEmpty(msg)) {
return true;
}
if (!msg.contains("brand") || !msg.contains("content") || !msg.contains("node")) {
return true;
}
JSONObject entries = JSONUtil.parseObj(msg);
String node = entries.getStr("node");
if (StrUtil.isEmpty(node)) {
return true;
}
// 不是志邦需要的节点数据直接不处理
if (!EnumUtil.contains(NodeNeedEnums.class, node)) {
return true;
}
WorkNodeEnums workNodeEnums = EnumUtil.fromString(WorkNodeEnums.class, node);
if (ObjectUtil.isEmpty(workNodeEnums)) {
return true;
}
List<JSONObject> content = entries.getBeanList("content", JSONObject.class);
if (CollUtil.isEmpty(content)) {
return true;
}
return false;
}
}

65
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/pros/JinPaiProperties.java

@ -0,0 +1,65 @@
package com.logpm.factorydata.jinpai.pros;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* FactoryProperties
*
* @author pref
*/
@Data
@ConfigurationProperties(prefix = "jinpai")
@Component
public class JinPaiProperties {
/**
* 金牌工厂推送节点数据url
*/
private String pushNodeUrl;
/**
* 是否推送工厂
*/
private Boolean enable = true;
/**
* 金牌工厂主机地址
*/
private String host;
/**
* 承运商编码
*/
private String carrierCode;
/**
* 补节点数据时的延时时间分钟
*/
private Integer delayedTime = 30;
/**
* 生成老系统暂存单
*/
private Boolean oldAdvance = false;
/**
* 生成新系统暂存单
*/
private Boolean newAdvance = false;
/**
* 老系统host
*/
private String oldSystemHost;
/**
* 老系统回传到达url
*/
private String oldSystemArrivedUrl;
/**
* 老系统回传入库url
*/
private String oldSystemAlreadyStockedUrl;
}

14
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/FactoryNodePushService.java

@ -0,0 +1,14 @@
package com.logpm.factorydata.jinpai.service;
import com.logpm.factorydata.jinpai.entity.FactoryNodePushEntity;
import org.springblade.core.mp.base.BaseService;
/**
* 推送工厂节点数据 服务类
*
* @Author zqb
* @Date 2024/4/26
**/
public interface FactoryNodePushService extends BaseService<FactoryNodePushEntity> {
}

22
blade-service/logpm-factory-data/logpm-factory-data-jinpai/src/main/java/com/logpm/factorydata/jinpai/service/impl/FactoryNodePushServiceImpl.java

@ -0,0 +1,22 @@
package com.logpm.factorydata.jinpai.service.impl;
import com.logpm.factorydata.jinpai.entity.FactoryNodePushEntity;
import com.logpm.factorydata.jinpai.mapper.FactoryNodePushMapper;
import com.logpm.factorydata.jinpai.service.FactoryNodePushService;
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 FactoryNodePushServiceImpl extends BaseServiceImpl<FactoryNodePushMapper, FactoryNodePushEntity> implements FactoryNodePushService {
}

53
blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

@ -541,17 +541,16 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
nextCarsLoadLineEntity.setArriveUserId(AuthUtil.getUserId());
nextCarsLoadLineEntity.setArriveUserName(AuthUtil.getNickName());
trunklineCarsLoadLineService.updateById(nextCarsLoadLineEntity);
Integer workNode = null;
WorkNodeEnums workNodeEnums = WorkNodeEnums.NET_ARRIVE_CAR;
if (!nodeId.equals(endNodeId)) {
carsLoadEntity.setLoadStatus("20");
carsLoadEntity.setArriveTime(date);
carsLoadEntity.setNowWarehouseId(warehouseId);
workNode = WorkNodeEnums.NET_ARRIVE_CAR.getCode();
} else {
carsLoadEntity.setLoadStatus("40");
carsLoadEntity.setArriveTime(date);
carsLoadEntity.setNowWarehouseId(warehouseId);
workNode = WorkNodeEnums.FINAL_NET_ARRIVE_CAR.getCode();
workNodeEnums = WorkNodeEnums.FINAL_NET_ARRIVE_CAR;
}
updateById(carsLoadEntity);
@ -568,12 +567,55 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
List<String> orderPackageCodes = trunklineCarsLoadScanService.findPackageListByLoadId(loadId);
String content = "包件在 " + warehouseEntity.getName() + "到车";
packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, warehouseEntity.getName(), workNode, content);
packageTrackLogAsyncService.addPackageTrackLog(AuthUtil.getTenantId(), AuthUtil.getUserId(), Func.firstLong(AuthUtil.getDeptId()), AuthUtil.getNickName(), orderPackageCodes, warehouseId, warehouseEntity.getName(), workNodeEnums.getCode(), content);
try {
FindParamterDTO param = new FindParamterDTO();
param.setWarehouseId(warehouseId);
param.setOrderPackageCodeList(orderPackageCodes);
List<DistributionParcelListEntity> listByOrderPackageCodeList = distributionParcelListClient.findListByOrderPackageCodeList(param);
Map<Long, List<DistributionParcelListEntity>> map = listByOrderPackageCodeList.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getStockArticleId));
JSONObject js = new JSONObject();
js.put("carNumber", carsLoadEntity.getCarNumber());
js.put("driverName", carsLoadEntity.getDriverName());
js.put("driverMobile", carsLoadEntity.getDriverMobile());
for (Map.Entry<Long, List<DistributionParcelListEntity>> entry : map.entrySet()) {
List<DistributionParcelListEntity> value = entry.getValue();
DistributionParcelListEntity parcelListEntity = value.get(0);
js.put("orderCode", parcelListEntity.getOrderCode());
js.put("serviceNumber", parcelListEntity.getServiceNumber());
js.put("waybillNumber", parcelListEntity.getWaybillNumber());
js.put("sendWarehouseName", parcelListEntity.getSendWarehouseName());
js.put("acceptWarehouseName", parcelListEntity.getAcceptWarehouseName());
// 分割字符串得到仓库名称列表
List<String> warehouseNames = StrUtil.split(carsLoadEntity.getEndWarehouseNames(), ",");
// 获取最后一个仓库名称
String lastWarehouseName = CollUtil.isNotEmpty(warehouseNames) ? warehouseNames.get(warehouseNames.size() - 1): "";
// 将最后一个仓库名称放入js对象
js.put("warehouseName", lastWarehouseName);
NodePushMsg msg = new NodePushMsg();
msg.setNode(workNodeEnums);
msg.setBrand(BrandEnums.getByValue(parcelListEntity.getBrandName()));
msg.setOperator(AuthUtil.getNickName());
msg.setOperatorTime(new Date());
msg.setMain(js.toString());
msg.setContent(value.stream().map(item -> {
return PushData.builder()
.packageCode(item.getOrderPackageCode())
.orderCode(item.getOrderCode())
.warehouseName(warehouseEntity.getName())
.waybillNumber(item.getWaybillNumber()).build();
}).collect(Collectors.toList()));
log.info("推送工厂数据:{}", JSONUtil.toJsonStr(msg));
factoryDataMessageSender.sendNodeDataByBrand(msg);
}
} catch (Exception e){
log.warn("推送工厂失败:{}", e);
}
} catch (Exception e) {
log.warn("#############arriveCarByLoadId: 存入日志失败");
}
}
@Override
@ -4143,6 +4185,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
.content(Collections.singletonList(PushData.builder()
.packageCode(entity.getOrderPackageCode())
.warehouseName(warehouseName)
.waybillNumber(entity.getWaybillNumber())
.orderCode(entity.getOrderCode())
.build()))
.build();

Loading…
Cancel
Save