1.电能质量代码调整
2.微服务-监测点数据完整性调用中心任务 3.分布式光伏部分接口移植
This commit is contained in:
@@ -163,6 +163,8 @@ public interface InfluxDBPublicParam {
|
|||||||
* 时区
|
* 时区
|
||||||
*/
|
*/
|
||||||
String TIME_ZONE = " tz('Asia/Shanghai')";
|
String TIME_ZONE = " tz('Asia/Shanghai')";
|
||||||
|
String TZ = "Asia/Shanghai";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日起始时间
|
* 日起始时间
|
||||||
@@ -261,4 +263,9 @@ public interface InfluxDBPublicParam {
|
|||||||
*/
|
*/
|
||||||
String PHASIC_TYPET = "T";
|
String PHASIC_TYPET = "T";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每天固定时间分钟
|
||||||
|
*/
|
||||||
|
Integer DAY_MINUTE = 1440;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,4 +60,6 @@ public interface ValidMessage {
|
|||||||
|
|
||||||
String IP_FORMAT_ERROR = "IP格式非法";
|
String IP_FORMAT_ERROR = "IP格式非法";
|
||||||
|
|
||||||
|
String DEVICE_VERSION_NOT_BLANK = "装置版本json文件不能为空,请检查deviceVersionFile参数";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.device.api.fallback.LineFeignClientFallbackFactory;
|
import com.njcn.device.api.fallback.LineFeignClientFallbackFactory;
|
||||||
import com.njcn.device.pojo.dto.*;
|
import com.njcn.device.pojo.dto.*;
|
||||||
import com.njcn.device.pojo.po.Line;
|
import com.njcn.device.pojo.po.Line;
|
||||||
|
import com.njcn.device.pojo.po.LineDetail;
|
||||||
import com.njcn.device.pojo.po.Overlimit;
|
import com.njcn.device.pojo.po.Overlimit;
|
||||||
import com.njcn.device.pojo.vo.*;
|
import com.njcn.device.pojo.vo.*;
|
||||||
import org.apache.commons.collections.map.MultiValueMap;
|
import org.apache.commons.collections.map.MultiValueMap;
|
||||||
@@ -189,4 +190,15 @@ public interface LineFeignClient {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("getBaseLineList")
|
@PostMapping("getBaseLineList")
|
||||||
HttpResult<List<Line>> getBaseLineList(@RequestBody List<String> list);
|
HttpResult<List<Line>> getBaseLineList(@RequestBody List<String> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: 获取指定条件的监测点信息
|
||||||
|
* @param list 监测点id集合
|
||||||
|
* @author xy
|
||||||
|
* @date 2022/7/8 14:24
|
||||||
|
* @return 监测点详情集合
|
||||||
|
*/
|
||||||
|
@PostMapping("getLineDetail")
|
||||||
|
HttpResult<List<LineDetail>> getLineDetail(@RequestParam(required = false,value = "list") List<String> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.device.api.LineFeignClient;
|
import com.njcn.device.api.LineFeignClient;
|
||||||
import com.njcn.device.pojo.dto.*;
|
import com.njcn.device.pojo.dto.*;
|
||||||
import com.njcn.device.pojo.po.Line;
|
import com.njcn.device.pojo.po.Line;
|
||||||
|
import com.njcn.device.pojo.po.LineDetail;
|
||||||
import com.njcn.device.pojo.po.Overlimit;
|
import com.njcn.device.pojo.po.Overlimit;
|
||||||
import com.njcn.device.pojo.vo.*;
|
import com.njcn.device.pojo.vo.*;
|
||||||
import com.njcn.device.utils.DeviceEnumUtil;
|
import com.njcn.device.utils.DeviceEnumUtil;
|
||||||
import feign.hystrix.FallbackFactory;
|
import feign.hystrix.FallbackFactory;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -147,7 +149,11 @@ public class LineFeignClientFallbackFactory implements FallbackFactory<LineFeign
|
|||||||
throw new BusinessException(finalExceptionEnum);
|
throw new BusinessException(finalExceptionEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResult<List<LineDetail>> getLineDetail(List<String> list) {
|
||||||
|
log.error("{}异常,降级处理,异常为:{}", "获取监测点详情 ", throwable.toString());
|
||||||
|
throw new BusinessException(finalExceptionEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ import com.njcn.common.pojo.response.HttpResult;
|
|||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
import com.njcn.device.mapper.DeviceMapper;
|
import com.njcn.device.mapper.DeviceMapper;
|
||||||
|
import com.njcn.device.mapper.LineDetailMapper;
|
||||||
import com.njcn.device.mapper.LineMapper;
|
import com.njcn.device.mapper.LineMapper;
|
||||||
import com.njcn.device.pojo.dto.*;
|
import com.njcn.device.pojo.dto.*;
|
||||||
import com.njcn.device.pojo.po.Device;
|
import com.njcn.device.pojo.po.Device;
|
||||||
import com.njcn.device.pojo.po.Line;
|
import com.njcn.device.pojo.po.Line;
|
||||||
|
import com.njcn.device.pojo.po.LineDetail;
|
||||||
import com.njcn.device.pojo.po.Overlimit;
|
import com.njcn.device.pojo.po.Overlimit;
|
||||||
import com.njcn.device.pojo.vo.*;
|
import com.njcn.device.pojo.vo.*;
|
||||||
import com.njcn.device.service.LineService;
|
import com.njcn.device.service.LineService;
|
||||||
@@ -42,6 +44,9 @@ public class LineController extends BaseController {
|
|||||||
|
|
||||||
private final LineMapper lineMapper;
|
private final LineMapper lineMapper;
|
||||||
|
|
||||||
|
private final LineDetailMapper lineDetailMapper;
|
||||||
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/getLineDetailData")
|
@PostMapping("/getLineDetailData")
|
||||||
@ApiOperation("根据监测点id获取监测点详情")
|
@ApiOperation("根据监测点id获取监测点详情")
|
||||||
@@ -256,4 +261,21 @@ public class LineController extends BaseController {
|
|||||||
String methodDescribe = getMethodDescribe("getBaseLineList");
|
String methodDescribe = getMethodDescribe("getBaseLineList");
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineService.getBaseLineList(lineIndex), methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineService.getBaseLineList(lineIndex), methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: 获取指定条件的监测点信息
|
||||||
|
* @author xy
|
||||||
|
* @date 2022/7/8 14:24
|
||||||
|
* @return 监测点详情集合
|
||||||
|
*/
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getLineDetail")
|
||||||
|
@ApiOperation("根据监测点集合获取监测点详情")
|
||||||
|
@ApiImplicitParam(name = "list", value = "监测点集合")
|
||||||
|
public HttpResult<List<LineDetail>> getLineDetail(@RequestParam(required = false) List<String> list) {
|
||||||
|
String methodDescribe = getMethodDescribe("getLineDetail");
|
||||||
|
LogUtil.njcnDebug(log, "{},监测点集合:{}", methodDescribe, list);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, lineDetailMapper.getSpecifyLineDetail(list), methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,4 +25,12 @@ public interface LineDetailMapper extends BaseMapper<LineDetail> {
|
|||||||
*/
|
*/
|
||||||
List<LineDetail> getLineDetail(@Param("devIndex") String devIndex, @Param("num") List<Integer> num);
|
List<LineDetail> getLineDetail(@Param("devIndex") String devIndex, @Param("num") List<Integer> num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实际设备下的监测点&&稳态系统和两个系统的监测点&&投运终端下的监测点
|
||||||
|
* 获取指定条件的监测点信息
|
||||||
|
* @param list 监测点集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
List<LineDetail> getSpecifyLineDetail(@Param("list") List<String> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,26 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getSpecifyLineDetail" resultType="LineDetail">
|
||||||
|
SELECT
|
||||||
|
D.*
|
||||||
|
FROM
|
||||||
|
pq_line A1,
|
||||||
|
pq_line A2,
|
||||||
|
pq_line A3,
|
||||||
|
pq_line_detail B,
|
||||||
|
pq_device C,
|
||||||
|
pq_line_detail D
|
||||||
|
WHERE
|
||||||
|
<if test="list != null and list.size() > 0">
|
||||||
|
A1.Id in
|
||||||
|
<foreach collection="list" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
AND
|
||||||
|
</if>
|
||||||
|
A1.`Level` = 6 AND A1.Id = B.Id AND
|
||||||
|
A1.Pid = A2.Id AND A2.Pid = A3.Id AND A3.Id = C.Id AND
|
||||||
|
C.Dev_Model = 1 AND C.Dev_Data_Type IN (1,2) AND C.Run_Flag = 0 AND A1.Id = D.Id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public enum HarmonicResponseEnum {
|
|||||||
* A00550 ~ A00649
|
* A00550 ~ A00649
|
||||||
*/
|
*/
|
||||||
HARMONIC_COMMON_ERROR("A00550","谐波模块异常"),
|
HARMONIC_COMMON_ERROR("A00550","谐波模块异常"),
|
||||||
LIMIT_RATE_ERROR("A00551","稳态监测点数据异常")
|
|
||||||
|
LIMIT_MISSING_ERROR("A00551","limit_rate表缺失限值数据")
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.njcn.harmonic.pojo.photoVO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/7 9:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WarningAreaVO implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("区域id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("区域名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("在线监测点数量(个)")
|
||||||
|
private Integer onlineMonitorCounts = 0;
|
||||||
|
|
||||||
|
@ApiModelProperty("告警监测点数量(个)")
|
||||||
|
private Integer alertMonitorCounts = 0;
|
||||||
|
|
||||||
|
@ApiModelProperty("告警次数")
|
||||||
|
private Integer alertCounts = 0;
|
||||||
|
|
||||||
|
@ApiModelProperty("告警频次(次/点)")
|
||||||
|
private Double alertAlarmFrequency = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("频率偏差")
|
||||||
|
private Double frequencyDeviation = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压偏差")
|
||||||
|
private Double voltageDeviation = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("谐波电压")
|
||||||
|
private Double harmonicVoltage = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("谐波电流")
|
||||||
|
private Double harmonicCurrent = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("三相电压不平衡")
|
||||||
|
private Double threePhaseVoltageUnbalance = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("闪变")
|
||||||
|
private Double flicker = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("间谐波电压")
|
||||||
|
private Double interHarmonic = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("负序电流")
|
||||||
|
private Double negative = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("短时中断")
|
||||||
|
private Double shortInterruption = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压暂降")
|
||||||
|
private Double voltageDip = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压暂升")
|
||||||
|
private Double voltageSwell = -1.0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.njcn.harmonic.pojo.photoVO;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/7 14:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WarningMonitorVO implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("监测点id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("监测点名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("告警次数")
|
||||||
|
private Integer alertCounts = 0;
|
||||||
|
|
||||||
|
@ApiModelProperty("告警频次(次/点)")
|
||||||
|
private Double alertAlarmFrequency = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("频率偏差")
|
||||||
|
private Double frequencyDeviation = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压偏差")
|
||||||
|
private Double voltageDeviation = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("谐波电压")
|
||||||
|
private Double harmonicVoltage = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("谐波电流")
|
||||||
|
private Double harmonicCurrent = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("三相电压不平衡")
|
||||||
|
private Double threePhaseVoltageUnbalance = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("闪变")
|
||||||
|
private Double flicker = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("间谐波电压")
|
||||||
|
private Double interHarmonic = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("负序电流")
|
||||||
|
private Double negative = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("短时中断")
|
||||||
|
private Double shortInterruption = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压暂降")
|
||||||
|
private Double voltageDip = -1.0;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压暂升")
|
||||||
|
private Double voltageSwell = -1.0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package com.njcn.harmonic.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
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.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.common.utils.LogUtil;
|
||||||
|
import com.njcn.device.pojo.param.DeviceInfoParam;
|
||||||
|
import com.njcn.harmonic.pojo.param.HistoryParam;
|
||||||
|
import com.njcn.harmonic.pojo.photoVO.WarningAreaVO;
|
||||||
|
import com.njcn.harmonic.pojo.photoVO.WarningMonitorVO;
|
||||||
|
import com.njcn.harmonic.pojo.vo.*;
|
||||||
|
import com.njcn.harmonic.service.HistoryResultService;
|
||||||
|
import com.njcn.harmonic.service.IAnalyzeService;
|
||||||
|
import com.njcn.harmonic.service.PhotovoltaicService;
|
||||||
|
import com.njcn.harmonic.service.SteadyQualifyService;
|
||||||
|
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.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/5 10:37
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/photovoltaicHarmonic")
|
||||||
|
@Api(tags = "分布式光伏-稳态")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PhotovoltaicController extends BaseController {
|
||||||
|
|
||||||
|
private final IAnalyzeService IAnalyzeService;
|
||||||
|
|
||||||
|
private final SteadyQualifyService steadyQualifyService;
|
||||||
|
|
||||||
|
private final HistoryResultService historyResultService;
|
||||||
|
|
||||||
|
private final PhotovoltaicService photovoltaicService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/overAreaStatistics")
|
||||||
|
@ApiOperation("稳态指标超标统计")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<Page<OverAreaLimitVO>> overAreaStatistics(@Validated @RequestBody OverAreaVO param) {
|
||||||
|
String methodDescribe = getMethodDescribe("overAreaStatistics");
|
||||||
|
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, param);
|
||||||
|
Page<OverAreaLimitVO> list = IAnalyzeService.getAreaData(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/test")
|
||||||
|
@ApiOperation("有问题-稳态指标超标分类统计")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<Page<OverAreaLimitVO>> test(@Validated @RequestBody OverAreaVO param) {
|
||||||
|
String methodDescribe = getMethodDescribe("overAreaStatistics");
|
||||||
|
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, param);
|
||||||
|
Page<OverAreaLimitVO> list = IAnalyzeService.getAreaData(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/lineOverLimit")
|
||||||
|
@ApiOperation("稳态指标超标明细")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<Page<MonitorOverLimitVO>> lineOverLimit(@Validated @RequestBody OverAreaVO param) {
|
||||||
|
String methodDescribe = getMethodDescribe("lineOverLimit");
|
||||||
|
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, param);
|
||||||
|
Page<MonitorOverLimitVO> list = IAnalyzeService.monitorOverLimitVO(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getSteadyQualifyData")
|
||||||
|
@ApiOperation("稳态合格率统计")
|
||||||
|
@ApiImplicitParam(name = "steadyParam", value = "稳态列表参数", required = true)
|
||||||
|
public HttpResult<List<SteadyQualifyVO>> getSteadyQualifyData(@RequestBody @Validated DeviceInfoParam.BusinessParam steadyParam){
|
||||||
|
String methodDescribe = getMethodDescribe("getSteadyQualifyData");
|
||||||
|
List<SteadyQualifyVO> list = steadyQualifyService.getSteadyQualifyData(steadyParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/getHistoryResult")
|
||||||
|
@ApiOperation("稳态指标历史趋势")
|
||||||
|
@ApiImplicitParam(name = "historyParam", value = "稳态数据分析参数", required = true)
|
||||||
|
public HttpResult<List<HistoryDataResultVO>> getHistoryResult(@RequestBody @Validated HistoryParam historyParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("getHistoryResult");
|
||||||
|
List<HistoryDataResultVO> list = historyResultService.getHistoryResult(historyParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/wholeEvaluation")
|
||||||
|
@ApiOperation("有问题-全网水平评价")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<List<HistoryDataResultVO>> wholeEvaluation(@Validated @RequestBody OverAreaVO param) {
|
||||||
|
String methodDescribe = getMethodDescribe("wholeEvaluation");
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/areaWithEvaluation")
|
||||||
|
@ApiOperation("有问题-台区水平评价")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<List<HistoryDataResultVO>> areaWithEvaluation(@Validated @RequestBody OverAreaVO param) {
|
||||||
|
String methodDescribe = getMethodDescribe("areaWithEvaluation");
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/areaWarningManage")
|
||||||
|
@ApiOperation("区域告警管理")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<Page<WarningAreaVO>> areaWarningManage(@Validated @RequestBody OverAreaVO param) {
|
||||||
|
String methodDescribe = getMethodDescribe("areaWarningManage");
|
||||||
|
Page<WarningAreaVO> page = photovoltaicService.areaWarningManage(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/monitorWarningManage")
|
||||||
|
@ApiOperation("监测点告警管理")
|
||||||
|
@ApiImplicitParam(name = "param", value = "实体参数", required = true)
|
||||||
|
public HttpResult<Page<WarningMonitorVO>> monitorWarningManage(@Validated @RequestBody OverAreaVO param) {
|
||||||
|
String methodDescribe = getMethodDescribe("monitorWarningManage");
|
||||||
|
Page<WarningMonitorVO> page = photovoltaicService.monitorWarningManage(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.harmonic.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.harmonic.pojo.photoVO.WarningAreaVO;
|
||||||
|
import com.njcn.harmonic.pojo.photoVO.WarningMonitorVO;
|
||||||
|
import com.njcn.harmonic.pojo.vo.OverAreaVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 徐扬
|
||||||
|
*/
|
||||||
|
public interface PhotovoltaicService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述:区域告警管理
|
||||||
|
* @author xy
|
||||||
|
* @param param 参数
|
||||||
|
* @date 2022/7/7 9:48
|
||||||
|
* @return 分页数据
|
||||||
|
*/
|
||||||
|
Page<WarningAreaVO> areaWarningManage(OverAreaVO param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述:监测点告警管理
|
||||||
|
* @author xy
|
||||||
|
* @param param 参数
|
||||||
|
* @date 2022/7/7 9:48
|
||||||
|
* @return 分页数据
|
||||||
|
*/
|
||||||
|
Page<WarningMonitorVO> monitorWarningManage(OverAreaVO param);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -152,8 +152,6 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
|
|||||||
LimitRate limitRate = map.get(item2).get(0);
|
LimitRate limitRate = map.get(item2).get(0);
|
||||||
if (!Objects.isNull(limitRate)){
|
if (!Objects.isNull(limitRate)){
|
||||||
onlineMonitorCount++;
|
onlineMonitorCount++;
|
||||||
System.out.println("1==:" + limitRate.getFreqDevOverTime());
|
|
||||||
System.out.println("2==:" + limitRate.getVoltageDevOverTime());
|
|
||||||
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
|
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
|
||||||
alertMonitorCount++;
|
alertMonitorCount++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,443 @@
|
|||||||
|
package com.njcn.harmonic.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.shaded.com.google.common.collect.Lists;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.device.api.GeneralDeviceInfoClient;
|
||||||
|
import com.njcn.device.api.LineFeignClient;
|
||||||
|
import com.njcn.device.pojo.dto.GeneralDeviceDTO;
|
||||||
|
import com.njcn.device.pojo.dto.OverLimitLineDTO;
|
||||||
|
import com.njcn.device.pojo.dto.PollutionParamDTO;
|
||||||
|
import com.njcn.device.pojo.dto.WarningSubstationDTO;
|
||||||
|
import com.njcn.harmonic.constant.Param;
|
||||||
|
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||||
|
import com.njcn.harmonic.pojo.photoVO.WarningAreaVO;
|
||||||
|
import com.njcn.harmonic.pojo.photoVO.WarningMonitorVO;
|
||||||
|
import com.njcn.harmonic.pojo.po.EventDetail;
|
||||||
|
import com.njcn.harmonic.pojo.po.LimitRate;
|
||||||
|
import com.njcn.harmonic.pojo.po.LimitTarget;
|
||||||
|
import com.njcn.harmonic.pojo.vo.OverAreaVO;
|
||||||
|
import com.njcn.harmonic.service.PhotovoltaicService;
|
||||||
|
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.influxdb.dto.QueryResult;
|
||||||
|
import org.influxdb.impl.InfluxDBResultMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/7 9:26
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
||||||
|
|
||||||
|
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||||
|
|
||||||
|
private final InfluxDbUtils influxDbUtils;
|
||||||
|
|
||||||
|
private final LineFeignClient lineFeignClient;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Page<WarningAreaVO> areaWarningManage(OverAreaVO param) {
|
||||||
|
List<String> line = new ArrayList<>();
|
||||||
|
Map<String,List<LimitRate>> map = new HashMap<>();
|
||||||
|
Map<String,List<EventDetail>> map2 = new HashMap<>();
|
||||||
|
Page<WarningAreaVO> page = new Page<>();
|
||||||
|
List<WarningAreaVO> list = new ArrayList<>();
|
||||||
|
page.setSize(param.getPageSize());
|
||||||
|
page.setCurrent(param.getPageNum());
|
||||||
|
List<GeneralDeviceDTO> subList = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData();
|
||||||
|
if (!CollectionUtils.isEmpty(subList)){
|
||||||
|
page.setTotal(subList.size());
|
||||||
|
int pages = (int)Math.ceil(subList.size()*1.0/param.getPageSize());
|
||||||
|
page.setPages(pages);
|
||||||
|
List<List<GeneralDeviceDTO>> pageList = Lists.partition(subList,param.getPageSize());
|
||||||
|
List<GeneralDeviceDTO> temList = pageList.get(param.getPageNum()-1);
|
||||||
|
temList.forEach(item->{
|
||||||
|
line.addAll(item.getLineIndexes());
|
||||||
|
});
|
||||||
|
if (!CollectionUtils.isEmpty(line)){
|
||||||
|
List<LimitRate> limitRateList = (List<LimitRate>)getAllData(line,param.getSearchBeginTime(),param.getSearchEndTime(), Param.LIMIT_RATE);
|
||||||
|
if (!CollectionUtils.isEmpty(limitRateList)){
|
||||||
|
map = limitRateList.stream().collect(Collectors.groupingBy(LimitRate::getLineId));
|
||||||
|
}
|
||||||
|
List<EventDetail> eventDetailList = getEventDetail(line,param.getSearchBeginTime(),param.getSearchEndTime());
|
||||||
|
if (!CollectionUtils.isEmpty(eventDetailList)){
|
||||||
|
map2 = eventDetailList.stream().collect(Collectors.groupingBy(EventDetail::getLineId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(temList)){
|
||||||
|
for (GeneralDeviceDTO item : temList) {
|
||||||
|
int onlineMonitorCount = 0,alertMonitorCount = 0,alertCount = 0,freqCount = 0,voltageCount = 0,ubalanceCount = 0,flickerCount = 0,iNegCount = 0,uharmCount = 0,iharmCount = 0,inuharmCount = 0;
|
||||||
|
int freqCounts = 0,voltageCounts = 0,uharmCounts = 0,iharmCounts = 0,ubalanceCounts = 0,flickerCounts = 0,inuharmCounts = 0,iNegCounts = 0;
|
||||||
|
int eventUp = 0,eventDown = 0,eventInterrupt = 0,eventUps = 0,eventDowns = 0,eventInterrupts = 0;
|
||||||
|
WarningAreaVO warningAreaVO = new WarningAreaVO();
|
||||||
|
//单位id
|
||||||
|
warningAreaVO.setId(item.getIndex());
|
||||||
|
//单位名称
|
||||||
|
warningAreaVO.setName(item.getName());
|
||||||
|
if (!CollectionUtils.isEmpty(item.getLineIndexes())){
|
||||||
|
for (String item2 : item.getLineIndexes()) {
|
||||||
|
//谐波统计
|
||||||
|
if (!CollectionUtils.isEmpty(map.get(item2))){
|
||||||
|
LimitRate limitRate = map.get(item2).get(0);
|
||||||
|
if (!Objects.isNull(limitRate)){
|
||||||
|
onlineMonitorCount++;
|
||||||
|
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
|
||||||
|
alertMonitorCount++;
|
||||||
|
}
|
||||||
|
if (limitRate.getFreqDevOverTime() > 0){
|
||||||
|
freqCount++;
|
||||||
|
freqCounts = freqCounts + limitRate.getFreqDevOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getVoltageDevOverTime() > 0){
|
||||||
|
voltageCount++;
|
||||||
|
voltageCounts = voltageCounts + limitRate.getVoltageDevOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getUHarm2OverTime() > 0){
|
||||||
|
uharmCount++;
|
||||||
|
uharmCounts = uharmCounts + limitRate.getUHarm2OverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getIHarm2OverTime() > 0){
|
||||||
|
iharmCount++;
|
||||||
|
iharmCounts = iharmCounts + limitRate.getIHarm2OverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getUBalanceOverTime() > 0){
|
||||||
|
ubalanceCount++;
|
||||||
|
ubalanceCounts = ubalanceCounts + limitRate.getUBalanceOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getFlickerOverTime() > 0){
|
||||||
|
flickerCount++;
|
||||||
|
flickerCounts = flickerCounts + limitRate.getFlickerOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getInuHarm1OverTime() > 0){
|
||||||
|
inuharmCount++;
|
||||||
|
inuharmCounts = inuharmCounts + limitRate.getInuHarm1OverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getINegOverTime() > 0){
|
||||||
|
iNegCount++;
|
||||||
|
iNegCounts = iNegCounts + limitRate.getINegOverTime();
|
||||||
|
}
|
||||||
|
alertCount = limitRate.getFreqDevOverTime() + limitRate.getVoltageDevOverTime() + limitRate.getUBalanceOverTime() + limitRate.getFlickerOverTime() + limitRate.getINegOverTime() + limitRate.getUHarm2OverTime() + limitRate.getIHarm2OverTime() + limitRate.getInuHarm1OverTime();
|
||||||
|
} else {
|
||||||
|
log.info("此监测点在限值表中无数据:" + item2);
|
||||||
|
throw new BusinessException(HarmonicResponseEnum.LIMIT_MISSING_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//暂降统计
|
||||||
|
if (!CollectionUtils.isEmpty(map2.get(item2))){
|
||||||
|
List<EventDetail> eventDetailList = map2.get(item2);
|
||||||
|
if (!CollectionUtils.isEmpty(eventDetailList)){
|
||||||
|
for (EventDetail item3 : eventDetailList) {
|
||||||
|
if (item3.getWaveType() == 1){
|
||||||
|
eventDowns++;
|
||||||
|
} else if (item3.getWaveType() == 2){
|
||||||
|
eventUps++;
|
||||||
|
} else if (item3.getWaveType() == 3){
|
||||||
|
eventInterrupts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventDowns > 0){
|
||||||
|
eventDown++;
|
||||||
|
}
|
||||||
|
if (eventUps > 0){
|
||||||
|
eventUp++;
|
||||||
|
}
|
||||||
|
if (eventInterrupts > 0){
|
||||||
|
eventInterrupt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//在线监测点数量(个)
|
||||||
|
warningAreaVO.setOnlineMonitorCounts(onlineMonitorCount);
|
||||||
|
if (onlineMonitorCount != 0){
|
||||||
|
//告警监测点数量(个)
|
||||||
|
warningAreaVO.setAlertMonitorCounts(alertMonitorCount);
|
||||||
|
//告警次数
|
||||||
|
warningAreaVO.setAlertCounts(alertCount);
|
||||||
|
//告警频次(次/点)
|
||||||
|
warningAreaVO.setAlertAlarmFrequency(alertMonitorCount==0?0: BigDecimal.valueOf(alertCount*1.0/alertMonitorCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//频率偏差
|
||||||
|
warningAreaVO.setFrequencyDeviation(freqCount==0?0:BigDecimal.valueOf(freqCounts*1.0/freqCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//电压偏差
|
||||||
|
warningAreaVO.setVoltageDeviation(voltageCount==0?0:BigDecimal.valueOf(voltageCounts*1.0/voltageCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//谐波电压
|
||||||
|
warningAreaVO.setHarmonicVoltage(uharmCount==0?0:BigDecimal.valueOf(uharmCounts*1.0/uharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//谐波电流
|
||||||
|
warningAreaVO.setHarmonicCurrent(iharmCount==0?0:BigDecimal.valueOf(iharmCounts*1.0/iharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//三相电压不平衡
|
||||||
|
warningAreaVO.setThreePhaseVoltageUnbalance(ubalanceCount==0?0:BigDecimal.valueOf(ubalanceCounts*1.0/ubalanceCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//闪变
|
||||||
|
warningAreaVO.setFlicker(flickerCount==0?0:BigDecimal.valueOf(flickerCounts*1.0/flickerCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//间谐波电压
|
||||||
|
warningAreaVO.setInterHarmonic(inuharmCount==0?0:BigDecimal.valueOf(inuharmCounts*1.0/inuharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//负序电流
|
||||||
|
warningAreaVO.setNegative(iNegCount==0?0:BigDecimal.valueOf(iNegCounts*1.0/iNegCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//电压暂降
|
||||||
|
warningAreaVO.setVoltageDip(eventDown==0?0:BigDecimal.valueOf(eventDowns*1.0/eventDown).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//电压暂升
|
||||||
|
warningAreaVO.setVoltageSwell(eventUp==0?0:BigDecimal.valueOf(eventUps*1.0/eventUp).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//短时中断
|
||||||
|
warningAreaVO.setShortInterruption(eventInterrupt==0?0:BigDecimal.valueOf(eventInterrupts*1.0/eventInterrupt).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
}
|
||||||
|
list.add(warningAreaVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
|
List<WarningAreaVO> recordList = new ArrayList<>();
|
||||||
|
//默认 在线监测点数量 倒叙排序
|
||||||
|
recordList = list.stream().sorted(Comparator.comparing(WarningAreaVO::getOnlineMonitorCounts).reversed().thenComparing(WarningAreaVO::getName)).collect(Collectors.toList());
|
||||||
|
page.setRecords(recordList);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Page<WarningMonitorVO> monitorWarningManage(OverAreaVO param) {
|
||||||
|
List<String> line = new ArrayList<>(),temList = new ArrayList<>();
|
||||||
|
Map<String,List<LimitRate>> map = new HashMap<>();
|
||||||
|
Map<String,List<EventDetail>> map2 = new HashMap<>();
|
||||||
|
Page<WarningMonitorVO> page = new Page<>();
|
||||||
|
List<WarningMonitorVO> list = new ArrayList<>();
|
||||||
|
page.setSize(param.getPageSize());
|
||||||
|
page.setCurrent(param.getPageNum());
|
||||||
|
List<GeneralDeviceDTO> areaList = generalDeviceInfoClient.getPracticalRunDeviceInfo(param).getData();
|
||||||
|
if (!CollectionUtils.isEmpty(areaList)){
|
||||||
|
areaList.forEach(item->{
|
||||||
|
line.addAll(item.getLineIndexes());
|
||||||
|
});
|
||||||
|
if (!CollectionUtils.isEmpty(line)){
|
||||||
|
page.setTotal(line.size());
|
||||||
|
int pages = (int)Math.ceil(line.size()*1.0/param.getPageSize());
|
||||||
|
page.setPages(pages);
|
||||||
|
List<List<String>> pageList = Lists.partition(line,param.getPageSize());
|
||||||
|
temList = pageList.get(param.getPageNum()-1);
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(temList)){
|
||||||
|
List<LimitRate> limitRateList = (List<LimitRate>)getAllData(temList,param.getSearchBeginTime(),param.getSearchEndTime(), Param.LIMIT_RATE);
|
||||||
|
if (!CollectionUtils.isEmpty(limitRateList)){
|
||||||
|
map = limitRateList.stream().collect(Collectors.groupingBy(LimitRate::getLineId));
|
||||||
|
}
|
||||||
|
List<EventDetail> eventDetailList = getEventDetail(temList,param.getSearchBeginTime(),param.getSearchEndTime());
|
||||||
|
if (!CollectionUtils.isEmpty(eventDetailList)){
|
||||||
|
map2 = eventDetailList.stream().collect(Collectors.groupingBy(EventDetail::getLineId));
|
||||||
|
}
|
||||||
|
PollutionParamDTO pollutionParamDTO = new PollutionParamDTO();
|
||||||
|
pollutionParamDTO.setLineList(temList);
|
||||||
|
List<OverLimitLineDTO> overLimitLineList = lineFeignClient.getOverLimitLineInfo(pollutionParamDTO).getData();
|
||||||
|
for (OverLimitLineDTO pojo:overLimitLineList) {
|
||||||
|
String item = pojo.getId();
|
||||||
|
String name = pojo.getLineName();
|
||||||
|
int alertMonitorCount = 0,alertCount = 0,freqCount = 0,voltageCount = 0,ubalanceCount = 0,flickerCount = 0,iNegCount = 0,uharmCount = 0,iharmCount = 0,inuharmCount = 0;
|
||||||
|
int freqCounts = 0,voltageCounts = 0,uharmCounts = 0,iharmCounts = 0,ubalanceCounts = 0,flickerCounts = 0,inuharmCounts = 0,iNegCounts = 0;
|
||||||
|
int eventUp = 0,eventDown = 0,eventInterrupt = 0,eventUps = 0,eventDowns = 0,eventInterrupts = 0;
|
||||||
|
WarningMonitorVO warningMonitorVO = new WarningMonitorVO();
|
||||||
|
//监测点id
|
||||||
|
warningMonitorVO.setId(item);
|
||||||
|
//监测点名称
|
||||||
|
warningMonitorVO.setName(name);
|
||||||
|
//谐波统计
|
||||||
|
if (!CollectionUtils.isEmpty(map.get(item))){
|
||||||
|
LimitRate limitRate = map.get(item).get(0);
|
||||||
|
if (!Objects.isNull(limitRate)){
|
||||||
|
if (limitRate.getFreqDevOverTime() > 0 || limitRate.getVoltageDevOverTime() > 0 || limitRate.getUBalanceOverTime() > 0 || limitRate.getFlickerOverTime() > 0 || limitRate.getINegOverTime() > 0 || limitRate.getUHarm2OverTime() > 0 || limitRate.getIHarm2OverTime() > 0 || limitRate.getInuHarm1OverTime() > 0){
|
||||||
|
alertMonitorCount++;
|
||||||
|
}
|
||||||
|
if (limitRate.getFreqDevOverTime() > 0){
|
||||||
|
freqCount++;
|
||||||
|
freqCounts = freqCounts + limitRate.getFreqDevOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getVoltageDevOverTime() > 0){
|
||||||
|
voltageCount++;
|
||||||
|
voltageCounts = voltageCounts + limitRate.getVoltageDevOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getUHarm2OverTime() > 0){
|
||||||
|
uharmCount++;
|
||||||
|
uharmCounts = uharmCounts + limitRate.getUHarm2OverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getIHarm2OverTime() > 0){
|
||||||
|
iharmCount++;
|
||||||
|
iharmCounts = iharmCounts + limitRate.getIHarm2OverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getUBalanceOverTime() > 0){
|
||||||
|
ubalanceCount++;
|
||||||
|
ubalanceCounts = ubalanceCounts + limitRate.getUBalanceOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getFlickerOverTime() > 0){
|
||||||
|
flickerCount++;
|
||||||
|
flickerCounts = flickerCounts + limitRate.getFlickerOverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getInuHarm1OverTime() > 0){
|
||||||
|
inuharmCount++;
|
||||||
|
inuharmCounts = inuharmCounts + limitRate.getInuHarm1OverTime();
|
||||||
|
}
|
||||||
|
if (limitRate.getINegOverTime() > 0){
|
||||||
|
iNegCount++;
|
||||||
|
iNegCounts = iNegCounts + limitRate.getINegOverTime();
|
||||||
|
}
|
||||||
|
alertCount = limitRate.getFreqDevOverTime() + limitRate.getVoltageDevOverTime() + limitRate.getUBalanceOverTime() + limitRate.getFlickerOverTime() + limitRate.getINegOverTime() + limitRate.getUHarm2OverTime() + limitRate.getIHarm2OverTime() + limitRate.getInuHarm1OverTime();
|
||||||
|
} else {
|
||||||
|
log.info("此监测点在限值表中无数据:" + item);
|
||||||
|
throw new BusinessException(HarmonicResponseEnum.LIMIT_MISSING_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//暂降统计
|
||||||
|
if (!CollectionUtils.isEmpty(map2.get(item))){
|
||||||
|
List<EventDetail> eventDetailList2 = map2.get(item);
|
||||||
|
if (!CollectionUtils.isEmpty(eventDetailList2)){
|
||||||
|
for (EventDetail item3 : eventDetailList2) {
|
||||||
|
if (item3.getWaveType() == 1){
|
||||||
|
eventDowns++;
|
||||||
|
} else if (item3.getWaveType() == 2){
|
||||||
|
eventUps++;
|
||||||
|
} else if (item3.getWaveType() == 3){
|
||||||
|
eventInterrupts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventDowns > 0){
|
||||||
|
eventDown++;
|
||||||
|
}
|
||||||
|
if (eventUps > 0){
|
||||||
|
eventUp++;
|
||||||
|
}
|
||||||
|
if (eventInterrupts > 0){
|
||||||
|
eventInterrupt++;
|
||||||
|
}
|
||||||
|
//告警次数
|
||||||
|
warningMonitorVO.setAlertCounts(alertCount);
|
||||||
|
//告警频次(次/点)
|
||||||
|
warningMonitorVO.setAlertAlarmFrequency(alertMonitorCount==0?0: BigDecimal.valueOf(alertCount*1.0/alertMonitorCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//频率偏差
|
||||||
|
warningMonitorVO.setFrequencyDeviation(freqCount==0?0:BigDecimal.valueOf(freqCounts*1.0/freqCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//电压偏差
|
||||||
|
warningMonitorVO.setVoltageDeviation(voltageCount==0?0:BigDecimal.valueOf(voltageCounts*1.0/voltageCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//谐波电压
|
||||||
|
warningMonitorVO.setHarmonicVoltage(uharmCount==0?0:BigDecimal.valueOf(uharmCounts*1.0/uharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//谐波电流
|
||||||
|
warningMonitorVO.setHarmonicCurrent(iharmCount==0?0:BigDecimal.valueOf(iharmCounts*1.0/iharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//三相电压不平衡
|
||||||
|
warningMonitorVO.setThreePhaseVoltageUnbalance(ubalanceCount==0?0:BigDecimal.valueOf(ubalanceCounts*1.0/ubalanceCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//闪变
|
||||||
|
warningMonitorVO.setFlicker(flickerCount==0?0:BigDecimal.valueOf(flickerCounts*1.0/flickerCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//间谐波电压
|
||||||
|
warningMonitorVO.setInterHarmonic(inuharmCount==0?0:BigDecimal.valueOf(inuharmCounts*1.0/inuharmCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//负序电流
|
||||||
|
warningMonitorVO.setNegative(iNegCount==0?0:BigDecimal.valueOf(iNegCounts*1.0/iNegCount).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//电压暂降
|
||||||
|
warningMonitorVO.setVoltageDip(eventDown==0?0:BigDecimal.valueOf(eventDowns*1.0/eventDown).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//电压暂升
|
||||||
|
warningMonitorVO.setVoltageSwell(eventUp==0?0:BigDecimal.valueOf(eventUps*1.0/eventUp).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
//短时中断
|
||||||
|
warningMonitorVO.setShortInterruption(eventInterrupt==0?0:BigDecimal.valueOf(eventInterrupts*1.0/eventInterrupt).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||||
|
list.add(warningMonitorVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
|
List<WarningMonitorVO> recordList = new ArrayList<>();
|
||||||
|
//默认 监测点告警次数 倒叙排序
|
||||||
|
recordList = list.stream().sorted(Comparator.comparing(WarningMonitorVO::getAlertCounts).reversed()).collect(Collectors.toList());
|
||||||
|
page.setRecords(recordList);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: 处理区域在线监测点数、超标监测点数
|
||||||
|
* @param list 集合
|
||||||
|
* @return
|
||||||
|
* @author xy
|
||||||
|
* @date 2022/2/25 15:05
|
||||||
|
*/
|
||||||
|
private List<?> getAllData(List<String> list, String startTime, String endTime, String databaseName){
|
||||||
|
List<?> result = new ArrayList<>();
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
StringBuilder stringBuilder1 = new StringBuilder();
|
||||||
|
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (");
|
||||||
|
for (int i=0;i<list.size();i++){
|
||||||
|
if (list.size() - i != 1){
|
||||||
|
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("' or ");
|
||||||
|
} else {
|
||||||
|
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("')");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stringBuilder.append(" group by line_id tz('Asia/Shanghai')");
|
||||||
|
stringBuilder1.append("sum(freq_dev_overtime) AS freq_dev_overtime,sum(voltage_dev_overtime) AS voltage_dev_overtime,sum(ubalance_overtime) AS ubalance_overtime,sum(flicker_overtime) AS flicker_overtime,sum(i_neg_overtime) AS i_neg_overtime,");
|
||||||
|
stringBuilder1.append("sum(uaberrance_overtime)+");
|
||||||
|
for (int i = 2; i <= 25; i++) {
|
||||||
|
if (i==25){
|
||||||
|
stringBuilder1.append("sum(uharm_").append(i).append("_overtime) AS ").append("uharm_2").append("_overtime,");
|
||||||
|
} else {
|
||||||
|
stringBuilder1.append("sum(uharm_").append(i).append("_overtime)+");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 2; i <= 25; i++) {
|
||||||
|
if (i==25){
|
||||||
|
stringBuilder1.append("sum(iharm_").append(i).append("_overtime) AS ").append("iharm_2").append("_overtime,");
|
||||||
|
} else {
|
||||||
|
stringBuilder1.append("sum(iharm_").append(i).append("_overtime)+");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= 16; i++) {
|
||||||
|
if (i==16){
|
||||||
|
stringBuilder1.append("sum(inuharm_").append(i).append("_overtime) AS ").append("inuharm_1").append("_overtime");
|
||||||
|
} else {
|
||||||
|
stringBuilder1.append("sum(inuharm_").append(i).append("_overtime)+");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String sql = "select "+stringBuilder1+" from "+databaseName+" where " + stringBuilder;
|
||||||
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
|
switch (databaseName) {
|
||||||
|
case Param.LIMIT_TARGET:
|
||||||
|
result = resultMapper.toPOJO(sqlResult, LimitTarget.class);
|
||||||
|
break;
|
||||||
|
case Param.LIMIT_RATE:
|
||||||
|
result = resultMapper.toPOJO(sqlResult,LimitRate.class);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EventDetail> getEventDetail(List<String> list, String startTime, String endTime){
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append(Param.TIME + " >= '").append(startTime).append("' and ").append(Param.TIME).append(" <= '").append(endTime).append("' and (");
|
||||||
|
for (int i=0;i<list.size();i++){
|
||||||
|
if (list.size() - i != 1){
|
||||||
|
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("' or ");
|
||||||
|
} else {
|
||||||
|
stringBuilder.append(Param.LINE_ID + "='").append(list.get(i)).append("')");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stringBuilder.append(" group by line_id tz('Asia/Shanghai')");
|
||||||
|
String sql = "select * from pqs_eventdetail where " + stringBuilder;
|
||||||
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
|
return resultMapper.toPOJO(sqlResult, EventDetail.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,6 +14,10 @@ import org.influxdb.dto.BatchPoints;
|
|||||||
import org.influxdb.dto.Point;
|
import org.influxdb.dto.Point;
|
||||||
import org.influxdb.dto.QueryResult;
|
import org.influxdb.dto.QueryResult;
|
||||||
import org.influxdb.impl.InfluxDBResultMapper;
|
import org.influxdb.impl.InfluxDBResultMapper;
|
||||||
|
import org.influxdb.querybuilder.SelectQueryImpl;
|
||||||
|
import org.influxdb.querybuilder.WhereNested;
|
||||||
|
import org.influxdb.querybuilder.WhereQueryImpl;
|
||||||
|
import org.influxdb.querybuilder.clauses.Clause;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -190,13 +194,21 @@ public class PollutionJob {
|
|||||||
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
|
return lineFeignClient.getAllLineOverLimit("harmonic-boot","").getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void whereAndNested(List<Clause> clauses, WhereQueryImpl<SelectQueryImpl> whereQuery) {
|
||||||
|
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
|
||||||
|
for (Clause clause : clauses) {
|
||||||
|
andNested.or(clause);
|
||||||
|
}
|
||||||
|
andNested.close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 谐波电压 -> 电压总谐波畸变率
|
* 谐波电压 -> 电压总谐波畸变率
|
||||||
* 各监测点最新的A、B、C三相数据
|
* 各监测点最新的A、B、C三相数据
|
||||||
* 按照监测点分组,每个监测点取最大
|
* 按照监测点分组,每个监测点取最大
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getDistortionData(){
|
private Map<String, Optional<PublicDTO>> getDistortionData(){
|
||||||
String sql = "SELECT * FROM day_v where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3";
|
String sql = "SELECT * FROM day_v where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -226,7 +238,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的A、B、C三相数据
|
* 各监测点最新的A、B、C三相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getContentData(){
|
private Map<String, Optional<PublicDTO>> getContentData(){
|
||||||
String sql = "SELECT * FROM day_harmrate_v where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3";
|
String sql = "SELECT * FROM day_harmrate_v where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -279,7 +291,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的A、B、C三相数据
|
* 各监测点最新的A、B、C三相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getIharm(){
|
private Map<String, Optional<PublicDTO>> getIharm(){
|
||||||
String sql = "SELECT * FROM day_i where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3";
|
String sql = "SELECT * FROM day_i where value_type = 'CP95' and (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -332,7 +344,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的T相数据
|
* 各监测点最新的T相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getFreq(){
|
private Map<String, Optional<PublicDTO>> getFreq(){
|
||||||
String sql = "SELECT line_id,abs(freq_dev) AS freq_dev FROM day_v where phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') group by line_id order by time desc limit 2";
|
String sql = "SELECT line_id,abs(freq_dev) AS freq_dev FROM day_v where phasic_type = 'T' and (value_type = 'MIN' or value_type = 'MAX') group by line_id order by time desc limit 2 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -362,7 +374,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的A、B、C三相数据
|
* 各监测点最新的A、B、C三相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getDev(){
|
private Map<String, Optional<PublicDTO>> getDev(){
|
||||||
String sql = "SELECT line_id,vu_dev,vl_dev,value_type FROM day_v where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') group by line_id order by time desc limit 6";
|
String sql = "SELECT line_id,vu_dev,vl_dev,value_type FROM day_v where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and (value_type = 'MIN' or value_type = 'MAX') group by line_id order by time desc limit 6 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -393,7 +405,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的T相数据
|
* 各监测点最新的T相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getUbalance(){
|
private Map<String, Optional<PublicDTO>> getUbalance(){
|
||||||
String sql = "SELECT line_id,v_unbalance,value_type FROM day_v where phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') group by line_id order by time desc limit 2";
|
String sql = "SELECT line_id,v_unbalance,value_type FROM day_v where phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') group by line_id order by time desc limit 2 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -423,7 +435,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的T相数据
|
* 各监测点最新的T相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getIneg(){
|
private Map<String, Optional<PublicDTO>> getIneg(){
|
||||||
String sql = "SELECT line_id,i_neg,value_type FROM day_i where phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') group by line_id order by time desc limit 2";
|
String sql = "SELECT line_id,i_neg,value_type FROM day_i where phasic_type = 'T' and (value_type = 'CP95' or value_type = 'MAX') group by line_id order by time desc limit 2 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -453,7 +465,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的A、B、C三相数据
|
* 各监测点最新的A、B、C三相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getInuharm(){
|
private Map<String, Optional<PublicDTO>> getInuharm(){
|
||||||
String sql = "SELECT * FROM day_inharm_v where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' group by line_id order by time desc limit 3";
|
String sql = "SELECT * FROM day_inharm_v where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
@@ -498,7 +510,7 @@ public class PollutionJob {
|
|||||||
* 各监测点最新的A、B、C三相数据
|
* 各监测点最新的A、B、C三相数据
|
||||||
*/
|
*/
|
||||||
private Map<String, Optional<PublicDTO>> getFlicker(){
|
private Map<String, Optional<PublicDTO>> getFlicker(){
|
||||||
String sql = "SELECT * FROM day_plt where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' group by line_id order by time desc limit 3";
|
String sql = "SELECT * FROM day_plt where (phasic_type = 'A' or phasic_type = 'B' or phasic_type = 'C') and value_type = 'CP95' group by line_id order by time desc limit 3 tz('Asia/Shanghai')";
|
||||||
QueryResult sqlResult = influxDbUtils.query(sql);
|
QueryResult sqlResult = influxDbUtils.query(sql);
|
||||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
List<Double> data;
|
List<Double> data;
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
package com.njcn.executor.handler;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import com.njcn.device.api.LineFeignClient;
|
||||||
|
import com.njcn.device.pojo.po.LineDetail;
|
||||||
|
import com.njcn.executor.pojo.vo.*;
|
||||||
|
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||||
|
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||||
|
import com.xxl.job.core.context.XxlJobHelper;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.influxdb.InfluxDB;
|
||||||
|
import org.influxdb.dto.BatchPoints;
|
||||||
|
import org.influxdb.dto.Point;
|
||||||
|
import org.influxdb.dto.QueryResult;
|
||||||
|
import org.influxdb.impl.InfluxDBResultMapper;
|
||||||
|
import org.influxdb.querybuilder.SelectQueryImpl;
|
||||||
|
import org.influxdb.querybuilder.WhereNested;
|
||||||
|
import org.influxdb.querybuilder.WhereQueryImpl;
|
||||||
|
import org.influxdb.querybuilder.clauses.Clause;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.njcn.influxdb.param.InfluxDBPublicParam.*;
|
||||||
|
import static com.njcn.influxdb.param.InfluxDBPublicParam.LINE_ID;
|
||||||
|
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.*;
|
||||||
|
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/8 13:44
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PqsIntegrityJob {
|
||||||
|
|
||||||
|
private final InfluxDbUtils influxDbUtils;
|
||||||
|
|
||||||
|
private final LineFeignClient lineFeignClient;
|
||||||
|
|
||||||
|
@XxlJob("pqsIntegrityJobHandler")
|
||||||
|
public void pqsIntegrityJobHandler() throws ParseException {
|
||||||
|
List<PqsIntegrity> result = new ArrayList<>();
|
||||||
|
List<String> paramList = new ArrayList<>(),lineList = new ArrayList<>();
|
||||||
|
List<DataV> dataList = new ArrayList<>();
|
||||||
|
String command = XxlJobHelper.getJobParam();
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)-1, 0, 0, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
Calendar calendar2 = Calendar.getInstance();
|
||||||
|
calendar2.set(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DAY_OF_MONTH)-1, 23, 59, 59);
|
||||||
|
calendar2.set(Calendar.MILLISECOND, 0);
|
||||||
|
String startTime = format.format(calendar.getTime());
|
||||||
|
String endTime = format.format(calendar2.getTime());
|
||||||
|
if (!StringUtils.isEmpty(command)){
|
||||||
|
paramList = Arrays.asList(command.split(","));
|
||||||
|
startTime = paramList.get(0);
|
||||||
|
endTime = paramList.get(1);
|
||||||
|
lineList = paramList.subList(2,paramList.size());
|
||||||
|
boolean s1 = Pattern.matches(PatternRegex.TIME_FORMAT,startTime);
|
||||||
|
boolean e1 = Pattern.matches(PatternRegex.TIME_FORMAT,endTime);
|
||||||
|
if (!s1 || !e1){
|
||||||
|
log.error("补招时间格式错误");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
startTime = startTime + " 00:00:00";
|
||||||
|
endTime = endTime + " 23:59:59";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<LineDetail> lineDetail = lineFeignClient.getLineDetail(lineList).getData();
|
||||||
|
if (!CollectionUtils.isEmpty(lineDetail)){
|
||||||
|
//获取dataV表中监测点的数据数量
|
||||||
|
lineList = lineDetail.stream().map(LineDetail::getId).collect(Collectors.toList());
|
||||||
|
long diff,diffDays,a,b = 0;
|
||||||
|
Date d1 = format.parse(startTime);
|
||||||
|
Date d2 = format.parse(endTime);
|
||||||
|
diff = d2.getTime() - d1.getTime();
|
||||||
|
diffDays = diff / (24 * 60 * 60 * 1000-1000);
|
||||||
|
int days = (int) diffDays;
|
||||||
|
for (int i = 1; i <= days; i++) {
|
||||||
|
a = d1.getTime() + (long)(i-1)*(24 * 60 * 60) * 1000;
|
||||||
|
b = d1.getTime() + (long)i*(24 * 60 * 60) * 1000-1000;
|
||||||
|
startTime = format.format(a);
|
||||||
|
endTime = format.format(b);
|
||||||
|
dataList = getDataV(lineList,startTime,endTime);
|
||||||
|
for (LineDetail detail : lineDetail) {
|
||||||
|
PqsIntegrity pqsIntegrity = new PqsIntegrity();
|
||||||
|
pqsIntegrity.setTime(Instant.ofEpochMilli(a));
|
||||||
|
pqsIntegrity.setLineId(detail.getId());
|
||||||
|
pqsIntegrity.setDue(DAY_MINUTE/detail.getTimeInterval());
|
||||||
|
if (!CollectionUtils.isEmpty(dataList)){
|
||||||
|
Map<String,List<DataV>> lineMap = dataList.stream().collect(Collectors.groupingBy(DataV::getLineId));
|
||||||
|
List<DataV> l1 = lineMap.get(detail.getId());
|
||||||
|
if (!CollectionUtils.isEmpty(l1)){
|
||||||
|
Map<Instant,List<DataV>> timeMap = l1.stream().collect(Collectors.groupingBy(DataV::getTime));
|
||||||
|
pqsIntegrity.setReal(timeMap.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.add(pqsIntegrity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
insertData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取dataV数据
|
||||||
|
* @param list 监测点集合
|
||||||
|
* @return dataV数据
|
||||||
|
*/
|
||||||
|
private List<DataV> getDataV(List<String> list, String startTime, String endTime){
|
||||||
|
SelectQueryImpl selectQuery = select().from(DATABASE, DATA_V);
|
||||||
|
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
||||||
|
whereAndNested(list, where);
|
||||||
|
where.and(gte(TIME, startTime)).and(lte(TIME, endTime));
|
||||||
|
where.tz(TZ);
|
||||||
|
QueryResult queryResult = influxDbUtils.query(selectQuery.getCommand());
|
||||||
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
|
return resultMapper.toPOJO(queryResult, DataV.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼接监测点条件
|
||||||
|
* @param list 监测点集合
|
||||||
|
* @param whereQuery WhereQueryImpl
|
||||||
|
*/
|
||||||
|
private void whereAndNested(List<String> list, WhereQueryImpl<SelectQueryImpl> whereQuery) {
|
||||||
|
List<Clause> clauses = new ArrayList<>();
|
||||||
|
list.forEach(item->{
|
||||||
|
Clause clause = eq(LINE_ID, item);
|
||||||
|
clauses.add(clause);
|
||||||
|
});
|
||||||
|
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
|
||||||
|
for (Clause clause : clauses) {
|
||||||
|
andNested.or(clause);
|
||||||
|
}
|
||||||
|
andNested.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述:插入pqs_integrity表数据
|
||||||
|
* @author xy
|
||||||
|
* @param list 数据集合
|
||||||
|
* @date 2022/5/12 8:55
|
||||||
|
*/
|
||||||
|
private void insertData(List<PqsIntegrity> list){
|
||||||
|
List<String> records = new ArrayList<>();
|
||||||
|
list.forEach(item->{
|
||||||
|
Map<String, String> tags = new HashMap<>();
|
||||||
|
Map<String, Object> fields = new HashMap<>();
|
||||||
|
tags.put(LINE_ID,item.getLineId());
|
||||||
|
fields.put(DUE,item.getDue());
|
||||||
|
fields.put(REAL,item.getReal());
|
||||||
|
Point point = influxDbUtils.pointBuilder(PQS_INTEGRITY, item.getTime().toEpochMilli(), TimeUnit.MILLISECONDS, tags, fields);
|
||||||
|
BatchPoints batchPoints = BatchPoints.database(DATABASE).tag(LINE_ID, item.getLineId()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||||
|
batchPoints.point(point);
|
||||||
|
records.add(batchPoints.lineProtocol());
|
||||||
|
});
|
||||||
|
influxDbUtils.batchInsert(DATABASE,"", InfluxDB.ConsistencyLevel.ALL, records);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.njcn.executor.handler;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/8 13:43
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PqsOnlineRateJob {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.njcn.executor.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.influxdb.annotation.Column;
|
||||||
|
import org.influxdb.annotation.Measurement;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/5/11 16:08
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Measurement(name = "pqs_integrity")
|
||||||
|
public class PqsIntegrity {
|
||||||
|
|
||||||
|
@Column(name = "time")
|
||||||
|
private Instant time;
|
||||||
|
|
||||||
|
@Column(name = "line_id")
|
||||||
|
private String lineId;
|
||||||
|
|
||||||
|
@Column(name = "due")
|
||||||
|
private Integer due;
|
||||||
|
|
||||||
|
@Column(name = "real")
|
||||||
|
private Integer real = 0;
|
||||||
|
}
|
||||||
@@ -41,12 +41,12 @@ logging:
|
|||||||
xxl:
|
xxl:
|
||||||
job:
|
job:
|
||||||
admin:
|
admin:
|
||||||
addresses: http://@server.url@:10217/job-admin
|
addresses: http://192.168.1.13:10217/job-admin
|
||||||
#执行器通讯TOKEN [选填]:非空时启用;
|
#执行器通讯TOKEN [选填]:非空时启用;
|
||||||
accessToken:
|
accessToken:
|
||||||
executor:
|
executor:
|
||||||
#执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
|
#执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
|
||||||
appname: executorCdf
|
appname: executor
|
||||||
#执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。
|
#执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。
|
||||||
address:
|
address:
|
||||||
#执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
|
#执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务";
|
||||||
|
|||||||
56
pqs-job/job-executor/src/test/java/Test1.java
Normal file
56
pqs-job/job-executor/src/test/java/Test1.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
import com.njcn.executor.pojo.vo.DataFlicker;
|
||||||
|
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||||
|
import org.influxdb.dto.QueryResult;
|
||||||
|
import org.influxdb.impl.InfluxDBResultMapper;
|
||||||
|
import org.influxdb.querybuilder.SelectQueryImpl;
|
||||||
|
import org.influxdb.querybuilder.WhereNested;
|
||||||
|
import org.influxdb.querybuilder.WhereQueryImpl;
|
||||||
|
import org.influxdb.querybuilder.clauses.Clause;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq;
|
||||||
|
import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/4 19:04
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = Test1.class)
|
||||||
|
public class Test1 {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMethod(){
|
||||||
|
InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "njcnpqs", "http://192.168.1.18:8086", "pqsbase", "");
|
||||||
|
SelectQueryImpl selectQuery = select().from("pqsbase","data_flicker").where(eq("fluc",0)).limit(1).tz("Asia/Shanghai");
|
||||||
|
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
||||||
|
QueryResult queryResult = influxDBUtil.query(selectQuery.getCommand());
|
||||||
|
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||||
|
List<DataFlicker> list = resultMapper.toPOJO(queryResult, DataFlicker.class);
|
||||||
|
System.out.println("list===:" + list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Clause> getClauses() {
|
||||||
|
Clause c1 = eq("line_id", "5e467a40023b299070682eb21f2ec9a1");
|
||||||
|
Clause c2 = eq("line_id", "183245996f303ebfd80eeb3377cecdc2");
|
||||||
|
Clause c3 = eq("line_id", "0d46f54420246e999d5c68b3133f668c");
|
||||||
|
return Arrays.asList(c1, c2, c3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void whereAndNested(List<Clause> clauses, WhereQueryImpl<SelectQueryImpl> whereQuery) {
|
||||||
|
WhereNested<WhereQueryImpl<SelectQueryImpl>> andNested = whereQuery.andNested();
|
||||||
|
for (Clause clause : clauses) {
|
||||||
|
andNested.or(clause);
|
||||||
|
}
|
||||||
|
andNested.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,7 +65,9 @@ public enum EnergyResponseEnum {
|
|||||||
|
|
||||||
TASK_HAS_START("508","任务已经执行完毕"),
|
TASK_HAS_START("508","任务已经执行完毕"),
|
||||||
TASK_DEL_ERROR("509","定时任务删除失败,请联系管理员"),
|
TASK_DEL_ERROR("509","定时任务删除失败,请联系管理员"),
|
||||||
TASK_RUNING("510","任务正在执行无法操作,请先停止任务")
|
TASK_RUNING("510","任务正在执行无法操作,请先停止任务"),
|
||||||
|
|
||||||
|
FILE_EMPTY("511","上传的文件为空,请检查文件")
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.quality.param;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import com.njcn.web.constant.ValidMessage;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2022/7/6 9:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpdateDeviceVersion {
|
||||||
|
|
||||||
|
@ApiModelProperty("装置id")
|
||||||
|
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.NORMAL, message = ValidMessage.ID_FORMAT_ERROR)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("装置版本文件")
|
||||||
|
@NotNull(message = ValidMessage.DEVICE_VERSION_NOT_BLANK)
|
||||||
|
private MultipartFile deviceVersionFile;
|
||||||
|
}
|
||||||
@@ -22,4 +22,6 @@ public class AskDataParamDTO implements Serializable {
|
|||||||
|
|
||||||
private String endTime;
|
private String endTime;
|
||||||
|
|
||||||
|
private Object dataArray;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
6
pqs-quality/quality-boot/Dockerfile
Normal file
6
pqs-quality/quality-boot/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FROM openjdk:8-jdk-alpine
|
||||||
|
ADD target/qualityboot.jar qualityboot.jar
|
||||||
|
ENTRYPOINT ["java","-jar","/qualityboot.jar"]
|
||||||
|
EXPOSE 10209
|
||||||
|
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \&& echo 'Asia/Shanghai' >/etc/timezone
|
||||||
|
|
||||||
@@ -1,21 +1,31 @@
|
|||||||
package com.njcn.quality.controller;
|
package com.njcn.quality.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
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.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
|
import com.njcn.quality.param.UpdateDeviceVersion;
|
||||||
import com.njcn.quality.service.IModelService;
|
import com.njcn.quality.service.IModelService;
|
||||||
|
import com.njcn.system.pojo.param.ThemeParam;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -66,5 +76,12 @@ public class ModelController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
|
@PostMapping("/updateDevVersion")
|
||||||
|
@ApiOperation("更新装置模板信息")
|
||||||
|
public HttpResult<Boolean> updateDevVersion(@Validated UpdateDeviceVersion updateDeviceVersion) throws Exception {
|
||||||
|
String methodDescribe = getMethodDescribe("updateDevVersion");
|
||||||
|
modelService.updateDevVersion(updateDeviceVersion);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import com.github.tocrhz.mqtt.annotation.Payload;
|
|||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
import com.njcn.quality.enums.EnergyResponseEnum;
|
import com.njcn.quality.enums.EnergyResponseEnum;
|
||||||
import com.njcn.quality.pojo.constant.ApiParam;
|
import com.njcn.quality.pojo.constant.ApiParam;
|
||||||
import com.njcn.quality.pojo.dto.DeviceOperateDTO;
|
import com.njcn.quality.pojo.constant.DataType;
|
||||||
import com.njcn.quality.pojo.dto.RegisterDTO;
|
import com.njcn.quality.pojo.constant.ModelState;
|
||||||
|
import com.njcn.quality.pojo.dto.*;
|
||||||
import com.njcn.quality.pojo.po.EleLogs;
|
import com.njcn.quality.pojo.po.EleLogs;
|
||||||
import com.njcn.quality.service.IEleLogsService;
|
import com.njcn.quality.service.IEleLogsService;
|
||||||
import com.njcn.quality.service.IModelService;
|
import com.njcn.quality.service.IModelService;
|
||||||
@@ -127,28 +128,28 @@ public class MqttMessageHandler {
|
|||||||
//回复装置信息
|
//回复装置信息
|
||||||
publisher.send("/device/pltrep/"+version+"/" + edgeId,result,1,false);
|
publisher.send("/device/pltrep/"+version+"/" + edgeId,result,1,false);
|
||||||
|
|
||||||
// //询问模板数据 暂时线下传递模板数据
|
//询问模板数据 暂时线下传递模板数据
|
||||||
// Gson gson = new Gson();
|
Gson gson2 = new Gson();
|
||||||
// AccessDTO.AccessResponse response = gson.fromJson(result,AccessDTO.AccessResponse.class);
|
AccessDTO.AccessResponse response2 = gson2.fromJson(result,AccessDTO.AccessResponse.class);
|
||||||
// if (response.getCode() == Integer.parseInt(EnergyResponseEnum.NO_MODEL_FIND.getCode())){
|
if (response2.getCode() == Integer.parseInt(EnergyResponseEnum.NO_MODEL_FIND.getCode())){
|
||||||
// AskDataDTO.AskDataRequest askDataDTO = new AskDataDTO.AskDataRequest();
|
AskDataDTO.AskDataRequest askDataDTO = new AskDataDTO.AskDataRequest();
|
||||||
// askDataDTO.setTimestamp(Long.toString(System.currentTimeMillis()/1000));
|
askDataDTO.setTimestamp(Long.toString(System.currentTimeMillis()/1000));
|
||||||
// askDataDTO.setLevel(0);
|
askDataDTO.setLevel(0);
|
||||||
// askDataDTO.setType(ApiParam.CMD_DEV_DATA);
|
askDataDTO.setDeviceId(registerDTO.getParam().getDid().get(0));
|
||||||
// AskDataParamDTO askDataParamDTO = new AskDataParamDTO();
|
askDataDTO.setType(ApiParam.CMD_DEV_DATA);
|
||||||
// askDataParamDTO.setDataType(DataType.TEMPLATE);
|
AskDataParamDTO askDataParamDTO = new AskDataParamDTO();
|
||||||
// askDataParamDTO.setOperate(ModelState.READ);
|
askDataParamDTO.setDataType(DataType.TEMPLATE);
|
||||||
// askDataParamDTO.setStartTime(Long.toString(System.currentTimeMillis()/1000));
|
askDataParamDTO.setOperate(ModelState.READ);
|
||||||
// askDataDTO.setParam(askDataParamDTO);
|
askDataParamDTO.setStartTime(Long.toString(System.currentTimeMillis()/1000));
|
||||||
// publisher.send("/platform/command/v1/" + edgeId,gson.toJson(askDataDTO),1,false);
|
askDataDTO.setParam(askDataParamDTO);
|
||||||
// }
|
publisher.send("/platform/devcmd/"+version+"/" + edgeId,gson.toJson(askDataDTO),1,false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模板信息
|
* 获取模板信息
|
||||||
*/
|
*/
|
||||||
@MqttSubscribe(value = "/platform/reply/{version}/{edgeId}",qos = 1)
|
@MqttSubscribe(value = "/platform/devack/{version}/{edgeId}",qos = 1)
|
||||||
public void replyTemplate(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId, @Payload String payload) {
|
public void replyTemplate(String topic, MqttMessage message, @NamedValue("edgeId") String edgeId, @Payload String payload) {
|
||||||
String result = modelService.deviceData(new String(message.getPayload(), StandardCharsets.UTF_8));
|
String result = modelService.deviceData(new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||||
//模板发生变更通知其他云服务
|
//模板发生变更通知其他云服务
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.njcn.quality.service;
|
package com.njcn.quality.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.quality.param.UpdateDeviceVersion;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@@ -58,4 +60,14 @@ public interface IModelService {
|
|||||||
*/
|
*/
|
||||||
List<String> monitorHeartbeat(String ndid, String time);
|
List<String> monitorHeartbeat(String ndid, String time);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能描述: 手动更新装置模板版本
|
||||||
|
* @author xy
|
||||||
|
* @param updateDeviceVersion 参数
|
||||||
|
* @date 2022/7/6 20:19
|
||||||
|
*/
|
||||||
|
void updateDevVersion(UpdateDeviceVersion updateDeviceVersion) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.quality.enums.EnergyResponseEnum;
|
import com.njcn.quality.enums.EnergyResponseEnum;
|
||||||
@@ -18,11 +19,15 @@ import com.njcn.quality.pojo.dto.*;
|
|||||||
import com.njcn.quality.pojo.po.*;
|
import com.njcn.quality.pojo.po.*;
|
||||||
import com.njcn.quality.service.*;
|
import com.njcn.quality.service.*;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@@ -37,10 +42,13 @@ import java.util.stream.Stream;
|
|||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
* @createTime 2022/2/28 15:02
|
* @createTime 2022/2/28 15:02
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ModelServiceImpl implements IModelService {
|
public class ModelServiceImpl implements IModelService {
|
||||||
|
|
||||||
|
private final MqttPublisher publisher;
|
||||||
|
|
||||||
private final NetDevMapper netDevMapper;
|
private final NetDevMapper netDevMapper;
|
||||||
|
|
||||||
private final DevVersionMapper devVersionMapper;
|
private final DevVersionMapper devVersionMapper;
|
||||||
@@ -81,8 +89,6 @@ public class ModelServiceImpl implements IModelService {
|
|||||||
|
|
||||||
private final IEleCtrlService eleCtrlService;
|
private final IEleCtrlService eleCtrlService;
|
||||||
|
|
||||||
private final IEleActrlService eleActrlService;
|
|
||||||
|
|
||||||
private final IDataGroupService dataGroupService;
|
private final IDataGroupService dataGroupService;
|
||||||
|
|
||||||
private final IGroupArrayService groupArrayService;
|
private final IGroupArrayService groupArrayService;
|
||||||
@@ -416,7 +422,6 @@ public class ModelServiceImpl implements IModelService {
|
|||||||
BeanUtil.copyProperties(netDevDTO.getSoftInfoDTO(),hardwareParam);
|
BeanUtil.copyProperties(netDevDTO.getSoftInfoDTO(),hardwareParam);
|
||||||
hardwareParam.setType(ModelState.NET_DEV);
|
hardwareParam.setType(ModelState.NET_DEV);
|
||||||
hardwareService.addHardware(hardwareParam);
|
hardwareService.addHardware(hardwareParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析装置模板
|
* 解析装置模板
|
||||||
*/
|
*/
|
||||||
@@ -496,7 +501,7 @@ public class ModelServiceImpl implements IModelService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("获取数据失败");
|
log.error("获取数据失败");
|
||||||
}
|
}
|
||||||
AccessDTO.AccessResponse result = new AccessDTO.AccessResponse();
|
AccessDTO.AccessResponse result = new AccessDTO.AccessResponse();
|
||||||
result.setCode(Integer.parseInt(EnergyResponseEnum.SUCCESS.getCode()));
|
result.setCode(Integer.parseInt(EnergyResponseEnum.SUCCESS.getCode()));
|
||||||
@@ -600,6 +605,49 @@ public class ModelServiceImpl implements IModelService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件流解析成json
|
||||||
|
* @param updateDeviceVersion 参数
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateDevVersion(UpdateDeviceVersion updateDeviceVersion) throws Exception {
|
||||||
|
File file = multipartFileToFile(updateDeviceVersion.getDeviceVersionFile());
|
||||||
|
if (Objects.isNull(file)){
|
||||||
|
throw new BusinessException(EnergyResponseEnum.FILE_EMPTY);
|
||||||
|
}
|
||||||
|
String jsonStr = "";
|
||||||
|
try {
|
||||||
|
FileReader fileReader = new FileReader(file);
|
||||||
|
Reader reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
|
||||||
|
int ch = 0;
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while ((ch = reader.read()) != -1) {
|
||||||
|
sb.append((char) ch);
|
||||||
|
}
|
||||||
|
fileReader.close();
|
||||||
|
reader.close();
|
||||||
|
jsonStr = sb.toString();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
AskDataDTO.AskDataResponse response = gson.fromJson(jsonStr,AskDataDTO.AskDataResponse.class);
|
||||||
|
String edgeId = response.getDeviceId();
|
||||||
|
DataArrayListDTO dataArrayListDTO = response.getParam().getDataArray().get(0);
|
||||||
|
Gson gson2 = new Gson();
|
||||||
|
AskDataDTO.AskDataRequest askDataDTO = new AskDataDTO.AskDataRequest();
|
||||||
|
askDataDTO.setTimestamp(Long.toString(System.currentTimeMillis()/1000));
|
||||||
|
askDataDTO.setMid(0);
|
||||||
|
askDataDTO.setLevel(0);
|
||||||
|
askDataDTO.setType(ApiParam.CMD_DEV_DATA);
|
||||||
|
AskDataParamDTO askDataParamDTO = new AskDataParamDTO();
|
||||||
|
askDataParamDTO.setDataType(DataType.TEMPLATE);
|
||||||
|
askDataParamDTO.setOperate(ModelState.WRITE);
|
||||||
|
askDataParamDTO.setStartTime(Long.toString(System.currentTimeMillis()/1000));
|
||||||
|
askDataParamDTO.setDataArray(dataArrayListDTO);
|
||||||
|
askDataDTO.setParam(askDataParamDTO);
|
||||||
|
publisher.send("/platform/command/v1/" + edgeId,gson2.toJson(askDataDTO),1,false);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析设备模板
|
* 解析设备模板
|
||||||
@@ -1320,4 +1368,36 @@ public class ModelServiceImpl implements IModelService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File multipartFileToFile(MultipartFile file) throws Exception {
|
||||||
|
File toFile = null;
|
||||||
|
if (Objects.equals("",file) || file.getSize() <= 0) {
|
||||||
|
file = null;
|
||||||
|
} else {
|
||||||
|
InputStream ins = null;
|
||||||
|
ins = file.getInputStream();
|
||||||
|
toFile = new File(Objects.requireNonNull(file.getOriginalFilename()));
|
||||||
|
inputStreamToFile(ins, toFile);
|
||||||
|
ins.close();
|
||||||
|
}
|
||||||
|
return toFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取流文件
|
||||||
|
*/
|
||||||
|
private static void inputStreamToFile(InputStream ins, File file) {
|
||||||
|
try {
|
||||||
|
OutputStream os = new FileOutputStream(file);
|
||||||
|
int bytesRead = 0;
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
|
||||||
|
os.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
os.close();
|
||||||
|
ins.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user