From 3d9106399d9a2b9c8ba7d2dea621f54fd71d2ca7 Mon Sep 17 00:00:00 2001 From: Jay <csj123456> Date: 星期二, 12 十一月 2024 10:56:23 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java | 54 +++++++++++++++++++++++++++++++++++------------------- 1 files changed, 35 insertions(+), 19 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java index 8f73d14..1fd8c7f 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java @@ -13,22 +13,18 @@ import com.iailab.module.model.mdk.predict.PredictItemHandler; import com.iailab.module.model.mdk.predict.PredictModuleHandler; import com.iailab.module.model.mdk.predict.PredictResultHandler; +import com.iailab.module.model.mdk.schedule.ScheduleModelHandler; import com.iailab.module.model.mdk.vo.DataValueVO; import com.iailab.module.model.mdk.vo.ItemVO; import com.iailab.module.model.mdk.vo.PredictResultVO; +import com.iailab.module.model.mdk.vo.ScheduleResultVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; -import javax.validation.Valid; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; import static com.iailab.framework.common.pojo.CommonResult.error; @@ -62,6 +58,9 @@ @Autowired private PredictResultHandler predictResultHandler; + @Autowired + private ScheduleModelHandler scheduleModelHandler; + /** * 按模块预测 * @@ -69,7 +68,7 @@ * @return */ @Override - public CommonResult<MdkPredictModuleRespDTO> predictModule(MdkPredictReqDTO reqDTO) { + public MdkPredictModuleRespDTO predictModule(MdkPredictReqDTO reqDTO) { MdkPredictModuleRespDTO resp = new MdkPredictModuleRespDTO(); Map<String, MdkPredictItemRespDTO> predictItemRespMap = new HashMap<>(); try { @@ -79,6 +78,11 @@ if (reqDTO.getModuleType() == null) { throw new Exception("ModuleType不能为空"); } + Calendar calendar = Calendar.getInstance(); + calendar.setTime(reqDTO.getPredictTime()); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + reqDTO.setPredictTime(calendar.getTime()); log.info("预测参数:" + JSON.toJSONString(reqDTO)); MdkPredictModuleRespDTO result = new MdkPredictModuleRespDTO(); result.setPredictTime(reqDTO.getPredictTime()); @@ -107,10 +111,11 @@ } log.info("预测计算结束: " + System.currentTimeMillis()); } catch (Exception ex) { - return error(999, ex.getMessage()); + ex.printStackTrace(); + return resp; } resp.setPredictItemRespMap(predictItemRespMap); - return success(resp); + return resp; } /** @@ -120,7 +125,7 @@ * @return */ @Override - public CommonResult<MdkPredictItemRespDTO> predictItem(@Valid @RequestBody MdkPredictReqDTO reqDTO) { + public MdkPredictItemRespDTO predictItem(MdkPredictReqDTO reqDTO) { MdkPredictItemRespDTO resp = new MdkPredictItemRespDTO(); try { @@ -140,11 +145,11 @@ resp.setPredictTime(reqDTO.getPredictTime()); log.info("预测计算结束: " + System.currentTimeMillis()); } catch (Exception ex) { - log.info("预测计算异常: " + System.currentTimeMillis()); - ex.printStackTrace(); + log.info("预测计算异常: " + System.currentTimeMillis(),ex); + return resp; } - return success(resp); + return resp; } /** @@ -154,10 +159,10 @@ * @return */ @Override - public CommonResult<Boolean> predictAutoAdjust(@Valid @RequestBody MdkPredictReqDTO reqDTO) { + public Boolean predictAutoAdjust(MdkPredictReqDTO reqDTO) { - return success(true); + return true; } /** @@ -167,9 +172,20 @@ * @return */ @Override - public CommonResult<MdkScheduleRespDTO> doSchedule(@Valid @RequestBody MdkScheduleReqDTO reqDTO) { + public MdkScheduleRespDTO doSchedule(MdkScheduleReqDTO reqDTO) { MdkScheduleRespDTO resp = new MdkScheduleRespDTO(); - - return success(resp); + resp.setScheduleCode(reqDTO.getScheduleCode()); + resp.setScheduleTime(reqDTO.getScheduleTime()); + try { + log.info("调度计算开始: " + System.currentTimeMillis()); + ScheduleResultVO scheduleResult = scheduleModelHandler.doSchedule(reqDTO.getModelCode(), reqDTO.getScheduleTime()); + resp.setResult(scheduleResult.getResult()); + log.info("预测计算结束: " + System.currentTimeMillis()); + } catch (Exception ex) { + log.info("调度计算异常: " + System.currentTimeMillis()); + ex.printStackTrace(); + return resp; + } + return resp; } } \ No newline at end of file -- Gitblit v1.9.3