diff --git a/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java b/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java index 1049764c..5a4fde4c 100644 --- a/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java +++ b/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java @@ -1805,385 +1805,399 @@ public class PartInformationServiceImpl extends ServiceImpl revisionList = partInformationMapper.getPartRevisionList(ifsPart); // revision对象 - - // 校验revision - boolean b = revisionList.stream().anyMatch(a -> a.getEffPhaseOutDate() == null || a.getEffPhaseOutDate().isEmpty() || a.getEngRevision() == null || a.getEngRevision().isEmpty()); - if (b) { - throw new RuntimeException("请维护库存件版本的失效时间 和 工程版本号!"); - } - - // 1.1 库存件主表数据 - String getInventoryPartURL = apiUrl + "/part/ifs/getInventoryPartToIfs"; - ResponseData getInventoryPartResponse = HttpClientUtil.doPostByRawWithPLM(getInventoryPartURL, partIfsInventory); - if (!"200".equals(getInventoryPartResponse.getCode())) { // 新增 - String addInventoryPartURL = apiUrl + "/part/ifs/syncInventoryPartToIfs"; - ResponseData addInventoryPartResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartURL, partIfsInventory); - if (!"200".equals(addInventoryPartResponse.getCode())) { - throw new RuntimeException("IFS库存件新增异常:" + addInventoryPartResponse.getMsg()); - } - } else { // 修改 - String updateInventoryPartURL = apiUrl + "/part/ifs/modifyInventoryPartToIfs"; - ResponseData updateInventoryPartResponse = HttpClientUtil.doPostByRawWithPLM(updateInventoryPartURL, partIfsInventory); - if (!"200".equals(updateInventoryPartResponse.getCode())) { - throw new RuntimeException("IFS库存件修改异常:" + updateInventoryPartResponse.getMsg()); + // 1、库存件 + PartIfsInventory partIfsInventory = getPartIfsInventory(ifsPart); // 主表对象 + try { + // 同步数据到 IFS + if (dataUrl) { + PartIfsInventoryConfig partIfsInventoryConfig = getPartIfsInventoryConfig(ifsPart); // costs对象 + PartIfsInventoryManufacture partIfsInventoryManufacture = getPartIfsInventoryManufacture(ifsPart); // Manufacturing对象 + PartIfsInventoryPlan partIfsInventoryPlan = getPartIfsInventoryPlan(ifsPart); // planning对象 + List revisionList = partInformationMapper.getPartRevisionList(ifsPart); // revision对象 + + // 校验revision + boolean b = revisionList.stream().anyMatch(a -> a.getEffPhaseOutDate() == null || a.getEffPhaseOutDate().isEmpty() || a.getEngRevision() == null || a.getEngRevision().isEmpty()); + if (b) { + throw new RuntimeException("请维护库存件版本的失效时间 和 工程版本号!"); } - } - // 1.2 库存件 Costs 表数据 - String addInventoryPartCostsURL = apiUrl + "/part/ifs/modifyInventoryPartCostToIfs"; - ResponseData addInventoryPartCostsResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartCostsURL, partIfsInventoryConfig); - if (!"200".equals(addInventoryPartCostsResponse.getCode())) { - throw new RuntimeException("IFS库存件Costs修改异常:" + addInventoryPartCostsResponse.getMsg()); - } - // 1.3 库存件 Manufacturing 表数据 - String addInventoryPartManufacturingURL = apiUrl + "/part/ifs/modifyInventoryPartManufactureToIfs"; - ResponseData addInventoryPartManufacturingResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartManufacturingURL, partIfsInventoryManufacture); - if (!"200".equals(addInventoryPartManufacturingResponse.getCode())) { - throw new RuntimeException("IFS库存件Manufacturing修改异常:" + addInventoryPartManufacturingResponse.getMsg()); - } - // 1.4 库存件 Planning 表数据 - String addInventoryPartPlanningURL = apiUrl + "/part/ifs/modifyInventoryPartPlanToIfs"; - ResponseData addInventoryPartPlanningResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartPlanningURL, partIfsInventoryPlan); - if (!"200".equals(addInventoryPartPlanningResponse.getCode())) { - throw new RuntimeException("IFS库存件Planning修改异常:" + addInventoryPartPlanningResponse.getMsg()); - } - // 1.5 库存件 revision 表数据 - for (PartIfsInventoryRevision revision : revisionList) { - String queryPartRevisionURL = apiUrl + "/part/ifs/getInventoryPartRevision"; - ResponseData queryPartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(queryPartRevisionURL, revision); - if (!"200".equals(queryPartRevisionResponse.getCode())) { // 说明库存件版本不存在,走新增 - String savePartRevisionURL = apiUrl + "/part/ifs/syncInventoryPartRevisionToIfs"; - ResponseData savePartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(savePartRevisionURL, revision); - if (!"200".equals(savePartRevisionResponse.getCode())) { - throw new RuntimeException("IFS库存件版本新增异常:" + savePartRevisionResponse.getMsg()); + + // 1.1 库存件主表数据 + String getInventoryPartURL = apiUrl + "/part/ifs/getInventoryPart"; + ResponseData getInventoryPartResponse = HttpClientUtil.doPostByRawWithPLM(getInventoryPartURL, partIfsInventory); + if (!"200".equals(getInventoryPartResponse.getCode())) { // 新增 + String addInventoryPartURL = apiUrl + "/part/ifs/syncInventoryPartToIfs"; + ResponseData addInventoryPartResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartURL, partIfsInventory); + if (!"200".equals(addInventoryPartResponse.getCode())) { + throw new RuntimeException("IFS库存件新增异常:" + addInventoryPartResponse.getMsg()); } } else { // 修改 - String updatePartRevisionURL = apiUrl + "/part/ifs/modifyInventoryPartRevisionToIfs"; - ResponseData updatePartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(updatePartRevisionURL, revision); - if (!"200".equals(updatePartRevisionResponse.getCode())) { - throw new RuntimeException("IFS库存件版本修改异常:" + updatePartRevisionResponse.getMsg()); + String updateInventoryPartURL = apiUrl + "/part/ifs/modifyInventoryPartToIfs"; + ResponseData updateInventoryPartResponse = HttpClientUtil.doPostByRawWithPLM(updateInventoryPartURL, partIfsInventory); + if (!"200".equals(updateInventoryPartResponse.getCode())) { + throw new RuntimeException("IFS库存件修改异常:" + updateInventoryPartResponse.getMsg()); } } - } - } - - // 创建 IFS 物料的 BOM 和 Routing - // 所选 BOM 替代 - List bomAlternativeList = data.getBomAlternativeList(); - List routingAlternativeList = data.getRoutingAlternativeList(); - if (!"Purchased (raw)".equals(ifsPart.getPartType())) { - if (!bomAlternativeList.isEmpty()) { - // 对所选替代的版本进行去重 - TreeSet bomHeaderList = bomAlternativeList.stream().collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(BomDetailEntity::getEngChgLevel)))); - for (BomDetailVo bomDetailVo : bomHeaderList) { - BomHeaderEntity bomHeader = new BomHeaderEntity(); - bomHeader.setSite(ifsPart.getSite()); - bomHeader.setPartNo(ifsPart.getPartNo()); - if (ifsPart.getPartType().contains("Manufactured")) { - bomHeader.setBomType("Manufacturing"); - } else if ("Purchased".equals(ifsPart.getPartType())) { - bomHeader.setBomType("Purchase"); - } - bomHeader.setEffPhaseInDate(bomDetailVo.getEffPhaseInDate()); - bomHeader.setEngChgLevel(bomDetailVo.getEngChgLevel()); - bomHeader.setNoteText(bomDetailVo.getBomHeaderNoteText()); - bomHeader.setEngRevision(bomDetailVo.getEngRevision()); - bomHeader.setOfficialFlag("Y"); - - // 新增IFS 物料的 BOM 主信息 - bomManagementMapper.saveBomHeader(bomHeader); - - // 同步 BOM Header 数据到 IFS - if (dataUrl) { - BomIfsHeader bomIfsHeader = new BomIfsHeader(); - bomIfsHeader.setContract(bomHeader.getSite()); - bomIfsHeader.setPartNo(bomHeader.getPartNo()); - bomIfsHeader.setEngChgLevel(bomHeader.getEngChgLevel().toString()); - bomIfsHeader.setBomType(bomHeader.getBomType()); - bomIfsHeader.setEffPhaseInDate(DateUtils.format(bomHeader.getEffPhaseInDate())); - bomIfsHeader.setEffPhaseOutDate(bomIfsHeader.getEffPhaseOutDate() == null ? "" : DateUtils.format(bomHeader.getEffPhaseOutDate())); - bomIfsHeader.setNoteText(bomHeader.getNoteText()); - String getBomHeaderURL = apiUrl + "/bom/ifs/getBomHeader"; - ResponseData getBomHeaderResponse = HttpClientUtil.doPostByRawWithPLM(getBomHeaderURL, bomIfsHeader); - if (!"200".equals(getBomHeaderResponse.getCode())) { // 新增 - String addBomHeaderURL = apiUrl + "/bom/ifs/syncBomHeaderToIfs"; - ResponseData addBomHeaderResponse = HttpClientUtil.doPostByRawWithPLM(addBomHeaderURL, bomIfsHeader); - if (!"200".equals(addBomHeaderResponse.getCode())) { - throw new RuntimeException("IFS BOMHeader新增异常:" + addBomHeaderResponse.getMsg()); - } - } else { - // 修改 - String updateBomHeaderURL = apiUrl + "/bom/ifs/modifyBomHeaderToIfs"; - ResponseData updateBomHeaderResponse = HttpClientUtil.doPostByRawWithPLM(updateBomHeaderURL, bomIfsHeader); - if (!"200".equals(updateBomHeaderResponse.getCode())) { - throw new RuntimeException("IFS BOMHeader修改异常:" + updateBomHeaderResponse.getMsg()); - } + // 1.2 库存件 Costs 表数据 + String addInventoryPartCostsURL = apiUrl + "/part/ifs/modifyInventoryPartCostToIfs"; + ResponseData addInventoryPartCostsResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartCostsURL, partIfsInventoryConfig); + if (!"200".equals(addInventoryPartCostsResponse.getCode())) { + throw new RuntimeException("IFS库存件Costs修改异常:" + addInventoryPartCostsResponse.getMsg()); + } + // 1.3 库存件 Manufacturing 表数据 + String addInventoryPartManufacturingURL = apiUrl + "/part/ifs/modifyInventoryPartManufactureToIfs"; + ResponseData addInventoryPartManufacturingResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartManufacturingURL, partIfsInventoryManufacture); + if (!"200".equals(addInventoryPartManufacturingResponse.getCode())) { + throw new RuntimeException("IFS库存件Manufacturing修改异常:" + addInventoryPartManufacturingResponse.getMsg()); + } + // 1.4 库存件 Planning 表数据 + String addInventoryPartPlanningURL = apiUrl + "/part/ifs/modifyInventoryPartPlanToIfs"; + ResponseData addInventoryPartPlanningResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartPlanningURL, partIfsInventoryPlan); + if (!"200".equals(addInventoryPartPlanningResponse.getCode())) { + throw new RuntimeException("IFS库存件Planning修改异常:" + addInventoryPartPlanningResponse.getMsg()); + } + // 1.5 库存件 revision 表数据 + for (PartIfsInventoryRevision revision : revisionList) { + String queryPartRevisionURL = apiUrl + "/part/ifs/getInventoryPartRevision"; + ResponseData queryPartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(queryPartRevisionURL, revision); + if (!"200".equals(queryPartRevisionResponse.getCode())) { // 说明库存件版本不存在,走新增 + String savePartRevisionURL = apiUrl + "/part/ifs/syncInventoryPartRevisionToIfs"; + ResponseData savePartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(savePartRevisionURL, revision); + if (!"200".equals(savePartRevisionResponse.getCode())) { + throw new RuntimeException("IFS库存件版本新增异常:" + savePartRevisionResponse.getMsg()); + } + } else { +// // 删除再新增 +// String deletePartRevisionURL = apiUrl + "/part/ifs/removeInventoryPartRevisionToIfs"; +// ResponseData deletePartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(deletePartRevisionURL, revision); +// if (!"200".equals(deletePartRevisionResponse.getCode())) { +// throw new RuntimeException("IFS库存件版本删除异常:" + deletePartRevisionResponse.getMsg()); +// } +// String savePartRevisionURL = apiUrl + "/part/ifs/syncInventoryPartRevisionToIfs"; +// ResponseData savePartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(savePartRevisionURL, revision); +// if (!"200".equals(savePartRevisionResponse.getCode())) { +// throw new RuntimeException("IFS库存件版本新增异常:" + savePartRevisionResponse.getMsg()); +// } + // 修改 + String updatePartRevisionURL = apiUrl + "/part/ifs/modifyInventoryPartRevisionToIfs"; + ResponseData updatePartRevisionResponse = HttpClientUtil.doPostByRawWithPLM(updatePartRevisionURL, revision); + if (!"200".equals(updatePartRevisionResponse.getCode())) { + throw new RuntimeException("IFS库存件版本修改异常:" + updatePartRevisionResponse.getMsg()); } } } + } - for (BomDetailVo bomDetailVo : bomAlternativeList) { - // 查原物料的替代 - BomDetailEntity bomDetail = bomManagementMapper.queryDetailDataByNo(bomDetailVo); - // 查询原物料的 BOM 子物料 - List componentDataList = bomManagementMapper.queryBomComponentAll(bomDetailVo); - // 查询原BOM副产品成本分配数据列表 - List manufStructCostDistribList = bomManagementMapper.queryBomManufStructCostDistrib(bomDetailVo); - - // 创建 IFS 物料 BOM 的 替代 - bomDetail.setPartNo(ifsPart.getPartNo()); - bomDetail.setOfficialFlag("Y"); - bomManagementMapper.bomDetailSave(bomDetail); - - // 同步数据到 IFS - if (dataUrl) { - BomIfsAlternative bomIfsAlternative = new BomIfsAlternative(); - bomIfsAlternative.setContract(bomDetail.getSite()); - bomIfsAlternative.setPartNo(bomDetail.getPartNo()); - bomIfsAlternative.setEngChgLevel(bomDetail.getEngChgLevel().toString()); - bomIfsAlternative.setBomType(bomDetail.getBomType()); - bomIfsAlternative.setAlternativeNo(bomDetail.getAlternativeNo()); - bomIfsAlternative.setAlternativeDesc(bomDetail.getAlternativeDescription()); - bomIfsAlternative.setNoteText(bomDetail.getDetailNoteText()); - String getBomDetailURL = apiUrl + "/bom/ifs/getBomAlternative"; - ResponseData getBomDetailResponse = HttpClientUtil.doPostByRawWithPLM(getBomDetailURL, bomIfsAlternative); - if (!"200".equals(getBomDetailResponse.getCode())) { // 新增 - String addBomDetailURL = apiUrl + "/bom/ifs/syncBomAlternativeToIfs"; - ResponseData addBomDetailResponse = HttpClientUtil.doPostByRawWithPLM(addBomDetailURL, bomIfsAlternative); - if (!"200".equals(addBomDetailResponse.getCode())) { - throw new RuntimeException("IFS BOMAlternative新增异常:" + addBomDetailResponse.getMsg()); - } - } else { // 修改 - String updateBomDetailURL = apiUrl + "/bom/ifs/modifyBomAlternativeToIfs"; - ResponseData updateBomDetailResponse = HttpClientUtil.doPostByRawWithPLM(updateBomDetailURL, bomIfsAlternative); - if (!"200".equals(updateBomDetailResponse.getCode())) { - throw new RuntimeException("IFS BOMAlternative修改异常:" + updateBomDetailResponse.getMsg()); + // 创建 IFS 物料的 BOM 和 Routing + // 所选 BOM 替代 + List bomAlternativeList = data.getBomAlternativeList(); + List routingAlternativeList = data.getRoutingAlternativeList(); + if (!"Purchased (raw)".equals(ifsPart.getPartType())) { + if (!bomAlternativeList.isEmpty()) { + // 对所选替代的版本进行去重 + TreeSet bomHeaderList = bomAlternativeList.stream().collect(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(BomDetailEntity::getEngChgLevel)))); + for (BomDetailVo bomDetailVo : bomHeaderList) { + BomHeaderEntity bomHeader = new BomHeaderEntity(); + bomHeader.setSite(ifsPart.getSite()); + bomHeader.setPartNo(ifsPart.getPartNo()); + if (ifsPart.getPartType().contains("Manufactured")) { + bomHeader.setBomType("Manufacturing"); + } else if ("Purchased".equals(ifsPart.getPartType())) { + bomHeader.setBomType("Purchase"); + } + bomHeader.setEffPhaseInDate(bomDetailVo.getEffPhaseInDate()); + bomHeader.setEngChgLevel(bomDetailVo.getEngChgLevel()); + bomHeader.setNoteText(bomDetailVo.getBomHeaderNoteText()); + bomHeader.setEngRevision(bomDetailVo.getEngRevision()); + bomHeader.setOfficialFlag("Y"); + + // 新增IFS 物料的 BOM 主信息 + bomManagementMapper.saveBomHeader(bomHeader); + + // 同步 BOM Header 数据到 IFS + if (dataUrl) { + BomIfsHeader bomIfsHeader = new BomIfsHeader(); + bomIfsHeader.setContract(bomHeader.getSite()); + bomIfsHeader.setPartNo(bomHeader.getPartNo()); + bomIfsHeader.setEngChgLevel(bomHeader.getEngChgLevel().toString()); + bomIfsHeader.setBomType(bomHeader.getBomType()); + bomIfsHeader.setEffPhaseInDate(DateUtils.format(bomHeader.getEffPhaseInDate())); + bomIfsHeader.setEffPhaseOutDate(bomIfsHeader.getEffPhaseOutDate() == null ? "" : DateUtils.format(bomHeader.getEffPhaseOutDate())); + bomIfsHeader.setNoteText(bomHeader.getNoteText()); + String getBomHeaderURL = apiUrl + "/bom/ifs/getBomHeader"; + ResponseData getBomHeaderResponse = HttpClientUtil.doPostByRawWithPLM(getBomHeaderURL, bomIfsHeader); + if (!"200".equals(getBomHeaderResponse.getCode())) { // 新增 + String addBomHeaderURL = apiUrl + "/bom/ifs/syncBomHeaderToIfs"; + ResponseData addBomHeaderResponse = HttpClientUtil.doPostByRawWithPLM(addBomHeaderURL, bomIfsHeader); + if (!"200".equals(addBomHeaderResponse.getCode())) { + throw new RuntimeException("IFS BOMHeader新增异常:" + addBomHeaderResponse.getMsg()); + } + } else { + // 修改 + String updateBomHeaderURL = apiUrl + "/bom/ifs/modifyBomHeaderToIfs"; + ResponseData updateBomHeaderResponse = HttpClientUtil.doPostByRawWithPLM(updateBomHeaderURL, bomIfsHeader); + if (!"200".equals(updateBomHeaderResponse.getCode())) { + throw new RuntimeException("IFS BOMHeader修改异常:" + updateBomHeaderResponse.getMsg()); + } } } } - // 创建 IFS 物料 BOM 的 子物料 - if (!componentDataList.isEmpty()) { - List ifsBomComponentList = componentDataList.stream().map(c -> { - c.setPartNo(ifsPart.getPartNo()); - c.setAlternativeNo(bomDetail.getAlternativeNo()); - return c; - }).collect(Collectors.toList()); - bomManagementMapper.saveBomComponents(ifsBomComponentList); + for (BomDetailVo bomDetailVo : bomAlternativeList) { + // 查原物料的替代 + BomDetailEntity bomDetail = bomManagementMapper.queryDetailDataByNo(bomDetailVo); + // 查询原物料的 BOM 子物料 + List componentDataList = bomManagementMapper.queryBomComponentAll(bomDetailVo); + // 查询原BOM副产品成本分配数据列表 + List manufStructCostDistribList = bomManagementMapper.queryBomManufStructCostDistrib(bomDetailVo); + + // 创建 IFS 物料 BOM 的 替代 + bomDetail.setPartNo(ifsPart.getPartNo()); + bomDetail.setOfficialFlag("Y"); + bomManagementMapper.bomDetailSave(bomDetail); + // 同步数据到 IFS if (dataUrl) { - bomDetailVo.setPartNo(ifsPart.getPartNo()); - bomDetailVo.setAlternativeNo(bomDetail.getAlternativeNo()); - List componentList = bomManagementMapper.getBomComponent(bomDetailVo); - if (!componentList.isEmpty()) { - String addBomComponentURL = apiUrl + "/bom/ifs/syncBomIfsItemsToIfs"; - ResponseData addBomComponentResponse = HttpClientUtil.doPostByRawWithPLM(addBomComponentURL, componentList); - if (!"200".equals(addBomComponentResponse.getCode())) { - throw new RuntimeException("IFS BOM子物料新增异常:" + addBomComponentResponse.getMsg()); + BomIfsAlternative bomIfsAlternative = new BomIfsAlternative(); + bomIfsAlternative.setContract(bomDetail.getSite()); + bomIfsAlternative.setPartNo(bomDetail.getPartNo()); + bomIfsAlternative.setEngChgLevel(bomDetail.getEngChgLevel().toString()); + bomIfsAlternative.setBomType(bomDetail.getBomType()); + bomIfsAlternative.setAlternativeNo(bomDetail.getAlternativeNo()); + bomIfsAlternative.setAlternativeDesc(bomDetail.getAlternativeDescription()); + bomIfsAlternative.setNoteText(bomDetail.getDetailNoteText()); + String getBomDetailURL = apiUrl + "/bom/ifs/getBomAlternative"; + ResponseData getBomDetailResponse = HttpClientUtil.doPostByRawWithPLM(getBomDetailURL, bomIfsAlternative); + if (!"200".equals(getBomDetailResponse.getCode())) { // 新增 + String addBomDetailURL = apiUrl + "/bom/ifs/syncBomAlternativeToIfs"; + ResponseData addBomDetailResponse = HttpClientUtil.doPostByRawWithPLM(addBomDetailURL, bomIfsAlternative); + if (!"200".equals(addBomDetailResponse.getCode())) { + throw new RuntimeException("IFS BOMAlternative新增异常:" + addBomDetailResponse.getMsg()); + } + } else { // 修改 + String updateBomDetailURL = apiUrl + "/bom/ifs/modifyBomAlternativeToIfs"; + ResponseData updateBomDetailResponse = HttpClientUtil.doPostByRawWithPLM(updateBomDetailURL, bomIfsAlternative); + if (!"200".equals(updateBomDetailResponse.getCode())) { + throw new RuntimeException("IFS BOMAlternative修改异常:" + updateBomDetailResponse.getMsg()); } } } - } - // 创建 IFS 物料 BOM 的 副产品成本分配 - if (!manufStructCostDistribList.isEmpty()) { - // 创建副产品成本分配数据 - List collect1 = manufStructCostDistribList.stream().map(b -> { - b.setPartNo(ifsPart.getPartNo()); - b.setAlternativeNo(bomDetail.getAlternativeNo()); - return b; - }).collect(Collectors.toList()); - bomManagementMapper.saveBomManufStructCostDistrib(collect1); - - // 更新ifs的副产品成本分配数据 - List bomIfsManufStructCostDistribs = new ArrayList<>(); - for (BomManufStructCostDistribVo bomManufStructCostDistribVo : collect1) { - BomIfsManufStructCostDistrib bomIfsManufStructCostDistrib = new BomIfsManufStructCostDistrib(); - bomIfsManufStructCostDistrib.setContract(bomManufStructCostDistribVo.getSite()); - bomIfsManufStructCostDistrib.setPartNo(bomManufStructCostDistribVo.getPartNo()); - bomIfsManufStructCostDistrib.setEngChgLevel(bomManufStructCostDistribVo.getEngChgLevel().toString()); - bomIfsManufStructCostDistrib.setBomType(bomManufStructCostDistribVo.getBomType()); - bomIfsManufStructCostDistrib.setAlternativeNo(bomManufStructCostDistribVo.getAlternativeNo()); - bomIfsManufStructCostDistrib.setByProdLineItemNo(bomManufStructCostDistribVo.getByProdLineItemNo().toString()); - bomIfsManufStructCostDistrib.setComponentLineItemNo(bomManufStructCostDistribVo.getComponentLineItemNo().toString()); - bomIfsManufStructCostDistrib.setItemCostDistribution(bomManufStructCostDistribVo.getItemCostDistribution() == null ? "" : bomManufStructCostDistribVo.getItemCostDistribution().toString()); - bomIfsManufStructCostDistrib.setComponentPartNo(bomManufStructCostDistribVo.getComponentPartNo()); - bomIfsManufStructCostDistrib.setByProductPartNo(bomManufStructCostDistribVo.getByProdPartNo()); - bomIfsManufStructCostDistribs.add(bomIfsManufStructCostDistrib); - } - String updateBomManufStructCostDistribURL = apiUrl + "/bom/ifs/modifyBomManufStructCostDistribsToIfs"; - ResponseData updateBomManufStructCostDistribResponse = HttpClientUtil.doPostByRawWithPLM(updateBomManufStructCostDistribURL, bomIfsManufStructCostDistribs); - if (!"200".equals(updateBomManufStructCostDistribResponse.getCode())) { - throw new RuntimeException("IFS Bom副产品成本分配修改异常:" + updateBomManufStructCostDistribResponse.getMsg()); + // 创建 IFS 物料 BOM 的 子物料 + if (!componentDataList.isEmpty()) { + List ifsBomComponentList = componentDataList.stream().map(c -> { + c.setPartNo(ifsPart.getPartNo()); + c.setAlternativeNo(bomDetail.getAlternativeNo()); + return c; + }).collect(Collectors.toList()); + bomManagementMapper.saveBomComponents(ifsBomComponentList); + // 同步数据到 IFS + if (dataUrl) { + bomDetailVo.setPartNo(ifsPart.getPartNo()); + bomDetailVo.setAlternativeNo(bomDetail.getAlternativeNo()); + List componentList = bomManagementMapper.getBomComponent(bomDetailVo); + if (!componentList.isEmpty()) { + String addBomComponentURL = apiUrl + "/bom/ifs/syncBomIfsItemsToIfs"; + ResponseData addBomComponentResponse = HttpClientUtil.doPostByRawWithPLM(addBomComponentURL, componentList); + if (!"200".equals(addBomComponentResponse.getCode())) { + throw new RuntimeException("IFS BOM子物料新增异常:" + addBomComponentResponse.getMsg()); + } + } + } } - } - } - } - // Routing - if (!routingAlternativeList.isEmpty()) { - // 新增 IFS 物料的 Routing - if (ifsPart.getPartType().contains("Manufactured")) { - RoutingHeaderEntity headerEntity = routingManagementMapper.selectOne(new QueryWrapper().eq("site", data.getSite()).eq("part_no", data.getPartNo()).eq("routing_revision", routingAlternativeList.get(0).getRoutingRevision()).eq("routing_type", routingAlternativeList.get(0).getRoutingType())); - headerEntity.setPartNo(ifsPart.getPartNo()); - headerEntity.setOfficialFlag("Y"); - // 新增 routing 主信息 - routingManagementMapper.saveRoutingHeader(headerEntity); - - // 同步数据到 IFS - if (dataUrl) { - RoutingIfsHeader routingIfsHeader = new RoutingIfsHeader(); - routingIfsHeader.setContract(headerEntity.getSite()); - routingIfsHeader.setPartNo(headerEntity.getPartNo()); - routingIfsHeader.setRoutingRevision(headerEntity.getRoutingRevision().toString()); - routingIfsHeader.setRoutingType(headerEntity.getRoutingType()); - routingIfsHeader.setPhaseInDate(DateUtils.format(headerEntity.getPhaseInDate())); - routingIfsHeader.setPhaseOutDate(DateUtils.format(headerEntity.getPhaseOutDate())); - routingIfsHeader.setNoteText(headerEntity.getNoteText()); - String getRoutingHeaderURL = apiUrl + "/routing/ifs/getRoutingHeader"; - ResponseData getRoutingHeaderResponse = HttpClientUtil.doPostByRawWithPLM(getRoutingHeaderURL, routingIfsHeader); - if (!"200".equals(getRoutingHeaderResponse.getCode())) { // 新增 - String addRoutingHeaderURL = apiUrl + "/routing/ifs/syncRoutingHeaderToIfs"; - ResponseData addRoutingHeaderResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingHeaderURL, routingIfsHeader); - if (!"200".equals(addRoutingHeaderResponse.getCode())) { - throw new RuntimeException("IFS RoutingHeader新增异常:" + addRoutingHeaderResponse.getMsg()); + // 创建 IFS 物料 BOM 的 副产品成本分配 + if (!manufStructCostDistribList.isEmpty()) { + // 创建副产品成本分配数据 + List collect1 = manufStructCostDistribList.stream().map(b -> { + b.setPartNo(ifsPart.getPartNo()); + b.setAlternativeNo(bomDetail.getAlternativeNo()); + return b; + }).collect(Collectors.toList()); + bomManagementMapper.saveBomManufStructCostDistrib(collect1); + + // 更新ifs的副产品成本分配数据 + List bomIfsManufStructCostDistribs = new ArrayList<>(); + for (BomManufStructCostDistribVo bomManufStructCostDistribVo : collect1) { + BomIfsManufStructCostDistrib bomIfsManufStructCostDistrib = new BomIfsManufStructCostDistrib(); + bomIfsManufStructCostDistrib.setContract(bomManufStructCostDistribVo.getSite()); + bomIfsManufStructCostDistrib.setPartNo(bomManufStructCostDistribVo.getPartNo()); + bomIfsManufStructCostDistrib.setEngChgLevel(bomManufStructCostDistribVo.getEngChgLevel().toString()); + bomIfsManufStructCostDistrib.setBomType(bomManufStructCostDistribVo.getBomType()); + bomIfsManufStructCostDistrib.setAlternativeNo(bomManufStructCostDistribVo.getAlternativeNo()); + bomIfsManufStructCostDistrib.setByProdLineItemNo(bomManufStructCostDistribVo.getByProdLineItemNo().toString()); + bomIfsManufStructCostDistrib.setComponentLineItemNo(bomManufStructCostDistribVo.getComponentLineItemNo().toString()); + bomIfsManufStructCostDistrib.setItemCostDistribution(bomManufStructCostDistribVo.getItemCostDistribution() == null ? "" : bomManufStructCostDistribVo.getItemCostDistribution().toString()); + bomIfsManufStructCostDistrib.setComponentPartNo(bomManufStructCostDistribVo.getComponentPartNo()); + bomIfsManufStructCostDistrib.setByProductPartNo(bomManufStructCostDistribVo.getByProdPartNo()); + bomIfsManufStructCostDistribs.add(bomIfsManufStructCostDistrib); } - } else { // 修改 - String updateRoutingHeaderURL = apiUrl + "/routing/ifs/modifyRoutingHeaderToIfs"; - ResponseData updateRoutingHeaderResponse = HttpClientUtil.doPostByRawWithPLM(updateRoutingHeaderURL, routingIfsHeader); - if (!"200".equals(updateRoutingHeaderResponse.getCode())) { - throw new RuntimeException("IFS RoutingHeader修改异常:" + updateRoutingHeaderResponse.getMsg()); + String updateBomManufStructCostDistribURL = apiUrl + "/bom/ifs/modifyBomManufStructCostDistribsToIfs"; + ResponseData updateBomManufStructCostDistribResponse = HttpClientUtil.doPostByRawWithPLM(updateBomManufStructCostDistribURL, bomIfsManufStructCostDistribs); + if (!"200".equals(updateBomManufStructCostDistribResponse.getCode())) { + throw new RuntimeException("IFS Bom副产品成本分配修改异常:" + updateBomManufStructCostDistribResponse.getMsg()); } } } + } - // 创建 IFS 物料的 Routing 子物料 - for (RoutingDetailVo routingDetailVo : routingAlternativeList) { - // 查询原物料的 Routing 替代 - RoutingDetailEntity routingDetailEntity = routingManagementMapper.queryDetailDataByNo(routingDetailVo); - // 查询原物料的 Routing 工序 - List operationDataList = routingManagementMapper.queryRoutingComponent(routingDetailVo); - - // 创建 IFS 物料 Routing 的 替代 - routingDetailEntity.setPartNo(ifsPart.getPartNo()); - routingDetailEntity.setOfficialFlag("Y"); - routingManagementMapper.routingDetailSave(routingDetailEntity); + // Routing + if (!routingAlternativeList.isEmpty()) { + // 新增 IFS 物料的 Routing + if (ifsPart.getPartType().contains("Manufactured")) { + RoutingHeaderEntity headerEntity = routingManagementMapper.selectOne(new QueryWrapper().eq("site", data.getSite()).eq("part_no", data.getPartNo()).eq("routing_revision", routingAlternativeList.get(0).getRoutingRevision()).eq("routing_type", routingAlternativeList.get(0).getRoutingType())); + headerEntity.setPartNo(ifsPart.getPartNo()); + headerEntity.setOfficialFlag("Y"); + // 新增 routing 主信息 + routingManagementMapper.saveRoutingHeader(headerEntity); // 同步数据到 IFS if (dataUrl) { - RoutingIfsAlternative routingIfsAlternative = getIfsRoutingDetail(routingDetailEntity); - String getRoutingDetailURL = apiUrl + "/routing/ifs/getRoutingAlternative"; - ResponseData getRoutingDetailResponse = HttpClientUtil.doPostByRawWithPLM(getRoutingDetailURL, routingIfsAlternative); - if (!"200".equals(getRoutingDetailResponse.getCode())) { // 新增 - String addRoutingDetailURL = apiUrl + "/routing/ifs/syncRoutingAlternativeToIfs"; - ResponseData addRoutingDetailResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingDetailURL, routingIfsAlternative); - if (!"200".equals(addRoutingDetailResponse.getCode())) { - throw new RuntimeException("IFS RoutingAlternative新增异常:" + addRoutingDetailResponse.getMsg()); + RoutingIfsHeader routingIfsHeader = new RoutingIfsHeader(); + routingIfsHeader.setContract(headerEntity.getSite()); + routingIfsHeader.setPartNo(headerEntity.getPartNo()); + routingIfsHeader.setRoutingRevision(headerEntity.getRoutingRevision().toString()); + routingIfsHeader.setRoutingType(headerEntity.getRoutingType()); + routingIfsHeader.setPhaseInDate(DateUtils.format(headerEntity.getPhaseInDate())); + routingIfsHeader.setPhaseOutDate(DateUtils.format(headerEntity.getPhaseOutDate())); + routingIfsHeader.setNoteText(headerEntity.getNoteText()); + String getRoutingHeaderURL = apiUrl + "/routing/ifs/getRoutingHeader"; + ResponseData getRoutingHeaderResponse = HttpClientUtil.doPostByRawWithPLM(getRoutingHeaderURL, routingIfsHeader); + if (!"200".equals(getRoutingHeaderResponse.getCode())) { // 新增 + String addRoutingHeaderURL = apiUrl + "/routing/ifs/syncRoutingHeaderToIfs"; + ResponseData addRoutingHeaderResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingHeaderURL, routingIfsHeader); + if (!"200".equals(addRoutingHeaderResponse.getCode())) { + throw new RuntimeException("IFS RoutingHeader新增异常:" + addRoutingHeaderResponse.getMsg()); } } else { // 修改 - String updateRoutingDetailURL = apiUrl + "/routing/ifs/modifyRoutingAlternativeToIfs"; - ResponseData updateRoutingDetailResponse = HttpClientUtil.doPostByRawWithPLM(updateRoutingDetailURL, routingIfsAlternative); - if (!"200".equals(updateRoutingDetailResponse.getCode())) { - throw new RuntimeException("IFS RoutingAlternative修改异常:" + updateRoutingDetailResponse.getMsg()); + String updateRoutingHeaderURL = apiUrl + "/routing/ifs/modifyRoutingHeaderToIfs"; + ResponseData updateRoutingHeaderResponse = HttpClientUtil.doPostByRawWithPLM(updateRoutingHeaderURL, routingIfsHeader); + if (!"200".equals(updateRoutingHeaderResponse.getCode())) { + throw new RuntimeException("IFS RoutingHeader修改异常:" + updateRoutingHeaderResponse.getMsg()); } } } - // 创建 IFS 物料 Routing 的 工序 - if (!operationDataList.isEmpty()) { - RoutingComponentVo oldComponent = new RoutingComponentVo(); - for (RoutingComponentVo componentEntity : operationDataList) { - BeanUtils.copyProperties(componentEntity,oldComponent); - componentEntity.setPartNo(ifsPart.getPartNo()); - componentEntity.setAlternativeNo(routingDetailEntity.getAlternativeNo()); - routingManagementMapper.saveRoutingComponent(componentEntity); - - // 同步数据到 IFS - if (dataUrl) { - LinkedList routingIfsItems = new LinkedList<>(); - RoutingIfsItem routingIfsItem = getIfsRoutingComponent(componentEntity); - routingIfsItems.add(routingIfsItem); - String addRoutingComponentURL = apiUrl + "/routing/ifs/syncRoutingIfsItemsToIfs"; - ResponseData addRoutingComponentResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingComponentURL, routingIfsItems); - if (!"200".equals(addRoutingComponentResponse.getCode())) { - throw new RuntimeException("IFS RoutingItem新增异常:" + addRoutingComponentResponse.getMsg()); + // 创建 IFS 物料的 Routing 子物料 + for (RoutingDetailVo routingDetailVo : routingAlternativeList) { + // 查询原物料的 Routing 替代 + RoutingDetailEntity routingDetailEntity = routingManagementMapper.queryDetailDataByNo(routingDetailVo); + // 查询原物料的 Routing 工序 + List operationDataList = routingManagementMapper.queryRoutingComponent(routingDetailVo); + + // 创建 IFS 物料 Routing 的 替代 + routingDetailEntity.setPartNo(ifsPart.getPartNo()); + routingDetailEntity.setOfficialFlag("Y"); + routingManagementMapper.routingDetailSave(routingDetailEntity); + + // 同步数据到 IFS + if (dataUrl) { + RoutingIfsAlternative routingIfsAlternative = getIfsRoutingDetail(routingDetailEntity); + String getRoutingDetailURL = apiUrl + "/routing/ifs/getRoutingAlternative"; + ResponseData getRoutingDetailResponse = HttpClientUtil.doPostByRawWithPLM(getRoutingDetailURL, routingIfsAlternative); + if (!"200".equals(getRoutingDetailResponse.getCode())) { // 新增 + String addRoutingDetailURL = apiUrl + "/routing/ifs/syncRoutingAlternativeToIfs"; + ResponseData addRoutingDetailResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingDetailURL, routingIfsAlternative); + if (!"200".equals(addRoutingDetailResponse.getCode())) { + throw new RuntimeException("IFS RoutingAlternative新增异常:" + addRoutingDetailResponse.getMsg()); } - String s = String.valueOf(addRoutingComponentResponse.getObj()); - List ifsItems = JSON.parseArray(s, RoutingIfsItem.class); - if (!ifsItems.isEmpty()) { - for (RoutingIfsItem ifsItem : ifsItems) { // 修改ifs关键字 - routingManagementMapper.updateIfsRowKeyAndRevision(ifsItem); - } - } else { - throw new RuntimeException("IFS RoutingItem新增接口返回值异常!"); + } else { // 修改 + String updateRoutingDetailURL = apiUrl + "/routing/ifs/modifyRoutingAlternativeToIfs"; + ResponseData updateRoutingDetailResponse = HttpClientUtil.doPostByRawWithPLM(updateRoutingDetailURL, routingIfsAlternative); + if (!"200".equals(updateRoutingDetailResponse.getCode())) { + throw new RuntimeException("IFS RoutingAlternative修改异常:" + updateRoutingDetailResponse.getMsg()); } } + } + + // 创建 IFS 物料 Routing 的 工序 + if (!operationDataList.isEmpty()) { + RoutingComponentVo oldComponent = new RoutingComponentVo(); + for (RoutingComponentVo componentEntity : operationDataList) { + BeanUtils.copyProperties(componentEntity,oldComponent); + componentEntity.setPartNo(ifsPart.getPartNo()); + componentEntity.setAlternativeNo(routingDetailEntity.getAlternativeNo()); + routingManagementMapper.saveRoutingComponent(componentEntity); - // 查询原物料的 Routing Tool - List toolList = routingManagementMapper.getRoutingToolByOperation(oldComponent); - // 创建 IFS 物料 Routing 的 Tool - if (!toolList.isEmpty()) { - List tools = toolList.stream().map(a -> { - a.setPartNo(ifsPart.getPartNo()); - a.setAlternativeNo(componentEntity.getAlternativeNo()); - a.setOperationId(componentEntity.getOperationId()); - return a; - }).collect(Collectors.toList()); - routingManagementMapper.saveRoutingTool(tools); // 同步数据到 IFS if (dataUrl) { - List ifsRoutingTools = routingManagementMapper.getRoutingToolByOperationToIfs(componentEntity.getSite(), componentEntity.getPartNo(), componentEntity.getRoutingType(), componentEntity.getRoutingRevision(), componentEntity.getAlternativeNo(), componentEntity.getOperationId()); - String addRoutingToolURL = apiUrl + "/routing/ifs/syncRoutingIfsToolsToIfs"; - ResponseData addRoutingToolResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingToolURL, ifsRoutingTools); - if (!"200".equals(addRoutingToolResponse.getCode())) { - throw new RuntimeException("IFS RoutingTool新增异常:" + addRoutingToolResponse.getMsg()); + LinkedList routingIfsItems = new LinkedList<>(); + RoutingIfsItem routingIfsItem = getIfsRoutingComponent(componentEntity); + routingIfsItems.add(routingIfsItem); + String addRoutingComponentURL = apiUrl + "/routing/ifs/syncRoutingIfsItemsToIfs"; + ResponseData addRoutingComponentResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingComponentURL, routingIfsItems); + if (!"200".equals(addRoutingComponentResponse.getCode())) { + throw new RuntimeException("IFS RoutingItem新增异常:" + addRoutingComponentResponse.getMsg()); } - String s = String.valueOf(addRoutingToolResponse.getObj()); - List ifsTools = JSON.parseArray(s, RoutingIfsTool.class); - if (!ifsTools.isEmpty()) { - for (RoutingIfsTool ifsTool : ifsTools) { // 修改ifs关键字 - routingManagementMapper.updateIfsToolRowKeyAndRevision(ifsTool); + String s = String.valueOf(addRoutingComponentResponse.getObj()); + List ifsItems = JSON.parseArray(s, RoutingIfsItem.class); + if (!ifsItems.isEmpty()) { + for (RoutingIfsItem ifsItem : ifsItems) { // 修改ifs关键字 + routingManagementMapper.updateIfsRowKeyAndRevision(ifsItem); } } else { - throw new RuntimeException("IFS RoutingTool新增接口返回值异常!"); + throw new RuntimeException("IFS RoutingItem新增接口返回值异常!"); } } - } - // 查询原物料的 workGuide Line - List guideLineList = routingManagementMapper.getGuideLineByOperation(oldComponent); - // 创建 IFS 物料 Routing 的 workGuide Line - if (!guideLineList.isEmpty()) { - List guideLines = guideLineList.stream().map(x -> { - x.setPartNo(ifsPart.getPartNo()); - x.setAlternativeNo(componentEntity.getAlternativeNo()); - x.setOperationId(componentEntity.getOperationId()); - return x; - }).collect(Collectors.toList()); - routingManagementMapper.saveGuideLine(guideLines); - // 同步数据到 IFS - if (dataUrl) { - List ifsRoutingGuidelines = routingManagementMapper.getRoutingGuidelineByOperationToIfs(componentEntity.getSite(), componentEntity.getPartNo(), componentEntity.getRoutingType(), componentEntity.getRoutingRevision(), componentEntity.getAlternativeNo(), componentEntity.getOperationId()); - String addRoutingGuidelineURL = apiUrl + "/routing/ifs/syncRoutingIfsGuideLinesToIfs"; - ResponseData addRoutingGuidelineResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingGuidelineURL, ifsRoutingGuidelines); - if (!"200".equals(addRoutingGuidelineResponse.getCode())) { - throw new RuntimeException("IFS RoutingGuideline新增异常:" + addRoutingGuidelineResponse.getMsg()); + // 查询原物料的 Routing Tool + List toolList = routingManagementMapper.getRoutingToolByOperation(oldComponent); + // 创建 IFS 物料 Routing 的 Tool + if (!toolList.isEmpty()) { + List tools = toolList.stream().map(a -> { + a.setPartNo(ifsPart.getPartNo()); + a.setAlternativeNo(componentEntity.getAlternativeNo()); + a.setOperationId(componentEntity.getOperationId()); + return a; + }).collect(Collectors.toList()); + routingManagementMapper.saveRoutingTool(tools); + // 同步数据到 IFS + if (dataUrl) { + List ifsRoutingTools = routingManagementMapper.getRoutingToolByOperationToIfs(componentEntity.getSite(), componentEntity.getPartNo(), componentEntity.getRoutingType(), componentEntity.getRoutingRevision(), componentEntity.getAlternativeNo(), componentEntity.getOperationId()); + String addRoutingToolURL = apiUrl + "/routing/ifs/syncRoutingIfsToolsToIfs"; + ResponseData addRoutingToolResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingToolURL, ifsRoutingTools); + if (!"200".equals(addRoutingToolResponse.getCode())) { + throw new RuntimeException("IFS RoutingTool新增异常:" + addRoutingToolResponse.getMsg()); + } + String s = String.valueOf(addRoutingToolResponse.getObj()); + List ifsTools = JSON.parseArray(s, RoutingIfsTool.class); + if (!ifsTools.isEmpty()) { + for (RoutingIfsTool ifsTool : ifsTools) { // 修改ifs关键字 + routingManagementMapper.updateIfsToolRowKeyAndRevision(ifsTool); + } + } else { + throw new RuntimeException("IFS RoutingTool新增接口返回值异常!"); + } } - String s = String.valueOf(addRoutingGuidelineResponse.getObj()); - List ifsGuidelines = JSON.parseArray(s, RoutingIfsGuideLine.class); - if (!ifsGuidelines.isEmpty()) { - for (RoutingIfsGuideLine ifsGuideline : ifsGuidelines) { // 修改ifs关键字 - routingManagementMapper.updateIfsGuidelineRowKeyAndRevision(ifsGuideline); + } + + // 查询原物料的 workGuide Line + List guideLineList = routingManagementMapper.getGuideLineByOperation(oldComponent); + // 创建 IFS 物料 Routing 的 workGuide Line + if (!guideLineList.isEmpty()) { + List guideLines = guideLineList.stream().map(x -> { + x.setPartNo(ifsPart.getPartNo()); + x.setAlternativeNo(componentEntity.getAlternativeNo()); + x.setOperationId(componentEntity.getOperationId()); + return x; + }).collect(Collectors.toList()); + routingManagementMapper.saveGuideLine(guideLines); + // 同步数据到 IFS + if (dataUrl) { + List ifsRoutingGuidelines = routingManagementMapper.getRoutingGuidelineByOperationToIfs(componentEntity.getSite(), componentEntity.getPartNo(), componentEntity.getRoutingType(), componentEntity.getRoutingRevision(), componentEntity.getAlternativeNo(), componentEntity.getOperationId()); + String addRoutingGuidelineURL = apiUrl + "/routing/ifs/syncRoutingIfsGuideLinesToIfs"; + ResponseData addRoutingGuidelineResponse = HttpClientUtil.doPostByRawWithPLM(addRoutingGuidelineURL, ifsRoutingGuidelines); + if (!"200".equals(addRoutingGuidelineResponse.getCode())) { + throw new RuntimeException("IFS RoutingGuideline新增异常:" + addRoutingGuidelineResponse.getMsg()); + } + String s = String.valueOf(addRoutingGuidelineResponse.getObj()); + List ifsGuidelines = JSON.parseArray(s, RoutingIfsGuideLine.class); + if (!ifsGuidelines.isEmpty()) { + for (RoutingIfsGuideLine ifsGuideline : ifsGuidelines) { // 修改ifs关键字 + routingManagementMapper.updateIfsGuidelineRowKeyAndRevision(ifsGuideline); + } + } else { + throw new RuntimeException("IFS RoutingGuideline新增接口返回值异常!"); } - } else { - throw new RuntimeException("IFS RoutingGuideline新增接口返回值异常!"); } } } @@ -2192,56 +2206,64 @@ public class PartInformationServiceImpl extends ServiceImpl agents = partInformationMapper.getPartAgents(data); - List manufacturers = partInformationMapper.getPartManufacturers(data); - List defaultLocations = partInformationMapper.getPartDefaultLocations(data); - List files = partInformationMapper.getPartFiles(data); + // 创建 IFS 物料的代理商、制造商、默认库位、文档 + List agents = partInformationMapper.getPartAgents(data); + List manufacturers = partInformationMapper.getPartManufacturers(data); + List defaultLocations = partInformationMapper.getPartDefaultLocations(data); + List files = partInformationMapper.getPartFiles(data); - if (!agents.isEmpty()) { - List ifsAgents = agents.stream().map(a -> { - a.setPartNo(ifsPart.getPartNo()); - return a; - }).collect(Collectors.toList()); - partInformationMapper.savePartAgent(ifsAgents); - } + if (!agents.isEmpty()) { + List ifsAgents = agents.stream().map(a -> { + a.setPartNo(ifsPart.getPartNo()); + return a; + }).collect(Collectors.toList()); + partInformationMapper.savePartAgent(ifsAgents); + } - if (!manufacturers.isEmpty()) { - List ifsManufacturers = manufacturers.stream().map(a -> { - a.setPartNo(ifsPart.getPartNo()); - return a; - }).collect(Collectors.toList()); - partInformationMapper.savePartManufacturer(ifsManufacturers); - } + if (!manufacturers.isEmpty()) { + List ifsManufacturers = manufacturers.stream().map(a -> { + a.setPartNo(ifsPart.getPartNo()); + return a; + }).collect(Collectors.toList()); + partInformationMapper.savePartManufacturer(ifsManufacturers); + } - if (!defaultLocations.isEmpty()) { - List ifsDefaultLocations = defaultLocations.stream().map(a -> { - a.setPartNo(ifsPart.getPartNo()); - return a; - }).collect(Collectors.toList()); - partInformationMapper.savePartDefaultLocation(ifsDefaultLocations); + if (!defaultLocations.isEmpty()) { + List ifsDefaultLocations = defaultLocations.stream().map(a -> { + a.setPartNo(ifsPart.getPartNo()); + return a; + }).collect(Collectors.toList()); + partInformationMapper.savePartDefaultLocation(ifsDefaultLocations); - // 同步数据到 IFS - if (dataUrl) { - // location对象 - List locationList = partInformationMapper.getPartLocationList(ifsPart); - // 库存件 Location 表数据 - String addInventoryPartLocationURL = apiUrl + "/part/ifs/syncInventoryPartLocationsToIfs"; - ResponseData addInventoryPartLocationResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartLocationURL, locationList); - if (!"200".equals(addInventoryPartLocationResponse.getCode())) { - throw new RuntimeException("IFS 库存件Location新增异常:" + addInventoryPartLocationResponse.getMsg()); + // 同步数据到 IFS + if (dataUrl) { + // location对象 + List locationList = partInformationMapper.getPartLocationList(ifsPart); + // 库存件 Location 表数据 + String addInventoryPartLocationURL = apiUrl + "/part/ifs/syncInventoryPartLocationsToIfs"; + ResponseData addInventoryPartLocationResponse = HttpClientUtil.doPostByRawWithPLM(addInventoryPartLocationURL, locationList); + if (!"200".equals(addInventoryPartLocationResponse.getCode())) { + throw new RuntimeException("IFS 库存件Location新增异常:" + addInventoryPartLocationResponse.getMsg()); + } } } - } - if (!files.isEmpty()) { - List ifsFiles = files.stream().map(a -> { - a.setOrderRef2(ifsPart.getPartNo()); - return a; - }).collect(Collectors.toList()); - partInformationMapper.savePartFile(ifsFiles); + if (!files.isEmpty()) { + List ifsFiles = files.stream().map(a -> { + a.setOrderRef2(ifsPart.getPartNo()); + return a; + }).collect(Collectors.toList()); + partInformationMapper.savePartFile(ifsFiles); + } + } catch (Exception e) { + // 删除inventoryPart + String deleteInventoryPartURL = apiUrl + "/part/ifs/removeInventoryPartToIfs"; + ResponseData deleteInventoryPartResponse = HttpClientUtil.doPostByRawWithPLM(deleteInventoryPartURL, partIfsInventory); + if (!"200".equals(deleteInventoryPartResponse.getCode())) { + throw new RuntimeException("IFS库存件删除异常:" + deleteInventoryPartResponse.getMsg()); + } + throw new RuntimeException(e.getMessage()); } } diff --git a/src/main/resources/mapper/part/PartInformationMapper.xml b/src/main/resources/mapper/part/PartInformationMapper.xml index ed52c6fc..e3edc37d 100644 --- a/src/main/resources/mapper/part/PartInformationMapper.xml +++ b/src/main/resources/mapper/part/PartInformationMapper.xml @@ -1416,7 +1416,7 @@ b.eng_revision FROM plm_bom_detail as a LEFT JOIN plm_bom_header as b on a.site = b.site and a.part_no = b.part_no and a.eng_chg_level = b.eng_chg_level and a.bom_type = b.bom_type - WHERE a.site = #{site} and a.part_no = #{partNo} and a.bom_type = 'Manufacturing' and (b.eff_phase_out_date is null or b.eff_phase_out_date = '') + WHERE a.site = #{site} and a.part_no = #{partNo} and a.bom_type = 'Manufacturing' and b.eff_phase_out_date =]]> getDate()