diff --git a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java index e3f3778fc..43b991466 100644 --- a/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java +++ b/blade-service-api/logpm-distribution-api/src/main/java/com/logpm/distribution/feign/IDistributionParcelListClient.java @@ -312,5 +312,9 @@ public interface IDistributionParcelListClient { @GetMapping(API_PREFIX + "/findListByOrderPackageCodeAndStatus") List findListByOrderPackageCodeAndStatus(@RequestParam String orderPackageCode, @RequestParam String status); + + @GetMapping(API_PREFIX + "/findOneByOrderPackageCode") + DistributionParcelListEntity findOneByOrderPackageCode(@RequestParam String orderPackageCode); + } diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TrayTypeDataListVO.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TrayTypeDataListVO.java index b3709746c..fd660bd39 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TrayTypeDataListVO.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/vo/TrayTypeDataListVO.java @@ -25,6 +25,9 @@ public class TrayTypeDataListVO implements Serializable { private Integer orderTotalNum;//订单总件数 private Integer residueNum;//剩余件数 + private String consigneeUnit; + private String consigneePerson; + private List positionList = new ArrayList<>(); diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java index 0a2588ed4..25e1ceed3 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/feign/DistributionParcelListClient.java @@ -664,4 +664,9 @@ public class DistributionParcelListClient implements IDistributionParcelListClie return distributionParcelListService.findListByOrderPackageCodeAndStatus(orderPackageCode,status); } + @Override + public DistributionParcelListEntity findOneByOrderPackageCode(String orderPackageCode) { + return distributionParcelListService.findOneByOrderPackageCode(orderPackageCode); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java index 62da525d1..f14c61272 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.java @@ -342,4 +342,6 @@ public interface DistributionParcelListMapper extends BaseMapper orderPackageCodeList,@Param("warehouseId") Long warehouseId); List findListByOrderPackageCodeAndStatus(@Param("orderPackageCode") String orderPackageCode, @Param("status") String status); + + DistributionParcelListEntity findOneByOrderPackageCode(@Param("orderPackageCode") String orderPackageCode); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml index 4a6d5df15..3a4a1a26a 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionParcelListMapper.xml @@ -2284,4 +2284,13 @@ and is_deleted = 0 + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java index 6623cfa83..c70869711 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionParcelListService.java @@ -316,4 +316,7 @@ public interface IDistributionParcelListService extends BaseService findListByOrderPackageCodeAndStatus(String orderPackageCode, String status); + + DistributionParcelListEntity findOneByOrderPackageCode(String orderPackageCode); + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java index aa7514591..f6fc2feda 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java @@ -1600,4 +1600,9 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl findListByOrderPackageCodeAndStatus(String orderPackageCode, String status) { return baseMapper.findListByOrderPackageCodeAndStatus(orderPackageCode,status); } + + @Override + public DistributionParcelListEntity findOneByOrderPackageCode(String orderPackageCode) { + return baseMapper.findOneByOrderPackageCode(orderPackageCode); + } } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java index 87e552b87..9364e1f98 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/jobhandle/SyncOrderInfoToPlatform.java @@ -3,9 +3,13 @@ package com.logpm.patch.jobhandle; import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.basicdata.entity.BasicdataClientEntity; +import com.logpm.basicdata.entity.BasicdataStoreBusinessEntity; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.distribution.entity.DistributionStockArticleEntity; +import com.logpm.distribution.feign.IDistributionParcelListClient; import com.logpm.distribution.feign.IDistributionStockArticleClient; import com.logpm.oldproject.entity.AdvanceDetailEntity; import com.logpm.oldproject.entity.AdvanceEntity; @@ -51,6 +55,7 @@ public class SyncOrderInfoToPlatform { private final IOrderSyncRecordService orderSyncRecordService; private final ISyncOrderInfoService syncOrderInfoService; private final IDistributionStockArticleClient distributionStockArticleClient; + private final IDistributionParcelListClient distributionParcelListClient; private final ITrunklineWaybillOrderClient waybillOrderClient; private final ITrunklineAdvanceClient trunklineAdvanceClient; @@ -1068,4 +1073,208 @@ public class SyncOrderInfoToPlatform { + @XxlJob("syncUnloadData") + public ReturnT syncUnloadData(String param) { + log.info("############syncUnloadData: 同步卸车数据 开始"); + + List ls = warehouseMappingDataService.findAllUnloadData(); + + + for (JSONObject json : ls) { + Integer id = json.getInt("id"); + String orderPackageCode = json.getStr("orderPackageCode"); + try{ + + log.info("###############syncUnloadData: 当前处理的包件 orderPackageCode={}",orderPackageCode); + + TrunklineAdvanceDetailEntity advanceDetailEntity = trunklineAdvanceDetailClient.findEntityByOrderPackageCode(orderPackageCode); + if(Objects.isNull(advanceDetailEntity)){ + log.info("############syncUnloadData: 暂存单不存在 orderPackageCode={}",orderPackageCode); + }else{ + + String packageStatus = advanceDetailEntity.getPackageStatus(); + Long incomingWarehouseId = advanceDetailEntity.getIncomingWarehouseId(); + String incomeCategoryName = advanceDetailEntity.getIncomeCategoryName(); + Long nowWarehouseId = advanceDetailEntity.getNowWarehouseId(); + String nowWarehouseName = advanceDetailEntity.getNowWarehouseName(); + Long warehouseId = advanceDetailEntity.getWarehouseId(); + String warehouseName = advanceDetailEntity.getWarehouseName(); + + DistributionParcelListEntity distributionParcelListEntity = distributionParcelListClient.findOneByOrderPackageCode(orderPackageCode); + + if(packageStatus.equals("0")){ + //未入库 判断当前包件入库最后的仓库有无数据 + if(!Objects.isNull(distributionParcelListEntity)){ + //如果有数据,则把暂存单入库并 + advanceDetailEntity.setPackageStatus("1"); + Long parcelListWarehouseId = distributionParcelListEntity.getWarehouseId(); + String parcelListWarehouse = distributionParcelListEntity.getWarehouse(); + //判断当前包件所在仓与导入仓库是否一致,一致则不插入 + if(parcelListWarehouseId.equals(warehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(parcelListWarehouseId); + advanceDetailEntity.setIncomingWarehouseName(parcelListWarehouse); + }else{ + //如果不一致,则把包件插入到入库仓库状态为60 + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + + log.info("#################syncUnloadData 1111 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"60"); + + } + advanceDetailEntity.setNowWarehouseId(parcelListWarehouseId); + advanceDetailEntity.setNowWarehouseName(parcelListWarehouse); + } + }else{ + //暂存单包件已入库 + if(!Objects.isNull(nowWarehouseId)){ + //当前所在仓id不为空 + if(!Objects.isNull(distributionParcelListEntity)){ + //判断当前所包件所在仓有数据 + Long warehouseId1 = distributionParcelListEntity.getWarehouseId(); + String warehouse = distributionParcelListEntity.getWarehouse(); + if(!nowWarehouseId.equals(warehouseId1)){ + //判断当前仓库与包件所在仓库是否一致,不一致则判断当前所在仓包件有无入库 + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, nowWarehouseId); + if(Objects.isNull(parcelListEntity)){ + //未入库 + + log.info("#################syncUnloadData 22222 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + + + }else{ + advanceDetailEntity.setNowWarehouseId(warehouseId1); + advanceDetailEntity.setNowWarehouseName(warehouse); + } + } + }else{ + if(Objects.isNull(incomingWarehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + if(warehouseId.equals(nowWarehouseId)){ + + log.info("#################syncUnloadData 333333 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"20"); + + }else{ + log.info("#################syncUnloadData 44444 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"60"); + log.info("#################syncUnloadData 55555 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + } + }else{ + if(nowWarehouseId.equals(incomingWarehouseId)){ + log.info("#################syncUnloadData 66666 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + }else{ + log.info("#################syncUnloadData 7777 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,incomingWarehouseId,"60"); + log.info("#################syncUnloadData 88888 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + + } + } + } + }else{ + + if(!Objects.isNull(distributionParcelListEntity)){ + + Long warehouseId1 = distributionParcelListEntity.getWarehouseId(); + String warehouse = distributionParcelListEntity.getWarehouse(); + if(Objects.isNull(incomingWarehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + advanceDetailEntity.setNowWarehouseId(warehouseId1); + advanceDetailEntity.setNowWarehouseName(warehouse); + log.info("#################syncUnloadData 99999 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"60"); + + }else{ + advanceDetailEntity.setNowWarehouseId(warehouseId1); + advanceDetailEntity.setNowWarehouseName(warehouse); + if(!incomingWarehouseId.equals(warehouseId1)){ + log.info("#################syncUnloadData 000000 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,incomingWarehouseId,"60"); + } + } + + + }else{ + if(Objects.isNull(incomingWarehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + advanceDetailEntity.setNowWarehouseId(warehouseId); + advanceDetailEntity.setNowWarehouseName(warehouseName); + log.info("#################syncUnloadData aaaaaa orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"20"); + }else{ + advanceDetailEntity.setIncomingWarehouseId(incomingWarehouseId); + advanceDetailEntity.setIncomingWarehouseName(incomeCategoryName); + advanceDetailEntity.setNowWarehouseId(incomingWarehouseId); + advanceDetailEntity.setNowWarehouseName(incomeCategoryName); + + log.info("#################syncUnloadData bbbbbbb orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,incomingWarehouseId,"20"); + } + } + } + } + } + + warehouseMappingDataService.updateSyncUnloadDataStatus(id,1); + + }catch (Exception e){ + log.warn("###############syncUnloadData: 包件处理失败 orderPackageCode={}", orderPackageCode); + } + } + log.info("############syncUnloadData: 同步卸车数据 完成"); + + return ReturnT.SUCCESS; + } + + private void updateParcelListToWarehouse(TrunklineAdvanceDetailEntity advanceDetailEntity, Long warehouseId, String status) { + String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); + String orderCode = advanceDetailEntity.getOrderCode(); + + if("20".equals(status)){ + List list = distributionParcelListClient.findListByOrderPackageCodeAndStatus(orderPackageCode,"20"); + //把list通过warehouseId进行分组 + List updateParceList = new ArrayList<>(); + if(CollUtil.isNotEmpty(list)){ + list.forEach(distributionParcelListEntity -> { + DistributionParcelListEntity updateEntity = new DistributionParcelListEntity(); + updateEntity.setId(distributionParcelListEntity.getId()); + updateEntity.setOrderPackageStatus("60"); + updateParceList.add(updateEntity); + }); + } + distributionParcelListClient.updateList(updateParceList); + } + + + + + + + + + + + + } + + } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.java index cb423789e..dabea1c8e 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.java @@ -164,5 +164,10 @@ public interface WarehouseMappingDataMapper { void deletedOrderByWaybillNo(@Param("waybillNo") String waybillNo); void deletedBalanceOrderByWaybillNo(@Param("waybillNo") String waybillNo); + + void updateSyncUnloadDataStatus(@Param("id") Integer id, @Param("status") int status); + + List findAllUnloadData(); + } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.xml b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.xml index 6f50a258c..a5f51d977 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.xml +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/WarehouseMappingDataMapper.xml @@ -553,5 +553,17 @@ where waybill_no = #{waybillNo} + + update sync_unload_data + set status = #{syncStatus} + where id = #{id} + + + diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IWarehouseMappingDataService.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IWarehouseMappingDataService.java index 1c00269b6..133322f1b 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IWarehouseMappingDataService.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IWarehouseMappingDataService.java @@ -138,5 +138,8 @@ public interface IWarehouseMappingDataService { void deleteStatisticsdata(String waybillNo); + void updateSyncUnloadDataStatus(Integer id, int status); + + List findAllUnloadData(); } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/WarehouseMappingDataServiceImpl.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/WarehouseMappingDataServiceImpl.java index 82dc78361..34eb91fd8 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/WarehouseMappingDataServiceImpl.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/WarehouseMappingDataServiceImpl.java @@ -338,4 +338,14 @@ public class WarehouseMappingDataServiceImpl implements IWarehouseMappingDataSer warehouseMappingDataMapper.deletedBalanceOrderByWaybillNo(waybillNo); } + + @Override + public void updateSyncUnloadDataStatus(Integer id, int status) { + warehouseMappingDataMapper.updateSyncUnloadDataStatus(id,status); + } + + @Override + public List findAllUnloadData() { + return warehouseMappingDataMapper.findAllUnloadData(); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java index 4912837e0..08b70aa0b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/controller/CarsLoadController.java @@ -1397,6 +1397,9 @@ public class CarsLoadController { // } // loadCarsDTO.setWarehouseId(myCurrentWarehouse.getId()); + + + if(Objects.isNull(loadId)){ log.warn(method+"配载计划id为空 loadId={}",loadId); return R.fail(400,"配载计划id为空"); @@ -1413,6 +1416,28 @@ public class CarsLoadController { } + @ResponseBody + @PostMapping("/syncUnloadData") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "数据修复", notes = "传入loadCarsDTO") + public R syncUnloadData() { + String method = "############syncUnloadData: "; + try{ + + carsLoadService.syncUnloadData(); + + + return R.success("success"); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常",e); + return R.fail(500,"系统异常"); + } + } + + @ResponseBody @PostMapping("/zeroSuppleList") @ApiOperationSupport(order = 1) diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java index 62f6ae26e..cb8b38d8b 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.java @@ -1,5 +1,6 @@ package com.logpm.trunkline.mapper; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.trunkline.dto.AdvanceDTO; @@ -93,4 +94,8 @@ public interface TrunklineAdvanceDetailMapper extends BaseMapper advanceIds); List findOrderPackageCodesByAdvanceIds(@Param("advanceIds") List advanceIds); + + List findAllUnloadData(); + + void updateSyncUnloadDataStatus(@Param("id") Integer id, @Param("status") int status); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml index b29fa87f1..fc9690f41 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceDetailMapper.xml @@ -591,4 +591,17 @@ + + + + update sync_unload_data + set status = #{status} + where id = #{id} + + diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java index 9b51a7146..e84d08474 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineAdvanceDetailService.java @@ -1,5 +1,6 @@ package com.logpm.trunkline.service; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.distribution.vo.OrderPackgeCodeDataVO; import com.logpm.trunkline.dto.AdvanceDTO; @@ -110,4 +111,8 @@ public interface ITrunklineAdvanceDetailService extends BaseService advanceIds); List findOrderPackageCodesByAdvanceIds(List advanceIds); + + List findAllUnloadData(); + + void updateSyncUnloadDataStatus(Integer id, int status); } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java index e958ca305..46395b704 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/ITrunklineCarsLoadService.java @@ -272,4 +272,7 @@ public interface ITrunklineCarsLoadService extends BaseService findOrderPackageCodesByAdvanceIds(List advanceIds) { return baseMapper.findOrderPackageCodesByAdvanceIds(advanceIds); } + + @Override + public List findAllUnloadData() { + return baseMapper.findAllUnloadData(); + } + + @Override + public void updateSyncUnloadDataStatus(Integer id, int status) { + baseMapper.updateSyncUnloadDataStatus(id,status); + } } diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java index 5ea9b00e6..bce73e977 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/TrunklineCarsLoadServiceImpl.java @@ -18,13 +18,13 @@ import com.logpm.aftersales.entity.AftersalesAbnormalRecordEntity; import com.logpm.aftersales.feign.IAftersalesAbnormalRecordClient; import com.logpm.aftersales.feign.IAftersalesWorkOrderClient; import com.logpm.aftersales.vo.DealWithAbnormalVO; +import com.logpm.basic.entity.BasicMaterialEntity; +import com.logpm.basic.feign.IBasicMaterialClient; +import com.logpm.basicdata.entity.BasicdataClientEntity; import com.logpm.basicdata.entity.BasicdataDriverArteryEntity; import com.logpm.basicdata.entity.BasicdataTrayEntity; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; -import com.logpm.basicdata.feign.IBasicdataCodeClient; -import com.logpm.basicdata.feign.IBasicdataDriverArteryClient; -import com.logpm.basicdata.feign.IBasicdataTrayClient; -import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.basicdata.feign.*; import com.logpm.distribution.dto.FindParamterDTO; import com.logpm.distribution.dto.UpdatePackageDTO; import com.logpm.distribution.entity.DistributionParcelListEntity; @@ -138,6 +138,9 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl loadLineList = trunklineCarsLoadLineService.findListByLoadId(loadId); @@ -4821,6 +4829,391 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl ls = trunklineAdvanceDetailService.findAllUnloadData(); + + + for (JSONObject json : ls) { + Integer id = json.getInteger("id"); + String orderPackageCode = json.getString("orderPackageCode"); + try{ + + log.info("###############syncUnloadData: 当前处理的包件 orderPackageCode={}",orderPackageCode); + + TrunklineAdvanceDetailEntity advanceDetailEntity = trunklineAdvanceDetailService.findEntityByOrderPackageCode(orderPackageCode); + if(Objects.isNull(advanceDetailEntity)){ + log.info("############syncUnloadData: 暂存单不存在 orderPackageCode={}",orderPackageCode); + }else{ + + String packageStatus = advanceDetailEntity.getPackageStatus(); + Long incomingWarehouseId = advanceDetailEntity.getIncomingWarehouseId(); + String incomeCategoryName = advanceDetailEntity.getIncomeCategoryName(); + Long nowWarehouseId = advanceDetailEntity.getNowWarehouseId(); + String nowWarehouseName = advanceDetailEntity.getNowWarehouseName(); + Long warehouseId = advanceDetailEntity.getWarehouseId(); + String warehouseName = advanceDetailEntity.getWarehouseName(); + + DistributionParcelListEntity distributionParcelListEntity = distributionParcelListClient.findOneByOrderPackageCode(orderPackageCode); + + if(packageStatus.equals("0")){ + //未入库 判断当前包件入库最后的仓库有无数据 + if(!Objects.isNull(distributionParcelListEntity)){ + //如果有数据,则把暂存单入库并 + advanceDetailEntity.setPackageStatus("1"); + Long parcelListWarehouseId = distributionParcelListEntity.getWarehouseId(); + String parcelListWarehouse = distributionParcelListEntity.getWarehouse(); + //判断当前包件所在仓与导入仓库是否一致,一致则不插入 + if(parcelListWarehouseId.equals(warehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(parcelListWarehouseId); + advanceDetailEntity.setIncomingWarehouseName(parcelListWarehouse); + }else{ + //如果不一致,则把包件插入到入库仓库状态为60 + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + + log.info("#################syncUnloadData 1111 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"60"); + + } + advanceDetailEntity.setNowWarehouseId(parcelListWarehouseId); + advanceDetailEntity.setNowWarehouseName(parcelListWarehouse); + } + }else{ + //暂存单包件已入库 + if(!Objects.isNull(nowWarehouseId)){ + //当前所在仓id不为空 + if(!Objects.isNull(distributionParcelListEntity)){ + //判断当前所包件所在仓有数据 + Long warehouseId1 = distributionParcelListEntity.getWarehouseId(); + String warehouse = distributionParcelListEntity.getWarehouse(); + if(!nowWarehouseId.equals(warehouseId1)){ + //判断当前仓库与包件所在仓库是否一致,不一致则判断当前所在仓包件有无入库 + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, nowWarehouseId); + if(Objects.isNull(parcelListEntity)){ + //未入库 + + log.info("#################syncUnloadData 22222 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + + + }else{ + advanceDetailEntity.setNowWarehouseId(warehouseId1); + advanceDetailEntity.setNowWarehouseName(warehouse); + } + } + }else{ + if(Objects.isNull(incomingWarehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + if(warehouseId.equals(nowWarehouseId)){ + + log.info("#################syncUnloadData 333333 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"20"); + + }else{ + log.info("#################syncUnloadData 44444 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"60"); + log.info("#################syncUnloadData 55555 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + } + }else{ + if(nowWarehouseId.equals(incomingWarehouseId)){ + log.info("#################syncUnloadData 66666 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + }else{ + log.info("#################syncUnloadData 7777 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,incomingWarehouseId,"60"); + log.info("#################syncUnloadData 88888 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,nowWarehouseId,"20"); + + } + } + } + }else{ + + if(!Objects.isNull(distributionParcelListEntity)){ + + Long warehouseId1 = distributionParcelListEntity.getWarehouseId(); + String warehouse = distributionParcelListEntity.getWarehouse(); + if(Objects.isNull(incomingWarehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + advanceDetailEntity.setNowWarehouseId(warehouseId1); + advanceDetailEntity.setNowWarehouseName(warehouse); + log.info("#################syncUnloadData 99999 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"60"); + + }else{ + advanceDetailEntity.setNowWarehouseId(warehouseId1); + advanceDetailEntity.setNowWarehouseName(warehouse); + if(!incomingWarehouseId.equals(warehouseId1)){ + log.info("#################syncUnloadData 000000 orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,incomingWarehouseId,"60"); + } + } + + + }else{ + if(Objects.isNull(incomingWarehouseId)){ + advanceDetailEntity.setIncomingWarehouseId(warehouseId); + advanceDetailEntity.setIncomingWarehouseName(warehouseName); + advanceDetailEntity.setNowWarehouseId(warehouseId); + advanceDetailEntity.setNowWarehouseName(warehouseName); + log.info("#################syncUnloadData aaaaaa orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,warehouseId,"20"); + }else{ + advanceDetailEntity.setIncomingWarehouseId(incomingWarehouseId); + advanceDetailEntity.setIncomingWarehouseName(incomeCategoryName); + advanceDetailEntity.setNowWarehouseId(incomingWarehouseId); + advanceDetailEntity.setNowWarehouseName(incomeCategoryName); + + log.info("#################syncUnloadData bbbbbbb orderPackageCode={}",orderPackageCode); + //更新包件到指定仓并且状态为20 + updateParcelListToWarehouse(advanceDetailEntity,incomingWarehouseId,"20"); + } + } + } + } + } + + trunklineAdvanceDetailService.updateSyncUnloadDataStatus(id,1); + + }catch (Exception e){ + log.warn("###############syncUnloadData: 包件处理失败 orderPackageCode={}", orderPackageCode); + } + } + log.info("############syncUnloadData: 同步卸车数据 完成"); + + } + + private void updateParcelListToWarehouse(TrunklineAdvanceDetailEntity advanceDetailEntity, Long warehouseId, String status) { + String orderPackageCode = advanceDetailEntity.getOrderPackageCode(); + String orderCode = advanceDetailEntity.getOrderCode(); + String waybillNo = advanceDetailEntity.getWaybillNo(); + Long advanceId = advanceDetailEntity.getAdvanceId(); + TrunklineAdvanceEntity advanceEntity = advanceService.getById(advanceId); + + Integer total = trunklineAdvanceDetailService.findTotalNumByOrderCode(orderCode); + + BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + String warehouseName = warehouseEntity.getName(); + + + if("20".equals(status)){ + List list = distributionParcelListClient.findListByOrderPackageCodeAndStatus(orderPackageCode,"20"); + //把list通过warehouseId进行分组 + List updateParceList = new ArrayList<>(); + if(CollUtil.isNotEmpty(list)){ + list.forEach(distributionParcelListEntity -> { + DistributionParcelListEntity updateEntity = new DistributionParcelListEntity(); + updateEntity.setId(distributionParcelListEntity.getId()); + updateEntity.setOrderPackageStatus("60"); + updateParceList.add(updateEntity); + }); + } + distributionParcelListClient.updateList(updateParceList); + } + + WarehouseWaybillEntity waybillEntity = warehouseWaybillClient.findByWaybillNo(waybillNo); + Date date = new Date(); + + Long orderId = null; + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCodeAndWarehouseId(orderCode, warehouseId); + if(Objects.isNull(stockArticleEntity)){ + stockArticleEntity = new DistributionStockArticleEntity(); + stockArticleEntity.setOrderCode(orderCode); + stockArticleEntity.setServiceNumber(advanceEntity.getServiceNum()); + stockArticleEntity.setWaybillNumber(waybillNo); + stockArticleEntity.setTotalNumber(total); + stockArticleEntity.setHandQuantity(0); +// stockArticleEntity.setTenantId(TenantNum.HUITONGCODE);// 对应租户ID + stockArticleEntity.setWarehouse(warehouseName); + stockArticleEntity.setWarehouseId(warehouseId); + stockArticleEntity.setBrand(advanceEntity.getBrand()); + stockArticleEntity.setDescriptionGoods(advanceEntity.getPackName()); + stockArticleEntity.setWarehouseEntryTime(date); + stockArticleEntity.setGenre(1); + + String dealerName = advanceEntity.getDealerName();//暂存单经销商名称 + stockArticleEntity.setDealerCode(advanceEntity.getDealerCode()); + stockArticleEntity.setDealerName(advanceEntity.getDealerName()); + + stockArticleEntity.setTypeService("1");//默认商配 + + if (!Objects.isNull(waybillEntity)) { + + Long consigneeId = waybillEntity.getConsigneeId(); + String consigneeName1 = waybillEntity.getConsignee(); + + + BasicdataClientEntity clientEntity = clientClient.getMallById(consigneeId); + // 如果在入库的时候发现客户信息不存在,则不设置客户信息 默认采用商配 + if (!Objects.isNull(clientEntity)) { + stockArticleEntity.setMallId(clientEntity.getId()); + stockArticleEntity.setMallName(clientEntity.getClientName()); + stockArticleEntity.setMallCode(clientEntity.getClientCode()); + + stockArticleEntity.setTypeService(clientEntity.getTypeService()+""); + } + String consignee = waybillEntity.getConsignee(); + String consigneeName = waybillEntity.getConsigneeName(); + String consigneeMobile = waybillEntity.getConsigneeMobile(); + String consigneeAddress = waybillEntity.getConsigneeAddress(); + stockArticleEntity.setConsigneeUnit(consignee); + stockArticleEntity.setConsigneePerson(consigneeName); + stockArticleEntity.setConsigneeMobile(consigneeMobile); + stockArticleEntity.setConsigneeAddress(consigneeAddress); + + } else { + Long clientId = tripartiteMallClient.getClientIdByNameAndBrand(dealerName, advanceEntity.getBrand()); + BasicdataClientEntity basicdataClientEntity = clientClient.findEntityById(clientId); + if (!Objects.isNull(basicdataClientEntity)) { + String clientType = basicdataClientEntity.getClientType(); + if ("5".equals(clientType)) { + stockArticleEntity.setStoreId(basicdataClientEntity.getId()); + stockArticleEntity.setStoreCode(basicdataClientEntity.getClientCode()); + stockArticleEntity.setStoreName(basicdataClientEntity.getClientName()); + //查询门店的父级商场 + Long pid = basicdataClientEntity.getPid(); + BasicdataClientEntity pidEntity = clientClient.findEntityById(pid); + if (!Objects.isNull(pidEntity)) { + String pidEntityClientType = pidEntity.getClientType(); + if ("2".equals(pidEntityClientType)) { + //商城 + stockArticleEntity.setMallId(pidEntity.getId()); + stockArticleEntity.setMallName(pidEntity.getClientName()); + stockArticleEntity.setMallCode(pidEntity.getClientCode()); + + stockArticleEntity.setTypeService(pidEntity.getTypeService()+""); + + } + } + } else if ("2".equals(clientType)) { + //商城 + stockArticleEntity.setMallId(basicdataClientEntity.getId()); + stockArticleEntity.setMallName(basicdataClientEntity.getClientName()); + stockArticleEntity.setMallCode(basicdataClientEntity.getClientCode()); + + stockArticleEntity.setTypeService(basicdataClientEntity.getTypeService()+""); + } + } + } + stockArticleEntity.setCustomerName(advanceEntity.getCustomerName()); + stockArticleEntity.setCustomerTelephone(advanceEntity.getCustomerPhone()); + stockArticleEntity.setCustomerAddress(advanceEntity.getCustomerAddress()); + stockArticleEntity.setStockupStatus("10"); + stockArticleEntity.setReservationStatus("10"); + stockArticleEntity.setOrderStatus("0"); + stockArticleEntity.setGroundingStatus("10"); + stockArticleEntity.setOrderReceiveStatus("10"); + stockArticleEntity.setFreezeStatus("10"); + stockArticleEntity.setNotification(2); + stockArticleEntity.setIsHaveData(2); + stockArticleEntity.setTrainNumber(advanceEntity.getTrainNumber()); + stockArticleEntity.setSortingQuantity(0); + stockArticleEntity.setDeliveryQuantity(0); + stockArticleEntity.setTransferQuantity(0); + stockArticleEntity.setSigninQuantity(0); + orderId = distributionStockArticleClient.addData(stockArticleEntity); + if(NumberUtil.equals(orderId,0)){ + log.warn("################111111: 保存失败"); + throw new CustomerException(405,"保存失败"); + } + }else{ + stockArticleEntity.setGenre(1); + stockArticleEntity.setTotalNumber(total); + orderId = stockArticleEntity.getId(); + distributionStockArticleClient.updateEntity(stockArticleEntity); + } + + DistributionParcelListEntity parcelList = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(orderPackageCode, warehouseId); + if(Objects.isNull(parcelList)){ + parcelList = new DistributionParcelListEntity(); + parcelList.setWarehouse(warehouseEntity.getName()); + parcelList.setWarehouseId(warehouseId); + parcelList.setIsTransfer(1); + + + if (!Objects.isNull(waybillEntity)) { + parcelList.setWaybillId(waybillEntity.getId()); + parcelList.setWaybillNumber(waybillEntity.getWaybillNo()); + parcelList.setSendWarehouseId(waybillEntity.getDepartureWarehouseId()); + parcelList.setSendWarehouseName(waybillEntity.getDepartureWarehouseName()); + Long destinationWarehouseId = waybillEntity.getDestinationWarehouseId(); + parcelList.setAcceptWarehouseId(destinationWarehouseId); + parcelList.setAcceptWarehouseName(waybillEntity.getDestinationWarehouseName()); + if (warehouseId.equals(destinationWarehouseId)) { + parcelList.setIsTransfer(0); + } + + } + + parcelList.setConditions(1); + parcelList.setOrderPackageCode(orderPackageCode); + parcelList.setFirsts(advanceDetailEntity.getFirstPackName()); + parcelList.setSecond(advanceDetailEntity.getSecondPackName()); + parcelList.setThirdProduct(advanceDetailEntity.getThirdPackName()); + parcelList.setQuantity(1); + parcelList.setStockArticleId(orderId); + parcelList.setOrderCode(orderCode); + parcelList.setServiceNumber(advanceDetailEntity.getServiceNum()); + parcelList.setTrainNumber(advanceDetailEntity.getTrainNumber()); + parcelList.setAdvanceId(advanceId); + + Long materialId = advanceDetailEntity.getMaterialId(); + String materialCode = advanceDetailEntity.getMaterialCode(); + String materialName = advanceDetailEntity.getMaterialName(); + if (Objects.isNull(materialId)) { + if (StringUtil.isNotBlank(materialCode) && StringUtil.isNotBlank(materialCode) && StringUtil.isNotBlank(materialName)) { + BasicMaterialEntity materialEntity = basicMaterialClient.findEntityByCodeAndName(materialCode, materialName); + if (!Objects.isNull(materialEntity)) { + parcelList.setMaterialId(materialEntity.getId()); + parcelList.setMaterialName(materialEntity.getName()); + parcelList.setMaterialCode(materialEntity.getProductCode()); + parcelList.setMaterialUnit(materialEntity.getSpecification()); + } + } + + } else { + BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId); + if (!Objects.isNull(materialOwnId)) { + parcelList.setMaterialId(materialOwnId.getId()); + parcelList.setMaterialName(materialOwnId.getName()); + parcelList.setMaterialCode(materialOwnId.getProductCode()); + parcelList.setMaterialUnit(materialOwnId.getSpecification()); + } + } + + parcelList.setBrandName(advanceDetailEntity.getBrand()); + parcelList.setOrderPackageStatus(status); + parcelList.setOrderPackageFreezeStatus("10"); + parcelList.setOrderPackageGroundingStatus("10"); + parcelList.setOrderPackageStockupStatus("10"); + parcelList.setOrderPackageReservationStatus("10"); + parcelList.setOrderPackageLoadingStatus("10"); + parcelList.setWarehouseEntryTimeEnd(date); + parcelList.setDealerCode(stockArticleEntity.getDealerCode()); + parcelList.setDealerName(stockArticleEntity.getDealerName()); + distributionParcelListClient.addReturnId(parcelList); + } + + } + @Override public R carsLoadDetailInfo(LoadCarsDTO loadCarsDTO) { @@ -5288,7 +5681,7 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl map = new HashMap<>(); map.put("trayType", trayType); map.put("trayCode", trayCode); @@ -7714,13 +8107,19 @@ public class TrunklineCarsLoadServiceImpl extends BaseServiceImpl