diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java index faa996aa0..9746f16af 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataGoodsAllocationClient.java @@ -54,4 +54,6 @@ public interface IBasicdataGoodsAllocationClient { @GetMapping(API_PREFIX+"/getEntityByAllocationCode") BasicdataGoodsAllocationEntity getEntityByAllocationCode(@RequestParam("allocationCode") String allocationCode); + @PostMapping(API_PREFIX+"/updateAllocationStatus") + void updateAllocationStatus(@RequestParam("allocationId") Long allocationId, @RequestParam("allocationStatus") String allocationStatus); } 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 c6a908458..606fc4e94 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 @@ -65,4 +65,7 @@ public interface IDistributionParcelListClient { @GetMapping(API_PREFIX+"/findEntityListByOrderCode") List findEntityListByOrderCode(@RequestParam String orderCode); + + @GetMapping(API_PREFIX+"/findALLNoUpShelfPackageByOrderCode") + List findALLNoUpShelfPackageByOrderCode(@RequestParam String orderCode); } diff --git a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseUpdownGoodsEntity.java b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseUpdownGoodsEntity.java index 9bf1f21e8..39ef8e285 100644 --- a/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseUpdownGoodsEntity.java +++ b/blade-service-api/logpm-warehouse-api/src/main/java/com/logpm/warehouse/entity/WarehouseUpdownGoodsEntity.java @@ -33,19 +33,19 @@ public class WarehouseUpdownGoodsEntity extends TenantEntity { private Long updownTypeId ; /** 货区id */ @ApiModelProperty(name = "货区id",notes = "") - private String areaId ; + private Long areaId ; /** 货区名称 */ @ApiModelProperty(name = "货区名称",notes = "") private String areaTitle ; /** 货架id */ @ApiModelProperty(name = "货架id",notes = "") - private String shelfId ; + private Long shelfId ; /** 货架名称 */ @ApiModelProperty(name = "货架名称",notes = "") private String shelfTitle ; /** 货位id */ @ApiModelProperty(name = "货位id",notes = "") - private String allocationId ; + private Long allocationId ; /** 货位名称 */ @ApiModelProperty(name = "货位名称",notes = "") private String allocationTitle ; @@ -69,7 +69,7 @@ public class WarehouseUpdownGoodsEntity extends TenantEntity { private String goodsName ; /** 数量 */ @ApiModelProperty(name = "数量",notes = "") - private String num ; + private Integer num ; /** 商场id */ @ApiModelProperty(name = "商场id",notes = "") private Long marketId ; diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java index 7274dec23..01bdbf97b 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataGoodsAllocationClient.java @@ -16,6 +16,7 @@ */ package com.logpm.basicdata.feign; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.logpm.basicdata.entity.BasicdataGoodsAllocationEntity; import com.logpm.basicdata.service.IBasicdataGoodsAllocationService; @@ -65,4 +66,12 @@ public class BasicdataGoodsAllocationClient implements IBasicdataGoodsAllocation return BasicdataGoodsAllocationService.getEntityByAllocationCode(allocationCode); } + @Override + public void updateAllocationStatus(Long allocationId, String allocationStatus) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("allocation_status",allocationStatus) + .eq("id",allocationId); + BasicdataGoodsAllocationService.update(updateWrapper); + } + } 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 559516f68..1c375cd11 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 @@ -88,4 +88,13 @@ public class DistributionParcelListClient implements IDistributionParcelListClie return distributionParcelListService.list(queryWrapper); } + @Override + public List findALLNoUpShelfPackageByOrderCode(String orderCode) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("order_code",orderCode) + .eq("is_deleted",0) + .eq("order_package_grounding_status",10); + return distributionParcelListService.list(queryWrapper); + } + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseUpdownTypeApiController.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseUpdownTypeApiController.java index c1b9cb558..b32df68d8 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseUpdownTypeApiController.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/api/WarehouseUpdownTypeApiController.java @@ -1,6 +1,7 @@ package com.logpm.warehouse.api; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.logpm.warehouse.dto.UpShelfOrderDTO; import com.logpm.warehouse.dto.UpdownTypeDTO; import com.logpm.warehouse.service.IWarehouseUpdownTypeService; import com.logpm.warehouse.vo.TragetAllocationVO; @@ -66,7 +67,7 @@ public class WarehouseUpdownTypeApiController { @PostMapping("/upShelfScanAllocation") @ApiOperationSupport(order = 1) @ApiOperation(value = "上架扫描库位", notes = "传入trayTypeDTO") - public R upShelfScanAllocation(@RequestBody UpdownTypeDTO updownTypeDTO) { + public R upShelfScanAllocation(@RequestBody UpdownTypeDTO updownTypeDTO ) { String method = "###########upShelfScanAllocation: "; log.info(method + "上架扫描库位 updownTypeDTO={}", updownTypeDTO); String code = updownTypeDTO.getCode();//码值 @@ -88,14 +89,37 @@ public class WarehouseUpdownTypeApiController { } } -// @ResponseBody -// @PostMapping("/upShelfScanAllocation") -// @ApiOperationSupport(order = 1) -// @ApiOperation(value = "上架扫描库位", notes = "传入trayTypeDTO") -// public R upShelfScanAllocation(@RequestBody UpdownTypeDTO updownTypeDTO) { -// String method = "###########upShelfScanAllocation: "; -// log.info(method + "上架扫描库位 updownTypeDTO={}", updownTypeDTO); + @ResponseBody + @PostMapping("/upShelfOrder") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "上架订单维度", notes = "传入trayTypeDTO") + public R upShelfOrder(@RequestBody UpdownTypeDTO updownTypeDTO ) { + String method = "###########upShelfOrder: "; + log.info(method + "上架订单维度 updownTypeDTO={}", updownTypeDTO); + List upShelfOrderList = updownTypeDTO.getUpShelfOrderList(); + String allocationCode = updownTypeDTO.getTargetAllocation();//库位码 + try{ + int size = upShelfOrderList.size(); + if(size == 0 ){ + log.warn(method+"没有处理的数据"); + return R.fail(403,"无处理数据"); + } + if(StringUtil.isBlank(allocationCode)){ + log.warn(method+"库位信息不能为空 allocationCode={}",allocationCode); + return R.fail(403,"库位信息不能为空"); + } + //查询该库位的货物信息 + return warehouseUpdownTypeService.upShelfOrder(upShelfOrderList,allocationCode); + }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-warehouse/src/main/java/com/logpm/warehouse/dto/UpShelfOrderDTO.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/UpShelfOrderDTO.java new file mode 100644 index 000000000..2d8ddb6e5 --- /dev/null +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/UpShelfOrderDTO.java @@ -0,0 +1,13 @@ +package com.logpm.warehouse.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class UpShelfOrderDTO implements Serializable { + + private String serviceNumber;//服务号 + private String orderCode;//订单号 + +} diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/UpdownTypeDTO.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/UpdownTypeDTO.java index 434d705be..dabc788d4 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/UpdownTypeDTO.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/dto/UpdownTypeDTO.java @@ -3,6 +3,8 @@ package com.logpm.warehouse.dto; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; @Data public class UpdownTypeDTO implements Serializable { @@ -17,4 +19,6 @@ public class UpdownTypeDTO implements Serializable { private Integer downShelfType;//下架类型 1按件下架 2按库位下架 3按托盘下架 + private List upShelfOrderList = new ArrayList<>(); + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java index 9e384577a..9276af9f0 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.java @@ -58,6 +58,9 @@ public interface WarehouseUpdownGoodsMapper extends BaseMapper findStockByUpdownTypeId(@Param("updownTypeId") Long updownTypeId); + List findListByUpdownTypeIdAndOrderCode(@Param("updownTypeId") Long updownTypeId, @Param("orderCode") String orderCode); + + // /** // * 根据货位查询货物 // * diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml index 50272fca7..a4d35c190 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownGoodsMapper.xml @@ -121,4 +121,14 @@ and lwug.updown_type_id = #{updownTypeId} + + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.java index 1f0c1dca3..ba54f2354 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.java @@ -14,4 +14,8 @@ public interface WarehouseUpdownTypeMapper extends BaseMapper selectPackageListByUpdownTypeId(@Param("updownTypeId") Long updownTypeId); List selectZeroListByUpdownTypeId(@Param("updownTypeId") Long updownTypeId); + + void updateOrderTotalNumAndTotalNum(@Param("updownTypeId") Long updownTypeId, @Param("orderTotalNumber") Integer orderTotalNumber, @Param("quantity") Integer quantity); + + void updateTotalNum(@Param("updownTypeId") Long updownTypeId, @Param("quantity") Integer quantity); } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.xml b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.xml index c0c862be3..4e6400a75 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.xml +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/mapper/WarehouseUpdownTypeMapper.xml @@ -28,4 +28,22 @@ and ldsa.is_zero = 1 + + + update logpm_warehouse_updown_type + set total_num = total_num + #{quantity}, + order_total_num = order_total_num + #{orderTotalNumber} + where id = #{updownTypeId} + and total_num + #{quantity} >= 0 + and order_total_num + #{orderTotalNumber} >=0 + + + + update logpm_warehouse_updown_type + set total_num = total_num + #{quantity} + where id = #{updownTypeId} + and total_num + #{quantity} >= 0 + + + diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java index ac30ab67e..7af30620d 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownGoodsService.java @@ -17,7 +17,9 @@ package com.logpm.warehouse.service; import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.warehouse.entity.WarehouseUpdownGoodsEntity; +import com.logpm.warehouse.entity.WarehouseUpdownTypeEntity; import com.logpm.warehouse.vo.UpShelfDataVO; import com.logpm.warehouse.vo.WarehouseUpdownGoodsVO; import com.logpm.warehouse.excel.WarehouseUpdownGoodsExcel; @@ -69,4 +71,9 @@ public interface IWarehouseUpdownGoodsService extends BaseService findZeroByUpdownTypeId(Long updownTypeId); List findStockByUpdownTypeId(Long updownTypeId); + + List findListByUpdownTypeIdAndOrderCode(Long updownTypeId, String orderCode); + + void bindingAllocationAndPackage(WarehouseUpdownTypeEntity updownTypeEntity, DistributionParcelListEntity parcelListEntity); + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownTypeService.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownTypeService.java index 8e9de26f1..956c0c266 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownTypeService.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/IWarehouseUpdownTypeService.java @@ -1,10 +1,12 @@ package com.logpm.warehouse.service; +import com.logpm.warehouse.dto.UpShelfOrderDTO; import com.logpm.warehouse.entity.WarehouseUpdownTypeEntity; import com.logpm.warehouse.vo.TragetAllocationVO; import com.logpm.warehouse.vo.UpShelfAllocationVO; import com.logpm.warehouse.vo.UpShelfDataVO; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.tool.api.R; import java.util.List; @@ -16,4 +18,6 @@ public interface IWarehouseUpdownTypeService extends BaseService upShelfOrderList,String allocationCode); + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java index 5fee0ae7f..c24f4cf50 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownGoodsServiceImpl.java @@ -17,7 +17,9 @@ package com.logpm.warehouse.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.logpm.distribution.entity.DistributionParcelListEntity; import com.logpm.warehouse.entity.WarehouseUpdownGoodsEntity; +import com.logpm.warehouse.entity.WarehouseUpdownTypeEntity; import com.logpm.warehouse.vo.UpShelfDataVO; import com.logpm.warehouse.vo.WarehouseUpdownGoodsVO; import com.logpm.warehouse.excel.WarehouseUpdownGoodsExcel; @@ -81,4 +83,29 @@ public class WarehouseUpdownGoodsServiceImpl extends BaseServiceImpl findListByUpdownTypeIdAndOrderCode(Long updownTypeId, String orderCode) { + return baseMapper.findListByUpdownTypeIdAndOrderCode(updownTypeId,orderCode); + } + + @Override + public void bindingAllocationAndPackage(WarehouseUpdownTypeEntity updownTypeEntity, DistributionParcelListEntity parcelListEntity) { + WarehouseUpdownGoodsEntity updownGoodsEntity = new WarehouseUpdownGoodsEntity(); + updownGoodsEntity.setUpdownTypeId(updownTypeEntity.getId()); + updownGoodsEntity.setAreaId(updownTypeEntity.getAreaId()); + updownGoodsEntity.setAreaTitle(updownTypeEntity.getAreaTitle()); + updownGoodsEntity.setShelfId(updownTypeEntity.getShelfId()); + updownGoodsEntity.setShelfTitle(updownTypeEntity.getShelfTitle()); + updownGoodsEntity.setAllocationId(updownGoodsEntity.getAllocationId()); + updownGoodsEntity.setAllocationTitle(updownGoodsEntity.getAllocationTitle()); + updownGoodsEntity.setPositionCode(updownGoodsEntity.getPositionCode()); + updownGoodsEntity.setGoodsType(updownGoodsEntity.getGoodsType()); + updownGoodsEntity.setAssociationId(parcelListEntity.getId()); + updownGoodsEntity.setAssociationValue(parcelListEntity.getOrderPackageCode()); + updownGoodsEntity.setAssociationType("3");//包件 + updownGoodsEntity.setGoodsName(updownGoodsEntity.getGoodsName()); + updownGoodsEntity.setNum(parcelListEntity.getQuantity()); + baseMapper.insert(updownGoodsEntity); + } + } diff --git a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java index 84e926a68..866ef52fe 100644 --- a/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java +++ b/blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/service/impl/WarehouseUpdownTypeServiceImpl.java @@ -7,7 +7,10 @@ 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.warehouse.bean.Resp; +import com.logpm.warehouse.dto.UpShelfOrderDTO; import com.logpm.warehouse.entity.WarehouseTrayTypeEntity; +import com.logpm.warehouse.entity.WarehouseUpdownGoodsEntity; import com.logpm.warehouse.entity.WarehouseUpdownTypeEntity; import com.logpm.warehouse.mapper.WarehouseUpdownTypeMapper; import com.logpm.warehouse.service.*; @@ -20,6 +23,8 @@ import lombok.extern.log4j.Log4j2; import org.springblade.common.constant.apiwarehouse.PalletProductTypeConstant; import org.springblade.common.exception.CustomerException; 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.ArrayList; @@ -307,4 +312,152 @@ public class WarehouseUpdownTypeServiceImpl extends BaseServiceImpl upShelfOrderList,String allocationCode) { + int num = 0; + Long trayId = null; + //判断货位是否有托盘 + BasicdataTrayEntity trayEntity = warehouseTaryAllocationService.getTrayByAllocation(allocationCode); + if(!Objects.isNull(trayEntity)){ + trayId = trayEntity.getId(); + } + + for (UpShelfOrderDTO upShelfOrderDTO:upShelfOrderList){ + String orderCode = upShelfOrderDTO.getOrderCode(); + if(StringUtil.isBlank(orderCode)){ + log.warn("##############upShelfOrder: 订单号不存在 orderCode={}",orderCode); + continue; + } + //查询所有该订单号未上架的数据 + List parcelListList = distributionParcelListClient.findALLNoUpShelfPackageByOrderCode(orderCode); + for (DistributionParcelListEntity parcelListEntity:parcelListList){ + //包件级别的上架 + if(Objects.isNull(trayId)){ + //如果没有托盘就直接存入库位上 + upShelfPackageNoTray(parcelListEntity,allocationCode); + }else{ + //如果有托盘就存入库位和托盘上 + } + + } + + } + + + return Resp.scanSuccess("处理成功","处理成功"+num+"条"); + } + + + private void upShelfPackageNoTray(DistributionParcelListEntity parcelListEntity, String allocationCode) { + log.info("###########upShelfPackageNoTray: 上架包件没有托盘 orderPackageCode={} allocationCode={}",parcelListEntity.getOrderPackageCode(),allocationCode); + //修改上架方式的数量 + BasicdataGoodsAllocationEntity goodsAllocationEntity = basicdataGoodsAllocationClient.getEntityByAllocationCode(allocationCode); + if(Objects.isNull(goodsAllocationEntity)){ + log.warn("##############upShelfOrder: 库位不存在 allocationCode={}",allocationCode); + throw new CustomerException(403,"库位不存在"); + } + Long allocationId = goodsAllocationEntity.getId();//库位id + String enableStatus = goodsAllocationEntity.getEnableStatus(); + if("2".equals(enableStatus)){ + log.warn("##############upShelfOrder: 库位已被禁用 allocationCode={}",allocationCode); + throw new CustomerException(403,"库位已被禁用"); + } + QueryWrapper updownTypeEntityQueryWrapper = new QueryWrapper<>(); + updownTypeEntityQueryWrapper.eq("allocation_id",allocationId) + .eq("is_deleted",0); + WarehouseUpdownTypeEntity updownTypeEntity = baseMapper.selectOne(updownTypeEntityQueryWrapper); + if(Objects.isNull(updownTypeEntity)){ + updownTypeEntity = createUpdownType(goodsAllocationEntity); + } + Long updownTypeId = updownTypeEntity.getId();//上架方式id + + //修改上架方式上的数据 + updateUpdownTypeNumPackage(updownTypeEntity,parcelListEntity,"1"); + //货物和库位绑定 + warehouseUpdownGoodsService.bindingAllocationAndPackage(updownTypeEntity,parcelListEntity); + //存入包件货物上架记录 + + + + } + + private void updateUpdownTypeNumPackage(WarehouseUpdownTypeEntity updownTypeEntity, DistributionParcelListEntity parcelListEntity, String addStatus) { + String orderCode = parcelListEntity.getOrderCode(); + Integer quantity = parcelListEntity.getQuantity(); + Long updownTypeId = updownTypeEntity.getId(); + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleClient.findStockArticleByOrderCode(orderCode); + if(Objects.isNull(stockArticleEntity)){ + log.warn("##############updateUpdownTypeNumPackage: 订单信息不存在 orderCode={}",orderCode); + throw new CustomerException(403,"订单信息不存在"); + } + Integer orderTotalNumber = stockArticleEntity.getTotalNumber(); + //查询该订单在该上架方式下的包件还有几条数据 + List ls = warehouseUpdownGoodsService.findListByUpdownTypeIdAndOrderCode(updownTypeId,orderCode); + int size = ls.size(); + if("1".equals(addStatus)){ + if(size==0){ + baseMapper.updateOrderTotalNumAndTotalNum(updownTypeId,orderTotalNumber,quantity); + }else{ + baseMapper.updateTotalNum(updownTypeId,quantity); + } + }else if("2".equals(addStatus)){ + if(size==0){ + log.warn("##############updateUpdownTypeNumPackage: 数据格式问题 updownTypeId={} orderCode={}",updownTypeId,orderCode); + throw new CustomerException(403,"数据格式问题"); + }else if(size > 1){ + //如果库中有至少2条数据,那么去掉一条也不会影响改订单的总数变化,所以只减去包件的数量 + baseMapper.updateTotalNum(updownTypeId,-quantity); + }else{ + //如果库中有至少2条数据,那么去掉一条也不会影响改订单的总数变化,所以只减去包件的数量 + baseMapper.updateOrderTotalNumAndTotalNum(updownTypeId,-orderTotalNumber,-quantity); + } + } + } + + /** + * 创建库位 + */ + private WarehouseUpdownTypeEntity createUpdownType(BasicdataGoodsAllocationEntity goodsAllocationEntity) { + Long goodsShelfId = goodsAllocationEntity.getGoodsShelfId();//货架id + Long allocationId = goodsAllocationEntity.getId(); + String goodsAllocationName = goodsAllocationEntity.getGoodsAllocationName(); + BasicdataGoodsShelfEntity goodsShelfEntity = basicdataGoodsShelfClient.getEntityByGoodsShelfId(goodsShelfId); + if(Objects.isNull(goodsShelfEntity)){ + log.warn("##############createUpdownType: 货架不存在 goodsShelfId={}",goodsShelfId); + throw new CustomerException(403,"货架不存在"); + } + String goodsShelfName = goodsShelfEntity.getGoodsShelfName(); + Long goodsAreaId = goodsShelfEntity.getGoodsAreaId(); + BasicdataGoodsAreaEntity goodsAreaEntity = basicdataGoodsAreaClient.getEntityByGoodsAreaId(goodsAreaId); + if(Objects.isNull(goodsAreaEntity)){ + log.warn("##############createUpdownType: 货区不存在 goodsAreaId={}",goodsAreaId); + throw new CustomerException(403,"货区不存在"); + } + String headline = goodsAreaEntity.getHeadline(); + Long warehouseId = goodsAreaEntity.getWarehouseId(); + BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(warehouseId); + if(Objects.isNull(warehouseEntity)){ + log.warn("##############createUpdownType: 仓库不存在 warehouseId={}",warehouseId); + throw new CustomerException(403,"仓库不存在"); + } + WarehouseUpdownTypeEntity updownTypeEntity = new WarehouseUpdownTypeEntity(); + updownTypeEntity.setUpdownType("100"); + updownTypeEntity.setAreaId(goodsAreaId); + updownTypeEntity.setAreaTitle(headline); + updownTypeEntity.setShelfId(goodsShelfId); + updownTypeEntity.setShelfTitle(goodsShelfName); + updownTypeEntity.setAllocationId(allocationId); + updownTypeEntity.setAllocationTitle(goodsAllocationName); + updownTypeEntity.setPositionCode(headline+"-"+goodsShelfName+"-"+goodsAllocationName); + updownTypeEntity.setTotalNum(0); + updownTypeEntity.setOrderTotalNum(0); + updownTypeEntity.setStockNum(0); + updownTypeEntity.setStockTotalNum(0); + baseMapper.insert(updownTypeEntity); + + //修改库位状态为有货 + basicdataGoodsAllocationClient.updateAllocationStatus(allocationId,"2"); + return updownTypeEntity; + } }