Browse Source

1.干线bug修复

dev
zhenghaoyu 2 months ago
parent
commit
8156976006
  1. 228
      blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java

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

@ -10356,38 +10356,170 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
String trayCode = trunklineCarsLoadScan.getTrayCode();
String waybillNo = trunklineCarsLoadScan.getWaybillNo();
String orderCode = trunklineCarsLoadScan.getOrderCode();
if(type==1){
//包件
DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(scanCode, warehouseId);
if(Objects.isNull(parcelListEntity)){
log.info("#########adnormalHasStock: 包件信息不存在");
Integer unbingTray = 0;
if(StringUtil.isNotBlank(trayCode)){
unbingTray = 1;
}
unloadPackageNoXz(loadId,scanCode,warehouseId,unbingTray,IncomingTypeEnum.ABNORMAL_INCOMING.getValue(),IncomingTypeEnum.ABNORMAL_INCOMING.getCode(),null,null);
}else{
String orderPackageStatus = parcelListEntity.getOrderPackageStatus();
if("20".equals(orderPackageStatus)){
log.warn("#########adnormalHasStock: 包件已入库 scanCode={} warehouseId={}",scanCode,warehouseId);
return R.success("包件已入库");
String loadCode = trunklineCarsLoadScan.getLoadCode();
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId);
if(Objects.isNull(warehouseEntity)){
log.warn("###############adnormalHasStock: 仓库信息不存在");
return R.fail(405, "仓库信息不存在");
}
String warehouseName = warehouseEntity.getName();
List<TrunklineCarsLoadScanEntity> carsLoadScanEntities = new ArrayList<>();
carsLoadScanEntities.add(trunklineCarsLoadScan);
//把carsLoadScanEntities中所有元素的scanCode放入一个Set集合
Set<String> scanCodeSet = carsLoadScanEntities.stream().map(TrunklineCarsLoadScanEntity::getScanCode).collect(Collectors.toSet());
log.info("###############adnormalHasStock: 当前同步的数据 {}",scanCodeSet);
List<String> scanCodeList = new ArrayList<>(scanCodeSet);
List<TrunklineAdvanceDetailEntity> allAdvanceDetailList = new ArrayList<>();
int packageBatchSize = 500;
List<List<String>> orderPackageCodeGroups = new ArrayList<>();
for (int i = 0; i < scanCodeList.size(); i += packageBatchSize) {
int endIndex = Math.min(i + packageBatchSize, scanCodeList.size());
orderPackageCodeGroups.add(scanCodeList.subList(i, endIndex));
}
orderPackageCodeGroups.forEach(orderPackageCodeGroup -> {
List<TrunklineAdvanceDetailEntity> advanceDetailEntityList = trunklineAdvanceDetailService.findListByOrderPackageCodeList(orderPackageCodeGroup);
allAdvanceDetailList.addAll(advanceDetailEntityList);
});
//把allAdvanceDetailList转化成orderPackageCode为key的Map
Map<String, TrunklineAdvanceDetailEntity> advanceDetailMap = allAdvanceDetailList.stream().collect(Collectors.toMap(TrunklineAdvanceDetailEntity::getOrderPackageCode, Function.identity()));
List<TrunklineCarsLoadScanEntity> updateScanList = new ArrayList<>();
List<TrunklineAdvanceDetailEntity> incomingAdvanceDetailList = new ArrayList<>();
List<TrunklineAdvanceDetailEntity> udateAdvanceDetailList = new ArrayList<>();
Set<String> orderPackageCodeSet = new HashSet<>();
carsLoadScanEntities.forEach(carsLoadScanEntity -> {
String orderPackageCode = carsLoadScanEntity.getScanCode();
TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity = advanceDetailMap.get(orderPackageCode);
if(!Objects.isNull(trunklineAdvanceDetailEntity)){
orderPackageCodeSet.add(orderPackageCode);
TrunklineCarsLoadScanEntity updateScanEntity = new TrunklineCarsLoadScanEntity();
updateScanEntity.setId(carsLoadScanEntity.getId());
String packageStatus = trunklineAdvanceDetailEntity.getPackageStatus();
if(packageStatus.equals("0")){
updateScanEntity.setFromWarehouseId(trunklineAdvanceDetailEntity.getWarehouseId());
incomingAdvanceDetailList.add(trunklineAdvanceDetailEntity);
}else{
Integer unbingTray = 0;
if(StringUtil.isNotBlank(trayCode)){
unbingTray = 1;
}
unloadPackageNoXz(loadId,scanCode,warehouseId,unbingTray,IncomingTypeEnum.ABNORMAL_INCOMING.getValue(),IncomingTypeEnum.ABNORMAL_INCOMING.getCode(),null,null);
updateScanEntity.setFromWarehouseId(trunklineAdvanceDetailEntity.getNowWarehouseId());
udateAdvanceDetailList.add(trunklineAdvanceDetailEntity);
}
updateScanEntity.setOrderCode(trunklineAdvanceDetailEntity.getOrderCode());
updateScanEntity.setWaybillId(trunklineAdvanceDetailEntity.getWaybillId());
updateScanEntity.setWaybillNo(trunklineAdvanceDetailEntity.getWaybillNo());
updateScanEntity.setIsData(1);
updateScanList.add(updateScanEntity);
}
}else{
Integer unbingTray = 0;
if(StringUtil.isNotBlank(trayCode)){
unbingTray = 1;
});
if(CollUtil.isNotEmpty(incomingAdvanceDetailList)){
for (TrunklineAdvanceDetailEntity trunklineAdvanceDetailEntity : incomingAdvanceDetailList) {
InComingDTO inComingDTO = new InComingDTO();
inComingDTO.setOrderPackageCode(trunklineAdvanceDetailEntity.getOrderPackageCode());
inComingDTO.setIncomingType(IncomingTypeEnum.SYNC_INCOMING.getCode());
inComingDTO.setWarehouseId(warehouseId);
R r = inComingService.incomingPackage(inComingDTO);
if(r.getCode() != 200){
throw new CustomerException(405,"入库失败");
}
}
//零担
unloadZeroNoXz(loadId,waybillNo,num,warehouseId,unbingTray,trayCode,orderCode,"异常列表入库");
}
if(CollUtil.isNotEmpty(udateAdvanceDetailList)){
List<DistributionParcelListEntity> updateParceList = new ArrayList<>();
udateAdvanceDetailList.forEach(trunklineAdvanceDetailEntity -> {
String orderPackageCode = trunklineAdvanceDetailEntity.getOrderPackageCode();
List<DistributionParcelListEntity> list = distributionParcelListClient.findListByOrderPackageCodeAndStatus(orderPackageCode,"20");
//把list通过warehouseId进行分组
if(CollUtil.isNotEmpty(list)){
list.forEach(distributionParcelListEntity -> {
DistributionParcelListEntity updateEntity = new DistributionParcelListEntity();
updateEntity.setId(distributionParcelListEntity.getId());
updateEntity.setOrderPackageStatus("60");
updateEntity.setOrderCode(distributionParcelListEntity.getOrderCode());
updateEntity.setWarehouseId(distributionParcelListEntity.getWarehouseId());
updateParceList.add(updateEntity);
});
}
});
distributionParcelListClient.updateList(updateParceList);
advanceService.saveOrderAndPackages(udateAdvanceDetailList, warehouseId);
List<TrunklineAdvanceDetailEntity> updateNowWarehouseList = new ArrayList<>();
udateAdvanceDetailList.forEach(trunklineAdvanceDetailEntity -> {
TrunklineAdvanceDetailEntity updateEntity = new TrunklineAdvanceDetailEntity();
updateEntity.setId(trunklineAdvanceDetailEntity.getId());
updateEntity.setNowWarehouseId(warehouseId);
updateEntity.setNowWarehouseName(warehouseName);
updateNowWarehouseList.add(updateEntity);
});
trunklineAdvanceDetailService.updateBatchById(updateNowWarehouseList);
}
trunklineCarsLoadScanService.updateBatchById(updateScanList);
int i= 0;
//完结所有包件异常列表
if(CollUtil.isNotEmpty(orderPackageCodeSet)){
i = orderPackageCodeSet.size();
DealWithAbnormalVO dealWithAbnormalVO = new DealWithAbnormalVO();
dealWithAbnormalVO.setOrderPackageCodes(new ArrayList<>(orderPackageCodeSet));
dealWithAbnormalVO.setCarsNo(loadCode);
dealWithAbnormalVO.setWarehouseName(warehouseName);
dealWithAbnormalVO.setNickName(AuthUtil.getNickName());
dealWithAbnormalVO.setRemark("数据同步系统自动处理("+warehouseName+" "+loadCode+" "+AuthUtil.getNickName()+")");
abnormalRecordClient.dealwithOrderPackageCodes(dealWithAbnormalVO);
}
// if(type==1){
// //包件
// DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(scanCode, warehouseId);
// if(Objects.isNull(parcelListEntity)){
// log.info("#########adnormalHasStock: 包件信息不存在");
// Integer unbingTray = 0;
// if(StringUtil.isNotBlank(trayCode)){
// unbingTray = 1;
// }
// unloadPackageNoXz(loadId,scanCode,warehouseId,unbingTray,IncomingTypeEnum.ABNORMAL_INCOMING.getValue(),IncomingTypeEnum.ABNORMAL_INCOMING.getCode(),null,null);
// }else{
// String orderPackageStatus = parcelListEntity.getOrderPackageStatus();
// if("20".equals(orderPackageStatus)){
// log.warn("#########adnormalHasStock: 包件已入库 scanCode={} warehouseId={}",scanCode,warehouseId);
// return R.success("包件已入库");
// }else{
// Integer unbingTray = 0;
// if(StringUtil.isNotBlank(trayCode)){
// unbingTray = 1;
// }
// unloadPackageNoXz(loadId,scanCode,warehouseId,unbingTray,IncomingTypeEnum.ABNORMAL_INCOMING.getValue(),IncomingTypeEnum.ABNORMAL_INCOMING.getCode(),null,null);
// }
// }
// }else{
// Integer unbingTray = 0;
// if(StringUtil.isNotBlank(trayCode)){
// unbingTray = 1;
// }
// //零担
// unloadZeroNoXz(loadId,waybillNo,num,warehouseId,unbingTray,trayCode,orderCode,"异常列表入库");
//
// }
return R.success("入库成功");
}
@ -12631,6 +12763,9 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
} else {
String scanStatus = carsLoadScanEntity.getScanStatus();
if(!"1".equals(scanStatus)){
carsLoadScanEntity.setUnloadTrayCode(unloadTrayCode);
carsLoadScanEntity.setUnloadTrayName(unloadTrayName);
trunklineCarsLoadScanService.updateById(carsLoadScanEntity);
log.warn("##############unloadPackage: 包件已卸车 orderPackageCode={}", orderPackageCode);
return R.fail(405, "包件已卸车");
}
@ -12656,8 +12791,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
carsLoadScanEntity.setScanStatus("2");
carsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName());
carsLoadScanEntity.setUnloadTime(new Date());
carsLoadScanEntity.setUnloadAbnormal(1);
carsLoadScanEntity.setIsSupple(1);
carsLoadScanEntity.setUnloadTrayCode(unloadTrayCode);
carsLoadScanEntity.setUnloadTrayName(unloadTrayName);
trayCode = carsLoadScanEntity.getTrayCode();
if (!StringUtil.isBlank(trayCode)) {
BasicdataTrayEntity trayEntity = basicdataTrayClient.getTrayByTrayCode(trayCode);
@ -12665,13 +12800,11 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
trayName = trayEntity.getPalletName();
}
if (unbindTray == 1) {
if(StringUtils.isNotBlank(orderPackageCode)){
updownTypeClient.downPackageOrDelTray(orderPackageCode, fromWarehouseId, "干线卸车下架解托");
}
carsLoadAsyncService.downPackageOrDelTray(orderPackageCode, fromWarehouseId, "干线卸车下架解托");
}
trunklineCarsLoadScanService.updateById(carsLoadScanEntity);
trunklineCarsUnloadLogService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNo, orderCode, orderPackageCode, 1,
carsLoadAsyncService.savaUnloadLog(warehouseId, warehouseName, loadId, loadCode, waybillId, waybillNo, orderCode, orderPackageCode, 1,
1, 1, isAbnormal, trayId, trayCode, trayName, fromWarehouseId, loadScanId, remark);
if (1 == isData) {
@ -12691,6 +12824,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
}else{
Long currentOrderId = null;
//查询当前仓库订单信息有没有
Integer totalNum = trunklineAdvanceDetailService.findTotalNumByOrderCode(orderCode);
DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId);
if (Objects.isNull(stockArticleEntity)) {
//查询包件前面仓的订单信息
@ -12700,11 +12834,12 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
stockArticleEntity.setId(null);
stockArticleEntity.setWarehouseId(warehouseId);
stockArticleEntity.setWarehouse(warehouseName);
stockArticleEntity.setTotalNumber(totalNum);
stockArticleEntity.setHandQuantity(0);
stockArticleEntity.setCompleteSet(1);
stockArticleEntity.setStockupStatus("10");
stockArticleEntity.setReservationStatus("10");
stockArticleEntity.setOrderStatus("10");
stockArticleEntity.setOrderStatus("20");
stockArticleEntity.setGroundingStatus("10");
stockArticleEntity.setOrderReceiveStatus("10");
stockArticleEntity.setFreezeStatus("10");
@ -12713,10 +12848,23 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
stockArticleEntity.setTransferQuantity(0);
stockArticleEntity.setSigninQuantity(0);
stockArticleEntity.setIncomingNum(0);
stockArticleEntity.setAllocation(null);
stockArticleEntity.setTrays(null);
currentOrderId = distributionStockArticleClient.addData(stockArticleEntity);
stockArticleEntity.setId(currentOrderId);
} else {
currentOrderId = stockArticleEntity.getId();
String reservationStatus = stockArticleEntity.getReservationStatus();
if("30".equals(reservationStatus)){
stockArticleEntity.setReservationStatus("20");
}
String orderStatus = stockArticleEntity.getOrderStatus();
if("80".equals(orderStatus)){
stockArticleEntity.setOrderStatus("70");
}
stockArticleEntity.setGenre(1);
stockArticleEntity.setTotalNumber(totalNum);
distributionStockArticleClient.updateEntity(stockArticleEntity);
}
//判断包件当前仓是否是目的仓
@ -12731,8 +12879,10 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓
if (destinationWarehouseId.equals(warehouseId)) {
distributionParcelListEntity.setIsTransfer(0);
isTransfer = 0;
} else {
distributionParcelListEntity.setIsTransfer(1);
isTransfer = 1;
}
}
distributionParcelListEntity.setWarehouseId(warehouseId);
@ -12754,8 +12904,10 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
Long destinationWarehouseId = warehouseWaybillEntity.getDestinationWarehouseId();//目的仓
if (destinationWarehouseId.equals(warehouseId)) {
distributionParcelListEntity.setIsTransfer(0);
isTransfer = 0;
} else {
distributionParcelListEntity.setIsTransfer(1);
isTransfer = 1;
}
}
distributionParcelListClient.update(distributionParcelListEntity);
@ -12773,6 +12925,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
//未入库
InComingDTO inComingDTO = new InComingDTO();
inComingDTO.setOrderPackageCode(orderPackageCode);
inComingDTO.setIncomingType(incomingType);
inComingDTO.setWarehouseId(warehouseId);
inComingService.incomingPackage(inComingDTO);
@ -12790,6 +12943,8 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
newStockArticle.setId(null);
newStockArticle.setWarehouseId(warehouseId);
newStockArticle.setWarehouse(basicdataWarehouseEntity.getName());
newStockArticle.setAllocation(null);
newStockArticle.setTrays(null);
orderId = distributionStockArticleClient.addData(newStockArticle);
} else {
orderId = newStockArticle.getId();
@ -12809,9 +12964,16 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl<TrunklineCarsL
carsLoadScanEntity.setUnloadUserName(AuthUtil.getNickName());
carsLoadScanEntity.setUnloadTime(new Date());
carsLoadScanEntity.setIsData(1);
carsLoadScanEntity.setIsSupple(1);
carsLoadScanEntity.setUnloadTrayCode(unloadTrayCode);
carsLoadScanEntity.setUnloadTrayName(unloadTrayName);
isData = 1;
trunklineCarsLoadScanService.updateById(carsLoadScanEntity);
}else{
carsLoadScanEntity.setReserve1("1");
trunklineCarsLoadScanService.updateById(carsLoadScanEntity);
}
}
}

Loading…
Cancel
Save