iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleReqDTO.java
@@ -29,6 +29,6 @@ @Schema(description = "动态数据长度(输入端口,数据长度)") private Map<Integer, Integer> dynamicDataLength; @Schema(description = "模型参数") private Map<String, Object> params; @Schema(description = "动态模型设置参数") private Map<String, String> dynamicSettings; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java
@@ -216,7 +216,8 @@ resp.setScheduleTime(reqDTO.getScheduleTime()); try { log.info("调度计算开始: " + System.currentTimeMillis()); ScheduleResultVO scheduleResult = scheduleModelHandler.doSchedule(reqDTO.getScheduleCode(), reqDTO.getScheduleTime(), reqDTO.getDynamicDataLength(), reqDTO.getParams()); ScheduleResultVO scheduleResult = scheduleModelHandler.doSchedule(reqDTO.getScheduleCode(), reqDTO.getScheduleTime(), reqDTO.getDynamicDataLength(), reqDTO.getDynamicSettings()); resp.setStatusCode(scheduleResult.getResultCode()); resp.setResult(scheduleResult.getResult()); stScheduleRecordService.create(scheduleResult); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/predict/impl/PredictModelHandlerImpl.java
@@ -64,7 +64,7 @@ } String modelId = predictModel.getId(); try { List<SampleData> sampleDataList = sampleConstructor.constructSample(TypeA.Predict.name(), modelId, predictTime, itemName); List<SampleData> sampleDataList = sampleConstructor.constructSample(TypeA.Predict.name(), modelId, predictTime, itemName, new HashMap<>()); String modelPath = predictModel.getModelpath(); if (modelPath == null) { log.info("模型路径不存在,modelId=" + modelId); iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/ScheduleModelHandler.java
@@ -13,5 +13,5 @@ */ public interface ScheduleModelHandler { ScheduleResultVO doSchedule(String schemeCode, Date scheduleTime, Map<Integer, Integer> dynamicDataLength, Map<String, Object> params) throws ModelInvokeException; ScheduleResultVO doSchedule(String schemeCode, Date scheduleTime, Map<Integer, Integer> dynamicDataLength, Map<String, String> dynamicSettings) throws ModelInvokeException; } iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java
@@ -52,7 +52,8 @@ private SampleConstructor sampleConstructor; @Override public ScheduleResultVO doSchedule(String schemeCode, Date scheduleTime, Map<Integer, Integer> dynamicDataLength, Map<String, Object> params) 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,18 +74,10 @@ } 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; } //如果输入参数中包含setting,则覆盖默认的setting if (!params.isEmpty()){ for (Map.Entry<String, Object> entry : params.entrySet()){ if (settings.containsKey(entry.getKey())){ settings.put(entry.getKey(), entry.getValue()); } } } // 校验setting必须有pyFile,否则可能导致程序崩溃 if (!settings.containsKey(MdkConstant.PY_FILE_KEY)) { @@ -135,13 +128,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 (!dynamicSettings.isEmpty()){ 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(); //去除两端空格