diff --git a/src/main/java/cn/lihongjie/coal/base/dto/TreeDto.java b/src/main/java/cn/lihongjie/coal/base/dto/TreeDto.java index 21fc35b2..df4b4b2f 100644 --- a/src/main/java/cn/lihongjie/coal/base/dto/TreeDto.java +++ b/src/main/java/cn/lihongjie/coal/base/dto/TreeDto.java @@ -11,7 +11,6 @@ import lombok.Data; import lombok.NoArgsConstructor; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Stream; @@ -91,7 +90,11 @@ public class TreeDto { private static List getChildren(Object x) { if (x instanceof TreeDto) { - return ((TreeDto) x).getChildren().stream().map(TreeDto::buildTree).toList(); + List list = ((TreeDto) x).getChildren(); + if (list == null){ + return new ArrayList<>(); + } + return list.stream().map(TreeDto::buildTree).toList(); } Object c = ReflectUtils.getFieldValue(x, "children"); diff --git a/src/main/java/cn/lihongjie/coal/dictionary/service/DictionaryService.java b/src/main/java/cn/lihongjie/coal/dictionary/service/DictionaryService.java index a3b6c54a..4909effa 100644 --- a/src/main/java/cn/lihongjie/coal/dictionary/service/DictionaryService.java +++ b/src/main/java/cn/lihongjie/coal/dictionary/service/DictionaryService.java @@ -224,27 +224,34 @@ class DictionaryService extends BaseService { } + @Autowired + ObjectMapper objectMapper; + @SneakyThrows public ScriptExecResultDto exec(ScriptExecResultDto json) throws ScriptException { @@ -228,7 +234,7 @@ class ScriptService extends BaseService { } }); - script.setProperty("params", json.getParams()); + script.setProperty("params", ObjectUtils.defaultIfNull(json.getParams(), objectMapper.createObjectNode())); script.setProperty("ioc", applicationContext); long start = System.currentTimeMillis(); diff --git a/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisAC.groovy b/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisAC.groovy index e7115317..887afc43 100644 --- a/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisAC.groovy +++ b/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisAC.groovy @@ -1,5 +1,6 @@ package scripts.dict +import cn.lihongjie.coal.common.Ctx import cn.lihongjie.coal.dictionary.dto.AutoCompleteRequest import cn.lihongjie.coal.dictionary.service.DictionaryService import org.springframework.context.ApplicationContext @@ -11,5 +12,5 @@ def service = ioc.getBean(DictionaryService.class) -return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis", fieldName: "name", query: params.get("query").asText())) +return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis", fieldName: "name", organizationId: Ctx.currentUser().organizationId,query: params.get("query")?.asText())) diff --git a/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFAC.groovy b/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFAC.groovy index 3fcf9977..16ed9213 100644 --- a/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFAC.groovy +++ b/src/main/resources/scripts/dict/enum/coalWashingDailyAnalysisKFAC.groovy @@ -1,5 +1,6 @@ package scripts.dict +import cn.lihongjie.coal.common.Ctx import cn.lihongjie.coal.dictionary.dto.AutoCompleteRequest import cn.lihongjie.coal.dictionary.service.DictionaryService import org.springframework.context.ApplicationContext @@ -11,5 +12,5 @@ def service = ioc.getBean(DictionaryService.class) -return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis_kf_items", fieldName: "name", query: params.get("query").asText())) +return service.autoComplete(new AutoCompleteRequest(tableName: "t_coal_washing_daily_analysis_kf_items kf inner join t_coal_washing_daily_analysis a on kf.coal_washing_daily_analysis_id = a.id", fieldName: "kf.name",organizationId: Ctx.currentUser().organizationId, query: params.get("query")?.asText()))