From 79ad3ddd83804b550e4ab7d4a28e115a39e71eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=B6=85?= <973677575@qq.com> Date: Mon, 27 Jun 2022 11:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=8A=A0=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/constant/DeviceValidMessage.java | 2 + .../device/pojo/param/AlarmStrategyParam.java | 38 ++++++++ .../device/pojo/param/DeviceLogParam.java | 18 +++- .../njcn/device/pojo/po/AlarmStrategy.java | 36 ++++++++ .../com/njcn/device/pojo/po/TerminalLogs.java | 33 +++++++ .../njcn/device/pojo/vo/AlarmStrategyVO.java | 60 +++++++++++++ .../com/njcn/device/pojo/vo/DeviceLogVO.java | 5 -- .../njcn/device/pojo/vo/ShowVersionVO.java | 7 +- .../device/controller/AlarmController.java | 89 +++++++++++++++++++ .../controller/LogManageController.java | 6 +- .../controller/ProgramVersionController.java | 15 ++-- .../device/mapper/AlarmStrategyMapper.java | 28 ++++++ .../njcn/device/mapper/LogManageMapper.java | 7 +- .../device/mapper/ProgramVersionMapper.java | 9 +- .../mapper/mapping/AlarmStrategyMapper.xml | 42 +++++++++ .../device/mapper/mapping/LogManageMapper.xml | 50 ++++++----- .../mapper/mapping/ProgramVersionMapper.xml | 13 +-- .../device/service/AlarmStrategyService.java | 33 +++++++ .../njcn/device/service/LogManageService.java | 4 +- .../device/service/ProgramVersionService.java | 5 +- .../impl/AlarmStrategyServiceImpl.java | 73 +++++++++++++++ .../service/impl/LogManageServiceImpl.java | 68 ++++++++++++-- .../impl/ProgramVersionServiceImpl.java | 50 +---------- 23 files changed, 578 insertions(+), 113 deletions(-) create mode 100644 pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/AlarmStrategyParam.java create mode 100644 pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/AlarmStrategy.java create mode 100644 pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/TerminalLogs.java create mode 100644 pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/AlarmStrategyVO.java create mode 100644 pqs-device/device-boot/src/main/java/com/njcn/device/controller/AlarmController.java create mode 100644 pqs-device/device-boot/src/main/java/com/njcn/device/mapper/AlarmStrategyMapper.java create mode 100644 pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/AlarmStrategyMapper.xml create mode 100644 pqs-device/device-boot/src/main/java/com/njcn/device/service/AlarmStrategyService.java create mode 100644 pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/AlarmStrategyServiceImpl.java diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/constant/DeviceValidMessage.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/constant/DeviceValidMessage.java index 93a9d924c..208488f46 100644 --- a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/constant/DeviceValidMessage.java +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/constant/DeviceValidMessage.java @@ -8,6 +8,8 @@ package com.njcn.device.pojo.constant; */ public interface DeviceValidMessage { + String ID_NOT_BLANK = "id不能为空,请检查id参数"; + String PROJECT_NAME_NOT = "项目名称不能为空"; String PROJECT_NAME_RULE = "项目名称违规"; String PROVINCE_NAME_NOT = "省份不可为空"; diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/AlarmStrategyParam.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/AlarmStrategyParam.java new file mode 100644 index 000000000..ab6e0d030 --- /dev/null +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/AlarmStrategyParam.java @@ -0,0 +1,38 @@ +package com.njcn.device.pojo.param; + +import com.njcn.common.pojo.constant.PatternRegex; +import com.njcn.device.pojo.constant.DeviceValidMessage; +import com.njcn.web.constant.ValidMessage; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/23 14:54 + */ +@Data +public class AlarmStrategyParam { + + @ApiModelProperty(value = "告警策略Id", required = true) + @NotBlank(message = DeviceValidMessage.ID_NOT_BLANK) + @Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR) + private String id; + + @ApiModelProperty(value = "数据完整性标准", required = true) + private Integer integrityValue; + + @ApiModelProperty(value = "在线率标准", required = true) + private Integer onlineValue; + + @ApiModelProperty(value = "离线持续时间", required = true) + private Integer offTimeValue; + + @ApiModelProperty(value = "告警次数", required = true) + private Integer warnValue; + + +} diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/DeviceLogParam.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/DeviceLogParam.java index 965c05206..970365ddc 100644 --- a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/DeviceLogParam.java +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/param/DeviceLogParam.java @@ -4,7 +4,9 @@ import com.njcn.common.pojo.constant.PatternRegex; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.hibernate.validator.constraints.Range; +import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; /** @@ -19,7 +21,7 @@ public class DeviceLogParam { /** * 套餐类型 */ - @ApiModelProperty("套餐类型") + @ApiModelProperty("套餐类型,为空表示查询所有") private String type; /** * 开始时间 @@ -33,6 +35,20 @@ public class DeviceLogParam { @ApiModelProperty("结束时间") @Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误") private String searchEndTime; + /** + * 页码 + */ + @ApiModelProperty("页码") + @NotNull(message = "页码不可为空") + @Range(min = 1,message = "页码必须大于0") + private Integer pageNum; + /** + * 条数 + */ + @ApiModelProperty("条数") + @NotNull(message = "条数不可为空") + @Range(min = 1,message = "条数必须大于0") + private Integer pageSize; } diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/AlarmStrategy.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/AlarmStrategy.java new file mode 100644 index 000000000..25f3f0105 --- /dev/null +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/AlarmStrategy.java @@ -0,0 +1,36 @@ +package com.njcn.device.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/23 16:43 + */ +@Data +@TableName("pqs_alarm_strategy") +public class AlarmStrategy { + + private static final long serialVersionUID = 1L; + + private String id; + + private Integer integrityValue; + + private Integer onlineValue; + + private Integer offtimeValue; + + private Integer warnValue; + + private String updateBy; + + private LocalDateTime updateTime; + + private Integer state; + + +} diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/TerminalLogs.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/TerminalLogs.java new file mode 100644 index 000000000..4c2d7d245 --- /dev/null +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/po/TerminalLogs.java @@ -0,0 +1,33 @@ +package com.njcn.device.pojo.po; + +import lombok.Data; +import org.influxdb.annotation.Column; +import org.influxdb.annotation.Measurement; + +import java.time.Instant; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/22 19:03 + */ +@Data +@Measurement(name = "pqs_terminal_logs") +public class TerminalLogs { + + @Column(name = "time") + private Instant timeId; + + @Column(name = "line_id") + private String lineId; + + @Column(name = "terminal_type") + private String terminalType; + + @Column(name = "update_by") + private String updateBy; + + @Column(name = "terminal_describe") + private String terminalDescribe; + +} diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/AlarmStrategyVO.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/AlarmStrategyVO.java new file mode 100644 index 000000000..2369fa3a5 --- /dev/null +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/AlarmStrategyVO.java @@ -0,0 +1,60 @@ +package com.njcn.device.pojo.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/23 11:39 + */ +@Data +public class AlarmStrategyVO implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * id + */ + @ApiModelProperty("id") + private String id; + /** + * 等级 + */ + @ApiModelProperty("等级") + private String name; + /** + * 数据完整性标准 + */ + @ApiModelProperty("数据完整性标准") + private Integer integrityValue; + /** + * 在线率标准 + */ + @ApiModelProperty("在线率标准") + private Integer onlineValue; + /** + * 离线持续时间 + */ + @ApiModelProperty("离线持续时间") + private Integer offTimeValue; + /** + * 告警次数 + */ + @ApiModelProperty("告警次数") + private Integer warnValue; + /** + * 更新日期 + */ + @ApiModelProperty("更新日期") + private LocalDateTime updateTime; + /** + * 更新用户 + */ + @ApiModelProperty("更新用户") + private String updateBy; + + +} diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/DeviceLogVO.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/DeviceLogVO.java index b5f5bb4de..c01929564 100644 --- a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/DeviceLogVO.java +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/DeviceLogVO.java @@ -14,11 +14,6 @@ import java.io.Serializable; public class DeviceLogVO implements Serializable { private static final long serialVersionUID = 1L; - /** - * id - */ - @ApiModelProperty("id") - private String id; /** * 装置、监测点名称 */ diff --git a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/ShowVersionVO.java b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/ShowVersionVO.java index 6b3f97687..70110bb55 100644 --- a/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/ShowVersionVO.java +++ b/pqs-device/device-api/src/main/java/com/njcn/device/pojo/vo/ShowVersionVO.java @@ -15,9 +15,10 @@ public class ShowVersionVO extends VersionVO { private static final long serialVersionUID = 1L; /** - * 终端版本文件状态(0-不存在 1-存在) + * 终端版本文件 */ - @ApiModelProperty("终端版本文件状态(0-不存在 1-存在)") - private Integer fileFlag; + @ApiModelProperty("终端版本文件") + // private MultipartFile file; + private byte[] file; } diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/AlarmController.java b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/AlarmController.java new file mode 100644 index 000000000..c86caa137 --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/AlarmController.java @@ -0,0 +1,89 @@ +package com.njcn.device.controller; + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.device.pojo.param.AlarmStrategyParam; +import com.njcn.device.pojo.vo.AlarmStrategyVO; +import com.njcn.device.service.AlarmStrategyService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/23 11:36 + */ +@Validated +@Slf4j +@RestController +@RequestMapping("/Alarm") +@Api(tags = "告警管理") +@AllArgsConstructor +public class AlarmController extends BaseController { + + private final AlarmStrategyService alarmStrategyService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getAlarmStrategyData") + @ApiOperation("告警策略管理") + public HttpResult> getAlarmStrategyData(){ + String methodDescribe = getMethodDescribe("getAlarmStrategyData"); + List list = alarmStrategyService.getAlarmStrategyData(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/updateAlarmStrategyById") + @ApiOperation("修改告警策略") + @ApiImplicitParam(name = "alarmStrategyParam", value = "修改策略参数", required = true) + public HttpResult> updateAlarmStrategyById(@RequestBody AlarmStrategyParam alarmStrategyParam){ + String methodDescribe = getMethodDescribe("getAlarmStrategyData"); + boolean res = alarmStrategyService.updateAlarmStrategyById(alarmStrategyParam); + if (res) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } else { + throw new BusinessException(CommonResponseEnum.FAIL); + } + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/addAlarmStrategyById") + @ApiOperation("新增告警策略") + @ApiImplicitParam(name = "alarmStrategyParam", value = "新增策略参数", required = true) + public HttpResult> addAlarmStrategyById(@RequestBody AlarmStrategyParam alarmStrategyParam){ + String methodDescribe = getMethodDescribe("addAlarmStrategyById"); + boolean res = alarmStrategyService.addAlarmStrategyById(alarmStrategyParam); + if (res) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } else { + throw new BusinessException(CommonResponseEnum.FAIL); + } + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/removeAlarmStrategyData") + @ApiOperation("删除告警策略") + @ApiImplicitParam(name = "id", value = "策略id", required = true) + public HttpResult> removeAlarmStrategyData(@RequestParam("id") String id){ + String methodDescribe = getMethodDescribe("removeAlarmStrategyData"); + boolean res = alarmStrategyService.removeAlarmStrategyData(id); + if (res) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } else { + throw new BusinessException(CommonResponseEnum.FAIL); + } + } + +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/LogManageController.java b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/LogManageController.java index ab81dabf5..c1a612a6c 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/LogManageController.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/LogManageController.java @@ -23,8 +23,6 @@ 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; - /** * @version 1.0.0 * @author: chenchao @@ -44,9 +42,9 @@ public class LogManageController extends BaseController { @PostMapping("/getDeviceLogData") @ApiOperation("终端运维日志") @ApiImplicitParam(name = "deviceLogParam", value = "查询终端日志信息", required = true) - public HttpResult> getDeviceLogData(@RequestBody @Validated DeviceLogParam deviceLogParam){ + public HttpResult> getDeviceLogData(@RequestBody @Validated DeviceLogParam deviceLogParam){ String methodDescribe = getMethodDescribe("getDeviceLogData"); - List list = deviceLogService.getDeviceLogData(deviceLogParam); + Page list = deviceLogService.getDeviceLogData(deviceLogParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); } diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/ProgramVersionController.java b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/ProgramVersionController.java index e43ab9700..0c3cdcd8e 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/controller/ProgramVersionController.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/controller/ProgramVersionController.java @@ -7,7 +7,6 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; -import com.njcn.device.pojo.vo.ShowVersionVO; import com.njcn.device.pojo.vo.VersionVO; import com.njcn.device.service.ProgramVersionService; import com.njcn.web.controller.BaseController; @@ -70,12 +69,16 @@ public class ProgramVersionController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getProgramVersionById") - @ApiOperation("修改版本回显") + @ApiOperation("版本文件是否存在") @ApiImplicitParam(name = "id", value = "终端版本id", required = true) - public HttpResult getProgramVersionById(@RequestParam("id") String id) { + public HttpResult getProgramVersionById(@RequestParam("id") String id) { String methodDescribe = getMethodDescribe("getProgramVersionById"); - ShowVersionVO result = programService.getProgramVersionById(id); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + boolean res = programService.getProgramVersionById(id); + if (res) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } else { + throw new BusinessException(CommonResponseEnum.NO_DATA); + } } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @@ -101,6 +104,7 @@ public class ProgramVersionController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/updateVersionFlag") @ApiOperation("修改程序版本状态") + @ApiImplicitParam(name = "id", value = "终端版本id", required = true) public HttpResult updateVersionFlag(@RequestParam("id") String id) { String methodDescribe = getMethodDescribe("updateVersionFlag"); boolean res = programService.updateVersionFlag(id); @@ -114,6 +118,7 @@ public class ProgramVersionController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/delProgramVersion") @ApiOperation("删除程序版本") + @ApiImplicitParam(name = "id", value = "终端版本id", required = true) public HttpResult delProgramVersion(@RequestParam("id") String id) { String methodDescribe = getMethodDescribe("delProgramVersion"); boolean res = programService.delProgramVersion(id); diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/AlarmStrategyMapper.java b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/AlarmStrategyMapper.java new file mode 100644 index 000000000..8b7b4a58c --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/AlarmStrategyMapper.java @@ -0,0 +1,28 @@ +package com.njcn.device.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.device.pojo.po.AlarmStrategy; +import com.njcn.device.pojo.vo.AlarmStrategyVO; + +import java.util.List; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/23 13:39 + */ +public interface AlarmStrategyMapper extends BaseMapper { + + /** + * 获取告警策略列表 + */ + List getAlarmStrategyData(); + /** + * 查询告警策略是否已存在 + */ + Integer getAlarmStrategyById(String id); + /** + * 删除告警策略 + */ + void updateAlarmStrategyState(String id); +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/LogManageMapper.java b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/LogManageMapper.java index 14f5bd58e..1c113206c 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/LogManageMapper.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/LogManageMapper.java @@ -1,12 +1,9 @@ package com.njcn.device.mapper; -import com.njcn.device.pojo.param.DeviceLogParam; import com.njcn.device.pojo.vo.DeviceLogVO; import com.njcn.device.pojo.vo.EventLogVO; import org.apache.ibatis.annotations.Param; -import java.util.List; - /** * @version 1.0.0 * @author: chenchao @@ -17,9 +14,9 @@ public interface LogManageMapper { /** * 查询终端日志信息 */ - List getDeviceLogData(@Param("deviceLogParam")DeviceLogParam deviceLogParam); + DeviceLogVO getDeviceLogData(@Param("lineIds") String lineIds,@Param("terminalTypes") String terminalTypes,@Param("updateBys") String updateBys); /** * 查询暂降推送日志信息 */ - EventLogVO getEventLogData(@Param("lineId") String lineId); + EventLogVO getEventLogData(String lineId); } diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/ProgramVersionMapper.java b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/ProgramVersionMapper.java index b282fdeed..aa1b8be37 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/ProgramVersionMapper.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/ProgramVersionMapper.java @@ -1,5 +1,6 @@ package com.njcn.device.mapper; +import com.njcn.device.pojo.vo.ShowVersionVO; import com.njcn.device.pojo.vo.VersionVO; import java.util.List; @@ -15,10 +16,10 @@ public interface ProgramVersionMapper { * 获取终端版本信息,根据装置型号查询 */ List getVersion(String devType); - // /** - // * 修改版本回显 - // */ - // ShowVersionVO getProgramVersionById(String id); + /** + * 根据id获取终端版本信息 + */ + ShowVersionVO getProgramVersionById(String id); /** * 修改程序版本状态 */ diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/AlarmStrategyMapper.xml b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/AlarmStrategyMapper.xml new file mode 100644 index 000000000..0ece0c697 --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/AlarmStrategyMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + UPDATE + pqs_alarm_strategy + SET + State = 0 + WHERE Id = #{id} + + + \ No newline at end of file diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/LogManageMapper.xml b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/LogManageMapper.xml index fea2dc3f8..68c340125 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/LogManageMapper.xml +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/mapper/mapping/LogManageMapper.xml @@ -5,30 +5,38 @@ + + + + + + + + + + + + + + + + + + + + - - - - - + UPDATE diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/AlarmStrategyService.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/AlarmStrategyService.java new file mode 100644 index 000000000..0b9cc0948 --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/AlarmStrategyService.java @@ -0,0 +1,33 @@ +package com.njcn.device.service; + +import com.njcn.device.pojo.param.AlarmStrategyParam; +import com.njcn.device.pojo.vo.AlarmStrategyVO; + +import java.util.List; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/23 11:37 + */ +public interface AlarmStrategyService { + + /** + * 获取告警策略列表 + */ + List getAlarmStrategyData(); + + /** + * 修改告警策略 + */ + boolean updateAlarmStrategyById(AlarmStrategyParam alarmStrategyParam); + + /** + * 新增告警策略 + */ + boolean addAlarmStrategyById(AlarmStrategyParam alarmStrategyParam); + /** + * 删除告警策略 + */ + boolean removeAlarmStrategyData(String id); +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/LogManageService.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/LogManageService.java index f40e57caf..a58e893dd 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/LogManageService.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/LogManageService.java @@ -6,8 +6,6 @@ import com.njcn.device.pojo.param.EventLogParam; import com.njcn.device.pojo.vo.DeviceLogVO; import com.njcn.device.pojo.vo.EventLogVO; -import java.util.List; - /** * @version 1.0.0 * @author: chenchao @@ -20,7 +18,7 @@ public interface LogManageService { * @param deviceLogParam * @return */ - List getDeviceLogData(DeviceLogParam deviceLogParam); + Page getDeviceLogData(DeviceLogParam deviceLogParam); /** * 获取暂降推送日志列表 * @param eventLogParam diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/ProgramVersionService.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/ProgramVersionService.java index 757ac4665..ce3d79472 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/ProgramVersionService.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/ProgramVersionService.java @@ -1,7 +1,6 @@ package com.njcn.device.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.njcn.device.pojo.vo.ShowVersionVO; import com.njcn.device.pojo.vo.VersionVO; import org.springframework.web.multipart.MultipartFile; @@ -25,10 +24,10 @@ public interface ProgramVersionService { */ boolean addProgramVersion(String name, String protocol, LocalDate date, String devType, String remark, String versionType, MultipartFile file); /** - * 修改版本回显 + * 版本文件是否存在 * @return */ - ShowVersionVO getProgramVersionById(String id); + boolean getProgramVersionById(String id); /** * 修改程序版本管理信息 * @return diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/AlarmStrategyServiceImpl.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/AlarmStrategyServiceImpl.java new file mode 100644 index 000000000..64f0c22eb --- /dev/null +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/AlarmStrategyServiceImpl.java @@ -0,0 +1,73 @@ +package com.njcn.device.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.device.mapper.AlarmStrategyMapper; +import com.njcn.device.pojo.param.AlarmStrategyParam; +import com.njcn.device.pojo.po.AlarmStrategy; +import com.njcn.device.pojo.vo.AlarmStrategyVO; +import com.njcn.device.service.AlarmStrategyService; +import com.njcn.web.utils.RequestUtil; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * @version 1.0.0 + * @author: chenchao + * @date: 2022/06/23 13:24 + */ +@Service +@AllArgsConstructor +public class AlarmStrategyServiceImpl extends ServiceImpl implements AlarmStrategyService { + + private final AlarmStrategyMapper alarmStrategyMapper; + + @Override + public List getAlarmStrategyData() { + List alarmStrategyVOS = alarmStrategyMapper.getAlarmStrategyData(); + return alarmStrategyVOS; + } + + @Override + public boolean updateAlarmStrategyById(AlarmStrategyParam alarmStrategyParam) { + AlarmStrategy alarmStrategy = new AlarmStrategy(); + alarmStrategy.setId(alarmStrategyParam.getId()); + alarmStrategy.setIntegrityValue(alarmStrategyParam.getIntegrityValue()); + alarmStrategy.setOnlineValue(alarmStrategyParam.getOnlineValue()); + alarmStrategy.setOfftimeValue(alarmStrategyParam.getOffTimeValue()); + alarmStrategy.setWarnValue(alarmStrategyParam.getWarnValue()); + alarmStrategy.setUpdateBy(RequestUtil.getUserIndex()); + alarmStrategy.setUpdateTime(LocalDateTime.now()); + alarmStrategyMapper.updateById(alarmStrategy); + return true; + } + + @Override + public boolean addAlarmStrategyById(AlarmStrategyParam alarmStrategyParam) { + Integer result = alarmStrategyMapper.getAlarmStrategyById(alarmStrategyParam.getId()); + if (result==0) { + AlarmStrategy alarmStrategy = new AlarmStrategy(); + alarmStrategy.setId(alarmStrategyParam.getId()); + alarmStrategy.setIntegrityValue(alarmStrategyParam.getIntegrityValue()); + alarmStrategy.setOnlineValue(alarmStrategyParam.getOnlineValue()); + alarmStrategy.setOfftimeValue(alarmStrategyParam.getOffTimeValue()); + alarmStrategy.setWarnValue(alarmStrategyParam.getWarnValue()); + alarmStrategy.setUpdateBy(RequestUtil.getUserIndex()); + alarmStrategy.setUpdateTime(LocalDateTime.now()); + alarmStrategy.setState(1); + alarmStrategyMapper.insert(alarmStrategy); + return true; + } else { + return false; + } + } + + @Override + public boolean removeAlarmStrategyData(String id) { + alarmStrategyMapper.updateAlarmStrategyState(id); + return true; + } + +} diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LogManageServiceImpl.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LogManageServiceImpl.java index 98c60347c..097c365bf 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LogManageServiceImpl.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/LogManageServiceImpl.java @@ -1,11 +1,13 @@ package com.njcn.device.service.impl; +import com.alibaba.nacos.shaded.com.google.common.collect.Lists; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.device.mapper.LogManageMapper; import com.njcn.device.pojo.constant.DeviceValidMessage; import com.njcn.device.pojo.param.DeviceLogParam; import com.njcn.device.pojo.param.EventLogParam; import com.njcn.device.pojo.po.EventPushLogs; +import com.njcn.device.pojo.po.TerminalLogs; import com.njcn.device.pojo.vo.DeviceLogVO; import com.njcn.device.pojo.vo.EventLogVO; import com.njcn.device.service.LogManageService; @@ -42,14 +44,38 @@ public class LogManageServiceImpl implements LogManageService { private final InfluxDbUtils influxDbUtils; @Override - public List getDeviceLogData(DeviceLogParam deviceLogParam) { - if (deviceLogParam.getType().isEmpty()) { - deviceLogParam.setType(null); + public Page getDeviceLogData(DeviceLogParam deviceLogParam) { + Page page = new Page<>(); + page.setSize(deviceLogParam.getPageSize()); + page.setCurrent(deviceLogParam.getPageNum()); + + List logData = new ArrayList<>(); + List terminalLogs = getTerminalLogs(deviceLogParam.getSearchBeginTime(), deviceLogParam.getSearchEndTime(), deviceLogParam.getType()); + //待分页数据总量 + page.setTotal(terminalLogs.size()); + //分页总页数 + int pages = (int)Math.ceil(terminalLogs.size()*1.0/deviceLogParam.getPageSize()); + page.setPages(pages); + + if (!CollectionUtils.isEmpty(terminalLogs)) { + List> partition = Lists.partition(terminalLogs, deviceLogParam.getPageSize()); + List pageLogs = partition.get(deviceLogParam.getPageNum() - 1); + + if (!CollectionUtils.isEmpty(pageLogs)) { + for (TerminalLogs logs: pageLogs) { + DeviceLogVO deviceLogVO = logManageMapper.getDeviceLogData(logs.getLineId(), logs.getTerminalType(), logs.getUpdateBy()); + LocalDateTime localDateTime = LocalDateTime.ofInstant(logs.getTimeId(), ZoneId.systemDefault()); + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + String time = dateTimeFormatter.format(localDateTime); + deviceLogVO.setUpdateTime(time); + deviceLogVO.setRemark(logs.getTerminalDescribe()); + logData.add(deviceLogVO); + } + //当前页数据 + page.setRecords(logData); + } } - deviceLogParam.setSearchBeginTime(deviceLogParam.getSearchBeginTime()+" 00:00:00"); - deviceLogParam.setSearchEndTime(deviceLogParam.getSearchEndTime()+" 23:59:59"); - List logData = logManageMapper.getDeviceLogData(deviceLogParam); - return logData; + return page; } @@ -115,6 +141,32 @@ public class LogManageServiceImpl implements LogManageService { return page; } + /** + * influxDB查询终端运维日志相关信息 + * @param startTime + * @param endTime + * @param type + */ + private List getTerminalLogs(String startTime, String endTime, String type) { + List terminalLogs; + //组装sql语句 + StringBuilder string = new StringBuilder(); + string.append(DeviceValidMessage.TIME + " >= '" + startTime + DeviceValidMessage.START_TIME + "' and " + DeviceValidMessage.TIME + " <= '" + endTime + DeviceValidMessage.END_TIME + "'"); + if (!type.isEmpty()) { + string.append(" and terminal_type = '" + type +"'").append(" tz('Asia/Shanghai')"); + } + //sql语句 + String sql = "SELECT * FROM pqs_terminal_logs WHERE " + string; + System.out.println("sql==========="+sql); + //结果集 + QueryResult results = influxDbUtils.query(sql); + //结果集映射到对象中 + InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); + terminalLogs = resultMapper.toPOJO(results, TerminalLogs.class); + + return terminalLogs; + } + /** * influxDB查询暂降事件相关信息 * @param startTime @@ -127,7 +179,7 @@ public class LogManageServiceImpl implements LogManageService { StringBuilder string = new StringBuilder(); string.append(DeviceValidMessage.TIME + " >= '" + startTime + DeviceValidMessage.START_TIME + "' and " + DeviceValidMessage.TIME + " <= '" + endTime + DeviceValidMessage.END_TIME + "'"); if (result==1 || result==2) { - string.append(" and result=" + result); + string.append(" and result=" + result).append(" tz('Asia/Shanghai')"); } //sql语句 String sql = "SELECT * FROM pqs_event_push_logs WHERE " + string; diff --git a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/ProgramVersionServiceImpl.java b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/ProgramVersionServiceImpl.java index e80e9ea1a..c963a7e37 100644 --- a/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/ProgramVersionServiceImpl.java +++ b/pqs-device/device-boot/src/main/java/com/njcn/device/service/impl/ProgramVersionServiceImpl.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.Objects; /** * @version 1.0.0 @@ -99,14 +100,11 @@ public class ProgramVersionServiceImpl extends ServiceImpl