|
|
|
@ -17,7 +17,6 @@
|
|
|
|
|
package com.logpm.warehouse.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.BeanUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.basicdata.entity.*; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataGoodsAllocationClient; |
|
|
|
@ -37,7 +36,6 @@ import com.logpm.warehouse.dto.*;
|
|
|
|
|
import com.logpm.warehouse.dto.UpShelfPackageDTO; |
|
|
|
|
import com.logpm.warehouse.dto.UpShelfStockDTO; |
|
|
|
|
import com.logpm.warehouse.dto.UpStockupAreaPackageDTO; |
|
|
|
|
import com.logpm.warehouse.dto.UpdownZeroOrderDTO; |
|
|
|
|
import com.logpm.warehouse.entity.*; |
|
|
|
|
import com.logpm.warehouse.feign.WarehouseGoodsAllocationClient; |
|
|
|
|
import com.logpm.warehouse.mapper.WarehouseUpdownStockupAreaMapper; |
|
|
|
@ -51,7 +49,6 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
@ -557,6 +554,95 @@ public class WarehouseUpdownStockupAreaServiceImpl extends BaseServiceImpl<Wareh
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param upShelfZeroOrderList |
|
|
|
|
* @param allocationId |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public R upShelfZeroStockeArticle(List<UpShelfZeroOrderDTO> upShelfZeroOrderList, Long allocationId, Long warehouseId) { |
|
|
|
|
String collected = upShelfZeroOrderList.stream().filter(f -> f.getEnterNum() <= 0).map(UpShelfZeroOrderDTO::getOrderCode).collect(Collectors.joining(",")); |
|
|
|
|
if (Func.isNotBlank(collected)){ |
|
|
|
|
return Resp.scanFail(collected+"请输入正确的上架数量" , "请输入正确的上架数量, 物料编码为"); |
|
|
|
|
} |
|
|
|
|
List<UpShelfZeroOrderDTO> upShelfZeroOrderDTOS = upShelfZeroOrderList; |
|
|
|
|
BasicdataGoodsAllocationEntity goodsAllocationEntity = basicdataGoodsAllocationClient.getEntityByAllocationId(allocationId); |
|
|
|
|
if(Objects.isNull(goodsAllocationEntity)){ |
|
|
|
|
log.warn("##############upShelfOrder: 库位不存在 allocationId={}",allocationId); |
|
|
|
|
return R.fail(403,"库位不存在"); |
|
|
|
|
} |
|
|
|
|
String enableStatus = goodsAllocationEntity.getEnableStatus(); |
|
|
|
|
Long goodsShelfId = goodsAllocationEntity.getGoodsShelfId(); |
|
|
|
|
if("2".equals(enableStatus)){ |
|
|
|
|
log.warn("##############upShelfOrder: 库位已被禁用 allocationId={}",allocationId); |
|
|
|
|
return R.fail(403,"库位已被禁用"); |
|
|
|
|
} |
|
|
|
|
BasicdataGoodsShelfEntity goodsShelfEntity = basicdataGoodsShelfClient.getEntityByGoodsShelfId(goodsShelfId); |
|
|
|
|
if(Objects.isNull(goodsShelfEntity)){ |
|
|
|
|
log.warn("##############upShelfOrder: 货架不存在 goodsShelfId={}",goodsShelfId); |
|
|
|
|
return R.fail(403,"货架不存在"); |
|
|
|
|
} |
|
|
|
|
Long goodsAreaId = goodsShelfEntity.getGoodsAreaId(); |
|
|
|
|
BasicdataGoodsAreaEntity goodsAreaEntity = basicdataGoodsAreaClient.getEntityByGoodsAreaId(goodsAreaId); |
|
|
|
|
if(Objects.isNull(goodsAreaEntity)){ |
|
|
|
|
log.warn("##############upShelfOrder: 货区不存在 goodsAreaId={}",goodsAreaId); |
|
|
|
|
return R.fail(403,"货区不存在"); |
|
|
|
|
} |
|
|
|
|
String areaType = goodsAreaEntity.getAreaType(); |
|
|
|
|
if(!"1".equals(areaType)){ |
|
|
|
|
log.warn("#################upShelfOrder: 备货区不能上下架 goodsAreaId={}",goodsAreaId); |
|
|
|
|
throw new CustomerException(403,"请扫描备货库位"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Long wid = goodsAreaEntity.getWarehouseId(); |
|
|
|
|
BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(wid); |
|
|
|
|
if(Objects.isNull(warehouseEntity)){ |
|
|
|
|
log.warn("##############upShelfOrder: 仓库不存在 wid={}",wid); |
|
|
|
|
return R.fail(403,"仓库不存在"); |
|
|
|
|
} |
|
|
|
|
if(!wid.equals(warehouseId)){ |
|
|
|
|
log.warn("##############upShelfOrder: 库位不在本仓库中 warehouseId={}",warehouseId); |
|
|
|
|
return R.fail(403,"库位不在本仓库中"); |
|
|
|
|
} |
|
|
|
|
List<WarehouseUpdownStockupAreaEntity> warehouseUpdownStockupAreaEntities = new ArrayList<>(); |
|
|
|
|
List<WarehouseUpdownStockupAreaLogEntity> warehouseUpdownStockupAreaLogEntities = new ArrayList<>(); |
|
|
|
|
QueryWrapper<WarehouseUpdownStockupAreaEntity> updownTypeQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
updownTypeQueryWrapper |
|
|
|
|
.eq("allocation_id",allocationId) |
|
|
|
|
.eq("shelf_id",goodsShelfId) |
|
|
|
|
.eq("area_id",goodsAreaId) |
|
|
|
|
.eq("is_deleted",0); |
|
|
|
|
for (UpShelfZeroOrderDTO upShelfZeroOrderDTO : upShelfZeroOrderDTOS) { |
|
|
|
|
updownTypeQueryWrapper.eq("association_value",upShelfZeroOrderDTO.getAssociationValue()); |
|
|
|
|
updownTypeQueryWrapper.eq("association_type",upShelfZeroOrderDTO.getAssociationType()); |
|
|
|
|
updownTypeQueryWrapper.eq("association_id",upShelfZeroOrderDTO.getAssociationId()); |
|
|
|
|
updownTypeQueryWrapper.eq("goods_type",upShelfZeroOrderDTO.getGoodsType()); |
|
|
|
|
WarehouseUpdownStockupAreaEntity updownStockupAreaEntity = this.getOne(updownTypeQueryWrapper); |
|
|
|
|
if (Func.isNotEmpty(updownStockupAreaEntity)){ |
|
|
|
|
//备货库位上数量增加
|
|
|
|
|
//存在,需要进行新的上架数量维护
|
|
|
|
|
int updateNum = updownStockupAreaEntity.getNum() + upShelfZeroOrderDTO.getEnterNum(); |
|
|
|
|
updownStockupAreaEntity.setNum(updateNum); |
|
|
|
|
this.updateById(updownStockupAreaEntity); |
|
|
|
|
WarehouseUpdownStockupAreaLogEntity warehouseUpdownStockupAreaLogEntity = Func.copy(updownStockupAreaEntity, WarehouseUpdownStockupAreaLogEntity.class); |
|
|
|
|
warehouseUpdownStockupAreaLogEntity.setBindingType(1); |
|
|
|
|
warehouseUpdownStockupAreaLogEntity.setId(null); |
|
|
|
|
warehouseUpdownStockupAreaLogEntity.setNum(upShelfZeroOrderDTO.getEnterNum()); |
|
|
|
|
warehouseUpdownStockupAreaLogEntities.add(warehouseUpdownStockupAreaLogEntity); |
|
|
|
|
}else { |
|
|
|
|
//在该备货库位上第一次进行上架操作
|
|
|
|
|
WarehouseUpdownStockupAreaEntity warehouseUpdownStockupArea = createdNewUpShelfZeroOrder(allocationId, warehouseId, upShelfZeroOrderDTO, goodsAreaId, goodsAreaEntity, goodsShelfId, goodsShelfEntity, goodsAllocationEntity); |
|
|
|
|
warehouseUpdownStockupAreaEntities.add(warehouseUpdownStockupArea); |
|
|
|
|
WarehouseUpdownStockupAreaLogEntity warehouseUpdownStockupAreaLogEntity = Func.copy(warehouseUpdownStockupArea, WarehouseUpdownStockupAreaLogEntity.class); |
|
|
|
|
warehouseUpdownStockupAreaLogEntity.setBindingType(1); |
|
|
|
|
warehouseUpdownStockupAreaLogEntities.add(warehouseUpdownStockupAreaLogEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
warehouseUpdownStockupAreaLogService.saveBatch(warehouseUpdownStockupAreaLogEntities); |
|
|
|
|
|
|
|
|
|
return R.status(this.saveBatch(warehouseUpdownStockupAreaEntities)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private WarehouseUpdownStockupAreaEntity createdNewUpShelfInventory(Long allocationId, Long warehouseId, UpShelfStockDTO upShelfStockDTO, WarehouseUpdownStockupAreaEntity updownTypeEntity, Long goodsAreaId, BasicdataGoodsAreaEntity goodsAreaEntity, Long goodsShelfId, BasicdataGoodsShelfEntity goodsShelfEntity, BasicdataGoodsAllocationEntity goodsAllocationEntity) { |
|
|
|
|
WarehouseUpdownStockupAreaEntity updownStockupAreaEntity = new WarehouseUpdownStockupAreaEntity(); |
|
|
|
|
updownStockupAreaEntity.setWarehouseId(warehouseId); |
|
|
|
@ -580,6 +666,29 @@ public class WarehouseUpdownStockupAreaServiceImpl extends BaseServiceImpl<Wareh
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private WarehouseUpdownStockupAreaEntity createdNewUpShelfZeroOrder(Long allocationId, Long warehouseId,UpShelfZeroOrderDTO upShelfZeroOrderDTO, Long goodsAreaId, BasicdataGoodsAreaEntity goodsAreaEntity, Long goodsShelfId, BasicdataGoodsShelfEntity goodsShelfEntity, BasicdataGoodsAllocationEntity goodsAllocationEntity) { |
|
|
|
|
WarehouseUpdownStockupAreaEntity updownStockupAreaEntity = new WarehouseUpdownStockupAreaEntity(); |
|
|
|
|
updownStockupAreaEntity.setWarehouseId(warehouseId); |
|
|
|
|
updownStockupAreaEntity.setAreaId(goodsAreaId); |
|
|
|
|
updownStockupAreaEntity.setAreaTitle(goodsAreaEntity.getHeadline()); |
|
|
|
|
updownStockupAreaEntity.setShelfId(goodsShelfId); |
|
|
|
|
updownStockupAreaEntity.setShelfTitle(goodsShelfEntity.getGoodsShelfName()); |
|
|
|
|
updownStockupAreaEntity.setAllocationId(allocationId); |
|
|
|
|
updownStockupAreaEntity.setAllocationTitle(goodsAllocationEntity.getGoodsAllocationName()); |
|
|
|
|
updownStockupAreaEntity.setPositionCode(goodsAllocationEntity.getQrCode()); |
|
|
|
|
updownStockupAreaEntity.setAssociationValue(upShelfZeroOrderDTO.getAssociationValue()); |
|
|
|
|
updownStockupAreaEntity.setAssociationId(Long.parseLong(upShelfZeroOrderDTO.getAssociationId())); |
|
|
|
|
updownStockupAreaEntity.setAssociationType("1"); |
|
|
|
|
updownStockupAreaEntity.setUpdownType("订单"); |
|
|
|
|
updownStockupAreaEntity.setGoodsType("2"); |
|
|
|
|
updownStockupAreaEntity.setGoodsName(upShelfZeroOrderDTO.getGoodsName()); |
|
|
|
|
updownStockupAreaEntity.setNum(upShelfZeroOrderDTO.getEnterNum()); |
|
|
|
|
updownStockupAreaEntity.setMarketId(Long.parseLong(upShelfZeroOrderDTO.getMarketId())); |
|
|
|
|
updownStockupAreaEntity.setMarketName(upShelfZeroOrderDTO.getMarketName()); |
|
|
|
|
return updownStockupAreaEntity; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private UpdownStockVO stockToUpdownStockVO(DistributionStockListEntity stockListEntity,Long warehouseId) { |
|
|
|
|
Long marketId = stockListEntity.getMarketId(); |
|
|
|
|
// Long materialId = stockListEntity.getMaterialId();
|
|
|
|
|