|
|
|
@ -2,9 +2,12 @@ package com.spring.ifs.utils; |
|
|
|
|
|
|
|
import com.spring.ifs.data.IfsParamBean; |
|
|
|
import ifs.fnd.ap.*; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@ -15,6 +18,7 @@ import java.util.Map; |
|
|
|
* @version 1.0 |
|
|
|
*/ |
|
|
|
public class IfsPlsqlUtils { |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(IfsPlsqlUtils.class); |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 调用查询的通用方法-- 返回单个Bean |
|
|
|
@ -73,6 +77,7 @@ public class IfsPlsqlUtils { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 执行存储过程 返回需要的数据 |
|
|
|
* @author LR |
|
|
|
@ -80,7 +85,7 @@ public class IfsPlsqlUtils { |
|
|
|
* @version 1.0 |
|
|
|
*/ |
|
|
|
public static Map<String, String> execProcedureGetRecord(Server srv, String packageName, String methodName, |
|
|
|
PlsqlBaseMethodType methodType, PlsqlBaseMethodAction methodAction, Map<String, String> inParam) throws APException { |
|
|
|
PlsqlBaseMethodType methodType, PlsqlBaseMethodAction methodAction, Map<String, String> inParam) throws APException { |
|
|
|
//创建查询体 |
|
|
|
Record profile = new Record("PROFILE"); |
|
|
|
//填充参数 |
|
|
|
@ -108,15 +113,95 @@ public class IfsPlsqlUtils { |
|
|
|
}catch(ManualDecisionException e){ |
|
|
|
//转换类型 |
|
|
|
resultMap = IfsConverterToMap.ConverterIfsToMap(profile); |
|
|
|
System.out.print(e.getMessage()); |
|
|
|
String warningInfo = e.getMessage(); |
|
|
|
logger.info("执行存储过程返回警告信息:" + warningInfo); |
|
|
|
//填充警告信息 |
|
|
|
resultMap.put("WARNING", e.getMessage()); |
|
|
|
resultMap.put("WARNING", warningInfo); |
|
|
|
} |
|
|
|
//返回结果集 |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 执行存储过程 返回需要的数据 |
|
|
|
* @author LR |
|
|
|
* @date 2024/12/9 16:17 |
|
|
|
* @version 1.0 |
|
|
|
*/ |
|
|
|
public static Map<String, String> execProcedureGetRecordWithDecisions(Server srv, String packageName, String methodName, |
|
|
|
PlsqlBaseMethodType methodType, PlsqlBaseMethodAction methodAction, Map<String, String> inParam) throws APException { |
|
|
|
//创建查询体 |
|
|
|
Record profile = new Record("PROFILE"); |
|
|
|
//填充参数 |
|
|
|
//循环设置入参 |
|
|
|
for(Map.Entry<String, String> entry : inParam.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
|
String value = entry.getValue(); |
|
|
|
//设置入参 |
|
|
|
profile.add(key, value); |
|
|
|
} |
|
|
|
//创建执行的框体 |
|
|
|
PlsqlBaseMethodCommand methodCommand = new PlsqlBaseMethodCommand( |
|
|
|
srv, |
|
|
|
methodType, |
|
|
|
packageName, |
|
|
|
methodName, |
|
|
|
profile, |
|
|
|
methodAction); |
|
|
|
//转换类型 |
|
|
|
Map<String, String> resultMap = null; |
|
|
|
//执行 |
|
|
|
try{ |
|
|
|
methodCommand.execute(); |
|
|
|
srv.setDecisions(null); |
|
|
|
resultMap = IfsConverterToMap.ConverterIfsToMap(profile); |
|
|
|
}catch(ManualDecisionException e){ |
|
|
|
//转换类型 |
|
|
|
//logger.info("执行存储过程返回警告信息:" + e.getMessage()); |
|
|
|
//填充警告信息 |
|
|
|
resultMap = new HashMap<>(); |
|
|
|
resultMap.put("WARNING", ""); |
|
|
|
ManualDecisionCollection decisions = e.getDecisions(); |
|
|
|
acceptAllDecisions(decisions); |
|
|
|
srv.setDecisions(decisions); |
|
|
|
} |
|
|
|
//返回结果集 |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 自动应答 IFS 返回的全部 ManualDecision 警告。 |
|
|
|
* 遍历 {@link ManualDecisionCollection},对未应答的决策调用 {@link ManualDecision#setAnswer}. |
|
|
|
*/ |
|
|
|
private static void acceptAllDecisions(ManualDecisionCollection decisions) { |
|
|
|
Iterator<ManualDecision> iterator = decisions.iterator(); |
|
|
|
while (iterator.hasNext()) { |
|
|
|
ManualDecision decision = iterator.next(); |
|
|
|
if (decision.isAnswered()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
decision.setAnswer(resolveDecisionAnswer(decision)); |
|
|
|
logger.info("应答IFS警告: {}", decision.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据决策类型选择应答值:CONTINUE 类型用 CONTINUE,其余默认 YES。 |
|
|
|
*/ |
|
|
|
private static ManualDecisionAnswer resolveDecisionAnswer(ManualDecision decision) { |
|
|
|
ManualDecisionAnswer defaultAnswer = decision.getDefaultAnswer(); |
|
|
|
if (defaultAnswer != null |
|
|
|
&& defaultAnswer != ManualDecisionAnswer.NO_ANSWER |
|
|
|
&& defaultAnswer != ManualDecisionAnswer.CANCEL) { |
|
|
|
return defaultAnswer; |
|
|
|
} |
|
|
|
if (decision.getQuestionType() == ManualDecisionQuestionType.CONTINUE) { |
|
|
|
return ManualDecisionAnswer.CONTINUE; |
|
|
|
} |
|
|
|
return ManualDecisionAnswer.YES; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 执行存储过程 返回需要的数据 |
|
|
|
* @author LR |
|
|
|
@ -165,14 +250,14 @@ public class IfsPlsqlUtils { |
|
|
|
//返回结果集 |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @Title: execProcedureGetRecord |
|
|
|
* |
|
|
|
* @Title: execProcedureGetRecord |
|
|
|
* @Description: 调用特殊的存储过程 出参和入参严格规范后的数据 入参和出参 不重复的数据 |
|
|
|
* @author: LR |
|
|
|
* @date 2024年12月10日 下午3:54:22 |
|
|
|
* @return: Map<String,String> |
|
|
|
* @date 2024年12月10日 下午3:54:22 |
|
|
|
* @return: Map<String,String> |
|
|
|
* @throws |
|
|
|
*/ |
|
|
|
public static Map<String, String> execProcedureGetRecord(Server srv, String packageName, String methodName, |
|
|
|
@ -194,7 +279,7 @@ public class IfsPlsqlUtils { |
|
|
|
searchSql.append(", "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
//然后填充入参 |
|
|
|
for(int i = 0; i < inParams.size(); i++) { |
|
|
|
@ -204,7 +289,7 @@ public class IfsPlsqlUtils { |
|
|
|
if(i < inParams.size() - 1) { |
|
|
|
searchSql.append(", "); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
//拼接最终的sql |
|
|
|
searchSql.append("); END;"); |
|
|
|
@ -228,13 +313,9 @@ public class IfsPlsqlUtils { |
|
|
|
String columnValue = bindVars.find(param.getColumnName()).getString(); |
|
|
|
resultMap.put(columnName, columnValue); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//返回结果集 |
|
|
|
return resultMap; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |