@ -117,6 +117,12 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
private IMesProduceSnExtService mesProduceSnExtService ;
@Autowired
private MesShippingQueueRepository shippingQueueRDao ;
@Autowired
private IMesConfigService mesConfigService ;
@Autowired
private MesVolvoRackRepository mesVolvoRackRDao ;
@Autowired
private MesCustSoftInfoRepository custSoftInfoRDao ;
@ -141,7 +147,6 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
//发运单号
model . setShippingCode ( orderManagement . getShippingCode ( ) ) ;
model . setVolvoRackNo ( orderManagement . getRackNo ( ) ) ;
//零件发运组
model . setMesPartShippingGroup ( getMesPartShippingGroup ( orderManagement . getOrganizeCode ( ) , orderManagement . getShippingGroupCode ( ) ) ) ;
//发运单明细
@ -222,7 +227,9 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
} else {
//自制件校验前道工艺 零件发运组详情中的优先
MesPartShippingGroupDetail groupDetail = mesPartShippingGroupService . getMesPartShippingGroupDetailByPartNo ( organizeCode , shippingGroup . getShippingGroupCode ( ) , produceSn . getPartNo ( ) ) ;
if ( null = = groupDetail ) return true ;
if ( null = = groupDetail ) {
return true ;
}
if ( ! StringUtils . isEmpty ( groupDetail . getFrontProcessCode ( ) ) ) {
Integer count = mesProductionRecordService . findFrontProcessProductionRecord ( organizeCode , produceSn . getProductSn ( ) , groupDetail . getFrontProcessCode ( ) ) ;
if ( count > 0 ) {
@ -248,6 +255,40 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
MesProduceSn produceSn = checkMesProduceSn ( model , organizeCode ) ;
//校验发运单是否存在
MesShippingOrderManagement orderManagement = checkMesShippingOrderManagement ( model ) ;
final String confirmPartType = getConfirmPartType ( orderManagement ) ;
if ( Objects . equals ( confirmPartType , String . valueOf ( MesExtEnumUtil . SHIPPING_GROUP_CONFIRM_PART_TYPE . SHIPPING_GROUP_CONFIRM_PART_TYPE_50 . getValue ( ) ) ) ) {
return saveChengDuSnAndLocationCode ( model , organizeCode , userInfo ) ;
}
//根据条码找到对应的物料号, 若物料号一致, 则修改扫描flg, 将flg改为true.
boolean scanFlg = false ;
for ( MesShippingOrderManagementDetail detail : model . getDetailList ( ) ) {
if ( detail . getPartNo ( ) . equals ( produceSn . getPartNo ( ) ) ) {
scanFlg = true ;
detail . setIsScanFlg ( MesCommonConstant . TRUE_INTEGER ) ;
detail . setBarcode ( produceSn . getSerialNumber ( ) ) ;
break ;
}
}
if ( ! scanFlg ) {
throw new ImppBusiException ( String . format ( "【%s】此条码对应的【%s】物料号与发运单中物料号不匹配, 请检查数据! " , model . getSn ( ) , produceSn . getPartNo ( ) ) ) ;
}
Long count = model . getDetailList ( ) . stream ( ) . filter ( k - > Objects . equals ( k . getIsScanFlg ( ) , MesCommonConstant . TRUE_INTEGER ) ) . count ( ) ;
//当前发运单全部扫描完成
if ( count . intValue ( ) = = model . getDetailList ( ) . size ( ) ) {
//保存数据库
saveDate ( orderManagement , model , organizeCode , userInfo ) ;
}
return model ;
}
private MesSortShippingCheckModel saveChengDuSnAndLocationCode ( MesSortShippingCheckModel model , String organizeCode , String userInfo ) {
//校验条码
MesProduceSn produceSn = checkMesProduceSn ( model , organizeCode ) ;
//校验发运单是否存在
MesShippingOrderManagement orderManagement = checkMesShippingOrderManagement ( model ) ;
//根据条码找到对应的物料号, 若物料号一致, 则修改扫描flg, 将flg改为true.
boolean scanFlg = false ;
for ( MesShippingOrderManagementDetail detail : model . getDetailList ( ) ) {
@ -281,6 +322,8 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
shippingOrderManagementDetailRepository . update ( detail ) ;
break ;
}
final String confirmPartType = getConfirmPartType ( orderManagement ) ;
}
if ( ! scanFlg ) {
@ -425,10 +468,22 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
private List < MesShippingOrderManagementDetail > getMesShippingOrderManagementDetails ( MesShippingOrderManagement orderManagement , MesPartShippingGroup mesPartShippingGroup ) {
//45550 PDA-MES-PDA发运扫描排序方式修改
List < MesConfig > shippingBusiSoftCfgList = mesConfigService . getConfigList ( orderManagement . getOrganizeCode ( ) ,
MesCommonConstant . SHIPPING_BUSI_SOFT_CFG , mesPartShippingGroup . getShippingGroupCode ( ) , null ) ;
DdlPackBean orderDetailPackBean = DdlPackBean . getDdlPackBean ( orderManagement . getOrganizeCode ( ) ) ;
DdlPreparedPack . getNumEqualPack ( orderManagement . getId ( ) , "pid" , orderDetailPackBean ) ;
DdlPreparedPack . getNumberSmallerPack ( MesExtEnumUtil . SHIPPING_ORDER_DETAIL_SHIPPING_STATUS . CLOSE . getValue ( ) , "status" , orderDetailPackBean ) ;
DdlPreparedPack . getOrderByPack ( new Object [ ] { CommonEnumUtil . ASC_OR_DESC . ASC . getValue ( ) } , new String [ ] { "custInfoSeq" } , orderDetailPackBean ) ;
if ( CollectionUtils . isEmpty ( shippingBusiSoftCfgList ) ) {
DdlPreparedPack . getOrderByPack ( new Object [ ] { CommonEnumUtil . ASC_OR_DESC . ASC . getValue ( ) } , new String [ ] { "custInfoSeq" } , orderDetailPackBean ) ;
} else {
MesConfig mesConfig = shippingBusiSoftCfgList . get ( 0 ) ;
if ( ! Objects . isNull ( mesConfig ) & &
! StringUtils . isEmpty ( mesConfig . getCfgValue ( ) ) & &
"logic_seq" . equals ( mesConfig . getCfgValue ( ) ) ) {
DdlPreparedPack . getOrderByPack ( new Object [ ] { CommonEnumUtil . ASC_OR_DESC . ASC . getValue ( ) } , new String [ ] { "logicSeq" } , orderDetailPackBean ) ;
}
}
List < MesShippingOrderManagementDetail > detailList = shippingOrderManagementDetailRepository . findByHqlWhere ( orderDetailPackBean ) ;
if ( CollectionUtils . isEmpty ( detailList ) ) {
throw new ImppBusiException ( String . format ( "发运单【%s】明细信息不存在, 请检查数据! " , orderManagement . getShippingCode ( ) ) ) ;
@ -538,10 +593,10 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
private void checkStatus ( MesSortShippingCheckModel model , MesProduceSn produceSn ) {
//校验产品条码状态 必须是状态为已下线条码
// if (produceSn.getSnStatus() != MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue() && produceSn.getSnStatus() != MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()) {
// throw new ImppBusiException(String.format("【%s】此条码状态为【%s】,请选择状态为【%s】或【%s】状态的条码, 请检查数据! ", model.getSn(), MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSn.getSnStatus()),
// MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getDescription(),MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getDescription()));
// }
if ( produceSn . getSnStatus ( ) ! = MesExtEnumUtil . PRODUCE_SN_STATUS . OFFLINE . getValue ( ) & & produceSn . getSnStatus ( ) ! = MesExtEnumUtil . PRODUCE_SN_STATUS . CREATE . getValue ( ) ) {
throw new ImppBusiException ( String . format ( "【%s】此条码状态为【%s】,请选择状态为【%s】或【%s】状态的条码, 请检查数据! " , model . getSn ( ) , MesExtEnumUtil . PRODUCE_SN_STATUS . valueOfDescription ( produceSn . getSnStatus ( ) ) ,
MesExtEnumUtil . PRODUCE_SN_STATUS . OFFLINE . getDescription ( ) , MesExtEnumUtil . PRODUCE_SN_STATUS . CREATE . getDescription ( ) ) ) ;
}
//校验产品质量状态 必须是状态为合格条码
if ( produceSn . getQcStatus ( ) ! = MesExtEnumUtil . PRODUCE_QC_STATUS . QUALIFIED . getValue ( ) ) {
throw new ImppBusiException ( String . format ( "【%s】此条码质量状态为【%s】,请选择【%s】状态的条码, 请检查数据! " , model . getSn ( ) , MesExtEnumUtil . PRODUCE_QC_STATUS . valueOfDescription ( produceSn . getQcStatus ( ) ) ,
@ -612,6 +667,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
//查询条码信息
Map < String , List < MesProduceSn > > produceSnByCustSnMap = getProduceSnByCustSnMap ( orderManagement . getIsEnableMemory ( ) , organizeCode , detailList . stream ( ) . map ( MesShippingOrderManagementDetail : : getBarcode ) . filter ( barCode - > ! StringUtil . isEmptyAndNull ( barCode ) ) . collect ( Collectors . toList ( ) ) ) ;
final String confirmPartType = getConfirmPartType ( orderManagement ) ;
List < MesProduceSn > produceSnList = new ArrayList < > ( ) ;
List < String > workOrderNoList = new ArrayList < > ( ) ;
List < MesShippingSnUnique > mesShippingSnUniqueList = new ArrayList < > ( ) ;
@ -640,9 +696,16 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
workOrderNoList . add ( detail . getVisualOrderNo ( ) ) ;
//更新应急件库位管理库存出库
mesEmergencyLocationService . doShippingStockOutOnline ( organizeCode , detail . getVisualOrderNo ( ) , userInfo , true ) ;
//条码格式(扫描目视单,扫描条码)
// detail.setBarcode(new StringJoiner(MesPcnExtConstWords.COMMA).add(detail.getVisualOrderNo()).add(detail.getBarcode()).toString());
detail . setBarcode ( detail . getBarcode ( ) + "," + detail . getPartPosition ( ) ) ;
// 保存到发运队列,后续发运单的条码会拼接,而保存到发运队列中的为拼接前的数据,因此要在拼接前调用。
saveShippingQueue ( orderManagement , detail , userInfo ) ;
if ( ! Objects . equals ( confirmPartType , String . valueOf ( MesExtEnumUtil . SHIPPING_GROUP_CONFIRM_PART_TYPE . SHIPPING_GROUP_CONFIRM_PART_TYPE_40 . getValue ( ) ) ) ) {
if ( Objects . equals ( confirmPartType , String . valueOf ( MesExtEnumUtil . SHIPPING_GROUP_CONFIRM_PART_TYPE . SHIPPING_GROUP_CONFIRM_PART_TYPE_50 . getValue ( ) ) ) ) {
detail . setBarcode ( detail . getBarcode ( ) + "," + detail . getPartPosition ( ) ) ;
} else {
//条码格式(扫描目视单,扫描条码)
detail . setBarcode ( new StringJoiner ( MesPcnExtConstWords . COMMA ) . add ( detail . getVisualOrderNo ( ) ) . add ( detail . getBarcode ( ) ) . toString ( ) ) ;
}
}
}
}
//客供品移库
@ -685,7 +748,9 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
DdlPreparedPack . getNumEqualPack ( orderManagement . getLoadingListId ( ) , "pid" , orderManagementPackBean ) ;
DdlPreparedPack . getNumberSmallerEqualPack ( MesExtEnumUtil . LOADING_ORDER_DETAIL_SHIPPING_STATUS . SKIP . getValue ( ) , "status" , orderManagementPackBean ) ;
List < MesLoadingListDetail > listDetails = vehiclesOrderDetailRepository . findByHqlWhere ( orderManagementPackBean ) ;
if ( CollectionUtils . isEmpty ( listDetails ) ) return ;
if ( CollectionUtils . isEmpty ( listDetails ) ) {
return ;
}
List < String > shippingCodeList = listDetails . stream ( ) . map ( MesLoadingListDetail : : getShippingCode ) . collect ( Collectors . toList ( ) ) ;
orderManagementPackBean = DdlPackBean . getDdlPackBean ( organizeCode ) ;
@ -759,6 +824,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
return rule ;
}
@Override
public List < MesJisShipping > getMesJisShippings ( MesShippingOrderManagement mesShippingOrderManagement , List < MesShippingOrderManagementDetail > shippingOrderManagementDetails , String userName ) {
if ( CollectionUtils . isEmpty ( shippingOrderManagementDetails ) ) {
DdlPackBean detailPackBean = DdlPackBean . getDdlPackBean ( mesShippingOrderManagement . getOrganizeCode ( ) ) ;
@ -783,7 +849,9 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
private void updateShippingOrderDetails ( String organizeCode , String userName , long id ) {
if ( StringUtils . isEmpty ( id ) | | StringUtils . isEmpty ( organizeCode ) ) return ;
if ( StringUtils . isEmpty ( id ) | | StringUtils . isEmpty ( organizeCode ) ) {
return ;
}
DdlPackBean packBean = DdlPackBean . getDdlPackBean ( organizeCode ) ;
DdlPreparedPack . getNumEqualPack ( id , "pid" , packBean ) ;
shippingOrderManagementDetailRepository . updateByProperties ( new String [ ] { "modifyUser" , "modifyDatetime" , "status" , "remark" } ,
@ -835,4 +903,39 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
}
}
private void saveShippingQueue ( MesShippingOrderManagement orderManagement , MesShippingOrderManagementDetail detail , String userInfo ) {
if ( StringUtil . isEmpty ( detail . getVin ( ) ) ) {
MesPcnException . throwMesBusiException ( "发运单【%s】零件号【%s】vin号为空, 请检查数据" , orderManagement . getShippingCode ( ) , detail . getPartNo ( ) ) ;
}
final boolean matchCfgValue = mesConfigService . checkCfgValueIsContainItem ( orderManagement . getOrganizeCode ( ) , MesPcnExtConstWords . MES_SHIPPING_QUEUE_SAVE_CFG , null , null , "," , orderManagement . getShippingGroupCode ( ) ) ;
if ( ! matchCfgValue ) {
return ;
}
MesShippingQueue mesShippingQueue = new MesShippingQueue ( ) ;
mesShippingQueue . setOrganizeCode ( orderManagement . getOrganizeCode ( ) ) ;
mesShippingQueue . setShippingCode ( orderManagement . getShippingCode ( ) ) ;
mesShippingQueue . setShippingGroupCode ( orderManagement . getShippingGroupCode ( ) ) ;
mesShippingQueue . setShippingType ( orderManagement . getShippingType ( ) ) ;
mesShippingQueue . setWorkOrderNo ( detail . getVisualOrderNo ( ) ) ;
mesShippingQueue . setCustSn ( detail . getBarcode ( ) ) ;
mesShippingQueue . setPartNo ( detail . getPartNo ( ) ) ;
mesShippingQueue . setPartName ( detail . getPartName ( ) ) ;
mesShippingQueue . setVin ( detail . getVin ( ) ) ;
mesShippingQueue . setQueueStatus ( MesExtEnumUtil . QUEUE_ORDER_STATUS . CREATE . getValue ( ) ) ;
ConvertBean . serviceModelInitialize ( mesShippingQueue , userInfo ) ;
shippingQueueRDao . insert ( mesShippingQueue ) ;
}
private String getConfirmPartType ( MesShippingOrderManagement orderManagement ) {
if ( StringUtils . isEmpty ( orderManagement . getShippingGroupCode ( ) ) ) {
return "" ;
}
MesPartShippingGroup shippingGroup = mesPartShippingGroupService . getMesPartShippingGroup ( orderManagement . getOrganizeCode ( ) , orderManagement . getShippingGroupCode ( ) ) ;
if ( shippingGroup = = null ) {
return "" ;
}
return shippingGroup . getConfirmPartType ( ) ;
}
}