@ -4,16 +4,21 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.logpm.basicdata.entity.BasicdataGoodsAllocationEntity ;
import com.logpm.basicdata.entity.BasicdataGoodsShelfEntity ;
import com.logpm.basicdata.entity.BasicdataTrayEntity ;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity ;
import com.logpm.basicdata.feign.IBasicdataGoodsAllocationClient ;
import com.logpm.basicdata.feign.IBasicdataGoodsShelfClient ;
import com.logpm.basicdata.feign.IBasicdataTrayClient ;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient ;
import com.logpm.distribution.entity.DistributionStockListEntity ;
import com.logpm.distribution.feign.IDistributionStockArticleClient ;
import com.logpm.distribution.feign.IDistributionStockListClient ;
import com.logpm.warehouse.dto.UpShelfPackageDTO ;
import com.logpm.warehouse.dto.UpShelfStockDTO ;
import com.logpm.warehouse.dto.UpShelfZeroOrderDTO ;
import com.logpm.warehouse.dto.ZeroOrderVO ;
import com.logpm.oldproject.entity.TrayEntity ;
import com.logpm.oldproject.feign.ITrayClient ;
import com.logpm.oldproject.feign.ITrayScanClient ;
import com.logpm.oldproject.feign.ITrayScanDesClient ;
import com.logpm.warehouse.dto.* ;
import com.logpm.warehouse.entity.TaskQuestEntity ;
import com.logpm.warehouse.entity.WarehouseTrayGoodsEntity ;
import com.logpm.warehouse.entity.WarehouseTrayTypeEntity ;
import com.logpm.warehouse.entity.WarehouseUpdownGoodsEntity ;
import com.logpm.warehouse.service.* ;
@ -60,6 +65,16 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
private IDistributionStockArticleClient distributionStockArticleClient ;
@Autowired
private IDistributionStockListClient distributionStockListClient ;
@Autowired
private IBasicdataWarehouseClient basicdataWarehouseClient ;
@Autowired
private IBasicdataTrayClient basicdataTrayClient ;
@Autowired
private ITrayClient trayClient ;
@Autowired
private ITrayScanClient trayScanClient ;
@Autowired
private ITrayScanDesClient trayScanDesClient ;
@Override
@Async
@ -298,6 +313,164 @@ public class AsyncDataServiceImpl implements IAsyncDataService {
log . info ( "################syncTaskData: 处理完成" ) ;
}
@Override
public void sendTrayInfoByOrderPackageCode ( TrayInfoDTO trayInfoDTO ) {
Integer trayId = trayInfoDTO . getTrayId ( ) ;
String orderPackageCode = trayInfoDTO . getOrderPackageCode ( ) ;
Integer oldWarehouseId = trayInfoDTO . getWarehouseId ( ) ;
Integer type = trayInfoDTO . getType ( ) ;
BasicdataWarehouseEntity basicdataWarehouseEntity = basicdataWarehouseClient . getWarehouseByOldId ( oldWarehouseId ) ;
if ( Objects . isNull ( basicdataWarehouseEntity ) ) {
log . warn ( "####################sendTrayInfoByOrderPackageCode: 仓库信息为空 basicdataWarehouseEntity={}" , basicdataWarehouseEntity ) ;
throw new CustomerException ( 405 , "仓库信息为空" ) ;
}
Long newWarehouseId = basicdataWarehouseEntity . getId ( ) ;
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient . getTrayByTrayCode ( "T" + trayId ) ;
if ( Objects . isNull ( basicdataTrayEntity ) ) {
log . info ( "############sendTrayInfoByOrderPackageCode: 托盘信息不存在 同步" ) ;
//如果托盘不存在就去同步该托盘
TrayEntity trayEntity = trayClient . getTrayById ( trayId ) ;
basicdataTrayEntity = new BasicdataTrayEntity ( ) ;
basicdataTrayEntity . setTenantId ( "627683" ) ;
basicdataTrayEntity . setCreateUser ( 1714696768639311873L ) ;
basicdataTrayEntity . setUpdateUser ( 1714696768639311873L ) ;
basicdataTrayEntity . setCreateDept ( 1649331096241836033L ) ;
basicdataTrayEntity . setPalletName ( trayEntity . getTrayNo ( ) ) ;
basicdataTrayEntity . setPalletCode ( "T" + trayEntity . getId ( ) ) ;
basicdataTrayEntity . setWarehouseId ( newWarehouseId ) ;
basicdataTrayEntity . setTrayStatus ( trayEntity . getStatus ( ) + "" ) ;
basicdataTrayEntity . setType ( 1 ) ;
basicdataTrayEntity . setOldId ( trayId ) ;
// basicdataTrayEntity.setNowWarehouseId(nowNewWarehouseId);
Long aLong = basicdataTrayClient . addTray ( basicdataTrayEntity ) ;
basicdataTrayEntity . setId ( aLong ) ;
}
// TrayScanDesEntity trayScanDesEntity = trayScanDesClient.findScanTypeId(trayId, orderPackageCode, oldWarehouseId);
// if(Objects.isNull(trayScanDesEntity)){
// log.warn("####################sendTrayInfoByOrderPackageCode: 没有打托数据 trayId={}",trayId);
// throw new CustomerException(405,"没有打托数据");
// }
// Integer trayScanId = trayScanDesEntity.getTrayScanId();
// TrayScanEntity trayScanEntity = trayScanClient.getEntityByTrayScanId(trayScanId);
// if(Objects.isNull(trayScanEntity)){
// log.warn("####################sendTrayInfoByOrderPackageCode: 没有打托方式数据 trayScanId={}",trayScanId);
// throw new CustomerException(405,"没有打托方式数据");
// }
// Integer trayType = trayScanEntity.getType();
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" ;
}
//判断托盘是否有上架
Long allocationId = taryAllocationService . getAllocationIdByTrayId ( basicdataTrayEntity . getId ( ) ) ;
if ( Objects . isNull ( allocationId ) ) {
//没有上架就直接打托
R response = trayTypeService . orderScanOrderPackageCode ( newTrayType , "T" + trayId , orderPackageCode , newWarehouseId ) ;
int code = response . getCode ( ) ;
String msg = response . getMsg ( ) ;
if ( code = = 4001 ) {
log . info ( "####################sendTrayInfoByOrderPackageCode: 包件已在当前托盘打托 orderPackageCode={} trayCode={}" , orderPackageCode , "T" + trayId ) ;
} else if ( code = = 4002 ) {
log . info ( "####################sendTrayInfoByOrderPackageCode: 包件已在其他托盘打托 orderPackageCode={} " , orderPackageCode ) ;
QueryWrapper < WarehouseTrayGoodsEntity > trayGoodsEntityQueryWrapper = new QueryWrapper < > ( ) ;
trayGoodsEntityQueryWrapper . eq ( "association_value" , orderPackageCode ) ;
WarehouseTrayGoodsEntity trayGoodsEntity = trayGoodsService . getOne ( trayGoodsEntityQueryWrapper ) ;
if ( Objects . isNull ( trayGoodsEntity ) ) {
log . warn ( "####################sendTrayInfoByOrderPackageCode: 包件未打托 orderPackageCode={}" , orderPackageCode ) ;
} else {
String oldTrayCode = trayGoodsEntity . getTrayCode ( ) ;
Long trayGoodsId = trayGoodsEntity . getId ( ) ;
Long wid = trayGoodsEntity . getWarehouseId ( ) ;
BasicdataTrayEntity oldTrayEntity = basicdataTrayClient . getTrayByTrayCode ( oldTrayCode ) ;
Long oldTrayId = oldTrayEntity . getId ( ) ;
//判断托盘是否有上架
Long oldAllocationId = taryAllocationService . getAllocationIdByTrayId ( oldTrayId ) ;
if ( Objects . isNull ( oldAllocationId ) ) {
//没有上架
//直接解绑托盘
trayGoodsService . deleteByTrayGoodsId ( trayGoodsId , wid ) ;
} else {
//有上架
//下架
List < UpShelfPackageDTO > upShelfPackageList = new ArrayList < > ( ) ;
UpShelfPackageDTO upShelfPackageDTO = new UpShelfPackageDTO ( ) ;
upShelfPackageDTO . setOrderPackageCode ( orderPackageCode ) ;
upShelfPackageList . add ( upShelfPackageDTO ) ;
updownTypeService . downPackage ( upShelfPackageList , wid ) ;
}
}
R r = trayTypeService . orderScanOrderPackageCode ( newTrayType , "T" + trayId , orderPackageCode , newWarehouseId ) ;
int code1 = r . getCode ( ) ;
if ( code1 ! = 200 ) {
log . warn ( "####################orderStatusHandler: 二次打托失败 orderPackageCode={} trayCode={}" , orderPackageCode , "T" + trayId ) ;
} else {
log . info ( "####################orderStatusHandler: 二次打托成功 orderPackageCode={} trayCode={}" , orderPackageCode , "T" + trayId ) ;
}
} else if ( code = = 4003 ) {
log . info ( "####################orderStatusHandler: 包件未打托已上架 orderPackageCode={} " , orderPackageCode ) ;
QueryWrapper < WarehouseUpdownGoodsEntity > updownGoodsEntityQueryWrapper = new QueryWrapper < > ( ) ;
updownGoodsEntityQueryWrapper . eq ( "association_value" , orderPackageCode ) ;
WarehouseUpdownGoodsEntity updownGoodsEntity = updownGoodsService . getOne ( updownGoodsEntityQueryWrapper ) ;
if ( Objects . isNull ( updownGoodsEntity ) ) {
log . warn ( "####################orderStatusHandler: 包件未上架 orderPackageCode={}" , orderPackageCode ) ;
} else {
Long wid = updownGoodsEntity . getWarehouseId ( ) ;
List < UpShelfPackageDTO > upShelfPackageList = new ArrayList < > ( ) ;
UpShelfPackageDTO upShelfPackageDTO = new UpShelfPackageDTO ( ) ;
upShelfPackageDTO . setOrderPackageCode ( orderPackageCode ) ;
upShelfPackageList . add ( upShelfPackageDTO ) ;
updownTypeService . downPackage ( upShelfPackageList , wid ) ;
}
R r = trayTypeService . orderScanOrderPackageCode ( newTrayType , "T" + trayId , orderPackageCode , newWarehouseId ) ;
int code1 = r . getCode ( ) ;
if ( code1 ! = 200 ) {
log . warn ( "####################orderStatusHandler: 二次打托失败 orderPackageCode={} trayCode={}" , orderPackageCode , "T" + trayId ) ;
} else {
log . info ( "####################orderStatusHandler: 二次打托成功 orderPackageCode={} trayCode={}" , orderPackageCode , "T" + trayId ) ;
}
} else if ( code = = 4004 ) {
log . info ( "####################orderStatusHandler: 包件打托方式不正确 orderPackageCode={} " , orderPackageCode ) ;
//先去空置托盘再打托
trayTypeService . trayToNull ( "T" + trayId ) ;
R r = trayTypeService . orderScanOrderPackageCode ( newTrayType , "T" + trayId , orderPackageCode , newWarehouseId ) ;
int code1 = r . getCode ( ) ;
if ( code1 ! = 200 ) {
log . warn ( "####################orderStatusHandler: 二次打托失败 orderPackageCode={} trayCode={}" , orderPackageCode , "T" + trayId ) ;
}
} else {
log . warn ( "######################orderStatusHandler: 打托失败 msg={} code={}" , msg , code ) ;
log . warn ( "######################orderStatusHandler: 打托失败 orderPackageCode={} trayCode={}" , orderPackageCode , "T" + trayId ) ;
}
} else {
//有上架就上架
List < UpShelfPackageDTO > upShelfPackageList = new ArrayList < > ( ) ;
UpShelfPackageDTO upShelfPackageDTO = new UpShelfPackageDTO ( ) ;
upShelfPackageDTO . setOrderPackageCode ( orderPackageCode ) ;
upShelfPackageList . add ( upShelfPackageDTO ) ;
updownTypeService . upShelfPackage ( upShelfPackageList , allocationId , newWarehouseId ) ;
}
}
private void dealWithStockTray ( String materialCode , String marketName , String incomingBatch , Integer stockNum , String trayCode , String trayType , Long warehouseId ) {
log . info ( "#############dealWithStockTray: 处理库存品的打托" ) ;