From c5fe30af6e6d1a72503d65f59532990f8b7fe070 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 26 十一月 2024 16:36:42 +0800 Subject: [PATCH] 预警信息 API --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java | 1 - iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java | 2 ++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java | 12 ++++++++++++ iailab-module-model/iailab-module-model-api/src/main/java/com/iailab/module/model/api/mcs/McsApi.java | 4 ++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/api/McsApiImpl.java | 24 +++++++++++++++++++++++- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java index 3913af3..339c042 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/api/controller/admin/ApiDataController.java @@ -38,7 +38,6 @@ import javax.annotation.security.PermitAll; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; 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 ee39d33..424a1c6 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,6 +52,10 @@ @Operation(summary = "获取预警信息列表") List<AlarmMessageRespDTO> listAlarmMessage(@RequestParam Map<String, Object> params); + @GetMapping(PREFIX + "/alarm-message/last") + @Operation(summary = "获取最新预警信息") + AlarmMessageRespDTO getLastAlarmMessage(@RequestParam("alarmObj") String alarmObj); + @PostMapping(PREFIX + "/schedule-suggest/create") @Operation(summary = "添加调度建议") Boolean createScheduleSuggest(@RequestBody ScheduleSuggestRespDTO dto); 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 3aa0c92..4d9fc79 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 @@ -15,7 +15,9 @@ import com.iailab.module.model.common.enums.PreLineTypeEnum; 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.MmPredictAlarmMessageEntity; import com.iailab.module.model.mcs.pre.service.*; +import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; import com.iailab.module.model.mdk.vo.ItemVO; import com.iailab.module.model.mpk.service.ChartService; import lombok.extern.slf4j.Slf4j; @@ -62,6 +64,9 @@ @Autowired private ChartService chartService; + + @Autowired + private MmPredictAlarmMessageService mmPredictAlarmMessageService; @Autowired private PlanItemApi planItemApi; @@ -452,9 +457,20 @@ return result; } + /** + * 新增预警信息 + * + * @param dto + * @return + */ @Override public Boolean createAlarmMessage(AlarmMessageRespDTO dto) { - return true; + try { + mmPredictAlarmMessageService.create(ConvertUtils.sourceToTarget(dto, MmPredictAlarmMessageSaveReqVO.class)); + return true; + } catch (Exception e) { + return false; + } } @Override @@ -463,6 +479,12 @@ } @Override + public AlarmMessageRespDTO getLastAlarmMessage(String alarmObj) { + MmPredictAlarmMessageEntity entity = mmPredictAlarmMessageService.getLast(alarmObj); + return ConvertUtils.sourceToTarget(entity, AlarmMessageRespDTO.class); + } + + @Override public Boolean createScheduleSuggest(ScheduleSuggestRespDTO dto) { return true; } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java index 3e1485e..5512dde 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/MmPredictAlarmMessageService.java @@ -17,6 +17,8 @@ MmPredictAlarmMessageEntity getInfo(String id); + MmPredictAlarmMessageEntity getLast(String alarmObj); + void create(MmPredictAlarmMessageSaveReqVO reqVO); void update(MmPredictAlarmMessageSaveReqVO reqVO); diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java index 33da851..1f55917 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmPredictAlarmMessageServiceImpl.java @@ -1,5 +1,6 @@ package com.iailab.module.model.mcs.pre.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; @@ -9,8 +10,10 @@ import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessagePageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageSaveReqVO; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.Date; +import java.util.List; import java.util.UUID; /** @@ -34,6 +37,15 @@ } @Override + public MmPredictAlarmMessageEntity getLast(String alarmObj) { + QueryWrapper<MmPredictAlarmMessageEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("alarm_obj", alarmObj) + .orderByDesc("alarm_time") + .last("limit 1"); + return baseDao.selectOne(queryWrapper); + } + + @Override public void create(MmPredictAlarmMessageSaveReqVO reqVO) { MmPredictAlarmMessageEntity entity = BeanUtils.toBean(reqVO, MmPredictAlarmMessageEntity.class); entity.setId(UUID.randomUUID().toString()); -- Gitblit v1.9.3