@ -177,15 +177,12 @@ public class SplitSfcServiceImpl extends ServiceImpl<SplitSfcMapper, SplitSfc> i
SplitSfcDto splitSfcDto = splitSfcMapper . getAbnormalQty ( site , sfc , operation , abnormalNo ) ;
String routerBo = splitSfcDto . getRouterBo ( ) ;
String ncCode = splitSfcDto . getNcCode ( ) ;
if ( StringUtil . isBlank ( routerBo ) ) {
throw new BaseException ( "异常处置未选择处置工艺路线" ) ;
}
if ( StringUtil . isBlank ( ncCode ) ) {
throw new BaseException ( "异常处置未选择不良代码" ) ;
}
BigDecimal sfcQty = new BigDecimal ( sfcData . getQty ( ) ) ;
if ( new BigDecimal ( splitSfcDto . getNcQty ( ) ) . compareTo ( sfcQty ) > = 0 ) {
throw new BaseException ( "质量异常数量 不小 于于产品条码的数量,不能拆分") ;
throw new BaseException ( "质量异常数量 大于等 于于产品条码的数量,不能拆分") ;
}
if ( splitQty . compareTo ( new BigDecimal ( splitSfcDto . getNcQty ( ) ) ) > 0 ) {
throw new BaseException ( "拆分数量大于质量异常数量的数量,不能拆分" ) ;
@ -206,37 +203,42 @@ public class SplitSfcServiceImpl extends ServiceImpl<SplitSfcMapper, SplitSfc> i
Collection < SplitSfcResponse > splitSfcResponses = splitService . splitSfc ( splitSfcRequest ) ;
SplitSfcResponse splitSfcResponse = splitSfcResponses . iterator ( ) . next ( ) ;
String newSfcRef = splitSfcResponse . getNewSfcRef ( ) ;
//记录不合格
CreateNCRequest createNCRequest = new CreateNCRequest ( ) ;
createNCRequest . setQty ( splitQty ) ;
createNCRequest . setSfcRef ( newSfcRef ) ;
ProductionContext productionContext = new ProductionContext ( ) ;
StepIdentifier stepIdentifier = new StepIdentifier ( ) ;
stepIdentifier . setStepId ( sfcData . getStepId ( ) ) ;
stepIdentifier . setOperationId ( sfcData . getOperation ( ) ) ;
productionContext . setStepIdentifier ( stepIdentifier ) ;
List < StepOperation > resourceBySfc = sfcCrossMapper . getResourceBySfc ( site , sfc ) ;
if ( resourceBySfc . isEmpty ( ) ) {
throw new BaseException ( "产品不在工作中" ) ;
String newSfc = StringUtil . trimHandle ( newSfcRef ) ;
if ( StringUtil . notBlank ( routerBo ) ) {
//记录不合格
CreateNCRequest createNCRequest = new CreateNCRequest ( ) ;
createNCRequest . setQty ( splitQty ) ;
createNCRequest . setSfcRef ( newSfcRef ) ;
ProductionContext productionContext = new ProductionContext ( ) ;
StepIdentifier stepIdentifier = new StepIdentifier ( ) ;
stepIdentifier . setStepId ( sfcData . getStepId ( ) ) ;
stepIdentifier . setOperationId ( sfcData . getOperation ( ) ) ;
productionContext . setStepIdentifier ( stepIdentifier ) ;
List < StepOperation > resourceBySfc = sfcCrossMapper . getResourceBySfc ( site , sfc ) ;
if ( resourceBySfc . isEmpty ( ) ) {
throw new BaseException ( "产品不在工作中" ) ;
}
productionContext . setResourceRef ( resourceBySfc . get ( 0 ) . getResourceBo ( ) ) ;
createNCRequest . setProdCtx ( productionContext ) ;
createNCRequest . setNcCodeRef ( HandleEnum . NC_CODE . getHandle ( site , splitNcCode [ 0 ] ) ) ;
ncProductionService . createNC ( createNCRequest ) ;
//不合格处置特殊工艺路线
DispositionMultipleSfcsRequest dispositionSfcsRequest = new DispositionMultipleSfcsRequest ( ) ;
List < String > sfcs = new ArrayList < > ( ) ;
sfcs . add ( newSfcRef ) ;
dispositionSfcsRequest . setSfcs ( sfcs ) ;
dispositionSfcsRequest . setBypassStepValidation ( true ) ;
DispositionSelection dispositionSelection = new DispositionSelection ( ) ;
Router maxRevisionRouter = routerService . getMaxRevisionRouter ( site , StringUtil . trimHandle ( routerBo ) ) ;
dispositionSelection . setRouterRef ( maxRevisionRouter . getHandle ( ) ) ;
dispositionSfcsRequest . setDispositionSelection ( dispositionSelection ) ;
dispositionSfcsRequest . setProdCtx ( new ProductionContext ( ) ) ;
ncProductionService . dispositionMultipleSfcs ( dispositionSfcsRequest ) ;
String workCenterBo = shopOrderService . getById ( HandleEnum . SHOP_ORDER . getHandle ( site , sfcData . getShopOrder ( ) ) ) . getPlannedWorkCenterBo ( ) ;
sfcDispatchCommonService . saveSfcDispatch ( site , CommonMethods . getUser ( ) , StringUtil . trimHandle ( workCenterBo ) , newSfc , sfcData . getShopOrder ( ) , maxRevisionRouter . getHandle ( ) ) ;
}
productionContext . setResourceRef ( resourceBySfc . get ( 0 ) . getResourceBo ( ) ) ;
createNCRequest . setProdCtx ( productionContext ) ;
createNCRequest . setNcCodeRef ( HandleEnum . NC_CODE . getHandle ( site , splitNcCode [ 0 ] ) ) ;
ncProductionService . createNC ( createNCRequest ) ;
//不合格处置特殊工艺路线
DispositionMultipleSfcsRequest dispositionSfcsRequest = new DispositionMultipleSfcsRequest ( ) ;
List < String > sfcs = new ArrayList < > ( ) ;
sfcs . add ( newSfcRef ) ;
dispositionSfcsRequest . setSfcs ( sfcs ) ;
dispositionSfcsRequest . setBypassStepValidation ( true ) ;
DispositionSelection dispositionSelection = new DispositionSelection ( ) ;
Router maxRevisionRouter = routerService . getMaxRevisionRouter ( site , StringUtil . trimHandle ( routerBo ) ) ;
dispositionSelection . setRouterRef ( maxRevisionRouter . getHandle ( ) ) ;
dispositionSfcsRequest . setDispositionSelection ( dispositionSelection ) ;
dispositionSfcsRequest . setProdCtx ( new ProductionContext ( ) ) ;
ncProductionService . dispositionMultipleSfcs ( dispositionSfcsRequest ) ;
SplitSfc splitSfc = new SplitSfc ( ) ;
String newSfc = StringUtil . trimHandle ( newSfcRef ) ;
splitSfc . setHandle ( HandleEnum . SPLIT_SFC . getHandle ( site , newSfc ) ) ;
splitSfc . setSite ( site ) ;
splitSfc . setSfc ( sfc ) ;
@ -246,8 +248,6 @@ public class SplitSfcServiceImpl extends ServiceImpl<SplitSfcMapper, SplitSfc> i
splitSfc . setCreateUser ( CommonMethods . getUser ( ) ) ;
splitSfc . setCreatedDateTime ( LocalDateTime . now ( ) ) ;
save ( splitSfc ) ;
String workCenterBo = shopOrderService . getById ( HandleEnum . SHOP_ORDER . getHandle ( site , sfcData . getShopOrder ( ) ) ) . getPlannedWorkCenterBo ( ) ;
sfcDispatchCommonService . saveSfcDispatch ( site , CommonMethods . getUser ( ) , StringUtil . trimHandle ( workCenterBo ) , newSfc , sfcData . getShopOrder ( ) , maxRevisionRouter . getHandle ( ) ) ;
return splitSfc ;
} catch ( Exception e ) {
ExceptionUtil . throwException ( e ) ;