Commit 839bb6b3 authored by tianyiming's avatar tianyiming

四横八纵稳压泵启停指标修改

parent efcfbd62
...@@ -276,7 +276,8 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -276,7 +276,8 @@ public class SupervisionConfigureController extends AbstractBaseController {
} }
Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize()); Page page = new Page<>(commonPageable.getPageNumber(), commonPageable.getPageSize());
Page<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null); Page<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.getPressurePumpInfo(page, bizOrgCode, null);
List<Long> ids = new ArrayList(); List<Long> startTimeList = new ArrayList();
List<Long> stopTimeList = new ArrayList();
pressurePumpInfo.getRecords().stream().map(item -> { pressurePumpInfo.getRecords().stream().map(item -> {
item.put("monthStartNum", 0); item.put("monthStartNum", 0);
item.put("halfHourStartNum", 0); item.put("halfHourStartNum", 0);
...@@ -315,12 +316,16 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -315,12 +316,16 @@ public class SupervisionConfigureController extends AbstractBaseController {
ResponseModel twoHourEntity = null; ResponseModel twoHourEntity = null;
ResponseModel fourHourEntity = null; ResponseModel fourHourEntity = null;
ResponseModel oneHourEntity = null; ResponseModel oneHourEntity = null;
ResponseModel start = null;
ResponseModel stop = null;
try { try {
mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startDateStr, nowStrLong, prefix, suffix, pressurePumpStart); mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startDateStr, nowStrLong, prefix, suffix, pressurePumpStart);
halfHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), half, nowStrLong, prefix, suffix, pressurePumpStart); halfHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), half, nowStrLong, prefix, suffix, pressurePumpStart);
twoHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), two, nowStrLong, prefix, suffix, pressurePumpStart); twoHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), two, nowStrLong, prefix, suffix, pressurePumpStart);
fourHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), four, nowStrLong, prefix, suffix, pressurePumpStart); fourHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), four, nowStrLong, prefix, suffix, pressurePumpStart);
oneHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), one, nowStrLong, prefix, suffix, pressurePumpStart); oneHourEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), one, nowStrLong, prefix, suffix, pressurePumpStart);
start = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "true", pressurePumpStart);
stop = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "flase", pressurePumpStart);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -359,53 +364,90 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -359,53 +364,90 @@ public class SupervisionConfigureController extends AbstractBaseController {
int num = collect.size(); int num = collect.size();
item.put("oneHourStartNum", num); item.put("oneHourStartNum", num);
} }
if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
String json1 = JSON.toJSONString(start.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
item.put("start", collect.get(0).get("time"));
}
if (200 == stop.getStatus() && !ObjectUtils.isEmpty(stop.getResult())) {
String json1 = JSON.toJSONString(stop.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
item.put("stop", collect.get(0).get("time"));
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long nowDateTime = new Date().getTime();//当前时间戳 long nowDateTime = new Date().getTime();//当前时间戳
Map<String, String> stateMap = fireFightingSystemMapper.queryPressureNowStateBySpecificId((Long) item.get("id"));
ids.add((Long) item.get("id"));
boolean time = true; boolean time = true;
if (!ObjectUtils.isEmpty(stateMap) && stateMap.containsKey("update_date") && stateMap.containsKey("equipment_index_name")) { String startTime = null;
item.put("update_time", String.valueOf(stateMap.get("update_date")).replaceAll("T", " ")); String stopTime = null;
if (!ObjectUtils.isEmpty(stateMap.get("value"))) { Long start_time = 0L;
item.put("equipment_index_name", stateMap.get("equipment_index_name")); Long stop_time = 0L;
} else { Date startDate = null;
Date stopDate = null;
if (ObjectUtils.isEmpty(item.get("start")) && ObjectUtils.isEmpty(item.get("stop"))) {
item.put("equipment_index_name", "无信号"); item.put("equipment_index_name", "无信号");
} else {
if (!ObjectUtils.isEmpty(item.get("start"))) {
startTime = item.get("start").toString().substring(0, 19).replace("T", " ");
startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8);
startTimeList.add(startDate.getTime());
start_time = startDate.getTime();
item.put("startTime", startDate);
} else {
item.put("startTime", 0);
}
if (!ObjectUtils.isEmpty(item.get("stop"))) {
stopTime = item.get("stop").toString().substring(0, 19).replace("T", " ");
stopDate = DateUtils.dateAddHours(DateUtils.longStr2Date(stopTime), +8);
stopTimeList.add(stopDate.getTime());
stop_time = stopDate.getTime();
item.put("stopTime", stopDate);
} else {
item.put("stopTime", 0);
} }
if ("启动".equals(item.get("equipment_index_name"))) { if (!"0".equals(item.get("startTime"))) {
long update_time = 0L; if ("0".equals(item.get("stopTime"))) {
try { long res = nowDateTime - start_time;
update_time = sdf.parse(String.valueOf(stateMap.get("update_date")).replaceAll("T", " ")).getTime(); long diffMinute = res / 1000 / 60;
} catch (ParseException e) { if (diffMinute > 5) {
throw new RuntimeException(e); time = false;
} }
long res = nowDateTime - update_time; item.put("upTime", diffMinute);
item.put("equipment_index_name", "启动");
item.put("update_time", startDate);
} else {
String startOrStop = start_time - stop_time > 0 ? "start" : " stop";
if ("start".equals(startOrStop)) {
long res = nowDateTime - start_time;
long diffMinute = res / 1000 / 60; long diffMinute = res / 1000 / 60;
if (diffMinute > 5) { if (diffMinute > 5) {
time = false; time = false;
} }
item.put("upTime", diffMinute); item.put("upTime", diffMinute);
item.put("equipment_index_name", "启动");
item.put("update_time", startDate);
} else {
item.put("upTime", 0);
item.put("equipment_index_name", "停止");
item.put("update_time", stopDate);
}
}
} else {
item.put("upTime", 0);
} }
} }
item.put("stateDesc", Integer.parseInt(String.valueOf(item.get("isAlarm"))) == 0 && time ? "正常" : "异常"); item.put("stateDesc", Integer.parseInt(String.valueOf(item.get("isAlarm"))) == 0 && time ? "正常" : "异常");
return item; return item;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
List<Map<String, Object>> stateMap = fireFightingSystemMapper.queryStartAndStopBySpecificId(ids); List<Long> startCollect = startTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList());
long diffMinute = 0L; List<Long> stopCollect = stopTimeList.stream().sorted(Comparator.reverseOrder()).limit(1).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(stateMap)) { long res = 0L;
String startTime = stateMap.get(0).get("update_date").toString(); if (startCollect.size() > 0 && stopCollect.size() > 0) {
String endTime = stateMap.get(1).get("update_date").toString(); res = Math.abs(startCollect.get(0) - stopCollect.get(0));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long start = 0L;
long end = 0L;
try {
start = sdf.parse(startTime.replaceAll("T", " ")).getTime();
end = sdf.parse(endTime.replaceAll("T", " ")).getTime();
} catch (ParseException e) {
throw new RuntimeException(e);
} }
long res = Math.abs(start - end); long diffMinute = 0L;
diffMinute = res / 1000 / 60; diffMinute = res / 1000 / 60;
}
long finalDiffMinute = diffMinute; long finalDiffMinute = diffMinute;
pressurePumpInfo.getRecords().stream( pressurePumpInfo.getRecords().stream(
).map(item -> { ).map(item -> {
...@@ -534,7 +576,8 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -534,7 +576,8 @@ public class SupervisionConfigureController extends AbstractBaseController {
map.put("name", pressurePump.get("name")); map.put("name", pressurePump.get("name"));
String json1 = JSON.toJSONString(mounthEntity.getResult()); String json1 = JSON.toJSONString(mounthEntity.getResult());
List<Map<String, String>> list = (List<Map<String, String>>) JSONArray.parse(json1); List<Map<String, String>> list = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = list.stream().filter(t -> (t.containsKey("time") && t.get("time").substring(0, 10).equals(item.get("date")))&&((t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("true")) || (t.containsKey(pressurePumpStop) && t.get(pressurePumpStop).equals("true")))).collect(Collectors.toList()); List<Map<String, String>> collect = list.stream().filter(t -> (t.containsKey("time") && t.get("time").substring(0, 10).equals(item.get("date"))) && ((t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("true"))
|| (t.containsKey(pressurePumpStart) && t.get(pressurePumpStart).equals("false")))).collect(Collectors.toList());
map.put("value", collect.size()); map.put("value", collect.size());
map.put("id", pressurePump.get("id")); map.put("id", pressurePump.get("id"));
if (item.containsKey("yData")) { if (item.containsKey("yData")) {
...@@ -559,6 +602,7 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -559,6 +602,7 @@ public class SupervisionConfigureController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "稳压泵详情", produces = "application/json;charset=UTF-8", notes = "稳压泵详情") @ApiOperation(httpMethod = "GET", value = "稳压泵详情", produces = "application/json;charset=UTF-8", notes = "稳压泵详情")
public ResponseModel selectPressureDetails(@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode) { public ResponseModel selectPressureDetails(@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode) {
if (ObjectUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity(); ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) { if (!ValidationUtil.isEmpty(personIdentity)) {
...@@ -567,8 +611,65 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -567,8 +611,65 @@ public class SupervisionConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(null); return CommonResponseUtil.success(null);
} }
} }
List<Map<String, Object>> pressurePumps = fireFightingSystemMapper.selectPressureDetails(bizOrgCode); }
return CommonResponseUtil.success(pressurePumps); List<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.selectAllPressurePumpInfo(bizOrgCode);
pressurePumpInfo.stream().map(item -> {
String prefix = null;
String suffix = null;
String iotCode = item.get("iot_code").toString();
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
ResponseModel start = null;
ResponseModel stop = null;
try {
start = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "true", pressurePumpStart);
stop = iotFeign.selectOne(getAppKey(), getProduct(), getToken(), "1", prefix, suffix, "flase", pressurePumpStart);
} catch (Exception e) {
e.printStackTrace();
}
if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
String json1 = JSON.toJSONString(start.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
if (collect.size() > 0) {
String startTime = collect.get(0).get("time").substring(0, 19).replace("T", " ");
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8);
item.put("startTime", startDate);
} else {
item.put("startTime", "");
}
}
if (200 == stop.getStatus() && !ObjectUtils.isEmpty(stop.getResult())) {
String json1 = JSON.toJSONString(stop.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
if (collect.size() > 0) {
String stopTime = collect.get(0).get("time").substring(0, 19).replace("T", " ");
Date stopDate = DateUtils.dateAddHours(DateUtils.longStr2Date(stopTime), +8);
item.put("stopTime", stopDate);
} else {
item.put("stopTime", "");
}
}
return item;
}).collect(Collectors.toList());
return CommonResponseUtil.success(pressurePumpInfo);
// ReginParams reginParams = getSelectedOrgInfo();
// ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
// if (!ValidationUtil.isEmpty(personIdentity)) {
// bizOrgCode = personIdentity.getBizOrgCode();
// if (bizOrgCode == null) {
// return CommonResponseUtil.success(null);
// }
// }
// List<Map<String, Object>> pressurePumps = fireFightingSystemMapper.selectPressureDetails(bizOrgCode);
// return CommonResponseUtil.success(pressurePumps);
} }
......
package com.yeejoin.equipmanage.fegin; package com.yeejoin.equipmanage.fegin;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -25,4 +26,18 @@ public interface IotFeign { ...@@ -25,4 +26,18 @@ public interface IotFeign {
@RequestParam(value = "deviceName") String deviceName, @RequestParam(value = "deviceName") String deviceName,
@RequestParam(required = false, value = "fieldKey") String fieldKey); @RequestParam(required = false, value = "fieldKey") String fieldKey);
@RequestMapping(value = "v1/livedata/common/top", method = RequestMethod.GET, consumes = "application/json")
ResponseModel selectOne(
@RequestHeader("appKey") String appKey,
@RequestHeader("product") String product,
@RequestHeader("token") String token,
@RequestParam(value = "top") String top,
@RequestParam(value = "productKey") String productKey,
@RequestParam(value = "deviceName") String deviceName,
@RequestParam("FHS_FirePump_RunStatus") String key,
@RequestParam(required = false, value = "fieldKey") String fieldKey);
} }
...@@ -108,7 +108,7 @@ equipment.scrap.day=30 ...@@ -108,7 +108,7 @@ equipment.scrap.day=30
equipment.scrap.cron=0 0 9 * * ? equipment.scrap.cron=0 0 9 * * ?
# 稳压泵启动信号 # 稳压泵启动信号
equipment.pressurepump.start=FHS_PressurePump_Start equipment.pressurepump.start=FHS_FirePump_RunStatus
# 稳压泵停止信号 # 稳压泵停止信号
equipment.pressurepump.stop=FHS_PressurePump_Stop equipment.pressurepump.stop=FHS_PressurePump_Stop
......
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