From b368e6092f83b98a9d81ba48b22ece51d5807112 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 14 十一月 2024 11:29:14 +0800 Subject: [PATCH] 返回预测结果 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java | 44 ++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageReqDTO.java | 4 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java | 41 ++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleRespDTO.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemOutputEntity.java | 5 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineReqVO.java | 34 ++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestRespDTO.java | 3 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineRespVO.java | 40 ++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictDataDTO.java | 4 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageRespDTO.java | 4 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultLastPointEntity.java | 42 ++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java | 24 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictItemRespDTO.java | 4 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewRespDTO.java | 6 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java | 17 + iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewReqDTO.java | 8 iailab-module-model/iailab-module-model-biz/db/mysql.sql | 3 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java | 2 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleModelSettingReqDTO.java | 11 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestReqDTO.java | 3 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultLastPointDao.java | 16 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultJsonEntity.java | 2 iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml | 24 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/ItemVO.java | 7 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultJsonDao.java | 16 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java | 17 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemOutputService.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java | 12 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java | 245 ++++++++++++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/MdkApiImpl.java | 1 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictModelSettingReqDTO.java | 10 /dev/null | 22 - iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java | 21 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java | 168 ----------- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java | 6 iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictItemInfoDTO.java | 10 37 files changed, 638 insertions(+), 244 deletions(-) diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java index 99d264b..42bc079 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java @@ -1,6 +1,5 @@ package com.iailab.module.model.api.mcs; -import com.iailab.framework.common.pojo.CommonResult; import com.iailab.module.model.api.mcs.dto.*; import com.iailab.module.model.enums.ApiConstants; import io.swagger.v3.oas.annotations.Operation; @@ -20,40 +19,39 @@ * @createTime 2024年08月26日 */ @FeignClient(name = ApiConstants.NAME) -@Tag(name = "RPC 服务 - 模型配置接口") +@Tag(name = "RPC 服务 - 模型配置信息接口") public interface McsApi { String PREFIX = ApiConstants.PREFIX + "/mcs"; - @GetMapping(PREFIX + "/predict-item-tree") + @GetMapping(PREFIX + "/predict-item/tree") @Operation(summary = "预测项树") - CommonResult<List<PredictItemTreeDTO>> getPredictItemTree(); + List<PredictItemTreeDTO> getPredictItemTree(); - @GetMapping(PREFIX + "/predict-item-info") - @Operation(summary = "预测项详情") - CommonResult<PredictItemInfoDTO> getPredictItemInfo(@RequestParam Map<String, Object> params); + @PostMapping(PREFIX + "/predict-data/charts") + PreDataBarLineRespVO getPreDataCharts(@RequestBody PreDataBarLineReqVO reqVO); @PostMapping(PREFIX + "/alarm-message/create") @Operation(summary = "添加预警信息") - CommonResult<Boolean> createAlarmMessage(@RequestBody AlarmMessageRespDTO dto); + Boolean createAlarmMessage(@RequestBody AlarmMessageRespDTO dto); @GetMapping(PREFIX + "/alarm-message/list") @Operation(summary = "获取预警信息列表") - CommonResult<AlarmMessageRespDTO> listAlarmMessage(@RequestParam Map<String, Object> params); + List<AlarmMessageRespDTO> listAlarmMessage(@RequestParam Map<String, Object> params); @PostMapping(PREFIX + "/schedule-suggest/create") @Operation(summary = "添加调度建议") - CommonResult<Boolean> createScheduleSuggest(@RequestBody ScheduleSuggestRespDTO dto); + Boolean createScheduleSuggest(@RequestBody ScheduleSuggestRespDTO dto); @GetMapping(PREFIX + "/alarm-message/list") @Operation(summary = "获取调度建议列表") - CommonResult<ScheduleSuggestRespDTO> listScheduleSuggest(@RequestParam ScheduleSuggestReqDTO params); + List<ScheduleSuggestRespDTO> listScheduleSuggest(@RequestParam ScheduleSuggestReqDTO params); @PostMapping(PREFIX + "/predict-model-setting/modify") @Operation(summary = "修改预测模型设置参数") - CommonResult<Boolean> modifyPredictModelSetting(@RequestBody List<PredictModelSettingReqDTO> dtos); + Boolean modifyPredictModelSetting(@RequestBody List<PredictModelSettingReqDTO> dtos); @PostMapping(PREFIX + "/schedule-model-setting/modify") @Operation(summary = "修改调度模型设置参数") - CommonResult<Boolean> modifyScheduleModelSetting(@RequestBody List<ScheduleModelSettingReqDTO> dtos); + Boolean modifyScheduleModelSetting(@RequestBody List<ScheduleModelSettingReqDTO> dtos); } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageReqDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageReqDTO.java index a55af61..4389fc2 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageReqDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageReqDTO.java @@ -1,5 +1,6 @@ package com.iailab.module.model.api.mcs.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -26,11 +27,14 @@ private String itemId; @Schema(description = "预警时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date alarmTime; @Schema(description = "开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date startTime; @Schema(description = "结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date endTime; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageRespDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageRespDTO.java index c9d164d..a6dc52b 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageRespDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/AlarmMessageRespDTO.java @@ -6,6 +6,7 @@ * @createTime 2024年08月29日 */ +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -46,15 +47,18 @@ private BigDecimal currentValue; @Schema(description = "超出时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date outTime; @Schema(description = "超出值") private BigDecimal outValue; @Schema(description = "预警类型") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private String alarmType; @Schema(description = "预警时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date alarmTime; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineReqVO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineReqVO.java new file mode 100644 index 0000000..da490a2 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineReqVO.java @@ -0,0 +1,34 @@ +package com.iailab.module.model.api.mcs.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月13日 + */ +@Data +public class PreDataBarLineReqVO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "查询ID列表") + private List<String[]> queryIds; + + @Schema(description = "预测时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date predictTime; + + @Schema(description = "开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date startTime; + + @Schema(description = "结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date endTime; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineRespVO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineRespVO.java new file mode 100644 index 0000000..c59975f --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataBarLineRespVO.java @@ -0,0 +1,40 @@ +package com.iailab.module.model.api.mcs.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月13日 + */ +@Data +public class PreDataBarLineRespVO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "预测时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date predictTime; + + @Schema(description = "开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date startTime; + + @Schema(description = "结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date endTime; + + @Schema(description = "图例") + private List<String> legend; + + @Schema(description = "X轴数据") + private List<String> categories; + + @Schema(description = "图表数据") + private List<PreDataViewRespDTO> dataViewList; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewReqDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewReqDTO.java index 3ae56b2..37e8537 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewReqDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewReqDTO.java @@ -1,8 +1,10 @@ package com.iailab.module.model.api.mcs.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serializable; import java.util.Date; /** @@ -12,14 +14,18 @@ */ @Schema(description = "RPC 模型 - 预测数据 DTO") @Data -public class PreDataViewReqDTO { +public class PreDataViewReqDTO implements Serializable { + private static final long serialVersionUID = 1L; @Schema(description = "预测项ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private String itemId; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private String startTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private String endTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date predictTime; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewRespDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewRespDTO.java index add373f..f01b123 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewRespDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PreDataViewRespDTO.java @@ -1,8 +1,10 @@ package com.iailab.module.model.api.mcs.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serializable; import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -15,7 +17,8 @@ */ @Schema(description = "RPC 模型 - 预测数据 DTO") @Data -public class PreDataViewRespDTO { +public class PreDataViewRespDTO implements Serializable { + private static final long serialVersionUID = 1L; @Schema(description = "预测项ID") private String itemId; @@ -24,6 +27,7 @@ private String itemName; @Schema(description = "预测时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date predictTime; @Schema(description = "量程上限") diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictItemInfoDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictItemInfoDTO.java index 3e5f060..6d50225 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictItemInfoDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictItemInfoDTO.java @@ -1,14 +1,14 @@ package com.iailab.module.model.api.mcs.dto; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; -import java.util.Date; -import java.util.List; -import java.util.Map; /** + * 预测项信息 + * * @author PanZhibao * @Description * @createTime 2024年07月31日 @@ -17,11 +17,15 @@ public class PredictItemInfoDTO implements Serializable { private static final long serialVersionUID = 1L; + @Schema(description = "预测项ID") private String itemId; + @Schema(description = "预测项编号") private String itemNo; + @Schema(description = "预测项名称") private String itemName; + @Schema(description = "预测项长度") private BigDecimal predictLength; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictModelSettingReqDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictModelSettingReqDTO.java index 5d1f29b..4408e34 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictModelSettingReqDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/PredictModelSettingReqDTO.java @@ -3,7 +3,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -16,15 +15,12 @@ public class PredictModelSettingReqDTO implements Serializable { private static final long serialVersionUID = 1L; + @Schema(description = "模型ID") private String modelid; - /** - * 键 - */ + @Schema(description = "键") private String key; - /** - * 值 - */ + @Schema(description = "值") private String value; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleModelSettingReqDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleModelSettingReqDTO.java index bd40728..ff5de3b 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleModelSettingReqDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleModelSettingReqDTO.java @@ -1,5 +1,7 @@ package com.iailab.module.model.api.mcs.dto; +import io.swagger.v3.oas.annotations.media.Schema; + import java.io.Serializable; /** @@ -10,15 +12,12 @@ public class ScheduleModelSettingReqDTO implements Serializable { private static final long serialVersionUID = 1L; + @Schema(description = "模型ID") private String modelid; - /** - * 键 - */ + @Schema(description = "键") private String key; - /** - * 值 - */ + @Schema(description = "值") private String value; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestReqDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestReqDTO.java index ba217bd..7efea0b 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestReqDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestReqDTO.java @@ -1,5 +1,6 @@ package com.iailab.module.model.api.mcs.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -26,9 +27,11 @@ private String adjustObj; @Schema(description = "开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date startTime; @Schema(description = "结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date endTime; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestRespDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestRespDTO.java index a0418c1..bb11c48 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestRespDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/ScheduleSuggestRespDTO.java @@ -1,5 +1,6 @@ package com.iailab.module.model.api.mcs.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -61,9 +62,11 @@ private BigDecimal adjustTimes; @Schema(description = "调整开始时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date adjustStart; @Schema(description = "调整结束时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date adjustEnd; @Schema(description = "建议时间") diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictDataDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictDataDTO.java index 2391f63..6c03b78 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictDataDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictDataDTO.java @@ -1,5 +1,6 @@ package com.iailab.module.model.api.mdk.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -14,7 +15,10 @@ @Data public class MdkPredictDataDTO { + @Schema(description = "数据时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date dataTime; + @Schema(description = "数据值") private Double dataValue; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictItemRespDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictItemRespDTO.java index 424af2c..9c3202d 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictItemRespDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkPredictItemRespDTO.java @@ -1,5 +1,6 @@ package com.iailab.module.model.api.mdk.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -18,8 +19,11 @@ @Data public class MdkPredictItemRespDTO { + @Schema(description = "预测时间") private String itemId; + @Schema(description = "预测时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date predictTime; @Schema(description = "单个预测项预测结果,KEY为预测项目编码") diff --git a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleRespDTO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleRespDTO.java index 1b88f23..ab3862a 100644 --- a/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleRespDTO.java +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mdk/dto/MdkScheduleRespDTO.java @@ -1,5 +1,6 @@ package com.iailab.module.model.api.mdk.dto; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -17,6 +18,7 @@ private String scheduleCode; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") private Date scheduleTime; private Map<String, Object> result; diff --git a/iailab-module-model/iailab-module-model-biz/db/mysql.sql b/iailab-module-model/iailab-module-model-biz/db/mysql.sql index 2cdaff8..4dab812 100644 --- a/iailab-module-model/iailab-module-model-biz/db/mysql.sql +++ b/iailab-module-model/iailab-module-model-biz/db/mysql.sql @@ -868,3 +868,6 @@ INSERT INTO `iailab_plat_system`.`system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (644, '模型结果数据类型', 'model_result_type', 0, '', '141', '2024-11-11 15:16:58', '141', '2024-11-11 15:16:58', b'0', '1970-01-01 00:00:00'); INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1628, 1, 'double[]', '1', 'model_result_type', 0, '', '', '', '141', '2024-11-11 15:21:05', '141', '2024-11-11 15:21:05', b'0'); INSERT INTO `iailab_plat_system`.`system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1629, 2, 'double[][]', '2', 'model_result_type', 0, '', '', '', '141', '2024-11-11 15:21:17', '141', '2024-11-11 15:21:17', b'0'); + + +alter table t_mm_item_output add column `result_name` varchar(50) DEFAULT NULL; \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java new file mode 100644 index 0000000..5351dcd --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java @@ -0,0 +1,245 @@ +package com.iailab.module.model.api; + +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.module.data.api.point.DataPointApi; +import com.iailab.module.data.api.point.dto.ApiPointDTO; +import com.iailab.module.data.api.point.dto.ApiPointValueDTO; +import com.iailab.module.data.api.point.dto.ApiPointValueQueryDTO; +import com.iailab.module.model.api.mcs.McsApi; +import com.iailab.module.model.api.mcs.dto.*; +import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; +import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; +import com.iailab.module.model.mcs.pre.service.*; +import com.iailab.module.model.mcs.pre.vo.MmPredictItemRespVO; +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.RestController; + +import java.math.BigDecimal; +import java.util.*; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月13日 + */ +@Slf4j +@RestController +@Validated +public class McsApiImpl implements McsApi { + + @Autowired + private DmModuleService dmModuleService; + + @Autowired + private MmPredictItemService mmPredictItemService; + + @Autowired + private MmItemOutputService mmItemOutputService; + + @Autowired + private MmItemResultService mmItemResultService; + + @Autowired + private MmItemResultLastPointService mmItemResultLastPointService; + + @Autowired + private DataPointApi dataPointApi; + + private int HOUR_MINS = 60; + + @Override + public List<PredictItemTreeDTO> getPredictItemTree() { + List<PredictItemTreeDTO> result = new ArrayList<>(); + + List<DmModuleEntity> moduleList = dmModuleService.list(new HashMap<>()); + if (CollectionUtils.isEmpty(moduleList)) { + return result; + } + moduleList.forEach(item -> { + PredictItemTreeDTO moduleOpt = new PredictItemTreeDTO(); + moduleOpt.setId(item.getId()); + moduleOpt.setLabel(item.getModulename()); + List<PredictItemTreeDTO> children = new ArrayList<>(); + Map<String, Object> params = new HashMap<>(2); + params.put("status", 1); + params.put("moduleid", item.getId()); + List<MmPredictItemRespVO> itemList = mmPredictItemService.list(params); + itemList.forEach(item1 -> { + PredictItemTreeDTO chd = new PredictItemTreeDTO(); + chd.setLabel(item1.getItemname()); + chd.setId(item1.getId()); + children.add(chd); + }); + moduleOpt.setChildren(children); + result.add(moduleOpt); + }); + return result; + } + + @Override + public PreDataBarLineRespVO getPreDataCharts(PreDataBarLineReqVO reqVO) { + PreDataBarLineRespVO result = new PreDataBarLineRespVO(); + List<String[]> queryIds = reqVO.getQueryIds(); + List<String> legends = new ArrayList<>(); + List<PreDataViewRespDTO> dataViewList = new ArrayList<>(); + if (CollectionUtils.isEmpty(reqVO.getQueryIds())) { + return result; + } + Date predictTime = reqVO.getPredictTime(); + if (predictTime == null) { + DmModuleEntity dmModule = dmModuleService.getModuleByItemId(queryIds.get(0)[0]); + if (dmModule != null) { + predictTime = dmModule.getPredicttime(); + } else { + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.MILLISECOND, 0); + calendar.set(Calendar.SECOND, 0); + predictTime = calendar.getTime(); + } + } + Date startTime = reqVO.getStartTime(); + if (startTime == null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(predictTime); + calendar.add(Calendar.HOUR_OF_DAY, -1); + startTime = calendar.getTime(); + } + Date endTime = reqVO.getEndTime(); + if (endTime == null) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(predictTime); + calendar.add(Calendar.HOUR_OF_DAY, 1); + endTime = calendar.getTime(); + } + + for (int i = 0; i < queryIds.size(); i++) { + PreDataViewRespDTO viewDto = new PreDataViewRespDTO(); + String itemId = queryIds.get(i)[0]; + String outKey = queryIds.get(i)[1]; + MmItemOutputEntity output = mmItemOutputService.getByItemid(itemId, outKey); + if (output == null) { + continue; + } + legends.add(output.getResultstr()); + viewDto.setRealData(getHisData(output.getPointid(), startTime, endTime)); + viewDto.setPreDataN(mmItemResultService.getData(output.getId(), startTime, endTime)); + viewDto.setPreDataL(mmItemResultLastPointService.getData(output.getId(), startTime, endTime)); + + List<Double> values = new ArrayList<>(); + if (!CollectionUtils.isEmpty(viewDto.getRealData())) { + List<Double> hisValues = new ArrayList<>(); + viewDto.getRealData().forEach(item -> { + values.add(Double.parseDouble(item[1].toString())); + hisValues.add(Double.parseDouble(item[1].toString())); + }); + viewDto.setHisMax(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + viewDto.setHisMin(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + viewDto.setHisAvg(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + viewDto.setHisCumulant(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).sum()) + .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP)); + } + if (!CollectionUtils.isEmpty(viewDto.getPreDataN())) { + viewDto.getPreDataN().forEach(item -> { + values.add(Double.parseDouble(item[1].toString())); + }); + } + if (!CollectionUtils.isEmpty(viewDto.getPreDataL())) { + List<Double> preValues = new ArrayList<>(); + viewDto.getPreDataL().forEach(item -> { + values.add(Double.parseDouble(item[1].toString())); + preValues.add(Double.parseDouble(item[1].toString())); + }); + viewDto.setPreMax(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + viewDto.setPreMin(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + viewDto.setPreAvg(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + if (!CollectionUtils.isEmpty(viewDto.getCurData())) { + List<Double> preValues = new ArrayList<>(); + viewDto.getCurData().forEach(item -> { + values.add(Double.parseDouble(item[1].toString())); + preValues.add(Double.parseDouble(item[1].toString())); + }); + viewDto.setPreCumulant(new BigDecimal(preValues.stream().mapToDouble(Double::doubleValue).sum()) + .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP)); + } + if (!CollectionUtils.isEmpty(viewDto.getAdjData())) { + viewDto.getAdjData().forEach(item -> { + values.add(Double.parseDouble(item[1].toString())); + }); + } + if (!CollectionUtils.isEmpty(values)) { + viewDto.setMaxValue(new BigDecimal(values.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + viewDto.setMinValue(new BigDecimal(values.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + dataViewList.add(viewDto); + } + result.setStartTime(startTime); + result.setEndTime(endTime); + result.setPredictTime(predictTime); + result.setCategories(DateUtils.getTimeScale(startTime, endTime, 60)); + result.setLegend(legends); + result.setDataViewList(dataViewList); + return result; + } + + /** + * 获取真实值 + * + * @param pointId + * @param startTime + * @param endTime + * @return + */ + private List<Object[]> getHisData(String pointId, Date startTime, Date endTime) { + List<Object[]> result = new ArrayList<>(); + ApiPointDTO pointDTO = dataPointApi.getInfoById(pointId); + ApiPointValueQueryDTO queryPointDto = new ApiPointValueQueryDTO(); + queryPointDto.setPointNo(pointDTO.getPointNo()); + queryPointDto.setStart(startTime); + queryPointDto.setEnd(endTime); + List<ApiPointValueDTO> valueDTOS = dataPointApi.queryPointHistoryValue(queryPointDto); + if (CollectionUtils.isEmpty(valueDTOS)) { + return result; + } + valueDTOS.forEach(item -> { + Object[] values = new Object[2]; + values[0] = DateUtils.format(item.getDataTime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); + values[1] = item.getDataValue(); + result.add(values); + }); + return result; + } + + @Override + public Boolean createAlarmMessage(AlarmMessageRespDTO dto) { + return true; + } + + @Override + public List<AlarmMessageRespDTO> listAlarmMessage(Map<String, Object> params) { + return null; + } + + @Override + public Boolean createScheduleSuggest(ScheduleSuggestRespDTO dto) { + return true; + } + + @Override + public List<ScheduleSuggestRespDTO> listScheduleSuggest(ScheduleSuggestReqDTO params) { + return null; + } + + @Override + public Boolean modifyPredictModelSetting(List<PredictModelSettingReqDTO> dtos) { + return true; + } + + @Override + public Boolean modifyScheduleModelSetting(List<ScheduleModelSettingReqDTO> dtos) { + return true; + } +} \ No newline at end of file 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 eb7267e..eb9ea4f 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 @@ -4,7 +4,6 @@ import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.model.api.mdk.MdkApi; import com.iailab.module.model.api.mdk.dto.*; -import com.iailab.framework.common.pojo.CommonResult; import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; import com.iailab.module.model.mcs.pre.service.DmModuleService; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java index 7bfdc9e..94fed54 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictItemController.java @@ -4,31 +4,21 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.iailab.framework.common.pojo.CommonResult; import com.iailab.framework.common.pojo.PageResult; -import com.iailab.framework.common.util.date.DateUtils; import com.iailab.module.model.common.enums.CommonConstant; import com.iailab.module.model.mcs.pre.dto.MmPredictItemDTO; -import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; -import com.iailab.module.model.mcs.pre.entity.MmItemOutputEntity; -import com.iailab.module.model.mcs.pre.entity.MmPredictItemEntity; -import com.iailab.module.model.mcs.pre.service.DmModuleService; -import com.iailab.module.model.mcs.pre.service.MmItemOutputService; import com.iailab.module.model.mcs.pre.service.MmPredictItemService; import com.iailab.module.model.mcs.pre.vo.*; import com.iailab.module.model.mpk.common.utils.IAILModelUtil; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.security.PermitAll; import java.io.File; -import java.math.BigDecimal; -import java.math.RoundingMode; import java.util.*; import static com.iailab.framework.common.pojo.CommonResult.success; @@ -51,13 +41,6 @@ @Autowired private MmPredictItemService mmPredictItemService; - @Autowired - private DmModuleService dmModuleService; - - @Autowired - private MmItemOutputService mmItemOutputService; - - private int HOUR_MINS = 60; /** * 预测项列表 */ @@ -137,157 +120,6 @@ file.transferTo(new File(uploadDir)); Map<String, Object> result = iAILModelUtil.parseModel(uploadDir); result.put("originalFilename", file.getOriginalFilename().replace(CommonConstant.MDK_SUFFIX, "")); - return success(result); - } - - @GetMapping("/tree") - public CommonResult<List<PreItemOptionVO>> itemTree() { - List<PreItemOptionVO> result = new ArrayList<>(); - - List<DmModuleEntity> moduleList = dmModuleService.list(new HashMap<>()); - if (CollectionUtils.isEmpty(moduleList)) { - return success(result); - } - moduleList.forEach(item -> { - PreItemOptionVO moduleOpt = new PreItemOptionVO(); - moduleOpt.setId(item.getId()); - moduleOpt.setLabel(item.getModulename()); - List<PreItemOptionVO> children = new ArrayList<>(); - Map<String, Object> params = new HashMap<>(2); - params.put("status", 1); - params.put("moduleid", item.getId()); - List<MmPredictItemRespVO> itemList = mmPredictItemService.list(params); - itemList.forEach(item1 -> { - PreItemOptionVO chd = new PreItemOptionVO(); - chd.setLabel(item1.getItemname()); - chd.setId(item1.getId()); - children.add(chd); - }); - moduleOpt.setChildren(children); - result.add(moduleOpt); - }); - return success(result); - } - - @GetMapping("/view-charts") - public CommonResult<PreDataBarLineVO> viewCharts(@RequestParam Map<String, Object> params) { - PreDataBarLineVO result = new PreDataBarLineVO(); - List<String> legends = new ArrayList<>(); - List<PreDataViewVO> dataViewList = new ArrayList<>(); - if (params.get("itemIds") == null) { - return success(result); - } - List<String> itemIdList = Arrays.asList(params.get("itemIds").toString().split(",")); - - Date predictTime; - if (StringUtils.isBlank((String) params.get("predictTime"))) { - DmModuleEntity dmModule = dmModuleService.getModuleByItemId(itemIdList.get(0)); - if (dmModule != null) { - predictTime = dmModule.getPredicttime(); - } else { - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.MILLISECOND, 0); - calendar.set(Calendar.SECOND, 0); - predictTime = calendar.getTime(); - } - } else { - predictTime = DateUtils.parse(params.get("predictTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); - } - Date startTime; - if (StringUtils.isBlank((String) params.get("startTime"))) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(predictTime); - calendar.add(Calendar.HOUR_OF_DAY, -1); - startTime = calendar.getTime(); - } else { - startTime = DateUtils.parse(params.get("startTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); - } - Date endTime = null; - if (StringUtils.isBlank((String) params.get("endTime"))) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(predictTime); - calendar.add(Calendar.HOUR_OF_DAY, 1); - endTime = calendar.getTime(); - } else { - endTime = DateUtils.parse(params.get("endTime").toString(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); - } - - for (int i = 0; i < itemIdList.size(); i++) { - PreDataViewVO viewDto = new PreDataViewVO(); - String itemId = itemIdList.get(i); -// MmItemOutputEntity mmItemOutput = mmItemOutputService.getByItemid(itemId); - MmPredictItemEntity predictItem = mmPredictItemService.getById(itemId); - if (predictItem == null) { - log.info("itemId=" + itemId + "; is null"); - continue; - } - try { - viewDto.setItemId(itemId); - viewDto.setItemName(predictItem.getItemname()); - viewDto.setRealData(mmPredictItemService.getHisData(itemId, startTime, endTime)); -// viewDto.setPreDataN(mmItemResultService.getData(mmItemOutput.getId(), startTime, endTime)); -// viewDto.setPreDataL(mmItemResultLastPointService.getData(mmItemOutput.getId(), startTime, endTime)); -// viewDto.setCurData(mmItemResultJsonService.getData(mmItemOutput.getId(), predictTime)); -// viewDto.setAdjData(scheduleAdjustResultService.getData(itemId, predictTime)); - legends.add(predictItem.getItemname()); - List<Double> values = new ArrayList<>(); - if (!CollectionUtils.isEmpty(viewDto.getRealData())) { - List<Double> hisValues = new ArrayList<>(); - viewDto.getRealData().forEach(item -> { - values.add(Double.parseDouble(item[1].toString())); - hisValues.add(Double.parseDouble(item[1].toString())); - }); - viewDto.setHisMax(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - viewDto.setHisMin(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - viewDto.setHisAvg(BigDecimal.valueOf(hisValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - viewDto.setHisCumulant(new BigDecimal(hisValues.stream().mapToDouble(Double::doubleValue).sum()) - .divide(new BigDecimal(HOUR_MINS), 2, BigDecimal.ROUND_HALF_UP)); - } - if (!CollectionUtils.isEmpty(viewDto.getPreDataN())) { - viewDto.getPreDataN().forEach(item -> { - values.add(Double.parseDouble(item[1].toString())); - }); - } - if (!CollectionUtils.isEmpty(viewDto.getPreDataL())) { - List<Double> preValues = new ArrayList<>(); - viewDto.getPreDataL().forEach(item -> { - values.add(Double.parseDouble(item[1].toString())); - preValues.add(Double.parseDouble(item[1].toString())); - }); - viewDto.setPreMax(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - viewDto.setPreMin(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - viewDto.setPreAvg(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).average().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - } - if (!CollectionUtils.isEmpty(viewDto.getCurData())) { - List<Double> preValues = new ArrayList<>(); - viewDto.getCurData().forEach(item -> { - values.add(Double.parseDouble(item[1].toString())); - preValues.add(Double.parseDouble(item[1].toString())); - }); - viewDto.setPreCumulant(BigDecimal.valueOf(preValues.stream().mapToDouble(Double::doubleValue).sum()) - .divide(new BigDecimal(HOUR_MINS), 2, RoundingMode.HALF_UP)); - } - if (!CollectionUtils.isEmpty(viewDto.getAdjData())) { - viewDto.getAdjData().forEach(item -> { - values.add(Double.parseDouble(item[1].toString())); - }); - } - if (!CollectionUtils.isEmpty(values)) { - viewDto.setMaxValue(BigDecimal.valueOf(values.stream().mapToDouble(Double::doubleValue).max().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - viewDto.setMinValue(BigDecimal.valueOf(values.stream().mapToDouble(Double::doubleValue).min().getAsDouble()).setScale(2, RoundingMode.HALF_UP)); - } - - dataViewList.add(viewDto); - } catch (Exception ex) { - ex.printStackTrace(); - } - } - result.setStartTime(startTime); - result.setEndTime(endTime); - result.setPredictTime(predictTime); - result.setCategories(DateUtils.getTimeScale(startTime, endTime, 60)); - result.setLegend(legends); - result.setDataViewList(dataViewList); return success(result); } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmResultTableController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmResultTableController.java deleted file mode 100644 index 55f0017..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmResultTableController.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.iailab.module.model.mcs.pre.controller.admin; - -import com.baomidou.dynamic.datasource.annotation.DSTransactional; -import com.iailab.framework.common.pojo.CommonResult; -import com.iailab.framework.common.pojo.PageResult; -import com.iailab.framework.common.util.object.BeanUtils; -import com.iailab.module.model.mcs.pre.entity.DmModuleEntity; -import com.iailab.module.model.mcs.pre.entity.MmResultTableEntity; -import com.iailab.module.model.mcs.pre.service.MmResultTableService; -import com.iailab.module.model.mcs.pre.vo.MmItemTypeRespVO; -import com.iailab.module.model.mcs.pre.vo.MmResultTablePageReqVO; -import com.iailab.module.model.mcs.pre.vo.MmResultTableRespVO; -import io.swagger.v3.oas.annotations.Operation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; -import java.util.List; -import java.util.Map; - -import static com.iailab.framework.common.pojo.CommonResult.error; -import static com.iailab.framework.common.pojo.CommonResult.success; - -/** - * @author PanZhibao - * @date 2021年04月22日 9:57 - */ -@RestController -@RequestMapping("/model/pre/result-table") -public class MmResultTableController { - - @Autowired - private MmResultTableService mmResultTableService; - - /** - * 结果存放列表 - */ - @GetMapping("/page") - public CommonResult<PageResult<MmResultTableRespVO>> page(@Validated MmResultTablePageReqVO reqVO) { - PageResult<MmResultTableEntity> page = mmResultTableService.page(reqVO); - - return success(BeanUtils.toBean(page, MmResultTableRespVO.class)); - } - - - @GetMapping("/list") - public CommonResult<List<MmResultTableEntity>> list(@Valid @RequestParam Map<String, Object> params) { - List<MmResultTableEntity> list = mmResultTableService.list(params); - return success(list); - } - - @GetMapping("/get/{id}") - @PreAuthorize("@ss.hasPermission('model:pre-result:query')") - public CommonResult<MmResultTableEntity> info(@PathVariable("id") String id){ - MmResultTableEntity resultTable = mmResultTableService.info(id); - - return success(resultTable); - } - - /** - * 保存结果存放 - */ - @PostMapping("/create") - @PreAuthorize("@ss.hasPermission('model:pre-result:create')") - @DSTransactional(rollbackFor= Exception.class) - public CommonResult<Boolean> save(@RequestBody MmResultTableEntity resultTable){ - int count = mmResultTableService.check(resultTable); - if (count > 0) { - return error(999,"名称重复"); - } - mmResultTableService.saveResultTable(resultTable); - return success(true); - } - - /** - * 修改结果存放 - */ - @PutMapping("/update") - @PreAuthorize("@ss.hasPermission('model:pre-result:update')") - @DSTransactional(rollbackFor= Exception.class) - public CommonResult<Boolean> update(@RequestBody MmResultTableEntity resultTable){ - int count = mmResultTableService.check(resultTable); - if (count > 0) { - return error(999,"名称重复"); - } - mmResultTableService.update(resultTable); - return success(true); - } - - /** - * 删除结果存放 - */ - @DeleteMapping("/delete") - @PreAuthorize("@ss.hasPermission('model:pre-result:delete')") - @DSTransactional(rollbackFor= Exception.class) - public CommonResult<Boolean> delete(@RequestParam("id") String id) { - mmResultTableService.deleteBatch(new String[]{id}); - return success(true); - } -} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultJsonDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultJsonDao.java new file mode 100644 index 0000000..a7386b9 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultJsonDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.model.mcs.pre.dao; + +import com.iailab.framework.mybatis.core.mapper.BaseMapperX; +import com.iailab.framework.tenant.core.db.dynamic.TenantDS; +import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月14日 + */ +@TenantDS +@Mapper +public interface MmItemResultJsonDao extends BaseMapperX<MmItemResultJsonEntity> { +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultLastPointDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultLastPointDao.java new file mode 100644 index 0000000..181ad0c --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/dao/MmItemResultLastPointDao.java @@ -0,0 +1,16 @@ +package com.iailab.module.model.mcs.pre.dao; + +import com.iailab.framework.mybatis.core.mapper.BaseMapperX; +import com.iailab.framework.tenant.core.db.dynamic.TenantDS; +import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月14日 + */ +@TenantDS +@Mapper +public interface MmItemResultLastPointDao extends BaseMapperX<MmItemResultLastPointEntity> { +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemOutputEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemOutputEntity.java index c5871aa..bc4251e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemOutputEntity.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemOutputEntity.java @@ -65,4 +65,9 @@ * 排序(默认值1) */ private BigDecimal outputorder; + + /** + * 结果名称 + */ + private String resultName; } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultJsonEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultJsonEntity.java index 2509a5c..be01bd1 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultJsonEntity.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultJsonEntity.java @@ -14,7 +14,7 @@ * @createTime 2024年09月02日 */ @Data -@TableName("T_MM_ITEM_RESULT") +@TableName("t_mm_item_result_json") public class MmItemResultJsonEntity implements Serializable { @TableId(value = "id",type = IdType.INPUT) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultLastPointEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultLastPointEntity.java new file mode 100644 index 0000000..022d6da --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/entity/MmItemResultLastPointEntity.java @@ -0,0 +1,42 @@ +package com.iailab.module.model.mcs.pre.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月14日 + */ +@Data +@TableName("t_mm_item_result_last_point") +public class MmItemResultLastPointEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id",type = IdType.INPUT) + private String id; + + /** + * 输出ID + */ + private String outputid; + + /** + * 预测时间 + */ + private Date datatime; + + /** + * 预测值 + */ + private BigDecimal datavalue; +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemOutputService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemOutputService.java index dd45baa..fe760d7 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemOutputService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemOutputService.java @@ -27,5 +27,7 @@ List<MmItemOutputEntity> getByItemid(String itemid); + MmItemOutputEntity getByItemid(String itemid, String resultstr); + void deleteByItemId(String itemId); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java new file mode 100644 index 0000000..971e867 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultJsonService.java @@ -0,0 +1,17 @@ +package com.iailab.module.model.mcs.pre.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; + +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月14日 + */ +public interface MmItemResultJsonService extends BaseService<MmItemResultJsonEntity> { + + List<Object[]> getData(String outputId, Date predictTime); +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java new file mode 100644 index 0000000..bc70faf --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultLastPointService.java @@ -0,0 +1,17 @@ +package com.iailab.module.model.mcs.pre.service; + +import com.iailab.framework.common.service.BaseService; +import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity; + +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月14日 + */ +public interface MmItemResultLastPointService extends BaseService<MmItemResultLastPointEntity> { + + List<Object[]> getData(String outputid, Date startTime, Date endTime); +} diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java index f4d57d4..88e09f6 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmItemResultService.java @@ -18,4 +18,6 @@ void savePredictValue(Map<String, List<DataValueVO>> predictValueMap, int t, String nIndex, Date predictTime); List<DataValueVO> getPredictValue(String outputid, Date startTime, Date endTime); + + List<Object[]> getData(String outputid, Date startTime, Date endTime); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java index ef80336..457cdaa 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictItemService.java @@ -41,6 +41,4 @@ List<MmPredictItemRespVO> list(Map<String, Object> params); MmPredictItemEntity getById(String id); - - List<Object[]> getHisData(String itemId, Date startTime, Date endTime); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java index f678832..6e22fc7 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java @@ -43,14 +43,20 @@ @Override public List<MmItemOutputEntity> getByItemid(String itemid) { - QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper(); - queryWrapper.eq("itemid", itemid); - queryWrapper.orderByAsc("outputorder"); + QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("itemid", itemid).orderByAsc("outputorder"); List<MmItemOutputEntity> list = mmItemOutputDao.selectList(queryWrapper); return list; } @Override + public MmItemOutputEntity getByItemid(String itemid, String resultstr) { + QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("itemid", itemid).eq("resultstr", resultstr); + return mmItemOutputDao.selectOne(queryWrapper); + } + + @Override public void deleteByItemId(String itemId) { QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper(); queryWrapper.eq("itemid", itemId); diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java new file mode 100644 index 0000000..409434a --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultJsonServiceImpl.java @@ -0,0 +1,41 @@ +package com.iailab.module.model.mcs.pre.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.module.model.mcs.pre.dao.MmItemResultJsonDao; +import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; +import com.iailab.module.model.mcs.pre.service.MmItemResultJsonService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月14日 + */ +@Service +public class MmItemResultJsonServiceImpl extends BaseServiceImpl<MmItemResultJsonDao, MmItemResultJsonEntity> + implements MmItemResultJsonService { + + @Override + public List<Object[]> getData(String outputId, Date predictTime) { + List<Object[]> result = new ArrayList<>(); + QueryWrapper<MmItemResultJsonEntity> wrapper = new QueryWrapper<>(); + wrapper.eq("outputid", outputId) + .eq("predicttime", predictTime); + MmItemResultJsonEntity data = baseDao.selectOne(wrapper); + if (data == null || StringUtils.isBlank(data.getJsonvalue())) { + return result; + } + result = JSONArray.parseArray(data.getJsonvalue(), Object[].class); + result.forEach(item -> { + item[0] = new Date(Long.parseLong(item[0].toString())); + }); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java new file mode 100644 index 0000000..fca0cd5 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultLastPointServiceImpl.java @@ -0,0 +1,44 @@ +package com.iailab.module.model.mcs.pre.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.iailab.framework.common.service.impl.BaseServiceImpl; +import com.iailab.framework.common.util.date.DateUtils; +import com.iailab.module.model.mcs.pre.dao.MmItemResultLastPointDao; +import com.iailab.module.model.mcs.pre.entity.MmItemResultLastPointEntity; +import com.iailab.module.model.mcs.pre.service.MmItemResultLastPointService; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月14日 + */ +@Service +public class MmItemResultLastPointServiceImpl extends BaseServiceImpl<MmItemResultLastPointDao, MmItemResultLastPointEntity> + implements MmItemResultLastPointService { + + @Override + public List<Object[]> getData(String outputid, Date startTime, Date endTime) { + List<Object[]> result = new ArrayList<>(); + QueryWrapper<MmItemResultLastPointEntity> queryWrapper = new QueryWrapper<MmItemResultLastPointEntity>() + .eq("outputid", outputid) + .between("datatime", startTime, endTime) + .orderByAsc("datatime"); + List<MmItemResultLastPointEntity> list = baseDao.selectList(queryWrapper); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + Object[] dataItem = new Object[2]; + dataItem[0] = DateUtils.format(item.getDatatime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); + dataItem[1] = item.getDatavalue(); + result.add(dataItem); + }); + return result; + } +} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java index 03e3c52..a953fe5 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemResultServiceImpl.java @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.iailab.framework.common.util.date.DateUtils; import com.iailab.module.model.mcs.pre.dao.MmItemResultDao; import com.iailab.module.model.mcs.pre.entity.MmItemResultEntity; import com.iailab.module.model.mcs.pre.entity.MmItemResultJsonEntity; @@ -140,4 +141,24 @@ }).collect(Collectors.toList()); return result; } + + @Override + public List<Object[]> getData(String outputid, Date startTime, Date endTime) { + List<Object[]> result = new ArrayList<>(); + QueryWrapper<MmItemResultEntity> queryWrapper = new QueryWrapper<MmItemResultEntity>() + .eq("outputid", outputid) + .between("datatime", startTime, endTime) + .orderByAsc("datatime"); + List<MmItemResultEntity> list = mmItemResultDao.selectList(queryWrapper); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + Object[] dataItem = new Object[2]; + dataItem[0] = DateUtils.format(item.getDatatime(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND); + dataItem[1] = item.getDatavalue(); + result.add(dataItem); + }); + return result; + } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java index a1bf58c..5b1b9e5 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictItemServiceImpl.java @@ -75,12 +75,6 @@ return mmPredictItemDao.selectById(id); } - @Override - public List<Object[]> getHisData(String itemId, Date startTime, Date endTime) { - List<Object[]> result = new ArrayList<>(); - return result; - } - @DSTransactional(rollbackFor = Exception.class) @Override public void add(MmPredictItemDTO mmPredictItemDto) { diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreDataBarLineVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreDataBarLineVO.java deleted file mode 100644 index e3f4458..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreDataBarLineVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.iailab.module.model.mcs.pre.vo; - -import lombok.Data; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年08月01日 - */ -@Data -public class PreDataBarLineVO implements Serializable { - private static final long serialVersionUID = 1L; - - private Date predictTime; - - private Date startTime; - - private Date endTime; - - private List<String> legend; - - private List<String> categories; - - private List<PreDataViewVO> dataViewList; - -} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreDataViewVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreDataViewVO.java deleted file mode 100644 index 6b1f955..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreDataViewVO.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.iailab.module.model.mcs.pre.vo; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年07月31日 - */ -@Data -public class PreDataViewVO implements Serializable { - private static final long serialVersionUID = 1L; - - private String itemId; - - private String itemName; - - private Date predictTime; - - private BigDecimal rangeH; - - private BigDecimal rangeL; - - private BigDecimal deadLineH; - - private BigDecimal deadLineL; - - private BigDecimal limtH; - - private BigDecimal limtL; - - private BigDecimal maxValue; - - private BigDecimal minValue; - - private BigDecimal hisMax; - - private BigDecimal hisMin; - - private BigDecimal hisAvg; - - private BigDecimal hisCumulant; - - private BigDecimal preMax; - - private BigDecimal preMin; - - private BigDecimal preAvg; - - private BigDecimal preCumulant; - - private Map<String, Object> prop; - - /** - * 真实值 - */ - private List<Object[]> realData; - - /** - * T+N预测值,N表示预测频率 - */ - private List<Object[]> preDataN; - - /** - * T+L预测值,L表示预测长度 - */ - private List<Object[]> preDataL; - - /** - * 当时预测值 - */ - private List<Object[]> curData; - - /** - * 调整值 - */ - private List<Object[]> adjData; -} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreItemOptionVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreItemOptionVO.java deleted file mode 100644 index 5a67166..0000000 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/PreItemOptionVO.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.iailab.module.model.mcs.pre.vo; - -import lombok.Data; - -import java.io.Serializable; -import java.util.List; - -/** - * @author PanZhibao - * @Description - * @createTime 2024年07月31日 - */ -@Data -public class PreItemOptionVO implements Serializable { - private static final long serialVersionUID = 1L; - - private String id; - - private String label; - - private List<PreItemOptionVO> children; -} \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/ItemVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/ItemVO.java index a6efdcf..ce35e63 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/ItemVO.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/vo/ItemVO.java @@ -2,6 +2,8 @@ import lombok.Data; +import java.util.Date; + /** * @author PanZhibao * @Description @@ -31,4 +33,9 @@ * 项目id */ private String mpkProjectId; + + /** + * 最后运行时间 + */ + private Date lastTime; } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml index 11b097b..5bda3f9 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/MmPredictItemDao.xml @@ -14,6 +14,7 @@ <result property="isFuse" column="ISFUSE"/> <result property="predictPhase" column="PREDICTPHASE"/> <result property="workChecked" column="WORKCHECKED"/> + <result property="lastTime" column="last_time"/> </resultMap> <resultMap id="MergeItemVO" type="com.iailab.module.model.mdk.vo.MergeItemVO"> @@ -134,17 +135,20 @@ t1.status, t1.isfuse, t1.predictphase, - t1.workchecked + t1.workchecked, + t3.last_time FROM - t_mm_predict_item t1, - t_mm_item_type t2 - WHERE t1.itemtypeid=t2.id - <if test="ITEMID != null and ITEMID != ''"> - AND t1.id=#{ITEMID} - </if> - <if test="ITEMNO != null and ITEMNO != ''"> - t1.itemno=#{ITEMNO} - </if> + t_mm_predict_item t1 + LEFT JOIN t_mm_item_type t2 on t2.id = t1.itemtypeid + LEFT JOIN t_mm_item_status t3 on t3.item_id = t1.id + <where> + <if test="ITEMID != null and ITEMID != ''"> + AND t1.id=#{ITEMID} + </if> + <if test="ITEMNO != null and ITEMNO != ''"> + t1.itemno=#{ITEMNO} + </if> + </where> </select> <select id="getMergeItemByItemId" parameterType="map" resultMap="MergeItemVO"> SELECT t1.id, -- Gitblit v1.9.3