diff --git a/src/main/java/com/spring/ifs/api/RecipeApi.java b/src/main/java/com/spring/ifs/api/RecipeApi.java index ee5b150b..08d509d3 100644 --- a/src/main/java/com/spring/ifs/api/RecipeApi.java +++ b/src/main/java/com/spring/ifs/api/RecipeApi.java @@ -77,8 +77,8 @@ public class RecipeApi { inParam.put("CONTRACT", contract); // 域 inParam.put("ENG_CHG_LEVEL", engChgLevel); // 物料的版本 inParam.put("BOM_TYPE", bomType); // BOM类型 - inParam.put("EFF_PHASE_IN_DATE", effPhaseInDate); // 启用日期 - inParam.put("EFF_PHASE_OUT_DATE", effPhaseOutDate); // 到期时间 + //inParam.put("EFF_PHASE_IN_DATE", effPhaseInDate); // 启用日期 + //inParam.put("EFF_PHASE_OUT_DATE", effPhaseOutDate); // 到期时间 inParam.put("NOTE_TEXT", noteText); // 备注 inParam.put("CREATE_DATE", createDate); // 创建日期 @@ -117,8 +117,8 @@ public class RecipeApi { //填充参数 inParam.put("OBJID", ifsRowId); inParam.put("OBJVERSION", ifsRowVersion); - inParam.put("EFF_PHASE_IN_DATE", effPhaseInDate); // 启用日期 - inParam.put("EFF_PHASE_OUT_DATE", effPhaseOutDate); // 到期时间 + //inParam.put("EFF_PHASE_IN_DATE", effPhaseInDate); // 启用日期 + //inParam.put("EFF_PHASE_OUT_DATE", effPhaseOutDate); // 到期时间 inParam.put("NOTE_TEXT", noteText); // 备注 //执行check的操作 @@ -166,6 +166,7 @@ public class RecipeApi { public static Map getRecipeAlternative(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, STD_SIZE_KG,"); + searchSql.append(" DISPLAY_WEIGHT_UOM, REG_UNIT, DISPLAY_VOLUME_UOM,"); searchSql.append(" CONTRACT, PART_NO, BOM_TYPE, ENG_CHG_LEVEL, ALTERNATIVE_NO, STATE, NOTE_TEXT"); searchSql.append(" FROM IFSAPP.RECIPE_STRUCT_ALTERNATE"); searchSql.append(" WHERE CONTRACT = :contract AND PART_NO = :partNo AND ENG_CHG_LEVEL = :engChgLevel AND BOM_TYPE = :bomType AND ALTERNATIVE_NO = :alternativeNo"); @@ -252,6 +253,7 @@ public class RecipeApi { //公共参数 String ifsRowId = inData.getIfsRowId();// 域 String ifsRowVersion = inData.getIfsRowVersion();// 物料编码 + String regUnit = inData.getRegUnit(); String alternativeDesc = inData.getAlternativeDesc(); String stdSizeKg = inData.getStdSizeKg(); String noteText = inData.getNoteText();// 备注 @@ -261,6 +263,7 @@ public class RecipeApi { inParam.put("OBJID", ifsRowId); inParam.put("OBJVERSION", ifsRowVersion); inParam.put("ALTERNATIVE_DESCRIPTION", alternativeDesc); // 替代编码描述 + inParam.put("REG_UNIT", regUnit); //类型 inParam.put("STD_SIZE_KG", stdSizeKg); // inParam.put("NOTE_TEXT", noteText); // 备注 @@ -520,8 +523,8 @@ public class RecipeApi { String leadtimeOffset = inData.getLeadtimeOffset(); String stdPlannedItem = inData.getStdPlannedItem(); String chargedItem = inData.getChargedItem(); - String createDate = inData.getCreateDate(); - String lastActivityDate = inData.getLastActivityDate(); + String createDate = DateUtils.getStringDate(new Date(), "yyyy-MM-dd")+"-00.00.00"; + String lastActivityDate = DateUtils.getStringDate(new Date(), "yyyy-MM-dd")+"-00.00.00"; String excludeFromCalculationsDb = inData.getExcludeFromCalculationsDb(); String excludeFromAsBuiltDb = inData.getExcludeFromAsBuiltDb(); String shrinkageFactor = inData.getShrinkageFactor(); @@ -607,8 +610,7 @@ public class RecipeApi { String leadtimeOffset = inData.getLeadtimeOffset(); String stdPlannedItem = inData.getStdPlannedItem(); String chargedItem = inData.getChargedItem(); - String createDate = inData.getCreateDate(); - String lastActivityDate = inData.getLastActivityDate(); + String lastActivityDate = DateUtils.getStringDate(new Date(), "yyyy-MM-dd")+"-00.00.00"; String excludeFromCalculationsDb = inData.getExcludeFromCalculationsDb(); String excludeFromAsBuiltDb = inData.getExcludeFromAsBuiltDb(); String shrinkageFactor = inData.getShrinkageFactor(); @@ -644,7 +646,6 @@ public class RecipeApi { inParam.put("EXCLUDE_FROM_AS_BUILT_DB", excludeFromAsBuiltDb); // inParam.put("SHRINKAGE_FACTOR", shrinkageFactor); // inParam.put("LOT_BATCH_ORIGIN_DB", lotBatchOriginDb); // - inParam.put("CREATE_DATE", createDate); // 创建时间 inParam.put("LAST_ACTIVITY_DATE", lastActivityDate); // 最近更新时间 //执行check的操作 diff --git a/src/main/java/com/spring/ifs/api/RecipeApiTest.java b/src/main/java/com/spring/ifs/api/RecipeApiTest.java new file mode 100644 index 00000000..982d1788 --- /dev/null +++ b/src/main/java/com/spring/ifs/api/RecipeApiTest.java @@ -0,0 +1,688 @@ +package com.spring.ifs.api; + +import com.spring.ifs.utils.IfsConverterToMap; +import com.spring.ifs.utils.IfsPlsqlUtils; +import com.spring.modules.base.utils.DateUtils; +import com.spring.modules.part.entity.APIEntity.RecipeIfsAlternative; +import com.spring.modules.part.entity.APIEntity.RecipeIfsHeader; +import com.spring.modules.part.entity.APIEntity.RecipeIfsItem; +import ifs.fnd.ap.*; + +import java.util.*; + +/** +* @description: 配方的api +* @author LR +* @date 2024/12/9 10:56 +* @version 1.0 +*/ +public class RecipeApiTest { + + /** + * @description: 查询 Recipe Header + * @author LR + * @date 2024/12/11 14:45 + * @version 1.0 + */ + public static Map getRecipeHeader(Server srv, String contract, String partNo, String engChgLevel, String bomType) throws APException { + StringBuilder searchSql = new StringBuilder(); + searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion,"); + searchSql.append(" CONTRACT, PART_NO, BOM_TYPE, ENG_CHG_LEVEL, NOTE_TEXT"); + searchSql.append(" FROM IFSAPP.RECIPE_STRUCTURE_HEAD"); + searchSql.append(" WHERE CONTRACT = :contract AND PART_NO = :partNo AND ENG_CHG_LEVEL = :engChgLevel AND BOM_TYPE = :bomType"); + //设置查询的入参 + Map inParam = new HashMap<>(); + inParam.put("contract", contract); + inParam.put("partNo", partNo); + inParam.put("engChgLevel", engChgLevel); + inParam.put("bomType", bomType); + //调用查询的通用方法 + RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); + //判断能否返回 + if (recordCollection == null) { + return null; + } else { + Record recordData = recordCollection.get(0); + Map resultMap = IfsConverterToMap.ConverterIfsToMap(recordData); + return resultMap; + } + } + + /** + * @description: 插入Recipe Header的主表 + * @author LR + * @date 2024/12/11 15:08 + * @version 1.0 + */ + public static Map insertRecipeHeader(Server srv, RecipeIfsHeader inData) throws APException { + //公共参数 + String contract = inData.getContract();// 域 + String partNo = inData.getPartNo();// 物料编码 + String engChgLevel = inData.getEngChgLevel();// 版本 + String bomType = inData.getBomType();// 分类 + String effPhaseInDate = inData.getEffPhaseInDate().substring(0, 10)+"-00.00.00";// 启用时间-年月日 + String effPhaseOutDate = inData.getEffPhaseOutDate();// 结束时间-年月日 + if(effPhaseOutDate == null || effPhaseOutDate.equals("")) { + effPhaseOutDate = ""; + }else { + effPhaseOutDate = effPhaseOutDate+"-00.00.00"; + } + //判断是否存在问题 + String noteText = inData.getNoteText();// 备注 + String createDate = DateUtils.getStringDate(new Date(), "yyyy-MM-dd")+"-00.00.00";//创建的时间 + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ""); + inParam.put("OBJVERSION", ""); + inParam.put("PART_NO", partNo); // 物料编码 + inParam.put("CONTRACT", contract); // 域 + inParam.put("ENG_CHG_LEVEL", engChgLevel); // 物料的版本 + inParam.put("BOM_TYPE", bomType); // BOM类型 + //inParam.put("EFF_PHASE_IN_DATE", effPhaseInDate); // 启用日期 + //inParam.put("EFF_PHASE_OUT_DATE", effPhaseOutDate); // 到期时间 + inParam.put("NOTE_TEXT", noteText); // 备注 + inParam.put("CREATE_DATE", createDate); // 创建日期 + + //执行存储过程 获取结果集 + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_HEAD_API", + "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_HEAD_API", + "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 修改Recipe Header的主表信息 + * @author LR + * @date 2024/12/11 15:32 + * @version 1.0 + */ + public static Map modifyRecipeHeader(Server srv, RecipeIfsHeader inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId(); + String ifsRowVersion = inData.getIfsRowVersion(); + String effPhaseInDate = inData.getEffPhaseInDate().substring(0, 10)+"-00.00.00";// 启用时间-年月日 + String effPhaseOutDate = inData.getEffPhaseOutDate();// 结束时间-年月日 + if(effPhaseOutDate == null || effPhaseOutDate.equals("")) { + effPhaseOutDate = ""; + }else { + effPhaseOutDate = effPhaseOutDate+"-00.00.00"; + } + //判断是否存在问题 + String noteText = inData.getNoteText();// 备注 + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + //inParam.put("EFF_PHASE_IN_DATE", effPhaseInDate); // 启用日期 + //inParam.put("EFF_PHASE_OUT_DATE", effPhaseOutDate); // 到期时间 + inParam.put("NOTE_TEXT", noteText); // 备注 + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_HEAD_API", + "MODIFY__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_HEAD_API", + "MODIFY__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 删除Recipe的主表信息 + * @author LR + * @date 2024/12/11 15:33 + * @version 1.0 + */ + public static Map removeRecipeHeader(Server srv, RecipeIfsHeader inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId(); + String ifsRowVersion = inData.getIfsRowVersion(); + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_HEAD_API", + "REMOVE__", PlsqlBaseMethodType.REMOVE, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_HEAD_API", + "REMOVE__", PlsqlBaseMethodType.REMOVE, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 查询Recipe Alternative + * @author LR + * @date 2024/12/11 14:48 + * @version 1.0 + */ + public static Map getRecipeAlternative(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, STD_SIZE_KG,"); + searchSql.append(" DISPLAY_WEIGHT_UOM, REG_UNIT, DISPLAY_VOLUME_UOM,"); + searchSql.append(" CONTRACT, PART_NO, BOM_TYPE, ENG_CHG_LEVEL, ALTERNATIVE_NO, STATE, NOTE_TEXT"); + searchSql.append(" FROM IFSAPP.RECIPE_STRUCT_ALTERNATE"); + 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 null; + } else { + Record recordData = recordCollection.get(0); + Map resultMap = IfsConverterToMap.ConverterIfsToMap(recordData); + return resultMap; + } + } + + /** + * @description: 插入Recipe Alternative + * @author LR + * @date 2024/12/11 15:45 + * @version 1.0 + */ + public static Map insertRecipeAlternative(Server srv, RecipeIfsAlternative inData) throws APException { + //公共参数 + String contract = inData.getContract();// 域 + String partNo = inData.getPartNo();// 物料编码 + String engChgLevel = inData.getEngChgLevel();// 版本 + String bomType = inData.getBomType();// 分类 + String alternativeNo = inData.getAlternativeNo(); + String alternativeDesc = inData.getAlternativeDesc(); + String displayWeightUom = inData.getDisplayWeightUom(); + String displayVolumeUom = inData.getDisplayVolumeUom(); + String regUnit = inData.getRegUnit(); + //判断是否存在问题 + String noteText = inData.getNoteText();// 备注 + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ""); + inParam.put("OBJVERSION", ""); + inParam.put("PART_NO", partNo); // 物料编码 + inParam.put("CONTRACT", contract); // 域 + inParam.put("ENG_CHG_LEVEL", engChgLevel); // 物料的版本 + inParam.put("BOM_TYPE", bomType); // BOM类型 + inParam.put("DISPLAY_WEIGHT_UOM", displayWeightUom); // + inParam.put("DISPLAY_VOLUME_UOM", displayVolumeUom); // + + //执行PREPARE的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.PREPARE, inParam); + + //填充PREPARE返回的参数 + inParam.put("STD_SIZE_KG", checkMap.get("STD_SIZE_KG")); // + inParam.put("YIELD", checkMap.get("YIELD")); // + inParam.put("USE_COST_DISTRIBUTION_DB", checkMap.get("USE_COST_DISTRIBUTION_DB")); // 替代编码 + inParam.put("REWORK_ALTERNATE_DB", checkMap.get("REWORK_ALTERNATE_DB")); // 替代编码 + //添加DO的参数 + inParam.put("ALTERNATIVE_NO", alternativeNo); // 替代编码 + inParam.put("ALTERNATIVE_DESCRIPTION", alternativeDesc); // 替代编码描述 + inParam.put("REG_UNIT", regUnit); // + inParam.put("NOTE_TEXT", noteText); // 备注 + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 修改Recipe Alternative + * @author LR + * @date 2024/12/11 15:47 + * @version 1.0 + */ + public static Map modifyRecipeAlternative(Server srv, RecipeIfsAlternative inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId();// 域 + String ifsRowVersion = inData.getIfsRowVersion();// 物料编码 + String regUnit = inData.getRegUnit(); + String alternativeDesc = inData.getAlternativeDesc(); + String stdSizeKg = inData.getStdSizeKg(); + String noteText = inData.getNoteText();// 备注 + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + inParam.put("ALTERNATIVE_DESCRIPTION", alternativeDesc); // 替代编码描述 + inParam.put("REG_UNIT", regUnit); //类型 + inParam.put("STD_SIZE_KG", stdSizeKg); // + inParam.put("NOTE_TEXT", noteText); // 备注 + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "MODIFY__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "MODIFY__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 删除Recipe Alternative + * @author LR + * @date 2024/12/11 15:51 + * @version 1.0 + */ + public static void removeRecipeAlternative(Server srv, RecipeIfsAlternative inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId();// 域 + String ifsRowVersion = inData.getIfsRowVersion();// 物料编码 + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "REMOVE__", PlsqlBaseMethodType.REMOVE, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "REMOVE__", PlsqlBaseMethodType.REMOVE, PlsqlBaseMethodAction.DO, inParam); + } + + /** + * @description: Build Recipe Alternative + * @author LR + * @date 2024/12/11 15:53 + * @version 1.0 + */ + public static Map buildRecipeAlternative(Server srv, RecipeIfsAlternative inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId();// 域 + String ifsRowVersion = inData.getIfsRowVersion();// 物料编码 + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "BUILD__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "BUILD__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: retire Recipe Alternative + * @author LR + * @date 2024/12/11 15:55 + * @version 1.0 + */ + public static Map retireRecipeAlternative(Server srv, RecipeIfsAlternative inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId();// 域 + String ifsRowVersion = inData.getIfsRowVersion();// 物料编码 + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "RETIRE__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCT_ALTERNATE_API", + "RETIRE__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 获取Recipe Item + * @author LR + * @date 2024/12/11 16:12 + * @version 1.0 + */ + public static Map getRecipeItem(Server srv, String contract, String partNo, String engChgLevel, String bomType, String alternativeNo, String lineItemNo) throws APException { + StringBuilder searchSql = new StringBuilder(); + searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, PART_NO, CONTRACT, ENG_CHG_LEVEL, BOM_TYPE, ALTERNATIVE_NO,"); + searchSql.append(" LINE_ITEM_NO, LINE_SEQUENCE, COMPONENT_PART, QTY_PER_ASSEMBLY, ISSUE_TYPE, WEIGHT_SHARE,"); + searchSql.append(" COMPONENT_SCRAP, SHRINKAGE_FACTOR"); + searchSql.append(" FROM IFSAPP.RECIPE_STRUCTURE"); + searchSql.append(" WHERE CONTRACT = :contract AND PART_NO = :partNo AND ENG_CHG_LEVEL = :engChgLevel AND BOM_TYPE = :bomType"); + searchSql.append(" AND ALTERNATIVE_NO = :alternativeNo AND LINE_ITEM_NO = :lineItemNo"); + + //设置查询的入参 + Map inParam = new HashMap<>(); + inParam.put("contract", contract); + inParam.put("partNo", partNo); + inParam.put("engChgLevel", engChgLevel); + inParam.put("bomType", bomType); + inParam.put("alternativeNo", alternativeNo); + inParam.put("lineItemNo", lineItemNo); + //调用查询的通用方法 + RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); + //判断能否返回 + if (recordCollection == null) { + return null; + } else { + Record recordData = recordCollection.get(0); + Map resultMap = IfsConverterToMap.ConverterIfsToMap(recordData); + return resultMap; + } + } + + /** + * @description: 获取Recipe Items + * @author LR + * @date 2024/12/11 16:16 + * @version 1.0 + */ + public static List> getRecipeItems(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, PART_NO, CONTRACT, ENG_CHG_LEVEL, BOM_TYPE, ALTERNATIVE_NO,"); + searchSql.append(" LINE_ITEM_NO, LINE_SEQUENCE, COMPONENT_PART, QTY_PER_ASSEMBLY, ISSUE_TYPE, WEIGHT_SHARE,"); + searchSql.append(" COMPONENT_SCRAP, SHRINKAGE_FACTOR"); + searchSql.append(" FROM IFSAPP.RECIPE_STRUCTURE"); + searchSql.append(" WHERE CONTRACT = :contract AND PART_NO = :partNo AND ENG_CHG_LEVEL = :engChgLevel AND BOM_TYPE = :bomType"); + searchSql.append(" 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 null; + } else { + List> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); + return resultList; + } + } + + /** + * @description: 查询 Recipe Item集合 + * @author LR + * @date 2024/12/13 9:48 + * @version 1.0 + */ + public static List getRecipeItems(Server srv, String contract, String partNo, String engChgLevel, String bomType, + String alternativeNo, String lineItemNo) throws APException { + StringBuilder searchSql = new StringBuilder(); + searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, PART_NO, CONTRACT, ENG_CHG_LEVEL, BOM_TYPE, ALTERNATIVE_NO,"); + searchSql.append(" LINE_ITEM_NO, LINE_SEQUENCE, COMPONENT_PART, QTY_PER_ASSEMBLY, ISSUE_TYPE, WEIGHT_SHARE,"); + searchSql.append(" COMPONENT_SCRAP, SHRINKAGE_FACTOR"); + searchSql.append(" FROM IFSAPP.RECIPE_STRUCTURE"); + searchSql.append(" WHERE CONTRACT = :contract AND PART_NO = :partNo AND ENG_CHG_LEVEL = :engChgLevel AND BOM_TYPE = :bomType"); + searchSql.append(" 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); + //判断是否需要添加查询的条件 + if(!(lineItemNo == null || "".equals(lineItemNo))) { + inParam.put("lineItemNo", lineItemNo); + searchSql.append(" AND LINE_ITEM_NO = :lineItemNo"); + } + //调用查询的通用方法 + 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); + RecipeIfsItem tempItem = new RecipeIfsItem(); + //设置参数 + 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")); + tempItem.setLineItemNo(tempMap.get("LINE_ITEM_NO")); + tempItem.setLineSequence(tempMap.get("LINE_SEQUENCE")); + tempItem.setComponentPart(tempMap.get("COMPONENT_PART")); + tempItem.setQtyPerAssembly(tempMap.get("QTY_PER_ASSEMBLY")); + tempItem.setIssueType(tempMap.get("ISSUE_TYPE")); + tempItem.setComponentScrap(tempMap.get("COMPONENT_SCRAP")); + tempItem.setShrinkageFactor(tempMap.get("SHRINKAGE_FACTOR")); + //添加对象 + resultItems.add(tempItem); + } + return resultItems; + } + } + + /** + * @description: 插入Recipe Item + * @author LR + * @date 2024/12/11 16:17 + * @version 1.0 + */ + public static Map insertRecipeItem(Server srv, RecipeIfsItem inData) throws APException { + //公共参数 + String contract = inData.getContract(); + String partNo = inData.getPartNo();// 物料编码 + String engChgLevel = inData.getEngChgLevel();// 版本 + String bomType = inData.getBomType();// 分类 + String alternativeNo = inData.getAlternativeNo(); + String lineItemNo = inData.getLineItemNo(); + String lineSequence = inData.getLineSequence(); + String componentPart = inData.getComponentPart();// + String weightShare = inData.getWeightShare(); + String partsByWeight = inData.getPartsByWeight(); + String qtyUom = inData.getQtyUom(); + String qtyPerAssembly = inData.getQtyPerAssembly(); + String componentScrap = inData.getComponentScrap(); + String issueType = inData.getIssueType(); + String issuePlannedScrapDb = inData.getIssuePlannedScrapDb(); + String issueOverreportedQtyDb = inData.getIssueOverreportedQtyDb(); + String fixedQtyFlag = inData.getFixedQtyFlag(); + String promisePlanned = inData.getPromisePlanned(); + String phantomConsume = inData.getPhantomConsume(); + String consumptionItem = inData.getConsumptionItem(); + String operCostDistribution = inData.getOperCostDistribution(); + String genOhCostDistribution = inData.getGenOhCostDistribution(); + String qtyKg = inData.getQtyKg(); + String byProdAsSupplyInMrpDb = inData.getByProdAsSupplyInMrpDb(); + String leadtimeOffset = inData.getLeadtimeOffset(); + String stdPlannedItem = inData.getStdPlannedItem(); + String chargedItem = inData.getChargedItem(); + String createDate = DateUtils.getStringDate(new Date(), "yyyy-MM-dd")+"-00.00.00"; + String lastActivityDate = DateUtils.getStringDate(new Date(), "yyyy-MM-dd")+"-00.00.00"; + String excludeFromCalculationsDb = inData.getExcludeFromCalculationsDb(); + String excludeFromAsBuiltDb = inData.getExcludeFromAsBuiltDb(); + String shrinkageFactor = inData.getShrinkageFactor(); + String lotBatchOriginDb = inData.getLotBatchOriginDb(); + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ""); + inParam.put("OBJVERSION", ""); + inParam.put("CONTRACT", contract); // 域 + inParam.put("PART_NO", partNo); // 物料编码 + inParam.put("ENG_CHG_LEVEL", engChgLevel); // 物料的版本 + inParam.put("BOM_TYPE", bomType); // BOM类型 + inParam.put("ALTERNATIVE_NO", alternativeNo); // 替代编码 + inParam.put("LINE_ITEM_NO", lineItemNo); // 行号 + inParam.put("LINE_SEQUENCE", lineSequence); // 序号 + inParam.put("COMPONENT_PART", componentPart); // 子零件 + inParam.put("QTY_PER_ASSEMBLY", qtyPerAssembly); // 单位用量 + inParam.put("ISSUE_TYPE", issueType); // 域 + inParam.put("COMPONENT_SCRAP", componentScrap); // 报废 + inParam.put("WEIGHT_SHARE", weightShare); // 损耗率 + inParam.put("PARTS_BY_WEIGHT", partsByWeight); // 备注 + inParam.put("QTY_UOM", qtyUom); // + inParam.put("ISSUE_PLANNED_SCRAP_DB", issuePlannedScrapDb); // + inParam.put("ISSUE_OVERREPORTED_QTY_DB", issueOverreportedQtyDb); // + inParam.put("FIXED_QTY_FLAG", fixedQtyFlag); // + inParam.put("PROMISE_PLANNED", promisePlanned); // + inParam.put("PHANTOM_CONSUME", phantomConsume); // + inParam.put("CONSUMPTION_ITEM", consumptionItem); // + inParam.put("OPER_COST_DISTRIBUTION", operCostDistribution); // + inParam.put("GEN_OH_COST_DISTRIBUTION", genOhCostDistribution); // + inParam.put("QTY_KG", qtyKg); // + inParam.put("BY_PROD_AS_SUPPLY_IN_MRP_DB", byProdAsSupplyInMrpDb); // + inParam.put("LEADTIME_OFFSET", leadtimeOffset); // + inParam.put("STD_PLANNED_ITEM", stdPlannedItem); // 固定值 + inParam.put("CHARGED_ITEM", chargedItem); // + inParam.put("EXCLUDE_FROM_CALCULATIONS_DB", excludeFromCalculationsDb); // + inParam.put("EXCLUDE_FROM_AS_BUILT_DB", excludeFromAsBuiltDb); // + inParam.put("SHRINKAGE_FACTOR", shrinkageFactor); // + inParam.put("LOT_BATCH_ORIGIN_DB", lotBatchOriginDb); // + inParam.put("CREATE_DATE", createDate); // 创建时间 + inParam.put("LAST_ACTIVITY_DATE", lastActivityDate); // 最近更新时间 + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_API", + "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_API", + "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 修改 Recipe Item + * @author LR + * @date 2024/12/11 16:22 + * @version 1.0 + */ + public static Map modifyRecipeItem(Server srv, RecipeIfsItem inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId();// + String ifsRowVersion = inData.getIfsRowVersion();// + String lineItemNo = inData.getLineItemNo(); + String lineSequence = inData.getLineSequence(); + String componentPart = inData.getComponentPart();// + String weightShare = inData.getWeightShare(); + String partsByWeight = inData.getPartsByWeight(); + String qtyUom = inData.getQtyUom(); + String qtyPerAssembly = inData.getQtyPerAssembly(); + String componentScrap = inData.getComponentScrap(); + String issueType = inData.getIssueType(); + String issuePlannedScrapDb = inData.getIssuePlannedScrapDb(); + String issueOverreportedQtyDb = inData.getIssueOverreportedQtyDb(); + String fixedQtyFlag = inData.getFixedQtyFlag(); + String promisePlanned = inData.getPromisePlanned(); + String phantomConsume = inData.getPhantomConsume(); + String consumptionItem = inData.getConsumptionItem(); + String operCostDistribution = inData.getOperCostDistribution(); + String genOhCostDistribution = inData.getGenOhCostDistribution(); + String qtyKg = inData.getQtyKg(); + String byProdAsSupplyInMrpDb = inData.getByProdAsSupplyInMrpDb(); + String leadtimeOffset = inData.getLeadtimeOffset(); + String stdPlannedItem = inData.getStdPlannedItem(); + String chargedItem = inData.getChargedItem(); + String lastActivityDate = DateUtils.getStringDate(new Date(), "yyyy-MM-dd")+"-00.00.00"; + String excludeFromCalculationsDb = inData.getExcludeFromCalculationsDb(); + String excludeFromAsBuiltDb = inData.getExcludeFromAsBuiltDb(); + String shrinkageFactor = inData.getShrinkageFactor(); + String lotBatchOriginDb = inData.getLotBatchOriginDb(); + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + inParam.put("LINE_ITEM_NO", lineItemNo); // 行号 + inParam.put("LINE_SEQUENCE", lineSequence); // 序号 + inParam.put("COMPONENT_PART", componentPart); // 子零件 + inParam.put("QTY_PER_ASSEMBLY", qtyPerAssembly); // 单位用量 + inParam.put("ISSUE_TYPE", issueType); // 域 + inParam.put("COMPONENT_SCRAP", componentScrap); // 报废 + inParam.put("WEIGHT_SHARE", weightShare); // 损耗率 + inParam.put("PARTS_BY_WEIGHT", partsByWeight); // 备注 + inParam.put("QTY_UOM", qtyUom); // + inParam.put("ISSUE_PLANNED_SCRAP_DB", issuePlannedScrapDb); // + inParam.put("ISSUE_OVERREPORTED_QTY_DB", issueOverreportedQtyDb); // + inParam.put("FIXED_QTY_FLAG", fixedQtyFlag); // + inParam.put("PROMISE_PLANNED", promisePlanned); // + inParam.put("PHANTOM_CONSUME", phantomConsume); // + inParam.put("CONSUMPTION_ITEM", consumptionItem); // + inParam.put("OPER_COST_DISTRIBUTION", operCostDistribution); // + inParam.put("GEN_OH_COST_DISTRIBUTION", genOhCostDistribution); // + inParam.put("QTY_KG", qtyKg); // + inParam.put("BY_PROD_AS_SUPPLY_IN_MRP_DB", byProdAsSupplyInMrpDb); // + inParam.put("LEADTIME_OFFSET", leadtimeOffset); // + inParam.put("STD_PLANNED_ITEM", stdPlannedItem); // 固定值 + inParam.put("CHARGED_ITEM", chargedItem); // + inParam.put("EXCLUDE_FROM_CALCULATIONS_DB", excludeFromCalculationsDb); // + inParam.put("EXCLUDE_FROM_AS_BUILT_DB", excludeFromAsBuiltDb); // + inParam.put("SHRINKAGE_FACTOR", shrinkageFactor); // + inParam.put("LOT_BATCH_ORIGIN_DB", lotBatchOriginDb); // + inParam.put("LAST_ACTIVITY_DATE", lastActivityDate); // 最近更新时间 + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_API", + "MODIFY__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_API", + "MODIFY__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.DO, inParam); + //返回结果集 + return resultMap; + } + + /** + * @description: 删除 Recipe Item + * @author LR + * @date 2024/12/11 16:24 + * @version 1.0 + */ + public static void removeRecipeItem(Server srv, RecipeIfsItem inData) throws APException { + //公共参数 + //公共参数 + String ifsRowId = inData.getIfsRowId();// + String ifsRowVersion = inData.getIfsRowVersion();// + //入参 + Map inParam = new HashMap<>(); + //填充参数 + inParam.put("OBJID", ifsRowId); + inParam.put("OBJVERSION", ifsRowVersion); + + //执行check的操作 + Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_API", + "REMOVE__", PlsqlBaseMethodType.REMOVE, PlsqlBaseMethodAction.CHECK, inParam); + //执行do的操作 + Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "RECIPE_STRUCTURE_API", + "REMOVE__", PlsqlBaseMethodType.REMOVE, PlsqlBaseMethodAction.DO, inParam); + } + +} diff --git a/src/main/java/com/spring/ifs/bean/BomServiceBean.java b/src/main/java/com/spring/ifs/bean/BomServiceBean.java index 1985e417..48954ad9 100644 --- a/src/main/java/com/spring/ifs/bean/BomServiceBean.java +++ b/src/main/java/com/spring/ifs/bean/BomServiceBean.java @@ -96,6 +96,7 @@ public class BomServiceBean { //调用api Map resultMap = BomApi.insertBomHeader(srv, inData); //设置版本的信息 + inData.setIfsRowId(resultMap.get("OBJID")); inData.setIfsRowVersion(resultMap.get("OBJVERSION")); returnMap.put("resultCode", "200"); returnMap.put("obj", JSON.toJSONString(inData)); diff --git a/src/main/java/com/spring/ifs/bean/BomServiceBeanTest.java b/src/main/java/com/spring/ifs/bean/BomServiceBeanTest.java index 9fa4d92c..2ac00f63 100644 --- a/src/main/java/com/spring/ifs/bean/BomServiceBeanTest.java +++ b/src/main/java/com/spring/ifs/bean/BomServiceBeanTest.java @@ -101,6 +101,7 @@ public class BomServiceBeanTest { //调用api Map resultMap = BomApiTest.insertBomHeader(srv, inData); //设置版本的信息 + inData.setIfsRowId(resultMap.get("OBJID")); inData.setIfsRowVersion(resultMap.get("OBJVERSION")); returnMap.put("resultCode", "200"); returnMap.put("obj", JSON.toJSONString(inData)); diff --git a/src/main/java/com/spring/ifs/bean/RecipeServiceBean.java b/src/main/java/com/spring/ifs/bean/RecipeServiceBean.java index 552b5ed4..58bedb46 100644 --- a/src/main/java/com/spring/ifs/bean/RecipeServiceBean.java +++ b/src/main/java/com/spring/ifs/bean/RecipeServiceBean.java @@ -1,8 +1,8 @@ package com.spring.ifs.bean; import com.alibaba.fastjson.JSON; -import com.spring.ifs.api.RecipeApi; import com.spring.ifs.api.IfsServer; +import com.spring.ifs.api.RecipeApi; import com.spring.modules.part.entity.APIEntity.RecipeIfsAlternative; import com.spring.modules.part.entity.APIEntity.RecipeIfsHeader; import com.spring.modules.part.entity.APIEntity.RecipeIfsItem; @@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -35,13 +34,13 @@ public class RecipeServiceBean { private static final Logger logger = LoggerFactory.getLogger(RecipeServiceBean.class); /** - * @description: 查询Bom Header + * @description: 查询Recipe Header * @author LR * @date 2024/12/12 15:49 * @version 1.0 */ public Map getRecipeHeader(Server srv, RecipeIfsHeader inData) { - logger.info("Bom查询参数:"+JSON.toJSONString(inData)); + logger.info("Recipe查询参数:"+JSON.toJSONString(inData)); //查询的参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -53,7 +52,7 @@ public class RecipeServiceBean { Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); //判断是否需要插入到ifs if(RecipeMap == null || RecipeMap.size() == 0) { - throw new RuntimeException("Bom不存在!"); + throw new RuntimeException("Recipe不存在!"); } //设置ifs 信息 inData.setIfsRowId(RecipeMap.get("IFSROWID")); @@ -65,19 +64,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom查询:"+JSON.toJSONString(inData)); + logger.info("Recipe查询:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: Bom Header新增 + * @description: Recipe Header新增 * @author LR * @date 2024/12/12 15:52 * @version 1.0 */ public Map syncRecipeHeader(Server srv, RecipeIfsHeader inData) { - logger.info("Bom新增开始:"+JSON.toJSONString(inData)); + logger.info("Recipe新增开始:"+JSON.toJSONString(inData)); //查询的参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -89,12 +88,13 @@ public class RecipeServiceBean { Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); //判断是否需要插入到ifs if(RecipeMap != null && RecipeMap.size() > 0) { - throw new APException("Bom已存在!"); + throw new APException("Recipe已存在!"); } //调用api Map resultMap = RecipeApi.insertRecipeHeader(srv, inData); //设置版本的信息 + inData.setIfsRowId(resultMap.get("OBJID")); inData.setIfsRowVersion(resultMap.get("OBJVERSION")); returnMap.put("resultCode", "200"); returnMap.put("obj", JSON.toJSONString(inData)); @@ -103,19 +103,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom新增结束:"+JSON.toJSONString(inData)); + logger.info("Recipe新增结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: Bom Header修改 + * @description: Recipe Header修改 * @author LR * @date 2024/12/12 15:55 * @version 1.0 */ public Map modifyRecipeHeader(Server srv, RecipeIfsHeader inData) { - logger.info("Bom修改开始:"+JSON.toJSONString(inData)); + logger.info("Recipe修改开始:"+JSON.toJSONString(inData)); //查询的参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -127,7 +127,7 @@ public class RecipeServiceBean { Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); //判断是否需要插入到ifs if(RecipeMap == null || RecipeMap.size() == 0) { - throw new APException("Bom不存在!"); + throw new APException("Recipe不存在!"); } //设置ifs 信息 inData.setIfsRowId(RecipeMap.get("IFSROWID")); @@ -142,19 +142,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom修改结束:"+JSON.toJSONString(inData)); + logger.info("Recipe修改结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: Bom Header删除 + * @description: Recipe Header删除 * @author LR * @date 2024/12/12 15:58 * @version 1.0 */ public Map removeRecipeHeader(Server srv, RecipeIfsHeader inData) { - logger.info("Bom Header删除开始:"+JSON.toJSONString(inData)); + logger.info("Recipe Header删除开始:"+JSON.toJSONString(inData)); //查询的参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -166,7 +166,7 @@ public class RecipeServiceBean { Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); //判断是否需要插入到ifs if(RecipeMap == null || RecipeMap.size() == 0) { - throw new APException("Bom不存在!"); + throw new APException("Recipe不存在!"); } //设置ifs 信息 inData.setIfsRowId(RecipeMap.get("IFSROWID")); @@ -179,19 +179,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom Header 删除结束:"+JSON.toJSONString(inData)); + logger.info("Recipe Header 删除结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: 查询Bom Alternative + * @description: 查询Recipe Alternative * @author LR * @date 2024/12/12 16:59 * @version 1.0 */ - public Map getBomAlternative(Server srv, RecipeIfsAlternative inData) { - logger.info("Bom Alternative 查询开始:"+JSON.toJSONString(inData)); + public Map getRecipeAlternative(Server srv, RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 查询开始:"+JSON.toJSONString(inData)); //公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -204,7 +204,7 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null) { - throw new APException("Bom Alternative 不存在!"); + throw new APException("Recipe Alternative 不存在!"); } //设置ifs 信息 inData.setIfsRowId(alternativeMap.get("IFSROWID")); @@ -216,19 +216,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom Alternative 查询结束:"+JSON.toJSONString(inData)); + logger.info("Recipe Alternative 查询结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: 插入Bom Alternative + * @description: 插入Recipe Alternative * @author LR * @date 2024/12/12 17:03 * @version 1.0 */ - public Map syncRecipeAlternative(Server srv, RecipeIfsAlternative inData) { - logger.info("Bom Alternative 新增开始:"+JSON.toJSONString(inData)); + public Map syncRecipeAlternative(Server srv, RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 新增开始:"+JSON.toJSONString(inData)); //公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -241,7 +241,7 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap != null && alternativeMap.size() > 0) { - throw new APException("Bom Alternative 已存在!"); + throw new APException("Recipe Alternative 已存在!"); } //调用新增api @@ -250,25 +250,25 @@ public class RecipeServiceBean { inData.setIfsRowId(resultMap.get("OBJID")); inData.setIfsRowVersion(resultMap.get("OBJVERSION")); returnMap.put("resultCode", "200"); - returnMap.put("obj", JSON.toJSONString(inData)); + returnMap.put("obj", JSON.toJSONString(resultMap)); } catch(APException e){ returnMap.put("resultCode", "400"); returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom Alternative 新增结束:"+JSON.toJSONString(inData)); + logger.info("Recipe Alternative 新增结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: 修改Bom Alternative + * @description: 修改Recipe Alternative * @author LR * @date 2024/12/12 17:06 * @version 1.0 */ - public Map modifyRecipeAlternative(Server srv, RecipeIfsAlternative inData) { - logger.info("Bom Alternative 修改开始:"+JSON.toJSONString(inData)); + public Map modifyRecipeAlternative(Server srv, RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 修改开始:"+JSON.toJSONString(inData)); //公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -281,11 +281,12 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null || alternativeMap.size() == 0) { - throw new APException("Bom Alternative不存在!"); + throw new APException("Recipe Alternative不存在!"); } //设置ifs 信息 inData.setIfsRowId(alternativeMap.get("IFSROWID")); inData.setIfsRowVersion(alternativeMap.get("IFSROWVERSION")); + inData.setStdSizeKg(inData.getStdSizeKg()); //调用api Map resultMap = RecipeApi.modifyRecipeAlternative(srv, inData); //设置ifs 信息 @@ -297,19 +298,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom Alternative 修改结束:"+JSON.toJSONString(inData)); + logger.info("Recipe Alternative 修改结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: 删除Bom Alternative + * @description: 删除Recipe Alternative * @author LR * @date 2024/12/12 17:07 * @version 1.0 */ - public Map removeRecipeAlternative(Server srv, RecipeIfsAlternative inData) { - logger.info("Bom Alternative 删除开始:"+JSON.toJSONString(inData)); + public Map removeRecipeAlternative(Server srv, RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 删除开始:"+JSON.toJSONString(inData)); //公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -322,7 +323,7 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null || alternativeMap.size() == 0) { - throw new APException("Bom Alternative不存在!"); + throw new APException("Recipe Alternative不存在!"); } //设置ifs 信息 inData.setIfsRowId(alternativeMap.get("IFSROWID")); @@ -336,19 +337,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom Alternative 删除结束:"+JSON.toJSONString(inData)); + logger.info("Recipe Alternative 删除结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: Build Bom Alternative + * @description: Build Recipe Alternative * @author LR * @date 2024/12/13 9:37 * @version 1.0 */ - public Map buildRecipeAlternative(Server srv, RecipeIfsAlternative inData) { - logger.info("Bom替代Build开始:"+JSON.toJSONString(inData)); + public Map buildRecipeAlternative(Server srv, RecipeIfsAlternative inData) { + logger.info("Recipe替代Build开始:"+JSON.toJSONString(inData)); //公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -361,7 +362,7 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null || alternativeMap.size() == 0) { - throw new APException("Bom Alternative不存在!"); + throw new APException("Recipe Alternative不存在!"); } //设置ifs 信息 inData.setIfsRowId(alternativeMap.get("IFSROWID")); @@ -377,19 +378,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom替代Build结束:"+JSON.toJSONString(inData)); + logger.info("Recipe替代Build结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: Retire Bom Alternative + * @description: Retire Recipe Alternative * @author LR * @date 2024/12/13 9:40 * @version 1.0 */ - public Map retireRecipeAlternative(Server srv, RecipeIfsAlternative inData) { - logger.info("Bom替代retire开始:"+JSON.toJSONString(inData)); + public Map retireRecipeAlternative(Server srv, RecipeIfsAlternative inData) { + logger.info("Recipe替代retire开始:"+JSON.toJSONString(inData)); //公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -402,7 +403,7 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null || alternativeMap.size() == 0) { - throw new APException("Bom Alternative不存在!"); + throw new APException("Recipe Alternative不存在!"); } //设置ifs 信息 inData.setIfsRowId(alternativeMap.get("IFSROWID")); @@ -418,18 +419,18 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom替代retire开始:"+JSON.toJSONString(inData)); + logger.info("Recipe替代retire开始:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: 获取Bom 的明细 + * @description: 获取Recipe 的明细 * @author LR * @date 2024/12/13 9:53 * @version 1.0 */ - public Map getBomItems(Server srv, RecipeIfsItem inData) { + public Map getRecipeItems(Server srv, RecipeIfsItem inData) { //公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -443,34 +444,34 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null || alternativeMap.size() == 0) { - throw new APException("Bom Alternative不存在!"); + throw new APException("Recipe Alternative不存在!"); } //查询结果集 List resultList = RecipeApi.getRecipeItems(srv, contract, partNo, engChgLevel, bomType, alternativeNo, lineItemNo); //判断是否查询数据 if(resultList == null ||resultList.size() == 0 || resultList.isEmpty()) { - throw new APException("不存在此bom组件信息!"); + throw new APException("不存在此查Recipe组件信息!"); } returnMap.put("resultCode", "200"); - returnMap.put("obj", JSON.toJSONString(inData)); + returnMap.put("obj", JSON.toJSONString(resultList)); } catch(APException e){ returnMap.put("resultCode", "400"); returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom替代明细集合结束:"+JSON.toJSONString(inData)); + logger.info("Recipe替代明细集合结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } /** - * @description: 批量新增Bom Item + * @description: 批量新增查Recipe Item * @author LR * @date 2024/12/12 17:23 * @version 1.0 */ - public Map syncBomItems(Server srv, List inDatas) { - logger.info("Bom替代明细集合新增开始:"+JSON.toJSONString(inDatas)); + public Map syncRecipeItems(Server srv, List inDatas) { + logger.info("Recipe替代明细集合新增开始:"+JSON.toJSONString(inDatas)); //公共参数 Map returnMap = new HashMap<>(); String contract = inDatas.get(0).getContract(); @@ -484,29 +485,29 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null || alternativeMap.size() == 0) { - throw new APException("Bom Alternative不存在!"); + throw new APException("Recipe Alternative不存在!"); } //查询结果集 List itemList = RecipeApi.getRecipeItems(srv, contract, partNo, engChgLevel, bomType, alternativeNo, null); //转Map Map itemMap = itemList.stream().collect(Collectors.toMap(RecipeIfsItem::getLineItemNo, RecipeIfsItem::getLineItemNo)); //打印日志 - logger.info("Bom替代明细集合 批量新增结束:"+JSON.toJSONString(inDatas)); + logger.info("Recipe替代明细集合 批量新增结束:"+JSON.toJSONString(inDatas)); //循环判断的方法 - for(RecipeIfsItem bomItem : inDatas) { + for(RecipeIfsItem recipeItem : inDatas) { //判断是否已经存在 - String tempLineItemNo = bomItem.getLineItemNo(); + String tempLineItemNo = recipeItem.getLineItemNo(); if(itemMap.containsKey(tempLineItemNo)) { throw new APException("已存在此bom组件信息!LineItemNo:"+tempLineItemNo); } } // 校验通过 循环调用新增的方法 - for(RecipeIfsItem bomItem : inDatas) { + for(RecipeIfsItem recipeItem : inDatas) { //调用api - Map tempMap = RecipeApi.insertRecipeItem(srv, bomItem); + Map tempMap = RecipeApi.insertRecipeItem(srv, recipeItem); //设置ifs 信息 - bomItem.setIfsRowId(tempMap.get("OBJID")); - bomItem.setIfsRowVersion(tempMap.get("OBJVERSION")); + recipeItem.setIfsRowId(tempMap.get("OBJID")); + recipeItem.setIfsRowVersion(tempMap.get("OBJVERSION")); } returnMap.put("resultCode", "200"); returnMap.put("obj", JSON.toJSONString(inDatas)); @@ -515,19 +516,19 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom替代明细集合新增开始:"+JSON.toJSONString(inDatas)); + logger.info("Recipe替代明细集合新增开始:"+JSON.toJSONString(inDatas)); //返回结果集 return returnMap; } /** - * @description: 修改Bom的明细 + * @description: 修改查Recipe的明细 暂时不可用 * @author LR * @date 2024/12/13 10:24 * @version 1.0 */ - public Map modifyBomItem(Server srv, RecipeIfsItem inData) { - logger.info("Bom替代明细新增开始:"+JSON.toJSONString(inData)); + public Map modifyRecipeItem(Server srv, RecipeIfsItem inData) { + logger.info("Recipe替代明细新增开始:"+JSON.toJSONString(inData)); // 公共参数 Map returnMap = new HashMap<>(); String contract = inData.getContract(); @@ -541,24 +542,24 @@ public class RecipeServiceBean { Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); //判断是否需要插入到ifs if(alternativeMap == null || alternativeMap.size() == 0) { - throw new APException("Bom Alternative不存在!"); + throw new APException("Recipe Alternative不存在!"); } //查询结果集 List resultList = RecipeApi.getRecipeItems(srv, contract, partNo, engChgLevel, bomType, alternativeNo, lineItemNo); //判断是否查询数据 if(resultList.size() == 0 || resultList.isEmpty()) { - throw new APException("不存在此bom组件信息!"); + throw new APException("不存在此Recipe组件信息!"); } - RecipeIfsItem bomItem = resultList.get(0); + RecipeIfsItem recipeItem = resultList.get(0); //设置版本信息 - inData.setIfsRowId(bomItem.getIfsRowId()); - inData.setIfsRowVersion(bomItem.getIfsRowVersion()); + inData.setIfsRowId(recipeItem.getIfsRowId()); + inData.setIfsRowVersion(recipeItem.getIfsRowVersion()); //调用修改的方法 Map resultMap = RecipeApi.modifyRecipeItem(srv, inData); //设置ifs 信息 - bomItem.setIfsRowId(resultMap.get("OBJID")); - bomItem.setIfsRowVersion(resultMap.get("OBJVERSION")); + recipeItem.setIfsRowId(resultMap.get("OBJID")); + recipeItem.setIfsRowVersion(resultMap.get("OBJVERSION")); returnMap.put("resultCode", "200"); returnMap.put("obj", JSON.toJSONString(inData)); } catch(APException e){ @@ -566,7 +567,7 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom替代明细新增结束:"+JSON.toJSONString(inData)); + logger.info("Recipe替代明细新增结束:"+JSON.toJSONString(inData)); //返回结果集 return returnMap; } @@ -577,8 +578,8 @@ public class RecipeServiceBean { * @date 2024/12/13 10:26 * @version 1.0 */ - public Map removeRecipeItem(Server srv, ArrayList inDatas) { - logger.info("Bom 明细集合删除开始:"+JSON.toJSONString(inDatas)); + public Map removeRecipeItems(Server srv, List inDatas) { + logger.info("Recipe 明细集合删除开始:"+JSON.toJSONString(inDatas)); //公共参数 Map returnMap = new HashMap<>(); String contract = inDatas.get(0).getContract(); @@ -592,24 +593,24 @@ public class RecipeServiceBean { //转Map Map itemMap = itemList.stream().collect(Collectors.toMap(RecipeIfsItem::getLineItemNo, Function.identity())); //打印日志 - logger.info("Bom替代明细集合 批量新增结束:"+JSON.toJSONString(inDatas)); + logger.info("Recipe替代明细集合 批量新增结束:"+JSON.toJSONString(inDatas)); //循环判断的方法 - for(RecipeIfsItem bomItem : inDatas) { + for(RecipeIfsItem recipeItem : inDatas) { //判断是否已经存在 - String tempLineItemNo = bomItem.getLineItemNo(); + String tempLineItemNo = recipeItem.getLineItemNo(); if(!itemMap.containsKey(tempLineItemNo)) { - throw new APException("不存在此bom组件信息!LineItemNo:"+tempLineItemNo); + throw new APException("不存在此Recipe组件信息!LineItemNo:"+tempLineItemNo); } } // 校验通过 循环调用新增的方法 - for(RecipeIfsItem bomItem : inDatas) { + for(RecipeIfsItem recipeItem : inDatas) { //设置版本的信息 - String key = bomItem.getLineItemNo(); + String key = recipeItem.getLineItemNo(); RecipeIfsItem oriItem = itemMap.get(key); - bomItem.setIfsRowId(oriItem.getIfsRowId()); - bomItem.setIfsRowVersion(oriItem.getIfsRowVersion()); + recipeItem.setIfsRowId(oriItem.getIfsRowId()); + recipeItem.setIfsRowVersion(oriItem.getIfsRowVersion()); //调用api - RecipeApi.removeRecipeItem(srv, bomItem); + RecipeApi.removeRecipeItem(srv, recipeItem); } returnMap.put("resultCode", "200"); returnMap.put("obj", JSON.toJSONString(inDatas)); @@ -618,7 +619,7 @@ public class RecipeServiceBean { returnMap.put("resultMsg", e.getMessage()); } //打印日志 - logger.info("Bom 明细集合删除开始:"+JSON.toJSONString(inDatas)); + logger.info("Recipe 明细集合删除开始:"+JSON.toJSONString(inDatas)); //返回结果集 return returnMap; } diff --git a/src/main/java/com/spring/ifs/bean/RecipeServiceBeanTest.java b/src/main/java/com/spring/ifs/bean/RecipeServiceBeanTest.java new file mode 100644 index 00000000..12b88b83 --- /dev/null +++ b/src/main/java/com/spring/ifs/bean/RecipeServiceBeanTest.java @@ -0,0 +1,684 @@ +package com.spring.ifs.bean; + +import com.alibaba.fastjson.JSON; +import com.spring.ifs.api.IfsServer; +import com.spring.ifs.api.RecipeApi; +import com.spring.modules.part.entity.APIEntity.RecipeIfsAlternative; +import com.spring.modules.part.entity.APIEntity.RecipeIfsHeader; +import com.spring.modules.part.entity.APIEntity.RecipeIfsItem; +import ifs.fnd.ap.APException; +import ifs.fnd.ap.Server; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** +* @description: 处理配方的 +* @author LR +* @date 2024/12/9 15:44 +* @version 1.0 +*/ +@Component +public class RecipeServiceBeanTest { + + @Autowired + private IfsServer ifsServer; + + private static final Logger logger = LoggerFactory.getLogger(RecipeServiceBeanTest.class); + + /** + * @description: 查询Recipe Header + * @author LR + * @date 2024/12/12 15:49 + * @version 1.0 + */ + public Map getRecipeHeader(RecipeIfsHeader inData) { + logger.info("Recipe查询参数:"+JSON.toJSONString(inData)); + //查询的参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); + //判断是否需要插入到ifs + if(RecipeMap == null || RecipeMap.size() == 0) { + throw new RuntimeException("Recipe不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(RecipeMap.get("IFSROWID")); + inData.setIfsRowVersion(RecipeMap.get("IFSROWVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe查询:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: Recipe Header新增 + * @author LR + * @date 2024/12/12 15:52 + * @version 1.0 + */ + public Map syncRecipeHeader(RecipeIfsHeader inData) { + logger.info("Recipe新增开始:"+JSON.toJSONString(inData)); + //查询的参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); + //判断是否需要插入到ifs + if(RecipeMap != null && RecipeMap.size() > 0) { + throw new APException("Recipe已存在!"); + } + + //调用api + Map resultMap = RecipeApi.insertRecipeHeader(srv, inData); + //设置版本的信息 + inData.setIfsRowId(resultMap.get("OBJID")); + inData.setIfsRowVersion(resultMap.get("OBJVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe新增结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: Recipe Header修改 + * @author LR + * @date 2024/12/12 15:55 + * @version 1.0 + */ + public Map modifyRecipeHeader(RecipeIfsHeader inData) { + logger.info("Recipe修改开始:"+JSON.toJSONString(inData)); + //查询的参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); + //判断是否需要插入到ifs + if(RecipeMap == null || RecipeMap.size() == 0) { + throw new APException("Recipe不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(RecipeMap.get("IFSROWID")); + inData.setIfsRowVersion(RecipeMap.get("IFSROWVERSION")); + Map resultMap = RecipeApi.modifyRecipeHeader(srv, inData); + //设置ifs 信息 + inData.setIfsRowVersion(resultMap.get("OBJVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe修改结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: Recipe Header删除 + * @author LR + * @date 2024/12/12 15:58 + * @version 1.0 + */ + public Map removeRecipeHeader(RecipeIfsHeader inData) { + logger.info("Recipe Header删除开始:"+JSON.toJSONString(inData)); + //查询的参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map RecipeMap = RecipeApi.getRecipeHeader(srv, contract, partNo, engChgLevel, bomType); + //判断是否需要插入到ifs + if(RecipeMap == null || RecipeMap.size() == 0) { + throw new APException("Recipe不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(RecipeMap.get("IFSROWID")); + inData.setIfsRowVersion(RecipeMap.get("IFSROWVERSION")); + RecipeApi.removeRecipeHeader(srv, inData); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe Header 删除结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: 查询Recipe Alternative + * @author LR + * @date 2024/12/12 16:59 + * @version 1.0 + */ + public Map getRecipeAlternative( RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 查询开始:"+JSON.toJSONString(inData)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null) { + throw new APException("Recipe Alternative 不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(alternativeMap.get("IFSROWID")); + inData.setIfsRowVersion(alternativeMap.get("IFSROWVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe Alternative 查询结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: 插入Recipe Alternative + * @author LR + * @date 2024/12/12 17:03 + * @version 1.0 + */ + public Map syncRecipeAlternative( RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 新增开始:"+JSON.toJSONString(inData)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap != null && alternativeMap.size() > 0) { + throw new APException("Recipe Alternative 已存在!"); + } + + //调用新增api + Map resultMap = RecipeApi.insertRecipeAlternative(srv, inData); + //设置ifs 信息 + inData.setIfsRowId(resultMap.get("OBJID")); + inData.setIfsRowVersion(resultMap.get("OBJVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(resultMap)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe Alternative 新增结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: 修改Recipe Alternative + * @author LR + * @date 2024/12/12 17:06 + * @version 1.0 + */ + public Map modifyRecipeAlternative( RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 修改开始:"+JSON.toJSONString(inData)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Recipe Alternative不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(alternativeMap.get("IFSROWID")); + inData.setIfsRowVersion(alternativeMap.get("IFSROWVERSION")); + inData.setStdSizeKg(inData.getStdSizeKg()); + //调用api + Map resultMap = RecipeApi.modifyRecipeAlternative(srv, inData); + //设置ifs 信息 + inData.setIfsRowVersion(resultMap.get("OBJVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe Alternative 修改结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: 删除Recipe Alternative + * @author LR + * @date 2024/12/12 17:07 + * @version 1.0 + */ + public Map removeRecipeAlternative( RecipeIfsAlternative inData) { + logger.info("Recipe Alternative 删除开始:"+JSON.toJSONString(inData)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Recipe Alternative不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(alternativeMap.get("IFSROWID")); + inData.setIfsRowVersion(alternativeMap.get("IFSROWVERSION")); + //调用api + RecipeApi.removeRecipeAlternative(srv, inData); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe Alternative 删除结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: Build Recipe Alternative + * @author LR + * @date 2024/12/13 9:37 + * @version 1.0 + */ + public Map buildRecipeAlternative( RecipeIfsAlternative inData) { + logger.info("Recipe替代Build开始:"+JSON.toJSONString(inData)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Recipe Alternative不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(alternativeMap.get("IFSROWID")); + inData.setIfsRowVersion(alternativeMap.get("IFSROWVERSION")); + //调用删除方法 + Map resultMap = RecipeApi.buildRecipeAlternative(srv, inData); + //设置ifs 信息 + inData.setIfsRowVersion(resultMap.get("OBJVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe替代Build结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: Retire Recipe Alternative + * @author LR + * @date 2024/12/13 9:40 + * @version 1.0 + */ + public Map retireRecipeAlternative( RecipeIfsAlternative inData) { + logger.info("Recipe替代retire开始:"+JSON.toJSONString(inData)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Recipe Alternative不存在!"); + } + //设置ifs 信息 + inData.setIfsRowId(alternativeMap.get("IFSROWID")); + inData.setIfsRowVersion(alternativeMap.get("IFSROWVERSION")); + //调用删除方法 + Map resultMap = RecipeApi.retireRecipeAlternative(srv, inData); + //设置ifs 信息 + inData.setIfsRowVersion(resultMap.get("IFSROWVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe替代retire开始:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: 获取Recipe 的明细 + * @author LR + * @date 2024/12/13 9:53 + * @version 1.0 + */ + public Map getRecipeItems(RecipeIfsItem inData) { + //公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + String lineItemNo = inData.getLineItemNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Recipe Alternative不存在!"); + } + //查询结果集 + List resultList = RecipeApi.getRecipeItems(srv, contract, partNo, engChgLevel, bomType, alternativeNo, lineItemNo); + //判断是否查询数据 + if(resultList == null ||resultList.size() == 0 || resultList.isEmpty()) { + throw new APException("不存在此查Recipe组件信息!"); + } + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(resultList)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe替代明细集合结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: 批量新增查Recipe Item + * @author LR + * @date 2024/12/12 17:23 + * @version 1.0 + */ + public Map syncRecipeItems(List inDatas) { + logger.info("Recipe替代明细集合新增开始:"+JSON.toJSONString(inDatas)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inDatas.get(0).getIfsUsername(); + String password = inDatas.get(0).getIfsPassword(); + String contract = inDatas.get(0).getContract(); + String partNo = inDatas.get(0).getPartNo(); + String engChgLevel = inDatas.get(0).getEngChgLevel(); + String bomType = inDatas.get(0).getBomType(); + String alternativeNo = inDatas.get(0).getAlternativeNo(); + String lineItemNo = inDatas.get(0).getLineItemNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Recipe Alternative不存在!"); + } + //查询结果集 + List itemList = RecipeApi.getRecipeItems(srv, contract, partNo, engChgLevel, bomType, alternativeNo, null); + //转Map + Map itemMap = itemList.stream().collect(Collectors.toMap(RecipeIfsItem::getLineItemNo, RecipeIfsItem::getLineItemNo)); + //打印日志 + logger.info("Recipe替代明细集合 批量新增结束:"+JSON.toJSONString(inDatas)); + //循环判断的方法 + for(RecipeIfsItem recipeItem : inDatas) { + //判断是否已经存在 + String tempLineItemNo = recipeItem.getLineItemNo(); + if(itemMap.containsKey(tempLineItemNo)) { + throw new APException("已存在此bom组件信息!LineItemNo:"+tempLineItemNo); + } + } + // 校验通过 循环调用新增的方法 + for(RecipeIfsItem recipeItem : inDatas) { + //调用api + Map tempMap = RecipeApi.insertRecipeItem(srv, recipeItem); + //设置ifs 信息 + recipeItem.setIfsRowId(tempMap.get("OBJID")); + recipeItem.setIfsRowVersion(tempMap.get("OBJVERSION")); + } + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inDatas)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe替代明细集合新增开始:"+JSON.toJSONString(inDatas)); + //返回结果集 + return returnMap; + } + + /** + * @description: 修改查Recipe的明细 + * @author LR + * @date 2024/12/13 10:24 + * @version 1.0 + */ + public Map modifyRecipeItem(RecipeIfsItem inData) { + logger.info("Recipe替代明细新增开始:"+JSON.toJSONString(inData)); + // 公共参数 + Map returnMap = new HashMap<>(); + String username = inData.getIfsUsername(); + String password = inData.getIfsPassword(); + String contract = inData.getContract(); + String partNo = inData.getPartNo(); + String engChgLevel = inData.getEngChgLevel(); + String bomType = inData.getBomType(); + String alternativeNo = inData.getAlternativeNo(); + String lineItemNo = inData.getLineItemNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + Map alternativeMap = RecipeApi.getRecipeAlternative(srv, contract, partNo, engChgLevel, bomType, alternativeNo); + //判断是否需要插入到ifs + if(alternativeMap == null || alternativeMap.size() == 0) { + throw new APException("Recipe Alternative不存在!"); + } + //查询结果集 + List resultList = RecipeApi.getRecipeItems(srv, contract, partNo, engChgLevel, bomType, alternativeNo, lineItemNo); + //判断是否查询数据 + if(resultList.size() == 0 || resultList.isEmpty()) { + throw new APException("不存在此Recipe组件信息!"); + } + + RecipeIfsItem recipeItem = resultList.get(0); + //设置版本信息 + inData.setIfsRowId(recipeItem.getIfsRowId()); + inData.setIfsRowVersion(recipeItem.getIfsRowVersion()); + //调用修改的方法 + Map resultMap = RecipeApi.modifyRecipeItem(srv, inData); + //设置ifs 信息 + recipeItem.setIfsRowId(resultMap.get("OBJID")); + recipeItem.setIfsRowVersion(resultMap.get("OBJVERSION")); + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inData)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe替代明细新增结束:"+JSON.toJSONString(inData)); + //返回结果集 + return returnMap; + } + + /** + * @description: 批量删除 + * @author LR + * @date 2024/12/13 10:26 + * @version 1.0 + */ + public Map removeRecipeItems(List inDatas) { + logger.info("Recipe 明细集合删除开始:"+JSON.toJSONString(inDatas)); + //公共参数 + Map returnMap = new HashMap<>(); + String username = inDatas.get(0).getIfsUsername(); + String password = inDatas.get(0).getIfsPassword(); + String contract = inDatas.get(0).getContract(); + String partNo = inDatas.get(0).getPartNo(); + String engChgLevel = inDatas.get(0).getEngChgLevel(); + String bomType = inDatas.get(0).getBomType(); + String alternativeNo = inDatas.get(0).getAlternativeNo(); + try{ + //获取连接 + Server srv = ifsServer.getIfsServer(username, password); + //查询数据 + List itemList = RecipeApi.getRecipeItems(srv, contract, partNo, engChgLevel, bomType, alternativeNo, null); + //转Map + Map itemMap = itemList.stream().collect(Collectors.toMap(RecipeIfsItem::getLineItemNo, Function.identity())); + //打印日志 + logger.info("Recipe替代明细集合 批量新增结束:"+JSON.toJSONString(inDatas)); + //循环判断的方法 + for(RecipeIfsItem recipeItem : inDatas) { + //判断是否已经存在 + String tempLineItemNo = recipeItem.getLineItemNo(); + if(!itemMap.containsKey(tempLineItemNo)) { + throw new APException("不存在此Recipe组件信息!LineItemNo:"+tempLineItemNo); + } + } + // 校验通过 循环调用新增的方法 + for(RecipeIfsItem recipeItem : inDatas) { + //设置版本的信息 + String key = recipeItem.getLineItemNo(); + RecipeIfsItem oriItem = itemMap.get(key); + recipeItem.setIfsRowId(oriItem.getIfsRowId()); + recipeItem.setIfsRowVersion(oriItem.getIfsRowVersion()); + //调用api + RecipeApi.removeRecipeItem(srv, recipeItem); + } + returnMap.put("resultCode", "200"); + returnMap.put("obj", JSON.toJSONString(inDatas)); + } catch(APException e){ + returnMap.put("resultCode", "400"); + returnMap.put("resultMsg", e.getMessage()); + } + //打印日志 + logger.info("Recipe 明细集合删除开始:"+JSON.toJSONString(inDatas)); + //返回结果集 + return returnMap; + } + +}