@ -129,7 +129,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
// 生成成品条码
else if ( mesBaseBarcodeInfo . getBarcodeType ( ) . equals ( MesConstants . MES_BARCODE_TYPE_PRODUCT ) ) {
generateProductBarcode ( mesBaseBarcodeInfo ) ;
} else { //生成 背板条码或者门板条 码
} else { //生成 配对 码
generateBindBarcode ( mesBaseBarcodeInfo ) ;
}
@ -282,6 +282,9 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
Long materialId ;
String barcode = Seq . getId ( Seq . mesCompBarcodeSeqType , Seq . mesCompBarcodeCode ) ;
Date currentDate = new Date ( ) ;
String userName = SecurityUtils . getUsername ( ) ;
//在五楼根据原材料条码单独生成成品条码
if ( StringUtils . isNotEmpty ( mesBaseBarcodeInfo . getSingleFlag ( ) ) & &
mesBaseBarcodeInfo . getSingleFlag ( ) . equals ( MesConstants . MES_BARCODE_SINGLE_FLAG_YES ) ) {
@ -295,40 +298,66 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException ( "此条码为非原材料条码,不能生成成品条码" ) ;
}
MesBaseBarcodeInfo bindBarcode = mesBaseBarcodeInfoMapper . selectMesBaseBarcodeInfoByBindBarcode ( rawMaterialBarcode ) ;
if ( bindBarcode = = null ) {
throw new ServiceException ( "此原材料条码没有绑定背板或门板" ) ;
}
MesBaseBarcodeInfo productBarcodeInfo = mesBaseBarcodeInfoMapper . selectMesBaseBarcodeInfoByProductBarcode ( rawMaterialBarcode ) ;
if ( productBarcodeInfo ! = null ) {
throw new ServiceException ( "此原材料条码已经生成过成品条码,不能重复生成" ) ;
}
planCode = bindBarcode . getPlanCode ( ) ;
planDetailCode = bindBarcode . getPlanDetailCode ( ) ;
saleOrderId = bindBarcode . getSaleOrderId ( ) ;
saleOrderCode = bindBarcode . getSaleorderCode ( ) ;
materialId = rawBarcode . getMaterialId ( ) ;
MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper . selectMesProductPlanDetailByMaterialBarcode ( rawMaterialBarcode ) ;
if ( mesProductPlanDetail = = null ) {
throw new ServiceException ( "此条码没有生产明细" ) ;
}
if ( ! mesProductPlanDetail . getPlanDetailStatus ( ) . equals ( MesConstants . MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH ) ) {
throw new ServiceException ( "生产明细还未结束" ) ;
}
planCode = mesProductPlanDetail . getPlanCode ( ) ;
planDetailCode = mesProductPlanDetail . getPlanDetailCode ( ) ;
if ( StringUtils . isEmpty ( planCode ) | | StringUtils . isEmpty ( planDetailCode ) ) {
throw new ServiceException ( "绑定的门板或背板条码有误" ) ;
throw new ServiceException ( "绑定的 配对 码有误") ;
}
if ( StringUtils . isEmpty ( rawBarcode . getPalletInfoCode ( ) ) ) {
throw new ServiceException ( "此条码有误,未绑定托盘信息" ) ;
throw new ServiceException ( "此条码 未绑定托盘信息") ;
}
mesBaseBarcodeInfo . setPalletInfoCode ( rawBarcode . getPalletInfoCode ( ) ) ;
MesProductPlan productPlan = mesProductPlanMapper . selectOnlyMesProductPlanByPlanCode ( planCode ) ;
if ( productPlan = = null ) {
throw new ServiceException ( "此生产派工不存在" ) ;
}
saleOrderId = rawBarcode . getSaleOrderId ( ) ;
saleOrderCode = rawBarcode . getSaleorderCode ( ) ;
materialId = productPlan . getMaterialId ( ) ;
mesBaseBarcodeInfo . setPalletInfoCode ( rawBarcode . getPalletInfoCode ( ) ) ; //重新绑定托盘号
mesBaseBarcodeInfo . setBindStatus ( MesConstants . MES_BARCODE_BIND_STATUS_BINDING ) ;
//取消托盘信息此原材料条码的绑定信息
MesBasePalletInfo mesBasePalletInfo = mesBasePalletInfoMapper . selectMesBasePalletInfoByPalletInfoCode ( rawBarcode . getPalletInfoCode ( ) ) ;
mesBasePalletInfo . setMaterialBarcode ( barcode ) ;
mesBasePalletInfo . setMaterialId ( materialId ) ;
mesBasePalletInfo . setUpdateTime ( currentDate ) ;
mesBasePalletInfo . setUpdateBy ( userName ) ;
mesBasePalletInfoMapper . updateMesBasePalletInfo ( mesBasePalletInfo ) ;
//取消原材料条码的托盘绑定信息
rawBarcode . setPalletInfoCode ( "" ) ;
rawBarcode . setBindStatus ( MesConstants . MES_BARCODE_BIND_STATUS_UNBINDING ) ;
rawBarcode . setUpdateTime ( currentDate ) ;
rawBarcode . setUpdateBy ( userName ) ;
mesBaseBarcodeInfoMapper . updateMesBaseBarcodeInfo ( rawBarcode ) ;
mesProductPlanDetail . setMaterialBarcode ( barcode ) ;
mesProductPlanDetail . setUpdateBy ( userName ) ;
mesProductPlanDetail . setUpdateTime ( currentDate ) ;
mesProductPlanDetailMapper . updateMesProductPlanDetail ( mesProductPlanDetail ) ;
} else {
planCode = mesBaseBarcodeInfo . getPlanCode ( ) ;
planDetailCode = mesBaseBarcodeInfo . getPlanDetailCode ( ) ;
@ -358,16 +387,13 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
saleOrderId = productPlan . getSaleOrderId ( ) ;
saleOrderCode = productPlan . getSaleorderCode ( ) ;
materialId = productPlan . getMaterialId ( ) ;
materialId = productPlan . getMaterialId ( ) ; //在生产计划的materialid是根据saletype保存, 如果是外部销售则保存productorder中的materialid, 如果是内部生产则保存prpductorder中的producematerialid
MesProductOrder mesProductOrder = mesProductOrderMapper . selectMesProductOrderByProductOrderId ( productPlan . getProductOrderId ( ) ) ;
mesBaseBarcodeInfo . setCompleteFlag ( mesProductOrder . getSaleType ( ) . equals ( MesConstants . MES_PRODUCT_ORDER_SALE )
? MesConstants . MES_BASE_BARCODE_COMPLETE_FLAG_YES : MesConstants . MES_BASE_BARCODE_COMPLETE_FLAG_NO ) ;
}
Date currentDate = new Date ( ) ;
mesBaseBarcodeInfo . setBatchCode ( barcode ) ; // 成品的批次代码 == 条码内容
mesBaseBarcodeInfo . setBarcodeInfo ( barcode ) ;
mesBaseBarcodeInfo . setAmount ( new BigDecimal ( 1 ) ) ;
@ -380,7 +406,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesBaseBarcodeInfo . setPlanCode ( planCode ) ;
mesBaseBarcodeInfo . setPlanDetailCode ( planDetailCode ) ;
mesBaseBarcodeInfo . setCreateTime ( currentDate ) ;
mesBaseBarcodeInfo . setCreateBy ( SecurityUtils. getUsername ( ) ) ;
mesBaseBarcodeInfo . setCreateBy ( userName ) ;
mesBaseBarcodeInfoMapper . insertMesBaseBarcodeInfo ( mesBaseBarcodeInfo ) ;
@ -417,7 +443,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
Date currentDate = new Date ( ) ;
for ( int i = 0 ; i < barcodeAmount ; i + + ) {
String barcode = Seq . getId ( Seq . mes CompBarcodeSeqType, Seq . mesComp BarcodeCode) ;
String barcode = Seq . getId ( Seq . mes BindBarcodeSeqType, Seq . mesBind BarcodeCode) ;
mesBaseBarcodeInfo . setBatchCode ( barcode ) ; // 成品的批次代码 == 条码内容
mesBaseBarcodeInfo . setBarcodeInfo ( barcode ) ;
mesBaseBarcodeInfo . setAmount ( new BigDecimal ( 1 ) ) ;
@ -429,6 +455,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesBaseBarcodeInfo . setPrintFlag ( MesConstants . MES_BARCODE_PRINT_FLAG_NO ) ;
mesBaseBarcodeInfo . setSaleOrderId ( productPlan . getSaleOrderId ( ) ) ;
mesBaseBarcodeInfo . setSaleorderCode ( productPlan . getSaleorderCode ( ) ) ;
mesBaseBarcodeInfo . setPlanDetailCode ( null ) ;
mesBaseBarcodeInfo . setCreateTime ( currentDate ) ;
mesBaseBarcodeInfo . setCreateBy ( userName ) ;
@ -714,7 +741,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
/ * *
* 绑定 条 码 信 息 ( 适 用 于 五 楼 柜 体 拆 分 区 )
* 配对 条 码 信 息 ( 适 用 于 五 楼 柜 体 拆 分 区 )
*
* @param mesBindBarcodeVo
* @return
@ -763,7 +790,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
/ * *
* 查 询 条 码 信 息
*
* @param bindBarcode 绑定 条 码 信 息
* @param bindBarcode 配对 条 码 信 息
* @return 条 码 信 息
* /
@Override
@ -772,6 +799,18 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
}
/ * *
* 查 询 条 码 信 息
*
* @param productBarcode 在 5 楼 成 品 入 库 时 贴 成 品 条 码 , 此 码 作 为 之 前 的 原 材 料 码 ; 在 4 楼 的 成 品 到 5 楼 时 需 要 生 成 原 材 料 条 码 时 , 此 字 段 作 为 之 前 的 成 品 条 码
* @return 条 码 信 息
* /
@Override
public MesBaseBarcodeInfo selectMesBaseBarcodeInfoByProductBarcode ( String productBarcode ) {
return mesBaseBarcodeInfoMapper . selectMesBaseBarcodeInfoByProductBarcode ( productBarcode ) ;
}
/ * *
* 验 证 成 品 条 码 信 息 ( 是 否 是 对 内 生 产 的 )
*
@ -814,7 +853,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
@Override
public int insertInternalMesBaseBarcode ( MesBaseBarcodeInfo mesBaseBarcodeInfo ) {
String productBarcode = mesBaseBarcodeInfo . getProductBarcode ( ) ;
//先 判断此成品条码是否有绑定过原材料条码
//先 获取此4楼的成品条码。 判断此成品条码是否有绑定过原材料条码
MesBaseBarcodeInfo bindProductBarcodeInfo = mesBaseBarcodeInfoMapper . selectMesBaseBarcodeInfoByProductBarcode ( productBarcode ) ;
if ( bindProductBarcodeInfo ! = null ) {
throw new ServiceException ( "此成品条码已经打印过原材料条码,无需重复打印" ) ;
@ -850,12 +889,24 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
if ( productBarcodeInfo = = null ) {
throw new ServiceException ( "成品条码不存在" ) ;
}
if ( StringUtils . isEmpty ( productBarcodeInfo . getPalletInfoCode ( ) ) ) {
throw new ServiceException ( "此成品还未绑定托盘信息" ) ;
}
productBarcodeInfo . setPalletInfoCode ( "" ) ;
productBarcodeInfo . setBindStatus ( MesConstants . MES_BARCODE_BIND_STATUS_UNBINDING ) ;
productBarcodeInfo . setUpdateTime ( currentDate ) ;
productBarcodeInfo . setUpdateBy ( userName ) ;
mesBaseBarcodeInfoMapper . updateMesBaseBarcodeInfo ( productBarcodeInfo ) ;
//更新此成品码之前的配对码的绑定码
MesBaseBarcodeInfo queryBarcodeInfo = new MesBaseBarcodeInfo ( ) ;
queryBarcodeInfo . setBindBarcode ( productBarcode ) ;
List < MesBaseBarcodeInfo > bindBarcodes = mesBaseBarcodeInfoMapper . selectMesBaseBarcodeInfoList ( queryBarcodeInfo ) ;
if ( bindBarcodes = = null | | bindBarcodes . isEmpty ( ) ) {
throw new ServiceException ( "此成品码没有配对码信息" ) ;
}
mesBaseBarcodeInfo . setBarcodeInfo ( barcodeInfo ) ;
mesBaseBarcodeInfo . setBatchCode ( barcodeInfo ) ;
mesBaseBarcodeInfo . setBatchFlag ( MesConstants . NOT_IS_BATCH ) ;
@ -863,6 +914,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesBaseBarcodeInfo . setBarcodeType ( MesConstants . MES_BARCODE_TYPE_RAW ) ;
mesBaseBarcodeInfo . setPalletInfoCode ( basePalletInfo . getPalletInfoCode ( ) ) ;
mesBaseBarcodeInfo . setSingleFlag ( MesConstants . MES_BARCODE_SINGLE_FLAG_INTERNAL ) ;
mesBaseBarcodeInfo . setCompleteFlag ( productBarcodeInfo . getCompleteFlag ( ) ) ;
if ( productBarcodeInfo . getSaleOrderId ( ) ! = null & & ! productBarcodeInfo . getSaleOrderId ( ) . equals ( 0 L ) ) {
mesBaseBarcodeInfo . setSaleOrderId ( productBarcodeInfo . getSaleOrderId ( ) ) ;
mesBaseBarcodeInfo . setSaleorderCode ( productBarcodeInfo . getSaleorderCode ( ) ) ;
@ -890,14 +942,16 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
String barcodeType = mesBaseBarcodeInfo . getBarcodeType ( ) ;
String oldBarcode = mesBaseBarcodeInfo . getBarcodeInfo ( ) ;
String newBarcode = "" ;
String errorMsg = "" ;
switch ( barcodeType ) {
case MesConstants . MES_BARCODE_TYPE_RAW :
WmsRawStockVo queryRawStockVo = new WmsRawStockVo ( ) ;
queryRawStockVo . setInstockBatch ( oldBarcode ) ;
R < Boolean > isExistRawStock = remoteWmsService . isExistRawStock ( queryRawStockVo , SecurityConstants . INNER ) ;
if ( isExistRawStock . getData ( ) ) {
throw new ServiceException ( "此物料条码存在 库存信息,不能重新生成") ;
throw new ServiceException ( "此物料条码存在 原料 库存信息,不能重新生成") ;
}
errorMsg = "此原材料条码已经生成过成品条码,不能重新生成" ;
newBarcode = Seq . getId ( Seq . mesBarcodeSeqType , Seq . mesBarcodeCode ) ;
break ;
case MesConstants . MES_BARCODE_TYPE_PRODUCT :
@ -905,8 +959,9 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
queryProductStockVo . setProductBatch ( oldBarcode ) ;
R < Boolean > isExistProductStock = remoteWmsService . isExistProductStock ( queryProductStockVo , SecurityConstants . INNER ) ;
if ( isExistProductStock . getData ( ) ) {
throw new ServiceException ( "此物料条码存在 库存信息,不能重新生成") ;
throw new ServiceException ( "此物料条码存在 成品 库存信息,不能重新生成") ;
}
errorMsg = "此成品条码已经生成过原材料条码,不能重新生成" ;
newBarcode = Seq . getId ( Seq . mesCompBarcodeSeqType , Seq . mesCompBarcodeCode ) ;
break ;
case MesConstants . MES_BARCODE_TYPE_BIND :
@ -914,6 +969,11 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
break ;
}
MesBaseBarcodeInfo productBarcodeInfo = mesBaseBarcodeInfoMapper . selectMesBaseBarcodeInfoByProductBarcode ( oldBarcode ) ;
if ( productBarcodeInfo ! = null ) {
throw new ServiceException ( errorMsg ) ;
}
String userName = SecurityUtils . getUsername ( ) ;
Date currentDate = new Date ( ) ;
MesBaseAbandonBarcode mesBaseAbandonBarcode = new MesBaseAbandonBarcode ( ) ;
@ -923,6 +983,14 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
mesBaseAbandonBarcode . setUpdateTime ( currentDate ) ;
mesBaseAbandonBarcodeMapper . insertMesBaseAbandonBarcode ( mesBaseAbandonBarcode ) ;
MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper . selectMesProductPlanDetailByMaterialBarcode ( oldBarcode ) ;
if ( mesProductPlanDetail ! = null ) {
mesProductPlanDetail . setMaterialBarcode ( newBarcode ) ;
mesProductPlanDetail . setUpdateTime ( currentDate ) ;
mesProductPlanDetail . setUpdateBy ( userName ) ;
mesProductPlanDetailMapper . updateMesProductPlanDetail ( mesProductPlanDetail ) ;
}
MesBasePalletInfo basePalletInfo = mesBasePalletInfoMapper . selectMesBasePalletInfoByBarcode ( oldBarcode ) ;
if ( basePalletInfo ! = null ) {
basePalletInfo . setMaterialBarcode ( newBarcode ) ;