diff --git a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java index 7c47a87a7..33d5d2d45 100644 --- a/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java +++ b/blade-service-api/logpm-trunkline-api/src/main/java/com/logpm/trunkline/dto/AdvanceDTO.java @@ -38,6 +38,7 @@ public class AdvanceDTO implements Serializable { private String brand; private Integer hasPackage; + private Integer enterNum; private String startCreateTimeStr; private String endCreateTimeStr; diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml index d887af07d..e88cfec74 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/mapper/TrunklineAdvanceMapper.xml @@ -187,6 +187,7 @@ ) orderCodes where orderCodes.orderCode = lta.order_code) + and lta.waybill_status = '0' diff --git a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java index 1a5cf4aad..11d094583 100644 --- a/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java +++ b/blade-service/logpm-trunkline/src/main/java/com/logpm/trunkline/service/impl/OpenOrderServiceImpl.java @@ -3317,9 +3317,84 @@ public class OpenOrderServiceImpl implements IOpenOrderService { public R createOrderPackage(AdvanceDTO advanceDTO) { Long advanceId = advanceDTO.getAdvanceId(); Long warehouseId = advanceDTO.getWarehouseId(); + Integer enterNum = advanceDTO.getEnterNum(); + BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if(Objects.isNull(warehouseEntity)){ + log.warn("##########createOrderPackage: 仓库信息不存在 warehouseId={}",warehouseId); + return R.fail(405,"仓库信息不存在"); + } + String warehouseName = warehouseEntity.getName(); + String warehouseCode = warehouseEntity.getWarehouseCode(); + + TrunklineAdvanceEntity advanceEntity = advanceService.getById(advanceId); + Integer totalNum = advanceEntity.getTotalNum(); + + List advanceDetailList = advanceDetailService.findList(advanceId); + + if(totalNum > 0 || CollUtil.isNotEmpty(advanceDetailList)){ + log.warn("##########createOrderPackage: 订单已有包件数据 advanceId={}",advanceId); + return R.fail(405,"订单已有包件数据"); + } + + if(enterNum == null || enterNum <= 0){ + log.warn("##########createOrderPackage: 输入的数量不正确 enterNum={}",enterNum); + return R.fail(405,"输入的数量不正确"); + } + + TrunklineAdvanceDetailEntity advanceDetailModel = new TrunklineAdvanceDetailEntity(); + advanceDetailModel.setWarehouseId(warehouseId); + advanceDetailModel.setWarehouseName(warehouseName); + advanceDetailModel.setAdvanceId(advanceId); + advanceDetailModel.setOrderCode(advanceEntity.getOrderCode()); + advanceDetailModel.setBrand(advanceEntity.getBrand()); + advanceDetailModel.setSystemType("线上"); + +// advanceDetailModel.setFirstPackName(firsts); +// String sencods = importOrderNoPackageExcelDTO.getSeconds(); +// if (StringUtil.isBlank(sencods)) { +// advanceDetailModel.setSecondPackName(firsts); +// } else { +// advanceDetailModel.setSecondPackName(sencods); +// } +// String thirds = importOrderNoPackageExcelDTO.getThirds(); +// if (StringUtil.isBlank(thirds)) { +// advanceDetailModel.setThirdPackName(firsts); +// } else { +// advanceDetailModel.setThirdPackName(thirds); +// } + advanceDetailModel.setQuantity(1); + advanceDetailModel.setServiceNum(advanceEntity.getServiceNum()); +// advanceDetailModel.setMaterialCode(importOrderNoPackageExcelDTO.getMaterialCode()); +// advanceDetailModel.setMaterialName(importOrderNoPackageExcelDTO.getMaterialName()); +// String volume = importOrderNoPackageExcelDTO.getVolume(); +// if (StringUtil.isBlank(volume)){ +// advanceDetailModel.setVolume(BigDecimal.ZERO); +// }else{ +// advanceDetailModel.setVolume(new BigDecimal(volume)); +// } +// String weight = importOrderNoPackageExcelDTO.getWeight(); +// if (StringUtil.isBlank(weight)){ +// advanceDetailModel.setWeight(BigDecimal.ZERO); +// }else{ +// advanceDetailModel.setWeight(new BigDecimal(weight)); +// } + advanceDetailModel.setPackageStatus("0"); - return null; + List advanceDetailEntities = new ArrayList<>(); + List orderPackageCodes = basicdataCodeClient.getBatchPackageCodeByType(warehouseCode, advanceEntity.getOrderCode(), totalNum); + orderPackageCodes.forEach(orderPackageCode -> { + TrunklineAdvanceDetailEntity advanceDetailEntity = new TrunklineAdvanceDetailEntity(); + BeanUtil.copy(advanceDetailModel, advanceDetailEntity); + advanceDetailEntity.setOrderPackageCode(orderPackageCode); + advanceDetailEntities.add(advanceDetailEntity); + }); + advanceDetailService.saveBatch(advanceDetailEntities); + advanceEntity.setTotalNum(enterNum); + + advanceService.updateById(advanceEntity); + + return R.success("添加成功"); } private List verifyData(OpenOrderDTO openOrderDTO, WarehouseWaybillEntity waybillEntity) {