bug修复
This commit is contained in:
@@ -6,7 +6,6 @@ import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
@@ -217,6 +216,8 @@ public class WordExportModelController extends BaseController {
|
||||
rtfPath = "file/reportModelNW.docx";
|
||||
} else if (theme.getRemark().equals("灿能")) {
|
||||
rtfPath = "file/reportModelCN.docx";
|
||||
} else if (theme.getName().contains("物联")) {
|
||||
rtfPath = "file/reportModelWL.docx";
|
||||
} else {
|
||||
rtfPath = "file/reportModel.docx";
|
||||
}
|
||||
@@ -493,6 +494,8 @@ public class WordExportModelController extends BaseController {
|
||||
reportmap.put("$detpName$", areaName);
|
||||
// 获取报告生成时间
|
||||
Date currentTime = new Date();
|
||||
// 报告日期格式
|
||||
SimpleDateFormat dayFormatter = new SimpleDateFormat("yyyy年MM月dd日");
|
||||
// 报告时分秒格式
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
|
||||
String strTime = String.format("%s——%s。",
|
||||
@@ -503,7 +506,8 @@ public class WordExportModelController extends BaseController {
|
||||
// 客户名称
|
||||
reportmap.put("$titlePoint$", crmName);
|
||||
// 报告生成时间
|
||||
reportmap.put("$TitleTime$", formatter.format(currentTime));
|
||||
reportmap.put("$TitleTime$", dayFormatter.format(currentTime));
|
||||
|
||||
// 报告标题
|
||||
reportmap.put("$ReportTitle$",
|
||||
String.format("对该地区%s电能质量在线监测数据进行分析, 以判断电能质量指标是否满足国标。", new String[]{strLineBaseName}));
|
||||
@@ -676,14 +680,14 @@ public class WordExportModelController extends BaseController {
|
||||
tmpstrResultVdeviationdata += "、";
|
||||
tmpstrResultVdeviationdata += tmpstrMap + "相";
|
||||
}
|
||||
|
||||
Overlimit pojo = overLimitData.getOverLimitRate().get(0);
|
||||
// 假如为空则所有的都满足
|
||||
if ("".equals(tmpstrResultVdeviationdata)) {
|
||||
strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + "A、B、C三相电压偏差满足国标限值(10%)的要求。";
|
||||
strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + "A、B、C三相电压偏差满足国标限值(上限"+pojo.getVoltageDev()+"%,下限"+pojo.getUvoltageDev()+"%)的要求。";
|
||||
} else {
|
||||
strAnalysis += tmpstrResultVdeviationdata + "电压偏差不满足国标限值(10%)的要求。";
|
||||
strAnalysis += tmpstrResultVdeviationdata + "电压偏差不满足国标限值(上限"+pojo.getVoltageDev()+"%,下限"+pojo.getUvoltageDev()+"%)的要求。";
|
||||
strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + tmpstrResultVdeviationdata
|
||||
+ "电压偏差不满足国标限值(10%)的要求。";
|
||||
+ "电压偏差不满足国标限值(上限"+pojo.getVoltageDev()+"%,下限"+pojo.getUvoltageDev()+"%)的要求。";
|
||||
}
|
||||
|
||||
reportmap.put("$ResultVdeviationdata$", strResultVdeviationdata);
|
||||
|
||||
@@ -0,0 +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> {
|
||||
|
||||
}
|
||||
@@ -5,20 +5,16 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.csharmonic.mapper.report.RStatDataIDMapper;
|
||||
import com.njcn.csharmonic.mapper.report.RStatDataInharmVDMapper;
|
||||
import com.njcn.csharmonic.mapper.report.RStatDataVDPOMapper;
|
||||
import com.njcn.csharmonic.mapper.report.ReportMapper;
|
||||
import com.njcn.csharmonic.mapper.report.*;
|
||||
import com.njcn.csharmonic.pojo.dto.report.OverLimitInfo;
|
||||
import com.njcn.csharmonic.pojo.param.report.ReportQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.day.RStatDataHarmrateVDPO;
|
||||
import com.njcn.csharmonic.pojo.po.day.RStatDataIDPO;
|
||||
import com.njcn.csharmonic.pojo.po.day.RStatDataInharmVDPO;
|
||||
import com.njcn.csharmonic.pojo.po.day.RStatDataVDPO;
|
||||
import com.njcn.csharmonic.pojo.vo.report.ReportValue;
|
||||
import com.njcn.csharmonic.service.ReportService;
|
||||
import com.njcn.csharmonic.util.RegroupData;
|
||||
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -37,6 +33,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
|
||||
private final ReportMapper reportMapper;
|
||||
private final RStatDataVDPOMapper rStatDataVDMapper;
|
||||
private final RStatDataHarmRateVDMapper rStatDataHarmRateVDMapper;
|
||||
private final RStatDataIDMapper rStatDataIDMapper;
|
||||
private final RStatDataInharmVDMapper rStatDataInharmVDMapper;
|
||||
|
||||
@@ -225,7 +222,8 @@ public class ReportServiceImpl implements ReportService {
|
||||
}
|
||||
|
||||
//获取电压含有率,不包含基波
|
||||
List<ReportValue> listRate = dataV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1);
|
||||
// List<ReportValue> listRate = dataV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1);
|
||||
List<ReportValue> listRate = dataHarmRateV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1);
|
||||
|
||||
if (CollUtil.isEmpty(listRate)) {
|
||||
for (int i = 0; i < 49; i++) {
|
||||
@@ -387,6 +385,66 @@ public class ReportServiceImpl implements ReportService {
|
||||
return a;
|
||||
}
|
||||
|
||||
//获取电压含有率应该取dataHarmRateV,不是dataV
|
||||
private List<ReportValue> dataHarmRateV(ReportQueryParam param, List<String> valueTypes, Integer num, Integer size, Boolean fly, Integer index) {
|
||||
List<RStatDataHarmrateVDPO> rStatDataVDS = rStatDataHarmRateVDMapper.selectList(new LambdaQueryWrapper<RStatDataHarmrateVDPO>()
|
||||
.eq(RStatDataHarmrateVDPO::getLineId, param.getLineId())
|
||||
.in(CollUtil.isNotEmpty(valueTypes), RStatDataHarmrateVDPO::getPhaseType, valueTypes)
|
||||
.ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
|
||||
.le(StrUtil.isNotBlank(param.getEndTime()), RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
|
||||
);
|
||||
String max = "MAX";
|
||||
String avg = "AVG";
|
||||
String min = "MIN";
|
||||
String cp95 = "CP95";
|
||||
List<ReportValue> a = new ArrayList<>();
|
||||
Map<String, List<RStatDataHarmrateVDPO>> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getPhaseType));
|
||||
collect.forEach((key, value) -> {
|
||||
Map<String, List<RStatDataHarmrateVDPO>> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getValueType));
|
||||
|
||||
for (int i = num; i < size; i++) {
|
||||
ReportValue reportValue = new ReportValue();
|
||||
String attribute = "";
|
||||
if (fly) {
|
||||
if (index == 0) {
|
||||
attribute = attributeV(i);
|
||||
} else {
|
||||
attribute = attributeV(index);
|
||||
}
|
||||
} else {
|
||||
attribute = "v" + i;
|
||||
}
|
||||
|
||||
if (valueTypeMap.containsKey(max)) {
|
||||
List<Float> aa = reflectDataHarmRateV(valueTypeMap.get(max), max, attribute);
|
||||
reportValue.setPhaseType(key);
|
||||
Float maxNum = aa.stream().distinct().max(Float::compareTo).get();
|
||||
reportValue.setFmaxValue(maxNum);
|
||||
}
|
||||
if (valueTypeMap.containsKey(avg)) {
|
||||
List<Float> aa = reflectDataHarmRateV(valueTypeMap.get(avg), avg, attribute);
|
||||
reportValue.setPhaseType(key);
|
||||
Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue));
|
||||
reportValue.setMeanValue(avgNum.floatValue());
|
||||
}
|
||||
if (valueTypeMap.containsKey(min)) {
|
||||
List<Float> aa = reflectDataHarmRateV(valueTypeMap.get(min), min, attribute);
|
||||
reportValue.setPhaseType(key);
|
||||
double minNum = aa.stream().distinct().min(Float::compareTo).get();
|
||||
reportValue.setMinValue((float) minNum);
|
||||
}
|
||||
if (valueTypeMap.containsKey(cp95)) {
|
||||
List<Float> aa = reflectDataHarmRateV(valueTypeMap.get(cp95), cp95, attribute);
|
||||
reportValue.setPhaseType(key);
|
||||
List<Float> cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList());
|
||||
reportValue.setCp95Value(cp95Num.get(0).floatValue());
|
||||
}
|
||||
a.add(reportValue);
|
||||
}
|
||||
});
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* 电压反射取属性值
|
||||
*
|
||||
@@ -416,6 +474,28 @@ public class ReportServiceImpl implements ReportService {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<Float> reflectDataHarmRateV(List<RStatDataHarmrateVDPO> value, String name, String attribute) {
|
||||
Field field = null;
|
||||
try {
|
||||
field = RStatDataHarmrateVDPO.class.getDeclaredField(attribute);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
field.setAccessible(true);
|
||||
|
||||
Field finalField = field;
|
||||
return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> {
|
||||
BigDecimal o = null;
|
||||
try {
|
||||
o = BigDecimal.valueOf((Double) finalField.get(temp));
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return o.floatValue();
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 电压反射取属性值
|
||||
*
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user