|
@@ -14,6 +14,7 @@ import com.huaxu.entity.DayReportEntity;
|
|
|
import com.huaxu.entity.DeviceParmEntity;
|
|
|
import com.huaxu.entity.MonitorDataEntity;
|
|
|
import com.huaxu.entity.MonitorDataValueEntity;
|
|
|
+import com.huaxu.model.LoginUser;
|
|
|
import com.huaxu.util.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
@@ -106,8 +107,13 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
// 设置报表标题
|
|
|
Map<String, Integer> mapsTitle = new LinkedHashMap<>();
|
|
|
Map<String, ReportAttributeDto> mapsAttributeTitle = new LinkedHashMap<>();
|
|
|
+ Map<String,String> mapsDeviceParm = new LinkedHashMap<>();
|
|
|
// 获取标题
|
|
|
List<ReportTitleDto> reportTitleDtos = getReportTitle(reportDto, mapsTitle, mapsAttributeTitle, 1);
|
|
|
+ //按设备ID+设备属性 获取设备参数
|
|
|
+ for(ReportAttributeDto item :mapsAttributeTitle.values()) {
|
|
|
+ mapsDeviceParm.put(item.getDeviceId().toString() + "_" + item.getAttributeId(), item.getDeviceParmId().toString());
|
|
|
+ }
|
|
|
// 如果为空,把自定义表头返回回去
|
|
|
reportPage.setSize(historyData.getSize());
|
|
|
reportPage.setCurrent(historyData.getCurrent());
|
|
@@ -128,6 +134,8 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
int total = 0;
|
|
|
// 单个属性值
|
|
|
List<ReportDto> reportDtos = new LinkedList<>();
|
|
|
+
|
|
|
+
|
|
|
for (MonitorDataEntity item : historyData.getRecords()) {
|
|
|
ReportDto reportDtoTemp = new ReportDto();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -145,8 +153,9 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
ReportAttributeDto itemData2 = new ReportAttributeDto();
|
|
|
itemData2.setAttributeName(itemData.getAttributeName());
|
|
|
itemData2.setLatestValue(itemData.getDataValue());
|
|
|
-
|
|
|
- mapData.put(itemData.getAttributeId().toString(), itemData2);
|
|
|
+ if (mapsDeviceParm.containsKey(item.getDeviceId().toString() + "_" + itemData.getAttributeId().toString())) {
|
|
|
+ mapData.put(mapsDeviceParm.get(item.getDeviceId().toString() + "_" + itemData.getAttributeId().toString()), itemData2);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 获取统计维度的值
|
|
@@ -168,17 +177,16 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
// 判断是否有需要展示的字段
|
|
|
boolean haveShowTitle = false;
|
|
|
List<Map<String, Object>> dataMapValues = new ArrayList<>();
|
|
|
- for (String keyTilte : mapsTitle.keySet()) {
|
|
|
- ReportAttributeDto reportAttributeDto = mapsAttributeTitle.get(keyTilte);
|
|
|
+ for (String key : mapsTitle.keySet()) {
|
|
|
+ ReportAttributeDto reportAttributeDto = mapsAttributeTitle.get(key);
|
|
|
// 过滤掉没有开启开关的
|
|
|
if (reportAttributeDto == null || !reportAttributeDto.isShowOnOff()) {
|
|
|
continue;
|
|
|
}
|
|
|
- String key = deviceParmService.selectById(Integer.valueOf(keyTilte)).getAttributeId().toString();
|
|
|
Map<String, Object> map = new LinkedHashMap<>();
|
|
|
map.put("attributeName", mapData.get(key) == null ? key : mapData.get(key).getAttributeName());
|
|
|
if (reportAttributeDto.isShowLatestValue()) {
|
|
|
- map.put("latestValue" + mapsTitle.get(keyTilte), mapData.get(key) == null || mapData.get(key).getLatestValue() == null ?
|
|
|
+ map.put("latestValue" + mapsTitle.get(key), mapData.get(key) == null || mapData.get(key).getLatestValue() == null ?
|
|
|
"-" : doubleRoundValue(mapData.get(key).getLatestValue()));
|
|
|
haveShowTitle = true;
|
|
|
}
|
|
@@ -335,9 +343,9 @@ public abstract class AbstractReportService<M extends BaseMapper<T>, T> extends
|
|
|
int numCount = 0;
|
|
|
for (ReportAttributeDto reportAttributeDto : reportAttributeDtos2) {
|
|
|
// 判断开关是否开启
|
|
|
- if (reportAttributeDto.isShowOnOff()){
|
|
|
+ if (reportAttributeDto.isShowOnOff()) {
|
|
|
setReportTitle(reportAttributeDto, deviceChildrenMap);
|
|
|
- mapsAttributeTitle.put(reportAttributeDto.getDeviceParmId().toString(),reportAttributeDto);
|
|
|
+ mapsAttributeTitle.put(reportAttributeDto.getDeviceParmId().toString(), reportAttributeDto);
|
|
|
}
|
|
|
}
|
|
|
// 转换list返回
|