From d26cb9e1ceea094b0bb428bed93e3e811d16ae15 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Tue, 5 Dec 2023 15:43:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=81=BF=E8=83=BD=E4=BA=91=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=A7=BB=E6=A4=8D,=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/njcn/cloud/pojo/dto/AppEventMsg.java | 6 ++ .../com/njcn/cloud/pojo/dto/AppInfoSet.java | 2 +- .../njcn/cloud/pojo/vo/DevMsgDetailInfo.java | 97 +++++++++++-------- .../njcn/cloud/pojo/vo/EventMsgDetailVO.java | 50 ++++++---- .../njcn/cloud/AppCloudBootApplication.java | 3 + .../RealTimeInfo/RealTimeInfoController.java | 45 +++++++++ .../information/DevMsgController.java | 10 +- .../information/EventMsgController.java | 6 +- .../information/SteadyMsgController.java | 4 +- .../message/EventMsgPushController.java | 8 +- .../cloud/controller/task/SteadyMsgTask.java | 9 +- .../impl/user/AppDevMsgServiceImpl.java | 42 +++++--- .../impl/user/AppEventMsgServiceImpl.java | 25 +++-- .../service/impl/user/MsgServiceImpl.java | 28 ++++-- .../impl/user/RealTimeInfoServiceImpl.java | 27 ++++++ .../cloud/service/user/IAppDevMsgService.java | 2 +- .../service/user/IAppEventMsgService.java | 2 +- .../service/user/RealTimeInfoService.java | 18 ++++ 18 files changed, 268 insertions(+), 116 deletions(-) create mode 100644 app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/RealTimeInfo/RealTimeInfoController.java create mode 100644 app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/RealTimeInfoServiceImpl.java create mode 100644 app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/RealTimeInfoService.java diff --git a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppEventMsg.java b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppEventMsg.java index 8d98537..4dcb9cb 100644 --- a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppEventMsg.java +++ b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppEventMsg.java @@ -3,6 +3,7 @@ package com.njcn.cloud.pojo.dto; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.njcn.db.bo.BaseEntity; import java.io.Serializable; import java.time.LocalDateTime; @@ -39,6 +40,11 @@ public class AppEventMsg { @TableField("EventDetail_Index") private String eventdetailIndex; + @ApiModelProperty("触发时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @TableField("Time_Id") + private LocalDateTime timeID; + @ApiModelProperty("读取状态(0:未读,1:已读,2:删除)") @TableField("state") private Integer state; diff --git a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppInfoSet.java b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppInfoSet.java index e0bfad7..9106e3c 100644 --- a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppInfoSet.java +++ b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/dto/AppInfoSet.java @@ -22,7 +22,7 @@ import lombok.Setter; @Setter @TableName("app_info_set") @ApiModel(value = "AppInfoSet对象", description = "推送消息设置") -public class AppInfoSet extends BaseEntity { +public class AppInfoSet { private static final long serialVersionUID = 1L; diff --git a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/DevMsgDetailInfo.java b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/DevMsgDetailInfo.java index e0a21a5..475af27 100644 --- a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/DevMsgDetailInfo.java +++ b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/DevMsgDetailInfo.java @@ -1,6 +1,7 @@ package com.njcn.cloud.pojo.vo; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,7 +10,6 @@ import java.io.Serializable; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -20,64 +20,75 @@ import java.util.stream.Collectors; */ @Data public class DevMsgDetailInfo implements Serializable { + @ApiModelProperty("未读条数") + Integer unstate; + @ApiModelProperty("终端信息") + Page page; - @ApiModelProperty("终端消息id") - private String topId; + @Data + public static class Unstate implements Serializable { + @ApiModelProperty("终端消息列表Guid") + private String devmsgIndex; - @ApiModelProperty("终端Id") - private String devIndex; + @ApiModelProperty("终端消息id") + private String topId; - @ApiModelProperty("供电公司") - private String gdName; + @ApiModelProperty("终端Id") + private String devIndex; - @ApiModelProperty("变电站名称") - private String bdzName; + @ApiModelProperty("供电公司") + private String gdName; - @ApiModelProperty("终端名称") - private String devName; + @ApiModelProperty("变电站名称") + private String bdzName; - @ApiModelProperty("ip") - private String ip; + @ApiModelProperty("终端名称") + private String devName; - @ApiModelProperty("统计时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime timeID; + @ApiModelProperty("ip") + private String ip; - @ApiModelProperty("总告警次数") - private Integer allNum; + @ApiModelProperty("统计时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime timeID; - @ApiModelProperty("终端告警") - private Integer alarmNum; + @ApiModelProperty("总告警次数") + private Integer allNum; - @ApiModelProperty("通讯中断") - private Integer comOutNum; + @ApiModelProperty("终端告警") + private Integer alarmNum; - @ApiModelProperty("终端流量百分比") - private Float flowNum; + @ApiModelProperty("通讯中断") + private Integer comOutNum; - @ApiModelProperty("中断描述") - private List comoutDesc; + @ApiModelProperty("终端流量百分比") + private Float flowNum; - @ApiModelProperty("告警描述") - private List alarmDesc; + @ApiModelProperty("中断描述") + private List comoutDesc; - @ApiModelProperty("读取状态") - private Integer state; - public void setComoutDesc(String comoutDesc) { - List collect =new ArrayList<>(); - if(StrUtil.isNotBlank(comoutDesc)){ - String[] split = comoutDesc.split(","); - collect = Arrays.stream(split).sorted().collect(Collectors.toList()); + @ApiModelProperty("告警描述") + private List alarmDesc; + + @ApiModelProperty("读取状态") + private Integer state; + + public void setComoutDesc(String comoutDesc) { + List collect = new ArrayList<>(); + if (StrUtil.isNotBlank(comoutDesc)) { + String[] split = comoutDesc.split(","); + collect = Arrays.stream(split).sorted().collect(Collectors.toList()); + } + this.comoutDesc = collect; } - this.comoutDesc = collect; - } - public void setAlarmDesc(String alarmDesc) { - List collect =new ArrayList<>(); - if(StrUtil.isNotBlank(alarmDesc)){ - String[] split = alarmDesc.split(","); - collect = Arrays.stream(split).sorted().collect(Collectors.toList()); + public void setAlarmDesc(String alarmDesc) { + List collect = new ArrayList<>(); + if (StrUtil.isNotBlank(alarmDesc)) { + String[] split = alarmDesc.split(","); + collect = Arrays.stream(split).sorted().collect(Collectors.toList()); + } + this.alarmDesc = collect; } - this.alarmDesc = collect; } } \ No newline at end of file diff --git a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/EventMsgDetailVO.java b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/EventMsgDetailVO.java index 98a92f3..59f4125 100644 --- a/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/EventMsgDetailVO.java +++ b/app-cloud/app-cloud-api/src/main/java/com/njcn/cloud/pojo/vo/EventMsgDetailVO.java @@ -1,5 +1,6 @@ package com.njcn.cloud.pojo.vo; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -16,37 +17,44 @@ import java.util.Date; */ @Data public class EventMsgDetailVO implements Serializable { + @ApiModelProperty("未读条数") + private Integer udState; - @ApiModelProperty("监测点Id") - private String lineIndex; + @ApiModelProperty("消息返回体") + private Page page; - @ApiModelProperty("监测点名称") - private String lineName; + @Data + public static class udState implements Serializable { + @ApiModelProperty("监测点Id") + private String lineIndex; - @ApiModelProperty("暂降事件id") - private String eventDetailIndex; + @ApiModelProperty("监测点名称") + private String lineName; - @ApiModelProperty("触发时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime timeID; + @ApiModelProperty("暂降事件id") + private String eventDetailIndex; - @ApiModelProperty("持续时间") - private Double persistTime; + @ApiModelProperty("触发时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime timeID; - @ApiModelProperty("毫秒数") - private Double ms; + @ApiModelProperty("持续时间") + private Double persistTime; - @ApiModelProperty("特征幅值") - private Double eventValue; + @ApiModelProperty("毫秒数") + private Double ms; - @ApiModelProperty("终端信息") - private String lineInfo; + @ApiModelProperty("特征幅值") + private Double eventValue; - @ApiModelProperty("暂态消息") - private String eventMsgIndex; + @ApiModelProperty("监测点信息") + private String lineInfo; - @ApiModelProperty("读取状态") - private Integer state; + @ApiModelProperty("暂态消息Guid") + private String eventMsgIndex; + @ApiModelProperty("读取状态") + private Integer state; + } } \ No newline at end of file diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/AppCloudBootApplication.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/AppCloudBootApplication.java index 71afe96..50a370b 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/AppCloudBootApplication.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/AppCloudBootApplication.java @@ -6,6 +6,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.DependsOn; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; @Slf4j @@ -13,6 +15,7 @@ import org.springframework.context.annotation.DependsOn; @EnableFeignClients(basePackages = "com.njcn") @SpringBootApplication(scanBasePackages = "com.njcn") @DependsOn("proxyMapperRegister") +@EnableScheduling public class AppCloudBootApplication { public static void main(String[] args) { diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/RealTimeInfo/RealTimeInfoController.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/RealTimeInfo/RealTimeInfoController.java new file mode 100644 index 0000000..4c18d0d --- /dev/null +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/RealTimeInfo/RealTimeInfoController.java @@ -0,0 +1,45 @@ +package com.njcn.cloud.controller.RealTimeInfo; + +import cn.hutool.core.util.StrUtil; +import com.njcn.cloud.enums.app.UserCodeEnum; +import com.njcn.cloud.service.user.RealTimeInfoService; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.device.pq.pojo.vo.LineDetailVO; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Description: 实时数据列表 + * @Author: wr + * @Date: 2023/11/22 15:38 + */ +@RestController +@RequestMapping("/realtimeinfo") +@Api(tags = "实时数据接口") +@RequiredArgsConstructor +public class RealTimeInfoController extends BaseController { + + + private final RealTimeInfoService realTimeInfoService; + + + @PostMapping("/getLineBaseInfo") + @ApiOperation(value = "监测点信息接口", notes = "监测点信息") + public HttpResult> getLineBaseInfo(@RequestBody List lineId) { + String methodDescribe = getMethodDescribe("getLineBaseInfo"); + List lineBaseInfo1 = realTimeInfoService.getLineBaseInfo(lineId); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineBaseInfo1, methodDescribe); + } + + +} \ No newline at end of file diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/DevMsgController.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/DevMsgController.java index 2bc56c7..cca52a7 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/DevMsgController.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/DevMsgController.java @@ -57,13 +57,13 @@ public class DevMsgController extends BaseController { */ @PostMapping("/deviceList") @ApiOperation(value = "终端列表入口", notes = "终端列表") - public HttpResult> deviceList(@RequestBody BaseParam param) { + public HttpResult deviceList(@RequestBody BaseParam param) { String methodDescribe = getMethodDescribe("deviceList"); if (StrUtil.isBlank(param.getSearchValue())) { throw new BusinessException(EventMsgCodeEnum.USERID_WRONG.getMsg()); } - Page page = devMsgService.deviceList(param); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); + DevMsgDetailInfo devMsgDetailInfo = devMsgService.deviceList(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devMsgDetailInfo, methodDescribe); } /** @@ -80,7 +80,7 @@ public class DevMsgController extends BaseController { /** * 终端通讯状态统计 */ - @PostMapping("/getDevComTJ") + @PostMapping("/devComTJ") @ApiOperation(value = "终端通讯状态统计", notes = "终端通讯状态统计") public HttpResult getDevComTJ(String deptId) { String methodDescribe = getMethodDescribe("getDevComTJ"); @@ -91,7 +91,7 @@ public class DevMsgController extends BaseController { /** * 终端通讯信息 */ - @PostMapping("/getDevComInfo") + @PostMapping("/devComInfo") @ApiOperation(value = "终端通讯信息", notes = "终端通讯信息") public HttpResult> getDevComInfo(String deptId) { String methodDescribe = getMethodDescribe("getDevComInfo"); diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/EventMsgController.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/EventMsgController.java index 5a71476..94f06a2 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/EventMsgController.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/EventMsgController.java @@ -48,13 +48,13 @@ public class EventMsgController extends BaseController { */ @PostMapping("/eventDetailList") @ApiOperation(value = "暂态消息获取入口", notes = "暂态消息") - public HttpResult> eventDetailList(@RequestBody BaseParam param) { + public HttpResult eventDetailList(@RequestBody BaseParam param) { String methodDescribe = getMethodDescribe("eventDetailList"); if (StrUtil.isBlank(param.getSearchValue())) { throw new BusinessException(EventMsgCodeEnum.USERID_WRONG.getMsg()); } - Page page = eventMsgService.eventMsgPage(param); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); + EventMsgDetailVO detailVO = eventMsgService.eventMsgPage(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, detailVO, methodDescribe); } /** diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/SteadyMsgController.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/SteadyMsgController.java index 7df62b1..97a6530 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/SteadyMsgController.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/information/SteadyMsgController.java @@ -49,7 +49,7 @@ public class SteadyMsgController extends BaseController { @PostMapping("steadyState") @ApiOperation(value = "稳态越限列表", notes = "稳态越限列表") public HttpResult steadyState(@RequestBody BaseParam param) { - String methodDescribe = getMethodDescribe("eventDetailList"); + String methodDescribe = getMethodDescribe("steadyState"); if (StrUtil.isBlank(param.getSearchValue())) { throw new BusinessException(EventMsgCodeEnum.USERID_WRONG.getMsg()); } @@ -126,7 +126,7 @@ public class SteadyMsgController extends BaseController { /** * @description: 生成稳态越限指标图形 - * @author gbl + * @author wr * @param lineIndex 监测点ID * @param timeID 统计时间 * @param typeCode diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/message/EventMsgPushController.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/message/EventMsgPushController.java index 2d62692..63878b3 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/message/EventMsgPushController.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/message/EventMsgPushController.java @@ -42,7 +42,7 @@ public class EventMsgPushController extends BaseController { @ApiOperation(value = "暂态消息推送", notes = "暂态消息推送") public HttpResult sendEventMsg(String eventDetailIndex, String lineId) throws Exception { String methodDescribe = getMethodDescribe("sendEventMsg"); - if (StrUtil.isNotBlank(eventDetailIndex) || StrUtil.isNotBlank(lineId)) { + if (StrUtil.isBlank(eventDetailIndex) || StrUtil.isBlank(lineId)) { throw new BusinessException(UserCodeEnum.INVALID_PARAMETER.getMsg()); } msgService.sendEventMsg(eventDetailIndex, lineId); @@ -61,7 +61,7 @@ public class EventMsgPushController extends BaseController { @ApiOperation(value = "稳态消息推送", notes = "稳态消息推送") public HttpResult sendSteadyMsg(String userIndex, String timeID, Integer lineNum) { String methodDescribe = getMethodDescribe("sendSteadyMsg"); - if (StrUtil.isNotBlank(userIndex) || StrUtil.isNotBlank(userIndex)) { + if (StrUtil.isBlank(userIndex) || StrUtil.isBlank(userIndex)) { throw new BusinessException(UserCodeEnum.INVALID_PARAMETER.getMsg()); } msgService.sendSteadyMsg(userIndex, timeID, lineNum); @@ -76,13 +76,13 @@ public class EventMsgPushController extends BaseController { @ApiImplicitParams({ @ApiImplicitParam(name = "userIndex", value = "用户索引", required = true, paramType = "query"), @ApiImplicitParam(name = "timeID", value = "统计时间", required = true, paramType = "query"), - @ApiImplicitParam(name = "topID", value = "终点消息id", required = true, paramType = "query"), + @ApiImplicitParam(name = "topID", value = "终端消息id", required = true, paramType = "query"), @ApiImplicitParam(name = "flag", value = "强制推送标志", required = true, paramType = "query"), }) @ApiOperation(value = "终端消息推送", notes = "终端消息推送") public HttpResult sendTargetMsg(String userIndex, String timeID, String topID, int flag) { String methodDescribe = getMethodDescribe("sendTargetMsg"); - if (StrUtil.isNotBlank(userIndex) || StrUtil.isNotBlank(userIndex)) { + if (StrUtil.isBlank(userIndex) || StrUtil.isBlank(userIndex)) { throw new BusinessException(UserCodeEnum.INVALID_PARAMETER.getMsg()); } msgService.sendTargetMsg(userIndex, timeID, topID, flag); diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/task/SteadyMsgTask.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/task/SteadyMsgTask.java index 3fcdaaa..f79d77a 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/task/SteadyMsgTask.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/controller/task/SteadyMsgTask.java @@ -37,8 +37,8 @@ public class SteadyMsgTask { private final IAppSteadyAssService appSteadyAssService; private final IAppDevMsgService appDevMsgService; - @Scheduled(cron = "* * 10 * * ?") - public void timer() throws Exception { + @Scheduled(cron = "0 0 10 * * ?") + public void timer() { System.out.println("开始执行++++++++++++++++++++++++"+new Date()); Date date = DateUtil.offsetDay(new Date(), -1); String time = DateUtil.format(date, DatePattern.NORM_DATE_PATTERN); @@ -58,7 +58,8 @@ public class SteadyMsgTask { * @Date: 2023/11/17 15:07 */ public void steadyMsg(String time,String startTime,String endTime) { - List users = userFeignClient.getUserByIdList(null).getData(); + List users = userFeignClient.getUserByIdList(new ArrayList<>()).getData(); +// List users = userFeignClient.getUserByIdList(Arrays.asList("5434cc08dc9d4b7cba5e856de52f0dda")).getData(); if(CollUtil.isNotEmpty(users)){ StatSubstationBizBaseParam param; for (User user : users) { @@ -96,7 +97,7 @@ public class SteadyMsgTask { */ public void devDegree(String time,String startTime,String endTime){ LocalDateTime date = LocalDateTimeUtil.parse(time,DatePattern.NORM_DATE_PATTERN); - List users = userFeignClient.getUserByIdList(null).getData(); + List users = userFeignClient.getUserByIdList(new ArrayList<>()).getData(); if(CollUtil.isNotEmpty(users)){ for (User user : users) { List devIds = generalDeviceInfoClient.deptGetRunDev(user.getDeptId()).getData(); diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppDevMsgServiceImpl.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppDevMsgServiceImpl.java index 023018a..a37c0fd 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppDevMsgServiceImpl.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppDevMsgServiceImpl.java @@ -51,26 +51,35 @@ public class AppDevMsgServiceImpl extends ServiceImpl deviceList(BaseParam param) { - Page page= this.page(new Page(param.getPageNum(), param.getPageSize()), + public DevMsgDetailInfo deviceList(BaseParam param) { + DevMsgDetailInfo dev = new DevMsgDetailInfo(); + int count = this.count( + new LambdaQueryWrapper() + .eq(AppDevMsg::getUserIndex, param.getSearchValue()) + .eq(AppDevMsg::getState, 0) + + ); + dev.setUnstate(count); + Page page = this.page(new Page(param.getPageNum(), param.getPageSize()), new LambdaQueryWrapper() .eq(AppDevMsg::getUserIndex, param.getSearchValue()) .orderByDesc(AppDevMsg::getTimeId) ); List records = page.getRecords(); - List info=new ArrayList<>(); - if(CollUtil.isNotEmpty(records)){ + List info = new ArrayList<>(); + if (CollUtil.isNotEmpty(records)) { List topIds = records.stream().map(AppDevMsg::getTopId).collect(Collectors.toList()); - OnlineRateParam top=new OnlineRateParam(); + OnlineRateParam top = new OnlineRateParam(); top.setIds(topIds); top.setType(0); List data = generalDeviceInfoClient.getTopMsgInfoByIds(top).getData(); Map topMap = data.stream().collect(Collectors.toMap(TopMsgPO::getTopId, Function.identity())); - DevMsgDetailInfo msg; + DevMsgDetailInfo.Unstate msg; for (AppDevMsg record : records) { - if(topMap.containsKey(record.getTopId())){ + if (topMap.containsKey(record.getTopId())) { TopMsgPO topMsgPO = topMap.get(record.getTopId()); - msg=new DevMsgDetailInfo(); + msg = new DevMsgDetailInfo.Unstate(); + msg.setDevmsgIndex(record.getDevmsgIndex()); msg.setComoutDesc(topMsgPO.getComOutDesc()); msg.setAlarmDesc(topMsgPO.getAlarmDesc()); msg.setTopId(topMsgPO.getTopId()); @@ -81,7 +90,7 @@ public class AppDevMsgServiceImpl extends ServiceImpl pageEvent = BeanUtil.copyProperties(page, Page.class); + Page pageEvent = BeanUtil.copyProperties(page, Page.class); pageEvent.setRecords(info); - return pageEvent; + dev.setPage(pageEvent); + return dev; } @Override public Boolean updateDevMsgState(List ids) { return this.update(new LambdaUpdateWrapper() - .set(AppDevMsg::getState,1) - .in(AppDevMsg::getTopId,ids) + .set(AppDevMsg::getState, 1) + .in(AppDevMsg::getDevmsgIndex, ids) ); } @Override public DevComTJ getDevComTJ(String deptId) { - DevComTJ devComTJ=new DevComTJ(); + DevComTJ devComTJ = new DevComTJ(); //根据部门获取监测id List userLine = generalDeviceInfoClient.deptGetRunDev(deptId).getData(); List devDetail = generalDeviceInfoClient.getDevInfoByIds(userLine).getData(); - if(CollUtil.isNotEmpty(devDetail)){ + if (CollUtil.isNotEmpty(devDetail)) { devComTJ.setAllDevCount(devDetail.size()); devComTJ.setErrDevCount(Math.toIntExact(devDetail.stream().filter(x -> x.getComFlag() == 0).count())); - }else{ + } else { devComTJ.setAllDevCount(0); devComTJ.setErrDevCount(0); diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppEventMsgServiceImpl.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppEventMsgServiceImpl.java index 08db11a..d22d91c 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppEventMsgServiceImpl.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/AppEventMsgServiceImpl.java @@ -46,15 +46,22 @@ public class AppEventMsgServiceImpl extends ServiceImpl eventMsgPage(BaseParam param) { + public EventMsgDetailVO eventMsgPage(BaseParam param) { + EventMsgDetailVO detailVO=new EventMsgDetailVO(); String searchValue = param.getSearchValue(); //获取暂态消息信息 Page page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), new LambdaQueryWrapper() .eq(AppEventMsg::getUserIndex, searchValue) - .eq(AppEventMsg::getUserIndex, searchValue) + .orderByDesc(AppEventMsg::getTimeID) ); + int count = this.count(new LambdaQueryWrapper() + .eq(AppEventMsg::getUserIndex, searchValue) + .eq(AppEventMsg::getUserIndex, searchValue) + .eq(AppEventMsg::getState, 0) + ); + detailVO.setUdState(count); List records = page.getRecords(); - List info=new ArrayList<>(); + List info=new ArrayList<>(); if(CollUtil.isNotEmpty(records)){ Map eventMsg = records.stream().collect(Collectors.toMap(AppEventMsg::getEventdetailIndex, Function.identity())); //获取暂态事件id @@ -64,16 +71,16 @@ public class AppEventMsgServiceImpl extends ServiceImpl lineDetail = lineFeignClient.getLineDetailByIds(linedIds).getData(); //监测点map Map lineDetailMap = lineDetail.stream().collect(Collectors.toMap(LineDetailVO.Detail::getLineId, Function.identity())); - EventMsgDetailVO vo; + EventMsgDetailVO.udState vo; AppEventMsg appEventMsg ; for (RmpEventDetailPO detail : eventDetail) { if(lineDetailMap.containsKey(detail.getLineId())){ LineDetailVO.Detail line = lineDetailMap.get(detail.getLineId()); - vo=new EventMsgDetailVO(); + vo=new EventMsgDetailVO.udState(); vo.setLineIndex(line.getLineId()); vo.setLineName(PubUtil.lineName(detail.getSagsource(),line.getLineName())); vo.setEventDetailIndex(detail.getEventId()); - vo.setTimeID(line.getTimeID()); + vo.setTimeID(detail.getStartTime()); vo.setPersistTime(detail.getDuration()); vo.setMs(detail.getFirstMs()); vo.setEventValue(detail.getFeatureAmplitude()); @@ -87,12 +94,12 @@ public class AppEventMsgServiceImpl extends ServiceImpl pageEvent = BeanUtil.copyProperties(page, Page.class); + Page pageEvent = BeanUtil.copyProperties(page, Page.class); pageEvent.setRecords(info); - return pageEvent; + detailVO.setPage(pageEvent); + return detailVO; } @Override diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/MsgServiceImpl.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/MsgServiceImpl.java index d7ed2a3..a893d11 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/MsgServiceImpl.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/MsgServiceImpl.java @@ -2,6 +2,7 @@ package com.njcn.cloud.service.impl.user; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; @@ -38,6 +39,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.sf.json.JSONObject; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -69,6 +71,7 @@ public class MsgServiceImpl implements MsgService { private final IAppSteadyMsgService appSteadyMsgService; private final IAppDevMsgService appDevMsgService; private final RedisUtil redisUtil; + private final SmsUtil smsUtil; /** @@ -82,6 +85,7 @@ public class MsgServiceImpl implements MsgService { * 4:执行推送保存功能 */ @Override + @Transactional(rollbackFor = {Exception.class}) public void sendEventMsg(String eventDetailIndex, String lineId) throws Exception { List eventDetails = eventDetailFeignClient.getEventDetailByIdsList(Arrays.asList(eventDetailIndex)).getData(); if (CollUtil.isEmpty(eventDetails)) { @@ -93,7 +97,7 @@ public class MsgServiceImpl implements MsgService { } DeptLine deptLines = deptLineFeignClient.getLineByLineIds(lineId).getData(); //查询为空,则无人关注,不做推送处理,但是需要进行日志记录 - if (ObjectUtil.isNotNull(deptLines)) { + if (ObjectUtil.isNull(deptLines)) { noUserFocus(eventDetailIndex, lineId); } //存在则进行筛选用户操作 @@ -115,6 +119,7 @@ public class MsgServiceImpl implements MsgService { List waveDataDetails = WaveUtil.filterWaveData(waveDataDTO); String instantPath = wavePicComponent.generateImageShun(waveDataDTO, waveDataDetails); String rmsPath = wavePicComponent.generateImageRms(waveDataDTO, waveDataDetails); + one=new AppEventInfo(); one.setEventdetailIndex(eventDetailIndex); one.setInstantwavePath(instantPath); one.setRmswavePath(rmsPath); @@ -142,10 +147,11 @@ public class MsgServiceImpl implements MsgService { * @param lineNum 监测点数 */ @Override + @Transactional(rollbackFor = {Exception.class}) public String sendSteadyMsg(String userIndex, String timeID, Integer lineNum) { List users = userFeignClient.getUserByIdList(Arrays.asList(userIndex)).getData(); AppInfoSet appInfoSet = appInfoSetService.getById(userIndex); - if (CollUtil.isEmpty(users) || ObjectUtil.isNotNull(appInfoSet)) { + if (CollUtil.isEmpty(users) || ObjectUtil.isNull(appInfoSet)) { throw new BusinessException(UserCodeEnum.NO_USER.getMsg()); } LocalDateTime time = LocalDateTimeUtil.parse(timeID,DatePattern.NORM_DATE_PATTERN); @@ -185,10 +191,11 @@ public class MsgServiceImpl implements MsgService { * @param flag 是否强制推送 */ @Override + @Transactional(rollbackFor = {Exception.class}) public String sendTargetMsg(String userIndex, String timeID, String topID, Integer flag) { List users = userFeignClient.getUserByIdList(Arrays.asList(userIndex)).getData(); AppInfoSet appInfoSet = appInfoSetService.getById(userIndex); - if (CollUtil.isEmpty(users) || ObjectUtil.isNotNull(appInfoSet)) { + if (CollUtil.isEmpty(users) || ObjectUtil.isNull(appInfoSet)) { throw new BusinessException(UserCodeEnum.NO_USER.getMsg()); } LocalDateTime time = LocalDateTimeUtil.parse(timeID,DatePattern.NORM_DATE_PATTERN); @@ -223,6 +230,7 @@ public class MsgServiceImpl implements MsgService { } @Override + @Transactional(rollbackFor = {Exception.class}) public void sendTerminalMsg(String userIndex,String devCode, String timeID,Integer devNum,Integer alarmNum,Integer comOutNum) { AppInfoSet appInfoSet = appInfoSetService.getById(userIndex); if (ObjectUtil.isNotNull(appInfoSet)) { @@ -250,7 +258,14 @@ public class MsgServiceImpl implements MsgService { float flowNum = topMsgPO.getFlowValue(); if (alarmNum > 0 || comOutNum > 0 || flowNum > 94) { //推送 - String title = time + "终端异常共" + topMsgPO.getDeviceAbnormalNum() + "台"; + List devIds = generalDeviceInfoClient.deptGetRunDev(user.getDeptId()).getData(); + OnlineRateParam top=new OnlineRateParam(); + top.setIds(devIds); + top.setType(1); + top.setStartTime(DateUtil.beginOfDay(DateUtil.parse(topMsgPO.getTime())).toString()); + top.setEndTime(DateUtil.endOfDay(DateUtil.parse(topMsgPO.getTime())).toString()); + List data = generalDeviceInfoClient.getTopMsgInfoByIds(top).getData(); + String title = time + "终端异常共" + data.size()+ "台"; String content = "异常情况:" + (StringUtils.isEmpty(alarmNum) ? "" : "终端告警:" + alarmNum + "次 ") + (StringUtils.isEmpty(comOutNum) ? "" : "通讯中断:" + Integer.valueOf(comOutNum) + "次 ") + (StringUtils.isEmpty(flowNum) ? "" : "终端流量:" + Float.valueOf(flowNum) + "%"); sendMsg(user.getDevCode(), title, content, "3"); } @@ -264,12 +279,13 @@ public class MsgServiceImpl implements MsgService { * @param appUser 用户信息 * @param devCode 手机唯一标识 */ - private void pushEventInfo(RmpEventDetailPO eventDetail, User appUser, String devCode, int phonePushFlag) throws Exception { + private void pushEventInfo(RmpEventDetailPO eventDetail, User appUser, String devCode, int phonePushFlag) { //先根据用户获取推送策略 AppInfoSet appInfoSet = appInfoSetService.getById(appUser.getId()); if (ObjectUtil.isNotNull(appInfoSet)) { AppEventMsg eventMsg = new AppEventMsg(); eventMsg.setEventdetailIndex(eventDetail.getEventId()); + eventMsg.setTimeID(eventDetail.getStartTime()); eventMsg.setUserIndex(appUser.getId()); eventMsg.setState(0); //执行保存消息记录操作 @@ -295,7 +311,7 @@ public class MsgServiceImpl implements MsgService { boolean isPush = judgeEventNeedPush(eventDetail, line); if (isPush) { String message = "{\"line\":\"" + line.getLineName() + "\",\"time\":\"" + time + "\",\"ms\":\"" + eventDetail.getFirstMs() + "\",\"eventvalue\":\"" + amplitude + "\",\"persisttime\":\"" + duration + "\"}"; - smsUtil.sendSms(appUser.getPhone(), smsUtil.getMessageTemplate("8"), message); +// smsUtil.sendSms(appUser.getPhone(), smsUtil.getMessageTemplate("8"), message); } } } diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/RealTimeInfoServiceImpl.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/RealTimeInfoServiceImpl.java new file mode 100644 index 0000000..3a7ef54 --- /dev/null +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/impl/user/RealTimeInfoServiceImpl.java @@ -0,0 +1,27 @@ +package com.njcn.cloud.service.impl.user; + +import com.njcn.cloud.service.user.RealTimeInfoService; +import com.njcn.device.pq.api.LineFeignClient; +import com.njcn.device.pq.pojo.vo.LineDetailVO; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author wr + * @description + * @date 2023/11/22 15:40 + */ +@Service +@RequiredArgsConstructor +public class RealTimeInfoServiceImpl implements RealTimeInfoService { + + + private final LineFeignClient lineFeignClient; + + @Override + public List getLineBaseInfo(List lineId) { + return lineFeignClient.getLineDetailByIds(lineId).getData(); + } +} diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppDevMsgService.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppDevMsgService.java index 7cbffc3..63b1308 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppDevMsgService.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppDevMsgService.java @@ -37,7 +37,7 @@ public interface IAppDevMsgService extends IService { * @Author: wr * @Date: 2023/11/7 11:13 */ - Page deviceList(BaseParam param); + DevMsgDetailInfo deviceList(BaseParam param); /** * @Description: 修改消息状态 diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppEventMsgService.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppEventMsgService.java index 328ed3f..47dfe73 100644 --- a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppEventMsgService.java +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/IAppEventMsgService.java @@ -24,7 +24,7 @@ public interface IAppEventMsgService extends IService { * @Author: wr * @Date: 2023/11/1 13:36 */ - Page eventMsgPage(BaseParam param); + EventMsgDetailVO eventMsgPage(BaseParam param); /** * @Description: 暂态事件基本信息 diff --git a/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/RealTimeInfoService.java b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/RealTimeInfoService.java new file mode 100644 index 0000000..e1e62ed --- /dev/null +++ b/app-cloud/app-cloud-boot/src/main/java/com/njcn/cloud/service/user/RealTimeInfoService.java @@ -0,0 +1,18 @@ +package com.njcn.cloud.service.user; + + +import com.njcn.device.pq.pojo.vo.LineDetailVO; + +import java.util.List; + +public interface RealTimeInfoService { + + /** + * @Description: 获取监测点信息 + * @param lineId + * @return: java.util.List + * @Author: wr + * @Date: 2023/11/22 15:44 + */ + List getLineBaseInfo(List lineId); +}