diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java index 4ba1d2a..f87f9c5 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBarcodeInfo.java @@ -43,6 +43,11 @@ public class MesBaseBarcodeInfo extends BaseEntity @Excel(name = "条码类型", readConverterExp = "1=原材料,2半成品,3成品,4背板") private String barcodeType; + /** + *单独成品条码标识(0否,1是),适合五楼打印成品条码使用 + */ + private String singleFlag; + /** 条码内容;如果是按单个物料贴,则一个物料一个条码,如果是按批次贴,则条码跟批次代码相同 */ @Excel(name = "条码内容") private String barcodeInfo; @@ -226,6 +231,15 @@ public class MesBaseBarcodeInfo extends BaseEntity { return barcodeType; } + + public String getSingleFlag() { + return singleFlag; + } + + public void setSingleFlag(String singleFlag) { + this.singleFlag = singleFlag; + } + public void setBarcodeInfo(String barcodeInfo) { this.barcodeInfo = barcodeInfo; diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java index 3f221ff..a65346e 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java @@ -140,6 +140,9 @@ public class MesConstants { /**工序类型*/ public static final String MES_PROCESS_TYPE_FIFTH_SPLIT = "1";//五楼拆分工序 + /**单独生成成品条码标识*/ + public static final String MES_BARCODE_SINGLE_FLAG_YES = "1";//是 + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBaseBarcodeInfoMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBaseBarcodeInfoMapper.java index 3f2cd63..8e0b360 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBaseBarcodeInfoMapper.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesBaseBarcodeInfoMapper.java @@ -73,13 +73,21 @@ public interface MesBaseBarcodeInfoMapper /** - * 查询条码信息 + * 查询条码信息,limit 1 * * @param bindBarcode 绑定条码信息 * @return 条码信息 */ public MesBaseBarcodeInfo selectMesBaseBarcodeInfoByBindBarcode(String bindBarcode); + /** + * 查询条码信息,limit 1 + * + * @param productBarcode 在5楼成品入库时贴成品条码,此码作为之前的原材料码;在4楼的成品到5楼时需要生成原材料条码时,此字段作为之前的成品条码 + * @return 条码信息 + */ + public MesBaseBarcodeInfo selectMesBaseBarcodeInfoByProductBarcode(String productBarcode); + /** * 获取物料条码信息数量 diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java index deefcc7..d539bfb 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseBarcodeInfoServiceImpl.java @@ -121,9 +121,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService // 生成成品条码 else if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_PRODUCT)) { generateProductBarcode(mesBaseBarcodeInfo); - } - - else{//生成背板条码或者门板条码 + } else {//生成背板条码或者门板条码 generateBackOrDoorBarcode(mesBaseBarcodeInfo); } @@ -197,6 +195,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService /** * 无采购订单生成条码信息 + * * @param mesBaseBarcodeInfo */ @Override @@ -213,16 +212,18 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService // 生成数量条的不同条码内容 toInsertedBarcodeInfo = getInsertedBarcodeInfo(mesBaseBarcodeInfo, batchCode, userName, currentDate); toInsertedBarcodeInfo.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES); + toInsertedBarcodeInfo.setSaleOrderId(0L); toInsertedBarcodeInfos.add(toInsertedBarcodeInfo); } - return mesBaseBarcodeInfoMapper.batchMesBaseBarcodeInfo(toInsertedBarcodeInfos); + return mesBaseBarcodeInfoMapper.batchMesBaseBarcodeInfo(toInsertedBarcodeInfos); } /** * 生成固定条码信息 + * * @param mesBaseBarcodeInfo */ @Override @@ -246,30 +247,78 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService public void generateProductBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { - String planCode = mesBaseBarcodeInfo.getPlanCode(); - String planDetailCode = mesBaseBarcodeInfo.getPlanDetailCode(); + String planCode; + String planDetailCode; + Long saleOrderId; + String saleOrderCode; + Long materialId; + if (mesBaseBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_YES)) { + String rawMaterialBarcode = mesBaseBarcodeInfo.getProductBarcode(); + MesBaseBarcodeInfo rawBarcode = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(rawMaterialBarcode); + if (rawBarcode == null) { + throw new ServiceException("原材料条码有误"); + } - MesBaseBarcodeInfo queryBarcodeInfo = new MesBaseBarcodeInfo(); - queryBarcodeInfo.setPlanDetailCode(planDetailCode); - List mesBaseBarcodeInfos = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoList(queryBarcodeInfo); + if (!rawBarcode.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW)) { + throw new ServiceException("此条码为非原材料条码,不能生成成品条码"); + } - if (mesBaseBarcodeInfos != null && !mesBaseBarcodeInfos.isEmpty()) { - throw new ServiceException("此生产明细已经生成条码,不能重复生成"); - } + MesBaseBarcodeInfo bindBarcode = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBindBarcode(rawMaterialBarcode); + if (bindBarcode == null) { + throw new ServiceException("此原材料条码没有绑定背板或门板"); + } - MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailCode(planDetailCode); - if (mesProductPlanDetail == null) { - throw new ServiceException("此生产明细不存在"); - } + MesBaseBarcodeInfo productBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByProductBarcode(rawMaterialBarcode); + if (productBarcodeInfo != null) { + throw new ServiceException("此原材料条码已经生成过成品条码,不能重复生成"); + } - if (!mesProductPlanDetail.getPlanDetailStatus().equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH) && - !mesProductPlanDetail.getPlanDetailStatus().equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_ABNORMAL_FINISH)) { - throw new ServiceException("此生产明细还未完成,不能打印条码"); - } + planCode = bindBarcode.getPlanCode(); + planDetailCode = bindBarcode.getPlanDetailCode(); + saleOrderId = bindBarcode.getSaleOrderId(); + saleOrderCode = bindBarcode.getSaleorderCode(); + materialId = rawBarcode.getMaterialId(); - MesProductPlan productPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanCode(planCode); - if (productPlan == null) { - throw new ServiceException("此生产派工不存在"); + if (StringUtils.isEmpty(planCode) || StringUtils.isEmpty(planDetailCode)) { + throw new ServiceException("绑定的门板或背板条码有误"); + } + + if (StringUtils.isEmpty(rawBarcode.getPalletInfoCode())) { + throw new ServiceException("此条码有误,未绑定托盘信息"); + } + + mesBaseBarcodeInfo.setPalletInfoCode(rawBarcode.getPalletInfoCode()); + + } else { + planCode = mesBaseBarcodeInfo.getPlanCode(); + planDetailCode = mesBaseBarcodeInfo.getPlanDetailCode(); + + MesBaseBarcodeInfo queryBarcodeInfo = new MesBaseBarcodeInfo(); + queryBarcodeInfo.setPlanDetailCode(planDetailCode); + List mesBaseBarcodeInfos = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoList(queryBarcodeInfo); + + if (mesBaseBarcodeInfos != null && !mesBaseBarcodeInfos.isEmpty()) { + throw new ServiceException("此生产明细已经生成条码,不能重复生成"); + } + + MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailCode(planDetailCode); + if (mesProductPlanDetail == null) { + throw new ServiceException("此生产明细不存在"); + } + + if (!mesProductPlanDetail.getPlanDetailStatus().equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH) && + !mesProductPlanDetail.getPlanDetailStatus().equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_ABNORMAL_FINISH)) { + throw new ServiceException("此生产明细还未完成,不能打印条码"); + } + + MesProductPlan productPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanCode(planCode); + if (productPlan == null) { + throw new ServiceException("此生产派工不存在"); + } + + saleOrderId = productPlan.getSaleOrderId(); + saleOrderCode = productPlan.getSaleorderCode(); + materialId = productPlan.getMaterialId(); } @@ -278,17 +327,17 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容 mesBaseBarcodeInfo.setBarcodeInfo(barcode); mesBaseBarcodeInfo.setAmount(new BigDecimal(1)); - mesBaseBarcodeInfo.setBatchFlag(MesConstants.NOT_IS_BATCH); - mesBaseBarcodeInfo.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES); - - mesBaseBarcodeInfo.setMaterialId(productPlan.getMaterialId()); + mesBaseBarcodeInfo.setSafeFlag(saleOrderId.equals(0L) ? MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES : MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO); + mesBaseBarcodeInfo.setMaterialId(materialId); mesBaseBarcodeInfo.setPrintFlag(MesConstants.MES_BARCODE_PRINT_FLAG_NO); - mesBaseBarcodeInfo.setSaleOrderId(productPlan.getSaleOrderId()); - mesBaseBarcodeInfo.setSaleorderCode(productPlan.getSaleorderCode()); - + mesBaseBarcodeInfo.setSaleOrderId(saleOrderId); + mesBaseBarcodeInfo.setSaleorderCode(saleOrderCode); + mesBaseBarcodeInfo.setPlanCode(planCode); + mesBaseBarcodeInfo.setPlanDetailCode(planDetailCode); mesBaseBarcodeInfo.setCreateTime(currentDate); mesBaseBarcodeInfo.setCreateBy(SecurityUtils.getUsername()); + mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo); } @@ -296,6 +345,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService /** * 生成背板或门板条码 + * * @param mesBaseBarcodeInfo */ public void generateBackOrDoorBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) { @@ -323,7 +373,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService } MesBaseBarcodeInfo bindBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(mesBaseBarcodeInfo.getBindBarcode()); - if(bindBarcodeInfo==null){ + if (bindBarcodeInfo == null) { throw new ServiceException("绑定的柜体码不存在"); } @@ -435,7 +485,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService List toUpdatedBaseBarcodeInfos = new ArrayList<>(); for (Long barcodeId : barcodeIds) { - printBarcodesByBarcodeId(barcodeId,printType); + printBarcodesByBarcodeId(barcodeId, printType); } // for (MesBaseBarcodeInfo toUpdateMesBaseBarcodeInfo : toUpdatedBaseBarcodeInfos) { @@ -463,7 +513,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService @Transactional(propagation = Propagation.REQUIRES_NEW) - public void printBarcodesByBarcodeId(Long barcodeId,String printType){ + public void printBarcodesByBarcodeId(Long barcodeId, String printType) { MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoJoinByBarcodeId(barcodeId); String printFlag = mesBaseBarcodeInfo.getPrintFlag(); if (printFlag.equals(MesConstants.MES_BARCODE_PRINT_FLAG_YES)) { diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml index 6795600..95ac1a6 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml @@ -11,6 +11,7 @@ + @@ -96,6 +97,7 @@ and bbi.print_flag = #{printFlag} and bbi.batch_flag = #{batchFlag} and bbi.barcode_type = #{barcodeType} + and bbi.single_flag = #{singleFlag} and bbi.barcode_info = #{barcodeInfo} and bbi.batch_code = #{batchCode} and bbi.pallet_info_code = #{palletInfoCode} @@ -140,6 +142,7 @@ print_flag, batch_flag, barcode_type, + single_flag, barcode_info, batch_code, pallet_info_code, @@ -175,6 +178,7 @@ #{printFlag}, #{batchFlag}, #{barcodeType}, + #{singleFlag}, #{barcodeInfo}, #{batchCode}, #{palletInfoCode}, @@ -268,7 +272,10 @@ - +