合并代码

This commit is contained in:
2022-10-18 11:17:20 +08:00
parent 1efdfa5cd6
commit 7b790e6dc2
93 changed files with 5045 additions and 555 deletions

View File

@@ -3,11 +3,13 @@ package com.njcn.harmonic.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.param.StatisticsBizBaseParam;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.pojo.param.HistoryParam;
import com.njcn.harmonic.pojo.param.NormHistoryParam;
import com.njcn.harmonic.pojo.vo.HistoryDataResultVO;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.harmonic.service.HistoryResultService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
@@ -16,9 +18,11 @@ 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 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.Date;
import java.util.List;
/**
@@ -55,4 +59,15 @@ public class HistoryResultController extends BaseController {
List<HistoryDataResultVO> list = historyResultService.getHistoryLineData(normHistoryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getHarmonicProportion")
@ApiOperation("获取谐波越限监测点占比")
@ApiImplicitParam(name = "statisticsBizBaseParam", value = "谐波越限监测点参数", required = true)
public HttpResult<List<StatHarmonicOrgVO>> getHistoryLineData(@RequestBody @Validated StatisticsBizBaseParam statisticsBizBaseParam) {
String methodDescribe = getMethodDescribe("getHarmonicProportion");
List<StatHarmonicOrgVO> list = historyResultService.getHarmonicProportion(statisticsBizBaseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -43,7 +43,17 @@ public class NormLimitController extends BaseController {
@ApiImplicitParam(name = "historyHarmOverLimitParam", value = "异常数据统计参数", required = true)
public HttpResult<List<HistoryHarmOverLimitVO>> getHistoryTableData(@RequestBody @Validated HistoryHarmOverLimitParam historyHarmOverLimitParam) {
String methodDescribe = getMethodDescribe("getHistoryTableData");
List<HistoryHarmOverLimitVO> list = normLimitService.getHistoryTableData(historyHarmOverLimitParam);
List<HistoryHarmOverLimitVO> list = normLimitService.getHistoryData(historyHarmOverLimitParam,0);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getHistoryData")
@ApiOperation("告警数据统计")
@ApiImplicitParam(name = "historyHarmOverLimitParam", value = "异常数据统计参数", required = true)
public HttpResult<List<HistoryHarmOverLimitVO>> getHistoryData(@RequestBody @Validated HistoryHarmOverLimitParam historyHarmOverLimitParam) {
String methodDescribe = getMethodDescribe("getHistoryTableData");
List<HistoryHarmOverLimitVO> list = normLimitService.getHistoryData(historyHarmOverLimitParam,1);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -0,0 +1,56 @@
package com.njcn.harmonic.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.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import com.njcn.harmonic.service.PollutionSubstationService;
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;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 9:39【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Validated
@Slf4j
@RestController
@RequestMapping("/PollutionSubstation")
@Api(tags = "变电站污染统计")
@AllArgsConstructor
public class PollutionSubstationController extends BaseController {
private final PollutionSubstationService pollutionSubstationService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getPollutionSubstationData")
@ApiOperation("按变电站及指标类型展示污染")
@ApiImplicitParam(name = "pollutionSubstationQuryParam", value = "污染指标查询参数", required = true)
public HttpResult<List<PollutionSubstationVO>> getPollutionSubstationData(@RequestBody @Validated PollutionSubstationQuryParam pollutionSubstationQuryParam) {
String methodDescribe = getMethodDescribe ("getPollutionSubstationData");
LogUtil.njcnDebug(log, "{},实体参数:{}", methodDescribe, pollutionSubstationQuryParam);
List<PollutionSubstationVO> list = pollutionSubstationService.getPollutionSubstationData (pollutionSubstationQuryParam);
return HttpResultUtil.assembleCommonResponseResult (CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -3,9 +3,11 @@ package com.njcn.harmonic.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.param.StatisticsBizBaseParam;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.vo.RMpVThdVO;
import com.njcn.harmonic.pojo.vo.THDistortionCensusVO;
import com.njcn.harmonic.pojo.vo.THDistortionVO;
import com.njcn.harmonic.service.THDistortionService;
@@ -58,5 +60,15 @@ public class THDController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, censusVO, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getTHDTopTenData")
@ApiOperation("谐波总畸变率前十列表")
@ApiImplicitParam(name = "statisticsBizBaseParam", value = "业务参数", required = true)
public HttpResult<List<RMpVThdVO>> getTHDTopTenData(@RequestBody @Validated StatisticsBizBaseParam statisticsBizBaseParam){
String methodDescribe = getMethodDescribe("getTHDTopTenData");
List<RMpVThdVO> list = thDistortionService.getTHDTopTenData(statisticsBizBaseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -0,0 +1,92 @@
package com.njcn.harmonic.mapper;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.vo.HistoryHarmOverLimitVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022年10月13日 10:05
*/
public interface NormLimitMapper extends BaseMapper<HistoryHarmOverLimitVO> {
/**
* 电压偏差
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @return 结果
*/
List<HistoryHarmOverLimitVO> getDyPc(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
/**
* 三相电压不平衡度
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @return 结果
*/
List<HistoryHarmOverLimitVO> getSxBpHd(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
/**
* 电压总畸变率
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @return 结果
*/
List<HistoryHarmOverLimitVO> getDyZjBl(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
/**
* 负序电流
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @return 结果
*/
List<HistoryHarmOverLimitVO> getFxDl(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
/**
* 频率
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @return 结果
*/
List<HistoryHarmOverLimitVO> getPl(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
/**
* 谐波电压含有率
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @param number 次数
* @return 结果
*/
List<HistoryHarmOverLimitVO> getXbDyHyl(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime,@Param("number")Integer number);
/**
* 谐波电流幅值
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @param number 次数
* @return 结果
*/
List<HistoryHarmOverLimitVO> getXbDlFz(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime,@Param("number")Integer number);
/**
* 间谐波电压含有率
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @param number 次数
* @return 结果
*/
List<HistoryHarmOverLimitVO> getJxbHyl(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime,@Param("number")Integer number);
/**
* 长时闪变
* @param lineIndex 监测点
* @param startTime 起始时间
* @param endTime 结束时间
* @return 结果
*/
List<HistoryHarmOverLimitVO> getCsSb(@Param("lineIndex")List<String> lineIndex, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
}

View File

@@ -0,0 +1,17 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RMpVThd;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/10 19:59【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface RMpVThdMapper extends BaseMapper<RMpVThd> {
}

View File

@@ -0,0 +1,25 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatPollutionSubstationM;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 13:58【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface RStatPollutionSubstationMMapper extends BaseMapper<RStatPollutionSubstationM> {
int updateBatch(List<RStatPollutionSubstationM> list);
int batchInsert(@Param("list") List<RStatPollutionSubstationM> list);
int insertOrUpdate(RStatPollutionSubstationM record);
int insertOrUpdateSelective(RStatPollutionSubstationM record);
}

View File

@@ -0,0 +1,24 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatHarmonicOrgD;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.user.pojo.dto.DeptDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author qijian
* @version 1.0.0
* @createTime 2022/10/9 - 11:09
*/
public interface StatHarmonicOrgDMapper extends BaseMapper<RStatHarmonicOrgD> {
/**
* 查询谐波越限 日占比
* @param list,startTime,endTime 参数
* @return 结果
*/
List<StatHarmonicOrgVO> listDayRatio(@Param("list") List<DeptDTO> list, @Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@@ -0,0 +1,24 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatHarmonicOrgM;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.user.pojo.dto.DeptDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author qijian
* @version 1.0.0
* @createTime 2022/10/9 - 11:09
*/
public interface StatHarmonicOrgMMapper extends BaseMapper<RStatHarmonicOrgM> {
/**
* 查询谐波越限 月占比
* @param list,startTime,endTime 参数
* @return 结果
*/
List<StatHarmonicOrgVO> listMonthRatio(@Param("list") List<DeptDTO> list, @Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@@ -0,0 +1,24 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatHarmonicOrgQ;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.user.pojo.dto.DeptDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author qijian
* @version 1.0.0
* @createTime 2022/10/9 - 11:09
*/
public interface StatHarmonicOrgQMapper extends BaseMapper<RStatHarmonicOrgQ> {
/**
* 查询谐波越限 季占比
* @param list,startTime,endTime 参数
* @return 结果
*/
List<StatHarmonicOrgVO> listQuarterRatio(@Param("list") List<DeptDTO> list, @Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@@ -0,0 +1,24 @@
package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatHarmonicOrgY;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.user.pojo.dto.DeptDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author qijian
* @version 1.0.0
* @createTime 2022/10/9 - 11:09
*/
public interface StatHarmonicOrgYMapper extends BaseMapper<RStatHarmonicOrgY> {
/**
* 查询谐波越限 年占比
* @param list,startTime,endTime 参数
* @return 结果
*/
List<StatHarmonicOrgVO> listYearRatio(@Param("list") List<DeptDTO> list, @Param("startTime") String startTime, @Param("endTime") String endTime);
}

View File

@@ -0,0 +1,348 @@
<?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.harmonic.mapper.NormLimitMapper">
<select id="getDyPc" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
IF
(
detail.PT_Type IN ( 1, 2 ),
IF (ab.Phasic_Type = 'A','AB',IF(ab.Phasic_Type = 'B','BC','CA')),ab.Phasic_Type
) phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Voltage_Dev ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN Voltage_Dev ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN Voltage_Dev ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN Voltage_Dev ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type!='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getSxBpHd" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
"/" phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Ubalance ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN Ubalance ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN Ubalance ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN Ubalance ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type ='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getDyZjBl" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
IF
(
detail.PT_Type IN ( 1, 2 ),
IF (ab.Phasic_Type = 'A','AB',IF(ab.Phasic_Type = 'B','BC','CA')),ab.Phasic_Type
) phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Uaberrance ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN Uaberrance ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN Uaberrance ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN Uaberrance ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type!='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getFxDl" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
"/" phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN I_Neg ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN I_Neg ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN I_Neg ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN I_Neg ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getPl" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
"/" phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Freq ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN Freq ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN Freq ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN Freq ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getXbDyHyl" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
IF
(
detail.PT_Type IN ( 1, 2 ),
IF (ab.Phasic_Type = 'A','AB',IF(ab.Phasic_Type = 'B','BC','CA')),ab.Phasic_Type
) phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Uharm_${number} ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN Uharm_${number} ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN Uharm_${number} ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN Uharm_${number} ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type!='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getXbDlFz" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
IF
(
detail.PT_Type IN ( 1, 2 ),
IF (ab.Phasic_Type = 'A','AB',IF(ab.Phasic_Type = 'B','BC','CA')),ab.Phasic_Type
) phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Iharm_${number} ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN Iharm_${number} ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN Iharm_${number} ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN Iharm_${number} ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type!='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getJxbHyl" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
IF
(
detail.PT_Type IN ( 1, 2 ),
IF (ab.Phasic_Type = 'A','AB',IF(ab.Phasic_Type = 'B','BC','CA')),ab.Phasic_Type
) phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Inuharm_${number} ELSE 0 END ) avgData,
sum( CASE WHEN Value_Type = 'MAX' THEN Inuharm_${number} ELSE 0 END ) maxData,
sum( CASE WHEN Value_Type = 'MIN' THEN Inuharm_${number} ELSE 0 END ) minData,
sum( CASE WHEN Value_Type = 'CP95' THEN Inuharm_${number} ELSE 0 END ) cp95Data
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type!='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
<select id="getCsSb" resultType="HistoryHarmOverLimitVO">
SELECT
ab.Id lineId,
sub.NAME subName,
line.NAME lineName,
date_format( ab.Time_Id, '%Y-%m-%d' ) timeId,
IF
(
detail.PT_Type IN ( 1, 2 ),
IF (ab.Phasic_Type = 'A','AB',IF(ab.Phasic_Type = 'B','BC','CA')),ab.Phasic_Type
) phaseType,
dic.NAME scale,
sum( CASE WHEN Value_Type = 'AVG' THEN Flicker ELSE 0 END ) avgData
FROM
( SELECT * FROM r_mp_surplus_abnormal_d WHERE Id IN
<foreach collection="lineIndex" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
) ab
LEFT JOIN pq_line line ON line.Id = ab.Id
LEFT JOIN pq_voltage vo ON vo.Id = line.Pid
LEFT JOIN sys_dict_data dic ON dic.Id = vo.scale
LEFT JOIN pq_line subv ON subv.Id = vo.Id
LEFT JOIN pq_line dev ON dev.Id = subv.Pid
LEFT JOIN pq_line sub ON sub.Id = dev.Pid
LEFT JOIN pq_line_detail detail ON detail.Id = line.Id
WHERE
ab.phasic_type!='T'
AND ab.Time_Id between #{startTime} and #{endTime}
GROUP BY
lineId,
timeid,
phaseType
ORDER BY
timeid
</select>
</mapper>

View File

@@ -0,0 +1,16 @@
<?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.harmonic.mapper.RMpVThdMapper">
<resultMap id="BaseResultMap" type="com.njcn.harmonic.pojo.po.RMpVThd">
<!--@mbg.generated-->
<!--@Table r_mp_v_thd-->
<id column="measurement_point_id" jdbcType="VARCHAR" property="measurementPointId" />
<id column="data_type" jdbcType="VARCHAR" property="dataType" />
<id column="data_date" jdbcType="TIMESTAMP" property="dataDate" />
<result column="v_thd" jdbcType="FLOAT" property="vThd" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
measurement_point_id, data_type, data_date, v_thd
</sql>
</mapper>

View File

@@ -0,0 +1,107 @@
<?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.harmonic.mapper.RStatPollutionSubstationMMapper">
<resultMap id="BaseResultMap" type="com.njcn.harmonic.pojo.po.RStatPollutionSubstationM">
<!--@mbg.generated-->
<!--@Table r_stat_pollution_substation_m-->
<id column="substation_id" jdbcType="VARCHAR" property="substationId" />
<id column="data_date" jdbcType="TIMESTAMP" property="dataDate" />
<result column="pollution_type" jdbcType="VARCHAR" property="pollutionType" />
<result column="value" jdbcType="FLOAT" property="value" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
substation_id, data_date, pollution_type, `value`
</sql>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update r_stat_pollution_substation_m
<trim prefix="set" suffixOverrides=",">
<trim prefix="pollution_type = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when substation_id = #{item.substationId,jdbcType=VARCHAR} then #{item.pollutionType,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="`value` = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when substation_id = #{item.substationId,jdbcType=VARCHAR} then #{item.value,jdbcType=FLOAT}
</foreach>
</trim>
</trim>
where substation_id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.substationId,jdbcType=VARCHAR}
</foreach>
</update>
<insert id="batchInsert" parameterType="map">
<!--@mbg.generated-->
insert into r_stat_pollution_substation_m
(substation_id, data_date, pollution_type, `value`)
values
<foreach collection="list" item="item" separator=",">
(#{item.substationId,jdbcType=VARCHAR}, #{item.dataDate,jdbcType=TIMESTAMP}, #{item.pollutionType,jdbcType=VARCHAR},
#{item.value,jdbcType=FLOAT})
</foreach>
</insert>
<insert id="insertOrUpdate" parameterType="com.njcn.harmonic.pojo.po.RStatPollutionSubstationM">
<!--@mbg.generated-->
insert into r_stat_pollution_substation_m
(substation_id, data_date, pollution_type, `value`)
values
(#{substationId,jdbcType=VARCHAR}, #{dataDate,jdbcType=TIMESTAMP}, #{pollutionType,jdbcType=VARCHAR},
#{value,jdbcType=FLOAT})
on duplicate key update
substation_id = #{substationId,jdbcType=VARCHAR},
data_date = #{dataDate,jdbcType=TIMESTAMP},
pollution_type = #{pollutionType,jdbcType=VARCHAR},
`value` = #{value,jdbcType=FLOAT}
</insert>
<insert id="insertOrUpdateSelective" parameterType="com.njcn.harmonic.pojo.po.RStatPollutionSubstationM">
<!--@mbg.generated-->
insert into r_stat_pollution_substation_m
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="substationId != null">
substation_id,
</if>
<if test="dataDate != null">
data_date,
</if>
<if test="pollutionType != null">
pollution_type,
</if>
<if test="value != null">
`value`,
</if>
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="substationId != null">
#{substationId,jdbcType=VARCHAR},
</if>
<if test="dataDate != null">
#{dataDate,jdbcType=TIMESTAMP},
</if>
<if test="pollutionType != null">
#{pollutionType,jdbcType=VARCHAR},
</if>
<if test="value != null">
#{value,jdbcType=FLOAT},
</if>
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="substationId != null">
substation_id = #{substationId,jdbcType=VARCHAR},
</if>
<if test="dataDate != null">
data_date = #{dataDate,jdbcType=TIMESTAMP},
</if>
<if test="pollutionType != null">
pollution_type = #{pollutionType,jdbcType=VARCHAR},
</if>
<if test="value != null">
`value` = #{value,jdbcType=FLOAT},
</if>
</trim>
</insert>
</mapper>

View File

@@ -0,0 +1,22 @@
<?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.harmonic.mapper.StatHarmonicOrgDMapper">
<select id="listDayRatio" resultType="StatHarmonicOrgVO">
SELECT
r.`org_no` `id`,
r.over_limit_measurement_ratio_average `ratio`,
r.over_limit_measurement_average `count`
FROM
r_stat_harmonic_org_d r
where 1=1
and org_no in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id}
</foreach>
<if test="startTime!=null and endTime!=null">
and DATE_FORMAT(data_date,'%Y-%m-%d') between #{startTime} and #{endTime}
</if>
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
<?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.harmonic.mapper.StatHarmonicOrgMMapper">
<select id="listMonthRatio" resultType="StatHarmonicOrgVO">
SELECT
r.`org_no` `id`,
r.over_limit_measurement_ratio_average `ratio`,
r.over_limit_measurement_average `count`
FROM
r_stat_harmonic_org_m r
where 1=1
and org_no in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id}
</foreach>
<if test="startTime!=null and endTime!=null">
and DATE_FORMAT(data_date,'%Y-%m-%d') between #{startTime} and #{endTime}
</if>
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
<?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.harmonic.mapper.StatHarmonicOrgQMapper">
<select id="listQuarterRatio" resultType="StatHarmonicOrgVO">
SELECT
r.`org_no` `id`,
r.over_limit_measurement_ratio_average `ratio`,
r.over_limit_measurement_average `count`
FROM
r_stat_harmonic_org_q r
where 1=1
and org_no in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id}
</foreach>
<if test="startTime!=null and endTime!=null">
and DATE_FORMAT(data_date,'%Y-%m-%d') between #{startTime} and #{endTime}
</if>
</select>
</mapper>

View File

@@ -0,0 +1,21 @@
<?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.harmonic.mapper.StatHarmonicOrgYMapper">
<select id="listYearRatio" resultType="StatHarmonicOrgVO">
SELECT
r.`org_no` `id`,
r.over_limit_measurement_ratio_average `ratio`,
r.over_limit_measurement_average `count`
FROM
r_stat_harmonic_org_y r
where 1=1
and org_no in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
#{item.id}
</foreach>
<if test="startTime!=null and endTime!=null">
and DATE_FORMAT(data_date,'%Y-%m-%d') between #{startTime} and #{endTime}
</if>
</select>
</mapper>

View File

@@ -1,8 +1,10 @@
package com.njcn.harmonic.service;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.harmonic.pojo.param.HistoryParam;
import com.njcn.harmonic.pojo.param.NormHistoryParam;
import com.njcn.harmonic.pojo.vo.HistoryDataResultVO;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import java.util.List;
@@ -27,4 +29,11 @@ public interface HistoryResultService {
* @return 结果
*/
List<HistoryDataResultVO> getHistoryLineData(NormHistoryParam normHistoryParam);
/**
* 获取谐波越限监测点占比
* @param statisticsBizBaseParam 参数
* @return 结果
*/
List<StatHarmonicOrgVO> getHarmonicProportion(StatisticsBizBaseParam statisticsBizBaseParam);
}

View File

@@ -17,5 +17,5 @@ public interface NormLimitService {
* @param historyHarmOverLimitParam 参数
* @return 返回值
*/
List<HistoryHarmOverLimitVO> getHistoryTableData(HistoryHarmOverLimitParam historyHarmOverLimitParam);
List<HistoryHarmOverLimitVO> getHistoryData(HistoryHarmOverLimitParam historyHarmOverLimitParam,int type);
}

View File

@@ -0,0 +1,29 @@
package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.po.RStatPollutionSubstationM;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import java.util.List;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 8:56【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface PollutionSubstationService extends IService<RStatPollutionSubstationM>{
/**
* @Description: getPollutionSubstationData
* @Param: [pollutionSubstationQuryParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.PollutionSubstationVO>
* @Author: clam
* @Date: 2022/10/13
*/
List<PollutionSubstationVO> getPollutionSubstationData(PollutionSubstationQuryParam pollutionSubstationQuryParam);
}

View File

@@ -1,6 +1,8 @@
package com.njcn.harmonic.service;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.pojo.vo.RMpVThdVO;
import com.njcn.harmonic.pojo.vo.THDistortionCensusVO;
import com.njcn.harmonic.pojo.vo.THDistortionVO;
@@ -27,4 +29,12 @@ public interface THDistortionService {
* @return
*/
THDistortionCensusVO getTHDistortionCensus(DeviceInfoParam.BusinessParam thDistortionCensusParam);
/**
* @Description: 谐波总畸变率前十列表
* @Param: [statisticsBizBaseParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.RMpVThdVO>
* @Author: clam
* @Date: 2022/10/10
*/
List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam);
}

View File

@@ -2,6 +2,8 @@ package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.Overlimit;
@@ -9,14 +11,22 @@ import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.mapper.StatHarmonicOrgDMapper;
import com.njcn.harmonic.mapper.StatHarmonicOrgMMapper;
import com.njcn.harmonic.mapper.StatHarmonicOrgQMapper;
import com.njcn.harmonic.mapper.StatHarmonicOrgYMapper;
import com.njcn.harmonic.pojo.param.HistoryParam;
import com.njcn.harmonic.pojo.param.NormHistoryParam;
import com.njcn.harmonic.pojo.vo.EventDetailVO;
import com.njcn.harmonic.pojo.vo.HistoryDataResultVO;
import com.njcn.harmonic.pojo.vo.QueryResultLimitVO;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.harmonic.service.HistoryResultService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.utils.WebUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.influxdb.dto.QueryResult;
@@ -27,9 +37,9 @@ import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @author denghuajun
@@ -45,6 +55,16 @@ public class HistoryResultServiceImpl implements HistoryResultService {
private final EventDetailFeignClient eventDetailFeignClient;
private final DeptFeignClient deptFeignClient;
private final StatHarmonicOrgYMapper statHarmonicOrgYMapper;
private final StatHarmonicOrgQMapper statHarmonicOrgQMapper;
private final StatHarmonicOrgMMapper statHarmonicOrgMMapper;
private final StatHarmonicOrgDMapper statHarmonicOrgDMapper;
@Override
public List<HistoryDataResultVO> getHistoryResult(HistoryParam historyParam) {
List<HistoryDataResultVO> historyDataResultVOList = new ArrayList<>();
@@ -859,4 +879,119 @@ public class HistoryResultServiceImpl implements HistoryResultService {
}
return historyDataResultVO;
}
@Override
public List<StatHarmonicOrgVO> getHarmonicProportion(StatisticsBizBaseParam statisticsBizBaseParam){
List<StatHarmonicOrgVO> statHarmonicOrgVOS = new ArrayList<>();
//获取子部门
List<DeptDTO> depts = deptFeignClient.getDeptDescendantIndexes(statisticsBizBaseParam.getId(), WebUtil.filterDeptType()).getData();
if (depts.size() != 0) {
//根据上层id查询子数据并返回一个顺序流
depts = depts.stream().filter(allItem -> allItem.getPid().equals(statisticsBizBaseParam.getId())).collect(Collectors.toList());
//根据时间区分表查询
//年 季 月 日
switch (statisticsBizBaseParam.getType().toString()) {
case BizParamConstant.STAT_BIZ_YEAR:
statHarmonicOrgVOS = statHarmonicOrgYMapper.listYearRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
case BizParamConstant.STAT_BIZ_QUARTER:
statHarmonicOrgVOS = statHarmonicOrgQMapper.listQuarterRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
case BizParamConstant.STAT_BIZ_MONTH:
statHarmonicOrgVOS = statHarmonicOrgMMapper.listMonthRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
case BizParamConstant.STAT_BIZ_DAY:
statHarmonicOrgVOS = statHarmonicOrgDMapper.listDayRatio(depts, statisticsBizBaseParam.getStartTime(),statisticsBizBaseParam.getEndTime());
break;
default:
break;
}
}
//使用流对象的方法插入name值
if (statHarmonicOrgVOS.size() != 0){
statHarmonicOrgVOS = transName(statHarmonicOrgVOS, depts);
}
return statHarmonicOrgVOS;
}
/**
* 使用流对象的方法插入数据
*/
private static List<StatHarmonicOrgVO> transName(List<StatHarmonicOrgVO> statHarmonicOrgVOS, List<DeptDTO> deptDTOS) {
List<StatHarmonicOrgVO> list = statHarmonicOrgVOS.stream().map(e1 -> {
return deptDTOS.stream().filter(e2 -> {//条件判断
return e1.getId().equals(e2.getId());
}).map(e2 -> {
if (e2.getType() == 0) {
e1.setName(e2.getArea());
} else {
e1.setName(e2.getName());
}
return e1;//返回的结果
}).collect(Collectors.toList());
}).flatMap(List::stream).collect(Collectors.toList());//设置返回结果类型
return list;
}
// /**
// * 获取季度时间段
// * @param date
// * @return 结果
// */
// private static Map<String, Date> getSeasonDate(Date date) {
// Map<String, Date> result = new HashMap<>();
// //根据当前时间初始化
// Calendar start = Calendar.getInstance();
// Calendar end = Calendar.getInstance();
// start.setTime(date);
// end.setTime(date);
// //根据月份计算出季度时间段
// int month = start.get(Calendar.MONTH);
// switch (month) {
// case Calendar.JANUARY:
// case Calendar.FEBRUARY:
// case Calendar.MARCH:
// start.set(Calendar.MONTH, 0);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 2);
// end.set(Calendar.DATE, 31);
// break;
// case Calendar.APRIL:
// case Calendar.MAY:
// case Calendar.JUNE:
// start.set(Calendar.MONTH, 3);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 5);
// end.set(Calendar.DATE, 30);
// break;
// case Calendar.JULY:
// case Calendar.AUGUST:
// case Calendar.SEPTEMBER:
// start.set(Calendar.MONTH, 6);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 8);
// end.set(Calendar.DATE, 30);
// break;
// case Calendar.OCTOBER:
// case Calendar.NOVEMBER:
// case Calendar.DECEMBER:
// start.set(Calendar.MONTH, 9);
// start.set(Calendar.DATE,1);
// end.set(Calendar.MONTH, 11);
// end.set(Calendar.DATE, 31);
// break;
// default:
// break;
// }
// //转换成date组装返回
// result.put("startTime",start.getTime());
// result.put("endTime",end.getTime());
// return result;
// }
}

View File

@@ -1,31 +1,22 @@
package com.njcn.harmonic.service.impl;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.harmonic.constant.Param;
import cn.hutool.core.date.DateUtil;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.enums.common.ServerEnum;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.harmonic.mapper.NormLimitMapper;
import com.njcn.harmonic.pojo.param.HistoryHarmOverLimitParam;
import com.njcn.harmonic.pojo.vo.HistoryHarmOverLimitVO;
import com.njcn.harmonic.service.NormLimitService;
import com.njcn.influxdb.param.InfluxDBPublicParam;
import com.njcn.influxdb.utils.InfluxDbUtils;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.influxdb.dto.QueryResult;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
/**
* 类介绍
@@ -38,23 +29,38 @@ import java.util.concurrent.TimeUnit;
@AllArgsConstructor
public class NormLimitServiceImpl implements NormLimitService {
private final InfluxDbUtils influxDbUtils;
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final LineFeignClient lineFeignClient;
private final NormLimitMapper normLimitMapper;
@SneakyThrows
@Override
public List<HistoryHarmOverLimitVO> getHistoryTableData(HistoryHarmOverLimitParam historyHarmOverLimitParam) {
public List<HistoryHarmOverLimitVO> getHistoryData(HistoryHarmOverLimitParam historyHarmOverLimitParam, int type) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
List<HistoryHarmOverLimitVO> historyHarmOverLimitVO;
//处理接口数据
String[] lineIds = new String[historyHarmOverLimitParam.getLineId().length];
List<String> lineIds = new ArrayList<>();
if (type == 0) {
//处理接口数据
System.arraycopy(historyHarmOverLimitParam.getLineId(), 0, lineIds, 0, historyHarmOverLimitParam.getLineId().length);
} else {
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
deviceInfoParam.setDeptIndex(RequestUtil.getDeptIndex());
deviceInfoParam.setPowerFlag(2);
deviceInfoParam.setMonitorFlag(2);
deviceInfoParam.setServerName(ServerEnum.HARMONIC.getName());
SimpleDTO simpleDTO = new SimpleDTO();
simpleDTO.setName("电网拓扑");
simpleDTO.setSort(0);
simpleDTO.setCode("Power_Network");
deviceInfoParam.setStatisticalType(simpleDTO);
//处理监测点
List<GeneralDeviceDTO> deviceDataList = generalDeviceInfoClient.getPracticalAllDeviceInfo(deviceInfoParam).getData();
for (GeneralDeviceDTO generalDeviceDTO : deviceDataList) {
lineIds.addAll(generalDeviceDTO.getLineIndexes());
}
}
int[] types = new int[historyHarmOverLimitParam.getCondition().length];
int[] inde = new int[0];
int[] inharm = new int[0];
for (int i = 0; i < historyHarmOverLimitParam.getLineId().length; i++) {
lineIds[i] = historyHarmOverLimitParam.getLineId()[i];
}
for (int i = 0; i < historyHarmOverLimitParam.getCondition().length; i++) {
types[i] = Integer.parseInt(historyHarmOverLimitParam.getCondition()[i]);
@@ -73,124 +79,172 @@ public class NormLimitServiceImpl implements NormLimitService {
inharm[i] = Integer.parseInt(historyHarmOverLimitParam.getInHarmonics()[i]);
}
}
for (int i = 0; i < lineIds.length; i++) {
//查询数据
for (int j = 0; j < types.length; j++) {
historyHarmOverLimitVO = getCondition(historyHarmOverLimitParam.getSearchBeginTime(), historyHarmOverLimitParam.getSearchEndTime(), String.valueOf(lineIds[i]), String.valueOf(types[j]), inde, inharm);
historyHarmOverLimitVOList.addAll(historyHarmOverLimitVO);
}
for (int i : types) {
historyHarmOverLimitVO = getMyCondition(historyHarmOverLimitParam.getSearchBeginTime(), historyHarmOverLimitParam.getSearchEndTime(), lineIds, String.valueOf(i), inde, inharm);
historyHarmOverLimitVOList.addAll(historyHarmOverLimitVO);
}
//获取值
//处理数据
return historyHarmOverLimitVOList;
}
/**
* influxDB相关操作
* mysql相关操作
* 查询稳态数据分析
*/
@SneakyThrows
private List<HistoryHarmOverLimitVO> getCondition(String startTime, String endTime, String lineId, String contion, int[] number, int[] valueType) {
private List<HistoryHarmOverLimitVO> getMyCondition(String startTime, String endTime, List<String> lineId, String contion, int[] number, int[] inharm) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
//数据的转化
historyHarmOverLimitVOList = getQueryResult(startTime, endTime, lineId, contion, number, valueType);
return historyHarmOverLimitVOList;
}
private List<HistoryHarmOverLimitVO> getQueryResult(String startTime, String endTime, String lineList, String contion, int[] number, int[] inHarmNum) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
QueryResult queryResult = null;
if (!lineList.isEmpty()) {
//组装sql语句
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(InfluxDBPublicParam.TIME + " >= '").append(startTime).append(InfluxDBPublicParam.START_TIME).append("' and ").append(InfluxDBPublicParam.TIME).append(" <= '").append(endTime).append(InfluxDBPublicParam.END_TIME).append("' and (");
//sql语句
stringBuilder.append(InfluxDBPublicParam.LINE_ID).append("='").append(lineList).append("')");
String sql;
String targetName;//指标名称
String unit;//单位
if (!lineId.isEmpty()) {
switch (Integer.parseInt(contion)) {
case 12:
//电压偏差
sql = "SELECT time as time, voltage_dev as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "电压偏差", "%");
targetName = "电压偏差";
unit = "%";
historyHarmOverLimitVOList = normLimitMapper.getDyPc(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getMinData()) ? 3 : 2);
}
}
break;
case 13:
//三相电压不平衡度
sql = "SELECT time as time, ubalance as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='T') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "三相电压不平衡度", "/");
targetName = "三相电压不平衡度";
unit = "/";
historyHarmOverLimitVOList = normLimitMapper.getSxBpHd(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getCp95Data()) ? 3 : 4);
}
}
break;
case 15:
//电压总谐波畸变率
sql = "SELECT time as time, uaberrance as aValue,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "电压总谐波畸变率", "%");
targetName = "电压总谐波畸变率";
unit = "%";
historyHarmOverLimitVOList = normLimitMapper.getDyZjBl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
break;
case 22:
//负序电流
sql = "SELECT time as time, i_neg as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='T') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "负序电流", "/");
targetName = "负序电流";
unit = "/";
historyHarmOverLimitVOList = normLimitMapper.getFxDl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getCp95Data()) ? 3 : 4);
}
}
break;
case 30:
//频率 V9暂时代表Freq
sql = "SELECT time as time, freq_dev as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='T') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "频率", "Hz");
targetName = "频率";
unit = "Hz";
historyHarmOverLimitVOList = normLimitMapper.getPl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(Math.abs(historyHarmOverLimitVO.getMaxData()) > Math.abs(historyHarmOverLimitVO.getMinData()) ? 3 : 2);
}
}
break;
case 40:
for (int i = 0; i < number.length; i++) {
List<HistoryHarmOverLimitVO> harmOverLimitVOList;
//谐波电压含有率
sql = "SELECT time as time, uharm_" + number[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
harmOverLimitVOList = getNormData(queryResult, contion, lineList, "谐波电压含有率", "%", number[i]);
historyHarmOverLimitVOList.addAll(harmOverLimitVOList);
targetName = "谐波电压含有率";
unit = "%";
for (int i : number) {
historyHarmOverLimitVOList = normLimitMapper.getXbDyHyl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)), i);
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setNumber(i);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
}
break;
case 43:
for (int i = 0; i < number.length; i++) {
List<HistoryHarmOverLimitVO> harmOverLimitVOList;
//谐波电流幅值
sql = "SELECT time as time, iharm_" + number[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
harmOverLimitVOList = getNormData(queryResult, contion, lineList, "谐波电流幅值", "A", number[i]);
historyHarmOverLimitVOList.addAll(harmOverLimitVOList);
targetName = "谐波电流幅值";
unit = "A";
for (int i : number) {
historyHarmOverLimitVOList = normLimitMapper.getXbDlFz(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)), i);
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setNumber(i);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
}
break;
case 46:
for (int i = 0; i < inHarmNum.length; i++) {
List<HistoryHarmOverLimitVO> harmOverLimitVOList;
//间谐波电压含有率
sql = "SELECT time as time, inuharm_" + inHarmNum[i] + " as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'MAX' or value_type = 'MIN' or value_type = 'AVG' or value_type = 'CP95') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
harmOverLimitVOList = getNormData(queryResult, contion, lineList, "间谐波电压含有率", "%", inHarmNum[i]);
historyHarmOverLimitVOList.addAll(harmOverLimitVOList);
targetName = "间谐波电压含有率";
unit = "%";
for (int i : inharm) {
historyHarmOverLimitVOList = normLimitMapper.getJxbHyl(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)), i);
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159 && historyHarmOverLimitVO.getMaxData() == -3.14159 && historyHarmOverLimitVO.getMinData() == -3.14159 && historyHarmOverLimitVO.getCp95Data() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setNumber(i);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(4);
}
}
}
break;
case 61:
//长时闪变
sql = "SELECT time as time, flicker as aValue ,phasic_type , value_type FROM pqs_abnormaldata WHERE " + stringBuilder.toString() +
" and (phasic_type ='A' or phasic_type ='B' or phasic_type ='C') " +
" and (value_type = 'AVG') group by phasic_type order by time asc tz('Asia/Shanghai');";
queryResult = influxDbUtils.query(sql);
historyHarmOverLimitVOList = getNormData(queryResult, contion, lineList, "长时闪变", "/");
targetName = "长时闪变";
unit = "/";
historyHarmOverLimitVOList = normLimitMapper.getCsSb(lineId, DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.endOfDay(DateUtil.parse(endTime)));
for (HistoryHarmOverLimitVO historyHarmOverLimitVO : historyHarmOverLimitVOList) {
if (historyHarmOverLimitVO.getAvgData() == -3.14159) {
historyHarmOverLimitVOList.remove(historyHarmOverLimitVO);
} else {
historyHarmOverLimitVO.setTargetName(targetName);
historyHarmOverLimitVO.setUnit(unit);
historyHarmOverLimitVO.setMaxData(3.14159f);
historyHarmOverLimitVO.setMinData(3.14159f);
historyHarmOverLimitVO.setCp95Data(3.14159f);
historyHarmOverLimitVO.setTargetCode(contion);
historyHarmOverLimitVO.setStatisticalType(1);
}
}
break;
default:
break;
@@ -200,328 +254,4 @@ public class NormLimitServiceImpl implements NormLimitService {
}
return historyHarmOverLimitVOList;
}
//数据组装
@SneakyThrows
private List<HistoryHarmOverLimitVO> getNormData(QueryResult queryResult, String contion, String lineList, String phaseName, String unit) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
List<QueryResult.Result> qusery = queryResult.getResults();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//获取监测点详情
LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(lineList).getData();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) {
String time = "";
Float aMax = 0.0f, aMin = 0.0f, aAvg = 0.0f, aCp95 = 0.0f, bMax = 0.0f, bMin = 0.0f, bAvg = 0.0f, bCp95 = 0.0f, cMax = 0.0f, cMin = 0.0f, cAvg = 0.0f, cCp95 = 0.0f;
for (int i = 0; i < qusery.get(0).getSeries().size(); i++) {
if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("A")) {
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) {
for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) {
List<Object> objectList = qusery.get(0).getSeries().get(i).getValues().get(j);
String aa = String.valueOf(objectList.get(0));
Date sd = dateFormat.parse(aa);
time = dateFormat.format(sd);
if (Integer.parseInt(contion) == 61) {
historyDataResultVO.setMaxValue((float) 3.14159);
historyDataResultVO.setMinValue((float) 3.14159);
historyDataResultVO.setCp95Value((float) 3.14159);
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else {
if (objectList.get(3).equals("MAX")) {
aMax = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMaxValue(aMax);
} else if (objectList.get(3).equals("MIN")) {
aMin = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMinValue(aMin);
} else if (objectList.get(3).equals("AVG")) {
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else if (objectList.get(3).equals("CP95")) {
aCp95 = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setCp95Value(aCp95);
}
}
}
}
historyDataResultVO.setTime(time);
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(0);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(phaseName);
if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("AB");
} else {
historyDataResultVO.setPhaseType("A");
}
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2);
} else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) {
historyDataResultVO.setPhaseType("/");
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4);
} else {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("AB");
} else {
historyDataResultVO.setPhaseType("A");
}
historyDataResultVO.setStatisticalType(3);
}
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
}
if ("12".equals(contion) || "15".equals(contion) || "40".equals(contion) || "61".equals(contion)) {
if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("B")) {
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) {
for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) {
List<Object> objectList = qusery.get(0).getSeries().get(i).getValues().get(j);
String aa = String.valueOf(objectList.get(0));
Date sd = dateFormat.parse(aa);
time = dateFormat.format(sd);
if (Integer.parseInt(contion) == 61) {
historyDataResultVO.setMaxValue((float) 3.14159);
historyDataResultVO.setMinValue((float) 3.14159);
historyDataResultVO.setCp95Value((float) 3.14159);
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else {
if (objectList.get(3).equals("MAX")) {
bMax = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMaxValue(bMax);
} else if (objectList.get(3).equals("MIN")) {
bMin = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMinValue(bMin);
} else if (objectList.get(3).equals("AVG")) {
bAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(bAvg);
} else if (objectList.get(3).equals("CP95")) {
bCp95 = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setCp95Value(bCp95);
}
}
}
}
historyDataResultVO.setTime(time);
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(0);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(phaseName);
if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("BC");
} else {
historyDataResultVO.setPhaseType("B");
}
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aMin) ? 3 : 2);
} else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) {
historyDataResultVO.setPhaseType("/");
historyDataResultVO.setStatisticalType(Math.abs(aMax) > Math.abs(aCp95) ? 3 : 4);
} else {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("BC");
} else {
historyDataResultVO.setPhaseType("B");
}
historyDataResultVO.setStatisticalType(3);
}
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
} else if (qusery.get(0).getSeries().get(i).getTags().get("phasic_type").equals("C")) {
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries().get(i).getValues())) {
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
for (int j = 0; j < qusery.get(0).getSeries().get(i).getValues().size(); j++) {
List<Object> objectList = qusery.get(0).getSeries().get(i).getValues().get(j);
String aa = String.valueOf(objectList.get(0));
Date sd = dateFormat.parse(aa);
time = dateFormat.format(sd);
if (Integer.parseInt(contion) == 61) {
historyDataResultVO.setMaxValue((float) 3.14159);
historyDataResultVO.setMinValue((float) 3.14159);
historyDataResultVO.setCp95Value((float) 3.14159);
aAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(aAvg);
} else {
if (objectList.get(3).equals("MAX")) {
cMax = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMaxValue(cMax);
} else if (objectList.get(3).equals("MIN")) {
cMin = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setMinValue(cMin);
} else if (objectList.get(3).equals("AVG")) {
cAvg = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setAvgValue(cAvg);
} else if (objectList.get(3).equals("CP95")) {
cCp95 = Float.parseFloat(String.valueOf(objectList.get(1)));
historyDataResultVO.setCp95Value(cCp95);
}
}
}
historyDataResultVO.setTime(time);
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(0);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(phaseName);
if (Integer.parseInt(contion) == 12 || Integer.parseInt(contion) == 15) {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("CA");
} else {
historyDataResultVO.setPhaseType("C");
}
historyDataResultVO.setStatisticalType(Math.abs(cMax) > Math.abs(cMin) ? 3 : 2);
} else if (Integer.parseInt(contion) == 13 || Integer.parseInt(contion) == 22) {
historyDataResultVO.setPhaseType("/");
historyDataResultVO.setStatisticalType(Math.abs(cMax) > Math.abs(cCp95) ? 3 : 4);
} else {
if (PubUtils.ptTypeName(lineDetailDataVO.getPtType()) != 0) {
historyDataResultVO.setPhaseType("CA");
} else {
historyDataResultVO.setPhaseType("C");
}
historyDataResultVO.setStatisticalType(3);
}
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
}
}
}
}
}
return historyHarmOverLimitVOList;
}
@SneakyThrows
private List<HistoryHarmOverLimitVO> getNormData(QueryResult queryResult, String contion, String lineList, String phaseName, String unit, int number) {
List<HistoryHarmOverLimitVO> historyHarmOverLimitVOList = new ArrayList<>();
List<QueryResult.Result> qusery = queryResult.getResults();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//获取监测点详情
LineDetailDataVO lineDetailDataVO = lineFeignClient.getLineDetailData(lineList).getData();
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) {
String time = "";
Float aMax = 0.0f, aMin = 0.0f, aAvg = 0.0f, aCp95 = 0.0f, bMax = 0.0f, bMin = 0.0f, bAvg = 0.0f, bCp95 = 0.0f, cMax = 0.0f, cMin = 0.0f, cAvg = 0.0f, cCp95 = 0.0f;
HistoryHarmOverLimitVO historyDataResultVO = new HistoryHarmOverLimitVO();
for (int i = 0; i < qusery.get(0).getSeries().get(0).getValues().size(); i++) {
//A相的最大值
if (!CollectionUtils.isEmpty(qusery.get(0).getSeries())) {
aMax = Float.parseFloat(qusery.get(0).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setMaxValue(aMax);
}
//A相的最小值
if (!CollectionUtils.isEmpty(qusery.get(1).getSeries())) {
aMin = Float.parseFloat(qusery.get(1).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setMinValue(aMin);
}
//A相的评价值
if (!CollectionUtils.isEmpty(qusery.get(2).getSeries())) {
aAvg = Float.parseFloat(qusery.get(2).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setAvgValue(aAvg);
}
//A相的CP95
if (!CollectionUtils.isEmpty(qusery.get(3).getSeries())) {
time = String.valueOf(qusery.get(3).getSeries().get(0).getValues().get(i).get(0));
aCp95 = Float.parseFloat(qusery.get(3).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVO.setTime(dateFormat.format(sdf.parse(time)));
historyDataResultVO.setCp95Value(aCp95);
}
historyDataResultVO.setLineName(lineDetailDataVO.getLineName());
historyDataResultVO.setLineId(lineList);
historyDataResultVO.setNumber(number);
historyDataResultVO.setSubName(lineDetailDataVO.getBdName());
historyDataResultVO.setTargetCode(contion);
historyDataResultVO.setTargetName(number + "" + phaseName);
historyDataResultVO.setPhaseType("A");
historyDataResultVO.setStatisticalType(4);
historyDataResultVO.setScale(lineDetailDataVO.getScale());
historyDataResultVO.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVO);
}
for (int i = 0; i < qusery.get(4).getSeries().get(0).getValues().size(); i++) {
HistoryHarmOverLimitVO historyDataResultVOB = new HistoryHarmOverLimitVO();
//B相的最大值
if (!CollectionUtils.isEmpty(qusery.get(4).getSeries())) {
bMax = Float.parseFloat(qusery.get(4).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setMaxValue(bMax);
}
//B相的最小值
if (!CollectionUtils.isEmpty(qusery.get(5).getSeries())) {
bMin = Float.parseFloat(qusery.get(5).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setMinValue(bMin);
}
//B相的平均值
if (!CollectionUtils.isEmpty(qusery.get(6).getSeries())) {
bAvg = Float.parseFloat(qusery.get(6).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setAvgValue(bAvg);
}
//B相的CP95
if (!CollectionUtils.isEmpty(qusery.get(7).getSeries())) {
time = String.valueOf(qusery.get(7).getSeries().get(0).getValues().get(i).get(0));
bCp95 = Float.parseFloat(qusery.get(7).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOB.setTime(dateFormat.format(sdf.parse(time)));
historyDataResultVOB.setCp95Value(bCp95);
}
historyDataResultVOB.setLineName(lineDetailDataVO.getLineName());
historyDataResultVOB.setLineId(lineList);
historyDataResultVOB.setNumber(number);
historyDataResultVOB.setSubName(lineDetailDataVO.getBdName());
historyDataResultVOB.setTargetCode(contion);
historyDataResultVOB.setTargetName(number + "" + phaseName);
historyDataResultVOB.setPhaseType("B");
historyDataResultVOB.setScale(lineDetailDataVO.getScale());
historyDataResultVOB.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVOB);
}
for (int i = 0; i < qusery.get(8).getSeries().get(0).getValues().size(); i++) {
HistoryHarmOverLimitVO historyDataResultVOC = new HistoryHarmOverLimitVO();
//C相的最大值
if (!CollectionUtils.isEmpty(qusery.get(8).getSeries())) {
cMax = Float.parseFloat(qusery.get(8).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setMaxValue(cMax);
}
//C相的最小值
if (!CollectionUtils.isEmpty(qusery.get(9).getSeries())) {
cMin = Float.parseFloat(qusery.get(9).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setMinValue(cMin);
}
//C相的平均值
if (!CollectionUtils.isEmpty(qusery.get(10).getSeries())) {
cAvg = Float.parseFloat(qusery.get(10).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setAvgValue(cAvg);
}
//C相的CP95
if (!CollectionUtils.isEmpty(qusery.get(11).getSeries())) {
time = String.valueOf(qusery.get(11).getSeries().get(0).getValues().get(i).get(0));
cCp95 = Float.parseFloat(qusery.get(11).getSeries().get(0).getValues().get(i).get(1).toString());
historyDataResultVOC.setTime(dateFormat.format(sdf.parse(time)));
historyDataResultVOC.setCp95Value(cCp95);
}
historyDataResultVOC.setLineName(lineDetailDataVO.getLineName());
historyDataResultVOC.setLineId(lineList);
historyDataResultVOC.setNumber(number);
historyDataResultVOC.setSubName(lineDetailDataVO.getBdName());
historyDataResultVOC.setTargetCode(contion);
historyDataResultVOC.setTargetName(number + "" + phaseName);
historyDataResultVOC.setPhaseType("C");
historyDataResultVOC.setScale(lineDetailDataVO.getScale());
historyDataResultVOC.setUnit(unit);
historyHarmOverLimitVOList.add(historyDataResultVOC);
}
}
return historyHarmOverLimitVOList;
}
}

View File

@@ -0,0 +1,111 @@
package com.njcn.harmonic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.config.GeneralInfo;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.api.SubstationFeignClient;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.dto.PollutionSubstationDTO;
import com.njcn.device.pq.pojo.dto.SubstationDTO;
import com.njcn.harmonic.mapper.RStatPollutionSubstationMMapper;
import com.njcn.harmonic.pojo.param.HarmonicPublicParam;
import com.njcn.harmonic.pojo.param.PollutionSubstationQuryParam;
import com.njcn.harmonic.pojo.po.RStatPollutionSubstationM;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import com.njcn.harmonic.service.PollutionSubstationService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/13 8:56【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@Service
@AllArgsConstructor
public class PollutionSubstationServiceImpl extends ServiceImpl<RStatPollutionSubstationMMapper, RStatPollutionSubstationM> implements PollutionSubstationService {
private final SubstationFeignClient substationFeignClient;
private final RStatPollutionSubstationMMapper pollutionSubstationMMapper;
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final LineFeignClient lineFeignClient;
private final GeneralInfo generalInfo;
/**
* @param pollutionSubstationQuryParam
* @Description: getPollutionSubstationData
* @Param: [pollutionSubstationQuryParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.PollutionSubstationVO>
* @Author: clam
* @Date: 2022/10/13
*/
@Override
public List<PollutionSubstationVO> getPollutionSubstationData(PollutionSubstationQuryParam pollutionSubstationQuryParam) {
List<PollutionSubstationVO> pollutionSubstationVOList = new ArrayList<> ();
/*根据部门获取变电站详情*/
HarmonicPublicParam harmonicPublicParam = new HarmonicPublicParam();
BeanUtils.copyProperties (pollutionSubstationQuryParam, harmonicPublicParam);
harmonicPublicParam.setServerName(generalInfo.getMicroServiceName());
List<PollutionSubstationDTO> pollutionSubstationDTOList = new ArrayList<>();
List<GeneralDeviceDTO> sub = generalDeviceInfoClient.getPracticalRunDeviceInfoAsSubstation(harmonicPublicParam).getData();
sub.forEach(item->{
PollutionSubstationDTO pollutionSubstationDTO = lineFeignClient.getSubstationInfo(item.getIndex()).getData();
pollutionSubstationDTOList.add(pollutionSubstationDTO);
});
List<String> collect = pollutionSubstationDTOList.stream ( ).map (PollutionSubstationDTO::getId).collect (Collectors.toList ( ));
List<SubstationDTO> locationData = substationFeignClient.getSubstationById (collect).getData ( );
/*todo 后期可以把locationData存入redis*/
/*把所有的变电站的污染指数查出来*/
QueryWrapper<RStatPollutionSubstationM> wrapper = new QueryWrapper<> ();
wrapper.in ("substation_id",collect).
eq ("pollution_type", pollutionSubstationQuryParam.getPollutionStatis ().getId ()).
apply("DATE_FORMAT( data_date ,'%Y-%m') = '"+pollutionSubstationQuryParam.getLocalDate ()+"'");
List<RStatPollutionSubstationM> rStatPollutionSubstationMList = pollutionSubstationMMapper.selectList (wrapper);
pollutionSubstationDTOList.forEach (substationInfo ->{
PollutionSubstationVO pollutionSubstationVO =new PollutionSubstationVO ();
pollutionSubstationVO.setSubstationId (substationInfo.getId ());
pollutionSubstationVO.setSubstationName (substationInfo.getName ());
/*todo 添加经纬度接口返回数据暂时没有*/
SubstationDTO substationDTO = locationData.stream ().filter (temp -> Objects.equals (substationInfo.getId ( ), temp.getId ())).
collect (Collectors.toList ( )).get (0);
pollutionSubstationVO.setLatitude (substationDTO.getLat ());
pollutionSubstationVO.setLongitude (substationDTO.getLng ());
Double value = Optional.ofNullable (
rStatPollutionSubstationMList.stream ( ).filter (temp -> Objects.equals (substationInfo.getId ( ), temp.getSubstationId ( ))).
collect (Collectors.toList ( )).get (0).getValue ( )
).orElse (new Double ("0.00"));
pollutionSubstationVO.setPollutionData (value);
pollutionSubstationVO.setPollutionStatis ( pollutionSubstationQuryParam.getStatisticalType ().getName ());
pollutionSubstationVOList.add (pollutionSubstationVO);
});
List<PollutionSubstationVO> result = pollutionSubstationVOList.stream ( ).sorted (Comparator.comparing (PollutionSubstationVO::getPollutionData).reversed ( )).collect (Collectors.toList ( ));
return result;
}
}

View File

@@ -1,27 +1,33 @@
package com.njcn.harmonic.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.harmonic.constant.Param;
import com.njcn.harmonic.mapper.RMpVThdMapper;
import com.njcn.harmonic.mapper.THDistortionMapper;
import com.njcn.harmonic.pojo.dto.PublicDTO;
import com.njcn.harmonic.pojo.po.RMpVThd;
import com.njcn.harmonic.pojo.vo.RMpVThdVO;
import com.njcn.harmonic.pojo.vo.THDistortionCensusVO;
import com.njcn.harmonic.pojo.vo.THDistortionVO;
import com.njcn.harmonic.service.THDistortionService;
import com.njcn.influxdb.utils.InfluxDbUtils;
import lombok.AllArgsConstructor;
import org.influxdb.dto.QueryResult;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -41,6 +47,9 @@ public class THDistortionServiceImpl implements THDistortionService {
private final InfluxDbUtils influxDbUtils;
private final RMpVThdMapper rMpVThdMapper;
private final LineFeignClient lineFeignClient;
@Override
public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) {
List<THDistortionVO> thDistortionVOS = new ArrayList<>();
@@ -96,6 +105,47 @@ public class THDistortionServiceImpl implements THDistortionService {
return distortionCensusVO;
}
/**
* @param statisticsBizBaseParam
* @Description: 谐波总畸变率前十列表
* @Param: [statisticsBizBaseParam]
* @return: java.util.List<com.njcn.harmonic.pojo.vo.RMpVThdVO>
* @Author: clam
* @Date: 2022/10/10
*/
@Override
public List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam) {
List<RMpVThdVO> rMpVThdVOList = new ArrayList<> ();
DeviceInfoParam deviceInfoParam = new DeviceInfoParam ();
deviceInfoParam.setDeptIndex (statisticsBizBaseParam.getId ());
deviceInfoParam.setStatisticalType (new SimpleDTO ());
deviceInfoParam.setServerName (generalInfo.getMicroServiceName());
deviceInfoParam.setPowerFlag (0);
deviceInfoParam.setMonitorFlag (0);
/*获取按部门分类的实际所有终端综合信息*/
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalAllDeviceInfoAsDept (deviceInfoParam).getData ();
/*监测点ID扁平化*/
List<String> collect = deviceList.stream ( ).map (GeneralDeviceDTO::getLineIndexes).flatMap (Collection::stream).distinct ( ).collect (Collectors.toList ( ));
QueryWrapper<RMpVThd> wrapper = new QueryWrapper<>();
wrapper.in ("measurement_point_id",collect).
eq ("data_type", statisticsBizBaseParam.getType ()).
between ("data_date", statisticsBizBaseParam.getStartTime (), statisticsBizBaseParam.getEndTime ()).
orderByDesc ("v_thd").
last (" limit 10");
List<RMpVThd> rMpVThdList = rMpVThdMapper.selectList (wrapper);
rMpVThdVOList = rMpVThdList.stream ( ).map (rMpVThd -> {
RMpVThdVO rMpVThdVO = new RMpVThdVO ( );
BeanUtils.copyProperties (rMpVThd, rMpVThdVO);
/*查询监测点详情获取名称*/
LineDetailDataVO data = lineFeignClient.getLineDetailData (rMpVThd.getMeasurementPointId ( )).getData ( );
rMpVThdVO.setName (data.getLineName ());
return rMpVThdVO;
}).collect (Collectors.toList ( ));
return rMpVThdVOList;
}
/**
* 计算父级畸变率