Commit 249f7729 authored by 高建强's avatar 高建强

item:稳压泵启停状态图接口扩展天查询

parent fea17ead
......@@ -220,18 +220,16 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Override
public Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String bizOrgCode, String appKey, String product, String token) {
Map<String, Object> map = new HashMap<>();
List<String> timeHourList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, "MM-dd HH:mm");
Set<String> timeSet = new LinkedHashSet<>();
List<String> timeList = new ArrayList<>();
// 获取稳压泵
List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
// 获取各稳压泵数据,及时间戳
if (!CollectionUtils.isEmpty(list)) {
// 获取查询时间范围内的时间戳
List<String> timeHourList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, "MM-dd HH:mm");
Set<String> timeSet = new LinkedHashSet<>();
List<Map<String, Object>> yData = new ArrayList<>();
LinkedHashMap<String, List<Map<String, String>>> dataListMap = new LinkedHashMap<>();
list.forEach(x -> {
Map<String, Object> yMap = new HashMap<>();
List<Integer> yList = new ArrayList<>();
String name = x.get("name").toString();
yMap.put("name", name);
Object iotCode = x.get("iotCode");
String prefix = null;
if (x.get("iotCode") != null && iotCode.toString().length() > 8) {
......@@ -242,42 +240,65 @@ public class EmergencyServiceImpl implements IEmergencyService {
String json = JSON.toJSONString(responseModel.getResult());
List<Map<String, String>> dataList = (List<Map<String, String>>) JSONArray.parse(json);
if (!CollectionUtils.isEmpty(dataList)) {
dataList.stream().filter(y -> y.containsKey("createdTime")).forEach(z -> timeSet.add(z.get("createdTime")));
dataListMap.put(iotCode.toString(), dataList);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
// 数据时间排序
List<String> sortTimeList = new ArrayList<>(timeSet);
Collections.sort(sortTimeList);
// 数据时间截取,MM-dd HH:mm
List<String> sortTimeCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 3)).collect(Collectors.toList());
// 数据时间截取,MM-dd HH
List<String> sortTimeTmpCollectList = sortTimeList.stream().map(x -> x.substring(5, x.length() - 6)).collect(Collectors.toList());
// 组装x时间轴数据
List<String> timeList = new ArrayList<>();
timeHourList.forEach(t -> {
String strTime = t.substring(0, t.length() - 3);
if (sortTimeCollectList.contains(t)) {
timeList.add(t);
} else if (!sortTimeTmpCollectList.contains(strTime)) {
timeList.add(strTime + ":00");
sortTimeTmpCollectList.add(strTime);
}
});
// 遍历稳压泵,dataListMap获取各稳压泵数据,没有数据的进行补0
list.forEach(x -> {
Map<String, Object> yMap = new HashMap<>();
List<Integer> yList = new ArrayList<>();
String name = x.get("name").toString();
yMap.put("name", name);
Object iotCode = x.get("iotCode");
if (x.get("iotCode") != null) {
List<Map<String, String>> dataList = dataListMap.get(iotCode.toString());
if (!CollectionUtils.isEmpty(dataList)) {
Collections.reverse(dataList);
Map<String, List<Map<String, String>>> dataMap = dataList.stream().filter(y -> y.containsKey("createdTime")).collect(Collectors.groupingBy(e -> e.get("createdTime").substring(5, 16)));
List<Map<String, String>> yDataList = null;
String flag = "true";
for (String t : timeHourList) {
for (String t : timeList) {
List<Map<String, String>> data = dataMap.get(t);
String strTime = t.substring(0, t.length() - 3);
if (!CollectionUtils.isEmpty(data)) {
yDataList = data.stream().filter(o -> "true".equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList());
yList.add(!CollectionUtils.isEmpty(yDataList) && "true".equalsIgnoreCase(flag) ? 1 : 0);
flag = data.get(data.size() - 1).get(pressurePumpStart);
timeList.add(t);
} else {
if (!timeSet.contains(strTime) && !timeList.contains(strTime + ":00")) {
timeList.add(strTime + ":00");
yList.add(0);
}
}
timeSet.add(strTime);
}
} else {
timeHourList.forEach(t -> {
String strTime = t.substring(0, t.length() - 3);
if (!timeSet.contains(strTime)) {
timeList.add(strTime + ":00");
timeList.forEach(t -> {
yList.add(0);
}
timeSet.add(strTime);
});
}
}
yMap.put("data", yList);
yData.add(yMap);
} catch (Exception e) {
e.printStackTrace();
}
}
});
map.put("xData", timeList);
......
......@@ -1001,7 +1001,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
if ("正常".equals(String.valueOf(m.get("status")))) {
statusMap.put("level", "success");
} else {
statusMap.put("level", "warning");
statusMap.put("level", "error");
}
list1.add(statusMap);
map.put("status", list1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment