diff --git a/src/main/java/com/spring/ifs/api/BomApi.java b/src/main/java/com/spring/ifs/api/BomApi.java index 1338052b..dcbfa635 100644 --- a/src/main/java/com/spring/ifs/api/BomApi.java +++ b/src/main/java/com/spring/ifs/api/BomApi.java @@ -769,6 +769,77 @@ public class BomApi { } } + /** + * @description: 查询使用的方法 + * @author LR + * @date 2025/7/4 09:38 + * @version 1.0 + */ + public static List getBomDistributionsForSync(Server srv, String contract, String partNo, String engChgLevel, String bomType, String alternativeNo) throws APException { + StringBuilder searchSql = new StringBuilder(); + searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT contract, PART_NO partNo, ENG_CHG_LEVEL engChgLevel,"); + searchSql.append(" BOM_TYPE bomType, ALTERNATIVE_NO alternativeNo, BYPROD_LINE_ITEM_NO byProdLineItemNo,"); + searchSql.append(" IFSAPP.MANUF_STRUCTURE_API.Get_Component_Part(contract,part_no,eng_chg_level,bom_type,alternative_no,BYPROD_LINE_ITEM_NO) byProductPartNo,"); + searchSql.append(" COMPONENT_LINE_ITEM_NO componentLineItemNo,"); + searchSql.append(" IFSAPP.MANUF_STRUCTURE_API.Get_Component_Part(contract,part_no,eng_chg_level,bom_type,alternative_no,COMPONENT_LINE_ITEM_NO) componentPartNo,"); + searchSql.append(" ITEM_COST_DISTRIBUTION itemCostDistribution"); + searchSql.append(" FROM IFSAPP.MANUF_STRUCT_COST_DISTRIB"); + searchSql.append(" WHERE CONTRACT = :contract AND PART_NO = :partNo AND ENG_CHG_LEVEL = :engChgLevel AND BOM_TYPE = :bomType AND ALTERNATIVE_NO = :alternativeNo"); + + //设置查询的入参 + Map inParam = new HashMap<>(); + inParam.put("contract", contract); + inParam.put("partNo", partNo); + inParam.put("engChgLevel", engChgLevel); + inParam.put("bomType", bomType); + inParam.put("alternativeNo", alternativeNo); + //调用查询的通用方法 + RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); + //判断能否返回 + if (recordCollection == null) { + return new ArrayList<>(); + } else { + List resultItems = new ArrayList<>(); + //调用通用的处理方法 返回Map + List> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); + //判断是否存在数据 + if (resultList == null) { + return resultItems; + } + //获取数据转bean + for (int i = 0; i < resultList.size(); i++) { + Map tempMap = resultList.get(i); + BomIfsManufStructCostDistrib tempItem = new BomIfsManufStructCostDistrib(); + //设置参数 + tempItem.setIfsRowId(tempMap.get("IFSROWID")); + tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); + tempItem.setPartNo(tempMap.get("PART_NO")); + tempItem.setContract(tempMap.get("CONTRACT")); + tempItem.setEngChgLevel(tempMap.get("ENG_CHG_LEVEL")); + tempItem.setBomType(tempMap.get("BOM_TYPE")); + tempItem.setAlternativeNo(tempMap.get("ALTERNATIVE_NO")); + + BigDecimal itemValue = new BigDecimal(tempMap.get("BYPRODLINEITEMNO")); + itemValue = itemValue.setScale(0, BigDecimal.ROUND_HALF_UP); + itemValue = itemValue.stripTrailingZeros(); + String formatterValue = itemValue.toPlainString(); + tempItem.setByProdLineItemNo(formatterValue); + + BigDecimal componentValue = new BigDecimal(tempMap.get("COMPONENTLINEITEMNO")); + componentValue = componentValue.setScale(0, BigDecimal.ROUND_HALF_UP); + componentValue = componentValue.stripTrailingZeros(); + String formatterComponentValue = componentValue.toPlainString(); + tempItem.setByProdLineItemNo(formatterComponentValue); + + tempItem.setComponentPartNo(tempMap.get("COMPONENTPARTNO")); + tempItem.setItemCostDistribution(tempMap.get("ITEMCOSTDISTRIBUTION")); + //添加对象 + resultItems.add(tempItem); + } + return resultItems; + } + } + /** * @description: 修改 Bom的副产品信息 * @author LR diff --git a/src/main/java/com/spring/ifs/bean/BomServiceBean.java b/src/main/java/com/spring/ifs/bean/BomServiceBean.java index 8dd347ac..17b9436e 100644 --- a/src/main/java/com/spring/ifs/bean/BomServiceBean.java +++ b/src/main/java/com/spring/ifs/bean/BomServiceBean.java @@ -641,6 +641,47 @@ public class BomServiceBean { return returnMap; } + + /** + * @description: 查询Bom分配信息 + * @author LR + * @date 2024/12/13 10:51 + * @version 1.0 + */ + public Map getBomDistributionsForSync(Server srv, BomIfsManufStructCostDistrib inData) { + logger.info("Bom Distribution查询开始:"+JSON.toJSONString(inData)); + //公共参数 + Map returnMap = new HashMap<>(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + try{ + //查询数据 + Map alternativeMap = BomApi.getBomAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Bom Alternative不存在!"); + } + //查询结果集 + List resultList = BomApi.getBomDistributionsForSync(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否查询数据 + if(resultList.size() == 0 || resultList.isEmpty()) { + throw new APException("不存在此bom组件分配信息!"); + } + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(resultList)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + logger.info("异常信息:"+e.getMessage()); + }//打印日志 + logger.info("Bom Distribution查询结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + /** * @description: 修改单个 Bom 副产品 * @author LR @@ -742,4 +783,4 @@ public class BomServiceBean { -} +} \ No newline at end of file