Commit 529ffc78 authored by 高建强's avatar 高建强

item:同步新旧接口,间隔不统一问题

parent e1a99945
...@@ -10,6 +10,7 @@ import com.yeejoin.equipmanage.common.utils.*; ...@@ -10,6 +10,7 @@ import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.config.PersonIdentify; import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper; import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IEmergencyService;
import com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmService; import com.yeejoin.equipmanage.service.IEquipmentSpecificAlarmService;
import com.yeejoin.equipmanage.service.IFireFightingSystemService; import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import com.yeejoin.equipmanage.service.ISupervisionVideoService; import com.yeejoin.equipmanage.service.ISupervisionVideoService;
...@@ -23,7 +24,6 @@ import org.springframework.util.CollectionUtils; ...@@ -23,7 +24,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.DateTimeUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
...@@ -55,6 +55,9 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -55,6 +55,9 @@ public class SupervisionConfigureController extends AbstractBaseController {
@Autowired @Autowired
private ISupervisionVideoService supervisionVideoService; private ISupervisionVideoService supervisionVideoService;
@Autowired
private IEmergencyService emergencyService;
@Value("${equipment.pressurepump.start}") @Value("${equipment.pressurepump.start}")
private String pressurePumpStart; private String pressurePumpStart;
...@@ -276,14 +279,14 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -276,14 +279,14 @@ public class SupervisionConfigureController extends AbstractBaseController {
Page<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null); Page<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null);
List<Long> startTimeList = new ArrayList(); List<Long> startTimeList = new ArrayList();
List<Long> stopTimeList = new ArrayList(); List<Long> stopTimeList = new ArrayList();
pressurePumpInfo.getRecords().stream().map(item -> { String prefix = null;
for (Map<String, Object> item : pressurePumpInfo.getRecords()) {
item.put("monthStartNum", 0); item.put("monthStartNum", 0);
item.put("halfHourStartNum", 0); item.put("halfHourStartNum", 0);
item.put("twoHourStartNum", 0); item.put("twoHourStartNum", 0);
item.put("fourHourStartNum", 0); item.put("fourHourStartNum", 0);
item.put("update_time", "--"); item.put("update_time", "--");
item.put("equipment_index_name", "--"); item.put("equipment_index_name", "--");
String prefix = null;
String suffix = null; String suffix = null;
String iotCode = item.get("iot_code").toString(); String iotCode = item.get("iot_code").toString();
if (iotCode.length() > 8) { if (iotCode.length() > 8) {
...@@ -426,17 +429,18 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -426,17 +429,18 @@ public class SupervisionConfigureController extends AbstractBaseController {
} else { } else {
item.put("sort",1); item.put("sort",1);
} }
return item; }
}).collect(Collectors.toList()); // List<Long> startCollect = startTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList());
List<Long> startCollect = startTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList()); // List<Long> stopCollect = stopTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList());
List<Long> stopCollect = stopTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList()); // long res = 0L;
long res = 0L; // if (startCollect.size() > 0 && stopCollect.size() > 0) {
if (startCollect.size() > 0 && stopCollect.size() > 0) { // res = Math.abs(startCollect.get(0) - stopCollect.get(0));
res = Math.abs(startCollect.get(0) - stopCollect.get(0)); // }
} // long diffMinute = 0L;
long diffMinute = 0L; // diffMinute = res / 1000 / 60;
diffMinute = res / 1000 / 60; // long finalDiffMinute = diffMinute;
long finalDiffMinute = diffMinute;
double finalDiffMinute = emergencyService.getPressurePumpIntervalTime(prefix, getAppKey(), getProduct(), getToken());
pressurePumpInfo.getRecords().stream( pressurePumpInfo.getRecords().stream(
).map(item -> { ).map(item -> {
item.put("startAndStopInterval", finalDiffMinute); item.put("startAndStopInterval", finalDiffMinute);
......
...@@ -58,5 +58,7 @@ public interface IEmergencyService { ...@@ -58,5 +58,7 @@ public interface IEmergencyService {
List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String equipmentCode, String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token); List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String equipmentCode, String nameKeys, String fieldKey, String bizOrgCode, String appKey, String product, String token);
double getPressurePumpIntervalTime(String prefix, String appKey, String product, String token);
Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus); Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus);
} }
...@@ -393,16 +393,14 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -393,16 +393,14 @@ public class EmergencyServiceImpl implements IEmergencyService {
String value = intervalDataList.get(0).get(pressurePumpStart); String value = intervalDataList.get(0).get(pressurePumpStart);
List<Map<String, String>> falseDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList()); List<Map<String, String>> falseDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
List<Map<String, String>> trueDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList()); List<Map<String, String>> trueDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(falseDataList) && !CollectionUtils.isEmpty(trueDataList)) { if (!CollectionUtils.isEmpty(trueDataList)) {
intervalTime1 = falseDataList.get(0).get("createdTime");
intervalTime2 = trueDataList.get(0).get("createdTime"); intervalTime2 = trueDataList.get(0).get("createdTime");
} }
if ("true".equalsIgnoreCase(value)) { if ("true".equalsIgnoreCase(value)) {
if (!CollectionUtils.isEmpty(trueDataList)) {
durationTime = intervalTime2;
}
if (!CollectionUtils.isEmpty(falseDataList)) { if (!CollectionUtils.isEmpty(falseDataList)) {
try { try {
durationTime = intervalTime2;
intervalTime1 = falseDataList.get(0).get("createdTime");
String stop5BeforeTime = DateUtils.convertDateToString(DateUtils.dateAddMinutes(DateUtils.convertStrToDate(intervalTime1, "yyyy-MM-dd HH:mm:ss"), -5), "yyyy-MM-dd HH:mm:ss"); String stop5BeforeTime = DateUtils.convertDateToString(DateUtils.dateAddMinutes(DateUtils.convertStrToDate(intervalTime1, "yyyy-MM-dd HH:mm:ss"), -5), "yyyy-MM-dd HH:mm:ss");
ResponseModel pipeResponseModel = iotFeign.selectListNew(appKey, product, token, prefix, null, stop5BeforeTime, intervalTime2, null, "FHS_PipePressureDetector_PipePressure"); ResponseModel pipeResponseModel = iotFeign.selectListNew(appKey, product, token, prefix, null, stop5BeforeTime, intervalTime2, null, "FHS_PipePressureDetector_PipePressure");
if (200 == pipeResponseModel.getStatus()) { if (200 == pipeResponseModel.getStatus()) {
...@@ -423,6 +421,10 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -423,6 +421,10 @@ public class EmergencyServiceImpl implements IEmergencyService {
if (!CollectionUtils.isEmpty(falseDataList) && !CollectionUtils.isEmpty(trueDataList)) { if (!CollectionUtils.isEmpty(falseDataList) && !CollectionUtils.isEmpty(trueDataList)) {
durationTime = trueDataList.get(0).get("createdTime"); durationTime = trueDataList.get(0).get("createdTime");
nowStrLong = falseDataList.get(0).get("createdTime"); nowStrLong = falseDataList.get(0).get("createdTime");
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String finalIntervalTime = intervalTime2;
List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSecconds(finalIntervalTime, x.get("createdTime"), "yyyy-MM-dd HH:mm:ss") >= 0).collect(Collectors.toList());
intervalTime1 = timeList.get(timeList.size() - 1).get("createdTime");
} }
} }
} }
...@@ -457,6 +459,41 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -457,6 +459,41 @@ public class EmergencyServiceImpl implements IEmergencyService {
} }
@Override @Override
public double getPressurePumpIntervalTime(String prefix, String appKey, String product, String token) {
Map<String, Object> map = new HashMap<>();
ResponseModel intervalResponseModel = iotFeign.topSingleField(appKey, product, token, "100", prefix, null, null, pressurePumpStart);
String nowStrLong = DateUtils.getNowStrLong();
String intervalTime1 = nowStrLong;
String intervalTime2 = nowStrLong;
if (200 == intervalResponseModel.getStatus()) {
String json = JSON.toJSONString(intervalResponseModel.getResult());
List<Map<String, String>> intervalDataList = (List<Map<String, String>>) JSONArray.parse(json);
if (!CollectionUtils.isEmpty(intervalDataList)) {
String value = intervalDataList.get(0).get(pressurePumpStart);
List<Map<String, String>> falseDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "false".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
List<Map<String, String>> trueDataList = intervalDataList.stream().filter(x -> x.containsKey("createdTime") && "true".equalsIgnoreCase(x.get(pressurePumpStart))).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(trueDataList)) {
intervalTime2 = trueDataList.get(0).get("createdTime");
}
if ("true".equalsIgnoreCase(value)) {
if (!CollectionUtils.isEmpty(falseDataList)) {
intervalTime1 = falseDataList.get(0).get("createdTime");
}
} else {
if (!CollectionUtils.isEmpty(falseDataList) && !CollectionUtils.isEmpty(trueDataList)) {
nowStrLong = falseDataList.get(0).get("createdTime");
// 获取最接近最新启动信号,且时间大于启动信号的停止信号时间值
String finalIntervalTime = intervalTime2;
List<Map<String, String>> timeList = falseDataList.stream().filter(x -> DateUtils.getDurationSecconds(finalIntervalTime, x.get("createdTime"), "yyyy-MM-dd HH:mm:ss") >= 0).collect(Collectors.toList());
intervalTime1 = timeList.get(timeList.size() - 1).get("createdTime");
}
}
}
}
return Math.ceil((double) Math.abs(DateUtils.getDurationSecconds(intervalTime1, intervalTime2, "yyyy-MM-dd HH:mm:ss")) / 60);
}
@Override
public Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus) { public Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus) {
return emergencyMapper.alarmList(page, bizOrgCode, types, emergencyLevels, name, cleanStatus, handleStatus); return emergencyMapper.alarmList(page, bizOrgCode, types, emergencyLevels, name, cleanStatus, handleStatus);
} }
......
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