Commit 54b92cb1 authored by 高建强's avatar 高建强

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

parent dbbac0db
...@@ -27,6 +27,7 @@ public class DateUtils { ...@@ -27,6 +27,7 @@ public class DateUtils {
public static final String YEAR_PATTERN = "yyyy"; public static final String YEAR_PATTERN = "yyyy";
public static final String MINUTE_ONLY_PATTERN = "mm"; public static final String MINUTE_ONLY_PATTERN = "mm";
public static final String HOUR_ONLY_PATTERN = "HH"; public static final String HOUR_ONLY_PATTERN = "HH";
public static final String MONTH_DAY_HOUR_PATTERN = "MM-dd HH";
public static final String DATE_TIME_T_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; public static final String DATE_TIME_T_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static final String[] TWENTY_FOUR = new String[]{" 00:00:00"," 01:00:00"," 02:00:00", public static final String[] TWENTY_FOUR = new String[]{" 00:00:00"," 01:00:00"," 02:00:00",
" 03:00:00"," 04:00:00"," 05:00:00"," 06:00:00"," 07:00:00"," 08:00:00"," 09:00:00"," 10:00:00"," 11:00:00"," 12:00:00"," 13:00:00", " 03:00:00"," 04:00:00"," 05:00:00"," 06:00:00"," 07:00:00"," 08:00:00"," 09:00:00"," 10:00:00"," 11:00:00"," 12:00:00"," 13:00:00",
...@@ -1038,11 +1039,14 @@ public class DateUtils { ...@@ -1038,11 +1039,14 @@ public class DateUtils {
list.add(convertDateToString(startDate, pattern)); list.add(convertDateToString(startDate, pattern));
Date date = startDate; Date date = startDate;
while (true) { while (true) {
date = dateAddMinutes(date, 1); if (MONTH_DAY_HOUR_PATTERN.equals(pattern)) {
date = dateAddMinutes(date, 60);
} else {
date = dateAddMinutes(date, 1);
}
if (dateCompare(endDate, date) == 1) { if (dateCompare(endDate, date) == 1) {
list.add(convertDateToString(date, pattern)); list.add(convertDateToString(date, pattern));
} else { } else {
list.add(convertDateToString(endDate, pattern));
break; break;
} }
} }
......
...@@ -220,7 +220,9 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -220,7 +220,9 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Override @Override
public Map<String, Object> getPressurePumpStatusChart(String equipmentCode, String startTime, String endTime, String bizOrgCode, String appKey, String product, String token) { 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<>(); Map<String, Object> map = new HashMap<>();
List<String> timeList = DateUtils.getTimeStrListByStartAndEnd(startTime, endTime, "MM-dd HH:mm"); 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); List<Map<String, Object>> list = equipmentSpecificSerivce.getListByEquipmentCode(equipmentCode, bizOrgCode);
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
...@@ -243,16 +245,31 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -243,16 +245,31 @@ public class EmergencyServiceImpl implements IEmergencyService {
Collections.reverse(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))); 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; List<Map<String, String>> yDataList = null;
for (String t : timeList) { String flag = "true";
for (String t : timeHourList) {
List<Map<String, String>> data = dataMap.get(t); List<Map<String, String>> data = dataMap.get(t);
String strTime = t.substring(0, t.length() - 3);
if (!CollectionUtils.isEmpty(data)) { if (!CollectionUtils.isEmpty(data)) {
yDataList = data.stream().filter(o -> "true".equalsIgnoreCase(o.get(pressurePumpStart))).collect(Collectors.toList()); 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);
}
} }
yList.add(CollectionUtils.isEmpty(yDataList) ? 0 : 1); timeSet.add(strTime);
} }
} else { } else {
timeList.forEach(t -> { timeHourList.forEach(t -> {
yList.add(0); String strTime = t.substring(0, t.length() - 3);
if (!timeSet.contains(strTime)) {
timeList.add(strTime + ":00");
yList.add(0);
}
timeSet.add(strTime);
}); });
} }
} }
......
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