1.新增工程项目管理接口

2.调整报表数据不对的问题
This commit is contained in:
xy
2026-01-30 15:21:07 +08:00
parent c3cb9a5f85
commit 3727b5777e
19 changed files with 604 additions and 62 deletions

View File

@@ -133,6 +133,13 @@ public class CustomReportServiceImpl implements CustomReportService {
private final String GRID_SIDE_DICT_CODE = "Grid_Side";
private final String LOAD_SIDE_DICT_CODE = "Load_Side";
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
put("AB", "A");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
/**
* map key转大写
*/
@@ -294,7 +301,8 @@ public class CustomReportServiceImpl implements CustomReportService {
// DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
// CsLinePO gridSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null);
// CsLinePO loadSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(loadSideDictData.getId())).findFirst().orElse(null);
String lineName = "";
String lineName1 = "";
String lineName2 = "";
// 模版内容数据
JSONArray templateData;
@@ -321,13 +329,13 @@ public class CustomReportServiceImpl implements CustomReportService {
Map<String, List<ReportTemplateDataVO>> classMap = indexDataList.stream().collect(Collectors.groupingBy(ReportTemplateDataVO::getResourceId));
//定义存放指标的map
if (gridSideLine != null) {
lineName = gridSideLine.getName();
lineName2 = gridSideLine.getName();
List<ReportTemplateDataVO> afterDataList = fetchDataList(gridSideLine, classMap, queryParam);
afterFinalDataList.addAll(afterDataList);
}
if (loadSideLine != null) {
lineName = loadSideLine.getName();
lineName1 = loadSideLine.getName();
List<ReportTemplateDataVO> beforeDataList = fetchDataList(loadSideLine, classMap, queryParam);
beforeFinalDataList.addAll(beforeDataList);
}
@@ -405,9 +413,13 @@ public class CustomReportServiceImpl implements CustomReportService {
} else if (v.charAt(0) == '&') {
// 基础数据
String baseItem = v.replace(STR_THREE, "").toUpperCase();
if (baseItem.startsWith("LINENAME")) {
if (baseItem.startsWith("LINENAME1")) {
//台账信息
son.putOpt(V, baseItem.replace("LINENAME", lineName));
son.putOpt(V, baseItem.replace("LINENAME1", lineName1));
}
if (baseItem.startsWith("LINENAME2")) {
//台账信息
son.putOpt(V, baseItem.replace("LINENAME2", lineName2));
}
} else if (v.contains("start_time") && v.contains("end_time")){
//如时间是大于当前时间则用当前时间
@@ -1034,7 +1046,7 @@ 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) {
private void assSqlByMysqlNew(Map<String,String> tMap, String dataLevel, Double pt, Double ct, 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)) {
for (int i = 0; i < data.size(); i++) {
@@ -1043,6 +1055,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"");
} else {
@@ -1050,6 +1063,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
}
@@ -1061,6 +1075,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"");
} else {
@@ -1068,6 +1083,7 @@ public class CustomReportServiceImpl implements CustomReportService {
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), pt, ct) : "")
.append(InfluxDbSqlConstant.AS)
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
}
@@ -1152,6 +1168,21 @@ public class CustomReportServiceImpl implements CustomReportService {
}
public String appendData(Map<String,String> tMap,String name, double pt, double ct) {
String result;
String format = tMap.get(name);
if (Objects.equals(format, "*PT")) {
result = "*"+pt+"/1000";
} else if (Objects.equals(format, "*CT")) {
result = "*"+ct;
} else if (Objects.equals(format, "*PT*CT")) {
result = "*"+pt+"*"+ct+"/1000";
} else {
result = "";
}
return result;
}
/**
* 处理
*
@@ -2099,6 +2130,27 @@ public class CustomReportServiceImpl implements CustomReportService {
private List<ReportTemplateDataVO> fetchDataList(CsLinePO linePO,
Map<String, List<ReportTemplateDataVO>> classMap,
SensitiveUserReportQueryParam queryParam) {
//获取指标一二次值转换关系
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
Map<String, String> tMap = new HashMap<>();
eleEpdPqdList.forEach(item->{
String phase;
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
phase = item.getPhase();
} else {
phase = PHASE_MAPPING.get(item.getPhase());
}
tMap.put((item.getOtherName() + phase + item.getResourcesId()).toUpperCase(), item.getPrimaryFormula());
});
//pt
double pt = safeDivide(linePO.getPtRatio(), linePO.getPt2Ratio());
//ct
double ct = safeDivide(linePO.getCtRatio(), linePO.getCt2Ratio());
//获取当前监测点是一次值还是二次值
Map<String,String> map = csLineFeignClient.getCustomDetailByLineId(linePO.getLineId()).getData();
String dataLevel = map.get("level");
String lineId = linePO.getLineId();
List<Future<List<ReportTemplateDataVO>>> futures = new ArrayList<>();
@@ -2131,13 +2183,13 @@ public class CustomReportServiceImpl implements CustomReportService {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.MAX, queryParam, lineId);
assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.MAX, queryParam, lineId);
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.MIN, queryParam, lineId);
assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.MIN, queryParam, lineId);
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.AVG_WEB, queryParam, lineId);
assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.AVG_WEB, queryParam, lineId);
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysqlNew(newDataList, sql, threadDataList, InfluxDbSqlConstant.CP95, queryParam, lineId);
assSqlByMysqlNew(tMap,dataLevel,pt,ct,newDataList, sql, threadDataList, InfluxDbSqlConstant.CP95, queryParam, lineId);
}
});
});
@@ -2156,6 +2208,14 @@ public class CustomReportServiceImpl implements CustomReportService {
return dataList;
}
private double safeDivide(Double dividend, Double divisor) {
if (divisor == null || divisor == 0.0) {
divisor = 1.0;
}
double dividendValue = dividend != null ? dividend : 0.0;
return dividendValue / divisor;
}
//获取模板id
public String getTempId(String oldTempId, String lineId) {
//根据模板类型的id获取模板
@@ -2191,34 +2251,4 @@ public class CustomReportServiceImpl implements CustomReportService {
}
}
}

View File

@@ -632,6 +632,9 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl<RStatLimitRateDMappe
private double calculatePercentage(double part, double total) {
if (total == 0) {
return 0.0;
}
return Double.parseDouble(df.format(BigDecimal.valueOf(part / total * 100.0)
.setScale(2, RoundingMode.HALF_UP).doubleValue()));
}