日志加分页

This commit is contained in:
陈超
2022-06-27 11:16:03 +08:00
parent 7327d661ac
commit 79ad3ddd83
23 changed files with 578 additions and 113 deletions

View File

@@ -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 = "省份不可为空";

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
/**
* 装置、监测点名称
*/

View File

@@ -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;
}

View File

@@ -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<List<AlarmStrategyVO>> getAlarmStrategyData(){
String methodDescribe = getMethodDescribe("getAlarmStrategyData");
List<AlarmStrategyVO> 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<List<AlarmStrategyVO>> 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<List<AlarmStrategyVO>> 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<List<AlarmStrategyVO>> 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);
}
}
}

View File

@@ -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<List<DeviceLogVO>> getDeviceLogData(@RequestBody @Validated DeviceLogParam deviceLogParam){
public HttpResult<Page<DeviceLogVO>> getDeviceLogData(@RequestBody @Validated DeviceLogParam deviceLogParam){
String methodDescribe = getMethodDescribe("getDeviceLogData");
List<DeviceLogVO> list = deviceLogService.getDeviceLogData(deviceLogParam);
Page<DeviceLogVO> list = deviceLogService.getDeviceLogData(deviceLogParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -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<ShowVersionVO> 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);

View File

@@ -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<AlarmStrategy> {
/**
* 获取告警策略列表
*/
List<AlarmStrategyVO> getAlarmStrategyData();
/**
* 查询告警策略是否已存在
*/
Integer getAlarmStrategyById(String id);
/**
* 删除告警策略
*/
void updateAlarmStrategyState(String id);
}

View File

@@ -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<DeviceLogVO> 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);
}

View File

@@ -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<VersionVO> getVersion(String devType);
// /**
// * 修改版本回显
// */
// ShowVersionVO getProgramVersionById(String id);
/**
* 根据id获取终端版本信息
*/
ShowVersionVO getProgramVersionById(String id);
/**
* 修改程序版本状态
*/

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.device.mapper.AlarmStrategyMapper">
<select id="getAlarmStrategyData" resultType="AlarmStrategyVO">
SELECT
A.`Id` id,
B.`Name` name,
A.`Integrity_Value` integrityValue,
A.`Online_Value` onlineValue,
A.`Offtime_Value` offTimeValue,
A.`Warn_Value` warnValue,
A.`Update_Time` updateTime,
C.`Name` updateBy
FROM
pqs_alarm_strategy A,
sys_dict_data B,
sys_user C
WHERE A.State = 1
AND A.Id = B.Id
AND A.Update_By = C.Id
</select>
<select id="getAlarmStrategyById" resultType="java.lang.Integer">
SELECT
COUNT(Id)
FROM
pqs_alarm_strategy
WHERE State = 1
AND Id = #{id}
</select>
<update id="updateAlarmStrategyState">
UPDATE
pqs_alarm_strategy
SET
State = 0
WHERE Id = #{id}
</update>
</mapper>

View File

@@ -5,30 +5,38 @@
<select id="getDeviceLogData" resultType="DeviceLogVO">
SELECT
T.`Logs_Index` id,
L.`Name` name,
D.`Name` type,
T.`Terminal_Describe` remark,
T.`Update_Time` updateTime,
T.`Update_By` updateBy
A.`Name` name,
B.`Name` type,
C.`Name` updateBy
FROM
pqs_terminallogs T,
pq_line L,
sys_dict_data D
pq_line A,
sys_dict_data B,
sys_user C
WHERE
T.State = 1
AND T.Obj_Index = L.Id
AND T.Terminal_Type = D.Id
<if test="deviceLogParam.type!=null">
AND T.Terminal_Type = '${deviceLogParam.type}'
</if>
<if test="deviceLogParam.searchBeginTime!=null">
AND T.Update_Time >= '${deviceLogParam.searchBeginTime}'
</if>
<if test="deviceLogParam.searchEndTime!=null">
AND '${deviceLogParam.searchEndTime}' >= T.Update_Time
</if>
A.Id = #{lineIds}
AND B.Id = #{terminalTypes}
AND C.Id = #{updateBys}
</select>
<!-- SELECT-->
<!-- A.`Name` name,-->
<!-- B.`Name` type,-->
<!-- C.`Name` updateBy-->
<!-- FROM-->
<!-- pq_line A,-->
<!-- sys_dict_data B,-->
<!-- sys_user C-->
<!-- WHERE A.Id IN-->
<!-- <foreach collection="lineIds" item="item" open="(" close=")" separator=",">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- AND B.Id IN-->
<!-- <foreach collection="terminalTypes" item="item" open="(" close=")" separator=",">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- AND C.Id IN-->
<!-- <foreach collection="updateBys" item="item" open="(" close=")" separator=",">-->
<!-- #{item}-->
<!-- </foreach>-->
<select id="getEventLogData" resultType="EventLogVO">
SELECT

