diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java index d306434..0fa0cd6 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/RemoteMesService.java @@ -156,4 +156,14 @@ public interface RemoteMesService { @GetMapping("/barcode/selectMesBaseBindBarcodeList/{barcodeId}") public R> selectMesBaseBindBarcodeList(@PathVariable("barcodeId") Long barcodeId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + /** + * 通过原材料条码查询绑定的成品条码信息 + * + * @param barcodeInfo 原材料条码 + * @param source 请求来源 + * @return 结果 + */ + @GetMapping("/barcode/selectBindBarcodeListByBarcodeInfo/{barcodeId}") + public R> selectBindBarcodeListByBarcodeInfo(@PathVariable("barcodeInfo") String barcodeInfo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); } diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBindBarcode.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBindBarcode.java index dcec64e..d4d8dce 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBindBarcode.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/domain/MesBaseBindBarcode.java @@ -26,6 +26,10 @@ public class MesBaseBindBarcode extends BaseEntity private Long saleOrderId; + private Long materialId; + + private Long productId; + /** 绑定的条码内容 */ @Excel(name = "绑定的条码内容") private String bindBarcode; @@ -65,6 +69,22 @@ public class MesBaseBindBarcode extends BaseEntity this.saleOrderId = saleOrderId; } + public Long getMaterialId() { + return materialId; + } + + public void setMaterialId(Long materialId) { + this.materialId = materialId; + } + + public Long getProductId() { + return productId; + } + + public void setProductId(Long productId) { + this.productId = productId; + } + public void setBindBarcode(String bindBarcode) { this.bindBarcode = bindBarcode; diff --git a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java index 1728b50..ad4e922 100644 --- a/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java +++ b/hw-api/hw-api-mes/src/main/java/com/hw/mes/api/factory/RemoteMesFallbackFactory.java @@ -88,6 +88,11 @@ public class RemoteMesFallbackFactory implements FallbackFactory> selectMesBaseBindBarcodeList(Long barcodeId, String source) { + return R.fail("根据原材料条码ID获取成品条码信息失败:" + throwable.getMessage()); + } + + @Override + public R> selectBindBarcodeListByBarcodeInfo(String barcodeInfo, String source) { return R.fail("根据原材料条码获取成品条码信息失败:" + throwable.getMessage()); } }; diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java index cdf0e21..293cf85 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java @@ -310,6 +310,50 @@ public class Seq { // 采购申请任务编号的记录标识 public static final String mesPurchaseApplyProcessCode = "CG"; + + + // 采购合并虚拟原材料条码内容记录标识 + public static final String mesPurchaseVirtualBarcodeSeqType = "VIRTUAL_BAR_CODE"; + + // 采购合并虚拟原材料条码内容序列数 + private static AtomicInteger mesPurchaseVirtualBarcodeSeq = new AtomicInteger(1); + + // 采购合并虚拟原材料条码内容标识 + public static final String mesPurchaseVirtualBarcodeCode = "VR"; + + + // 内部生产合并虚拟原材料条码内容记录标识 + public static final String mesInternalVirtualBarcodeSeqType = "INTERNAL_VIRTUAL_BAR_CODE"; + + // 内部生产虚拟原材料条码内容序列数 + private static AtomicInteger mesInternalVirtualBarcodeSeq = new AtomicInteger(1); + + // 内部生产虚拟原材料条码内容标识 + public static final String mesInternalVirtualBarcodeCode = "VI"; + + + + // 采购合并虚拟成品条码内容记录标识 + public static final String mesPurchaseVirtualProductBarcodeSeqType = "VIRTUAL_PRODUCT_BAR_CODE"; + + // 采购合并虚拟成品条码内容序列数 + private static AtomicInteger mesPurchaseVirtualProductBarcodeSeq = new AtomicInteger(1); + + // 采购合并虚拟成品条码内容标识 + public static final String mesPurchaseVirtualProductBarcodeCode = "VP"; + + + + // 内部生产合并虚拟成品条码内容记录标识 + public static final String mesInternalVirtualProductBarcodeSeqType = "INTERNAL_VIRTUAL_PRODUCT_BAR_CODE"; + + // 内部生产虚拟成品条码内容序列数 + private static AtomicInteger mesInternalVirtualProductBarcodeSeq = new AtomicInteger(1); + + // 内部生产虚拟成品条码内容标识 + public static final String mesInternalVirtualProductBarcodeCode = "VT"; + + /** * 获取通用序列号 * @@ -424,6 +468,14 @@ public class Seq { atomicInt = mesVirtualPurchasaeOrderSeq; }else if (mesPurchaseApplyProcessSeqType.equals(type)) { atomicInt = mesPurchaseApplyProcessSeq; + }else if (mesPurchaseVirtualBarcodeSeqType.equals(type)) { + atomicInt = mesPurchaseVirtualBarcodeSeq; + }else if (mesPurchaseVirtualProductBarcodeSeqType.equals(type)) { + atomicInt = mesPurchaseVirtualProductBarcodeSeq; + }else if (mesInternalVirtualBarcodeSeqType.equals(type)) { + atomicInt = mesInternalVirtualBarcodeSeq; + }else if (mesInternalVirtualProductBarcodeSeqType.equals(type)) { + atomicInt = mesInternalVirtualProductBarcodeSeq; } return getId(atomicInt, 3, code); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java index e0b5bbf..94d3fb6 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseBarcodeInfoController.java @@ -398,5 +398,15 @@ public class MesBaseBarcodeInfoController extends BaseController return R.ok(mesBaseBarcodeInfoService.selectMesBaseBindBarcodeList(queryBindBarcode)); } - + /** + * 查询原材料条码绑定的成品条码信息 + */ + @InnerAuth + @GetMapping(value="/selectBindBarcodeListByBarcodeInfo/{barcodeInfo}") + public R> selectBindBarcodeListByBarcodeInfo(@PathVariable("barcodeInfo") String barcodeInfo) + { + MesBaseBindBarcode queryBindBarcode = new MesBaseBindBarcode(); + queryBindBarcode.setBarcodeInfo(barcodeInfo); + return R.ok(mesBaseBarcodeInfoService.selectMesBaseBindBarcodeList(queryBindBarcode)); + } } 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 3b67d2c..15dbc7f 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 @@ -17,6 +17,7 @@ import com.hw.mes.domain.vo.MesBindBarcodeVo; import com.hw.mes.mapper.*; import java.text.DecimalFormat; +import java.util.stream.Collectors; import com.hw.printer.api.RemotePrinterService; import com.hw.printer.api.domain.vo.PrintContentVo; @@ -331,6 +332,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService throw new ServiceException("此生产明细已经生成条码,不能重复生成"); } + //根据生产明细代码获取生产明细 MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailCode(planDetailCode); if (mesProductPlanDetail == null) { throw new ServiceException("此生产明细不存在"); @@ -348,13 +350,14 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService Long saleOrderId = productPlan.getSaleOrderId(); String saleOrderCode = productPlan.getSaleorderCode(); - Long materialId = productPlan.getMaterialId();//在生产计划的materialid是根据saletype保存,如果是外部销售则保存productorder中的materialid,如果是内部生产则保存prpductorder中的producematerialid + Long materialId = null;//在生产计划的materialid是根据saletype保存,如果是外部销售则保存productorder中的materialid,如果是内部生产则保存prpductorder中的producematerialid - //在五楼根据原材料条码单独生成成品条码 + //五楼自检工序根据原材料条码生成成品条码 if (StringUtils.isNotEmpty(mesBaseBarcodeInfo.getSingleFlag()) && mesBaseBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_YES)) { String rawMaterialBarcode = mesBaseBarcodeInfo.getProductBarcode(); + MesBaseBarcodeInfo rawBarcode = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(rawMaterialBarcode); if (rawBarcode == null) { throw new ServiceException("原材料条码有误"); @@ -364,6 +367,12 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService throw new ServiceException("此条码为非原材料条码,不能生成成品条码"); } + if (rawMaterialBarcode.indexOf(Seq.mesPurchaseVirtualBarcodeCode) >= 0) { + barcode = Seq.getId(Seq.mesPurchaseVirtualProductBarcodeSeqType, Seq.mesPurchaseVirtualProductBarcodeCode); + } else if (rawMaterialBarcode.indexOf(Seq.mesInternalVirtualBarcodeCode) >= 0) { + barcode = Seq.getId(Seq.mesInternalVirtualProductBarcodeSeqType, Seq.mesInternalVirtualProductBarcodeCode); + } + MesBaseBarcodeInfo productBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByProductBarcode(rawMaterialBarcode); if (productBarcodeInfo != null) { throw new ServiceException("此原材料条码已经生成过成品条码,不能重复生成"); @@ -395,6 +404,13 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService throw new ServiceException("原材料条码的生产派工不存在"); } + if (!rawBarcodeProductPlan.getDispatchCode().equals(productPlan.getDispatchCode())) { + throw new ServiceException("派工单号不一致,当前派工单号:" + productPlan.getDispatchCode() + + ",原材料条码派工单号:" + rawBarcodeProductPlan.getDispatchCode()); + } + + + materialId = rawBarcode.getMaterialId(); mesBaseBarcodeInfo.setPalletInfoCode(rawBarcode.getPalletInfoCode());//重新绑定托盘号 mesBaseBarcodeInfo.setBindStatus(MesConstants.MES_BARCODE_BIND_STATUS_BINDING); @@ -421,12 +437,14 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail); } else { + materialId = mesBaseBarcodeInfo.getMaterialId(); 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); } + mesBaseBarcodeInfo.setBatchCode(barcode);// 成品的批次代码 == 条码内容 mesBaseBarcodeInfo.setBarcodeInfo(barcode); mesBaseBarcodeInfo.setAmount(new BigDecimal(1)); @@ -916,6 +934,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService StringBuilder palletBindErrorMsg = new StringBuilder(); boolean palletInfoCodeRepeat = false; String palletInfoCode = ""; + String barcodeInfo = ""; if (productBarcodesArr != null) { for (String productBarcode : productBarcodesArr) { //先根据之前的成品条码信息获取托盘信息 @@ -945,6 +964,8 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService allErrorMsgBuilder.append(this.checkInternalMesBaseBarcode(productBarcode, productBarcodeInfo, mesBaseBarcodeInfo)); } + + barcodeInfo = Seq.getId(Seq.mesInternalVirtualBarcodeSeqType, Seq.mesInternalVirtualBarcodeCode); } else { MesBasePalletInfo basePalletInfo = mesBasePalletInfoMapper.selectMesBasePalletInfoByBarcode(productBarcodes); if (basePalletInfo == null) { @@ -964,6 +985,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService basePalletInfoList.add(basePalletInfo); materialId = productBarcodeInfo.getMaterialId(); + barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode); } @@ -975,7 +997,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService throw new ServiceException(allErrorMsgBuilder.toString()); } - String barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode); + String userName = SecurityUtils.getUsername(); Date currentDate = DateUtils.getNowDate(); //修改托盘信息的绑定关系为当前原材料的 @@ -989,7 +1011,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService mesBasePalletInfoMapper.updateMesBasePalletInfo(toUpdatePalletInfo); } - mesBaseBarcodeInfo.setBarcodeInfo(barcodeInfo); mesBaseBarcodeInfo.setBatchCode(barcodeInfo); mesBaseBarcodeInfo.setMaterialId(materialId); @@ -1025,14 +1046,45 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(productBarcodeInfo); } - MesBaseBindBarcode baseBindBarcode = new MesBaseBindBarcode(); - baseBindBarcode.setBindBarcode(productBarcodeInfo.getBarcodeInfo()); - baseBindBarcode.setBarcodeId(mesBaseBarcodeInfo.getBarcodeId()); - baseBindBarcode.setBarcodeInfo(barcodeInfo); - baseBindBarcode.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId()); - baseBindBarcode.setCreateBy(userName); - baseBindBarcode.setCreateTime(new Date()); - toInsertedBaseBindBarcodeList.add(baseBindBarcode); + Long bindMaterialId = productBarcodeInfo.getMaterialId(); + MesMaterialBom queryMaterialBom = new MesMaterialBom(); + queryMaterialBom.setMaterialId(bindMaterialId); + queryMaterialBom.setActiveFlag(MesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_NORMAL); + List mesMaterialBomList = mesMaterialBomMapper.selectMesMaterialBomList(queryMaterialBom); + if (mesMaterialBomList == null || mesMaterialBomList.isEmpty()) { + allErrorMsgBuilder.append("成品条码[").append(productBarcodeInfo.getBarcodeInfo()).append("]没有维护生产bom信息;"); + } + + List childMaterialBomList = mesMaterialBomList.stream(). + filter(materialBom -> materialBom.getParentId() != null && !materialBom.getParentId().equals(0L)) + .collect(Collectors.toList()); + + if (childMaterialBomList == null || childMaterialBomList.isEmpty()) { + allErrorMsgBuilder.append("成品条码[").append(productBarcodeInfo.getBarcodeInfo()).append("]没有维护在五楼成品的生产bom信息中;"); + } else if (childMaterialBomList.size() > 1) { + allErrorMsgBuilder.append("成品条码[").append(productBarcodeInfo.getBarcodeInfo()) + .append("]五楼成品的生产bom信息多于1个").append(mesMaterialBomList.size()).append(";"); + } else { + MesMaterialBom childMaterialBom = childMaterialBomList.get(0); + MesMaterialBom parentBom = mesMaterialBomMapper.selectMesMaterialBomByMaterialBomId(childMaterialBom.getParentId()); + + MesBaseBindBarcode baseBindBarcode = new MesBaseBindBarcode(); + baseBindBarcode.setBindBarcode(productBarcodeInfo.getBarcodeInfo()); + baseBindBarcode.setBarcodeId(mesBaseBarcodeInfo.getBarcodeId()); + baseBindBarcode.setBarcodeInfo(barcodeInfo); + baseBindBarcode.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId()); + baseBindBarcode.setMaterialId(bindMaterialId);//四楼成品条码的物料id作为五楼原材料的物料id + baseBindBarcode.setProductId(parentBom.getMaterialId()); + baseBindBarcode.setCreateBy(userName); + baseBindBarcode.setCreateTime(new Date()); + toInsertedBaseBindBarcodeList.add(baseBindBarcode); + } + + + } + + if (allErrorMsgBuilder.length() > 0) { + throw new ServiceException(allErrorMsgBuilder.toString()); } return mesBaseBindBarcodeMapper.batchMesBaseBindBarcode(toInsertedBaseBindBarcodeList); } @@ -1357,8 +1409,10 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService throw new ServiceException(errorMsgBuilder.toString()); } + + String barcodeInfo = Seq.getId(Seq.mesPurchaseVirtualBarcodeSeqType, Seq.mesPurchaseVirtualBarcodeCode); + //新建虚拟物料 - String barcodeInfo = Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode); Long materialId = this.insertNewVirtualMaterial(barcodeInfo, userName, currentDate); //创建虚拟销售订单,保存对应的销售订单列表 @@ -1506,7 +1560,6 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService } - /** * 查询绑定的成品条码信息 * diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBindBarcodeMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBindBarcodeMapper.xml index 23eac51..f8e2732 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBindBarcodeMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBindBarcodeMapper.xml @@ -8,20 +8,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + + + - select bind_barcode_id, barcode_id,barcode_info, sale_order_id,bind_barcode, create_by, create_time from mes_base_bind_barcode + select bind_barcode_id, barcode_id,barcode_info, sale_order_id,material_id,product_id,bind_barcode, create_by, create_time from mes_base_bind_barcode @@ -37,6 +40,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" barcode_id, barcode_info, sale_order_id, + material_id, + product_id, bind_barcode, create_by, create_time, @@ -45,6 +50,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{barcodeId}, #{barcodeInfo}, #{saleOrderId}, + #{materialId}, + #{productId}, #{bindBarcode}, #{createBy}, #{createTime}, @@ -75,9 +82,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into mes_base_bind_barcode( bind_barcode_id, barcode_id, barcode_info, sale_order_id,bind_barcode, create_by, create_time) values + insert into mes_base_bind_barcode( bind_barcode_id, barcode_id, barcode_info, sale_order_id,material_id,product_id,bind_barcode, create_by, create_time) values - ( #{item.bindBarcodeId}, #{item.barcodeId},#{item.barcodeInfo}, #{item.saleOrderId}, #{item.bindBarcode}, #{item.createBy}, #{item.createTime}) + ( #{item.bindBarcodeId}, #{item.barcodeId},#{item.barcodeInfo}, #{item.saleOrderId}, #{item.materialId}, #{item.productId}, #{item.bindBarcode}, #{item.createBy}, #{item.createTime}) diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java index f49be08..f295632 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsProductInstockServiceImpl.java @@ -164,7 +164,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService { /** * 新增成品入库记录(适用于移动手持端,适用于5楼成品入库) * - * @param wmsProductInstockVo 原材料入库记录 + * @param wmsProductInstockVo 成品入库记录 * @return 结果 */ @Transactional(rollbackFor = Exception.class) @@ -174,7 +174,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService { R baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER); MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData(); if (baseBarcodeInfo == null) { - throw new ServiceException("物料编码有误"); + throw new ServiceException("物料条码有误"); } Long productId = baseBarcodeInfo.getMaterialId(); @@ -183,18 +183,52 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService { if (baseLocation == null) { throw new ServiceException("库位编码有误"); } - //todo 仓库可存储此物料判断是否可以入此库位 Date currentDate = new Date(); String userName = SecurityUtils.getUsername(); + + if (baseBarcodeInfo.getMaterialId().equals(0L)) {//代表4楼到5楼合并的条码 + String rawMaterialBarcode = baseBarcodeInfo.getProductBarcode(); + if (StringUtils.isEmpty(rawMaterialBarcode)) { + throw new ServiceException("没有绑定原材料条码"); + } + R> baseBindBarcodeListData = remoteMesService.selectBindBarcodeListByBarcodeInfo(rawMaterialBarcode, SecurityConstants.INNER); + if (baseBindBarcodeListData == null) { + throw new RuntimeException("没有绑定的成品条码信息。"); + } + List baseBindBarcodeList = baseBindBarcodeListData.getData(); + if (baseBindBarcodeList == null || baseBindBarcodeList.isEmpty()) { + throw new RuntimeException("没有绑定的成品条码信息!"); + } + + for(MesBaseBindBarcode baseBindBarcode:baseBindBarcodeList){ + this.saveWmsProductInstock(baseLocation.getWarehouseId(), locationCode, + baseBarcodeInfo.getPlanCode(), baseBarcodeInfo.getPlanDetailCode(), null, + baseBindBarcode.getProductId(), userName, currentDate); + } + + } else { + this.saveWmsProductInstock(baseLocation.getWarehouseId(), locationCode, + baseBarcodeInfo.getPlanCode(), baseBarcodeInfo.getPlanDetailCode(), materialBarcode, + productId, userName, currentDate); + } + + //更新库存 + updateProductStock(baseBarcodeInfo, locationCode, baseLocation.getWarehouseId(), baseLocation.getWarehouseFloor(), userName, currentDate); + + return 1; + } + + public void saveWmsProductInstock(Long warehouseId, String locationCode, String planCode, String planDetailCode, String materialBarcode, + Long productId, String userName, Date currentDate) { WmsProductInstock wmsProductInstock = new WmsProductInstock(); - wmsProductInstock.setWarehouseId(baseLocation.getWarehouseId()); + wmsProductInstock.setWarehouseId(warehouseId); wmsProductInstock.setLocationCode(locationCode); wmsProductInstock.setProductType(WmsConstants.PRODUCT_INSTOCK_STOCK_TYPE_PRODUCT); wmsProductInstock.setOperationType(WmsConstants.WMS_OPERATION_TYPE_MANUAL); wmsProductInstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH); - wmsProductInstock.setPlanCode(baseBarcodeInfo.getPlanCode()); - wmsProductInstock.setPlanDetailCode(baseBarcodeInfo.getPlanDetailCode()); + wmsProductInstock.setPlanCode(planCode); + wmsProductInstock.setPlanDetailCode(planDetailCode); wmsProductInstock.setProductBatch(materialBarcode); wmsProductInstock.setProductId(productId); wmsProductInstock.setInstockType(WmsConstants.PRODUCT_INSTOCK_INSTOCK_TYPE_PRODUCT); @@ -204,15 +238,7 @@ public class WmsProductInstockServiceImpl implements IWmsProductInstockService { wmsProductInstock.setApplyDate(currentDate); //插入记录 - int rows = wmsProductInstockMapper.insertWmsProductInstock(wmsProductInstock); - - //插入明细 -// insertWmsProductInstockDetail(wmsProductInstock, materialBarcode, productId, wmsProductInstockVo); - - //更新库存 - updateProductStock(baseBarcodeInfo, locationCode, baseLocation.getWarehouseId(), baseLocation.getWarehouseFloor(), userName, currentDate); - - return rows; + wmsProductInstockMapper.insertWmsProductInstock(wmsProductInstock); }