1.自定义报表调整
This commit is contained in:
@@ -33,6 +33,7 @@ public class ReportSearchParam {
|
||||
@ApiModelProperty(name = "deptId",value = "部门ID")
|
||||
private String deptId;
|
||||
|
||||
private Integer resourceType = 1;
|
||||
//目前用于区分不同系统资源,null默认 1.无线系统,配合cs-device
|
||||
private Integer resourceType;
|
||||
|
||||
}
|
||||
|
||||
@@ -106,6 +106,12 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>cs-device-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.FileUtil;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.pq.api.DeptLineFeignClient;
|
||||
import com.njcn.device.pq.api.DeviceUnitClient;
|
||||
@@ -100,6 +101,8 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
|
||||
@Override
|
||||
public boolean addCustomReportTemplate(ReportTemplateParam reportTemplateParam) {
|
||||
checkName(reportTemplateParam, false);
|
||||
@@ -238,14 +241,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
if (Objects.isNull(excelRptTemp)) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
|
||||
}
|
||||
try {
|
||||
analyzeReport(reportSearchParam, excelRptTemp, response);
|
||||
} catch (Exception exception) {
|
||||
log.error(exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
throw new BusinessException(HarmonicResponseEnum.REPORT_DOWNLOAD_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -424,16 +420,19 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 数据单位信息
|
||||
*
|
||||
* @param lineID
|
||||
* @param reportSearchParam
|
||||
* @return
|
||||
*/
|
||||
private Map<String, String> unitMap(String lineID) {
|
||||
PqsDeviceUnit deviceUnit = commTerminalGeneralClient.lineUnitDetail(lineID).getData();
|
||||
private Map<String, String> unitMap(ReportSearchParam reportSearchParam) {
|
||||
PqsDeviceUnit deviceUnit;
|
||||
if(Objects.isNull(reportSearchParam.getResourceType())){
|
||||
deviceUnit = commTerminalGeneralClient.lineUnitDetail(reportSearchParam.getLineId()).getData();
|
||||
}else {
|
||||
deviceUnit = csCommTerminalFeignClient.lineUnitDetail(reportSearchParam.getLineId()).getData();
|
||||
}
|
||||
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
|
||||
Map<String, String> unit = new HashMap<>();
|
||||
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
|
||||
@@ -484,7 +483,6 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param data 同类型的cell模板
|
||||
* @param sql 单个cell模板
|
||||
@@ -495,21 +493,17 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
*/
|
||||
private void assSqlNew(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap) {
|
||||
//sql拼接示例:select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
|
||||
|
||||
|
||||
//cp95函数特殊处理 PERCENTILE(field_key, N)
|
||||
if (InfluxDbSqlConstant.PERCENTILE.equals(method)) {
|
||||
|
||||
if (InfluxDbSqlConstant.CP95.equals(method)) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (i == data.size() - 1) {
|
||||
sql.append("MAX")
|
||||
sql.append(InfluxDbSqlConstant.MAX)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(InfluxDbSqlConstant.AS).append(InfluxDbSqlConstant.DQM)
|
||||
.append(data.get(i).getItemName()).append(InfluxDbSqlConstant.DQM);
|
||||
} else {
|
||||
sql.append("MAX")
|
||||
sql.append(InfluxDbSqlConstant.MAX)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
@@ -517,9 +511,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
.append(data.get(i).getItemName()).append(InfluxDbSqlConstant.DQM).append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (i == data.size() - 1) {
|
||||
sql.append(method)
|
||||
@@ -540,6 +532,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
}
|
||||
|
||||
//拼接表名
|
||||
sql.append(StrPool.C_SPACE)
|
||||
.append(InfluxDbSqlConstant.FROM)
|
||||
.append(data.get(0).getResourceId());
|
||||
@@ -561,16 +554,12 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
}
|
||||
|
||||
|
||||
//data_flicker、data_fluc、data_plt 无 value_type
|
||||
//if (!"r_stat_data_flicker_d".equals(data.get(0).getResourceId()) && !"r_stat_data_fluc_d".equals(data.get(0).getResourceId()) && !"r_stat_data_plt_d".equals(data.get(0).getResourceId())) {
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDBTableConstant.VALUE_TYPE)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(data.get(0).getStatMethod())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
//}
|
||||
|
||||
|
||||
//频率和频率偏差仅统计T相
|
||||
@@ -599,8 +588,6 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList());
|
||||
} else {
|
||||
Map<String, Object> map = mapList.get(0);
|
||||
|
||||
|
||||
for (ReportTemplateDTO item : data) {
|
||||
if (Objects.nonNull(map) && map.containsKey(item.getItemName())) {
|
||||
double v = Double.parseDouble(map.get(item.getItemName()).toString());
|
||||
@@ -623,7 +610,6 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
double limitVal = Double.parseDouble(tem.getValue());
|
||||
if (v > limitVal) {
|
||||
tem.setOverLimitFlag(1);
|
||||
|
||||
assNoPassMap.put(key, tem);
|
||||
} else if (!assNoPassMap.containsKey(key)) {
|
||||
tem.setOverLimitFlag(0);
|
||||
@@ -681,7 +667,6 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
List<ReportTemplateDTO> endList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(reportTemplateDTOList)) {
|
||||
|
||||
|
||||
//开始组织sql
|
||||
reportTemplateDTOList = reportTemplateDTOList.stream()
|
||||
.collect(Collectors.collectingAndThen(Collectors.toCollection(
|
||||
@@ -707,7 +692,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
|
||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.PERCENTILE, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -746,7 +731,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
long jie = System.currentTimeMillis();
|
||||
//数据单位信息
|
||||
//Map<String, String> unit = unitMap(reportSearchParam.getLineId());
|
||||
Map<String, String> unit = unitMap(reportSearchParam);
|
||||
//进行反向赋值到模板
|
||||
//1、根据itemName分组
|
||||
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
@@ -815,7 +800,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
//解决数据单位问题 @指标#类型@
|
||||
if (v.charAt(0) == '@' && v.contains("#")) {
|
||||
String replace = v.replace("@", "");
|
||||
// son.set("v", unit.getOrDefault(replace, "/"));
|
||||
son.set("v", unit.getOrDefault(replace, "/"));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -916,9 +901,9 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取测点限值
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/10/23
|
||||
*/
|
||||
@@ -935,6 +920,9 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
sql.append(" from ").append(reportLimitList.get(0).getResourceId()).append(" where id ='").append(reportSearchParam.getLineId()).append("'");
|
||||
limitMap = excelRptTempMapper.dynamicSqlMap(sql.toString());
|
||||
if (Objects.isNull(limitMap)) {
|
||||
throw new BusinessException("当前测点限值缺失!");
|
||||
}
|
||||
|
||||
for (ReportTemplateDTO item : reportLimitList) {
|
||||
if (limitMap.containsKey(item.getTemplateName())) {
|
||||
|
||||
Reference in New Issue
Block a user