Commit 37c6147d8351388d547e333a66d610b9e272c27c
1 parent
686f9562
添加未清选择 改成动态引导语
Showing
1 changed file
with
69 additions
and
67 deletions
src/main/java/com/xly/tool/DynamicToolProvider.java
| ... | ... | @@ -1006,74 +1006,76 @@ public class DynamicToolProvider implements ToolProvider { |
| 1006 | 1006 | Map<String, Object> result = new HashMap<>(args); |
| 1007 | 1007 | result = transformationArgs( result, paramDefsCheck); |
| 1008 | 1008 | List<ParamRule> paramDefs = new ArrayList<>(paramDefsCheck); |
| 1009 | + paramDefs = paramDefs.stream().filter(one-> !one.getBDynamicParam()).collect(Collectors.toList()); | |
| 1009 | 1010 | paramDefs.sort(Comparator.comparing(ParamRule::getIOrder)); |
| 1010 | -// for (ParamRule pd : paramDefs) { | |
| 1011 | -// String name = pd.getSParam(); | |
| 1012 | -// String sValue = pd.getSParamValue(); | |
| 1013 | -// String sRule = pd.getSRule(); | |
| 1014 | -// String sType = pd.getSType(); | |
| 1015 | -// | |
| 1016 | -// Boolean bCheck = result.containsKey(name); | |
| 1017 | -// bCheck = bCheck && ObjectUtil.isNotEmpty(result.get(name)); | |
| 1018 | -// bCheck = bCheck && RuleCode.SQL.getCode().equals(sRule); | |
| 1019 | -// bCheck = bCheck && ObjectUtil.isNotEmpty(pd.getSParamConfig()); | |
| 1020 | -// | |
| 1021 | -// Boolean bCheck2 = result.containsKey(sValue); | |
| 1022 | -// bCheck2 = bCheck2 && ObjectUtil.isNotEmpty(result.get(sValue)); | |
| 1023 | -// bCheck2 = bCheck2 && RuleCode.SQL.getCode().equals(sRule); | |
| 1024 | -// bCheck2 = bCheck2 && ObjectUtil.isNotEmpty(pd.getSParamConfig()); | |
| 1025 | -// | |
| 1026 | -// if ((bCheck || bCheck2) &&("enum".equals(sType) || "string".equals(sType))){ | |
| 1027 | -// String sSql = pd.getSParamConfig(); | |
| 1028 | -// String sKey = bCheck?name:sValue; | |
| 1029 | -// String nameValue = result.get(sKey).toString(); | |
| 1030 | -// List<Map<String,Object>> dataList = dynamicExeDbService.findSql(result,sSql); | |
| 1031 | -// if(ObjectUtil.isEmpty(dataList)){ | |
| 1032 | -// throw new BusinessException(ErrorCode.PARAM_REQUIRED,String.format("%s 您描述的%s 不存在,请重新告诉我",name,nameValue)); | |
| 1033 | -// } | |
| 1034 | -// if(ObjectUtil.isNotEmpty(args.get(name)) || ObjectUtil.isNotEmpty(args.get(sValue))){ | |
| 1035 | -// if(("enum".equals(sType) ||"string".equals(sType)) && (args.get(name) instanceof List || args.get(sValue) instanceof List)){ | |
| 1036 | -// if(args.get(name) instanceof List){ | |
| 1037 | -// args.put(name,((List<?>) args.get(name)).get(0)); | |
| 1038 | -// } | |
| 1039 | -// if(args.get(sValue) instanceof List){ | |
| 1040 | -// args.put(sValue,((List<?>) args.get(sValue)).get(0)); | |
| 1041 | -// } | |
| 1042 | -// } | |
| 1043 | -// List<Map<String,Object>> dataListNew = dataList.stream().filter(one-> | |
| 1044 | -// ObjectUtil.isNotEmpty(one.get(sValue)) | |
| 1045 | -// &&(one.get(sValue).equals(args.get(name)) | |
| 1046 | -// || one.get(sValue).equals(args.get(sValue)))).collect(Collectors.toUnmodifiableList()); | |
| 1047 | -//// if("enum".equals(sType) && ObjectUtil.isEmpty(dataListNew)){ | |
| 1048 | -//// args.remove(name); | |
| 1049 | -//// args.remove(sValue); | |
| 1050 | -//// result.remove(name); | |
| 1051 | -//// result.remove(sValue); | |
| 1052 | -//// continue; | |
| 1053 | -//// } | |
| 1054 | -// if(ObjectUtil.isNotEmpty(dataListNew)){ | |
| 1055 | -// dataList = new ArrayList<>(); | |
| 1056 | -// dataList.add(dataListNew.get(0)); | |
| 1057 | -// } | |
| 1058 | -// } | |
| 1059 | -// if(ObjectUtil.isNotEmpty(dataList)){ | |
| 1060 | -// String sCopyTo = pd.getSCopyTo(); | |
| 1061 | -// if(ObjectUtil.isEmpty(sCopyTo)){ | |
| 1062 | -// result.put(sValue, dataList.get(0).get(sValue)); | |
| 1063 | -// result.put(name, dataList.get(0).get(sValue)); | |
| 1064 | -// }else{ | |
| 1065 | -// String[] sCopyToA = sCopyTo.split(","); | |
| 1066 | -// for(String sCopyToOne:sCopyToA){ | |
| 1067 | -// String[] sCopyToOneA = sCopyToOne.split(":"); | |
| 1068 | -// result.put(sCopyToOneA[0], dataList.get(0).get(sCopyToOneA[1])); | |
| 1069 | -// result.put(name, dataList.get(0).get(sValue)); | |
| 1070 | -// } | |
| 1011 | + | |
| 1012 | + for (ParamRule pd : paramDefs) { | |
| 1013 | + String name = pd.getSParam(); | |
| 1014 | + String sValue = pd.getSParamValue(); | |
| 1015 | + String sRule = pd.getSRule(); | |
| 1016 | + String sType = pd.getSType(); | |
| 1017 | + | |
| 1018 | + Boolean bCheck = result.containsKey(name); | |
| 1019 | + bCheck = bCheck && ObjectUtil.isNotEmpty(result.get(name)); | |
| 1020 | + bCheck = bCheck && RuleCode.SQL.getCode().equals(sRule); | |
| 1021 | + bCheck = bCheck && ObjectUtil.isNotEmpty(pd.getSParamConfig()); | |
| 1022 | + | |
| 1023 | + Boolean bCheck2 = result.containsKey(sValue); | |
| 1024 | + bCheck2 = bCheck2 && ObjectUtil.isNotEmpty(result.get(sValue)); | |
| 1025 | + bCheck2 = bCheck2 && RuleCode.SQL.getCode().equals(sRule); | |
| 1026 | + bCheck2 = bCheck2 && ObjectUtil.isNotEmpty(pd.getSParamConfig()); | |
| 1027 | + | |
| 1028 | + if ((bCheck || bCheck2) &&("enum".equals(sType) || "string".equals(sType))){ | |
| 1029 | + String sSql = pd.getSParamConfig(); | |
| 1030 | + String sKey = bCheck?name:sValue; | |
| 1031 | + String nameValue = result.get(sKey).toString(); | |
| 1032 | + List<Map<String,Object>> dataList = dynamicExeDbService.findSql(result,sSql); | |
| 1033 | + if(ObjectUtil.isEmpty(dataList)){ | |
| 1034 | + throw new BusinessException(ErrorCode.PARAM_REQUIRED,String.format("%s 您描述的%s 不存在,请重新告诉我",name,nameValue)); | |
| 1035 | + } | |
| 1036 | + if(ObjectUtil.isNotEmpty(args.get(name)) || ObjectUtil.isNotEmpty(args.get(sValue))){ | |
| 1037 | + if(("enum".equals(sType) ||"string".equals(sType)) && (args.get(name) instanceof List || args.get(sValue) instanceof List)){ | |
| 1038 | + if(args.get(name) instanceof List){ | |
| 1039 | + args.put(name,((List<?>) args.get(name)).get(0)); | |
| 1040 | + } | |
| 1041 | + if(args.get(sValue) instanceof List){ | |
| 1042 | + args.put(sValue,((List<?>) args.get(sValue)).get(0)); | |
| 1043 | + } | |
| 1044 | + } | |
| 1045 | + List<Map<String,Object>> dataListNew = dataList.stream().filter(one-> | |
| 1046 | + ObjectUtil.isNotEmpty(one.get(sValue)) | |
| 1047 | + &&(one.get(sValue).equals(args.get(name)) | |
| 1048 | + || one.get(sValue).equals(args.get(sValue)))).collect(Collectors.toUnmodifiableList()); | |
| 1049 | +// if("enum".equals(sType) && ObjectUtil.isEmpty(dataListNew)){ | |
| 1050 | +// args.remove(name); | |
| 1051 | +// args.remove(sValue); | |
| 1052 | +// result.remove(name); | |
| 1053 | +// result.remove(sValue); | |
| 1054 | +// continue; | |
| 1071 | 1055 | // } |
| 1072 | -// } | |
| 1073 | -// } | |
| 1074 | -// | |
| 1075 | -// | |
| 1076 | -// } | |
| 1056 | + if(ObjectUtil.isNotEmpty(dataListNew)){ | |
| 1057 | + dataList = new ArrayList<>(); | |
| 1058 | + dataList.add(dataListNew.get(0)); | |
| 1059 | + } | |
| 1060 | + } | |
| 1061 | + if(ObjectUtil.isNotEmpty(dataList)){ | |
| 1062 | + String sCopyTo = pd.getSCopyTo(); | |
| 1063 | + if(ObjectUtil.isEmpty(sCopyTo)){ | |
| 1064 | + result.put(sValue, dataList.get(0).get(sValue)); | |
| 1065 | + result.put(name, dataList.get(0).get(sValue)); | |
| 1066 | + }else{ | |
| 1067 | + String[] sCopyToA = sCopyTo.split(","); | |
| 1068 | + for(String sCopyToOne:sCopyToA){ | |
| 1069 | + String[] sCopyToOneA = sCopyToOne.split(":"); | |
| 1070 | + result.put(sCopyToOneA[0], dataList.get(0).get(sCopyToOneA[1])); | |
| 1071 | + result.put(name, dataList.get(0).get(sValue)); | |
| 1072 | + } | |
| 1073 | + } | |
| 1074 | + } | |
| 1075 | + } | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + } | |
| 1077 | 1079 | return result; |
| 1078 | 1080 | } |
| 1079 | 1081 | |
| ... | ... | @@ -1081,7 +1083,7 @@ public class DynamicToolProvider implements ToolProvider { |
| 1081 | 1083 | Map<String, Object> result = new HashMap<>(args); |
| 1082 | 1084 | for (ParamRule pd : paramDefs) { |
| 1083 | 1085 | String name = pd.getSParam(); |
| 1084 | - if ((!result.containsKey(name)|| ObjectUtil.isEmpty(result.get(name))) | |
| 1086 | + if ((!result.containsKey(name) || ObjectUtil.isEmpty(result.get(name))) | |
| 1085 | 1087 | && ObjectUtil.isNotEmpty(pd.getSDefaultValue()) |
| 1086 | 1088 | ) { |
| 1087 | 1089 | Object defaultValue = pd.getSDefaultValue(); | ... | ... |