From 0a7d0fda65fc792d4549c266001f890c1a201e16 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期三, 08 一月 2025 08:20:43 +0800 Subject: [PATCH] 获取预警信息和调度建议分页列表 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSchemeDao.java | 10 +++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/StAlarmAndSuggestRespVO.java | 36 ++++++++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java | 9 +++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSchemeService.java | 4 + iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java | 5 + iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/StAlarmAndSuggestPageReqVO.java | 30 ++++++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java | 11 +++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java | 6 ++ iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StScheduleSchemeDao.xml | 33 +++++++++++ 9 files changed, 144 insertions(+), 0 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 97c9b8b..0858715 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,5 +1,6 @@ package com.iailab.module.model.api.mcs; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.module.model.api.mcs.dto.*; import com.iailab.module.model.enums.ApiConstants; import io.swagger.v3.oas.annotations.Operation; @@ -91,4 +92,8 @@ @GetMapping(PREFIX + "/chart/param/list") @Operation(summary = "图表配置列表") List<ChartParamDTO> getChartParamList(@RequestParam("chartCode") String chartCode); + + @PostMapping(PREFIX + "/alarm-suggest/page") + @Operation(summary = "获取预警信息和调度建议分页列表") + PageResult<StAlarmAndSuggestRespVO> getAlarmAndSuggestPage(@RequestBody StAlarmAndSuggestPageReqVO reqVO); } \ 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/StAlarmAndSuggestPageReqVO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/StAlarmAndSuggestPageReqVO.java new file mode 100644 index 0000000..e46f344 --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/StAlarmAndSuggestPageReqVO.java @@ -0,0 +1,30 @@ +package com.iailab.module.model.api.mcs.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.iailab.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2025年01月07日 + */ +@Schema(description = "RPC 模型 - 预警和建议 DTO") +@Data +public class StAlarmAndSuggestPageReqVO extends PageParam { + + @Schema(description = "对象") + private String obj; + + @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/StAlarmAndSuggestRespVO.java b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/StAlarmAndSuggestRespVO.java new file mode 100644 index 0000000..c9678be --- /dev/null +++ b/iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/dto/StAlarmAndSuggestRespVO.java @@ -0,0 +1,36 @@ +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; + +/** + * @author PanZhibao + * @Description + * @createTime 2025年01月07日 + */ +@Schema(description = "RPC 模型 - 预警和建议 DTO") +@Data +public class StAlarmAndSuggestRespVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @Schema(description = "类型(1:预警,2:建议)") + private String type; + + @Schema(description = "消息标题") + private String title; + + @Schema(description = "消息内容") + private String content; + + @Schema(description = "对象") + private String obj; + + @Schema(description = "时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date time; +} \ 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 index 8ea2538..d918e48 100644 --- 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 @@ -1,5 +1,6 @@ package com.iailab.module.model.api; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.date.DateUtils; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.data.api.plan.PlanItemApi; @@ -569,6 +570,11 @@ return chartParamService.list(chartCode); } + @Override + public PageResult<StAlarmAndSuggestRespVO> getAlarmAndSuggestPage(StAlarmAndSuggestPageReqVO reqVO) { + return stScheduleSchemeService.getAlarmAndSuggestPage(reqVO); + } + private Date[] calResultTime(ItemVO predictItem, Date startTimeReq, Date endTimeReq, int lengthLeft, int lengthRight) { Date[] result = new Date[3]; Date predictTime = predictItem.getLastTime(); diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java index 9d270d6..3e1bc65 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java @@ -1,6 +1,8 @@ package com.iailab.module.model.api.controller.admin; 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.api.mcs.McsApi; import com.iailab.module.model.api.mcs.dto.*; import com.iailab.module.model.common.utils.ApiSecurityUtils; @@ -19,6 +21,8 @@ import java.util.Date; import java.util.List; import java.util.Map; + +import static com.iailab.framework.common.pojo.CommonResult.success; /** * @author PanZhibao @@ -145,4 +149,11 @@ List<ScheduleSuggestRespDTO> data = mcsApi.getLastLimitScheduleSuggest(scheduleObj, limit); return CommonResult.success(data); } + + @GetMapping("/alarm-suggest/page") + @Operation(summary = "获取预警信息和调度建议分页列表") + public CommonResult<PageResult<StAlarmAndSuggestRespVO>> getAlarmAndSuggestPage(@RequestBody StAlarmAndSuggestPageReqVO reqVO) { + PageResult<StAlarmAndSuggestRespVO> page = mcsApi.getAlarmAndSuggestPage(reqVO); + return success(BeanUtils.toBean(page, StAlarmAndSuggestRespVO.class)); + } } \ No newline at end of file diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSchemeDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSchemeDao.java index 6a87c53..ceda199 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSchemeDao.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSchemeDao.java @@ -1,12 +1,16 @@ package com.iailab.module.model.mcs.sche.dao; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.mybatis.core.mapper.BaseMapperX; import com.iailab.framework.mybatis.core.query.LambdaQueryWrapperX; import com.iailab.framework.tenant.core.db.dynamic.TenantDS; +import com.iailab.module.model.api.mcs.dto.StAlarmAndSuggestPageReqVO; +import com.iailab.module.model.api.mcs.dto.StAlarmAndSuggestRespVO; import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity; import com.iailab.module.model.mcs.sche.vo.StScheduleSchemePageReqVO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.Map; @@ -23,4 +27,10 @@ .likeIfPresent(StScheduleSchemeEntity::getName, reqVO.getName()) .orderByDesc(StScheduleSchemeEntity::getCreateTime)); } + + IPage<StAlarmAndSuggestRespVO> getAlarmAndSuggestPage(IPage<StScheduleSchemeEntity> page, @Param("params") StAlarmAndSuggestPageReqVO reqVO); + + default IPage<StAlarmAndSuggestRespVO> selectAlarmAndSuggestPageList(StAlarmAndSuggestPageReqVO reqVO) { + return getAlarmAndSuggestPage(getPage(reqVO), reqVO); + } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSchemeService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSchemeService.java index 63e8012..d071770 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSchemeService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSchemeService.java @@ -2,6 +2,8 @@ import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.BaseService; +import com.iailab.module.model.api.mcs.dto.StAlarmAndSuggestPageReqVO; +import com.iailab.module.model.api.mcs.dto.StAlarmAndSuggestRespVO; import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; import com.iailab.module.model.mcs.sche.entity.StScheduleSchemeEntity; import com.iailab.module.model.mcs.sche.vo.StScheduleSchemePageReqVO; @@ -36,4 +38,6 @@ void enableByIds(String[] ids); void disableByIds(String[] ids); + + PageResult<StAlarmAndSuggestRespVO> getAlarmAndSuggestPage(StAlarmAndSuggestPageReqVO reqVO); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java index b395057..dde4144 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSchemeServiceImpl.java @@ -2,11 +2,14 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.impl.BaseServiceImpl; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.module.model.api.mcs.dto.AlarmConfigRespDTO; +import com.iailab.module.model.api.mcs.dto.StAlarmAndSuggestPageReqVO; +import com.iailab.module.model.api.mcs.dto.StAlarmAndSuggestRespVO; import com.iailab.module.model.api.mcs.dto.StScheduleSchemeDTO; import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmConfigEntity; import com.iailab.module.model.mcs.sche.dao.StScheduleSchemeDao; @@ -107,4 +110,10 @@ baseDao.updateById(entity); }); } + + @Override + public PageResult<StAlarmAndSuggestRespVO> getAlarmAndSuggestPage(StAlarmAndSuggestPageReqVO reqVO) { + IPage<StAlarmAndSuggestRespVO> page = baseDao.selectAlarmAndSuggestPageList(reqVO); + return new PageResult<>(page.getRecords(), page.getTotal()); + } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StScheduleSchemeDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StScheduleSchemeDao.xml new file mode 100644 index 0000000..e9d9a3e --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StScheduleSchemeDao.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="com.iailab.module.model.mcs.sche.dao.StScheduleSchemeDao"> + + <select id="getAlarmAndSuggestPage" resultType="com.iailab.module.model.api.mcs.dto.StAlarmAndSuggestRespVO"> + select + t.type, + t.title, + t.content, + t.time, + t.obj + from ( + select 'alarm' type, t1.title, t1.content, t1.alarm_time `time`, t1.alarm_obj obj + from t_mm_predict_alarm_message t1 + UNION + select 'suggest' type, t2.title, t2.content, t2.schedule_time `time`, t2.schedule_obj obj + from t_st_schedule_suggest t2 + ) t + <where> + <if test="params.obj != null and params.obj != ''"> + and t.obj = #{obj} + </if> + <if test="params.startTime != null and params.startTime != ''"> + and t.time >= #{startTime} + </if> + <if test="params.endTime != null and params.endTime != ''"> + and t.time <= #{endTime} + </if> + </where> + order by t.time desc + + </select> +</mapper> \ No newline at end of file -- Gitblit v1.9.3