监测点报告抽取公共方法

This commit is contained in:
cdf
2026-01-17 13:40:29 +08:00
parent 4497699178
commit 51a16c5701
40 changed files with 3585 additions and 5233 deletions

View File

@@ -8,13 +8,13 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csharmonic.param.SensitiveUserReportQueryParam;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.param.ReportTemplateParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.csharmonic.pojo.vo.ReportTreeVO;
import com.njcn.csharmonic.pojo.vo.SysDeptTempVO;
import com.njcn.csharmonic.service.CustomReportService;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;

View File

@@ -1,36 +0,0 @@
package com.njcn.csharmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.web.pojo.param.BaseParam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* pqs
*
* @author cdf
* @date 2022/8/16
*/
public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
Page<ReportTemplateVO> getReportTemplateListPage(Page<BaseParam> page, @Param("baseParam")BaseParam baseParam);
List<ReportTemplateVO> getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam);
List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
@Select("${sqlStr}")
StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql);
@Select("${sqlStr}")
Map<String, Float> dynamicSqlMap(@Param("sqlStr")String sql);
}

View File

@@ -1,58 +0,0 @@
<?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.csharmonic.mapper.ExcelRptTempMapper">
<select id="getReportTemplateListPage" resultType="com.njcn.csharmonic.pojo.vo.ReportTemplateVO">
select
a.id,
a.name,
a.dept_id,
b.name deptName,
a.activation,
a.update_time,
c.name updateBy
from sys_excel_rpt_temp a
left join sys_dept b on a.dept_id = b.id
left join sys_user c on a.update_by = c.id
where a.state = 1
<if test="baseParam.searchValue!=null and baseParam.searchValue!=''">
and (
a.name like CONCAT('%', #{baseParam.searchValue},'%') or
b.name like CONCAT('%', #{baseParam.searchValue},'%')
)
</if>
</select>
<select id="getReportTemplateList" resultType="com.njcn.csharmonic.pojo.vo.ReportTemplateVO">
SELECT
a.id,
a.NAME,
a.update_time,
a.create_time,
a.update_by,
a.Activation,
a.Report_Type,
a.Report_Form
FROM
sys_excel_rpt_temp a
WHERE
a.state = 1
order by a.create_time desc
</select>
<select id="getReportTemplateByDept" resultType="com.njcn.csharmonic.pojo.vo.ReportTemplateVO">
SELECT
DISTINCT
a.id,
a.NAME,
a.activation,
a.report_form,
a.sort
FROM
sys_excel_rpt_temp a
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
WHERE
a.activation = 1
order by a.sort asc
</select>
</mapper>

View File

@@ -0,0 +1,36 @@
//package com.njcn.csharmonic.mapper.report;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.njcn.csharmonic.pojo.param.ReportSearchParam;
//import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
//import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
//import com.njcn.influx.pojo.dto.StatisticalDataDTO;
//import com.njcn.web.pojo.param.BaseParam;
//import org.apache.ibatis.annotations.Param;
//import org.apache.ibatis.annotations.Select;
//
//import java.util.List;
//import java.util.Map;
//
///**
// * pqs
// *
// * @author cdf
// * @date 2022/8/16
// */
//public interface ExcelRptTempMapper extends BaseMapper<ExcelRptTemp> {
//
// Page<ReportTemplateVO> getReportTemplateListPage(Page<BaseParam> page, @Param("baseParam")BaseParam baseParam);
//
// List<ReportTemplateVO> getReportTemplateList(@Param("reportSearchParam")ReportSearchParam reportSearchParam);
//
// List<ReportTemplateVO> getReportTemplateByDept(@Param("ids") List<String> ids);
//
//
// @Select("${sqlStr}")
// StatisticalDataDTO dynamicSql(@Param("sqlStr")String sql);
//
// @Select("${sqlStr}")
// Map<String, Float> dynamicSqlMap(@Param("sqlStr")String sql);
//}

View File

@@ -1,16 +1,16 @@
package com.njcn.csharmonic.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-04-17
*/
public interface RStatDataHarmRateVDMapper extends BaseMapper<RStatDataHarmrateVDPO> {
}
//package com.njcn.csharmonic.mapper.report;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO;
//
///**
// * <p>
// * Mapper 接口
// * </p>
// *
// * @author wr
// * @since 2023-04-17
// */
//public interface RStatDataHarmRateVDMapper extends BaseMapper<RStatDataHarmrateVDPO> {
//
//}

View File

@@ -1,29 +1,29 @@
package com.njcn.csharmonic.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-04-17
*/
public interface RStatDataIDMapper extends BaseMapper<RStatDataIDPO> {
/**
* 获取监测点负序电流
* @return
*/
List<RStatDataIDPO> getINeg(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* 谐波电流
*/
List<RStatDataIDPO> getI(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
}
//package com.njcn.csharmonic.mapper.report;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO;
//import org.apache.ibatis.annotations.Param;
//
//import java.util.List;
//
///**
// * <p>
// * Mapper 接口
// * </p>
// *
// * @author wr
// * @since 2023-04-17
// */
//public interface RStatDataIDMapper extends BaseMapper<RStatDataIDPO> {
//
// /**
// * 获取监测点负序电流
// * @return
// */
// List<RStatDataIDPO> getINeg(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
// /**
// * 谐波电流
// */
// List<RStatDataIDPO> getI(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//}

View File

@@ -1,17 +1,17 @@
package com.njcn.csharmonic.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description:
* @Author: wr
* @Date: 2024/7/31 9:24
*/
public interface RStatDataInharmVDMapper extends BaseMapper<RStatDataInharmVDPO> {
//List<RStatDataInharmVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
}
//package com.njcn.csharmonic.mapper.report;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO;
//import org.apache.ibatis.annotations.Param;
//
//import java.util.List;
//
///**
// * @Description:
// * @Author: wr
// * @Date: 2024/7/31 9:24
// */
//public interface RStatDataInharmVDMapper extends BaseMapper<RStatDataInharmVDPO> {
//
// //List<RStatDataInharmVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//}

View File

@@ -1,43 +1,43 @@
package com.njcn.csharmonic.mapper.report;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author wr
* @since 2023-03-31
*/
public interface RStatDataVDPOMapper extends BaseMapper<RStatDataVDPO> {
/**
* 获取频率偏差、三相电压不平衡度
*/
List<RStatDataVDPO> getFreqDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* 获取电压偏差
*/
List<RStatDataVDPO> getVuDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* 获取电压总谐波畸变率
*/
List<RStatDataVDPO> getVthd(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* 获取三相电压不平衡度
*/
List<RStatDataVDPO> getUnbalance(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
/**
* 获取谐波电压
*/
List<RStatDataVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
}
//package com.njcn.csharmonic.mapper.report;
//
//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
//import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO;
//import org.apache.ibatis.annotations.Param;
//
//import java.util.List;
//
///**
// * <p>
// * Mapper 接口
// * </p>
// *
// * @author wr
// * @since 2023-03-31
// */
//public interface RStatDataVDPOMapper extends BaseMapper<RStatDataVDPO> {
//
// /**
// * 获取频率偏差、三相电压不平衡度
// */
// List<RStatDataVDPO> getFreqDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
// /**
// * 获取电压偏差
// */
// List<RStatDataVDPO> getVuDev(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
// /**
// * 获取电压总谐波畸变率
// */
// List<RStatDataVDPO> getVthd(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
// /**
// * 获取三相电压不平衡度
// */
// List<RStatDataVDPO> getUnbalance(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//
// /**
// * 获取谐波电压
// */
// List<RStatDataVDPO> getV(@Param("list") List<String> lineList, @Param("startTime") String startTime, @Param("endTime") String endTime);
//}

View File

@@ -1,138 +1,138 @@
package com.njcn.csharmonic.mapper.report;
import com.njcn.csharmonic.pojo.param.report.ReportQueryParam;
import com.njcn.csharmonic.pojo.vo.report.ReportValue;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 谐波报告查询
*/
public interface ReportMapper {
/**
* 获取电流有效值
* @return
*/
List<ReportValue> getVirtualDataI(@Param("param") ReportQueryParam param);
/**
* 获取电压有效值
* @return
*/
List<ReportValue> getVirtualDataV(@Param("param") ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalCP95Day(@Param("param")ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param);
List<ReportValue> getVVirtualData(@Param("param")ReportQueryParam param);
/**
* 获取有功功率
* @param param
* @return
*/
List<ReportValue> getPowerP(@Param("param")ReportQueryParam param);
/**
* 无功功率
* @param param
* @return
*/
List<ReportValue> getPowerQ(@Param("param")ReportQueryParam param);
/**
* 视在功率
* @param param
* @return
*/
List<ReportValue> getPowerS(@Param("param")ReportQueryParam param);
/**
* 功率因数
* @param param
* @return
*/
List<ReportValue> getPF(@Param("param")ReportQueryParam param);
/**
* 短时闪变
* @param param
* @return
*/
List<ReportValue> getFlickerData(@Param("param")ReportQueryParam param);
/**
* 长时闪变
* @param param
* @return
*/
List<ReportValue> getLFlickerData(@Param("param")ReportQueryParam param);
/**
* 电压负偏差
* @param param
* @return
*/
List<ReportValue> getUVdeviationData(@Param("param")ReportQueryParam param);
/**
* 电压正偏差
* @param param
* @return
*/
List<ReportValue> getLVdeviationData(@Param("param")ReportQueryParam param);
/**
* 获取电压畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionDataV(@Param("param")ReportQueryParam param);
/**
* 获取电流畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionDataI(@Param("param")ReportQueryParam param);
/**
*频率
* @param param
* @return
*/
List<ReportValue> getFrequencyData(@Param("param")ReportQueryParam param);
/**
*频率
* @param param
* @return
*/
List<ReportValue> getDEVFrequencyData(@Param("param")ReportQueryParam param);
/**
* 负序电流
* @param param
* @return
*/
List<ReportValue> getINegData(@Param("param")ReportQueryParam param);
}
//package com.njcn.csharmonic.mapper.report;
//
//
//import com.njcn.csharmonic.pojo.param.report.ReportQueryParam;
//import com.njcn.csharmonic.pojo.vo.report.ReportValue;
//import org.apache.ibatis.annotations.Param;
//
//import java.util.List;
//
///**
// * 谐波报告查询
// */
//public interface ReportMapper {
// /**
// * 获取电流有效值
// * @return
// */
// List<ReportValue> getVirtualDataI(@Param("param") ReportQueryParam param);
//
// /**
// * 获取电压有效值
// * @return
// */
// List<ReportValue> getVirtualDataV(@Param("param") ReportQueryParam param);
//
// /**
// * CP95条数
// * @param param
// * @return
// */
// Integer getTotalCP95Day(@Param("param")ReportQueryParam param);
// /**
// * CP95条数
// * @param param
// * @return
// */
// Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param);
// /**
// * CP95条数
// * @param param
// * @return
// */
// Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param);
//
//
// List<ReportValue> getVVirtualData(@Param("param")ReportQueryParam param);
//
// /**
// * 获取有功功率
// * @param param
// * @return
// */
// List<ReportValue> getPowerP(@Param("param")ReportQueryParam param);
//
// /**
// * 无功功率
// * @param param
// * @return
// */
// List<ReportValue> getPowerQ(@Param("param")ReportQueryParam param);
//
// /**
// * 视在功率
// * @param param
// * @return
// */
// List<ReportValue> getPowerS(@Param("param")ReportQueryParam param);
//
// /**
// * 功率因数
// * @param param
// * @return
// */
// List<ReportValue> getPF(@Param("param")ReportQueryParam param);
//
// /**
// * 短时闪变
// * @param param
// * @return
// */
// List<ReportValue> getFlickerData(@Param("param")ReportQueryParam param);
//
// /**
// * 长时闪变
// * @param param
// * @return
// */
// List<ReportValue> getLFlickerData(@Param("param")ReportQueryParam param);
//
// /**
// * 电压负偏差
// * @param param
// * @return
// */
// List<ReportValue> getUVdeviationData(@Param("param")ReportQueryParam param);
//
// /**
// * 电压正偏差
// * @param param
// * @return
// */
// List<ReportValue> getLVdeviationData(@Param("param")ReportQueryParam param);
//
// /**
// * 获取电压畸变率
// * @param param
// * @return
// */
// List<ReportValue> getDistortionDataV(@Param("param")ReportQueryParam param);
//
// /**
// * 获取电流畸变率
// * @param param
// * @return
// */
// List<ReportValue> getDistortionDataI(@Param("param")ReportQueryParam param);
//
// /**
// *频率
// * @param param
// * @return
// */
// List<ReportValue> getFrequencyData(@Param("param")ReportQueryParam param);
//
// /**
// *频率
// * @param param
// * @return
// */
// List<ReportValue> getDEVFrequencyData(@Param("param")ReportQueryParam param);
//
// /**
// * 负序电流
// * @param param
// * @return
// */
// List<ReportValue> getINegData(@Param("param")ReportQueryParam param);
//}

View File

@@ -1,12 +1,12 @@
package com.njcn.csharmonic.service;
import com.njcn.csharmonic.param.SensitiveUserReportQueryParam;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.param.ReportTemplateParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.csharmonic.pojo.vo.ReportTreeVO;
import com.njcn.csharmonic.pojo.vo.SysDeptTempVO;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

View File

@@ -15,6 +15,7 @@ import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.FileUtil;
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
@@ -23,20 +24,20 @@ import com.njcn.csdevice.api.WlRecordFeignClient;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.csharmonic.enums.CsHarmonicResponseEnum;
import com.njcn.csharmonic.mapper.ExcelRptTempMapper;
import com.njcn.csharmonic.param.SensitiveUserReportQueryParam;
import com.njcn.csharmonic.pojo.dto.ReportTemplateDTO;
import com.njcn.csharmonic.pojo.param.ReportSearchParam;
import com.njcn.csharmonic.pojo.param.ReportTemplateParam;
import com.njcn.csharmonic.pojo.po.ExcelRptTemp;
import com.njcn.csharmonic.pojo.vo.ReportTemplateDataVO;
import com.njcn.csharmonic.pojo.vo.ReportTemplateVO;
import com.njcn.csharmonic.pojo.vo.ReportTreeVO;
import com.njcn.csharmonic.pojo.vo.SysDeptTempVO;
import com.njcn.csharmonic.service.CustomReportService;
import com.njcn.csharmonic.utils.DataChangeUtil;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.influx.constant.InfluxDbSqlConstant;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.influx.utils.InfluxDbUtils;
@@ -118,6 +119,9 @@ public class CustomReportServiceImpl implements CustomReportService {
private final String STR_FIVE = "~";
private final String limitTable = "pq_overlimit";
private final String UVOLTAGE_DEV = "UVOLTAGE_DEV";
private final String VOLTAGE_DEV = "VOLTAGE_DEV";
private final String GRID_SIDE_DICT_CODE = "Grid_Side";
private final String LOAD_SIDE_DICT_CODE = "Load_Side";
@@ -839,7 +843,7 @@ public class CustomReportServiceImpl implements CustomReportService {
* @date 2023/10/20
*/
private void assSqlByMysql(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap) {
private void assSqlByMysql(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
//sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
if (InfluxDbSqlConstant.CP95.equals(method)) {
for (int i = 0; i < data.size(); i++) {
@@ -849,14 +853,14 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"");
.append("\""+data.get(i).getItemName()+"\"");
} else {
sql.append(InfluxDbSqlConstant.MAX)
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
}
}
} else {
@@ -867,14 +871,14 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"");
.append("\""+data.get(i).getItemName()+"\"");
} else {
sql.append(method)
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
}
}
@@ -911,7 +915,10 @@ public class CustomReportServiceImpl implements CustomReportService {
//频率和频率偏差仅统计T相
if (data.get(0).getTemplateName().equals("freq_dev") || data.get(0).getTemplateName().equals("freq")) {
if (noPhaseList.contains(data.get(0).getTemplateName())) {
if(data.get(0).getTemplateName().equalsIgnoreCase("v_unbalance")){
System.out.println(44);
}
sql.append(InfluxDbSqlConstant.AND)
.append(InfluxDBTableConstant.PHASIC_TYPE)
.append(InfluxDbSqlConstant.EQ)
@@ -931,6 +938,7 @@ public class CustomReportServiceImpl implements CustomReportService {
if (CollUtil.isEmpty(mapList) || Objects.isNull(mapList.get(0))) {
data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList());
} else {
//兼容达梦数据库方法
Map<String, Object> map = convertKeysToUpperCase(mapList.get(0));
for (ReportTemplateDTO item : data) {
if (map.containsKey(item.getItemName())) {
@@ -938,10 +946,22 @@ public class CustomReportServiceImpl implements CustomReportService {
item.setValue(String.format("%.3f", v));
if (overLimitMap.containsKey(item.getLimitName())) {
Float tagVal = overLimitMap.get(item.getLimitName());
if (v > tagVal) {
item.setOverLimitFlag(1);
} else {
item.setOverLimitFlag(0);
if(item.getLimitName().equalsIgnoreCase(UVOLTAGE_DEV)){
//对电压偏差特殊处理
Float tagVal_U = overLimitMap.get(UVOLTAGE_DEV);
if (v > tagVal || v<tagVal_U) {
item.setOverLimitFlag(1);
} else {
item.setOverLimitFlag(0);
}
}else {
if (v > tagVal) {
item.setOverLimitFlag(1);
} else {
item.setOverLimitFlag(0);
}
}
}
@@ -951,12 +971,27 @@ public class CustomReportServiceImpl implements CustomReportService {
if (limitMap.containsKey(key)) {
ReportTemplateDTO tem = limitMap.get(key);
double limitVal = Double.parseDouble(tem.getValue());
if (v > limitVal) {
tem.setOverLimitFlag(1);
assNoPassMap.put(key, tem);
} else if (!assNoPassMap.containsKey(key)) {
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem);
if(VOLTAGE_DEV.equalsIgnoreCase(tem.getLimitName())){
//针对电压偏差特殊处理
double limitLowVal = Double.parseDouble(tem.getLowValue());
if (v > limitVal || v<limitLowVal) {
tem.setOverLimitFlag(1);
assNoPassMap.put(key, tem);
} else if (!assNoPassMap.containsKey(key)) {
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem);
}
}else {
//其他指标
if (v > limitVal) {
tem.setOverLimitFlag(1);
assNoPassMap.put(key, tem);
} else if (!assNoPassMap.containsKey(key)) {
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem);
}
}
}
}
@@ -967,7 +1002,6 @@ public class CustomReportServiceImpl implements CustomReportService {
}
endList.addAll(data);
}
private void assSqlByMysqlNew(List<ReportTemplateDataVO> data, StringBuilder sql, List<ReportTemplateDataVO> finalDataList, String method, SensitiveUserReportQueryParam queryParam, String lineId) {
//sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
if (InfluxDbSqlConstant.CP95.equals(method)) {
@@ -1113,9 +1147,23 @@ public class CustomReportServiceImpl implements CustomReportService {
throw new BusinessException(CsHarmonicResponseEnum.CUSTOM_REPORT_JSON);
}
}
//查询不分相别的指标
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
if(Objects.isNull(dictData)){
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
}
//List<EleEpdPqd> temTargetList = eleEpdMapper.selectList(new LambdaQueryWrapper<EleEpdPqd>().eq(EleEpdPqd::getDataType,dictData.getId()).in(EleEpdPqd::getPhase,Arrays.asList("T", "M")));
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
//处理指标是否合格
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam.getLineId());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
//存放限值指标的map
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
@@ -1141,13 +1189,13 @@ public class CustomReportServiceImpl implements CustomReportService {
phaseMap.forEach((phaseKey, phaseVal) -> {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
}
});
@@ -1300,7 +1348,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) {
//$HA[_25]#max#classId$
reportTemplateDTO.setTemplateName(vItem[0].toUpperCase());
reportTemplateDTO.setPhase("M");
reportTemplateDTO.setPhase("T");
reportTemplateDTO.setStatMethod(vItem[1].toUpperCase());
reportTemplateDTO.setResourceId(vItem[2].toUpperCase());
reportTemplateDTO.setLimitName(vItem[3].toUpperCase());
@@ -1373,7 +1421,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) {
//$HA[_25]#max#classId#no$
indexDataVO.setTemplateName(vItem[0].toUpperCase());
indexDataVO.setPhase("M");
indexDataVO.setPhase("T");
indexDataVO.setStatMethod(vItem[1].toUpperCase());
indexDataVO.setResourceId(vItem[2].toUpperCase());
}
@@ -1417,7 +1465,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) {
//$HA[_25]#max#classId#no$
indexDataVO.setTemplateName(vItem[0].toUpperCase());
indexDataVO.setPhase("M");
indexDataVO.setPhase("T");
indexDataVO.setStatMethod(vItem[1].toUpperCase());
indexDataVO.setResourceId(vItem[2].toUpperCase());
}
@@ -1440,18 +1488,21 @@ public class CustomReportServiceImpl implements CustomReportService {
* @author cdf
* @date 2023/10/23
*/
private Map<String, Float> overLimitDeal(List<ReportTemplateDTO> reportLimitList, String lineId) {
private Map<String, Float> overLimitDeal(List<ReportTemplateDTO> reportLimitList, ReportSearchParam
reportSearchParam) {
Map<String, Float> limitMap = new HashMap<>();
if (CollUtil.isNotEmpty(reportLimitList)) {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
for (int i = 0; i < reportLimitList.size(); i++) {
if (i == reportLimitList.size() - 1) {
sql.append(UVOLTAGE_DEV).append(StrUtil.COMMA);
sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.C_SPACE);
} else {
sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.COMMA);
}
}
sql.append(InfluxDbSqlConstant.FROM).append(reportLimitList.get(0).getResourceId()).append(InfluxDbSqlConstant.WHERE).append("id ='").append(lineId).append("'");
sql.append(InfluxDbSqlConstant.FROM).append(reportLimitList.get(0).getResourceId()).append(InfluxDbSqlConstant.WHERE).append("id ='").append(reportSearchParam.getLineId()).append("'");
limitMap = excelRptTempMapper.dynamicSqlMap(sql.toString());
if (Objects.isNull(limitMap)) {
throw new BusinessException("当前报表测点限值缺失!");
@@ -1459,6 +1510,10 @@ public class CustomReportServiceImpl implements CustomReportService {
for (ReportTemplateDTO item : reportLimitList) {
if (limitMap.containsKey(item.getTemplateName())) {
if(item.getTemplateName().equalsIgnoreCase(VOLTAGE_DEV)){
item.setLowValue(limitMap.get(UVOLTAGE_DEV).toString());
}
item.setValue(limitMap.get(item.getTemplateName()).toString());
}
}
@@ -1515,7 +1570,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.sorted(Comparator.comparing(ReportTemplateDTO::getItemName))
.collect(Collectors.toList());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam.getLineId());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
//存放限值指标的map
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
@@ -1903,13 +1958,18 @@ public class CustomReportServiceImpl implements CustomReportService {
(Map<String, ReportTemplateDTO> assNoPassMap, Map<String, ReportTemplateDTO> limitTargetMapX, List<ReportTemplateDTO> endList) {
assNoPassMap.forEach((key, val) -> {
limitTargetMapX.remove(key);
if ("Voltage_Dev".toUpperCase().equals(val.getTemplateName()) || "Freq_Dev".toUpperCase().equals(val.getTemplateName())) {
if ("Freq_Dev".toUpperCase().equals(val.getTemplateName())) {
val.setValue("±" + val.getValue());
}
String expend = "";
if(Objects.nonNull(val.getLowValue())){
expend = val.getLowValue()+",";
}
if (val.getOverLimitFlag() == 1) {
val.setValue("不合格 (" + val.getValue() + ")");
val.setValue("不合格 (" + expend+val.getValue() + ")");
} else {
val.setValue("合格 (" + val.getValue() + ")");
val.setValue("合格 (" + expend+val.getValue() + ")");
}
endList.add(val);
});
@@ -1924,6 +1984,7 @@ public class CustomReportServiceImpl implements CustomReportService {
});
}
/**
* 解析模板
*
@@ -1964,7 +2025,7 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (vItem.length == 4) {
//$HA[_25]#max#classId$
reportTemplateDTO.setTemplateName(vItem[0]);
reportTemplateDTO.setPhase("M");
reportTemplateDTO.setPhase("T");
reportTemplateDTO.setStatMethod(vItem[1]);
reportTemplateDTO.setResourceId(vItem[2]);
reportTemplateDTO.setLimitName(vItem[3]);

View File

@@ -14,7 +14,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.CsOverLimitClient;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.Overlimit;
import com.njcn.csharmonic.mapper.RStatLimitRateDetailDMapper;
import com.njcn.csharmonic.pojo.param.LimitCalendarQueryParam;
import com.njcn.csharmonic.pojo.param.LimitExtentDayQueryParam;
@@ -26,6 +25,7 @@ import com.njcn.csharmonic.pojo.vo.LimitExtentVO;
import com.njcn.csharmonic.pojo.vo.LimitProbabilityVO;
import com.njcn.csharmonic.pojo.vo.LimitTimeProbabilityVO;
import com.njcn.csharmonic.service.IRStatLimitRateDetailDService;
import com.njcn.device.biz.pojo.po.Overlimit;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

View File

@@ -1,45 +1,45 @@
package com.njcn.csharmonic.util;
import com.njcn.csharmonic.pojo.vo.report.ReportValue;
import java.util.List;
public class RegroupData {
public static void regroupData(List<ReportValue> list, boolean... b) {
if (1 == b.length || (2 == b.length && b[1] == false)) {
if (0 < list.size()) {
return;
}
}
Float value = null;
int length = b[0] ? 3 : 1;
length = (b.length == 2 && !b[1]) ? 4 : length;
for (int i = 0; i < length; i++) {
String str = null;
if (b[0]) {
switch (i) {
case 0:
str = "A";
break;
case 1:
str = "B";
break;
case 2:
str = "C";
break;
case 3:
str = "T";
break;
}
}
ReportValue reportValue = new ReportValue(str, value, value, value, value);
list.add(reportValue);
}
}
}
//package com.njcn.csharmonic.util;
//
//
//import com.njcn.csharmonic.pojo.vo.report.ReportValue;
//
//import java.util.List;
//
//public class RegroupData {
// public static void regroupData(List<ReportValue> list, boolean... b) {
// if (1 == b.length || (2 == b.length && b[1] == false)) {
// if (0 < list.size()) {
// return;
// }
// }
//
// Float value = null;
// int length = b[0] ? 3 : 1;
//
// length = (b.length == 2 && !b[1]) ? 4 : length;
//
// for (int i = 0; i < length; i++) {
// String str = null;
//
// if (b[0]) {
// switch (i) {
// case 0:
// str = "A";
// break;
// case 1:
// str = "B";
// break;
// case 2:
// str = "C";
// break;
// case 3:
// str = "T";
// break;
// }
// }
//
// ReportValue reportValue = new ReportValue(str, value, value, value, value);
// list.add(reportValue);
// }
// }
//}