|
|
|
@ -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<WarehouseUpd
|
|
|
|
|
return upShelfAllocationVO; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R upShelfOrder(List<UpShelfOrderDTO> 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<DistributionParcelListEntity> 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<WarehouseUpdownTypeEntity> 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<WarehouseUpdownGoodsEntity> 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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|