From 787c55640130ac3faf12cf7e6fcd143ed373d224 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Fri, 15 Dec 2023 00:56:25 +0800 Subject: [PATCH] =?UTF-8?q?1.bug=E4=BF=AE=E5=A4=8D=202.=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=80=81=E7=B3=BB=E7=BB=9F=E7=A9=BA=E7=BD=AE=E6=89=98=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logpm/oldproject/feign/IOrderClient.java | 3 + .../oldproject/feign/ITrayScanDesClient.java | 3 + .../feign/IWarehouseTaryAllocationClient.java | 4 +- .../factory/receiver/OrderStatusHandler.java | 118 ++++++++++++++++ .../logpm/oldproject/feign/OrderClient.java | 5 + .../oldproject/feign/TrayScanDesClient.java | 5 + .../logpm/oldproject/mapper/OrderMapper.java | 2 + .../logpm/oldproject/mapper/OrderMapper.xml | 6 + .../oldproject/service/IOrderService.java | 2 + .../service/ITrayScanDesService.java | 2 + .../service/impl/OrderServiceImpl.java | 5 + .../service/impl/TrayScanDesServiceImpl.java | 9 ++ .../jobhandle/SyncOrderInfoToPlatform.java | 3 +- .../patch/service/ISyncOrderInfoService.java | 2 +- .../impl/SyncOrderInfoServiceImpl.java | 88 +++++++++++- .../controller/OldSystemPushController.java | 129 +++++++++--------- .../feign/WarehouseTaryAllocationClient.java | 6 + 17 files changed, 318 insertions(+), 74 deletions(-) diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java index 5c9d49529..78e9ce0e8 100644 --- a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IOrderClient.java @@ -66,4 +66,7 @@ public interface IOrderClient { @GetMapping(API_PREFIX + "/updateStatusWithTableName") void updateStatusWithTableName(@RequestParam int isUpdate, @RequestParam String orderCode, @RequestParam String tableName); + + @GetMapping(API_PREFIX + "/findAllTrayId") + List findAllTrayId(@RequestParam String tableName); } diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/ITrayScanDesClient.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/ITrayScanDesClient.java index 8f9ac1d19..dbf527656 100644 --- a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/ITrayScanDesClient.java +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/ITrayScanDesClient.java @@ -27,6 +27,9 @@ public interface ITrayScanDesClient { @GetMapping(API_PREFIX + "/findEntityByUnitNoAndWarehouseId") TrayScanDesEntity findEntityByUnitNoAndWarehouseId(@RequestParam String unitNo, @RequestParam Integer oldWarehouseId); + @GetMapping(API_PREFIX + "/findListByTrayId") + List findListByTrayId(@RequestParam Integer trayId, @RequestParam Integer oldWarehouseId); + // @GetMapping(API_PREFIX + "/getEntityByOrderCode") // OrderCountEntity getEntityByOrderCode(@RequestParam String orderCode, @RequestParam Integer oldWarehouseId); } diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseTaryAllocationClient.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseTaryAllocationClient.java index 0b05c8345..2856f1430 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseTaryAllocationClient.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/feign/IWarehouseTaryAllocationClient.java @@ -4,6 +4,7 @@ package com.logpm.warehouse.feign; import com.logpm.warehouse.entity.WarehouseTaryAllocationEntity; import org.springblade.common.constant.ModuleNameConstant; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -26,5 +27,6 @@ public interface IWarehouseTaryAllocationClient { @PostMapping(GETALLOCATIONID) List getAllocationId(@RequestParam Long allocationId); - + @GetMapping(API_PREFIX+"/findAllocationByTrayId") + Long findAllocationByTrayId(@RequestParam Long trayId); } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java index a10bbb114..c520376f3 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/receiver/OrderStatusHandler.java @@ -1,5 +1,9 @@ package com.logpm.factory.receiver; +import com.logpm.basicdata.entity.BasicdataTrayEntity; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataTrayClient; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.factory.comfac.constant.FactoryConstant; import com.logpm.factory.comfac.dto.OrderStatusDTO; import com.logpm.factory.mt.service.IMtFactoryDataService; @@ -7,7 +11,16 @@ import com.logpm.factory.oupai.service.IOuPaiFactoryService; import com.logpm.factory.pan.service.IPanFactoryDataService; import com.logpm.factory.zb.service.IZbFactoryDataService; import com.logpm.oldproject.entity.AdvanceEntity; +import com.logpm.oldproject.entity.TrayEntity; +import com.logpm.oldproject.entity.TrayScanDesEntity; +import com.logpm.oldproject.entity.TrayScanEntity; import com.logpm.oldproject.feign.IAdvanceClient; +import com.logpm.oldproject.feign.ITrayClient; +import com.logpm.oldproject.feign.ITrayScanClient; +import com.logpm.oldproject.feign.ITrayScanDesClient; +import com.logpm.warehouse.feign.IWarehouseTaryAllocationClient; +import com.logpm.warehouse.feign.IWarehouseTrayTypeClient; +import com.logpm.warehouse.feign.IWarehouseUpdownTypeClient; import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.RabbitConstant; @@ -21,6 +34,7 @@ import org.springframework.stereotype.Component; import java.io.IOException; import java.security.NoSuchAlgorithmException; +import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -47,6 +61,22 @@ public class OrderStatusHandler { @Autowired private IOuPaiFactoryService ouPaiFactoryService; + @Autowired + private IWarehouseTrayTypeClient warehouseTrayTypeClient; + @Autowired + private IWarehouseUpdownTypeClient updownTypeClient; + @Autowired + private IWarehouseTaryAllocationClient taryAllocationClient; + @Autowired + private IBasicdataWarehouseClient basicdataWarehouseClient; + @Autowired + private IBasicdataTrayClient basicdataTrayClient; + @Autowired + private ITrayClient trayClient; + @Autowired + private ITrayScanDesClient trayScanDesClient; + @Autowired + private ITrayScanClient trayScanClient; @RabbitHandler @@ -57,6 +87,7 @@ public class OrderStatusHandler { log.info("##################orderStatusHandler: 处理扫码作业数据"); OrderStatusDTO orderStatusDTO = (OrderStatusDTO) map.get("messageData"); String orderSelfNum = orderStatusDTO.getOrderNo();//订单自编号 + String unitNo = orderStatusDTO.getUnitNo(); //通过订单自编号去查询该条订单是属于哪个工厂 AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderSelfNum); if (Objects.isNull(advanceEntity)) { @@ -111,5 +142,92 @@ public class OrderStatusHandler { log.info("##################orderStatusHandler: 未知品牌 type={}", type); } + + String status = orderStatusDTO.getStatus(); + if("2".equals(status)){ + String currentWarehouse = orderStatusDTO.getCurrentWarehouse(); + BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getWarehouseByOldId(Integer.parseInt(currentWarehouse)); + if(Objects.isNull(basicdataWarehouseEntity)){ + log.warn("####################orderStatusHandler: 仓库信息为空 basicdataWarehouseEntity={}",basicdataWarehouseEntity); + return; + } + Long warehouseId = basicdataWarehouseEntity.getId(); + Integer oldId = basicdataWarehouseEntity.getOldId(); + + Integer trayId = orderStatusDTO.getTrayId(); + if(Objects.isNull(trayId)){ + log.warn("####################orderStatusHandler: 托盘id为空 trayId={}",trayId); + return; + } + BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient.getTrayByTrayCode("T" + trayId); + if(Objects.isNull(basicdataTrayEntity)){ + log.info("############syncTrayTypeData: 托盘信息不存在"); + //如果托盘不存在就去同步该托盘 + TrayEntity trayEntity = trayClient.getTrayById(trayId); + basicdataTrayEntity = new BasicdataTrayEntity(); + basicdataTrayEntity.setTenantId("627683"); + basicdataTrayEntity.setCreateUser(1714696768639311873L); + basicdataTrayEntity.setUpdateUser(1714696768639311873L); + basicdataTrayEntity.setCreateDept(1649331096241836033L); + basicdataTrayEntity.setPalletName(trayEntity.getTrayNo()); + basicdataTrayEntity.setPalletCode("T"+trayEntity.getId()); + basicdataTrayEntity.setWarehouseId(warehouseId); + basicdataTrayEntity.setTrayStatus(trayEntity.getStatus()+""); + basicdataTrayEntity.setType(1); + basicdataTrayEntity.setOldId(trayId); +// basicdataTrayEntity.setNowWarehouseId(nowNewWarehouseId); + Long aLong = basicdataTrayClient.addTray(basicdataTrayEntity); + basicdataTrayEntity.setId(aLong); + } + + TrayScanDesEntity trayScanDesEntity = trayScanDesClient.findScanTypeId(trayId, unitNo, oldId); + if(Objects.isNull(trayScanDesEntity)){ + log.warn("####################orderStatusHandler: 没有打托数据 trayId={}",trayId); + return; + } + Integer trayScanId = trayScanDesEntity.getTrayScanId(); + TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayScanId(trayScanId); + if(Objects.isNull(trayScanEntity)){ + log.warn("####################orderStatusHandler: 没有打托方式数据 trayScanId={}",trayScanId); + return; + } + Integer trayType = trayScanEntity.getType(); + + String newTrayType = "100"; + if(1==trayType){ + newTrayType = "60"; + }else if(2==trayType){ + newTrayType = "30"; + }else if(3==trayType){ + newTrayType = "50"; + }else if(4==trayType){ + newTrayType = "100"; + }else if(5==trayType){ + newTrayType = "10"; + }else if(6==trayType){ + newTrayType = "20"; + } + + //判断托盘是否有上架 + Long allocationId = taryAllocationClient.findAllocationByTrayId(basicdataTrayEntity.getId()); + if(Objects.isNull(allocationId)){ + //没有上架就直接打托 + Map m = new HashMap<>(); + m.put("trayType",newTrayType); + m.put("trayCode","T"+trayId); + m.put("warehouseId",warehouseId); + m.put("orderPackageCode",unitNo); + + boolean b = warehouseTrayTypeClient.orderScanOrderPackageCode(m); + if(!b){ + log.warn("####################orderStatusHandler: 打托失败 unitNo={} trayCode={}",unitNo,"T"+trayId); + return; + } + }else{ + //有上架就上架 + updownTypeClient.upShelfPackage(unitNo,allocationId,warehouseId); + } + } + } } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java index 139bcac9b..6629aff5b 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/OrderClient.java @@ -86,4 +86,9 @@ public class OrderClient implements IOrderClient { public void updateStatusWithTableName(int isUpdate, String orderCode, String tableName) { orderService.updateStatusWithTableName(isUpdate,orderCode,tableName); } + + @Override + public List findAllTrayId(String tableName) { + return orderService.findAllTrayId(tableName); + } } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/TrayScanDesClient.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/TrayScanDesClient.java index f5d7b5b40..18022a8b1 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/TrayScanDesClient.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/TrayScanDesClient.java @@ -34,4 +34,9 @@ public class TrayScanDesClient implements ITrayScanDesClient { public TrayScanDesEntity findEntityByUnitNoAndWarehouseId(String unitNo, Integer oldWarehouseId) { return trayScanDesService.findEntityByUnitNoAndWarehouseId(unitNo,oldWarehouseId); } + + @Override + public List findListByTrayId(Integer trayId, Integer oldWarehouseId) { + return trayScanDesService.findListByTrayId(trayId,oldWarehouseId); + } } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java index e1129adfe..b656923f8 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.java @@ -45,4 +45,6 @@ public interface OrderMapper extends BaseMapper { List findOrderCodeListByPageWithInventoryId(@Param("param") String param, @Param("oldWarehouseId") Integer oldWarehouseId, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize); void updateStatusWithTableName(@Param("isUpdate") int isUpdate, @Param("orderCode") String orderCode, @Param("tableName") String tableName); + + List findAllTrayId(@Param("tableName") String tableName); } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml index 6e5d2952d..641369922 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/OrderMapper.xml @@ -127,4 +127,10 @@ where order_code = #{orderCode} + + diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java index 2c2459d1f..9cff1af58 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IOrderService.java @@ -25,4 +25,6 @@ public interface IOrderService { List findOrderCodeListByPageWithInventoryId(String param, Integer oldWarehouseId, Integer pageNum, Integer pageSize); void updateStatusWithTableName(int isUpdate, String orderCode, String tableName); + + List findAllTrayId(String tableName); } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/ITrayScanDesService.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/ITrayScanDesService.java index ed516666a..c0eb06ecb 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/ITrayScanDesService.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/ITrayScanDesService.java @@ -12,4 +12,6 @@ public interface ITrayScanDesService { TrayScanDesEntity findScanTypeId(Integer trayId, String unitNo, Integer oldWarehouseId); TrayScanDesEntity findEntityByUnitNoAndWarehouseId(String unitNo, Integer oldWarehouseId); + + List findListByTrayId(Integer trayId, Integer oldWarehouseId); } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java index fa327456e..e54bc3aad 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/OrderServiceImpl.java @@ -73,4 +73,9 @@ public class OrderServiceImpl implements IOrderService { public void updateStatusWithTableName(int isUpdate, String orderCode, String tableName) { orderMapper.updateStatusWithTableName(isUpdate,orderCode,tableName); } + + @Override + public List findAllTrayId(String tableName) { + return orderMapper.findAllTrayId(tableName); + } } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/TrayScanDesServiceImpl.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/TrayScanDesServiceImpl.java index a7e2a888f..b26981653 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/TrayScanDesServiceImpl.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/TrayScanDesServiceImpl.java @@ -47,4 +47,13 @@ public class TrayScanDesServiceImpl implements ITrayScanDesService { .eq("unitNo",unitNo); return trayScanDesMapper.selectOne(queryWrapper); } + + @Override + public List findListByTrayId(Integer trayId, Integer oldWarehouseId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("now_warehouse_id",oldWarehouseId) + .eq("type",1) + .eq("trayId",trayId); + return trayScanDesMapper.selectList(queryWrapper); + } } 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 bfb6ed9f9..7ac90fa94 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 @@ -488,8 +488,9 @@ public class SyncOrderInfoToPlatform { for (WarehouseMappingDataEntity entity:warehouseMappingDataEntityList){ Integer oldWarehouseId = entity.getOldWarehouseId(); Long newWarehouseId = entity.getNewWarehouseId(); + String tableName = entity.getTableName(); - syncOrderInfoService.syncTrayType(oldWarehouseId,newWarehouseId); + syncOrderInfoService.syncTrayType(oldWarehouseId,newWarehouseId,tableName); } }catch (CustomerException e){ log.error(e.message,e); diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java index cb63a28c3..3ec9b173a 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncOrderInfoService.java @@ -7,7 +7,7 @@ public interface ISyncOrderInfoService { void handleDataZero(List orderCodeList, Integer oldWarehouseId, Long newWarehouseId); - void syncTrayType(Integer oldWarehouseId,Long newWarehouseId); + void syncTrayType(Integer oldWarehouseId,Long newWarehouseId,String tableName); void addTrayType(Integer oldWarehouseId, Long newWarehouseId); diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java index e88bd06bc..f10030e5f 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncOrderInfoServiceImpl.java @@ -224,10 +224,17 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { } @Override - public void syncTrayType(Integer oldWarehouseId,Long newWarehouseId) { + public void syncTrayType(Integer oldWarehouseId,Long newWarehouseId,String tableName) { - saveTrayTypeInfoPackageNew(null,oldWarehouseId,newWarehouseId,null); + List trayIds = orderClient.findAllTrayId(tableName); + do { + for (String trayId:trayIds){ + saveTrayTypeInfoPackage(oldWarehouseId,newWarehouseId,trayId); + orderClient.updateStatusWithTableName(1,trayId,tableName); + } + trayIds = orderClient.findAllTrayId(tableName); + }while (trayIds.size() > 0); } @Override @@ -1849,7 +1856,6 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { private void saveTrayTypeInfoPackageNew(String orderCode,Integer oldWarehouseId, Long newWarehouseId,Integer inventoryId) { - List ls = inventoryDetailClient.findAllTrayType(orderCode,inventoryId); for (InventoryDetailEntity entity:ls){ @@ -1926,4 +1932,80 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { } + + + private void saveTrayTypeInfoPackage(Integer oldWarehouseId, Long newWarehouseId,String trayId) { + + + TrayScanEntity trayScanEntity = null; + List trayScanDesEntities = trayScanDesClient.findListByTrayId(Integer.parseInt(trayId),oldWarehouseId); + for (TrayScanDesEntity trayScanDesEntity : trayScanDesEntities) { + if (Objects.isNull(trayScanEntity)) { + Integer trayScanId = trayScanDesEntity.getTrayScanId(); + trayScanEntity = trayScanClient.getEntityByTrayScanId(trayScanId); + } + Integer type = trayScanEntity.getType(); + String unitNo = trayScanDesEntity.getUnitNo(); + DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCodeAndWarehouseId(unitNo, newWarehouseId); + if(Objects.isNull(parcelListEntity)){ + log.info("###########saveTrayTypeInfoPackage: 包条不在库内,不同步 unitNo={} newWarehouseId={}",unitNo,newWarehouseId); + continue; + } + //判断托盘是否已经存在 + BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient.getTrayByTrayCode("T" + trayId); + if(Objects.isNull(basicdataTrayEntity)){ + log.info("############syncTrayTypeData: 托盘信息不存在"); + //如果托盘不存在就去同步该托盘 + TrayEntity trayEntity = trayClient.getTrayById(Integer.parseInt(trayId)); + basicdataTrayEntity = new BasicdataTrayEntity(); + basicdataTrayEntity.setTenantId("627683"); + basicdataTrayEntity.setCreateUser(1714696768639311873L); + basicdataTrayEntity.setUpdateUser(1714696768639311873L); + basicdataTrayEntity.setCreateDept(1649331096241836033L); + basicdataTrayEntity.setPalletName(trayEntity.getTrayNo()); + basicdataTrayEntity.setPalletCode("T"+trayEntity.getId()); + basicdataTrayEntity.setWarehouseId(newWarehouseId); + basicdataTrayEntity.setTrayStatus(trayEntity.getStatus()+""); + basicdataTrayEntity.setType(1); + basicdataTrayEntity.setOldId(Integer.parseInt(trayId)); +// basicdataTrayEntity.setNowWarehouseId(nowNewWarehouseId); + basicdataTrayClient.addTray(basicdataTrayEntity); + } + + //方式:1=仓,2=商场,3=客户,4=其他,5=服务号,6=合同号 + //方式:60=仓,30=商场,50=客户,100=其他,10=服务号,20=合同号 + String newTrayType = "100"; + if(1==type){ + newTrayType = "60"; + }else if(2==type){ + newTrayType = "30"; + }else if(3==type){ + newTrayType = "50"; + }else if(4==type){ + newTrayType = "100"; + }else if(5==type){ + newTrayType = "10"; + }else if(6==type){ + newTrayType = "20"; + } + + Map map = new HashMap<>(); + map.put("trayType",newTrayType); + map.put("trayCode","T"+trayId); + map.put("warehouseId",newWarehouseId); + map.put("orderPackageCode",unitNo); + + //新系统保存打托方式 + boolean b = warehouseTrayTypeClient.orderScanOrderPackageCode(map); + + if(!b){ + log.error("################saveTrayTypeInfo: 包件打托失败 unitNo={} trayCode={}",unitNo,"T"+trayId); +// throw new CustomerException(403,"包件打托失败"); + } + + } + + } + + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/OldSystemPushController.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/OldSystemPushController.java index 0c8b05d83..3d8ce9677 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/OldSystemPushController.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/OldSystemPushController.java @@ -1,10 +1,15 @@ package com.logpm.warehouse.controller; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.warehouse.dto.WaybillDTO; import com.logpm.warehouse.entity.WarehouseLog; +import com.logpm.warehouse.entity.WarehouseTrayTypeEntity; import com.logpm.warehouse.service.IWarehouseLogService; +import com.logpm.warehouse.service.IWarehouseTaryAllocationService; +import com.logpm.warehouse.service.IWarehouseTrayTypeService; +import com.logpm.warehouse.service.IWarehouseUpdownTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; @@ -17,10 +22,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 老系统推送数据;(logpm_mainline_waybill)表控制层 @@ -34,6 +36,9 @@ import java.util.Map; @RequestMapping("/oldpush") public class OldSystemPushController { + private final IWarehouseTrayTypeService trayTypeService; + private final IWarehouseUpdownTypeService updownTypeService; + private final IWarehouseTaryAllocationService taryAllocationService; private final IWarehouseLogService warehouseLogService; private final RabbitTemplate rabbitTemplate; @@ -77,70 +82,58 @@ public class OldSystemPushController { } } -// @PostMapping("/splitOrder") -// @ResponseBody -// @ApiOperationSupport(order = 8) -// @ApiOperation(value = "拆单", notes = "传入ids") -// public R splitOrder(@RequestBody List splitOrderDTOList) { -// //先查询运单数据 -// if(splitOrderDTOList.size() < 1){ -// log.warn("################splitOrder: 没有拆单数据"); -// return R.fail(405,"没有拆单数据"); -// } -// String waybillNo = splitOrderDTOList.get(0).getWaybillNo();//运单号 -// //查询运单 -// WarehouseWaybillEntity warehouseWaybillEntity = warehouseWaybillService.findByWaybillNo(waybillNo); -// if(Objects.isNull(warehouseWaybillEntity)){ -// log.warn("################splitOrder: 未找到运单信息 waybillNo={}",waybillNo); -// return R.fail(405,"未找到运单信息"); -// } -// Integer totalCount = warehouseWaybillEntity.getTotalCount();//包件总数量 -// Integer stockCount = warehouseWaybillEntity.getStockCount();//包件在库数量 -// //如果在库数量不等总数量 则不能进行拆单 -// if(!totalCount.equals(stockCount)){ -// log.warn("################splitOrder: 在库数量不等于总数量,不能拆单 waybillNo={}",waybillNo); -// return R.fail(405,"在库数量不等于总数量"); -// } -// //判断运单对应的订单是否已经 -// DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findByOrderSelfNum(waybillNo); -// if(Objects.isNull(distributionStockArticleEntity)){ -// log.warn("################splitOrder: 当前在库订单已转库存品,不能拆单 waybillNo={}",waybillNo); -// return R.fail(405,"当前在库订单已转库存品"); -// } -// Integer state = distributionStockArticleEntity.getState();//订单状态 -// Long orderId = distributionStockArticleEntity.getId();//订单id -// if(!state.equals(1)){ -// log.warn("################splitOrder: 当前在库订单已进入配送流程,不能拆单 waybillNo={}",waybillNo); -// return R.fail(405,"当前在库订单已进入配送流程"); -// } -// //判断拆单后的数值是否等于总数量 -// Integer total = new Integer("0"); -// for (SplitOrderDTO splitOrderDTO:splitOrderDTOList){ -// List products = splitOrderDTO.getProducts(); -// for (ProductDTO productDTO:products){ -// total = total + productDTO.getNum(); -// } -// } -// if(!totalCount.equals(total)){ -// log.warn("################splitOrder: 拆单数量不等于总数量 waybillNo={}",waybillNo); -// return R.fail(405,"拆单数量不等于总数量"); -// } -// -// try{ -// //拆单操作 -// warehouseWaybillService.splitOrder(splitOrderDTOList,distributionStockArticleEntity); -// //拆单完成去把以前的订单逻辑删除 -// distributionStockArticleClient.deleteById(orderId); -// -// return R.success("拆单成功"); -// }catch (CustomerException e){ -// log.warn(e.message); -// return R.fail(e.code,e.message); -// }catch (Exception e){ -// log.warn("系统出现异常",e); -// return R.fail(500,"系统出现异常"); -// } -// } + @ResponseBody + @PostMapping("/sendTrayIdToNullTray") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "空置托盘", notes = "传入waybillDTO") + public R sendTrayIdToNullTray(@RequestBody Map map) { + log.info("############sendTrayIdToNullTray: 请求参数{}",map); + try{ + + Integer trayId = map.get("trayId"); + + //先保存原始请求数据 + WarehouseLog warehouseLog = new WarehouseLog(); + warehouseLog.setArgs(JSONObject.toJSONString(map)); + warehouseLog.setStatus(1); + warehouseLog.setType(1); + warehouseLogService.save(warehouseLog); + + //先判断托盘有没有数据 + QueryWrapper trayTypeQueryWrapper = new QueryWrapper<>(); + trayTypeQueryWrapper.eq("tray_code","T"+trayId) + .eq("is_deleted",0); + WarehouseTrayTypeEntity trayTypeEntity = trayTypeService.getOne(trayTypeQueryWrapper); + if(Objects.isNull(trayTypeEntity)){ + log.warn("#############sendTrayIdToNullTray: 托盘暂无打托数据 trayId={}",trayId); + return R.fail(405,"托盘暂无打托数据"); + } + + //判断托盘有无上架 + Long newTrayId = trayTypeEntity.getTrayId(); + Long warehouseId = trayTypeEntity.getWarehouseId(); + Long allocationEntity = taryAllocationService.getAllocationIdByTrayId(newTrayId); + if(Objects.isNull(allocationEntity)){ + //没有上架,直接空置 + trayTypeService.trayToNull("T"+trayId); + }else{ + //有上架,先下架,再空置 + updownTypeService.downTrayCode("T"+trayId,warehouseId); + trayTypeService.trayToNull("T"+trayId); + } + return R.success("调用成功"); + }catch (CustomerException e){ + log.error(e.message,e); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error("############sendOrders: 系统异常",e); + return R.fail(500,"############sendOrders: 系统异常"); + } + } + + + + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseTaryAllocationClient.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseTaryAllocationClient.java index e3605e24d..06310990c 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseTaryAllocationClient.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/feign/WarehouseTaryAllocationClient.java @@ -29,4 +29,10 @@ public class WarehouseTaryAllocationClient implements IWarehouseTaryAllocationCl .eq(WarehouseTaryAllocationEntity::getBindStatus , "1") ); } + + @Override + public Long findAllocationByTrayId(Long trayId) { + Long allocationId = warehouseTaryAllocationService.getAllocationIdByTrayId(trayId); + return allocationId; + } }