From 05576523a8626d34aaa1a47f1dfdcad7710482b4 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期三, 27 十一月 2024 13:35:45 +0800 Subject: [PATCH] 调度建议 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSuggestServiceImpl.java | 46 +++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSuggestDao.java | 10 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleSuggestEntity.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestPageReqVO.java | 25 ++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestSaveReqVO.java | 88 ++++++++++++++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java | 6 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/controller/admin/McsApiController.java | 24 +++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestRespVO.java | 83 +++++++++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java | 10 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSuggestService.java | 17 ++ 10 files changed, 301 insertions(+), 10 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 424a1c6..b80ba25 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 @@ -52,7 +52,7 @@ @Operation(summary = "获取预警信息列表") List<AlarmMessageRespDTO> listAlarmMessage(@RequestParam Map<String, Object> params); - @GetMapping(PREFIX + "/alarm-message/last") + @GetMapping(PREFIX + "/alarm-message/last-one") @Operation(summary = "获取最新预警信息") AlarmMessageRespDTO getLastAlarmMessage(@RequestParam("alarmObj") String alarmObj); @@ -60,9 +60,9 @@ @Operation(summary = "添加调度建议") Boolean createScheduleSuggest(@RequestBody ScheduleSuggestRespDTO dto); - @GetMapping(PREFIX + "/schedule-suggest/list") + @GetMapping(PREFIX + "/schedule-suggest/last-limit") @Operation(summary = "获取调度建议列表") - List<ScheduleSuggestRespDTO> listScheduleSuggest(@RequestParam ScheduleSuggestReqDTO params); + List<ScheduleSuggestRespDTO> getLastLimitScheduleSuggest(@RequestParam("scheduleObj") String scheduleObj, @RequestParam("limit") Integer limit); @PostMapping(PREFIX + "/predict-model-setting/modify") @Operation(summary = "修改预测模型设置参数") 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 4d9fc79..c88e4d7 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 @@ -18,6 +18,8 @@ import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity; import com.iailab.module.model.mcs.pre.service.*; import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; +import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity; +import com.iailab.module.model.mcs.sche.service.StScheduleSuggestService; import com.iailab.module.model.mdk.vo.ItemVO; import com.iailab.module.model.mpk.service.ChartService; import lombok.extern.slf4j.Slf4j; @@ -67,6 +69,9 @@ @Autowired private MmPredictAlarmMessageService mmPredictAlarmMessageService; + + @Autowired + private StScheduleSuggestService stScheduleSuggestService; @Autowired private PlanItemApi planItemApi; @@ -490,8 +495,9 @@ } @Override - public List<ScheduleSuggestRespDTO> listScheduleSuggest(ScheduleSuggestReqDTO params) { - return null; + public List<ScheduleSuggestRespDTO> getLastLimitScheduleSuggest(String scheduleObj, Integer limit) { + List<StScheduleSuggestEntity> list = stScheduleSuggestService.getList(scheduleObj, limit); + return ConvertUtils.sourceToTarget(list, ScheduleSuggestRespDTO.class); } @Override 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 a0421b1..41b12ec 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 @@ -19,6 +19,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; + import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; /** @@ -90,7 +91,6 @@ @GetMapping("/predict-data/exportValue") @Operation(summary = "导出预测数据") - @ApiAccessLog(operateType = EXPORT) public void exportPointValue(@RequestParam("itemId") String itemId, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime, @@ -100,13 +100,13 @@ reqVO.setItemId(itemId); try { if (startTime == "") { - reqVO.setStartTime(new Date((new Date()).getTime() - 60*60*1000)); + reqVO.setStartTime(new Date((new Date()).getTime() - 60 * 60 * 1000)); } else { reqVO.setStartTime(formatter.parse(startTime)); } if (endTime == "") { - reqVO.setEndTime(new Date((new Date()).getTime() + 60*60*1000)); + reqVO.setEndTime(new Date((new Date()).getTime() + 60 * 60 * 1000)); } else { reqVO.setEndTime(formatter.parse(endTime)); } @@ -115,10 +115,26 @@ } PreDataItemChartRespVO respVO = mcsApi.getPreDataItemChart(reqVO); try { - String sheetTitle = "sheet1"; + String sheetTitle = "sheet1"; ExcelUtil.exportchart(sheetTitle, respVO, response); } catch (Exception ex) { ex.printStackTrace(); } } + + @GetMapping("/alarm-message/last-one") + @Operation(summary = "根据监控对象获取最新预警信息") + public CommonResult<AlarmMessageRespDTO> getLastAlarmMessage(HttpServletResponse response, HttpServletRequest + request, @RequestParam("alarmObj") String alarmObj) { + AlarmMessageRespDTO data = mcsApi.getLastAlarmMessage(alarmObj); + return CommonResult.success(data); + } + + @GetMapping("/schedule-suggest/last-limit") + @Operation(summary = "根据监控对象获取最新预警信息") + public CommonResult<List<ScheduleSuggestRespDTO>> getLastLimitScheduleSuggest(HttpServletResponse response, HttpServletRequest + request, @RequestParam("scheduleObj") String scheduleObj, @RequestParam("limit") Integer limit) { + List<ScheduleSuggestRespDTO> data = mcsApi.getLastLimitScheduleSuggest(scheduleObj, limit); + return CommonResult.success(data); + } } \ 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/StScheduleSuggestDao.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSuggestDao.java index 23fab12..ea81414 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSuggestDao.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/dao/StScheduleSuggestDao.java @@ -1,8 +1,11 @@ package com.iailab.module.model.mcs.sche.dao; +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.mcs.sche.entity.StScheduleSuggestEntity; +import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestPageReqVO; import org.apache.ibatis.annotations.Mapper; /** @@ -13,4 +16,11 @@ @TenantDS @Mapper public interface StScheduleSuggestDao extends BaseMapperX<StScheduleSuggestEntity> { + + default PageResult<StScheduleSuggestEntity> selectPage(StScheduleSuggestPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX<StScheduleSuggestEntity>() + .likeIfPresent(StScheduleSuggestEntity::getTitle, reqVO.getTitle()) + .likeIfPresent(StScheduleSuggestEntity::getScheduleObj, reqVO.getScheduleObj()) + .orderByDesc(StScheduleSuggestEntity::getCreateTime)); + } } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleSuggestEntity.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleSuggestEntity.java index babae42..9dda28a 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleSuggestEntity.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/entity/StScheduleSuggestEntity.java @@ -111,7 +111,7 @@ private Date scheduleTime; /** - * 状态 + * 状态(0未处理 1已采纳 2已忽略) */ private Integer status; diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSuggestService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSuggestService.java index 72104b3..489487f 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSuggestService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSuggestService.java @@ -1,7 +1,12 @@ package com.iailab.module.model.mcs.sche.service; +import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.service.BaseService; import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity; +import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestPageReqVO; +import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestSaveReqVO; + +import java.util.List; /** * @author PanZhibao @@ -9,4 +14,16 @@ * @createTime 2024年09月06日 */ public interface StScheduleSuggestService extends BaseService<StScheduleSuggestEntity> { + + PageResult<StScheduleSuggestEntity> page(StScheduleSuggestPageReqVO reqVO); + + void create(StScheduleSuggestSaveReqVO createReqVO); + + void update(StScheduleSuggestSaveReqVO createReqVO); + + void delete(String id); + + StScheduleSuggestEntity getInfo(String id); + + List<StScheduleSuggestEntity> getList(String scheduleObj, Integer limit); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSuggestServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSuggestServiceImpl.java index 32b7055..46cdb20 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSuggestServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSuggestServiceImpl.java @@ -1,10 +1,18 @@ package com.iailab.module.model.mcs.sche.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +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.module.model.mcs.sche.dao.StScheduleSuggestDao; import com.iailab.module.model.mcs.sche.entity.StScheduleSuggestEntity; import com.iailab.module.model.mcs.sche.service.StScheduleSuggestService; +import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestPageReqVO; +import com.iailab.module.model.mcs.sche.vo.StScheduleSuggestSaveReqVO; import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.UUID; /** * @author PanZhibao @@ -14,4 +22,42 @@ @Service public class StScheduleSuggestServiceImpl extends BaseServiceImpl<StScheduleSuggestDao, StScheduleSuggestEntity> implements StScheduleSuggestService { + + @Override + public PageResult<StScheduleSuggestEntity> page(StScheduleSuggestPageReqVO reqVO) { + return baseDao.selectPage(reqVO); + } + + @Override + public void create(StScheduleSuggestSaveReqVO createReqVO) { + StScheduleSuggestEntity entity = BeanUtils.toBean(createReqVO, StScheduleSuggestEntity.class); + entity.setId(UUID.randomUUID().toString()); + baseDao.insert(entity); + } + + @Override + public void update(StScheduleSuggestSaveReqVO createReqVO) { + StScheduleSuggestEntity entity = BeanUtils.toBean(createReqVO, StScheduleSuggestEntity.class); + baseDao.updateById(entity); + } + + @Override + public void delete(String id) { + baseDao.deleteById(id); + } + + @Override + public StScheduleSuggestEntity getInfo(String id) { + return baseDao.selectById(id); + } + + @Override + public List<StScheduleSuggestEntity> getList(String scheduleObj, Integer limit) { + QueryWrapper<StScheduleSuggestEntity> queryWrapper = new QueryWrapper<>(); + limit = limit == null ? 1 : limit; + queryWrapper.eq("schedule_obj", scheduleObj) + .orderByDesc("create_time") + .last("limit " + limit); + return baseDao.selectList(queryWrapper); + } } \ 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/vo/StScheduleSuggestPageReqVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestPageReqVO.java new file mode 100644 index 0000000..1bc0564 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestPageReqVO.java @@ -0,0 +1,25 @@ +package com.iailab.module.model.mcs.sche.vo; + +import com.iailab.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月27日 + */ +@Schema(description = "模型服务 - 调度建议分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class StScheduleSuggestPageReqVO extends PageParam { + + @Schema(description = "标题,模糊匹配", example = "") + private String title; + + @Schema(description = "调整对象,模糊匹配", example = "") + private String scheduleObj; +} \ 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/vo/StScheduleSuggestRespVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestRespVO.java new file mode 100644 index 0000000..7c3e0e7 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestRespVO.java @@ -0,0 +1,83 @@ +package com.iailab.module.model.mcs.sche.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月27日 + */ +@Schema(description = "模型服务 - 调度建议 Response VO") +@Data +public class StScheduleSuggestRespVO { + + @Schema(description = "ID") + private String id; + + @Schema(description = "标题") + private String title; + + @Schema(description = "内容") + private String content; + + @Schema(description = "排序") + private Integer sort; + + @Schema(description = "方案ID") + private String schemeId; + + @Schema(description = "预警ID") + private String alarmId; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "模型ID") + private String modelId; + + @Schema(description = "调整对象") + private String scheduleObj; + + @Schema(description = "调整类型") + private String scheduleType; + + @Schema(description = "调整策略") + private String scheduleStrategy; + + @Schema(description = "调整方式") + private String adjustMode; + + @Schema(description = "调整值") + private BigDecimal adjustValue; + + @Schema(description = "调整单位") + private String adjustUnit; + + @Schema(description = "持续时长") + private BigDecimal adjustTimes; + + @Schema(description = "调整开始时间") + private Date adjustStart; + + @Schema(description = "调整结束时间") + private Date adjustEnd; + + @Schema(description = "调度时间") + private Date scheduleTime; + + @Schema(description = "状态(0未处理 1已采纳 2已忽略)") + private Integer status; + + @Schema(description = "处理人") + private String handler; + + @Schema(description = "处理时间") + private Date handleTime; + + @Schema(description = "创建时间") + private Date createTime; +} \ 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/vo/StScheduleSuggestSaveReqVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestSaveReqVO.java new file mode 100644 index 0000000..fa3a51b --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestSaveReqVO.java @@ -0,0 +1,88 @@ +package com.iailab.module.model.mcs.sche.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author PanZhibao + * @Description + * @createTime 2024年11月27日 + */ +@Schema(description = "模型服务 - 调度建议创建/修改 Request VO") +@Data +public class StScheduleSuggestSaveReqVO { + + @Schema(description = "ID") + private String id; + + @Schema(description = "标题") + @NotNull(message = "应用编号不能为空") + private String title; + + @Schema(description = "内容") + @NotNull(message = "应用编号不能为空") + private String content; + + @Schema(description = "排序") + @NotNull(message = "应用编号不能为空") + private Integer sort; + + @Schema(description = "方案ID") + private String schemeId; + + @Schema(description = "预警ID") + private String alarmId; + + @Schema(description = "预测项ID") + private String itemId; + + @Schema(description = "模型ID") + private String modelId; + + @Schema(description = "调整对象") + @NotNull(message = "应用编号不能为空") + private String scheduleObj; + + @Schema(description = "调整类型") + private String scheduleType; + + @Schema(description = "调整策略") + private String scheduleStrategy; + + @Schema(description = "调整方式") + private String adjustMode; + + @Schema(description = "调整值") + private BigDecimal adjustValue; + + @Schema(description = "调整单位") + private String adjustUnit; + + @Schema(description = "持续时长") + private BigDecimal adjustTimes; + + @Schema(description = "调整开始时间") + private Date adjustStart; + + @Schema(description = "调整结束时间") + private Date adjustEnd; + + @Schema(description = "调度时间") + private Date scheduleTime; + + @Schema(description = "状态(0未处理 1已采纳 2已忽略)") + private Integer status; + + @Schema(description = "处理人") + private String handler; + + @Schema(description = "处理时间") + private Date handleTime; + + @Schema(description = "创建时间") + private Date createTime; +} \ No newline at end of file -- Gitblit v1.9.3