| | |
| | | import com.iail.IAILMDK; |
| | | import com.iail.model.IAILModel; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleModelEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleParamSettingEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleModelSettingEntity; |
| | | import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleModelService; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleParamSettingService; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleService; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleModelSettingService; |
| | | import com.iailab.module.model.mcs.sche.service.StScheduleSchemeService; |
| | | import com.iailab.module.model.mdk.common.enums.TypeA; |
| | | import com.iailab.module.model.mdk.common.exceptions.ModelInvokeException; |
| | | import com.iailab.module.model.mdk.sample.SampleConstructor; |
| | |
| | | public class ScheduleModelHandlerImpl implements ScheduleModelHandler { |
| | | |
| | | @Autowired |
| | | private StScheduleSchemeService stScheduleSchemeService; |
| | | |
| | | @Autowired |
| | | private StScheduleModelService stScheduleModelService; |
| | | |
| | | @Autowired |
| | | private StScheduleService stScheduleService; |
| | | private StScheduleModelSettingService stScheduleModelSettingService; |
| | | |
| | | @Autowired |
| | | private SampleConstructor sampleConstructor; |
| | | |
| | | @Autowired |
| | | private StScheduleParamSettingService stScheduleParamSettingService; |
| | | |
| | | @Override |
| | | public ScheduleResultVO doSchedule(String scheduleCode, Date scheduleTime) throws ModelInvokeException { |
| | | public ScheduleResultVO doSchedule(String schemeCode, Date scheduleTime) throws ModelInvokeException { |
| | | ScheduleResultVO scheduleResult = new ScheduleResultVO(); |
| | | |
| | | // todo |
| | | StScheduleModelEntity schModelEntity = stScheduleModelService.selectById(scheduleCode); |
| | | if (schModelEntity == null) { |
| | | StScheduleSchemeEntity scheduleScheme = stScheduleSchemeService.getByCode(schemeCode); |
| | | StScheduleModelEntity scheduleModel = stScheduleModelService.get(scheduleScheme.getModelId()); |
| | | if (scheduleModel == null) { |
| | | throw new ModelInvokeException(MessageFormat.format("{0},modelId={1}", |
| | | ModelInvokeException.errorGetModelEntity, schModelEntity.getId())); |
| | | ModelInvokeException.errorGetModelEntity, scheduleModel.getId())); |
| | | } |
| | | String modelId = schModelEntity.getId(); |
| | | String modelId = scheduleModel.getId(); |
| | | try { |
| | | IAILModel newModelBean = new IAILModel(); |
| | | //1.根据模型id构造模型输入样本 |
| | | List<SampleData> sampleDataList = sampleConstructor.constructSample(TypeA.Schedule.name(), modelId, scheduleTime); |
| | | if (CollectionUtils.isEmpty(sampleDataList)) { |
| | | log.info("调度模型构造样本失败,scheduleCode=" + scheduleCode); |
| | | log.info("调度模型构造样本失败,schemeCode=" + schemeCode); |
| | | return null; |
| | | } |
| | | |
| | | //2.拼接newModelBean的参数结构:a.类名、方法名 b.参数类型 |
| | | String className = schModelEntity.getClassname().trim(); |
| | | String methodName = schModelEntity.getMethodname().trim(); |
| | | String className = scheduleModel.getClassName() .trim(); |
| | | String methodName = scheduleModel.getMethodName().trim(); |
| | | newModelBean.setClassName(className); |
| | | newModelBean.setMethodName(methodName); |
| | | |
| | |
| | | //5.返回调度结果 |
| | | scheduleResult.setResult(result); |
| | | scheduleResult.setModelId(modelId); |
| | | scheduleResult.setScheduleId(schModelEntity.getId()); |
| | | scheduleResult.setSchemeId(scheduleScheme.getId()); |
| | | scheduleResult.setScheduleTime(scheduleTime); |
| | | } catch (Exception ex) { |
| | | log.error("IAILMDK.run()执行失败"); |
| | |
| | | * @return |
| | | */ |
| | | private HashMap<String, Object> getPredictSettingsByModelId(String modelId) { |
| | | List<StScheduleParamSettingEntity> list = stScheduleParamSettingService.getByModelid(modelId); |
| | | List<StScheduleModelSettingEntity> list = stScheduleModelSettingService.getByModelId(modelId); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | HashMap<String, Object> result = new HashMap<>(); |
| | | for (StScheduleParamSettingEntity entry : list) { |
| | | for (StScheduleModelSettingEntity entry : list) { |
| | | String valueType = entry.getValuetype().trim(); |
| | | String valueStr = entry.getValue().trim(); |
| | | if ("int".equals(valueType)) { |