自定义报表优化处理
This commit is contained in:
@@ -171,6 +171,9 @@ public interface CommTerminalGeneralClient {
|
||||
HttpResult<List<StatisticsMonitor>> getStatisticsMonitor(@RequestBody StatisticsBizBaseParam param);
|
||||
|
||||
|
||||
@GetMapping("/getCustomDetailByLineId")
|
||||
HttpResult<Map<String,String>> getCustomDetailByLineId(@RequestParam("id") String id);
|
||||
|
||||
|
||||
/**
|
||||
* 用于返回pq 还是pms系统
|
||||
|
||||
@@ -137,6 +137,12 @@ public class CommTerminalGeneralClientFallbackFactory implements FallbackFactory
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Map<String, String>> getCustomDetailByLineId(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取监测点信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> isPqOrPms() {
|
||||
log.error("{}异常,降级处理,异常为:{}", "返回pq还是pms系统", throwable.toString());
|
||||
|
||||
@@ -322,4 +322,19 @@ public class CommTerminalController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("getStatisticsMonitor");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, new ArrayList<>(), methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取监测点的台账详细信息
|
||||
* @author cdf
|
||||
* @date 2023/10/23
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getCustomDetailByLineId")
|
||||
@ApiOperation("获取监测点的台账详细信息(自定义报表用)")
|
||||
@ApiImplicitParam(name = "id", value = "监测点ID", required = true)
|
||||
public HttpResult<Map<String,String>> getCustomDetailByLineId(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getCustomDetailByLineId");
|
||||
Map<String,String> result = commTerminalService.getCustomDetailByLineId(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -523,4 +524,6 @@ public interface LineMapper extends BaseMapper<Line> {
|
||||
* @Date: 2023/9/22 10:20
|
||||
*/
|
||||
LineDTO selectLineDetail(@Param("id") String id);
|
||||
|
||||
Map<String,String> getCustomDetailByLineId(@Param("lineId")String lineId);
|
||||
}
|
||||
|
||||
@@ -1365,4 +1365,37 @@
|
||||
AND line.id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getCustomDetailByLineId" resultType="map">
|
||||
SELECT
|
||||
line.id AS lineId,
|
||||
concat(sub.name,"_",vo.name,"_",line.name) as lineName,
|
||||
concat(detail.pt1,concat(':',detail.pt2)) as pt,
|
||||
concat(detail.ct1,concat(':',detail.ct2)) as ct,
|
||||
detail.Dev_Capacity as Dev_Capacity,
|
||||
detail.Short_Capacity as Short_Capacity,
|
||||
detail.Standard_Capacity as Standard_Capacity,
|
||||
detail.Deal_Capacity as Deal_Capacity,
|
||||
pqd.This_Time_Check AS This_Time_Check,
|
||||
dic.name AS voltageLevel
|
||||
FROM
|
||||
pq_line line,
|
||||
pq_line_detail detail,
|
||||
pq_line vo,
|
||||
pq_voltage vg,
|
||||
pq_line dev,
|
||||
pq_device pqd,
|
||||
sys_dict_data dic,
|
||||
pq_line sub
|
||||
WHERE
|
||||
line.id = detail.id
|
||||
AND vo.id = line.pid
|
||||
AND dev.id = vo.pid
|
||||
AND vo.id = vg.id
|
||||
AND pqd.id = dev.id
|
||||
and vg.scale = dic.id
|
||||
and sub.id = dev.pid
|
||||
AND line.id = #{lineId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.njcn.device.pq.service;
|
||||
|
||||
import com.njcn.device.biz.pojo.dto.*;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
@@ -72,6 +74,14 @@ public interface CommTerminalService {
|
||||
LineDevGetBandDTO substationGetLine(String substationId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取监测点的台账详细信息
|
||||
* @author cdf
|
||||
* @date 2023/10/23
|
||||
*/
|
||||
Map<String,String> getCustomDetailByLineId(String id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -200,8 +200,10 @@ public class CommTerminalServiceImpl implements CommTerminalService {
|
||||
return lineDevGetBandDTO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCustomDetailByLineId(String id) {
|
||||
return lineMapper.getCustomDetailByLineId(id);
|
||||
}
|
||||
|
||||
|
||||
private List<Integer> filterDataTypeNew(String serverName) {
|
||||
|
||||
@@ -22,6 +22,8 @@ public class ExcelRptTemp extends BaseEntity {
|
||||
|
||||
private String content;
|
||||
|
||||
private Integer activation;
|
||||
|
||||
private Integer state;
|
||||
|
||||
private String valueTitle;
|
||||
|
||||
@@ -253,4 +253,18 @@ public class CustomReportController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取报表台账模板树
|
||||
* @author cdf
|
||||
* @date 2023/10/11
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/terminalChooseTree")
|
||||
@ApiOperation("获取报表台账模板树")
|
||||
public HttpResult<List<ReportTreeVO>> terminalChooseTree(){
|
||||
String methodDescribe = getMethodDescribe("terminalChooseTree");
|
||||
List<ReportTreeVO> res = customReportService.terminalChooseTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@
|
||||
DISTINCT
|
||||
a.id,
|
||||
a.NAME,
|
||||
b.activation,
|
||||
a.activation,
|
||||
a.report_form
|
||||
FROM
|
||||
sys_excel_rpt_temp a
|
||||
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
|
||||
WHERE
|
||||
b.activation = 1
|
||||
a.activation = 1
|
||||
and b.dept_id in
|
||||
<foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
|
||||
@@ -89,6 +89,13 @@ public interface CustomReportService {
|
||||
|
||||
List<ReportTreeVO> targetLimitChooseTree();
|
||||
|
||||
/**
|
||||
* 台账类型树
|
||||
* @author cdf
|
||||
* @date 2023/10/23
|
||||
*/
|
||||
List<ReportTreeVO> terminalChooseTree();
|
||||
|
||||
/**
|
||||
* 绑定/解绑模板数据
|
||||
* @author qijian
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.harmonic.service.impl;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.*;
|
||||
@@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.FileUtil;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.pq.api.DeptLineFeignClient;
|
||||
import com.njcn.device.pq.api.DeviceUnitClient;
|
||||
import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
@@ -42,6 +44,7 @@ import com.njcn.harmonic.pojo.vo.SysDeptTempVO;
|
||||
import com.njcn.harmonic.service.CustomReportService;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -92,10 +95,12 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
private final DeviceUnitClient deviceUnitClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final DeptLineFeignClient deptLineFeignClient;
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
|
||||
@Override
|
||||
public boolean addCustomReportTemplate(ReportTemplateParam reportTemplateParam) {
|
||||
checkName(reportTemplateParam, false);
|
||||
@@ -112,6 +117,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
ExcelRptTemp excelRptTemp = new ExcelRptTemp();
|
||||
BeanUtils.copyProperties(reportTemplateParam, excelRptTemp);
|
||||
excelRptTemp.setState(DataStateEnum.ENABLE.getCode());
|
||||
excelRptTemp.setActivation(DataStateEnum.ENABLE.getCode());
|
||||
excelRptTempMapper.insert(excelRptTemp);
|
||||
|
||||
//获取主键,并存入部门表
|
||||
@@ -177,9 +183,8 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
@Override
|
||||
public List<ReportTemplateVO> getTemplateByDept(String id) {
|
||||
//获取子孙部门,去重
|
||||
DeptLine data = deptLineFeignClient.getLineByLineIds(id).getData();
|
||||
return excelRptTempMapper.getReportTemplateByDept(Arrays.asList(data.getId()));
|
||||
List<String> deptIds = deptFeignClient.getDepSonIdtByDeptId(id).getData();
|
||||
return excelRptTempMapper.getReportTemplateByDept(deptIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,7 +312,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
reportTreeVO.setShowName(val.get(0).getShowName());
|
||||
|
||||
if (Objects.nonNull(val.get(0).getHarmStart()) && Objects.nonNull(val.get(0).getHarmEnd())) {
|
||||
String[] str = val.get(0).getLimitName().split("#");
|
||||
String one = val.get(0).getLimitName();
|
||||
List<ReportTreeVO> temList = new ArrayList<>();
|
||||
for (int i = val.get(0).getHarmStart(); i <= val.get(0).getHarmEnd(); i++) {
|
||||
double count;
|
||||
@@ -316,10 +321,10 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
if (val.get(0).getHarmStart() == 1) {
|
||||
count = i + 0.5;
|
||||
reportTreeItem.setShowName(count + "次" + val.get(0).getShowName());
|
||||
reportTreeItem.setName(str[0] + count + "#" + str[1] + count + "#" + val.get(0).getLimitTable());
|
||||
reportTreeItem.setName("%"+one + count + "#" + val.get(0).getFormula() + "#" + val.get(0).getLimitTable()+"%");
|
||||
} else {
|
||||
reportTreeItem.setShowName(i + "次" + val.get(0).getShowName());
|
||||
reportTreeItem.setName(str[0] + i + "#" + str[1] + i + "#" + val.get(0).getLimitTable());
|
||||
reportTreeItem.setName("%"+one + i + "#" + val.get(0).getFormula()+ "#" + val.get(0).getLimitTable()+"%");
|
||||
}
|
||||
|
||||
reportTreeItem.setFlag(1);
|
||||
@@ -327,19 +332,30 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
reportTreeVO.setChildren(temList);
|
||||
} else {
|
||||
reportTreeVO.setName(val.get(0).getLimitName() + "#" + val.get(0).getFormula());
|
||||
reportTreeVO.setName("%"+val.get(0).getLimitName() + "#" + val.get(0).getLimitTable()+"%"+ val.get(0).getFormula()+"%");
|
||||
reportTreeVO.setFlag(1);
|
||||
}
|
||||
|
||||
result.add(reportTreeVO);
|
||||
});
|
||||
/*list.forEach(item->{
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReportTreeVO> terminalChooseTree() {
|
||||
List<ReportTreeVO> result = new ArrayList<>();
|
||||
DictData dic = dicDataFeignClient.getDicDataByCode(DicDataEnum.TERMINAL_SORT.getCode()).getData();
|
||||
LambdaQueryWrapper<EleEpdPqd> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(EleEpdPqd::getDataType, dic.getId()).orderByAsc(EleEpdPqd::getSort);
|
||||
List<EleEpdPqd> list = eleEpdMapper.selectList(lambdaQueryWrapper);
|
||||
list.forEach(item -> {
|
||||
ReportTreeVO reportTreeVO = new ReportTreeVO();
|
||||
reportTreeVO.setId(item.getId());
|
||||
reportTreeVO.setName(item.getName());
|
||||
reportTreeVO.setName("&" + item.getName() + "&");
|
||||
reportTreeVO.setFlag(1);
|
||||
reportTreeVO.setShowName(item.getShowName());
|
||||
result.add(reportTreeVO);
|
||||
});*/
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -723,7 +739,6 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
* @param endList 用于返回最终组装好的数据,类似data
|
||||
* @param limitMap 指标是否合格模板
|
||||
* @param assNoPassMap 用于存储不合格的指标
|
||||
*
|
||||
* @date 2023/10/20
|
||||
*/
|
||||
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) {
|
||||
@@ -740,16 +755,16 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.NUM_95)
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(" as \"")
|
||||
.append(data.get(i).getItemName()).append("\" ");
|
||||
.append(InfluxDbSqlConstant.AS).append(InfluxDbSqlConstant.DQM)
|
||||
.append(data.get(i).getItemName()).append(InfluxDbSqlConstant.DQM);
|
||||
} else {
|
||||
sql.append(method)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.NUM_95)
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(" as \"")
|
||||
.append(data.get(i).getItemName()).append("\"").append(StrUtil.COMMA);
|
||||
.append(InfluxDbSqlConstant.AS).append(InfluxDbSqlConstant.DQM)
|
||||
.append(data.get(i).getItemName()).append(InfluxDbSqlConstant.DQM).append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,20 +776,21 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(" as \"")
|
||||
.append(data.get(i).getItemName()).append("\" ");
|
||||
.append(InfluxDbSqlConstant.AS).append(InfluxDbSqlConstant.DQM)
|
||||
.append(data.get(i).getItemName()).append(InfluxDbSqlConstant.DQM);
|
||||
} else {
|
||||
sql.append(method)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(" as \"")
|
||||
.append(data.get(i).getItemName()).append("\"").append(StrUtil.COMMA);
|
||||
.append(InfluxDbSqlConstant.AS).append(InfluxDbSqlConstant.DQM)
|
||||
.append(data.get(i).getItemName()).append(InfluxDbSqlConstant.DQM).append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sql.append(StrPool.C_SPACE);
|
||||
if (reportSearchParam.getResourceType() == 1) {
|
||||
sql.append(InfluxDbSqlConstant.FROM)
|
||||
.append(data.get(0).getClassId().replace("data", "day"));
|
||||
@@ -862,10 +878,12 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
double limitVal = Double.parseDouble(tem.getValue());
|
||||
if (v > limitVal) {
|
||||
tem.setOverLimitFlag(1);
|
||||
tem.setValue(tem.getValue());
|
||||
assNoPassMap.put(key, tem);
|
||||
} else if (!assNoPassMap.containsKey(key)) {
|
||||
tem.setOverLimitFlag(0);
|
||||
assNoPassMap.put(key, tem);
|
||||
tem.setValue(tem.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,10 +916,12 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>();
|
||||
//限值
|
||||
List<ReportTemplateDTO> reportLimitList = new ArrayList<>();
|
||||
//台账
|
||||
List<ReportTemplateDTO> terminalList = new ArrayList<>();
|
||||
JSONArray jsonArray;
|
||||
try (InputStream fileStream = fileStorageUtil.getFileStream(excelRptTemp.getContent())) {
|
||||
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||
pareTemplate(jsonArray,fileStream,excelRptTemp.getContent(),reportTemplateDTOList,reportLimitList);
|
||||
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList,terminalList);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
|
||||
}
|
||||
@@ -910,42 +930,16 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
long temEnd = System.currentTimeMillis();
|
||||
|
||||
//存放限值的map
|
||||
Map<String, Float> limitMap = new HashMap<>();
|
||||
|
||||
//存放限值指标的map
|
||||
Map<String, ReportTemplateDTO> limitTargetMapX = new HashMap<>();
|
||||
//处理指标是否合格
|
||||
if (CollUtil.isNotEmpty(reportLimitList)) {
|
||||
|
||||
StringBuilder sql = new StringBuilder("select ");
|
||||
for (int i = 0; i < reportLimitList.size(); i++) {
|
||||
if (i == reportLimitList.size() - 1) {
|
||||
sql.append(reportLimitList.get(i).getTemplateName());
|
||||
} else {
|
||||
sql.append(reportLimitList.get(i).getTemplateName()).append(",");
|
||||
}
|
||||
}
|
||||
|
||||
sql.append(" from ").append(reportLimitList.get(0).getClassId()).append(" where id ='").append(reportSearchParam.getLineId()).append("'");
|
||||
limitMap = excelRptTempMapper.dynamicSqlMap(sql.toString());
|
||||
|
||||
for (ReportTemplateDTO item : reportLimitList) {
|
||||
if (limitMap.containsKey(item.getTemplateName())) {
|
||||
item.setValue(limitMap.get(item.getTemplateName()).toString());
|
||||
}
|
||||
}
|
||||
limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
|
||||
}
|
||||
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
|
||||
//存放限值指标的map
|
||||
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
|
||||
|
||||
List<ReportTemplateDTO> endList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(reportTemplateDTOList)) {
|
||||
long deal = System.currentTimeMillis();
|
||||
|
||||
|
||||
Map<String, ReportTemplateDTO> finalLimitMapX = limitTargetMapX;
|
||||
Map<String, Float> overLimitMap = limitMap;
|
||||
|
||||
//开始组织sql
|
||||
Map<String, List<ReportTemplateDTO>> classMap = reportTemplateDTOList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getClassId));
|
||||
Map<String, ReportTemplateDTO> assNoPassMap = new HashMap<>();
|
||||
@@ -958,33 +952,31 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
//相别分组
|
||||
Map<String, List<ReportTemplateDTO>> phaseMap = valueTypeVal.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getPhase));
|
||||
phaseMap.forEach((phaseKey, phaseVal) -> {
|
||||
|
||||
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
||||
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, finalLimitMapX,overLimitMap, assNoPassMap);
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
|
||||
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, finalLimitMapX,overLimitMap, assNoPassMap);
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
|
||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.AVG, reportSearchParam, finalLimitMapX,overLimitMap, assNoPassMap);
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.AVG, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
|
||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.PERCENTILE, reportSearchParam, finalLimitMapX,overLimitMap, assNoPassMap);
|
||||
assSqlNew(phaseVal, sql, endList, InfluxDbSqlConstant.PERCENTILE, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
assNoPassMap.forEach((key, val) -> {
|
||||
finalLimitMapX.remove(key);
|
||||
limitTargetMapX.remove(key);
|
||||
if (val.getOverLimitFlag() == 1) {
|
||||
val.setValue("不合格");
|
||||
val.setValue("不合格 ("+val.getValue()+")");
|
||||
} else {
|
||||
val.setValue("合格");
|
||||
val.setValue("合格 ("+val.getValue()+")");
|
||||
}
|
||||
|
||||
endList.add(val);
|
||||
});
|
||||
|
||||
finalLimitMapX.forEach((key, val) -> {
|
||||
limitTargetMapX.forEach((key, val) -> {
|
||||
if (Objects.isNull(val.getOverLimitFlag())) {
|
||||
val.setValue("/");
|
||||
} else {
|
||||
@@ -998,6 +990,10 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
System.out.println("查询数据库花费时间" + (dealEnd - deal) / 1000 + "S");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
long jie = System.currentTimeMillis();
|
||||
//数据单位信息
|
||||
@@ -1005,7 +1001,16 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
//进行反向赋值到模板
|
||||
//1、根据itemName分组
|
||||
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
//处理台账信息
|
||||
Map<String,String> terminalMap = null;
|
||||
if(CollUtil.isNotEmpty(terminalList)){
|
||||
terminalMap = commTerminalGeneralClient.getCustomDetailByLineId(reportSearchParam.getLineId()).getData();
|
||||
}
|
||||
Map<String, String> finalTerminalMap = terminalMap;
|
||||
|
||||
|
||||
//2、把itemName的value赋给v和m
|
||||
|
||||
jsonArray.forEach(item -> {
|
||||
JSONObject jsonObject = (JSONObject) item;
|
||||
JSONArray itemArr = (JSONArray) jsonObject.get("celldata");
|
||||
@@ -1046,6 +1051,17 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
son.set("fc", "#990000");
|
||||
}
|
||||
}
|
||||
} else if (v.charAt(0) == '&') {
|
||||
//结论
|
||||
String tem = v.replace("&", "");
|
||||
if(Objects.nonNull(finalTerminalMap)) {
|
||||
if("statis_time".equals(tem)){
|
||||
son.set("v", reportSearchParam.getStartTime()+InfluxDbSqlConstant.START_TIME+"_"+reportSearchParam.getEndTime()+InfluxDbSqlConstant.END_TIME);
|
||||
}else {
|
||||
//台账信息
|
||||
son.set("v", finalTerminalMap.getOrDefault(tem, "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
//解决数据单位问题 @指标#类型@
|
||||
if (v.charAt(0) == '@' && v.contains("#")) {
|
||||
@@ -1102,10 +1118,11 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
/**
|
||||
* 解析模板
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/10/20
|
||||
*/
|
||||
private void pareTemplate(JSONArray jsonArray,InputStream fileStream,String content,List<ReportTemplateDTO> reportTemplateDTOList,List<ReportTemplateDTO> reportLimitList){
|
||||
private void parseTemplate(JSONArray jsonArray, List<ReportTemplateDTO> reportTemplateDTOList, List<ReportTemplateDTO> reportLimitList, List<ReportTemplateDTO> terminalList) {
|
||||
try {
|
||||
//通过文件服务器获取
|
||||
|
||||
@@ -1160,6 +1177,13 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
reportTemplateDTO.setClassId(vItem[2]);
|
||||
}
|
||||
reportLimitList.add(reportTemplateDTO);
|
||||
} else if (v.charAt(0) == '&') {
|
||||
//封装ReportTemplateDTO
|
||||
ReportTemplateDTO reportTemplateDTO = new ReportTemplateDTO();
|
||||
v = v.replace("&", "");
|
||||
reportTemplateDTO.setItemName(v);
|
||||
reportTemplateDTO.setTemplateName(v);
|
||||
terminalList.add(reportTemplateDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1172,6 +1196,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
/**
|
||||
* 获取两个时间之间的天数
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/10/20
|
||||
*/
|
||||
@@ -1199,6 +1224,34 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author cdf
|
||||
* @date 2023/10/23
|
||||
*/
|
||||
private Map<String,Float> overLimitDeal(List<ReportTemplateDTO> reportLimitList, ReportSearchParam reportSearchParam) {
|
||||
Map<String, Float> limitMap = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(reportLimitList)) {
|
||||
StringBuilder sql = new StringBuilder("select ");
|
||||
for (int i = 0; i < reportLimitList.size(); i++) {
|
||||
if (i == reportLimitList.size() - 1) {
|
||||
sql.append(reportLimitList.get(i).getTemplateName());
|
||||
} else {
|
||||
sql.append(reportLimitList.get(i).getTemplateName()).append(",");
|
||||
}
|
||||
}
|
||||
|
||||
sql.append(" from ").append(reportLimitList.get(0).getClassId()).append(" where id ='").append(reportSearchParam.getLineId()).append("'");
|
||||
limitMap = excelRptTempMapper.dynamicSqlMap(sql.toString());
|
||||
|
||||
for (ReportTemplateDTO item : reportLimitList) {
|
||||
if (limitMap.containsKey(item.getTemplateName())) {
|
||||
item.setValue(limitMap.get(item.getTemplateName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return limitMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -395,6 +395,7 @@ public enum DicDataEnum {
|
||||
SET("定值","Set"),
|
||||
INSET("内部定值","InSet"),
|
||||
CTRL("控制","Ctrl"),
|
||||
TERMINAL_SORT("台账类型","terminal_sort"),
|
||||
/**
|
||||
* 暂降原因
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user