From 73b3a394952353c318a8712d2cc1efec03dc009d Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 10 四月 2025 16:40:14 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java index bf9930d..6823247 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.iail.model.IAILModel; -import com.iailab.module.model.common.enums.CommonConstant; +import com.iailab.module.model.enums.CommonConstant; import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; import com.iailab.module.model.mcs.sche.entity.StScheduleModelSettingEntity; import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity; @@ -52,7 +52,8 @@ private SampleConstructor sampleConstructor; @Override - public ScheduleResultVO doSchedule(String schemeCode, Date scheduleTime, Map<Integer, Integer> dynamicDataLength) throws ModelInvokeException { + public ScheduleResultVO doSchedule(String schemeCode, Date scheduleTime, Map<Integer, Integer> dynamicDataLength, + Map<String, String> dynamicSettings) throws ModelInvokeException { ScheduleResultVO scheduleResult = new ScheduleResultVO(); StScheduleSchemeEntity scheduleScheme = stScheduleSchemeService.getByCode(schemeCode); StScheduleModelEntity scheduleModel = stScheduleModelService.get(scheduleScheme.getModelId()); @@ -73,7 +74,7 @@ } IAILModel newModelBean = composeNewModelBean(scheduleModel); - HashMap<String, Object> settings = getScheduleSettingsByModelId(modelId); + HashMap<String, Object> settings = getScheduleSettingsByModelId(modelId, dynamicSettings); if (settings == null) { log.error("模型setting不存在,modelId=" + modelId); return null; @@ -94,11 +95,22 @@ log.info("参数: " + JSON.toJSONString(param2Values)); //IAILMDK.run HashMap<String, Object> modelResult = DllUtils.run(newModelBean, param2Values, scheduleScheme.getMpkprojectid()); + HashMap<String, Object> result = new HashMap<>(); + if (modelResult == null) { + //返回调度结果 + scheduleResult.setResultCode("null"); + scheduleResult.setResult(result); + scheduleResult.setModelId(modelId); + scheduleResult.setSchemeId(scheduleScheme.getId()); + scheduleResult.setScheduleTime(scheduleTime); + return scheduleResult; + } + if (!modelResult.containsKey(CommonConstant.MDK_STATUS_CODE) || !modelResult.containsKey(CommonConstant.MDK_RESULT)) { log.info("模型结果异常:" + modelResult); } String statusCode = modelResult.get(CommonConstant.MDK_STATUS_CODE).toString(); - HashMap<String, Object> result = new HashMap<>(); + if (modelResult.containsKey(CommonConstant.MDK_RESULT) && modelResult.get(CommonConstant.MDK_RESULT) != null && CommonConstant.MDK_STATUS_100.equals(modelResult.get(CommonConstant.MDK_STATUS_CODE).toString())) { result = (HashMap<String, Object>) modelResult.get(CommonConstant.MDK_RESULT); @@ -127,13 +139,22 @@ * 根据模型id获取参数map * * @param modelId + * @param dynamicSettings * @return */ - private HashMap<String, Object> getScheduleSettingsByModelId(String modelId) { + private HashMap<String, Object> getScheduleSettingsByModelId(String modelId, Map<String, String> dynamicSettings) { List<StScheduleModelSettingEntity> list = stScheduleModelSettingService.getByModelId(modelId); if (CollectionUtils.isEmpty(list)) { return null; } + //如果输入参数中包含setting,则覆盖默认的setting + if (!CollectionUtils.isEmpty(dynamicSettings)){ + list.forEach(setting -> { + if (dynamicSettings.containsKey(setting.getKey())) { + setting.setValue(dynamicSettings.get(setting.getKey())); + } + }); + } HashMap<String, Object> result = new HashMap<>(); for (StScheduleModelSettingEntity entry : list) { String valueType = entry.getValuetype().trim(); //去除两端空格 -- Gitblit v1.9.3