View File

@@ -27,11 +27,14 @@
</if>
</select>
<!-- <select id="getProgramVersionById" resultType="ShowVersionVO">-->
<!-- SELECT-->
<!-- FROM-->
<!-- WHERE-->
<!-- </select>-->
<select id="getProgramVersionById" resultType="ShowVersionVO">
SELECT
`File` file
FROM
cld_version
WHERE Id = #{id}
AND State = 1
</select>
<update id="updateVersionFlag">
UPDATE

View File

@@ -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<AlarmStrategyVO> getAlarmStrategyData();
/**
* 修改告警策略
*/
boolean updateAlarmStrategyById(AlarmStrategyParam alarmStrategyParam);
/**
* 新增告警策略
*/
boolean addAlarmStrategyById(AlarmStrategyParam alarmStrategyParam);
/**
* 删除告警策略
*/
boolean removeAlarmStrategyData(String id);
}

View File

@@ -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<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam);
Page<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam);
/**
* 获取暂降推送日志列表
* @param eventLogParam

View File

@@ -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

View File

@@ -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<AlarmStrategyMapper, AlarmStrategy> implements AlarmStrategyService {
private final AlarmStrategyMapper alarmStrategyMapper;
@Override
public List<AlarmStrategyVO> getAlarmStrategyData() {
List<AlarmStrategyVO> 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;
}
}

View File

@@ -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<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam) {
if (deviceLogParam.getType().isEmpty()) {
deviceLogParam.setType(null);
public Page<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam) {
Page<DeviceLogVO> page = new Page<>();
page.setSize(deviceLogParam.getPageSize());
page.setCurrent(deviceLogParam.getPageNum());
List<DeviceLogVO> logData = new ArrayList<>();
List<TerminalLogs> 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<List<TerminalLogs>> partition = Lists.partition(terminalLogs, deviceLogParam.getPageSize());
List<TerminalLogs> 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);
}
deviceLogParam.setSearchBeginTime(deviceLogParam.getSearchBeginTime()+" 00:00:00");
deviceLogParam.setSearchEndTime(deviceLogParam.getSearchEndTime()+" 23:59:59");
List<DeviceLogVO> logData = logManageMapper.getDeviceLogData(deviceLogParam);
return logData;
//当前页数据
page.setRecords(logData);
}
}
return page;
}
@@ -115,6 +141,32 @@ public class LogManageServiceImpl implements LogManageService {
return page;
}
/**
* influxDB查询终端运维日志相关信息
* @param startTime
* @param endTime
* @param type
*/
private List<TerminalLogs> getTerminalLogs(String startTime, String endTime, String type) {
List<TerminalLogs> 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;

View File

@@ -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<VersionMapper, Versio
}
@Override
public ShowVersionVO getProgramVersionById(String id) {
// ShowVersionVO showVersionVO = programVersionMapper.getProgramVersionById(id);
return null;
public boolean getProgramVersionById(String id) {
ShowVersionVO showVersionVO = programVersionMapper.getProgramVersionById(id);
return !Objects.isNull(showVersionVO);
}
@Override
public boolean updateProgramVersion(String id, String name, String protocol, LocalDate date, String devType, String remark, String versionType, MultipartFile file) {
check(id,name,true);
@@ -149,46 +147,6 @@ public class ProgramVersionServiceImpl extends ServiceImpl<VersionMapper, Versio
return true;
}
// @Override
// public void upLoad(MultipartFile file) {
// Version version = new Version();
// version.setName("测试版本v1.3");
// version.setProtocol("测试版本v1.4");
// byte[] b = null, bytes = null;
// try {
// b = file.getBytes();
//
// InputStream in = file.getInputStream();
// bytes = FileCopyUtils.copyToByteArray(in);
// } catch (IOException e) {
// e.printStackTrace();
// }
// version.setFile(b);
//
// if (file.isEmpty()) {
// HttpResult result = new HttpResult();
// result.setData(null);
// result.setCode("500");
// result.setMessage("请上传升级文件");
// throw new BusinessException(result);
// } else {
// String fileName = file.getOriginalFilename();
// if(fileName.lastIndexOf(".")!=-1){
// //文件后缀,判断上传文件格式
// String subffix = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
// if (!judgeFileType(subffix)) {
// HttpResult result = new HttpResult();
// result.setData(null);
// result.setCode("500");
// result.setMessage("请上传后缀为bin的文件或无后缀文件");
// throw new BusinessException(result);
// }
// }
//
// }
// versionMapper.insert(version);
// }
private Boolean judgeFileType(String subffix) {
boolean result = false;