代码调整
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.njcn.device.pq.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.device.pq.pojo.param.AlgorithmSearchParam;
|
||||
import com.njcn.device.pq.service.DataExceptionService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
* 数据是否异常
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/dataException")
|
||||
@Api(tags = "数据是否异常")
|
||||
@AllArgsConstructor
|
||||
public class DataExceptionController extends BaseController {
|
||||
|
||||
private final DataExceptionService dataExceptionService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/lineDataException")
|
||||
@ApiOperation("监测点数据是否异常")
|
||||
@ApiImplicitParam(name = "algorithmSearchParam", value = "算法通用查询参数", required = true)
|
||||
public HttpResult<Boolean> lineDataException(@RequestBody @Validated AlgorithmSearchParam algorithmSearchParam) {
|
||||
String methodDescribe = getMethodDescribe("lineDataException");
|
||||
boolean res = dataExceptionService.lineDataException(algorithmSearchParam);
|
||||
if(res){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.device.pq.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.device.pq.pojo.param.AlgorithmSearchParam;
|
||||
import com.njcn.device.pq.service.DataIntegrityRateService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
* 数据完整率算法
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/dataIntegrityRate")
|
||||
@Api(tags = "数据完整率算法")
|
||||
@AllArgsConstructor
|
||||
public class DataIntegrityRateController extends BaseController {
|
||||
|
||||
private final DataIntegrityRateService dataIntegrityRateService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/lineDataIntegrityRate")
|
||||
@ApiOperation("监测点日数据完整率")
|
||||
@ApiImplicitParam(name = "algorithmSearchParam", value = "算法通用查询参数", required = true)
|
||||
public HttpResult<Boolean> lineDataIntegrityRate(@RequestBody @Validated AlgorithmSearchParam algorithmSearchParam) {
|
||||
String methodDescribe = getMethodDescribe("lineDataIntegrityRate");
|
||||
boolean res = dataIntegrityRateService.lineDataIntegrityRate(algorithmSearchParam);
|
||||
if(res){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.vo.DeptDeviceDetailVO;
|
||||
import com.njcn.device.pq.pojo.vo.DeptSubstationDetailVO;
|
||||
import com.njcn.device.pq.pojo.vo.ExceptionDeviceInfoVO;
|
||||
import com.njcn.device.pq.service.TerminalBaseService;
|
||||
import com.njcn.device.pq.service.impl.GeneralDeviceService;
|
||||
@@ -124,7 +126,6 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<List<GeneralDeviceDTO>> getPracticalRunDeviceInfoAsSubstation(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getPracticalRunDeviceInfoAsSubstation");
|
||||
List<GeneralDeviceDTO> substationDeviceInfos = generalDeviceService.getDeviceInfoAsSubstation(deviceInfoParam, Stream.of(0).collect(Collectors.toList()), Stream.of(1).collect(Collectors.toList()));
|
||||
@@ -229,4 +230,40 @@ public class GeneralDeviceInfoController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按部门获取终端设备总数,在线数,在线率
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getDeptDeviceDetail")
|
||||
@ApiOperation("按部门获取终端设备总数,在线数,在线率")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<DeptDeviceDetailVO> getDeptDeviceDetail(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getDeptDeviceDetail");
|
||||
DeptDeviceDetailVO deptDeviceDetail = generalDeviceService.getDeptDeviceDetail(deviceInfoParam);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptDeviceDetail, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 按部门获变电站数,变电站在线数,在线率
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getDeptSubstationDetail")
|
||||
@ApiOperation("按部门获变电站数,变电站在线数,在线率")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceInfoParam", value = "查询终端条件", required = true)
|
||||
})
|
||||
@Deprecated
|
||||
public HttpResult<DeptSubstationDetailVO> getDeptSubstationDetail(@RequestBody @Validated DeviceInfoParam deviceInfoParam) {
|
||||
String methodDescribe = getMethodDescribe("getDeptSubstationDetail");
|
||||
DeptSubstationDetailVO deptSubstationDetail = generalDeviceService.getDeptSubstationDetail(deviceInfoParam);
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, deptSubstationDetail, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
|
||||
/**
|
||||
* 查询装置下的母线信息
|
||||
*
|
||||
* @param devId 设备id
|
||||
* @date 2022/7/1
|
||||
*/
|
||||
@@ -117,7 +118,7 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
List<Line> getDeviceById(@Param("devIds") List<String> devIds, @Param("deviceType") DeviceType deviceType);
|
||||
|
||||
|
||||
List<TerminalBaseVO> getDeviceByIdOnOrOff(@Param("devIds") List<String> devIds, @Param("deviceType") DeviceType deviceType,@Param("comFlag")Integer comFlag);
|
||||
List<TerminalBaseVO> getDeviceByIdOnOrOff(@Param("devIds") List<String> devIds, @Param("deviceType") DeviceType deviceType, @Param("comFlag") Integer comFlag);
|
||||
|
||||
|
||||
List<LineDataVO> getLineDetail(@Param("ids") List<String> ids);
|
||||
@@ -176,116 +177,133 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
|
||||
/**
|
||||
* 获取所有在线投运的监测点限值
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/3/23
|
||||
*/
|
||||
List<Overlimit> getAllLineOverLimit(@Param("list")List<Integer> list);
|
||||
List<Overlimit> getAllLineOverLimit(@Param("list") List<Integer> list);
|
||||
|
||||
/**
|
||||
* 根据监测点集合查询基础信息
|
||||
*
|
||||
* @param lineIndex 监测点结合
|
||||
* @return 基础信息
|
||||
*/
|
||||
List<BaseLineInfo> getBaseLineInfo(@Param("list")List<String> lineIndex);
|
||||
List<BaseLineInfo> getBaseLineInfo(@Param("list") List<String> lineIndex);
|
||||
|
||||
|
||||
/**
|
||||
* 获取监测点区域详细信息(原基础上添加监测点区域经纬度信息)
|
||||
*
|
||||
* @param lineIndex 监测点结合
|
||||
* @date 2022/6/29
|
||||
*/
|
||||
List<AreaLineInfoVO> getBaseLineAreaInfo(@Param("list")List<String> lineIndex,@Param("searchValue")String searchValue,@Param("comFlag")Integer comFlag);
|
||||
List<AreaLineInfoVO> getBaseLineAreaInfo(@Param("list") List<String> lineIndex, @Param("searchValue") String searchValue, @Param("comFlag") Integer comFlag);
|
||||
|
||||
/**
|
||||
* 返回监测点信息及通讯状态
|
||||
*
|
||||
* @param lineIndex 监测点集合
|
||||
* @return 结果
|
||||
*/
|
||||
List<LineDeviceStateVO> getLineDeviceStateVO(@Param("list")List<String> lineIndex);
|
||||
List<LineDeviceStateVO> getLineDeviceStateVO(@Param("list") List<String> lineIndex);
|
||||
|
||||
|
||||
/**
|
||||
* 获取变电站信息
|
||||
* @param id 变电站id
|
||||
*
|
||||
* @param id 变电站id
|
||||
* @return 结果
|
||||
*/
|
||||
PollutionSubstationDTO getSubstationInfo(@Param("id")String id);
|
||||
PollutionSubstationDTO getSubstationInfo(@Param("id") String id);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param list 监测点集合
|
||||
*
|
||||
* @param list 监测点集合
|
||||
* @return 结果
|
||||
*/
|
||||
List<PollutionLineDTO> getLineInfo(@Param("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param id 监测点id
|
||||
*
|
||||
* @param id 监测点id
|
||||
* @return 结果
|
||||
*/
|
||||
LineDetailVO getLineSubGdDetail(@Param("id")String id);
|
||||
LineDetailVO getLineSubGdDetail(@Param("id") String id);
|
||||
|
||||
/**
|
||||
* 获取告警变电站信息
|
||||
* @param list 变电站集合
|
||||
*
|
||||
* @param list 变电站集合
|
||||
* @return 结果
|
||||
*/
|
||||
List<WarningSubstationDTO> getWarningSub(@Param("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param list 变电站集合
|
||||
*
|
||||
* @param list 变电站集合
|
||||
* @return 结果
|
||||
*/
|
||||
List<OverLimitLineDTO> getOverLimitLineInfo(@Param("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 获取监测点状态信息
|
||||
* @param list 变电站集合
|
||||
*
|
||||
* @param list 变电站集合
|
||||
* @return 结果
|
||||
*/
|
||||
LineStateVO getLineStatisticsDetail(@Param("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param list 变电站集合
|
||||
*
|
||||
* @param list 变电站集合
|
||||
* @return 结果
|
||||
*/
|
||||
List<LineStatisticsTableVO> getLineInfoByTableList(@Param("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param list 变电站集合
|
||||
*
|
||||
* @param list 变电站集合
|
||||
* @return 结果
|
||||
*/
|
||||
List<LineFlowMealDetailVO> getFlowLineInfoByTableList(@Param("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param list 变电站集合
|
||||
*
|
||||
* @param list 变电站集合
|
||||
* @return 结果
|
||||
*/
|
||||
List<LineStatisticsTableVO> getLineStatisticsTableData(@Param("list") List<String> list);
|
||||
|
||||
/**
|
||||
* 监测点运行统计
|
||||
* @param list 监测点集合
|
||||
*
|
||||
* @param list 监测点集合
|
||||
* @param startTime 起始时间
|
||||
* @param endTime 结束时间
|
||||
* @param endTime 结束时间
|
||||
* @return 结果
|
||||
*/
|
||||
List<LineFlowMealDetailVO> getLineRunStatistics(@Param("list") List<String> list, @Param("startTime") DateTime startTime, @Param("endTime")DateTime endTime);
|
||||
List<LineFlowMealDetailVO> getLineRunStatistics(@Param("list") List<String> list, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
|
||||
|
||||
/**
|
||||
* 监测点运行统计
|
||||
* @param list 监测点集合
|
||||
*
|
||||
* @param list 监测点集合
|
||||
* @param startTime 起始时间
|
||||
* @param endTime 结束时间
|
||||
* @param endTime 结束时间
|
||||
* @return 结果
|
||||
*/
|
||||
List<LineFlowMealDetailVO> getFlowLineRunStatistics(@Param("list") List<String> list, @Param("startTime") DateTime startTime, @Param("endTime")DateTime endTime);
|
||||
List<LineFlowMealDetailVO> getFlowLineRunStatistics(@Param("list") List<String> list, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取生成limitRate表的监测点集合
|
||||
*
|
||||
* @return 监测点id集合
|
||||
*/
|
||||
List<String> getLineList();
|
||||
@@ -293,6 +311,7 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
|
||||
/**
|
||||
* 导出终端台账信息
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/5/17
|
||||
*/
|
||||
@@ -300,45 +319,51 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
|
||||
/**
|
||||
* 根据监测点id获取终端id
|
||||
*
|
||||
* @param lineId 监测点id
|
||||
* @return 结果
|
||||
*/
|
||||
String getDevIndex(@Param("lineId")String lineId);
|
||||
String getDevIndex(@Param("lineId") String lineId);
|
||||
|
||||
/**
|
||||
* 获取变电站下母线
|
||||
*
|
||||
* @param subId 变电站id
|
||||
* @return 结果
|
||||
* @author cdf
|
||||
* @date 2022/7/4
|
||||
* @return 结果
|
||||
*/
|
||||
List<Line> getVoltageListBySubId(@Param("subId")String subId,@Param("voltageName")List<String> voltageName);
|
||||
List<Line> getVoltageListBySubId(@Param("subId") String subId, @Param("voltageName") List<String> voltageName);
|
||||
|
||||
/**
|
||||
* 获取生成在线率的装置Id
|
||||
*
|
||||
* @return 装置Id
|
||||
*/
|
||||
List<String> getDeviceList();
|
||||
|
||||
/**
|
||||
* 获取当前状态在线的监测点数量
|
||||
*
|
||||
* @return Integer 在线监测点数量
|
||||
*/
|
||||
Integer getOnLineCount(@Param("lineIds")List<String> lineIds);
|
||||
Integer getOnLineCount(@Param("lineIds") List<String> lineIds);
|
||||
|
||||
/**
|
||||
* 获取当前状态在线和离线的监测点
|
||||
*
|
||||
* @return 在线或离线监测点ids
|
||||
*/
|
||||
List<String> getOnOrUnLine(@Param("list")List<String> lineIds,@Param("comFlag")Integer comFlag);
|
||||
/**
|
||||
* @Description: 获取变电站id和监测点id用
|
||||
* @Param: [devDataType]
|
||||
* @return: java.util.List<com.njcn.device.pq.pojo.po.Line>
|
||||
* @Author: clam
|
||||
* @Date: 2022/10/20
|
||||
*/
|
||||
@Select ("SELECT\n" +
|
||||
List<String> getOnOrUnLine(@Param("list") List<String> lineIds, @Param("comFlag") Integer comFlag);
|
||||
|
||||
/**
|
||||
* @Description: 获取变电站id和监测点id用
|
||||
* @Param: [devDataType]
|
||||
* @return: java.util.List<com.njcn.device.pq.pojo.po.Line>
|
||||
* @Author: clam
|
||||
* @Date: 2022/10/20
|
||||
*/
|
||||
@Select("SELECT\n" +
|
||||
"\tpq_line.Id,\n" +
|
||||
"\tSUBSTRING_INDEX(\n" +
|
||||
"\t\tSUBSTRING_INDEX(pq_line.Pids, ',', 4),\n" +
|
||||
@@ -357,5 +382,30 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
"\tpq_device.Dev_Data_Type = 2\n" +
|
||||
"\tOR pq_device.Dev_Data_Type = #{devDataType}\n" +
|
||||
") ")
|
||||
List<Line> getLineBySubstationRelation(@Param("devDataType")Integer devDataType);
|
||||
List<Line> getLineBySubstationRelation(@Param("devDataType") Integer devDataType);
|
||||
|
||||
|
||||
@Select({"<script>",
|
||||
"SELECT\n" +
|
||||
"\tcount(1)\n",
|
||||
"FROM\n",
|
||||
"\t(\n",
|
||||
"\t\tSELECT\n",
|
||||
"\t\t\ta.pid,\n",
|
||||
"\t\t\tmax(b.com_flag) temp\n",
|
||||
"\t\tFROM\n",
|
||||
"\t\t\tpq_line a\n",
|
||||
"\t\tINNER JOIN pq_device b ON a.id = b.id\n",
|
||||
"where a.Pid in",
|
||||
"<foreach item='item' index='index' collection='items' open='(' separator=',' close=')'>",
|
||||
"#{item}",
|
||||
"</foreach>",
|
||||
"\t\tGROUP BY\n",
|
||||
"\t\t\ta.pid\n",
|
||||
"\t) TEMPTABLE\n",
|
||||
"WHERE\n",
|
||||
"\tTEMPTABLE .temp > 0",
|
||||
"</script>"
|
||||
})
|
||||
Integer queryOnlineSubstaion(@Param("items") List<String> deviceIds);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.device.pq.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pq.pojo.po.PmsAbnormalRules;
|
||||
|
||||
/**
|
||||
* PmsAbnormalRulesMapper
|
||||
*
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
*/
|
||||
public interface PmsAbnormalRulesMapper extends BaseMapper<PmsAbnormalRules> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.device.pq.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pq.pojo.po.RMpIntegrityD;
|
||||
|
||||
/**
|
||||
* RMpIntegrityDMapper
|
||||
*
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
*/
|
||||
public interface RMpIntegrityDMapper extends BaseMapper<RMpIntegrityD> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.device.pq.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.device.pq.pojo.po.RStatAbnormalD;
|
||||
|
||||
/**
|
||||
* RStatAbnormalDMapper
|
||||
*
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
*/
|
||||
public interface RStatAbnormalDMapper extends BaseMapper<RStatAbnormalD> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.device.pq.service;
|
||||
|
||||
import com.njcn.device.pq.pojo.param.AlgorithmSearchParam;
|
||||
|
||||
/**
|
||||
* 数据是否异常
|
||||
*
|
||||
* @author qijian
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/10/26 - 10:09
|
||||
*/
|
||||
public interface DataExceptionService {
|
||||
|
||||
/**
|
||||
* 监测点数据是否异常
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
*/
|
||||
boolean lineDataException(AlgorithmSearchParam algorithmSearchParam);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.device.pq.service;
|
||||
|
||||
import com.njcn.device.pq.pojo.param.AlgorithmSearchParam;
|
||||
|
||||
/**
|
||||
* 数据完整率算法
|
||||
*
|
||||
* @author qijian
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/10/26 - 10:09
|
||||
*/
|
||||
public interface DataIntegrityRateService {
|
||||
|
||||
/**
|
||||
* 监测点日数据完整率
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
*/
|
||||
boolean lineDataIntegrityRate(AlgorithmSearchParam algorithmSearchParam);
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.njcn.device.pq.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.device.pq.service.DataExceptionService;
|
||||
import com.njcn.influxdb.config.InfluxDbConfig;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.param.InfluxDBSqlConstant;
|
||||
import com.njcn.influxdb.param.InfluxDBTableConstant;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.njcn.device.pq.constant.Param;
|
||||
import com.njcn.device.pq.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.pq.mapper.PmsAbnormalRulesMapper;
|
||||
import com.njcn.device.pq.mapper.RStatAbnormalDMapper;
|
||||
import com.njcn.device.pq.pojo.param.AlgorithmSearchParam;
|
||||
import com.njcn.device.pq.pojo.po.DataV;
|
||||
import com.njcn.device.pq.pojo.po.PmsAbnormalRules;
|
||||
import com.njcn.device.pq.pojo.po.RStatAbnormalD;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 数据是否异常
|
||||
*
|
||||
* @author qijian
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/10/26 - 10:09
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DataExceptionServiceImpl implements DataExceptionService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final PmsAbnormalRulesMapper pmsAbnormalRulesMapper;
|
||||
|
||||
private final RStatAbnormalDMapper rStatAbnormalDMapper;
|
||||
|
||||
@Resource
|
||||
private InfluxDbConfig influxDbConfig;
|
||||
|
||||
/**
|
||||
* 监测点数据是否异常
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
*/
|
||||
@Override
|
||||
public boolean lineDataException(AlgorithmSearchParam algorithmSearchParam) {
|
||||
//测试
|
||||
// InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "njcnpqs", "http://192.168.1.18:8086", "pqsbase", "");
|
||||
//初始化
|
||||
InfluxDBResultMapper resultMapper = new InfluxDBResultMapper();
|
||||
String searchSql;
|
||||
String sql;
|
||||
QueryResult query;
|
||||
DataV dataV;
|
||||
Date date = DateUtil.parse(algorithmSearchParam.getDatadate());
|
||||
String lineId = algorithmSearchParam.getId();
|
||||
Integer type = algorithmSearchParam.getType();
|
||||
|
||||
//入库数据初始化
|
||||
RStatAbnormalD rStatAbnormalD = new RStatAbnormalD();
|
||||
rStatAbnormalD.setDataDate(date);
|
||||
rStatAbnormalD.setMeasurementPointId(lineId);
|
||||
rStatAbnormalD.setValueAlarm(0);
|
||||
|
||||
//1、取出规则
|
||||
List<PmsAbnormalRules> pmsAbnormalRules = pmsAbnormalRulesMapper.selectList(null);
|
||||
|
||||
//2、取出电压
|
||||
List<String> lineIds = new ArrayList<>();
|
||||
lineIds.add(lineId);
|
||||
List<LineDetailDataVO> lineDetailList = lineFeignClient.getLineDetailList(lineIds).getData();
|
||||
if (lineDetailList.size() == 0){
|
||||
throw new BusinessException(DeviceResponseEnum.ALGORITHM_LINE_EMPTY);
|
||||
}
|
||||
String scale = lineDetailList.get(0).getScale().replace("kV","");
|
||||
|
||||
//3、根据规则表进行判断
|
||||
//取前四项进行比较(相别为A)
|
||||
searchSql = "MAX(freq) as freq_max,MIN(freq) as freq_min,MAX(rms) as rms_max,MIN(rms) as rms_min,MAX(rms_lvr) as rms_lvr_max,MIN(rms_lvr) as rms_lvr_min,MAX(v_thd) as v_thd_max,MIN(v_thd) as v_thd_min ";
|
||||
sql = getAppend(lineId, date, type, searchSql, "A");
|
||||
query = influxDbUtils.query(sql);
|
||||
dataV = resultMapper.toPOJO(query, DataV.class).get(0);
|
||||
|
||||
//开始判断业务
|
||||
DeviceResponseEnum harmonicResponseEnum = null;
|
||||
for (PmsAbnormalRules pmsAbnormalRule : pmsAbnormalRules) {
|
||||
//每项数据进行上下限比较(MAX和MIN),若有一项不在数据范围内,则为异常
|
||||
switch (pmsAbnormalRule.getTarget()) {
|
||||
case Param.TARGET_FREQ:
|
||||
//频率:正常比较
|
||||
if (dataV.getFrepMIN() < pmsAbnormalRule.getLowerLimit() || dataV.getFrepMAX() > pmsAbnormalRule.getUpperLimit()){
|
||||
harmonicResponseEnum = DeviceResponseEnum.ALGORITHM_FREP_RULE;
|
||||
}
|
||||
break;
|
||||
case Param.TARGET_RMS:
|
||||
//相电压有效值特殊处理:在【0.85p.u.,1.2p.u.】之间;p.u=电压等级/1.732
|
||||
pmsAbnormalRule.setLowerLimit((pmsAbnormalRule.getLowerLimit() * (Double.parseDouble(scale) / 1.732)));
|
||||
pmsAbnormalRule.setUpperLimit((pmsAbnormalRule.getUpperLimit() * (Double.parseDouble(scale) / 1.732)));
|
||||
if (dataV.getRmsMIN() < pmsAbnormalRule.getLowerLimit() || dataV.getRmsMAX() > pmsAbnormalRule.getUpperLimit()){
|
||||
harmonicResponseEnum = DeviceResponseEnum.ALGORITHM_RMS_RULE;
|
||||
}
|
||||
break;
|
||||
case Param.TARGET_RMS_LVR:
|
||||
//线电压有效值特殊处理:在【0.85p.u.,1.2p.u.】之间;p.u=电压等级
|
||||
pmsAbnormalRule.setLowerLimit((pmsAbnormalRule.getLowerLimit() * Double.parseDouble(scale)));
|
||||
pmsAbnormalRule.setUpperLimit((pmsAbnormalRule.getUpperLimit() * Double.parseDouble(scale)));
|
||||
if (dataV.getRmsLvrMIN() < pmsAbnormalRule.getLowerLimit() || dataV.getRmsLvrMAX() > pmsAbnormalRule.getUpperLimit()){
|
||||
harmonicResponseEnum = DeviceResponseEnum.ALGORITHM_RMS_LVR_RULE;
|
||||
}
|
||||
break;
|
||||
case Param.TARGET_V_THD:
|
||||
//电压总谐波畸变率:正常比较
|
||||
if (dataV.getVThdMIN() < pmsAbnormalRule.getLowerLimit() || dataV.getVThdMAX() > pmsAbnormalRule.getUpperLimit()){
|
||||
harmonicResponseEnum = DeviceResponseEnum.ALGORITHM_V_THD_RULE;
|
||||
}
|
||||
break;
|
||||
case Param.TARGET_V_UNBALANCE:
|
||||
//三相不平衡度:正常比较(相别为T)
|
||||
searchSql = "MAX(v_unbalance) as v_unbalance_max,MIN(v_unbalance) as v_unbalance_min ";
|
||||
sql = getAppend(lineId, date,type, searchSql, "T");
|
||||
query = influxDbUtils.query(sql);
|
||||
dataV = resultMapper.toPOJO(query, DataV.class).get(0);
|
||||
if (dataV.getVUnbalanceMIN() < pmsAbnormalRule.getLowerLimit() || dataV.getVUnbalanceMAX() > pmsAbnormalRule.getUpperLimit()){
|
||||
harmonicResponseEnum = DeviceResponseEnum.ALGORITHM_V_UNBALANCE_RULE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (harmonicResponseEnum != null){
|
||||
//入库
|
||||
LambdaQueryWrapper<RStatAbnormalD> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(RStatAbnormalD::getMeasurementPointId, lineId).eq(RStatAbnormalD::getDataDate, date);
|
||||
RStatAbnormalD rStatAbnormalDOne = rStatAbnormalDMapper.selectOne(lambdaQueryWrapper);
|
||||
if (Objects.isNull(rStatAbnormalDOne)){
|
||||
rStatAbnormalDMapper.insert(rStatAbnormalD);
|
||||
}
|
||||
throw new BusinessException(harmonicResponseEnum);
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼装sql
|
||||
* @param id,date,searchSql,tableName 参数
|
||||
* @return 结果
|
||||
*/
|
||||
private String getAppend(String id, Date date, Integer type, String searchSql,String phase) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
//日期处理
|
||||
DateTime startTime = null;
|
||||
DateTime endTime = null;
|
||||
if (Param.YEAR.equals(type)){
|
||||
startTime = DateUtil.beginOfYear(date);
|
||||
endTime = DateUtil.endOfYear(date);
|
||||
}else if(Param.MONTH.equals(type)){
|
||||
startTime = DateUtil.beginOfMonth(date);
|
||||
endTime = DateUtil.endOfMonth(date);
|
||||
}else if(Param.DAY.equals(type)){
|
||||
startTime = DateUtil.beginOfDay(date);
|
||||
endTime = DateUtil.endOfDay(date);
|
||||
}
|
||||
|
||||
//拼接
|
||||
stringBuilder.append(InfluxDBSqlConstant.SELECT).append(searchSql)
|
||||
.append(InfluxDBSqlConstant.FROM).append(InfluxDBPublicParam.DATA_V)
|
||||
.append(InfluxDBSqlConstant.WHERE).append(InfluxDBPublicParam.TIME).append(InfluxDBSqlConstant.GE).append(InfluxDBSqlConstant.QM).append(startTime).append(InfluxDBSqlConstant.QM)
|
||||
.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.TIME).append(InfluxDBSqlConstant.LE).append(InfluxDBSqlConstant.QM).append(endTime).append(InfluxDBSqlConstant.QM)
|
||||
.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.LINE_ID).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(id).append(InfluxDBSqlConstant.QM)
|
||||
.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.VALUE_TYPE).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(InfluxDBTableConstant.AVG).append(InfluxDBSqlConstant.QM);
|
||||
if (InfluxDBTableConstant.PHASE_TYPE_T.equals(phase)){
|
||||
stringBuilder.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.PHASIC_TYPE).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(InfluxDBTableConstant.PHASE_TYPE_T).append(InfluxDBSqlConstant.QM);
|
||||
}else{
|
||||
stringBuilder.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.PHASIC_TYPE).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(InfluxDBTableConstant.PHASE_TYPE_A).append(InfluxDBSqlConstant.QM);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package com.njcn.device.pq.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.mapper.RMpIntegrityDMapper;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.influxdb.config.InfluxDbConfig;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.param.InfluxDBSqlConstant;
|
||||
import com.njcn.influxdb.param.InfluxDBTableConstant;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.njcn.device.pq.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.pq.pojo.param.AlgorithmSearchParam;
|
||||
import com.njcn.device.pq.pojo.po.RMpIntegrityD;
|
||||
import com.njcn.device.pq.service.DataIntegrityRateService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 数据完整率算法
|
||||
*
|
||||
* @author qijian
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/10/26 - 10:09
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DataIntegrityRateServiceImpl implements DataIntegrityRateService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final RMpIntegrityDMapper rMpIntegrityDMapper;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
@Resource
|
||||
private InfluxDbConfig influxDbConfig;
|
||||
|
||||
/**
|
||||
* 监测点日数据完整率
|
||||
* @author qijian
|
||||
* @date 2022/10/26
|
||||
*/
|
||||
@Override
|
||||
public boolean lineDataIntegrityRate(AlgorithmSearchParam algorithmSearchParam) {
|
||||
//测试
|
||||
// InfluxDbUtils influxDBUtil = new InfluxDbUtils("admin", "njcnpqs", "http://192.168.1.18:8086", "pqsbase", "");
|
||||
//初始化
|
||||
String searchSql;
|
||||
String tableName;
|
||||
String sql;
|
||||
QueryResult query;
|
||||
QueryResult.Series series;
|
||||
List<String> columns;
|
||||
List<List<Object>> values;
|
||||
RMpIntegrityD rMpIntegrityD = new RMpIntegrityD();
|
||||
Date date = DateUtil.parse(algorithmSearchParam.getDatadate());
|
||||
|
||||
//1、有效接入分钟数量:根据监测点编号获取统计间隔,1440 / 统计间隔 = 有效接入分钟数量
|
||||
List<String> lineIds = new ArrayList<>();
|
||||
lineIds.add(algorithmSearchParam.getId());
|
||||
List<LineDetailDataVO> lineDetailList = lineFeignClient.getLineDetailList(lineIds).getData();
|
||||
if (lineDetailList.size() == 0){
|
||||
throw new BusinessException(DeviceResponseEnum.ALGORITHM_LINE_EMPTY);
|
||||
}
|
||||
Integer effectiveMinuteCount = 1440 / lineDetailList.get(0).getTimeInterval();
|
||||
rMpIntegrityD.setEffectiveMinuteCount(effectiveMinuteCount);
|
||||
|
||||
//2、根据data_v表获取五项稳态指标日数量(count)
|
||||
searchSql = "count(freq) as freqCount,count(rms) as phaseVoltageCount,count(rms_lvr) as lineVoltageCount,count(v_thd) as vThdCount,count(v_unbalance) as unbalanceCount ";
|
||||
tableName = InfluxDBPublicParam.DATA_V;
|
||||
sql = getAppend(algorithmSearchParam.getId(), date, searchSql, tableName);
|
||||
query = influxDbUtils.query(sql);
|
||||
series = getSeries(query);
|
||||
|
||||
if (Objects.nonNull(series.getColumns())){
|
||||
columns = series.getColumns();
|
||||
values = series.getValues();
|
||||
for (List<Object> columnValue : values) {
|
||||
for (int i = 0; i < columnValue.size(); i++) {
|
||||
if (columns.get(i).equals("freqCount")) {
|
||||
rMpIntegrityD.setFreqCount(Integer.parseInt(convertDoubleToString(columnValue.get(i))));
|
||||
}else if (columns.get(i).equals("phaseVoltageCount")) {
|
||||
rMpIntegrityD.setPhaseVoltageCount(Integer.parseInt(convertDoubleToString(columnValue.get(i))));
|
||||
}else if (columns.get(i).equals("lineVoltageCount")) {
|
||||
rMpIntegrityD.setLineVoltageCount(Integer.parseInt(convertDoubleToString(columnValue.get(i))));
|
||||
}else if (columns.get(i).equals("vThdCount")) {
|
||||
rMpIntegrityD.setVThdCount(Integer.parseInt(convertDoubleToString(columnValue.get(i))));
|
||||
}else if (columns.get(i).equals("unbalanceCount")) {
|
||||
rMpIntegrityD.setUnbalanceCount(Integer.parseInt(convertDoubleToString(columnValue.get(i))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//3、根据day_flicker表获取两项闪变指标数量(count)
|
||||
searchSql = "count(pst) as pstCount,count(plt) as pltCount ";
|
||||
tableName = InfluxDBPublicParam.DATA_FLICKER;
|
||||
sql = getAppend(algorithmSearchParam.getId(), date, searchSql, tableName);
|
||||
query = influxDbUtils.query(sql);
|
||||
series = getSeries(query);
|
||||
|
||||
if (Objects.nonNull(series.getColumns())){
|
||||
columns = series.getColumns();
|
||||
values = series.getValues();
|
||||
for (List<Object> columnValue : values) {
|
||||
for (int i = 0; i < columnValue.size(); i++) {
|
||||
if (columns.get(i).equals("pstCount")) {
|
||||
rMpIntegrityD.setPstCount(Integer.parseInt(convertDoubleToString(columnValue.get(i))));
|
||||
}else if (columns.get(i).equals("pltCount")) {
|
||||
rMpIntegrityD.setPltCount(Integer.parseInt(convertDoubleToString(columnValue.get(i))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//4、存库
|
||||
LambdaQueryWrapper<RMpIntegrityD> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(RMpIntegrityD::getMeasurementPointId, algorithmSearchParam.getId()).eq(RMpIntegrityD::getDataDate, date);
|
||||
RMpIntegrityD rMpIntegrityDOne = rMpIntegrityDMapper.selectOne(lambdaQueryWrapper);
|
||||
if (Objects.nonNull(rMpIntegrityDOne)){
|
||||
rMpIntegrityDMapper.update(rMpIntegrityD,lambdaQueryWrapper);
|
||||
}else{
|
||||
rMpIntegrityD.setMeasurementPointId(algorithmSearchParam.getId());
|
||||
rMpIntegrityD.setDataDate(date);
|
||||
rMpIntegrityDMapper.insert(rMpIntegrityD);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Double转String
|
||||
* @param val 参数
|
||||
* @return 结果
|
||||
*/
|
||||
private String convertDoubleToString(Object val) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
|
||||
return decimalFormat.format(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取series
|
||||
* @param query 参数
|
||||
* @return 结果
|
||||
*/
|
||||
private QueryResult.Series getSeries(QueryResult query) {
|
||||
QueryResult.Series series = new QueryResult.Series();
|
||||
List<QueryResult.Result> results = query.getResults();
|
||||
if (results.size() != 0) {
|
||||
QueryResult.Result result = results.get(0);
|
||||
if (result.getSeries() != null){
|
||||
List<QueryResult.Series> seriess = result.getSeries();
|
||||
if (seriess.size() != 0) {
|
||||
series = seriess.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return series;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼装sql
|
||||
* @param id,date,searchSql,tableName 参数
|
||||
* @return 结果
|
||||
*/
|
||||
private String getAppend(String id, Date date, String searchSql,String tableName) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(InfluxDBSqlConstant.SELECT).append(searchSql)
|
||||
.append(InfluxDBSqlConstant.FROM).append(tableName)
|
||||
.append(InfluxDBSqlConstant.WHERE).append(InfluxDBPublicParam.TIME).append(InfluxDBSqlConstant.GE).append(InfluxDBSqlConstant.QM).append(DateUtil.beginOfDay(date)).append(InfluxDBSqlConstant.QM)
|
||||
.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.TIME).append(InfluxDBSqlConstant.LE).append(InfluxDBSqlConstant.QM).append(DateUtil.endOfDay(date)).append(InfluxDBSqlConstant.QM)
|
||||
.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.LINE_ID).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(id).append(InfluxDBSqlConstant.QM)
|
||||
.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.PHASIC_TYPE).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(InfluxDBTableConstant.PHASE_TYPE_A).append(InfluxDBSqlConstant.QM);
|
||||
if (InfluxDBPublicParam.DATA_V.equals(tableName)){
|
||||
stringBuilder.append(InfluxDBSqlConstant.AND).append(InfluxDBPublicParam.VALUE_TYPE).append(InfluxDBSqlConstant.EQ).append(InfluxDBSqlConstant.QM).append(InfluxDBTableConstant.AVG).append(InfluxDBSqlConstant.QM);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,9 @@ import com.njcn.device.pq.pojo.param.DeviceInfoParam;
|
||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import com.njcn.device.pq.pojo.po.Device;
|
||||
import com.njcn.device.pq.pojo.po.Line;
|
||||
import com.njcn.device.pq.pojo.po.Substation;
|
||||
import com.njcn.device.pq.pojo.vo.DeptDeviceDetailVO;
|
||||
import com.njcn.device.pq.pojo.vo.DeptSubstationDetailVO;
|
||||
import com.njcn.device.pq.pojo.vo.ExceptionDeviceInfoVO;
|
||||
import com.njcn.device.pq.service.DeptLineService;
|
||||
import com.njcn.device.pq.service.TerminalBaseService;
|
||||
@@ -32,6 +35,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -61,7 +65,7 @@ public class GeneralDeviceService {
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
|
||||
|
||||
@@ -627,4 +631,52 @@ public class GeneralDeviceService {
|
||||
|
||||
return exceptionDeviceInfoVOS;
|
||||
}
|
||||
/**
|
||||
* @Description: getDeptDeviceDetail
|
||||
* @Param: [deviceInfoParam]
|
||||
* @return: com.njcn.device.pq.pojo.vo.DeptDeviceDetailVO
|
||||
* @Author: clam
|
||||
* @Date: 2022/11/4
|
||||
*/
|
||||
public DeptDeviceDetailVO getDeptDeviceDetail(DeviceInfoParam deviceInfoParam) {
|
||||
|
||||
|
||||
DeptDeviceDetailVO deptDeviceDetailVO =new DeptDeviceDetailVO();
|
||||
/*总数*/
|
||||
List<GeneralDeviceDTO> deptDeviceInfos = this.getDeviceInfoAsDept(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
|
||||
List<String> DeviceIds = deptDeviceInfos.stream ( ).map (GeneralDeviceDTO::getDeviceIndexes).flatMap (Collection::stream).collect (Collectors.toList ( ));
|
||||
Integer deviceCount = DeviceIds.size ();
|
||||
|
||||
/*实际运行*/
|
||||
QueryWrapper<Device> query = new QueryWrapper<> ();
|
||||
query.in ("Id",DeviceIds).
|
||||
eq ("Com_Flag",1);
|
||||
Integer runDeviceCount = deviceMapper.selectCount (query);
|
||||
BigDecimal rate = BigDecimal.valueOf (runDeviceCount).divide ( BigDecimal.valueOf (deviceCount),2,BigDecimal.ROUND_HALF_UP);
|
||||
deptDeviceDetailVO.setDeviceCount (deviceCount);
|
||||
deptDeviceDetailVO.setRunDeviceCount (runDeviceCount);
|
||||
deptDeviceDetailVO.setOnLineRate (rate);
|
||||
return deptDeviceDetailVO;
|
||||
|
||||
}
|
||||
|
||||
public DeptSubstationDetailVO getDeptSubstationDetail(DeviceInfoParam deviceInfoParam) {
|
||||
|
||||
DeptSubstationDetailVO deptSubstationDetailVO = new DeptSubstationDetailVO ();
|
||||
|
||||
List<GeneralDeviceDTO> deptDeviceInfos = this.getDeviceInfoAsDept(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
|
||||
|
||||
List<String> DeviceIds = deptDeviceInfos.stream ( ).map (GeneralDeviceDTO::getSubIndexes).flatMap (Collection::stream).collect (Collectors.toList ( ));
|
||||
Integer substationCount = DeviceIds.size ();
|
||||
|
||||
Integer count =lineMapper.queryOnlineSubstaion(DeviceIds);
|
||||
deptSubstationDetailVO.setSubstationCount (substationCount);
|
||||
deptSubstationDetailVO.setRunsubstationCount (count);
|
||||
BigDecimal rate = BigDecimal.valueOf (count).divide ( BigDecimal.valueOf (substationCount),2,BigDecimal.ROUND_HALF_UP);
|
||||
deptSubstationDetailVO.setOnLineRate (rate);
|
||||
|
||||
return deptSubstationDetailVO;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,13 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
|
||||
List<TerminalTree> subList = treeMapper.getSubList(generalDeviceDTO.getSubIndexes());
|
||||
// 通过监测点索引查询监测点信息
|
||||
List<TerminalTree> lineList = treeMapper.getLineList(generalDeviceDTO.getLineIndexes());
|
||||
|
||||
//处理变电站
|
||||
dealChildrenData(subList, lineList, true);
|
||||
|
||||
//监测点前面加序号,后面不需要删除下面两行就行
|
||||
//Integer[] arr = {1};
|
||||
//subList.forEach(item->item.getChildren().forEach(it->it.setName((arr[0]++ +"_"+it.getName()))));
|
||||
//处理供电公司
|
||||
dealChildrenData(gdList, subList, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user