From 7587c74159ce4026baa811f25f306510569ee54a Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 20 三月 2025 17:32:02 +0800 Subject: [PATCH] 数据分析 预警,建议 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/DmModuleController.java | 1 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java | 28 ++++++++ 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 | 8 ++ 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/DmModuleItemServiceImpl.java | 14 ++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemOutputServiceImpl.java | 16 +++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/controller/admin/StScheduleSuggestController.java | 54 ++++++++++++++++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSuggestService.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleService.java | 2 iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/impl/StScheduleSuggestServiceImpl.java | 8 ++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleServiceImpl.java | 17 +++++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/vo/StScheduleSuggestPageReqVO.java | 9 +++ iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleItemService.java | 4 + iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java | 7 ++ 15 files changed, 172 insertions(+), 2 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/DmModuleController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/DmModuleController.java index 61826c0..5f9c705 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/DmModuleController.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/DmModuleController.java @@ -101,4 +101,5 @@ dmModuleService.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/controller/admin/MmPredictAlarmMessageController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java index 952913c..e300e92 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/controller/admin/MmPredictAlarmMessageController.java @@ -4,6 +4,9 @@ import com.iailab.framework.common.pojo.PageResult; import com.iailab.framework.common.util.object.BeanUtils; import com.iailab.module.model.mcs.pre.entity.MmPredictAlarmMessageEntity; +import com.iailab.module.model.mcs.pre.service.DmModuleItemService; +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.MmPredictAlarmMessageService; import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessagePageReqVO; import com.iailab.module.model.mcs.pre.vo.MmPredictAlarmMessageRespVO; @@ -15,6 +18,8 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; + +import java.util.List; import static com.iailab.framework.common.pojo.CommonResult.success; @@ -29,6 +34,15 @@ @Autowired private MmPredictAlarmMessageService mmPredictAlarmMessageService; + + @Autowired + private MmItemOutputService mmItemOutputService; + + @Autowired + private DmModuleItemService dmModuleItemService; + + @Autowired + private DmModuleService dmModuleService; @PostMapping("/create") @Operation(summary = "创建预警消息") @@ -50,7 +64,7 @@ @Operation(summary = "删除预警消息") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('pre:alarm-message:delete')") - public CommonResult<Boolean> deleteTenant(@RequestParam("id") String id) { + public CommonResult<Boolean> delete(@RequestParam("id") String id) { mmPredictAlarmMessageService.delete(id); return success(true); } @@ -67,8 +81,18 @@ @GetMapping("/page") @Operation(summary = "获得预警消息分页") @PreAuthorize("@ss.hasPermission('pre:alarm-message:query')") - public CommonResult<PageResult<MmPredictAlarmMessageRespVO>> getTenantPage(@Valid MmPredictAlarmMessagePageReqVO pageVO) { + public CommonResult<PageResult<MmPredictAlarmMessageRespVO>> getPage(@Valid MmPredictAlarmMessagePageReqVO pageVO) { PageResult<MmPredictAlarmMessageEntity> pageResult = mmPredictAlarmMessageService.page(pageVO); return success(BeanUtils.toBean(pageResult, MmPredictAlarmMessageRespVO.class)); } + + @PostMapping("/list-out") + @Operation(summary = "获得预警消息列表") + public CommonResult<List<MmPredictAlarmMessageRespVO>> getListByOut(@RequestBody MmPredictAlarmMessagePageReqVO pageVO) { + List<String> itemIds = mmItemOutputService.getItemIdByOut(pageVO.getOutIds()); + List<String> moduleIds = dmModuleItemService.getModuleIdByItemId(itemIds); + List<String> moduleList = dmModuleService.geModuleByIds(moduleIds); + List<MmPredictAlarmMessageEntity> list = mmPredictAlarmMessageService.getList(moduleList, pageVO.getPredictTime()); + return success(BeanUtils.toBean(list, MmPredictAlarmMessageRespVO.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/pre/service/DmModuleItemService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleItemService.java index d90da47..af9f5c5 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleItemService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleItemService.java @@ -2,6 +2,8 @@ import com.iailab.module.model.mcs.pre.entity.DmModuleItemEntity; +import java.util.List; + /** * @author PanZhibao * @date 2021年04月27日 9:11 @@ -11,4 +13,6 @@ void saveModuleItem(DmModuleItemEntity moduleItem); void update(DmModuleItemEntity moduleItem); + + List<String> getModuleIdByItemId(List<String> itemIds); } diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleService.java index fe83757..55fbf3e 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleService.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/DmModuleService.java @@ -33,4 +33,6 @@ DmModuleEntity getModuleByItemId(String itemId); void updatePredictTime(String id, Date predictTime); + + List<String> geModuleByIds(List<String> ids); } 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 195dcf0..e9e07f0 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,4 +27,6 @@ List<MmItemOutputEntity> getByItemid(String itemid, String resultstr, List<Integer> resultIndexs); void deleteByItemId(String itemId); + + List<String> getItemIdByOut(List<String> outIds); } 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 fc02943..5d0e46e 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 @@ -32,4 +32,6 @@ void delete(String id); void cleanAlarmMessage(Map<String, Date> tMap); + + List<MmPredictAlarmMessageEntity> getList(List<String> alarmObjList, 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/impl/DmModuleItemServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleItemServiceImpl.java index 52b4efe..66a8bbf 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleItemServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleItemServiceImpl.java @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -32,6 +33,19 @@ dmModuleItemDao.updateById(moduleItem); } + @Override + public List<String> getModuleIdByItemId(List<String> itemIds) { + List<String> result = new ArrayList<String>(); + QueryWrapper<DmModuleItemEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("itemid", itemIds); + List<DmModuleItemEntity> list = dmModuleItemDao.selectList(queryWrapper); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> result.add(item.getModuleid())); + return result; + } + public DmModuleItemEntity getByItemid(String itemid) { List<DmModuleItemEntity> list = dmModuleItemDao.selectList(new QueryWrapper<DmModuleItemEntity>().in("itemid", itemid)); if (CollectionUtils.isEmpty(list)) { diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleServiceImpl.java index 2ed8c90..ba748e2 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/DmModuleServiceImpl.java @@ -99,6 +99,23 @@ } @Override + public List<String> geModuleByIds(List<String> ids) { + List<String> result = new ArrayList<>(); + QueryWrapper<DmModuleEntity> wrapper = new QueryWrapper<>(); + wrapper.in("id", ids); + List<DmModuleEntity> list = dmModuleDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + if (StringUtils.isNotBlank(item.getModulenavconfig())) { + result.addAll(Arrays.asList(item.getModulenavconfig().split(","))); + } + }); + return result; + } + + @Override public int check(DmModuleEntity module) { String id = module.getId(); String modulename = module.getModulename(); 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 ff058ab..4011d56 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 @@ -11,6 +11,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -105,6 +106,21 @@ } @Override + public List<String> getItemIdByOut(List<String> outIds) { + List<String> result = new ArrayList<>(); + QueryWrapper<MmItemOutputEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("id", outIds); + List<MmItemOutputEntity> list = baseMapper.selectList(queryWrapper); + if (CollectionUtils.isEmpty(list)) { + return result; + } + list.forEach(item -> { + result.add(item.getId()); + }); + return result; + } + + @Override public MmItemOutputEntity getOutPutById(String outputid) { if (outputMap.containsKey(outputid)) { return outputMap.get(outputid); 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 f181254..057965d 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 @@ -47,6 +47,14 @@ } @Override + public List<MmPredictAlarmMessageEntity> getList(List<String> alarmObjList, Date predictTime) { + QueryWrapper<MmPredictAlarmMessageEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("alarm_obj", alarmObjList); + queryWrapper.eq("alarm_time", predictTime); + return baseDao.selectList(queryWrapper); + } + + @Override public List<MmPredictAlarmMessageEntity> getList(String alarmObj, Date alarmTime) { QueryWrapper<MmPredictAlarmMessageEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("alarm_obj", alarmObj) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java index e4e0f8b..042fde7 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/vo/MmPredictAlarmMessagePageReqVO.java @@ -7,6 +7,7 @@ import lombok.ToString; import java.util.Date; +import java.util.List; /** * @author PanZhibao @@ -36,4 +37,10 @@ @Schema(description = "结束时间", example = "") private Date endTime; + + @Schema(description = "预测时间", example = "") + private Date predictTime; + + @Schema(description = "输出ID", example = "") + private List<String> outIds; } \ 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/controller/admin/StScheduleSuggestController.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/controller/admin/StScheduleSuggestController.java new file mode 100644 index 0000000..4026a77 --- /dev/null +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/controller/admin/StScheduleSuggestController.java @@ -0,0 +1,54 @@ +package com.iailab.module.model.mcs.sche.controller.admin; + +import com.iailab.framework.common.pojo.CommonResult; +import com.iailab.framework.common.util.object.BeanUtils; +import com.iailab.module.model.mcs.pre.service.DmModuleItemService; +import com.iailab.module.model.mcs.pre.service.DmModuleService; +import com.iailab.module.model.mcs.pre.service.MmItemOutputService; +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.StScheduleSuggestRespVO; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static com.iailab.framework.common.pojo.CommonResult.success; + +/** + * @author PanZhibao + * @Description + * @createTime 2025年03月20日 + */ +@Tag(name = "模型服务 - 调度建议") +@RestController +@RequestMapping("/model/sche/suggest") +public class StScheduleSuggestController { + + @Autowired + private StScheduleSuggestService stScheduleSuggestService; + + @Autowired + private MmItemOutputService mmItemOutputService; + + @Autowired + private DmModuleItemService dmModuleItemService; + + @Autowired + private DmModuleService dmModuleService; + + @PostMapping("/list-out") + @Operation(summary = "获得预警消息列表") + public CommonResult<List<StScheduleSuggestRespVO>> getListByOut(StScheduleSuggestPageReqVO pageVO) { + List<String> itemIds = mmItemOutputService.getItemIdByOut(pageVO.getOutIds()); + List<String> moduleIds = dmModuleItemService.getModuleIdByItemId(itemIds); + List<String> moduleList = dmModuleService.geModuleByIds(moduleIds); + List<StScheduleSuggestEntity> list = stScheduleSuggestService.getList(moduleList, pageVO.getPredictTime()); + return success(BeanUtils.toBean(list, StScheduleSuggestRespVO.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/service/StScheduleSuggestService.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/sche/service/StScheduleSuggestService.java index c0a9778..4fae173 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 @@ -34,4 +34,6 @@ void cleanScheduleSuggest(Map<String, Date> tMap); List<ScheduleSuggestRespDTO> list(ScheduleSuggestReqDTO vo); + + List<StScheduleSuggestEntity> getList(List<String> scheduleObjList, Date predictTime); } 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 27b279d..32a5dbb 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 @@ -82,4 +82,12 @@ .le(null != vo.getEndTime(),"schedule_time",vo.getEndTime()); return ConvertUtils.sourceToTarget(baseDao.selectList(queryWrapper),ScheduleSuggestRespDTO.class); } + + @Override + public List<StScheduleSuggestEntity> getList(List<String> scheduleObjList, Date predictTime) { + QueryWrapper<StScheduleSuggestEntity> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("schedule_obj", scheduleObjList); + queryWrapper.eq("schedule_time", predictTime); + 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 index 1bc0564..787c8ff 100644 --- 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 @@ -6,6 +6,9 @@ import lombok.EqualsAndHashCode; import lombok.ToString; +import java.util.Date; +import java.util.List; + /** * @author PanZhibao * @Description @@ -22,4 +25,10 @@ @Schema(description = "调整对象,模糊匹配", example = "") private String scheduleObj; + + @Schema(description = "预测时间", example = "") + private Date predictTime; + + @Schema(description = "输出ID", example = "") + private List<String> outIds; } \ No newline at end of file -- Gitblit v1.9.3