|
|
|
@ -50,11 +50,14 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 监听志邦订单数据 |
|
|
|
@ -81,7 +84,7 @@ public class ZbomFactoryOrderListener {
|
|
|
|
|
key = FactoryDataConstants.Mq.RoutingKeys.ZBOM_FACTORY_ORDER |
|
|
|
|
)) |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public void factoryOrder(String msg) { |
|
|
|
|
public void factoryOrder(String msg, Set<String> packageCodeSet) { |
|
|
|
|
if (StrUtil.isEmpty(msg)) { |
|
|
|
|
log.error("消息内容为空"); |
|
|
|
|
return; |
|
|
|
@ -101,15 +104,34 @@ public class ZbomFactoryOrderListener {
|
|
|
|
|
log.error("入库单号已推送过了"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 查询当前这次推送的数据中的所有包件,校验其是否在数据库中已存在,存在则不保存
|
|
|
|
|
Set<String> packageCode = new HashSet<>(); |
|
|
|
|
List<OrderPackageDTO> details = zbReceiptDTO.getDetails(); |
|
|
|
|
if (CollUtil.isNotEmpty(details)) { |
|
|
|
|
// 收集包件编码
|
|
|
|
|
List<String> collect = details.stream().map(OrderPackageDTO::getPackageCode).collect(Collectors.toList()); |
|
|
|
|
if (CollUtil.isNotEmpty(collect)) { |
|
|
|
|
List<OrderPackageDTO> packageCodes = orderPackageService.findByPackageCodes(collect); |
|
|
|
|
if (CollUtil.isNotEmpty(packageCodes)) { |
|
|
|
|
// 将packageCodes中的数据存到packageCode中
|
|
|
|
|
packageCodes.forEach(item -> { |
|
|
|
|
packageCode.add(item.getPackageCode()); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ZbReceiptEntity zbReceiptEntity = new ZbReceiptEntity(); |
|
|
|
|
BeanUtil.copyProperties(zbReceiptDTO, zbReceiptEntity); |
|
|
|
|
// 保存订单数据
|
|
|
|
|
receiptService.save(zbReceiptEntity); |
|
|
|
|
List<OrderPackageDTO> details = zbReceiptDTO.getDetails(); |
|
|
|
|
if (CollUtil.isNotEmpty(details)) { |
|
|
|
|
List<ZbOrderPackageEntity> packageEntities = new ArrayList<>(); |
|
|
|
|
List<ZbPackageInfoEntity> packageInfoEntities = new ArrayList<>(); |
|
|
|
|
for (OrderPackageDTO detail : details) { |
|
|
|
|
if (packageCode.contains(detail.getPackageCode())) { |
|
|
|
|
log.info(" 接收志邦数据:包条码 {} 已存在数据库中,不保存。", detail.getPackageCode()); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
ZbOrderPackageEntity packageEntity = new ZbOrderPackageEntity(); |
|
|
|
|
BeanUtil.copyProperties(detail, packageEntity); |
|
|
|
|
packageEntity.setReceiptId(zbReceiptEntity.getId()); |
|
|
|
@ -118,6 +140,9 @@ public class ZbomFactoryOrderListener {
|
|
|
|
|
// 保存包件数据
|
|
|
|
|
orderPackageService.saveBatch(packageEntities); |
|
|
|
|
for (OrderPackageDTO detail : details) { |
|
|
|
|
if (packageCode.contains(detail.getPackageCode())) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Long detailId = null; |
|
|
|
|
for (ZbOrderPackageEntity packageEntity : packageEntities) { |
|
|
|
|
if (ObjectUtil.equal(packageEntity.getPackageCode(), detail.getPackageCode())) { |
|
|
|
@ -138,10 +163,10 @@ public class ZbomFactoryOrderListener {
|
|
|
|
|
packageInfoService.saveBatch(packageInfoEntities); |
|
|
|
|
} |
|
|
|
|
// 处理暂存单
|
|
|
|
|
buildAdvance(zbReceiptDTO); |
|
|
|
|
buildAdvance(zbReceiptDTO, packageCode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void buildAdvance(ZBReceiptDTO zbReceiptDTO) { |
|
|
|
|
private void buildAdvance(ZBReceiptDTO zbReceiptDTO, Set packageCode) { |
|
|
|
|
// 新起线程构建暂存单发送mq
|
|
|
|
|
ThreadPoolUtil.getThreadPool().submit(() -> { |
|
|
|
|
Long startWarehouseId = null; |
|
|
|
@ -161,6 +186,10 @@ public class ZbomFactoryOrderListener {
|
|
|
|
|
List<OrderPackageDTO> details = zbReceiptDTO.getDetails(); |
|
|
|
|
// 入库单号 + 订单自编号 + 发车单号 一个暂存单
|
|
|
|
|
for (OrderPackageDTO detail : details) { |
|
|
|
|
if (packageCode.contains(detail.getPackageCode())) { |
|
|
|
|
log.info(" 接收志邦数据:包条码 {} 已存在数据库中,不生成暂存单。", detail.getPackageCode()); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
String taskCode = zbReceiptDTO.getTaskCode(); |
|
|
|
|
String departCode = zbReceiptDTO.getDepartCode(); |
|
|
|
|
String platformOrderCode = detail.getPlatformOrderCode(); |
|
|
|
|