潘志宝
2024-10-10 aa96f9cab5f43c372d96a0844792d90d2dad2d5e
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/schedule/impl/ScheduleModelHandlerImpl.java
@@ -5,10 +5,11 @@
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;
@@ -33,40 +34,39 @@
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);
@@ -108,7 +108,7 @@
            //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()执行失败");
@@ -126,12 +126,12 @@
     * @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)) {