Commit 98dc229a authored by tianyiming's avatar tianyiming

Merge remote-tracking branch 'origin/develop_dl_plan6' into develop_dl_plan6_temp

# Conflicts: # amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/fegin/IotFeign.java
parents fc8d08e8 839bb6b3
...@@ -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,31 +364,77 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -359,31 +364,77 @@ 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;
Date startDate = null;
Date stopDate = null;
if (ObjectUtils.isEmpty(item.get("start")) && ObjectUtils.isEmpty(item.get("stop"))) {
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 { } else {
item.put("equipment_index_name", "无信号"); item.put("startTime", 0);
} }
if ("启动".equals(item.get("equipment_index_name"))) { if (!ObjectUtils.isEmpty(item.get("stop"))) {
long update_time = 0L; stopTime = item.get("stop").toString().substring(0, 19).replace("T", " ");
try { stopDate = DateUtils.dateAddHours(DateUtils.longStr2Date(stopTime), +8);
update_time = sdf.parse(String.valueOf(stateMap.get("update_date")).replaceAll("T", " ")).getTime(); stopTimeList.add(stopDate.getTime());
} catch (ParseException e) { stop_time = stopDate.getTime();
throw new RuntimeException(e); item.put("stopTime", stopDate);
} } else {
long res = nowDateTime - update_time; item.put("stopTime", 0);
long diffMinute = res / 1000 / 60; }
if (diffMinute > 5) { if (!"0".equals(item.get("startTime"))) {
time = false; if ("0".equals(item.get("stopTime"))) {
long res = nowDateTime - start_time;
long diffMinute = res / 1000 / 60;
if (diffMinute > 5) {
time = false;
}
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;
if (diffMinute > 5) {
time = false;
}
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);
}
} }
item.put("upTime", diffMinute); } 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 ? "正常" : "异常");
...@@ -394,23 +445,14 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -394,23 +445,14 @@ public class SupervisionConfigureController extends AbstractBaseController {
} }
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);
diffMinute = res / 1000 / 60;
} }
long diffMinute = 0L;
diffMinute = res / 1000 / 60;
long finalDiffMinute = diffMinute; long finalDiffMinute = diffMinute;
pressurePumpInfo.getRecords().stream( pressurePumpInfo.getRecords().stream(
).map(item -> { ).map(item -> {
...@@ -542,7 +584,8 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -542,7 +584,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")) {
...@@ -567,16 +610,74 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -567,16 +610,74 @@ 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) {
ReginParams reginParams = getSelectedOrgInfo(); if (ObjectUtils.isEmpty(bizOrgCode)) {
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity(); ReginParams reginParams = getSelectedOrgInfo();
if (!ValidationUtil.isEmpty(personIdentity)) { ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
bizOrgCode = personIdentity.getBizOrgCode(); if (!ValidationUtil.isEmpty(personIdentity)) {
if (bizOrgCode == null) { bizOrgCode = personIdentity.getBizOrgCode();
return CommonResponseUtil.success(null); if (bizOrgCode == null) {
return CommonResponseUtil.success(null);
}
} }
} }
List<Map<String, Object>> pressurePumps = fireFightingSystemMapper.selectPressureDetails(bizOrgCode); List<Map<String, Object>> pressurePumpInfo = fireFightingSystemMapper.selectAllPressurePumpInfo(bizOrgCode);
return CommonResponseUtil.success(pressurePumps); 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);
} }
......
...@@ -38,4 +38,18 @@ public interface IotFeign { ...@@ -38,4 +38,18 @@ public interface IotFeign {
@RequestParam(value = "current") Integer current, @RequestParam(value = "current") Integer current,
@RequestParam(value = "size") Integer size); @RequestParam(value = "size") Integer size);
@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);
} }
...@@ -115,7 +115,7 @@ equipment.scrap.day=30 ...@@ -115,7 +115,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