Merge remote-tracking branch 'origin/master'

This commit is contained in:
2022-06-27 16:07:18 +08:00
28 changed files with 1090 additions and 338 deletions

View File

@@ -0,0 +1,212 @@
package com.njcn.influxdb.param;
/**
* 类的介绍使用influxDB查询时的公共参数
*
* @author xuyang
* @version 1.0.0
* @createTime 2022/6/24 15:02
*/
public interface InfluxDBPublicParam {
/**
* influxDB数据库名称
*/
String DATABASE = "pqsbase";
/**
* 暂态事件汇总表
*/
String PQS_EVENT_DETAIL = "pqs_eventdetail";
/**
* 电压波动闪变表
*/
String DATA_FLICKER = "data_flicker";
/**
* 电压波动表
*/
String DATA_FLUC = "data_fluc";
/**
* 谐波电流角度表
*/
String DATA_HARM_PHASIC_I = "data_harmphasic_i";
/**
* 谐波电压角度表
*/
String DATA_HARM_PHASIC_V = "data_harmphasic_v";
/**
* 有功功率表
*/
String DATA_HARM_POWER_P = "data_harmpower_p";
/**
* 无功功率表
*/
String DATA_HARM_POWER_Q = "data_harmpower_q";
/**
* 视在功率表
*/
String DATA_HARM_POWER_S = "data_harmpower_s";
/**
* 谐波电流含有率表
*/
String DATA_HARM_RATE_I = "data_harmrate_i";
/**
* 谐波电压含有率表
*/
String DATA_HARM_RATE_V = "data_harmrate_v";
/**
* 电流表
*/
String DATA_I = "data_i";
/**
* 电流间谐波幅值表
*/
String DATA_IN_HARM_I = "data_inharm_i";
/**
* 电压间谐波幅值表
*/
String DATA_IN_HARM_V = "data_inharm_v";
/**
* 长时闪变表
*/
String DATA_PLT = "data_plt";
/**
* 电压表
*/
String DATA_V = "data_v";
/**
* 日统计-电压波动闪变表
*/
String DAY_FLICKER = "day_flicker";
/**
* 日统计-电压波动表
*/
String DAY_FLUC = "day_fluc";
/**
* 日统计-谐波电流角度表
*/
String DAY_HARM_PHASIC_I = "day_harmphasic_i";
/**
* 日统计-谐波电压角度表
*/
String DAY_HARM_PHASIC_V = "day_harmphasic_v";
/**
* 日统计-有功功率表
*/
String DAY_HARM_POWER_P = "day_harmpower_p";
/**
* 日统计-无功功率表
*/
String DAY_HARM_POWER_Q = "day_harmpower_q";
/**
* 日统计-视在功率表
*/
String DAY_HARM_POWER_S = "day_harmpower_s";
/**
* 日统计-谐波电流含有率表
*/
String DAY_HARM_RATE_I = "day_harmrate_i";
/**
* 日统计-谐波电压含有率表
*/
String DAY_HARM_RATE_V = "day_harmrate_v";
/**
* 日统计-电流表
*/
String DAY_I = "day_i";
/**
* 日统计-电流间谐波幅值表
*/
String DAY_IN_HARM_I = "day_inharm_i";
/**
* 日统计-电压间谐波幅值表
*/
String DAY_IN_HARM_V = "day_inharm_v";
/**
* 日统计-长时闪变表
*/
String DAY_PLT = "day_plt";
/**
* 日统计-电压表
*/
String DAY_V = "day_v";
/**
* 时区
*/
String TIME_ZONE = "tz('Asia/Shanghai')";
/**
* 日起始时间
*/
String START_TIME = " 00:00:00";
/**
* 日结束时间
*/
String END_TIME = " 23:59:59";
/**
* 时间
*/
String TIME = "time";
/**
* 数据线路号
*/
String LINE_ID = "line_id";
/**
* 数据类型
*/
String PHASIC_TYPE = "phasic_type";
/**
* 指标类型
*/
String VALUE_TYPE = "value_type";
/**
* 数据质量标志
*/
String QUALITY_FLAG = "quality_flag";
/**
* limit_rate
*/
String LIMIT_RATE = "limit_rate";
/**
* limit_target
*/
String LIMIT_TARGET = "limit_target";
}

View File

