|
|
@@ -368,7 +368,12 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
Object optionValue = optionalValues.get(0);
|
|
|
optionalValues = getValue(jdbc, String.valueOf(optionValue));
|
|
|
parameter.setOptionalValues(optionalValues);
|
|
|
- if (parameter.getValue() == null) {
|
|
|
+ if (CollectionUtils.isEmpty(optionalValues)) {
|
|
|
+ parameter.setValue(null);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 如果之前没有值,或者之前的值不是可选值的一项,取第一个可选值
|
|
|
+ if (parameter.getValue() == null || !optionalValues.contains(parameter.getValue())) {
|
|
|
parameter.setValue(CollectionUtils.isEmpty(optionalValues) ? null : optionalValues.get(0));
|
|
|
}
|
|
|
}
|
|
|
@@ -466,10 +471,22 @@ public class PanelInstanceServiceImpl extends BaseService<PanelInstance> impleme
|
|
|
}
|
|
|
for (Parameter parameter : parameters) {
|
|
|
for (Parameter oldParameter : oldParameters) {
|
|
|
- // 如果参数版本一致(参数未修改过),恢复之前的参数值
|
|
|
- if (Objects.equals(parameter.codeNotEmpty(), oldParameter.codeNotEmpty())
|
|
|
- && Objects.equals(parameter.getVersion(), oldParameter.getVersion())) {
|
|
|
- parameter.setValue(oldParameter.getValue());
|
|
|
+ if (Objects.equals(parameter.codeNotEmpty(), oldParameter.codeNotEmpty())) {
|
|
|
+ Object oldValue = oldParameter.getValue();
|
|
|
+ if (oldValue == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 如果参数版本一致(参数未修改过),或者参数为 SQL 类型(之后解析参数时再进行比较),则恢复之前的参数值
|
|
|
+ if (Objects.equals(parameter.getVersion(), oldParameter.getVersion()) ||
|
|
|
+ parameter.getType() == Type.SQL) {
|
|
|
+ parameter.setValue(oldValue);
|
|
|
+ } else {
|
|
|
+ // 或者版本不一致,但是之前的参数值仍是当前可选值中的一项,则恢复之前的参数值
|
|
|
+ List<Object> optionalValues = parameter.getOptionalValues();
|
|
|
+ if (!CollectionUtils.isEmpty(optionalValues) && optionalValues.contains(oldValue)) {
|
|
|
+ parameter.setValue(oldValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|