diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/controller/MesToWmsController.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/controller/MesToWmsController.java index 3dafe9a6..8e31a9da 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/controller/MesToWmsController.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/controller/MesToWmsController.java @@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.nl.common.base.ResponseData; +import org.nl.common.domain.constant.RegionConstant; import org.nl.common.exception.BadRequestException; import org.nl.common.logging.annotation.Log; import org.nl.common.utils.MapOf; @@ -172,9 +173,9 @@ public class MesToWmsController { params.stream().map(PmDemandParam::getSkuCode).collect(Collectors.toSet())); for (PmDemandParam param : params) { String warehouseCode = warehouseByMaterial.get(param.getSkuCode()); - if ("6.005".equals(warehouseCode)) { + if (RegionConstant.PLATING_STORE_CODE.equals(warehouseCode)) { pmDemandPlatingParams.add(param); - } else if ("6.006".equals(warehouseCode)) { + } else if (RegionConstant.ASSEMBLY_PART_STORE_CODE.equals(warehouseCode)) { partDemandParams.add(param); } else { pmDemandParams.add(param); diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java index d02235a2..63d1a7ec 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/ext_manage/service/impl/MesToWmsServiceImpl.java @@ -22,6 +22,11 @@ import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase; import org.nl.wms.basedata_manage.service.dao.Structattr; import org.nl.wms.ext_manage.service.MesToWmsService; import org.nl.wms.ext_manage.service.dto.*; +import org.nl.wms.pm_manage.demand.service.IMaterialWarehouseMappingService; +import org.nl.wms.pm_manage.demand.service.IPartDemandService; +import org.nl.wms.pm_manage.demand.service.dao.MaterialWarehouseMapping; +import org.nl.wms.pm_manage.demand.service.dao.PartDemand; +import org.nl.wms.pm_manage.demand.service.enums.DemandStatus; import org.nl.wms.sch_manage.service.ISchBasePointService; import org.nl.wms.sch_manage.service.ISchBaseRegionService; import org.nl.wms.sch_manage.service.core.tasks.LineCallFullTask; @@ -94,6 +99,10 @@ public class MesToWmsServiceImpl implements MesToWmsService { private IOStorInvDisMapper ioStorInvDisMapper; @Autowired private IStInventoryService iStInventoryService; + @Autowired + private IMaterialWarehouseMappingService materialWarehouseMappingService; + @Autowired + private IPartDemandService partDemandService; @Transactional @@ -272,6 +281,8 @@ public class MesToWmsServiceImpl implements MesToWmsService { entry.put("srcbillid", workOrder.getOrder_id()); // 数量 entry.put("srcbillentryid", item.getItem_id()); entry.put("qty", param.getLoadQty());//喷涂线边 + entry.put("warehouseno", storCode); + entry.put("materialno", item.getMaterial_code()); entrysOut.add(entry); break; } @@ -293,136 +304,27 @@ public class MesToWmsServiceImpl implements MesToWmsService { @Override public void assemblyOffline(AssemblyOfflineDto assemblyOfflineDto) { //部装下线 + String storeCode = RegionConstant.ASSEMBLY_PART_STORE_CODE;//部装半成品库 String orderCode = assemblyOfflineDto.getOrderCode(); + MaterialWarehouseMapping materialWarehouseMapping = new MaterialWarehouseMapping(); + materialWarehouseMapping.setMaterialCode(assemblyOfflineDto.getMaterialCode()); + materialWarehouseMapping.setWarehouseCode(storeCode); + materialWarehouseMappingService.saveOrUpdateMapping(materialWarehouseMapping); WorkOrderDao workOrder = workOrderService.getOne(new LambdaQueryWrapper() .eq(WorkOrderDao::getOrder_code, orderCode)); if (workOrder == null){ throw new BadRequestException("WMS不存在工单:" + orderCode); } -// List orderBomItems = workOrderService.getOrderBomItem(orderCode); -// BsrealStorattr storattrOut = storattrService.findByCode(storCode);//喷涂半成品库 -// Structattr structattrOut = iStructattrService.getOne(new LambdaQueryWrapper() -// .eq(Structattr::getSect_code, storCode) -// .last("limit 1")); final String now = DateUtil.now(); int seq = 1; String currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); -// IOStorInv ioStorInvOut = new IOStorInv(); -// ioStorInvOut.setIostorinv_id(IdUtil.getStringId()); -// ioStorInvOut.setBill_code(CodeUtil.getNewCode("OUT_STORE_CODE")); -// ioStorInvOut.setIo_type(IOSEnum.IO_TYPE.code("出库")); -// ioStorInvOut.setBill_type(IOSEnum.BILL_TYPE.code("生产出库")); -// ioStorInvOut.setBiz_date(DateUtil.today()); -// ioStorInvOut.setStor_code(storattrOut.getStor_code()); -// ioStorInvOut.setStor_name(storattrOut.getStor_name()); -// ioStorInvOut.setStor_id(storattrOut.getStor_id()); -// ioStorInvOut.setDetail_count((int) orderBomItems.stream().filter(i -> storCode.equals(i.getWarehouse_code())).count()); -// ioStorInvOut.setBill_status(IOSEnum.BILL_STATUS.code("完成")); -// ioStorInvOut.setCreate_mode(IOSEnum.CREATE_MODE.code("外部接口产生")); -// ioStorInvOut.setInput_optid(currentUserId); -// ioStorInvOut.setInput_optname(nickName); -// ioStorInvOut.setInput_time(now); -// ioStorInvOut.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否")); -// ioStorInvOut.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是")); final List ioStorInvDtls = new ArrayList<>(); final List iOStorInvDiss = new ArrayList<>(); -// List outFinsParams = new ArrayList<>(); -// for (WorkOrderBomDao bomItem : orderBomItems) { -// if (!Objects.equals(bomItem.getWarehouse_code(), storCode)){ -// continue;//跳过非喷涂半成品库物料 -// } -// BigDecimal qty = bomItem.getBom_qty(); -// final String materialCode = bomItem.getMaterial_code(); -// MdMeMaterialbase material = iMdMeMaterialbaseService.getByCode(materialCode); -// final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl(); -// ioStorInvDtl.setIostorinv_id(ioStorInvOut.getIostorinv_id()); -// ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId()); -// ioStorInvDtl.setSeq_no(String.valueOf(seq)); -// ioStorInvDtl.setMaterial_code(materialCode); -// ioStorInvDtl.setMaterial_id(material.getMaterial_id()); -// ioStorInvDtl.setQty_unit_id(material.getQty_unit_id()); -// ioStorInvDtl.setQty_unit_name(material.getQty_unit_name()); -// ioStorInvDtl.setPcsn("1"); -// ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成")); -// ioStorInvDtl.setAssign_qty(qty); -// ioStorInvDtl.setPlan_qty(qty); -// ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO); -// ioStorInvDtl.setSource_bill_code(orderCode); -// ioStorInvDtl.setSource_bill_type("work_order"); -// ioStorInvDtls.add(ioStorInvDtl); -// // 分配 -// final IOStorInvDis ioStorInvDis = new IOStorInvDis(); -// ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId()); -// ioStorInvDis.setIostorinv_id(ioStorInvOut.getIostorinv_id()); // 修正变量名 -// ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON -// ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String -// ioStorInvDis.setMaterial_id(material.getMaterial_id()); -// ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量 -// ioStorInvDis.setSect_code(bomItem.getWarehouse_code()); -// ioStorInvDis.setStruct_code(structattrOut.getStruct_code()); -// ioStorInvDis.setPcsn("1"); -// ioStorInvDis.setStoragevehicle_code(structattrOut.getStoragevehicle_code()); -// ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成")); -// ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是")); -// ioStorInvDis.setQty_unit_id(material.getQty_unit_id()); -// ioStorInvDis.setQty_unit_name(material.getQty_unit_name()); -// ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量 -// ioStorInvDis.setReal_qty(qty); -// iOStorInvDiss.add(ioStorInvDis); -// //更新组盘记录表 -// outFinsParams.add(OutFinishParam.builder() -// .storagevehicleCode(structattrOut.getStoragevehicle_code()) -// .changeQty(qty) -// .sectCode(bomItem.getWarehouse_code()) -// .structCode(structattrOut.getStruct_code()) -// .materialCode(materialCode) -// .build()); -// } -// ioStorInvMapper.insert(ioStorInvOut); -// ioStorInvDtlMapper.batchInsert(ioStorInvDtls); -// ioStorInvDisMapper.batchSave(iOStorInvDiss); -// iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams); -// //保存领料出库回传单定时回传 -// JSONObject callbackOutData = new JSONObject(); -// callbackOutData.put("method", "DealLLCKBill"); -// callbackOutData.put("type", "MES"); -// // 组装data节点 -// JSONObject dataOut = new JSONObject(); -// dataOut.put("orgno", workOrder.getOrg_code());//库存组织 -// dataOut.put("billno", workOrder.getOrder_code()); // 单据编号 -// dataOut.put("biztype", "340"); -// dataOut.put("invscheme", "002"); -// dataOut.put("transtype", "020"); -// dataOut.put("biztime", LocalDate.now()); -// dataOut.put("cztype", "02"); -// JSONArray entrysOut = new JSONArray(); -// for (WorkOrderBomDao item : orderBomItems) { -// if (!Objects.equals(item.getWarehouse_code(), storCode)){ -// continue;//跳过非喷涂半成品库物料 -// } -// JSONObject entry = new JSONObject(); -// entry.put("srcbillno", orderCode); -// entry.put("srcbillid", workOrder.getOrder_id()); // 数量 -// entry.put("srcbillentryid", item.getItem_id()); -// entry.put("qty", item.getBom_qty());//喷涂线边 -// entrysOut.add(entry); -// } -// dataOut.put("entrys", entrysOut); -// callbackOutData.put("data", dataOut); -// PmStockReturn stockReturnOut = new PmStockReturn(); -// stockReturnOut.setRequest_Id(orderCode); -// stockReturnOut.setRequest_type(IOSEnum.BILL_TYPE.code("生产出库")); -// stockReturnOut.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中 -// stockReturnOut.setCreate_time(now); -// stockReturnOut.setRequest_data(callbackOutData.toString()); -// iPmStockReturnService.save(stockReturnOut); - BsrealStorattr storattrIn = storattrService.findByCode(workOrder.getDefault_warehouse_code()); + BsrealStorattr storattrIn = storattrService.findByCode(storeCode); Structattr structattrIn = iStructattrService.getOne(new LambdaQueryWrapper() - .eq(Structattr::getSect_code, workOrder.getDefault_warehouse_code()) + .eq(Structattr::getSect_code, storeCode) .last("limit 1"));//部装半成品库 -// ioStorInvDtls.clear(); -// iOStorInvDiss.clear(); //生成入库单 IOStorInv ioStorInvIn = new IOStorInv(); ioStorInvIn.setIostorinv_id(IdUtil.getStringId()); @@ -468,7 +370,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String ioStorInvDis.setMaterial_id(material.getMaterial_id()); ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量 - ioStorInvDis.setSect_code(workOrder.getDefault_warehouse_code()); + ioStorInvDis.setSect_code(storeCode); ioStorInvDis.setStruct_code(structattrIn.getStruct_code()); ioStorInvDis.setPcsn("1"); ioStorInvDis.setStoragevehicle_code(structattrIn.getStoragevehicle_code()); @@ -522,6 +424,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { entry.put("srcbillid", workOrder.getOrder_id()); // 数量 entry.put("srcbillentryid", workOrder.getOrder_id()); entry.put("qty", workOrder.getOrder_qty()); + entry.put("warehouseno", storeCode); entrysIn.add(entry); dataIn.put("entrys", entrysIn); callbackInData.put("data", dataIn); @@ -575,8 +478,9 @@ public class MesToWmsServiceImpl implements MesToWmsService { final List ioStorInvDtls = new ArrayList<>(); final List iOStorInvDiss = new ArrayList<>(); List outFinsParams = new ArrayList<>(); + JSONArray entrysOut = new JSONArray(); for (WorkOrderBomDao bomItem : orderBomItems) { - if (!Objects.equals(bomItem.getWarehouse_code(), storCode1)){ + if (!Objects.equals(materialWarehouseMappingService.getOrDefault(bomItem.getMaterial_code(),bomItem.getWarehouse_code()), storCode1)){ continue;//跳过非部装半成品库物料 } BigDecimal qty = bomItem.getBom_qty(); @@ -625,144 +529,65 @@ public class MesToWmsServiceImpl implements MesToWmsService { .structCode(structattrOut.getStruct_code()) .materialCode(materialCode) .build()); + + JSONObject entry = new JSONObject(); + entry.put("srcbillno", orderCode); + entry.put("srcbillid", workOrder.getOrder_id()); // 数量 + entry.put("srcbillentryid", bomItem.getItem_id()); + entry.put("qty", bomItem.getBom_qty());//喷涂线边 + entry.put("warehouseno", storCode1); + entry.put("materialno", bomItem.getMaterial_code()); + entrysOut.add(entry); + //完成部装半成品库需求单 + PartDemand partDemand = partDemandService.getOne(new LambdaQueryWrapper() + .eq(PartDemand::getSku_code, materialCode) + .like(PartDemand::getWork_order_code, workOrder.getOrder_code()) + .last("limit 1")); + partDemand.setAssign_qty(partDemand.getAssign_qty().add(bomItem.getBom_qty())); + if (partDemand.getAssign_qty().compareTo(partDemand.getQty()) >= 0){ + partDemand.setStatus(DemandStatus.FINISH.getValue()); + }else { + partDemand.setStatus(DemandStatus.RUN.getValue()); + } + partDemandService.updateById(partDemand); } ioStorInvMapper.insert(ioStorInvOut); ioStorInvDtlMapper.batchInsert(ioStorInvDtls); ioStorInvDisMapper.batchSave(iOStorInvDiss); iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams); - BsrealStorattr storattrIn = storattrService.findByCode(storCode2);//装配线边库 - Structattr structattrIn = iStructattrService.getOne(new LambdaQueryWrapper() - .eq(Structattr::getSect_code, storCode2) - .last("limit 1"));//喷涂半成品库 - ioStorInvDtls.clear(); - iOStorInvDiss.clear(); - //生成入库单 - IOStorInv ioStorInvIn = new IOStorInv(); - ioStorInvIn.setIostorinv_id(IdUtil.getStringId()); - ioStorInvIn.setBill_code(CodeUtil.getNewCode("IN_STORE_CODE")); - ioStorInvIn.setIo_type(IOSEnum.IO_TYPE.code("入库")); - ioStorInvIn.setBill_type(IOSEnum.BILL_TYPE.code("生产入库")); - ioStorInvIn.setBiz_date(DateUtil.today()); - ioStorInvIn.setStor_code(storattrIn.getStor_code()); - ioStorInvIn.setStor_name(storattrIn.getStor_name()); - ioStorInvIn.setStor_id(storattrIn.getStor_id()); - ioStorInvIn.setDetail_count(1); - ioStorInvIn.setBill_status(IOSEnum.BILL_STATUS.code("完成")); - ioStorInvIn.setCreate_mode(IOSEnum.CREATE_MODE.code("外部接口产生")); - ioStorInvIn.setInput_optid(currentUserId); - ioStorInvIn.setInput_optname(nickName); - ioStorInvIn.setInput_time(now); - ioStorInvIn.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否")); - ioStorInvIn.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是")); - List addInvParams = new ArrayList<>(); - List inFinishParams = new ArrayList<>(); - JSONArray entrys = new JSONArray(); - for (WorkOrderBomDao item : orderBomItems) { - if (!Objects.equals(item.getWarehouse_code(), storCode1)){ - continue;//跳过非部装半成品库物料 - } - final String materialCode = item.getMaterial_code(); - BigDecimal qty = item.getBom_qty(); - MdMeMaterialbase material = iMdMeMaterialbaseService.getByCode(materialCode); - final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl(); - ioStorInvDtl.setIostorinv_id(ioStorInvIn.getIostorinv_id()); - ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId()); - ioStorInvDtl.setSeq_no(String.valueOf(seq)); - ioStorInvDtl.setMaterial_code(materialCode); - ioStorInvDtl.setMaterial_id(material.getMaterial_id()); - ioStorInvDtl.setQty_unit_id(material.getQty_unit_id()); - ioStorInvDtl.setQty_unit_name(material.getQty_unit_name()); - ioStorInvDtl.setPcsn("1"); - ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成")); - ioStorInvDtl.setAssign_qty(qty); - ioStorInvDtl.setPlan_qty(qty); - ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO); - ioStorInvDtl.setSource_bill_code(orderCode); - ioStorInvDtl.setSource_bill_type("work_order"); - ioStorInvDtls.add(ioStorInvDtl); - // 分配 - final IOStorInvDis ioStorInvDis = new IOStorInvDis(); - ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId()); - ioStorInvDis.setIostorinv_id(ioStorInvIn.getIostorinv_id()); // 修正变量名 - ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON - ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String - ioStorInvDis.setMaterial_id(material.getMaterial_id()); - ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量 - ioStorInvDis.setSect_code(storCode2); - ioStorInvDis.setStruct_code(structattrIn.getStruct_code()); - ioStorInvDis.setPcsn("1"); - ioStorInvDis.setStoragevehicle_code(structattrIn.getStoragevehicle_code()); - ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成")); - ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是")); - ioStorInvDis.setQty_unit_id(material.getQty_unit_id()); - ioStorInvDis.setQty_unit_name(material.getQty_unit_name()); - ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量 - ioStorInvDis.setReal_qty(qty); - iOStorInvDiss.add(ioStorInvDis); - AddInvParam addParam = new AddInvParam(); - addParam.setPcsn("1"); - addParam.setMaterialCode(materialCode); - addParam.setStoragevehicleCode(structattrIn.getStoragevehicle_code()); - addParam.setUnitName(material.getQty_unit_name()); - addParam.setUnitId(material.getQty_unit_id()); - addParam.setQty(qty); - addInvParams.add(addParam); - InFinishParam inFinishParam = new InFinishParam(); - inFinishParam.setPcsn("1"); - inFinishParam.setMaterialCode(materialCode); - inFinishParam.setStoragevehicleCode(structattrIn.getStoragevehicle_code()); - inFinishParam.setUnitName(material.getQty_unit_name()); - inFinishParam.setUnitId(material.getQty_unit_id()); - inFinishParam.setQty(qty); - inFinishParam.setSectCode(structattrIn.getSect_code()); - inFinishParam.setStructCode(structattrIn.getStruct_code()); - inFinishParams.add(inFinishParam); - JSONObject entry = new JSONObject(); - entry.put("unitNo", "PCS"); - entry.put("qty", loadMatDto.getLoadQty()); // 数量 - entry.put("materialNo", materialCode); - entry.put("trackNo", item.getTrack_no()); - entry.put("issueWarehouseNo", storCode1);//部装半成品库 - entry.put("receiptWarehouseNo", storCode2);//到装配线边 - entrys.add(entry); - } - ioStorInvMapper.insert(ioStorInvIn); - ioStorInvDtlMapper.batchInsert(ioStorInvDtls); - ioStorInvDisMapper.batchSave(iOStorInvDiss); - iStInventoryService.changeInventory(InventoryChangeType.ADD_INV, addInvParams); - iStInventoryService.changeInventory(InventoryChangeType.IN_FINISH, inFinishParams); - - - JSONObject callbackData = new JSONObject(); - callbackData.put("method", "DealLLDBBill"); - callbackData.put("type", "WMS"); + //部装件领料出库 + JSONObject callbackOutData = new JSONObject(); + callbackOutData.put("method", "DealLLCKBill"); + callbackOutData.put("type", "MES"); // 组装data节点 - JSONObject data = new JSONObject(); - data.put("issueStorageOrgUnitNo", "01.09.14"); - data.put("bizTypeNo", "331"); // 业务日期 - data.put("receiptStorageOrgUnitNo", "01.09.14"); - data.put("billNo", orderCode); // 使用工单编号作为MES单号 - data.put("entrys", entrys); - callbackData.put("data", data); - PmStockReturn stockReturn = new PmStockReturn(); - stockReturn.setRequest_Id(orderCode); - stockReturn.setRequest_type(IOSEnum.BILL_TYPE.code("库存调拨")); - stockReturn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中 - stockReturn.setCreate_time(now); - stockReturn.setRequest_data(callbackData.toString()); - iPmStockReturnService.save(stockReturn); + JSONObject dataOut = new JSONObject(); + dataOut.put("orgno", workOrder.getOrg_code());//库存组织 + dataOut.put("billno", workOrder.getOrder_code()); // 单据编号 + dataOut.put("biztype", "340"); + dataOut.put("invscheme", "002"); + dataOut.put("transtype", "020"); + dataOut.put("biztime", LocalDate.now().toString()); + dataOut.put("cztype", "02"); + PmStockReturn stockReturnOut = new PmStockReturn(); + stockReturnOut.setRequest_Id(orderCode); + stockReturnOut.setRequest_type(IOSEnum.BILL_TYPE.code("生产出库")); + stockReturnOut.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中 + stockReturnOut.setCreate_time(now); + stockReturnOut.setRequest_data(callbackOutData.toString()); + iPmStockReturnService.save(stockReturnOut); } @Transactional @Override public void platingOffline(PlatingOfflineDto param) { - //喷涂下线 车架:喷涂半成品-> 装配线边 + //喷涂下线 车架:喷涂半成品-> 装配线边 2026/10/15修改:全部走领料出库 // 门架:从喷涂领料出库 String storCode1 = RegionConstant.PLATING_STORE_CODE; String storCode2 = RegionConstant.ASSEMBLY_LINE_STORE_CODE; String unloadPort = param.getUnloadPort();//下件位置 - String storeMapper = iSchBasePointService.getPointRegionMapperSect(unloadPort);//映射仓库 - boolean isAllocate = !StringUtils.isEmpty(storeMapper);//如果有映射仓库则调拨到线边库,没有则直接出库 +// String storeMapper = iSchBasePointService.getPointRegionMapperSect(unloadPort);//映射仓库 +// boolean isAllocate = !StringUtils.isEmpty(storeMapper);//如果有映射仓库则调拨到线边库,没有则直接出库 + boolean isAllocate = true;//2026/10/15修改:全部走领料出库 String orderCode = param.getOrderCode(); WorkOrderDao workOrder = workOrderService.getOne(new LambdaQueryWrapper() .eq(WorkOrderDao::getOrder_code, orderCode)); @@ -845,7 +670,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { ioStorInvDtlMapper.batchInsert(ioStorInvDtls); ioStorInvDisMapper.batchSave(iOStorInvDiss); iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams); - if (!isAllocate){//不需要调拨 + if (isAllocate){//不需要调拨 BsrealStorattr storattrIn = storattrService.findByCode(storCode2); Structattr structattrIn = iStructattrService.getOne(new LambdaQueryWrapper() .eq(Structattr::getSect_code, storCode2) @@ -981,6 +806,8 @@ public class MesToWmsServiceImpl implements MesToWmsService { entry.put("srcbillid", workOrder.getOrder_id()); // 数量 entry.put("srcbillentryid", item.getItem_id()); entry.put("qty", param.getUnloadQty()); + entry.put("warehouseno", storCode1); + entry.put("materialno", item.getMaterial_code()); entrysOut.add(entry); break; } @@ -1003,6 +830,11 @@ public class MesToWmsServiceImpl implements MesToWmsService { @Override public void platingInbound(PlatingInboundDto param) { //入库喷涂半成品 + String storeCode = RegionConstant.PLATING_STORE_CODE; + MaterialWarehouseMapping materialWarehouseMapping = new MaterialWarehouseMapping(); + materialWarehouseMapping.setMaterialCode(param.getMaterialCode()); + materialWarehouseMapping.setWarehouseCode(storeCode); + materialWarehouseMappingService.saveOrUpdateMapping(materialWarehouseMapping); String orderCode = param.getOrderCode(); if (StringUtils.isEmpty(orderCode)){ throw new BadRequestException("参数为空"); @@ -1013,9 +845,9 @@ public class MesToWmsServiceImpl implements MesToWmsService { throw new BadRequestException("WMS不存在工单:" + orderCode); } List orderBomItems = workOrderService.getOrderBomItem(orderCode); - BsrealStorattr storattrIn = storattrService.findByCode(workOrder.getDefault_warehouse_code());//喷涂半成品库 + BsrealStorattr storattrIn = storattrService.findByCode(storeCode);//喷涂半成品库 Structattr structattrIn = iStructattrService.getOne(new LambdaQueryWrapper() - .eq(Structattr::getSect_code, workOrder.getDefault_warehouse_code()) + .eq(Structattr::getSect_code, storeCode) .last("limit 1"));//喷涂半成品库 final String now = DateUtil.now(); int seq = 1; @@ -1068,7 +900,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String ioStorInvDis.setMaterial_id(material.getMaterial_id()); ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量 - ioStorInvDis.setSect_code(workOrder.getDefault_warehouse_code()); + ioStorInvDis.setSect_code(storeCode); ioStorInvDis.setStruct_code(structattrIn.getStruct_code()); ioStorInvDis.setPcsn("1"); ioStorInvDis.setStoragevehicle_code(structattrIn.getStoragevehicle_code()); @@ -1122,6 +954,7 @@ public class MesToWmsServiceImpl implements MesToWmsService { entry.put("srcbillid", workOrder.getOrder_id()); // 数量 entry.put("srcbillentryid", workOrder.getOrder_id()); entry.put("qty", param.getQty()); + entry.put("warehouseno", storeCode); entrysIn.add(entry); dataIn.put("entrys", entrysIn); callbackInData.put("data", dataIn); diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pda_manage/ios_manage/purchase/service/impl/InboundPdaServiceImpl.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pda_manage/ios_manage/purchase/service/impl/InboundPdaServiceImpl.java index 48f16238..669bb0dd 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pda_manage/ios_manage/purchase/service/impl/InboundPdaServiceImpl.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pda_manage/ios_manage/purchase/service/impl/InboundPdaServiceImpl.java @@ -22,6 +22,7 @@ import org.nl.wms.pda_manage.ios_manage.purchase.service.InboundPdaService; import org.nl.wms.pda_manage.ios_manage.purchase.service.dto.*; import org.nl.wms.pda_manage.ios_manage.purchase.service.vo.PurchaseMatInfoVo; import org.nl.wms.pm_manage.SourceBillTypeEnum; +import org.nl.wms.pm_manage.demand.service.IMaterialWarehouseMappingService; import org.nl.wms.pm_manage.listener.PmManageEvent; import org.nl.wms.pm_manage.purchase.ListenerHandler.PurchaseListenerParams; import org.nl.wms.pm_manage.purchase.service.PurchaseService; @@ -126,6 +127,8 @@ public class InboundPdaServiceImpl implements InboundPdaService { private IOStorInvDisMapper ioStorInvDisMapper; @Autowired private IPmStockReturnService iPmStockReturnService; + @Autowired + private IMaterialWarehouseMappingService materialWarehouseMappingService; @@ -365,6 +368,8 @@ public class InboundPdaServiceImpl implements InboundPdaService { // 查询库区 Sectattr sectDao = iSectattrService.findByCode(groupPlateInboundDto.getSect_code()); + // 查询仓库 + BsrealStorattr storeDao = iSrealStorattrService.getById(sectDao.getStor_id()); // 组织主表数据 Map jsonMst = new HashMap<>(); jsonMst.put("stor_id", sectDao.getStor_id()); @@ -394,12 +399,11 @@ public class InboundPdaServiceImpl implements InboundPdaService { dtl.put("callback_strategy", "dealPurchaseRecBillCallback"); // 调用新增 tableData.add(dtl); + materialWarehouseMappingService.saveOrUpdateMapping(materDao.getMaterial_code(),storeDao.getStor_code()); } jsonMst.put("tableData",tableData); String iostorinv_id = iRawAssistIStorService.insertDtl(jsonMst); - // 查询仓库 - BsrealStorattr storeDao = iSrealStorattrService.getById(sectDao.getStor_id()); // 组织主数据 Map jsonMst1 = new HashMap<>(); jsonMst1.put("checked", true); @@ -464,6 +468,8 @@ public class InboundPdaServiceImpl implements InboundPdaService { } // 查询库区 Sectattr sectDao = iSectattrService.findByCode(struct.getSect_code()); + // 查询仓库 + BsrealStorattr storeDao = iSrealStorattrService.getById(sectDao.getStor_id()); // 组织主表数据 Map jsonMst = new HashMap<>(); jsonMst.put("stor_id", sectDao.getStor_id()); @@ -495,12 +501,11 @@ public class InboundPdaServiceImpl implements InboundPdaService { } // 调用新增入库单 tableData.add(dtl); + materialWarehouseMappingService.saveOrUpdateMapping(materDao.getMaterial_code(),storeDao.getStor_code()); } jsonMst.put("tableData",tableData); String iostorinv_id = iRawAssistIStorService.insertDtl(jsonMst); - // 查询仓库 - BsrealStorattr storeDao = iSrealStorattrService.getById(sectDao.getStor_id()); // 组织主数据 Map jsonMst1 = new HashMap<>(); jsonMst1.put("checked", false); @@ -882,6 +887,8 @@ public class InboundPdaServiceImpl implements InboundPdaService { stockReturnIn.setRequest_data(callbackInData.toString()); iPmStockReturnService.save(stockReturnIn); } + //入库映射仓库 + materialWarehouseMappingService.saveOrUpdateMapping(material.getMaterial_code(), storattrIn.getStor_code()); }); ioStorInvMapper.insert(ioStorInvIn); ioStorInvDtlMapper.batchInsert(ioStorInvDtls); diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/IMaterialWarehouseMappingService.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/IMaterialWarehouseMappingService.java index 2630840e..bb472dfe 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/IMaterialWarehouseMappingService.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/IMaterialWarehouseMappingService.java @@ -8,6 +8,8 @@ import java.util.Map; public interface IMaterialWarehouseMappingService extends IService { void saveOrUpdateMapping(MaterialWarehouseMapping mapping); + void saveOrUpdateMapping(String materialCode, String storeCode); int loadFromInventory(); Map getWarehouseByMaterialCodes(Collection materialCodes); + String getOrDefault(String materialCode, String defaultStoreCode); } diff --git a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/impl/MaterialWarehouseMappingServiceImpl.java b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/impl/MaterialWarehouseMappingServiceImpl.java index 300e6598..2c93aeba 100644 --- a/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/impl/MaterialWarehouseMappingServiceImpl.java +++ b/nladmin-system/wms-server/src/main/java/org/nl/wms/pm_manage/demand/service/impl/MaterialWarehouseMappingServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.StringUtils; +import org.nl.common.domain.constant.RegionConstant; import org.nl.common.exception.BadRequestException; import org.nl.wms.pm_manage.demand.service.IMaterialWarehouseMappingService; import org.nl.wms.pm_manage.demand.service.dao.MaterialWarehouseMapping; @@ -15,13 +16,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; @Service @@ -55,6 +50,14 @@ public class MaterialWarehouseMappingServiceImpl extends ServiceImpl inventories = stInventoryService.queryInventory(new StInventoryQuery()); @@ -68,6 +71,9 @@ public class MaterialWarehouseMappingServiceImpl extends ServiceImpl firstWarehouseByMaterial = new HashMap<>(); for (StInventoryDto inventory : inventories) { + if (Objects.equals(inventory.getStorCode(), RegionConstant.ASSEMBLY_LINE_STORE_CODE)){//跳过装配线边仓 + continue; + } String materialCode = StringUtils.trimToNull(inventory.getMaterialCode()); // 库存查询页面和需求单分配均使用 storCode 作为仓库编码。 String warehouseCode = StringUtils.trimToNull(inventory.getStorCode()); @@ -98,4 +104,14 @@ public class MaterialWarehouseMappingServiceImpl extends ServiceImpl().in(MaterialWarehouseMapping::getMaterialCode, materialCodes)) .stream().collect(Collectors.toMap(MaterialWarehouseMapping::getMaterialCode, MaterialWarehouseMapping::getWarehouseCode)); } + + @Override + public String getOrDefault(String materialCode, String defaultStoreCode) { + MaterialWarehouseMapping one = getOne(new LambdaQueryWrapper() + .eq(MaterialWarehouseMapping::getMaterialCode, materialCode)); + if (one != null){ + return one.getWarehouseCode(); + } + return defaultStoreCode; + } }