@@ -8,6 +8,8 @@ package com.njcn.device.pojo.constant;
*/ */
public interface DeviceValidMessage { public interface DeviceValidMessage {
String ID_NOT_BLANK = "id不能为空请检查id参数";
String PROJECT_NAME_NOT = "项目名称不能为空"; String PROJECT_NAME_NOT = "项目名称不能为空";
String PROJECT_NAME_RULE = "项目名称违规"; String PROJECT_NAME_RULE = "项目名称违规";
String PROVINCE_NAME_NOT = "省份不可为空"; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
/** /**
@@ -19,7 +21,7 @@ public class DeviceLogParam {
/** /**
* 套餐类型 * 套餐类型
*/ */
@ApiModelProperty("套餐类型") @ApiModelProperty("套餐类型,为空表示查询所有")
private String type; private String type;
/** /**
* 开始时间 * 开始时间
@@ -33,6 +35,20 @@ public class DeviceLogParam {
@ApiModelProperty("结束时间") @ApiModelProperty("结束时间")
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误") @Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
private String searchEndTime; 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 { public class DeviceLogVO implements Serializable {
private static final long serialVersionUID = 1L; 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; private static final long serialVersionUID = 1L;
/** /**
* 终端版本文件状态0-不存在 1-存在) * 终端版本文件
*/ */
@ApiModelProperty("终端版本文件状态0-不存在 1-存在)") @ApiModelProperty("终端版本文件")
private Integer fileFlag; // 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @version 1.0.0 * @version 1.0.0
* @author: chenchao * @author: chenchao
@@ -44,9 +42,9 @@ public class LogManageController extends BaseController {
@PostMapping("/getDeviceLogData") @PostMapping("/getDeviceLogData")
@ApiOperation("终端运维日志") @ApiOperation("终端运维日志")
@ApiImplicitParam(name = "deviceLogParam", value = "查询终端日志信息", required = true) @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"); String methodDescribe = getMethodDescribe("getDeviceLogData");
List<DeviceLogVO> list = deviceLogService.getDeviceLogData(deviceLogParam); Page<DeviceLogVO> list = deviceLogService.getDeviceLogData(deviceLogParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); 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.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pojo.vo.ShowVersionVO;
import com.njcn.device.pojo.vo.VersionVO; import com.njcn.device.pojo.vo.VersionVO;
import com.njcn.device.service.ProgramVersionService; import com.njcn.device.service.ProgramVersionService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
@@ -70,12 +69,16 @@ public class ProgramVersionController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getProgramVersionById") @PostMapping("/getProgramVersionById")
@ApiOperation("修改版本回显") @ApiOperation("版本文件是否存在")
@ApiImplicitParam(name = "id", value = "终端版本id", required = true) @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"); String methodDescribe = getMethodDescribe("getProgramVersionById");
ShowVersionVO result = programService.getProgramVersionById(id); boolean res = programService.getProgramVersionById(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); if (res) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} else {
throw new BusinessException(CommonResponseEnum.NO_DATA);
}
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@@ -101,6 +104,7 @@ public class ProgramVersionController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateVersionFlag") @PostMapping("/updateVersionFlag")
@ApiOperation("修改程序版本状态") @ApiOperation("修改程序版本状态")
@ApiImplicitParam(name = "id", value = "终端版本id", required = true)
public HttpResult updateVersionFlag(@RequestParam("id") String id) { public HttpResult updateVersionFlag(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("updateVersionFlag"); String methodDescribe = getMethodDescribe("updateVersionFlag");
boolean res = programService.updateVersionFlag(id); boolean res = programService.updateVersionFlag(id);
@@ -114,6 +118,7 @@ public class ProgramVersionController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/delProgramVersion") @PostMapping("/delProgramVersion")
@ApiOperation("删除程序版本") @ApiOperation("删除程序版本")
@ApiImplicitParam(name = "id", value = "终端版本id", required = true)
public HttpResult delProgramVersion(@RequestParam("id") String id) { public HttpResult delProgramVersion(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("delProgramVersion"); String methodDescribe = getMethodDescribe("delProgramVersion");
boolean res = programService.delProgramVersion(id); 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; 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.DeviceLogVO;
import com.njcn.device.pojo.vo.EventLogVO; import com.njcn.device.pojo.vo.EventLogVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @version 1.0.0 * @version 1.0.0
* @author: chenchao * @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; package com.njcn.device.mapper;
import com.njcn.device.pojo.vo.ShowVersionVO;
import com.njcn.device.pojo.vo.VersionVO; import com.njcn.device.pojo.vo.VersionVO;
import java.util.List; import java.util.List;
@@ -15,10 +16,10 @@ public interface ProgramVersionMapper {
* 获取终端版本信息,根据装置型号查询 * 获取终端版本信息,根据装置型号查询
*/ */
List<VersionVO> getVersion(String devType); List<VersionVO> getVersion(String devType);
// /** /**
// * 修改版本回显 * 根据id获取终端版本信息
// */ */
// ShowVersionVO getProgramVersionById(String 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 id="getDeviceLogData" resultType="DeviceLogVO">
SELECT SELECT
T.`Logs_Index` id, A.`Name` name,
L.`Name` name, B.`Name` type,
D.`Name` type, C.`Name` updateBy
T.`Terminal_Describe` remark,
T.`Update_Time` updateTime,
T.`Update_By` updateBy
FROM FROM
pqs_terminallogs T, pq_line A,
pq_line L, sys_dict_data B,
sys_dict_data D sys_user C
WHERE WHERE
T.State = 1 A.Id = #{lineIds}
AND T.Obj_Index = L.Id AND B.Id = #{terminalTypes}
AND T.Terminal_Type = D.Id AND C.Id = #{updateBys}
<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>
</select> </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 id="getEventLogData" resultType="EventLogVO">
SELECT SELECT

View File

@@ -27,11 +27,14 @@
</if> </if>
</select> </select>
<!-- <select id="getProgramVersionById" resultType="ShowVersionVO">--> <select id="getProgramVersionById" resultType="ShowVersionVO">
<!-- SELECT--> SELECT
<!-- FROM--> `File` file
<!-- WHERE--> FROM
<!-- </select>--> cld_version
WHERE Id = #{id}
AND State = 1
</select>
<update id="updateVersionFlag"> <update id="updateVersionFlag">
UPDATE 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.DeviceLogVO;
import com.njcn.device.pojo.vo.EventLogVO; import com.njcn.device.pojo.vo.EventLogVO;
import java.util.List;
/** /**
* @version 1.0.0 * @version 1.0.0
* @author: chenchao * @author: chenchao
@@ -20,7 +18,7 @@ public interface LogManageService {
* @param deviceLogParam * @param deviceLogParam
* @return * @return
*/ */
List<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam); Page<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam);
/** /**
* 获取暂降推送日志列表 * 获取暂降推送日志列表
* @param eventLogParam * @param eventLogParam

View File

@@ -1,7 +1,6 @@
package com.njcn.device.service; package com.njcn.device.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.pojo.vo.ShowVersionVO;
import com.njcn.device.pojo.vo.VersionVO; import com.njcn.device.pojo.vo.VersionVO;
import org.springframework.web.multipart.MultipartFile; 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); boolean addProgramVersion(String name, String protocol, LocalDate date, String devType, String remark, String versionType, MultipartFile file);
/** /**
* 修改版本回显 * 版本文件是否存在
* @return * @return
*/ */
ShowVersionVO getProgramVersionById(String id); boolean getProgramVersionById(String id);
/** /**
* 修改程序版本管理信息 * 修改程序版本管理信息
* @return * @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; 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.mapper.LogManageMapper; import com.njcn.device.mapper.LogManageMapper;
import com.njcn.device.pojo.constant.DeviceValidMessage; import com.njcn.device.pojo.constant.DeviceValidMessage;
import com.njcn.device.pojo.param.DeviceLogParam; import com.njcn.device.pojo.param.DeviceLogParam;
import com.njcn.device.pojo.param.EventLogParam; import com.njcn.device.pojo.param.EventLogParam;
import com.njcn.device.pojo.po.EventPushLogs; 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.DeviceLogVO;
import com.njcn.device.pojo.vo.EventLogVO; import com.njcn.device.pojo.vo.EventLogVO;
import com.njcn.device.service.LogManageService; import com.njcn.device.service.LogManageService;
@@ -42,14 +44,38 @@ public class LogManageServiceImpl implements LogManageService {
private final InfluxDbUtils influxDbUtils; private final InfluxDbUtils influxDbUtils;
@Override @Override
public List<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam) { public Page<DeviceLogVO> getDeviceLogData(DeviceLogParam deviceLogParam) {
if (deviceLogParam.getType().isEmpty()) { Page<DeviceLogVO> page = new Page<>();
deviceLogParam.setType(null); 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);
}
//当前页数据
page.setRecords(logData);
}
} }
deviceLogParam.setSearchBeginTime(deviceLogParam.getSearchBeginTime()+" 00:00:00"); return page;
deviceLogParam.setSearchEndTime(deviceLogParam.getSearchEndTime()+" 23:59:59");
List<DeviceLogVO> logData = logManageMapper.getDeviceLogData(deviceLogParam);
return logData;
} }
@@ -115,6 +141,32 @@ public class LogManageServiceImpl implements LogManageService {
return page; 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查询暂降事件相关信息 * influxDB查询暂降事件相关信息
* @param startTime * @param startTime
@@ -127,7 +179,7 @@ public class LogManageServiceImpl implements LogManageService {
StringBuilder string = new StringBuilder(); StringBuilder string = new StringBuilder();
string.append(DeviceValidMessage.TIME + " >= '" + startTime + DeviceValidMessage.START_TIME + "' and " + DeviceValidMessage.TIME + " <= '" + endTime + DeviceValidMessage.END_TIME + "'"); string.append(DeviceValidMessage.TIME + " >= '" + startTime + DeviceValidMessage.START_TIME + "' and " + DeviceValidMessage.TIME + " <= '" + endTime + DeviceValidMessage.END_TIME + "'");
if (result==1 || result==2) { if (result==1 || result==2) {
string.append(" and result=" + result); string.append(" and result=" + result).append(" tz('Asia/Shanghai')");
} }
//sql语句 //sql语句
String sql = "SELECT * FROM pqs_event_push_logs WHERE " + string; 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.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @version 1.0.0 * @version 1.0.0
@@ -99,14 +100,11 @@ public class ProgramVersionServiceImpl extends ServiceImpl<VersionMapper, Versio
} }
@Override @Override
public ShowVersionVO getProgramVersionById(String id) { public boolean getProgramVersionById(String id) {
// ShowVersionVO showVersionVO = programVersionMapper.getProgramVersionById(id); ShowVersionVO showVersionVO = programVersionMapper.getProgramVersionById(id);
return !Objects.isNull(showVersionVO);
return null;
} }
@Override @Override
public boolean updateProgramVersion(String id, String name, String protocol, LocalDate date, String devType, String remark, String versionType, MultipartFile file) { public boolean updateProgramVersion(String id, String name, String protocol, LocalDate date, String devType, String remark, String versionType, MultipartFile file) {
check(id,name,true); check(id,name,true);
@@ -149,46 +147,6 @@ public class ProgramVersionServiceImpl extends ServiceImpl<VersionMapper, Versio
return true; 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) { private Boolean judgeFileType(String subffix) {
boolean result = false; boolean result = false;

View File

@@ -5,7 +5,7 @@ import com.njcn.device.api.LineFeignClient;
import com.njcn.device.pojo.dto.PollutionParamDTO; import com.njcn.device.pojo.dto.PollutionParamDTO;
import com.njcn.device.pojo.po.Overlimit; import com.njcn.device.pojo.po.Overlimit;
import com.njcn.executor.pojo.vo.*; import com.njcn.executor.pojo.vo.*;
import com.njcn.harmonic.constant.Param; import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.influxdb.utils.InfluxDbUtils;
import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
@@ -40,8 +40,6 @@ import java.util.stream.Collectors;
@AllArgsConstructor @AllArgsConstructor
public class LimitRateJob { public class LimitRateJob {
private final String DATABASE = "pqsbase";
private final InfluxDbUtils influxDbUtils; private final InfluxDbUtils influxDbUtils;
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
@@ -956,8 +954,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and value_type = 'AVG' and quality_flag = '1' group by line_id tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and value_type = 'AVG' and quality_flag = '0' group by line_id ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT count(freq) AS all_time FROM data_v where " + stringBuilder; String sql = "SELECT count(freq) AS all_time FROM "+ InfluxDBPublicParam.DATA_V+" where " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class); List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class);
@@ -987,8 +985,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and value_type = 'AVG' and quality_flag = '1' group by line_id tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and quality_flag = '0' group by line_id ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT count(plt) AS flicker_all_time FROM data_plt where " + stringBuilder; String sql = "SELECT count(plt) AS flicker_all_time FROM "+ InfluxDBPublicParam.DATA_PLT+" where " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataPlt> list = resultMapper.toPOJO(sqlResult, DataPlt.class); List<DataPlt> list = resultMapper.toPOJO(sqlResult, DataPlt.class);
@@ -1018,8 +1016,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_harmrate_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_HARM_RATE_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataHarmRateV> list = resultMapper.toPOJO(sqlResult, DataHarmRateV.class); List<DataHarmRateV> list = resultMapper.toPOJO(sqlResult, DataHarmRateV.class);
@@ -1049,8 +1047,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_i WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_I+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataI> list = resultMapper.toPOJO(sqlResult, DataI.class); List<DataI> list = resultMapper.toPOJO(sqlResult, DataI.class);
@@ -1080,8 +1078,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_inharm_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_IN_HARM_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataInHarmV> list = resultMapper.toPOJO(sqlResult, DataInHarmV.class); List<DataInHarmV> list = resultMapper.toPOJO(sqlResult, DataInHarmV.class);
@@ -1111,8 +1109,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class); List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class);
@@ -1143,8 +1141,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class); List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class);
@@ -1174,8 +1172,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_i WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_I+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataI> list = resultMapper.toPOJO(sqlResult, DataI.class); List<DataI> list = resultMapper.toPOJO(sqlResult, DataI.class);
@@ -1205,8 +1203,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class); List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class);
@@ -1236,8 +1234,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class); List<DataV> list = resultMapper.toPOJO(sqlResult, DataV.class);
@@ -1267,8 +1265,8 @@ public class LimitRateJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'MAX' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM data_plt WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_PLT+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DataPlt> list = resultMapper.toPOJO(sqlResult, DataPlt.class); List<DataPlt> list = resultMapper.toPOJO(sqlResult, DataPlt.class);
@@ -1357,11 +1355,11 @@ public class LimitRateJob {
fields.put("inuharm_14_overtime",item.getInuHarm14OverTime()); fields.put("inuharm_14_overtime",item.getInuHarm14OverTime());
fields.put("inuharm_15_overtime",item.getInuHarm15OverTime()); fields.put("inuharm_15_overtime",item.getInuHarm15OverTime());
fields.put("inuharm_16_overtime",item.getInuHarm16OverTime()); fields.put("inuharm_16_overtime",item.getInuHarm16OverTime());
Point point = influxDbUtils.pointBuilder("limit_rate", time, TimeUnit.MILLISECONDS, tags, fields); Point point = influxDbUtils.pointBuilder(InfluxDBPublicParam.LIMIT_RATE, time, TimeUnit.MILLISECONDS, tags, fields);
BatchPoints batchPoints = BatchPoints.database(DATABASE).tag("line_id", item.getLineId()).tag("phasic_type",item.getPhasicType()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build(); BatchPoints batchPoints = BatchPoints.database(InfluxDBPublicParam.DATABASE).tag(InfluxDBPublicParam.LINE_ID, item.getLineId()).tag(InfluxDBPublicParam.PHASIC_TYPE,item.getPhasicType()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
batchPoints.point(point); batchPoints.point(point);
records.add(batchPoints.lineProtocol()); records.add(batchPoints.lineProtocol());
}); });
influxDbUtils.batchInsert(DATABASE,"", InfluxDB.ConsistencyLevel.ALL, records); influxDbUtils.batchInsert(InfluxDBPublicParam.DATABASE,"", InfluxDB.ConsistencyLevel.ALL, records);
} }
} }

View File

@@ -5,8 +5,8 @@ import com.njcn.device.api.LineFeignClient;
import com.njcn.device.pojo.dto.PollutionParamDTO; import com.njcn.device.pojo.dto.PollutionParamDTO;
import com.njcn.device.pojo.po.Overlimit; import com.njcn.device.pojo.po.Overlimit;
import com.njcn.executor.pojo.vo.*; import com.njcn.executor.pojo.vo.*;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.pojo.po.LimitTarget; import com.njcn.harmonic.pojo.po.LimitTarget;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils; import com.njcn.influxdb.utils.InfluxDbUtils;
import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
@@ -40,8 +40,6 @@ import java.util.stream.Collectors;
@AllArgsConstructor @AllArgsConstructor
public class LimitTargetJob { public class LimitTargetJob {
private final String DATABASE = "pqsbase";
private final InfluxDbUtils influxDbUtils; private final InfluxDbUtils influxDbUtils;
private final LineFeignClient lineFeignClient; private final LineFeignClient lineFeignClient;
@@ -573,8 +571,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and value_type = 'AVG' and quality_flag = '1' group by line_id tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and value_type = 'AVG' and quality_flag = '0' group by line_id ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT count(freq) AS all_time FROM day_v where " + stringBuilder; String sql = "SELECT count(freq) AS all_time FROM "+ InfluxDBPublicParam.DAY_V+" where " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class); List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
@@ -604,8 +602,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and value_type = 'AVG' and quality_flag = '1' group by line_id tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'A' and quality_flag = '0' group by line_id ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT count(plt) AS flicker_all_time FROM day_plt where " + stringBuilder; String sql = "SELECT count(plt) AS flicker_all_time FROM "+ InfluxDBPublicParam.DAY_PLT+" where " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayPlt> list = resultMapper.toPOJO(sqlResult, DayPlt.class); List<DayPlt> list = resultMapper.toPOJO(sqlResult, DayPlt.class);
@@ -635,8 +633,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_harmrate_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_HARM_RATE_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayHarmrateV> list = resultMapper.toPOJO(sqlResult, DayHarmrateV.class); List<DayHarmrateV> list = resultMapper.toPOJO(sqlResult, DayHarmrateV.class);
@@ -666,8 +664,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_i WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_I+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class); List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class);
@@ -697,8 +695,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_inharm_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DATA_IN_HARM_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayInharmV> list = resultMapper.toPOJO(sqlResult, DayInharmV.class); List<DayInharmV> list = resultMapper.toPOJO(sqlResult, DayInharmV.class);
@@ -728,8 +726,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class); List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
@@ -760,8 +758,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class); List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
@@ -791,8 +789,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_i WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_I+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class); List<DayI> list = resultMapper.toPOJO(sqlResult, DayI.class);
@@ -822,8 +820,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class); List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
@@ -853,8 +851,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_v WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_V+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class); List<DayV> list = resultMapper.toPOJO(sqlResult, DayV.class);
@@ -884,8 +882,8 @@ public class LimitTargetJob {
stringBuilder.append("line_id='").append(line.get(i)).append("') and "); stringBuilder.append("line_id='").append(line.get(i)).append("') and ");
} }
} }
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'MAX' and quality_flag = '1' tz('Asia/Shanghai')"); stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append("' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and quality_flag = '0' ").append(InfluxDBPublicParam.TIME_ZONE);
String sql = "SELECT * FROM day_plt WHERE " + stringBuilder; String sql = "SELECT * FROM "+ InfluxDBPublicParam.DAY_PLT+" WHERE " + stringBuilder;
QueryResult sqlResult = influxDbUtils.query(sql); QueryResult sqlResult = influxDbUtils.query(sql);
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper(); InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
List<DayPlt> list = resultMapper.toPOJO(sqlResult, DayPlt.class); List<DayPlt> list = resultMapper.toPOJO(sqlResult, DayPlt.class);
@@ -974,11 +972,11 @@ public class LimitTargetJob {
fields.put("inuharm_14_overtime",item.getInuHarm14OverTime()); fields.put("inuharm_14_overtime",item.getInuHarm14OverTime());
fields.put("inuharm_15_overtime",item.getInuHarm15OverTime()); fields.put("inuharm_15_overtime",item.getInuHarm15OverTime());
fields.put("inuharm_16_overtime",item.getInuHarm16OverTime()); fields.put("inuharm_16_overtime",item.getInuHarm16OverTime());
Point point = influxDbUtils.pointBuilder("limit_target", time, TimeUnit.MILLISECONDS, tags, fields); Point point = influxDbUtils.pointBuilder(InfluxDBPublicParam.LIMIT_TARGET, time, TimeUnit.MILLISECONDS, tags, fields);
BatchPoints batchPoints = BatchPoints.database(DATABASE).tag("line_id", item.getLineId()).tag("phasic_type",item.getPhasicType()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build(); BatchPoints batchPoints = BatchPoints.database(InfluxDBPublicParam.DATABASE).tag(InfluxDBPublicParam.LINE_ID, item.getLineId()).tag(InfluxDBPublicParam.PHASIC_TYPE,item.getPhasicType()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
batchPoints.point(point); batchPoints.point(point);
records.add(batchPoints.lineProtocol()); records.add(batchPoints.lineProtocol());
}); });
influxDbUtils.batchInsert(DATABASE,"", InfluxDB.ConsistencyLevel.ALL, records); influxDbUtils.batchInsert(InfluxDBPublicParam.DATABASE,"", InfluxDB.ConsistencyLevel.ALL, records);
} }
} }

View File

@@ -116,7 +116,7 @@ public class PollutionJob {
//长时电压闪变 //长时电压闪变
Map<String, Optional<PublicDTO>> map9 = getFlicker(); Map<String, Optional<PublicDTO>> map9 = getFlicker();
for (String key : map9.keySet()) { for (String key : map9.keySet()) {
flickerList.add(map8.get(key).get()); flickerList.add(map9.get(key).get());
} }
//组装数据 //组装数据
for (PollutionDTO item1 : pollutionList) { for (PollutionDTO item1 : pollutionList) {