From 19487df1adacce54e7aca9efcaa83e974dce4c4e Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Fri, 20 Oct 2023 19:39:22 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=90=8C=E6=AD=A5=E8=80=81=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E4=BB=BB=E5=8A=A1=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4,=E5=B7=B2=E5=AE=8C=E6=88=90=202.=E8=80=81=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=89=AB=E6=8F=8F=E5=80=92=E8=BD=A6=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E8=AE=A2=E5=8D=95=E6=8B=89=E5=8F=96=E6=89=98?= =?UTF-8?q?=E7=9B=98=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oldproject/entity/InventoryEntity.java | 48 ++++++ .../oldproject/feign/IInventoryClient.java | 22 +++ .../feign/IInventoryDetailClient.java | 6 +- .../oldproject/feign/ITrayScanDesClient.java | 3 + .../com/logpm/patch/dto/SyncInventoryDTO.java | 5 + .../patch/entity/OrderSyncRecordEntity.java | 1 + .../patch/entity/SyncInventoryEntity.java | 17 +++ .../entity/WarehouseMappingDataEntity.java | 2 + .../impl/PanFactoryDataServiceImpl.java | 70 ++++++++- .../oldproject/feign/InventoryClient.java | 20 +++ .../feign/InventoryDetailClient.java | 12 +- .../oldproject/feign/TrayScanDesClient.java | 5 + .../mapper/InventoryDetailMapper.java | 6 +- .../mapper/InventoryDetailMapper.xml | 8 +- .../oldproject/mapper/InventoryMapper.java | 12 ++ .../service/IInventoryDetailService.java | 7 +- .../oldproject/service/IInventoryService.java | 7 + .../service/ITrayScanDesService.java | 2 + .../impl/InventoryDetailServiceImpl.java | 13 +- .../service/impl/InventoryServiceImpl.java | 25 ++++ .../service/impl/TrayScanDesServiceImpl.java | 9 ++ .../controller/SyncInventoryController.java | 89 +++++++---- .../jobhandle/SyncOrderInfoToPlatform.java | 3 +- .../patch/mapper/SyncInventoryMapper.java | 5 + .../patch/mapper/SyncInventoryMapper.xml | 17 +++ .../patch/service/IAsyncDataService.java | 10 ++ .../patch/service/ISyncInventoryService.java | 8 + .../patch/service/ISyncOrderInfoService.java | 2 +- .../service/impl/AsyncDataServiceImpl.java | 139 ++++++++++++++++++ .../impl/SyncInventoryServiceImpl.java | 81 ++++++++++ .../impl/SyncOrderInfoServiceImpl.java | 56 ++++--- 31 files changed, 629 insertions(+), 81 deletions(-) create mode 100644 blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/InventoryEntity.java create mode 100644 blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryClient.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryClient.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryMapper.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryService.java create mode 100644 blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryServiceImpl.java create mode 100644 blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.xml create mode 100644 blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IAsyncDataService.java create mode 100644 blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/AsyncDataServiceImpl.java diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/InventoryEntity.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/InventoryEntity.java new file mode 100644 index 000000000..59aaca96b --- /dev/null +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/entity/InventoryEntity.java @@ -0,0 +1,48 @@ +package com.logpm.oldproject.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.Date; + +@Data +@TableName("ht_inventory") +@ApiModel(value = "Inventory对象", description = "盘点任务") +public class InventoryEntity { + + @TableId( + value = "id", + type = IdType.AUTO + ) + private Integer id; + + private String no; + + private Integer storeId; + + private String storeName; + + private String brandId; + + private String brand; + + private Date startDate; + + private Date endDate; + + private Integer administratorsId; + + private Integer warehouseId; + + private Integer status; + + private Date createTime; + + private Date updateTime; + + private Integer deleteTime; + +} diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryClient.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryClient.java new file mode 100644 index 000000000..a5fa28966 --- /dev/null +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryClient.java @@ -0,0 +1,22 @@ +package com.logpm.oldproject.feign; + +import com.logpm.oldproject.entity.InventoryEntity; +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.RequestParam; + +@FeignClient( + value = ModuleNameConstant.APPLICATION_OLDPROJECT_NAME +) +public interface IInventoryClient { + + String API_PREFIX = "/inventory/client"; + + @GetMapping(API_PREFIX + "/findEntityByWarehouseIdAndNo") + InventoryEntity findEntityByWarehouseIdAndNo(@RequestParam Integer oldId, @RequestParam String inventoryNo); + + +// @GetMapping(API_PREFIX + "/getEntityByOrderCode") +// OrderCountEntity getEntityByOrderCode(@RequestParam String orderCode, @RequestParam Integer oldWarehouseId); +} diff --git a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryDetailClient.java b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryDetailClient.java index 37df9c604..64e37415f 100644 --- a/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryDetailClient.java +++ b/blade-service-api/logpm-old-project-api/src/main/java/com/logpm/oldproject/feign/IInventoryDetailClient.java @@ -16,13 +16,13 @@ public interface IInventoryDetailClient { String API_PREFIX = "/inventoryDetail/client"; @GetMapping(API_PREFIX + "/findOrderIsExist") - InventoryDetailEntity findOrderIsExist(@RequestParam String orderCode); + InventoryDetailEntity findOrderIsExist(@RequestParam String orderCode,@RequestParam Integer inventoryId); @GetMapping(API_PREFIX + "/findUnitNoIsExist") - InventoryDetailEntity findUnitNoIsExist(@RequestParam String unitNo); + InventoryDetailEntity findUnitNoIsExist(@RequestParam String unitNo,@RequestParam Integer inventoryId); @GetMapping(API_PREFIX + "/findAllTrayType") - List findAllTrayType(); + List findAllTrayType(@RequestParam String orderCode,@RequestParam Integer inventoryId); // @GetMapping(API_PREFIX + "/getEntityByOrderCode") 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 1a0fb970d..8f9ac1d19 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 @@ -24,6 +24,9 @@ public interface ITrayScanDesClient { @GetMapping(API_PREFIX + "/findScanTypeId") TrayScanDesEntity findScanTypeId(@RequestParam Integer trayId, @RequestParam String unitNo, @RequestParam Integer oldWarehouseId); + @GetMapping(API_PREFIX + "/findEntityByUnitNoAndWarehouseId") + TrayScanDesEntity findEntityByUnitNoAndWarehouseId(@RequestParam String unitNo, @RequestParam Integer oldWarehouseId); + // @GetMapping(API_PREFIX + "/getEntityByOrderCode") // OrderCountEntity getEntityByOrderCode(@RequestParam String orderCode, @RequestParam Integer oldWarehouseId); } diff --git a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/dto/SyncInventoryDTO.java b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/dto/SyncInventoryDTO.java index 9602769e7..d86f792ca 100644 --- a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/dto/SyncInventoryDTO.java +++ b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/dto/SyncInventoryDTO.java @@ -7,6 +7,11 @@ import java.io.Serializable; @Data public class SyncInventoryDTO implements Serializable { + private Integer pageNum; + private Integer pageSize; + private String inventoryNo;//盘点任务编码 + + private Long warehouseId; } diff --git a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/OrderSyncRecordEntity.java b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/OrderSyncRecordEntity.java index ae11fd2cc..18a154abd 100644 --- a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/OrderSyncRecordEntity.java +++ b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/OrderSyncRecordEntity.java @@ -17,5 +17,6 @@ public class OrderSyncRecordEntity extends BaseEntity { private Integer finishNum; private Integer syncStatus; private Integer type; + private Integer inventoryId; } diff --git a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/SyncInventoryEntity.java b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/SyncInventoryEntity.java index 6b6821b5a..48b86cff6 100644 --- a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/SyncInventoryEntity.java +++ b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/SyncInventoryEntity.java @@ -1,11 +1,13 @@ package com.logpm.patch.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; +import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; @@ -50,9 +52,21 @@ public class SyncInventoryEntity extends TenantEntity { private Integer inventoryId; @ApiModelProperty(value = "同步开始时间") + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) private Date syncStartDate; @ApiModelProperty(value = "同步结束时间") + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) private Date syncEndDate; @ApiModelProperty(value = "同步状态 0未开始 1同步中 2同步完成 3同步异常") @@ -64,4 +78,7 @@ public class SyncInventoryEntity extends TenantEntity { @ApiModelProperty(value = "老系统仓库id") private Integer oldWarehouseId; + @ApiModelProperty(value = "仓库名称") + private String warehouseName; + } diff --git a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/WarehouseMappingDataEntity.java b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/WarehouseMappingDataEntity.java index 79981bba3..53593f0d7 100644 --- a/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/WarehouseMappingDataEntity.java +++ b/blade-service-api/logpm-patch-api/src/main/java/com/logpm/patch/entity/WarehouseMappingDataEntity.java @@ -21,4 +21,6 @@ public class WarehouseMappingDataEntity { private Long newWarehouseId; + private Integer inventoryId; + } diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java index b3531f93c..8a9817232 100644 --- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java +++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/pan/service/impl/PanFactoryDataServiceImpl.java @@ -35,12 +35,11 @@ import com.logpm.factory.snm.entity.OrderStatusLog; import com.logpm.factory.snm.entity.PanFactoryOrder; import com.logpm.factory.snm.entity.PanPackageInfo; import com.logpm.factory.snm.entity.PanPackageList; -import com.logpm.oldproject.entity.AdvanceDetailEntity; -import com.logpm.oldproject.entity.AdvanceEntity; -import com.logpm.oldproject.entity.WayBillEntity; +import com.logpm.oldproject.entity.*; import com.logpm.oldproject.feign.*; import com.logpm.oldproject.vo.DistributionParcelListEntityVO; import com.logpm.warehouse.entity.WarehouseWaybillEntity; +import com.logpm.warehouse.feign.IWarehouseTrayTypeClient; import com.logpm.warehouse.feign.IWarehouseWaybillClient; import lombok.AllArgsConstructor; import org.slf4j.Logger; @@ -90,6 +89,10 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { private final IBasicMaterialClient basicMaterialClient; + private final ITrayScanDesClient trayScanDesClient; + private final ITrayScanClient trayScanClient; + private final IWarehouseTrayTypeClient warehouseTrayTypeClient; + // @Override // public FactoryTokenVO getToken(String corpId, String appKey, String appSecret) throws NoSuchAlgorithmException { // @@ -365,6 +368,10 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { // 查询数据对应的仓库名称 BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.findByName(destinationWarehouse); + if(Objects.isNull(basicdataWarehouseEntity)){ + logger.warn("############handleDataToPlatform: 仓库信息不存在 destinationWarehouse={}",destinationWarehouse); + throw new CustomerException(405, "仓库信息不存在"); + } //判断新系统是否有这条订单数据 DistributionStockArticleEntity distributionStockArticleEntity = distributionStockArticleClient.findByAdvanceId(advanceId); @@ -507,6 +514,15 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { //保存包件信息 saveOrderPackage(unitNo, distributionStockArticleEntity, basicdataWarehouseEntity, waybillNoNum,operationTime); + //---------------------2023-10-20 17:23:00 增加打托数据 + Integer oldId = basicdataWarehouseEntity.getOldId(); + Long warehouseEntityId = basicdataWarehouseEntity.getId(); + try{ + saveTrayTypeInfoPackage(unitNo,oldId,warehouseEntityId); + }catch (Exception e){ + logger.error("################handleDataToPlatform: unitNo={} 打托失败",unitNo); + } + String waybillNumber = distributionStockArticleEntity.getWaybillNumber(); if(!waybillNumber.contains(waybillNoNum)){ waybillNumber = waybillNumber+","+waybillNoNum; @@ -538,6 +554,54 @@ public class PanFactoryDataServiceImpl implements IPanFactoryDataService { } } + private void saveTrayTypeInfoPackage(String unitNo,Integer oldWarehouseId,Long newWarehouseId) { + + //如果是订制品就先查询该订单有哪些包件打了托 + TrayScanDesEntity entity = trayScanDesClient.findEntityByUnitNoAndWarehouseId(unitNo,oldWarehouseId); + + Integer trayScanId = entity.getTrayScanId(); + + //查询打托方式信息 + TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayScanId(trayScanId); + Integer type = trayScanEntity.getType(); + Integer trayId = trayScanEntity.getTrayId(); + String customerName = trayScanEntity.getCustomerName(); + String customerPhone = trayScanEntity.getCustomerPhone(); + + //方式: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){ + logger.error("################saveTrayTypeInfoPackage: 包件打托失败 unitNo={} trayCode={}",unitNo,"T"+trayId); +// throw new CustomerException(403,"包件打托失败"); + } + + } + + /** * 根据订单的在库数联返回订单的状态 * @param distributionStockArticleEntity 订单对象 diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryClient.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryClient.java new file mode 100644 index 000000000..39f800e78 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryClient.java @@ -0,0 +1,20 @@ +package com.logpm.oldproject.feign; + +import com.logpm.oldproject.entity.InventoryEntity; +import com.logpm.oldproject.service.IInventoryService; +import lombok.AllArgsConstructor; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +@ApiIgnore() +@RestController +@AllArgsConstructor +public class InventoryClient implements IInventoryClient{ + + private final IInventoryService inventoryService; + + @Override + public InventoryEntity findEntityByWarehouseIdAndNo(Integer oldId, String inventoryNo) { + return inventoryService.findEntityByWarehouseIdAndNo(oldId,inventoryNo); + } +} diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryDetailClient.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryDetailClient.java index 5a0c0f8b3..4680e9ac3 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryDetailClient.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/feign/InventoryDetailClient.java @@ -16,17 +16,17 @@ public class InventoryDetailClient implements IInventoryDetailClient{ private final IInventoryDetailService inventoryDetailService; @Override - public InventoryDetailEntity findOrderIsExist(String orderCode) { - return inventoryDetailService.findOrderIsExist(orderCode); + public InventoryDetailEntity findOrderIsExist(String orderCode,Integer inventoryId) { + return inventoryDetailService.findOrderIsExist(orderCode,inventoryId); } @Override - public InventoryDetailEntity findUnitNoIsExist(String unitNo) { - return inventoryDetailService.findUnitNoIsExist(unitNo); + public InventoryDetailEntity findUnitNoIsExist(String unitNo,Integer inventoryId) { + return inventoryDetailService.findUnitNoIsExist(unitNo,inventoryId); } @Override - public List findAllTrayType() { - return inventoryDetailService.findAllTrayType(); + public List findAllTrayType(String orderCode,Integer inventoryId) { + return inventoryDetailService.findAllTrayType(orderCode,inventoryId); } } 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 2dbd072e2..f5d7b5b40 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 @@ -29,4 +29,9 @@ public class TrayScanDesClient implements ITrayScanDesClient { public TrayScanDesEntity findScanTypeId(Integer trayId, String unitNo, Integer oldWarehouseId) { return trayScanDesService.findScanTypeId(trayId,unitNo,oldWarehouseId); } + + @Override + public TrayScanDesEntity findEntityByUnitNoAndWarehouseId(String unitNo, Integer oldWarehouseId) { + return trayScanDesService.findEntityByUnitNoAndWarehouseId(unitNo,oldWarehouseId); + } } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.java index d4d8fb82a..2520f48db 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.java @@ -9,9 +9,9 @@ import java.util.List; @Mapper public interface InventoryDetailMapper extends BaseMapper { - InventoryDetailEntity findOrderIsExist(@Param("orderCode") String orderCode); + InventoryDetailEntity findOrderIsExist(@Param("orderCode") String orderCode,@Param("inventoryId") Integer inventoryId); - InventoryDetailEntity findUnitNoIsExist(@Param("unitNo") String unitNo); + InventoryDetailEntity findUnitNoIsExist(@Param("unitNo") String unitNo,@Param("inventoryId") Integer inventoryId); - List findAllTrayType(); + List findAllTrayType(@Param("orderCode") String orderCode,@Param("inventoryId") Integer inventoryId); } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.xml b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.xml index 0c4f47036..e363ddc06 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.xml +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryDetailMapper.xml @@ -5,7 +5,7 @@ select * from ht_inventory_detail - where inventory_id in (185,187,188,189) + where inventory_id = #{inventoryId} and unitNo = #{unitNo} and status = 2 and delete_time = 0 @@ -27,14 +27,14 @@ select unitNo unitNo, tray_id trayId from ht_inventory_detail - where inventory_id in (185,187,188,189) + where inventory_id = #{inventoryId} + and orderSelfNum = #{orderCode} and tray_id != 0 and unitNo != '10215486=027916' and status = 2 and delete_time = 0 group by unitNo, tray_id - diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryMapper.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryMapper.java new file mode 100644 index 000000000..5ec665959 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/mapper/InventoryMapper.java @@ -0,0 +1,12 @@ +package com.logpm.oldproject.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.logpm.oldproject.entity.InventoryEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface InventoryMapper extends BaseMapper { + + + +} diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryDetailService.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryDetailService.java index 7868d177e..311cd840d 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryDetailService.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryDetailService.java @@ -7,9 +7,10 @@ import java.util.List; public interface IInventoryDetailService { - InventoryDetailEntity findOrderIsExist(String orderCode); + InventoryDetailEntity findOrderIsExist(String orderCode,Integer inventoryId); - InventoryDetailEntity findUnitNoIsExist(String unitNo); + InventoryDetailEntity findUnitNoIsExist(String unitNo,Integer inventoryId); + + List findAllTrayType(String orderCode,Integer inventoryId); - List findAllTrayType(); } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryService.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryService.java new file mode 100644 index 000000000..3f6e61444 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/IInventoryService.java @@ -0,0 +1,7 @@ +package com.logpm.oldproject.service; + +import com.logpm.oldproject.entity.InventoryEntity; + +public interface IInventoryService { + InventoryEntity findEntityByWarehouseIdAndNo(Integer oldId, String inventoryNo); +} 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 d1a838314..ed516666a 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 @@ -10,4 +10,6 @@ public interface ITrayScanDesService { List findZeroListByOrderCodeAndWarehouseId(String orderCode, Integer oldWarehouseId); TrayScanDesEntity findScanTypeId(Integer trayId, String unitNo, Integer oldWarehouseId); + + TrayScanDesEntity findEntityByUnitNoAndWarehouseId(String unitNo, Integer oldWarehouseId); } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryDetailServiceImpl.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryDetailServiceImpl.java index 93a4b3934..85558e046 100644 --- a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryDetailServiceImpl.java +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryDetailServiceImpl.java @@ -15,17 +15,18 @@ public class InventoryDetailServiceImpl implements IInventoryDetailService { private final InventoryDetailMapper inventoryDetailMapper; @Override - public InventoryDetailEntity findOrderIsExist(String orderCode) { - return inventoryDetailMapper.findOrderIsExist(orderCode); + public InventoryDetailEntity findOrderIsExist(String orderCode,Integer inventoryId) { + return inventoryDetailMapper.findOrderIsExist(orderCode,inventoryId); } @Override - public InventoryDetailEntity findUnitNoIsExist(String unitNo) { - return inventoryDetailMapper.findUnitNoIsExist(unitNo); + public InventoryDetailEntity findUnitNoIsExist(String unitNo,Integer inventoryId) { + return inventoryDetailMapper.findUnitNoIsExist(unitNo,inventoryId); } @Override - public List findAllTrayType() { - return inventoryDetailMapper.findAllTrayType(); + public List findAllTrayType(String orderCode,Integer inventoryId) { + return inventoryDetailMapper.findAllTrayType(orderCode,inventoryId); } + } diff --git a/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryServiceImpl.java b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryServiceImpl.java new file mode 100644 index 000000000..4f33a8568 --- /dev/null +++ b/blade-service/logpm-old-project/src/main/java/com/logpm/oldproject/service/impl/InventoryServiceImpl.java @@ -0,0 +1,25 @@ +package com.logpm.oldproject.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.oldproject.entity.InventoryEntity; +import com.logpm.oldproject.mapper.InventoryMapper; +import com.logpm.oldproject.service.IInventoryService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@AllArgsConstructor +public class InventoryServiceImpl implements IInventoryService { + + private final InventoryMapper inventoryMapper; + + @Override + public InventoryEntity findEntityByWarehouseIdAndNo(Integer oldId, String inventoryNo) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("warehouse_id",oldId) + .eq("no",inventoryNo) + .eq("delete_time",0); + return inventoryMapper.selectOne(queryWrapper); + } + +} 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 9f04c9eb1..a7e2a888f 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 @@ -38,4 +38,13 @@ public class TrayScanDesServiceImpl implements ITrayScanDesService { .eq("unitNo",unitNo); return trayScanDesMapper.selectOne(queryWrapper); } + + @Override + public TrayScanDesEntity findEntityByUnitNoAndWarehouseId(String unitNo, Integer oldWarehouseId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("now_warehouse_id",oldWarehouseId) + .eq("type",1) + .eq("unitNo",unitNo); + return trayScanDesMapper.selectOne(queryWrapper); + } } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/controller/SyncInventoryController.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/controller/SyncInventoryController.java index aad12529c..2f5533797 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/controller/SyncInventoryController.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/controller/SyncInventoryController.java @@ -16,12 +16,24 @@ */ package com.logpm.patch.controller; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.patch.dto.SyncInventoryDTO; +import com.logpm.patch.entity.SyncInventoryEntity; import com.logpm.patch.service.ISyncInventoryService; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.common.exception.CustomerException; import org.springblade.core.boot.ctrl.BladeController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; +import org.springframework.web.bind.annotation.*; + +import java.util.Objects; /** * 库存品条码记录表 控制器 @@ -29,6 +41,7 @@ import org.springframework.web.bind.annotation.RestController; * @author zhy * @since 2023-10-20 */ +@Slf4j @RestController @AllArgsConstructor @RequestMapping("/syncInventory") @@ -36,39 +49,61 @@ import org.springframework.web.bind.annotation.RestController; public class SyncInventoryController extends BladeController { private final ISyncInventoryService syncInventoryService; + private final IBasicdataWarehouseClient warehouseClient; /** - * 库存品条码记录表 详情 - */ -// @GetMapping("/detail") -// @ApiOperationSupport(order = 1) -// @ApiOperation(value = "详情", notes = "传入disStockListDetail") -// public R detail(DisStockListDetailEntity disStockListDetail) { -// DisStockListDetailEntity detail = disStockListDetailService.getOne(Condition.getQueryWrapper(disStockListDetail)); -// return R.data(detail); -// } - /** - * 库存品条码记录表 分页 + * 同步老系统盘点数据 分页 */ -// @PostMapping("/list") -// @ApiOperationSupport(order = 2) -// @ApiOperation(value = "分页", notes = "传入disStockListDetail") -// public R> list(@RequestParam SyncInventoryDTO syncInventoryDTO) { -// IPage pages = syncInventoryService.page(Condition.getPage(query), Condition.getQueryWrapper(disStockListDetail, DisStockListDetailEntity.class)); -// return R.data(pages); -// } + @ResponseBody + @PostMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入disStockListDetail") + public R> list(@RequestBody SyncInventoryDTO syncInventoryDTO) { + String method = "############list: "; + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + syncInventoryDTO.setWarehouseId(myCurrentWarehouse.getId()); + IPage pages = syncInventoryService.pageList(syncInventoryDTO); + return R.data(pages); + } /** - * 库存品条码记录表 新增或修改 + * 同步老系统盘点数据 新增或修改 */ -// @PostMapping("/submit") -// @ApiOperationSupport(order = 6) -// @ApiOperation(value = "新增或修改", notes = "传入disStockListDetail") -// public R submit(@Valid @RequestBody DisStockListDetailEntity disStockListDetail) { -// return R.status(disStockListDetailService.saveOrUpdate(disStockListDetail)); -// } + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增或修改", notes = "传入disStockListDetail") + public R submit(@RequestBody SyncInventoryDTO syncInventoryDTO) { + String method = "##############submit: "; + String inventoryNo = syncInventoryDTO.getInventoryNo(); + try{ + //当前登录人选择的仓库 + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if(Objects.isNull(myCurrentWarehouse)){ + log.warn(method+"仓库信息为空 myCurrentWarehouse={}",myCurrentWarehouse); + return R.fail(403,"仓库信息为空"); + } + + if(StringUtil.isBlank(inventoryNo)){ + log.warn(method+"盘点编码为空 inventoryNo={}",inventoryNo); + return R.fail(403,"盘点编码为空"); + } + + + return syncInventoryService.addSyncTask(inventoryNo,myCurrentWarehouse.getId()); + }catch (CustomerException e){ + log.warn(e.message); + return R.fail(e.code,e.message); + }catch (Exception e){ + log.error(method+"系统异常,联系管理员",e); + return R.fail(500,"系统异常,联系管理员"); + } + } } 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 1761d1e64..768ac84cc 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 @@ -50,6 +50,7 @@ public class SyncOrderInfoToPlatform { for (WarehouseMappingDataEntity mappingDataEntity:warehouseMappingDataEntityList){ Integer oldWarehouseId = mappingDataEntity.getOldWarehouseId();//老系统仓库id Long newWarehouseId = mappingDataEntity.getNewWarehouseId();//新系统仓库id + Integer inventoryId = mappingDataEntity.getInventoryId(); //查询新系统是否已有仓库信息 BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(newWarehouseId); @@ -104,7 +105,7 @@ public class SyncOrderInfoToPlatform { try{ List orderCodeList = orderClient.findOrderCodeListByPage(param,oldWarehouseId,j,pageSize); - syncOrderInfoService.handleData(orderCodeList,oldWarehouseId,newWarehouseId); + syncOrderInfoService.handleData(orderCodeList,oldWarehouseId,newWarehouseId,inventoryId); log.info("################syncOrderInfo: 同步成功{}个订单",orderCodeList.size()); one.setCurrentPage(j+1); diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.java index 1fee7b157..49da9428e 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.java @@ -1,9 +1,14 @@ package com.logpm.patch.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.patch.entity.SyncInventoryEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface SyncInventoryMapper extends BaseMapper { + + IPage pageList(IPage page, @Param("inventoryNo") String inventoryNo, @Param("warehouseId") Long warehouseId); + } diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.xml b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.xml new file mode 100644 index 000000000..c14a5b088 --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/mapper/SyncInventoryMapper.xml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IAsyncDataService.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IAsyncDataService.java new file mode 100644 index 000000000..10d11202f --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/IAsyncDataService.java @@ -0,0 +1,10 @@ +package com.logpm.patch.service; + +import com.logpm.patch.entity.SyncInventoryEntity; + +public interface IAsyncDataService { + + + void syncInventoryToPlatform(SyncInventoryEntity syncInventoryEntity); + +} diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncInventoryService.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncInventoryService.java index 40dbe0ecd..ca4fd1c6e 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncInventoryService.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/ISyncInventoryService.java @@ -1,7 +1,15 @@ package com.logpm.patch.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.patch.dto.SyncInventoryDTO; import com.logpm.patch.entity.SyncInventoryEntity; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.tool.api.R; public interface ISyncInventoryService extends BaseService { + + IPage pageList(SyncInventoryDTO syncInventoryDTO); + + R addSyncTask(String inventoryNo, Long id); + } 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 7b3653e26..eecbbabc9 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 @@ -3,7 +3,7 @@ package com.logpm.patch.service; import java.util.List; public interface ISyncOrderInfoService { - void handleData(List orderCodeList,Integer oldWarehouseId,Long newWarehouseId); + void handleData(List orderCodeList,Integer oldWarehouseId,Long newWarehouseId,Integer inventoryId); void handleDataZero(List orderCodeList, Integer oldWarehouseId, Long newWarehouseId); diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/AsyncDataServiceImpl.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/AsyncDataServiceImpl.java new file mode 100644 index 000000000..b54328de8 --- /dev/null +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/AsyncDataServiceImpl.java @@ -0,0 +1,139 @@ +package com.logpm.patch.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.oldproject.feign.IOrderClient; +import com.logpm.patch.entity.OrderSyncRecordEntity; +import com.logpm.patch.entity.SyncInventoryEntity; +import com.logpm.patch.mapper.SyncInventoryMapper; +import com.logpm.patch.service.IAsyncDataService; +import com.logpm.patch.service.IOrderSyncRecordService; +import com.logpm.patch.service.ISyncOrderInfoService; +import com.logpm.patch.service.IWarehouseMappingDataService; +import lombok.AllArgsConstructor; +import lombok.extern.log4j.Log4j2; +import org.springblade.common.exception.CustomerException; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * 异步线程处理 + */ +@Log4j2 +@Service +@AllArgsConstructor +public class AsyncDataServiceImpl implements IAsyncDataService { + + private final IWarehouseMappingDataService warehouseMappingDataService; + private final IBasicdataWarehouseClient basicdataWarehouseClient;//新系统仓库 + private final IOrderClient orderClient;//老系统订单client + + private final IOrderSyncRecordService orderSyncRecordService; + private final ISyncOrderInfoService syncOrderInfoService; + + private final SyncInventoryMapper syncInventoryMapper; + + + @Override + @Async + public void syncInventoryToPlatform(SyncInventoryEntity syncInventoryEntity) { + + Integer pageSize = 500;//处理的每页条数 + Integer oldWarehouseId = syncInventoryEntity.getOldWarehouseId();//老系统仓库id + Long newWarehouseId = syncInventoryEntity.getWarehouseId();//新系统仓库id + Integer inventoryId = syncInventoryEntity.getInventoryId(); + + //查询新系统是否已有仓库信息 + BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(newWarehouseId); + if(Objects.isNull(basicdataWarehouseEntity)){ + log.warn("###############syncOrderInfo: 新系统没有仓库信息"); + throw new CustomerException(403,"新系统没有仓库信息"); + } + + Integer totalPage = 0; + Integer currentPage = 0; + //查询该仓库是否有未完成的同步数据 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("old_warehouse_id",oldWarehouseId) + .eq("inventory_id",inventoryId) + .eq("type",1) + .ne("sync_status",2); + OrderSyncRecordEntity one = orderSyncRecordService.getOne(queryWrapper); + if(!Objects.isNull(one)){ + //因为该仓库有未完成的同步,继续执行 + totalPage = one.getTotalPage(); + currentPage = one.getCurrentPage(); + }else{ + //查询本次同步一共多少的个订单 + Integer totalNum = orderClient.getTotalCountBy(null,oldWarehouseId); + if(totalNum == 0){ + log.info("################syncOrderInfo: 暂无需要执行的数据"); + throw new CustomerException(403,"暂无需要执行的数据"); + } + log.info("##################syncOrderInfo: 一共需要同步{}条数据",totalNum); + syncInventoryEntity.setSyncStartDate(new Date()); + syncInventoryEntity.setSyncStatus(1); + syncInventoryMapper.updateById(syncInventoryEntity); + //计算出需要多少页 + int i = totalNum % pageSize; + if(i == 0){ + totalPage = totalNum/pageSize; + }else{ + totalPage = totalNum/pageSize + 1; + } + currentPage = 0; + log.info("##################syncOrderInfo: 一共需要同步{}页size为{}的数据",totalPage,pageSize); + one = new OrderSyncRecordEntity(); + one.setOldWarehouseId(oldWarehouseId); + one.setTotalNum(totalNum); + one.setTotalPage(totalPage); + one.setType(1); + one.setCurrentPage(0); + one.setFinishNum(0); + one.setSyncStatus(0); + one.setInventoryId(inventoryId); + orderSyncRecordService.save(one); + } + + + for (int j = currentPage; j < totalPage; j++) { + log.info("##################syncOrderInfo: 当前同步的第{}页的数据",j+1); + try{ + List orderCodeList = orderClient.findOrderCodeListByPage(null,oldWarehouseId,j,pageSize); + + syncOrderInfoService.handleData(orderCodeList,oldWarehouseId,newWarehouseId,inventoryId); + + log.info("################syncOrderInfo: 同步成功{}个订单",orderCodeList.size()); + one.setCurrentPage(j+1); + one.setFinishNum(one.getFinishNum() + orderCodeList.size()); + if((j+1) == totalPage){ + one.setSyncStatus(2); + syncInventoryEntity.setSyncEndDate(new Date()); + syncInventoryEntity.setSyncStatus(2); + syncInventoryMapper.updateById(syncInventoryEntity); + }else{ + one.setSyncStatus(1); + } + orderSyncRecordService.saveOrUpdate(one); + }catch (CustomerException e){ + log.error(e.message,e); + syncInventoryEntity.setSyncEndDate(new Date()); + syncInventoryEntity.setSyncStatus(3); + syncInventoryMapper.updateById(syncInventoryEntity); + throw new CustomerException(e.code,e.message); + }catch (Exception e){ + log.error("#############syncOrderInfo: 同步数据失败",e); + syncInventoryEntity.setSyncEndDate(new Date()); + syncInventoryEntity.setSyncStatus(3); + syncInventoryMapper.updateById(syncInventoryEntity); + throw new CustomerException(403,"同步数据失败"); + } + } + + } +} diff --git a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncInventoryServiceImpl.java b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncInventoryServiceImpl.java index 7774248f6..b671caab7 100644 --- a/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncInventoryServiceImpl.java +++ b/blade-service/logpm-patch/src/main/java/com/logpm/patch/service/impl/SyncInventoryServiceImpl.java @@ -1,15 +1,96 @@ package com.logpm.patch.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.oldproject.entity.InventoryEntity; +import com.logpm.oldproject.feign.IInventoryClient; +import com.logpm.patch.dto.SyncInventoryDTO; import com.logpm.patch.entity.SyncInventoryEntity; import com.logpm.patch.mapper.SyncInventoryMapper; +import com.logpm.patch.service.IAsyncDataService; import com.logpm.patch.service.ISyncInventoryService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.StringUtil; import org.springframework.stereotype.Service; +import java.util.Objects; + @Slf4j @AllArgsConstructor @Service public class SyncInventoryServiceImpl extends BaseServiceImpl implements ISyncInventoryService { + + private final IInventoryClient inventoryClient; + private final IBasicdataWarehouseClient basicdataWarehouseClient; + private final IAsyncDataService asyncDataService; + + @Override + public IPage pageList(SyncInventoryDTO syncInventoryDTO) { + Integer pageNum = syncInventoryDTO.getPageNum(); + Integer pageSize = syncInventoryDTO.getPageSize(); + String inventoryNo = syncInventoryDTO.getInventoryNo(); + Long warehouseId = syncInventoryDTO.getWarehouseId(); + + if(Objects.isNull(pageNum)){ + pageNum = 1; + } + if(Objects.isNull(pageSize)){ + pageSize = 30; + } + + IPage page = new Page<>(); + page.setCurrent(pageNum); + page.setSize(pageSize); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + if(!StringUtil.isBlank(inventoryNo)){ + queryWrapper.like("inventory_no",inventoryNo); + } + return baseMapper.pageList(page,inventoryNo,warehouseId); + } + + @Override + public R addSyncTask(String inventoryNo, Long warehouseId) { + + BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if(Objects.isNull(basicdataWarehouseEntity)){ + log.warn("############addSyncTask: 仓库信息不存在 warehouseId={}",warehouseId); + return R.fail(403,"仓库信息不存在"); + } + Integer oldId = basicdataWarehouseEntity.getOldId(); + String name = basicdataWarehouseEntity.getName(); + + //判断盘点编码是否存在 + InventoryEntity inventoryEntity = inventoryClient.findEntityByWarehouseIdAndNo(oldId,inventoryNo); + if(Objects.isNull(inventoryEntity)){ + log.warn("############addSyncTask: 盘点任务不存在 inventoryNo={} oldId={}",inventoryNo,oldId); + return R.fail(403,"盘点任务不存在"); + } + Integer status = inventoryEntity.getStatus(); + if(4 != status){ + log.warn("############addSyncTask: 盘点任务还未完成 status={}",status); + return R.fail(403,"盘点任务还未完成"); + } + + //创建同步信息 + SyncInventoryEntity syncInventoryEntity = new SyncInventoryEntity(); + syncInventoryEntity.setInventoryId(inventoryEntity.getId()); + syncInventoryEntity.setInventoryNo(inventoryNo); + syncInventoryEntity.setSyncStatus(0); + syncInventoryEntity.setWarehouseId(warehouseId); + syncInventoryEntity.setOldWarehouseId(oldId); + syncInventoryEntity.setWarehouseName(name); + save(syncInventoryEntity); + + //开启异步线程,同步数据 + asyncDataService.syncInventoryToPlatform(syncInventoryEntity); + + return R.success("添加成功"); + } } 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 2295e6a0f..9e087c711 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 @@ -68,24 +68,34 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { @Transactional(rollbackFor = Exception.class) @Override - public void handleData(List orderCodeList,Integer oldWarehouseId,Long newWarehouseId) { + public void handleData(List orderCodeList,Integer oldWarehouseId,Long newWarehouseId,Integer inventoryId) { log.info("#############handleData: 处理订单开始"); for (String orderCode:orderCodeList){ - log.info("#############handleData: 当前处理orderCode={}的订单",orderCode); + log.info("#############handleData: 当前处理orderCode={}的订单 盘点任务 inventoryId={}",orderCode,inventoryId); // DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode); // if(!Objects.isNull(stockArticleEntity)){ // log.info("#############handleData: 订单orderCode={}已存在",orderCode); // continue; // } //查询订单是否在盘点任务中有被盘点到 -// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode); -// if(!Objects.isNull(inventoryDetailEntity)){ - //定单 - saveOrderInfo(orderCode,oldWarehouseId,newWarehouseId); + InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findOrderIsExist(orderCode,inventoryId); + if(!Objects.isNull(inventoryDetailEntity)){ + try{ + //定单 + saveOrderInfo(orderCode,oldWarehouseId,newWarehouseId,inventoryId); - //存入打托信息 - saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId); -// } + //存入打托信息 +// saveTrayTypeInfoPackage(orderCode,oldWarehouseId,newWarehouseId); + + saveTrayTypeInfoPackageNew(orderCode,oldWarehouseId,newWarehouseId,inventoryId); + + }catch (CustomerException e){ + log.error("同步订单"+orderCode+"失败: "+e.message,e); + }catch (Exception e){ + log.error("同步订单"+orderCode+"失败",e); + } + + } } } @@ -125,7 +135,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { @Override public void syncTrayType(Integer oldWarehouseId,Long newWarehouseId) { - saveTrayTypeInfoPackageNew(oldWarehouseId,newWarehouseId); + saveTrayTypeInfoPackageNew(null,oldWarehouseId,newWarehouseId,null); } @@ -662,7 +672,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { } - private void saveOrderInfo(String orderCode, Integer oldWarehouseId, Long newWarehouseId) { + private void saveOrderInfo(String orderCode, Integer oldWarehouseId, Long newWarehouseId,Integer inventoryId) { //通过订单号查询暂存单 AdvanceEntity advanceEntity = advanceClient.getQueryDataOne(orderCode); @@ -862,11 +872,11 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { } //保存包件信息 - saveOrderPackage(distributionStockArticleEntity,basicdataWarehouseEntity,wayBillNo,CommonUtil.dateToString(new Date()),oldWarehouseId); + saveOrderPackage(distributionStockArticleEntity,basicdataWarehouseEntity,wayBillNo,CommonUtil.dateToString(new Date()),oldWarehouseId,inventoryId); } - private void saveOrderPackage(DistributionStockArticleEntity distributionStockArticleEntity, BasicdataWarehouseEntity basicdataWarehouseEntity, String waybillNo,String operationTime,Integer oldWarehouseId) { + private void saveOrderPackage(DistributionStockArticleEntity distributionStockArticleEntity, BasicdataWarehouseEntity basicdataWarehouseEntity, String waybillNo,String operationTime,Integer oldWarehouseId,Integer inventoryId) { String orderCode = distributionStockArticleEntity.getOrderCode(); @@ -874,17 +884,18 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { List orderDetailList = orderDetailClient.findByOrderCode(orderCode,oldWarehouseId); for (OrderDetailEntity orderDetailEntity:orderDetailList){ String unitNo = orderDetailEntity.getUnitNo(); -// InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo); -// if(Objects.isNull(inventoryDetailEntity)){ -// log.info("###########saveOrderPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo); -// continue; -// } DistributionParcelListEntity parcelListEntity = distributionParcelListClient.findByPacketBarCode(unitNo); if(!Objects.isNull(parcelListEntity)){ log.info("###########saveOrderPackage: 包条已存在,不同步 unitNo={}",unitNo); continue; } + InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo,inventoryId); + if(Objects.isNull(inventoryDetailEntity)){ + log.info("###########saveOrderPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo); + continue; + } + Integer status = orderDetailEntity.getStatus(); Integer carsType = orderDetailEntity.getCarsType(); Integer signState = orderDetailEntity.getSignState(); @@ -961,10 +972,8 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { boolean b = distributionParcelListClient.add(entity); if (!b) { log.warn("#################handleDataToPlatform: 保存包件信息失败 orderCode={}", entity.getOrderCode()); - throw new CustomerException(405, "保存包件信息失败"); } - } } @@ -1112,10 +1121,10 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { return wayBillEntity; } - private void saveTrayTypeInfoPackageNew(Integer oldWarehouseId, Long newWarehouseId) { + private void saveTrayTypeInfoPackageNew(String orderCode,Integer oldWarehouseId, Long newWarehouseId,Integer inventoryId) { - List ls = inventoryDetailClient.findAllTrayType(); + List ls = inventoryDetailClient.findAllTrayType(orderCode,inventoryId); for (InventoryDetailEntity entity:ls){ Integer trayId = entity.getTrayId(); @@ -1130,8 +1139,7 @@ public class SyncOrderInfoServiceImpl implements ISyncOrderInfoService { type = trayScanEntity.getType(); } - - InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo); + InventoryDetailEntity inventoryDetailEntity = inventoryDetailClient.findUnitNoIsExist(unitNo,inventoryId); if(Objects.isNull(inventoryDetailEntity)){ log.info("###########saveTrayTypeInfoPackage: 包条不在盘点任务中存在,不同步 unitNo={}",unitNo); continue;