From 6e6d6e62890e795adf318d278f40960c0da010a8 Mon Sep 17 00:00:00 2001 From: DouDou <877258667@qq.com> Date: Wed, 10 Sep 2025 09:23:42 +0800 Subject: [PATCH] =?UTF-8?q?BOM=20Alternative=20retire=20master=20part=20in?= =?UTF-8?q?sert=20=E9=BB=98=E8=AE=A4=E8=AD=A6=E5=91=8A=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/spring/ifs/api/BomApi.java | 159 +++++++++++++++++- .../com/spring/ifs/api/MasterPartApi.java | 19 ++- .../com/spring/ifs/utils/IfsPlsqlUtils.java | 16 +- 3 files changed, 187 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/spring/ifs/api/BomApi.java b/src/main/java/com/spring/ifs/api/BomApi.java index cde06220..c7e35a99 100644 --- a/src/main/java/com/spring/ifs/api/BomApi.java +++ b/src/main/java/com/spring/ifs/api/BomApi.java @@ -1,5 +1,6 @@ package com.spring.ifs.api; +import com.alibaba.fastjson.JSONArray; import com.spring.ifs.data.*; import com.spring.ifs.utils.IfsConverterToMap; import com.spring.ifs.utils.IfsPlsqlUtils; @@ -9,6 +10,8 @@ import com.spring.modules.part.entity.APIEntity.BomIfsHeader; import com.spring.modules.part.entity.APIEntity.BomIfsItem; import com.spring.modules.part.entity.APIEntity.BomIfsManufStructCostDistrib; import ifs.fnd.ap.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.math.BigDecimal; import java.util.*; @@ -21,6 +24,8 @@ import java.util.*; */ public class BomApi { + private static Logger logger = LoggerFactory.getLogger(BomApi.class); + /** * @description: 查询Bom Header * @author LR @@ -278,6 +283,13 @@ public class BomApi { //执行check的操作 Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PROD_STRUCT_ALTERNATE_API", "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.CHECK, inParam); + //警告信息 + String warning = checkMap.get("WARNING"); + //如果存在警告信息 需要写入入参 + if (!(null == warning || "".equals(warning))){ + logger.info("警告信息:"+warning); + inParam.put("WARNING", warning); + } //执行do的操作 Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PROD_STRUCT_ALTERNATE_API", "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.DO, inParam); @@ -380,10 +392,24 @@ public class BomApi { //填充参数 inParam.put("OBJID", ifsRowId); inParam.put("OBJVERSION", ifsRowVersion); - + logger.info("retireBomAlternative 入参信息: "+ JSONArray.toJSONString(inParam)); //执行check的操作 Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PROD_STRUCT_ALTERNATE_API", "RETIRE__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.CHECK, inParam); + //警告信息 + logger.info("retireBomAlternative 返回信息: "+ JSONArray.toJSONString(checkMap)); + String warning = checkMap.get("WARNING"); + String info = checkMap.get("INFO"); + //如果存在警告信息 需要写入入参 + if (!(null == warning || "".equals(warning))){ + logger.info("警告信息:"+warning); + inParam.put("WARNING", warning); + } + //如果存在信息 需要写入入参 + if (!(null == info || "".equals(info))){ + logger.info("信息:"+info); + inParam.put("INFO", info); + } //执行do的操作 Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PROD_STRUCT_ALTERNATE_API", "RETIRE__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.DO, inParam); @@ -887,4 +913,135 @@ public class BomApi { return resultMap; } + /** + * 使用原生PlsqlBaseMethodCommand模式的RETIRE CHECK示例 + * 重点:抓取CHECK返回的警告信息 + * @description: 基于IFS原生demo的retire Bom Alternative CHECK + * @author Demo + * @date 2024/12/20 + * @version 1.0 + */ + public static Map retireBomAlternativeNativeCheck(Server srv, BomIfsAlternative inData) throws APException { + //公共参数 + String ifsRowId = inData.getIfsRowId(); + String ifsRowVersion = inData.getIfsRowVersion(); + + logger.info("=== 使用原生模式执行RETIRE CHECK ==="); + logger.info("输入参数 - OBJID: {}, OBJVERSION: {}", ifsRowId, ifsRowVersion); + + // 创建Profile,按照原生demo的模式 + Record profile = new Record("PROFILE"); + profile.add("OBJID", ifsRowId); + profile.add("OBJVERSION", ifsRowVersion); + + // 添加可能的返回信息字段,用于接收CHECK返回的值 + profile.add("WARNING", ""); // 用于接收警告信息 + profile.add("INFO", ""); // 用于接收信息 + profile.add("ERROR_SYS", ""); // 用于接收系统错误 + profile.add("ATTR", ""); // 用于接收属性信息 + + // 创建CHECK命令 + PlsqlBaseMethodCommand checkCmd = new PlsqlBaseMethodCommand( + srv, + PlsqlBaseMethodType.MODIFY, // 方法类型 + "PROD_STRUCT_ALTERNATE_API", // API包名 + "RETIRE__", // 方法名 + profile, // 参数Profile + PlsqlBaseMethodAction.CHECK // CHECK操作 + ); + + Map resultMap = new HashMap<>(); + + try { + // 执行CHECK + checkCmd.execute(); + + logger.info("CHECK执行成功,开始抓取返回信息..."); + + // 检查并抓取返回的信息(按照原生demo的模式) + + // 检查WARNING信息 + RecordAttribute warning = profile.find("WARNING"); + if(warning != null && warning.hasValue()) { + String warningValue = (String)warning.getValue(); + logger.info("WARNING returned by CHECK: {}", warningValue); + resultMap.put("WARNING", warningValue); + } else { + logger.info("WARNING returned by CHECK: null"); + resultMap.put("WARNING", ""); + } + + // 检查INFO信息 + RecordAttribute info = profile.find("INFO"); + if(info != null && info.hasValue()) { + String infoValue = (String)info.getValue(); + logger.info("INFO returned by CHECK: {}", infoValue); + resultMap.put("INFO", infoValue); + } else { + logger.info("INFO returned by CHECK: null"); + resultMap.put("INFO", ""); + } + + // 检查ERROR_SYS信息 + RecordAttribute errorSys = profile.find("ERROR_SYS"); + if(errorSys != null && errorSys.hasValue()) { + String errorValue = (String)errorSys.getValue(); + logger.info("ERROR_SYS returned by CHECK: {}", errorValue); + resultMap.put("ERROR_SYS", errorValue); + } else { + logger.info("ERROR_SYS returned by CHECK: null"); + resultMap.put("ERROR_SYS", ""); + } + + // 检查ATTR信息 + RecordAttribute attr = profile.find("ATTR"); + if(attr != null && attr.hasValue()) { + String attrValue = (String)attr.getValue(); + logger.info("ATTR returned by CHECK: {}", attrValue); + resultMap.put("ATTR", attrValue); + } else { + logger.info("ATTR returned by CHECK: null"); + resultMap.put("ATTR", ""); + } + + // 检查OBJID和OBJVERSION是否有变化 + RecordAttribute objIdAttr = profile.find("OBJID"); + if(objIdAttr != null && objIdAttr.hasValue()) { + String objIdValue = (String)objIdAttr.getValue(); + logger.info("OBJID after CHECK: {}", objIdValue); + resultMap.put("OBJID", objIdValue); + } + + RecordAttribute objVersionAttr = profile.find("OBJVERSION"); + if(objVersionAttr != null && objVersionAttr.hasValue()) { + String objVersionValue = (String)objVersionAttr.getValue(); + logger.info("OBJVERSION after CHECK: {}", objVersionValue); + resultMap.put("OBJVERSION", objVersionValue); + } + + logger.info("CHECK操作完成,返回信息: {}", resultMap); + + } catch (APException e) { + // 按照您的需求,CHECK阶段可能会抛出需要用户确认的异常 + logger.warn("CHECK操作抛出异常(可能需要用户确认): {}", e.getMessage()); + + // 异常情况下也要返回信息,将异常信息作为WARNING处理 + resultMap.put("EXCEPTION", e.getMessage()); + resultMap.put("WARNING", e.getMessage()); + resultMap.put("OBJID", ifsRowId); + resultMap.put("OBJVERSION", ifsRowVersion); + resultMap.put("INFO", ""); + resultMap.put("ERROR_SYS", ""); + resultMap.put("ATTR", ""); + } + + return resultMap; + } + + + + + + + } diff --git a/src/main/java/com/spring/ifs/api/MasterPartApi.java b/src/main/java/com/spring/ifs/api/MasterPartApi.java index 570d312c..a0280298 100644 --- a/src/main/java/com/spring/ifs/api/MasterPartApi.java +++ b/src/main/java/com/spring/ifs/api/MasterPartApi.java @@ -4,6 +4,8 @@ import com.spring.ifs.utils.IfsConverterToMap; import com.spring.ifs.utils.IfsPlsqlUtils; import com.spring.modules.part.entity.APIEntity.PartIfsCatalog; import ifs.fnd.ap.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.Map; @@ -16,6 +18,8 @@ import java.util.Map; */ public class MasterPartApi { + private static Logger logger = LoggerFactory.getLogger(MasterPartApi.class); + /** * @description: 获取Master part的相关信息 * @author LR @@ -102,6 +106,12 @@ public class MasterPartApi { //执行check的操作 Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PART_CATALOG_API", "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.CHECK, inParam); + String warning = checkMap.get("WARNING"); + //如果存在警告信息 需要写入入参 + if (!(null == warning || "".equals(warning))){ + logger.info("警告信息:"+warning); + inParam.put("WARNING", warning); + } //执行do的操作 Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PART_CATALOG_API", "NEW__", PlsqlBaseMethodType.NEW, PlsqlBaseMethodAction.DO, inParam); @@ -158,9 +168,12 @@ public class MasterPartApi { //执行check的操作 Map checkMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PART_CATALOG_API", "MODIFY__", PlsqlBaseMethodType.MODIFY, PlsqlBaseMethodAction.CHECK, inParam); - //检查是否需要填充checkMap的信息 - if (checkMap.get("WARNING") != null) { - inParam.put("WARNING", checkMap.get("WARNING")); + //警告信息 + String warning = checkMap.get("WARNING"); + //如果存在警告信息 需要写入入参 + if (!(null == warning || "".equals(warning))){ + logger.info("警告信息:"+warning); + inParam.put("WARNING", warning); } //执行do的操作 Map resultMap = IfsPlsqlUtils.execProcedureGetRecord(srv, "PART_CATALOG_API", diff --git a/src/main/java/com/spring/ifs/utils/IfsPlsqlUtils.java b/src/main/java/com/spring/ifs/utils/IfsPlsqlUtils.java index 88a9d369..ff6e0d34 100644 --- a/src/main/java/com/spring/ifs/utils/IfsPlsqlUtils.java +++ b/src/main/java/com/spring/ifs/utils/IfsPlsqlUtils.java @@ -99,10 +99,20 @@ public class IfsPlsqlUtils { methodName, profile, methodAction); - //执行 - methodCommand.execute(); //转换类型 - Map resultMap = IfsConverterToMap.ConverterIfsToMap(profile); + Map resultMap = null; + //执行 + try{ + methodCommand.execute(); + resultMap = IfsConverterToMap.ConverterIfsToMap(profile); + }catch(ManualDecisionException e){ + //转换类型 + resultMap = IfsConverterToMap.ConverterIfsToMap(profile); + System.out.print(e.getMessage()); + //填充警告信息 + resultMap.put("WARNING", e.getMessage()); + } + //返回结果集 return resultMap; }