|
@@ -10,6 +10,8 @@ import com.huaxu.entity.DayReportEntity;
|
|
|
import com.huaxu.util.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -46,6 +48,15 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
List<ReportTitleDto> reportTitleDtos = getReportTitle(reportDto, mapsTitle, mapsAttributeTitle);
|
|
|
// 固定参数项
|
|
|
List<ReportDto> reportList = findReport(reportDto);
|
|
|
+ // 如果为空,把自定义表头返回回去
|
|
|
+ if (CollectionUtil.isEmpty(reportPage.getRecords())){
|
|
|
+ List<ReportDto> reportDtos = new ArrayList<>();
|
|
|
+ ReportDto reportDto1 = new ReportDto();
|
|
|
+ reportDto1.setReportTitle(reportTitleDtos);
|
|
|
+ reportDtos.add(reportDto1);
|
|
|
+ reportPage.setRecords(reportDtos);
|
|
|
+ return;
|
|
|
+ }
|
|
|
int total = 0;
|
|
|
// 单个属性值
|
|
|
for (ReportDto item : reportPage.getRecords()) {
|
|
@@ -60,8 +71,8 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
List<ReportAttributeDto> reportAttributeDtos = this.findAttributeList(item);
|
|
|
Map<String, ReportAttributeDto> mapData = new LinkedHashMap<>();
|
|
|
for (ReportAttributeDto itemData : reportAttributeDtos) {
|
|
|
- if (!mapData.containsKey(itemData.getAttributeName())){
|
|
|
- mapData.put(itemData.getAttributeName(), itemData);
|
|
|
+ if (!mapData.containsKey(itemData.getDeviceParmId().toString())){
|
|
|
+ mapData.put(itemData.getDeviceParmId().toString(), itemData);
|
|
|
}
|
|
|
}
|
|
|
// 获取统计维度的值
|
|
@@ -113,6 +124,17 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
return (double) Math.round(value * 1000) / 1000;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Author lihui
|
|
|
+ * @Description 单位除以一万,保留3位小数
|
|
|
+ * @Date 14:18 2021/4/28
|
|
|
+ * @Param [value]
|
|
|
+ * @return double
|
|
|
+ **/
|
|
|
+ public double doubleDivideValue(double value){
|
|
|
+ return new BigDecimal(value).divide(BigDecimal.valueOf(10000), 3, RoundingMode.HALF_UP).doubleValue();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 组装参数
|
|
@@ -127,7 +149,7 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
reportDto.setMonth(queryDto.getMonth());
|
|
|
reportDto.setDay(queryDto.getDay());
|
|
|
if (isPipe){
|
|
|
- Integer[] parmType = null;
|
|
|
+ /*Integer[] parmType = null;
|
|
|
if (queryDto.getType() == 1) {
|
|
|
parmType = new Integer[]{13};
|
|
|
} else if (queryDto.getType() == 2){
|
|
@@ -135,8 +157,8 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
} else if (queryDto.getType() == 3){
|
|
|
parmType = new Integer[]{7, 9, 11};
|
|
|
}
|
|
|
+ reportDto.setParmType(Arrays.asList(parmType));*/
|
|
|
reportDto.setDeviceIds(devices);
|
|
|
- reportDto.setParmType(Arrays.asList(parmType));
|
|
|
} else {
|
|
|
reportDto.setDeviceIds(devices);
|
|
|
reportDto.setParentSceneIds(queryDto.getIds());
|
|
@@ -157,7 +179,7 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
dto.setDeviceIds(devices);
|
|
|
// 管网和其他有点不一样
|
|
|
if (isPipe){
|
|
|
- Integer[] parmType = null;
|
|
|
+ /* Integer[] parmType = null;
|
|
|
if (queryDto.getType() == 1) {
|
|
|
parmType = new Integer[]{13};
|
|
|
} else if (queryDto.getType() == 2){
|
|
@@ -165,7 +187,7 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
} else if (queryDto.getType() == 3){
|
|
|
parmType = new Integer[]{7, 9, 11};
|
|
|
}
|
|
|
- dto.setTypeIds(Arrays.asList(parmType));
|
|
|
+ dto.setTypeIds(Arrays.asList(parmType));*/
|
|
|
dto.setType(queryDto.getType());
|
|
|
} else {
|
|
|
dto.setParentSceneIds(queryDto.getIds());
|
|
@@ -184,28 +206,23 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
*/
|
|
|
public List<ReportTitleDto> getReportTitle(ReportDto reportDto, Map<String, Integer> mapsTitle,
|
|
|
Map<String, ReportAttributeDto> mapsAttributeTitle){
|
|
|
- // 获取设备参数属性
|
|
|
- List<ReportAttributeDto> reportAttributeDtos2 = deviceParmService.findAttributeNameList(reportDto);
|
|
|
- int numCount = 0;
|
|
|
- for (ReportAttributeDto title : reportAttributeDtos2) {
|
|
|
- if (!mapsAttributeTitle.containsKey(title.getAttributeName())){
|
|
|
- mapsAttributeTitle.put(title.getAttributeName(),title);
|
|
|
- }
|
|
|
- }
|
|
|
// 设置标题
|
|
|
Map<String, ReportTitleDto> deviceChildrenMap = new HashMap<>();
|
|
|
- mapsAttributeTitle.forEach((k, v) -> {
|
|
|
+ List<ReportAttributeDto> reportAttributeDtos2 = deviceParmService.findAttributeNameList(reportDto);
|
|
|
+ int numCount = 0;
|
|
|
+ for (ReportAttributeDto reportAttributeDto : reportAttributeDtos2) {
|
|
|
// 判断开关是否开启
|
|
|
- if (v.isShowOnOff()){
|
|
|
- setReportTitle(v, deviceChildrenMap);
|
|
|
+ if (reportAttributeDto.isShowOnOff()){
|
|
|
+ setReportTitle(reportAttributeDto, deviceChildrenMap);
|
|
|
+ mapsAttributeTitle.put(reportAttributeDto.getDeviceParmId().toString(),reportAttributeDto);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
// 转换list返回
|
|
|
List<ReportTitleDto> resultList = deviceChildrenMap.values().stream().collect(Collectors.toList());
|
|
|
for (ReportTitleDto reportTitleDto : resultList) {
|
|
|
List<ReportTitleDto.DeviceChildren> childrenList = reportTitleDto.getDeviceChildren();
|
|
|
for (ReportTitleDto.DeviceChildren children : childrenList) {
|
|
|
- mapsTitle.put(children.getName(), numCount++);
|
|
|
+ mapsTitle.put(children.getParamId(), numCount++);
|
|
|
}
|
|
|
}
|
|
|
return resultList;
|
|
@@ -218,14 +235,15 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
* @param mapsAttributeTitle
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<Map<String, Object>> getStatisticalDimensionsValue( Map<String, Integer> mapsTitle, Map<String, ReportAttributeDto> mapData, Map<String, ReportAttributeDto> mapsAttributeTitle){
|
|
|
+ public List<Map<String, Object>> getStatisticalDimensionsValue( Map<String, Integer> mapsTitle, Map<String, ReportAttributeDto> mapData,
|
|
|
+ Map<String, ReportAttributeDto> mapsAttributeTitle){
|
|
|
// 判断是否有需要展示的字段
|
|
|
boolean haveShowTitle = false;
|
|
|
List<Map<String, Object>> dataMapValues = new ArrayList<>();
|
|
|
for (String key : mapsTitle.keySet()) {
|
|
|
ReportAttributeDto reportAttributeDto = mapsAttributeTitle.get(key);
|
|
|
// 过滤掉没有开启开关的
|
|
|
- if (!reportAttributeDto.isShowOnOff()) {
|
|
|
+ if (reportAttributeDto == null || !reportAttributeDto.isShowOnOff()) {
|
|
|
continue;
|
|
|
}
|
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
@@ -271,7 +289,7 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
* @param deviceChildrenMap
|
|
|
*/
|
|
|
private void setReportTitle(ReportAttributeDto v, Map<String, ReportTitleDto> deviceChildrenMap){
|
|
|
- String classify = StringUtils.isEmpty(v.getClassify()) ? v.getAttributeName() + "isNull" : v.getClassify();
|
|
|
+ String classify = StringUtils.isEmpty(v.getClassify()) ? v.getAttributeName() + v.getDeviceParmId() + "isNull" : v.getClassify();
|
|
|
ReportTitleDto reportTitleDto = deviceChildrenMap.get(classify);
|
|
|
if (reportTitleDto == null) {
|
|
|
reportTitleDto = new ReportTitleDto();
|
|
@@ -283,7 +301,7 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
}
|
|
|
ReportTitleDto.DeviceChildren deviceChildren = new ReportTitleDto.DeviceChildren();
|
|
|
deviceChildren.setName(v.getAttributeName());
|
|
|
-
|
|
|
+ deviceChildren.setParamId(v.getDeviceParmId().toString());
|
|
|
// 检查是否有设置维度
|
|
|
List<ReportTitleDto.StatisticalDimension> statisticalDimensions = new ArrayList<>();
|
|
|
if (v.isShowMaxValue()){
|