|
@@ -124,23 +124,25 @@ public class CmcTemperatureController extends BaseController {
|
124
|
124
|
timeColumn.setNeedMerge(true);
|
125
|
125
|
timeColumn.setWidth(20);
|
126
|
126
|
entityList.add(timeColumn);
|
127
|
|
- cmcChannelService.listChannel(cmcChannel).forEach(channel -> {
|
|
127
|
+ List<CmcChannel> channelList = cmcChannelService.listChannel(cmcChannel);
|
|
128
|
+ channelList.forEach(channel -> {
|
128
|
129
|
ExcelExportEntity entity = new ExcelExportEntity(channel.getInfo(), channel.getSensorNo().toString());
|
129
|
130
|
entityList.add(entity);
|
130
|
131
|
});
|
131
|
|
- List<Map<String, Object>> dataList = prepareData(temperatureList);
|
|
132
|
+ List<Map<String, Object>> dataList = prepareData(channelList, temperatureList);
|
132
|
133
|
ExcelUtil.customExport(entityList, dataList);
|
133
|
134
|
}
|
134
|
135
|
|
135
|
|
- private static List<Map<String, Object>> prepareData(List<CmcTemperature> temperatureList) {
|
|
136
|
+ private static List<Map<String, Object>> prepareData(List<CmcChannel> channelList, List<CmcTemperature> temperatureList) {
|
136
|
137
|
Map<String, Map<Long, Float>> timeDataMap = new LinkedHashMap<>();
|
137
|
|
- Set<Long> locations = new TreeSet<>();
|
138
|
|
-
|
|
138
|
+ List<Long> sensors = new ArrayList<>();
|
|
139
|
+ channelList.forEach(channel -> {
|
|
140
|
+ sensors.add(channel.getSensorNo());
|
|
141
|
+ });
|
139
|
142
|
for (CmcTemperature cmcTemperature : temperatureList) {
|
140
|
143
|
Date datetime = cmcTemperature.getDatetime();
|
141
|
144
|
Long sensorNo = cmcTemperature.getSensorNo();
|
142
|
145
|
|
143
|
|
- locations.add(sensorNo);
|
144
|
146
|
String dateTme = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(datetime);
|
145
|
147
|
if (!timeDataMap.containsKey(dateTme)) {
|
146
|
148
|
timeDataMap.put(dateTme, new HashMap<>());
|
|
@@ -157,8 +159,8 @@ public class CmcTemperatureController extends BaseController {
|
157
|
159
|
rowData.put("Datetime", entry.getKey());
|
158
|
160
|
|
159
|
161
|
Map<Long, Float> locationData = entry.getValue();
|
160
|
|
- for (Long location : locations) {
|
161
|
|
- rowData.put(String.valueOf(location), locationData.get(location));
|
|
162
|
+ for (Long sensor : sensors) {
|
|
163
|
+ rowData.put(String.valueOf(sensor), locationData.get(sensor));
|
162
|
164
|
}
|
163
|
165
|
|
164
|
166
|
exportData.add(rowData);
|