Commit 1260a048 authored by 李秀明's avatar 李秀明

feat: 液位详情接口开发

parent 08f3c893
...@@ -543,6 +543,66 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -543,6 +543,66 @@ public class SupervisionConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(resMap); return CommonResponseUtil.success(resMap);
} }
@PersonIdentify
@RequestMapping(value = "/selectWaterLevelDetail", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "水池液位详情", produces = "application/json;charset=UTF-8", notes = "水池液位详情")
public ResponseModel selectWaterLevelDetail(@RequestParam(value = "equipmentSpecificId") String equipmentSpecificId,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime
) throws ParseException {
if (!StringUtil.isNotEmpty(equipmentSpecificId)) {
return CommonResponseUtil.success();
}
Map<String, Object> map = fireFightingSystemMapper.selectEquipmentSpecificById(equipmentSpecificId);
if (ObjectUtils.isEmpty(map) || ObjectUtils.isEmpty(map.get("iot_code"))) {
return CommonResponseUtil.success(null);
}
String iotCode = map.get("iot_code").toString();
String prefix, suffix;
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
ResponseModel mounthEntity;
try {
mounthEntity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startTime, endTime, prefix, suffix, "FHS_FirePoolDevice_WaterLevel");
} catch (Exception e) {
throw new BadRequest("请求物联平台失败,请稍后重试!");
}
List<Map<String, String>> result = new ArrayList<>();
assert mounthEntity != null;
if (200 == mounthEntity.getStatus()) {
String json = JSON.toJSONString(mounthEntity.getResult());
List<Map<String, String>> list = (List<Map<String, String>>) JSONArray.parse(json);
Collections.reverse(list);
if (!CollectionUtils.isEmpty(list)) {
result.addAll(list);
}
}
List<Map<String, String>> res = new ArrayList<>();
for (Map<String, String> m : result) {
Map<String, String> item = new HashMap<>();
item.put("time", change(String.valueOf(m.get("time"))));
for (String s : m.keySet()) {
if (!s.equals("time")) {
item.put("value", m.get(s));
item.remove(s);
}
}
res.add(item);
}
Map<String, Object> map1 = new HashMap<>();
map1.put("name", "水池液位");
map1.put("xData", res.stream().map(x -> x.get("time")).collect(Collectors.toList()));
map1.put("yData", res.stream().map(x -> x.get("value")).collect(Collectors.toList()));
Map<String, Object> resMap = new HashMap<>();
resMap.put("scyw", map1);
return CommonResponseUtil.success(resMap);
}
private String change(String time) throws ParseException { private String change(String time) throws ParseException {
//进行转化时区 //进行转化时区
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);
......
...@@ -4907,6 +4907,7 @@ ...@@ -4907,6 +4907,7 @@
from ( from (
(SELECT (SELECT
r.`name`, r.`name`,
wes.id as equipmentSpecificId,
IFNULL( rp.min_water_level, 0 ) AS minLevel, IFNULL( rp.min_water_level, 0 ) AS minLevel,
IFNULL( rp.max_water_level, 0 ) AS maxLevel, IFNULL( rp.max_water_level, 0 ) AS maxLevel,
-- IFNULL(max( CASE WHEN ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel' THEN ei.`value` END ),'--') AS nowLevel, -- IFNULL(max( CASE WHEN ei.equipment_index_key = 'FHS_FirePoolDevice_WaterLevel' or ei.equipment_index_key = 'FHS_WirelessliquidDetector_WaterLevel' THEN ei.`value` END ),'--') AS nowLevel,
...@@ -4942,6 +4943,7 @@ ...@@ -4942,6 +4943,7 @@
( (
SELECT SELECT
a.`name`, a.`name`,
a.equipmentSpecificId,
a.minLevel, a.minLevel,
a.maxLevel, a.maxLevel,
IFNULL( a.nowLevel, '--' ) nowLevel, IFNULL( a.nowLevel, '--' ) nowLevel,
...@@ -4955,6 +4957,7 @@ ...@@ -4955,6 +4957,7 @@
( (
SELECT SELECT
r.`name`, r.`name`,
wes.id as equipmentSpecificId,
IFNULL( rp.min_water_level, 0 ) AS minLevel, IFNULL( rp.min_water_level, 0 ) AS minLevel,
IFNULL( rp.max_water_level, 0 ) AS maxLevel, IFNULL( rp.max_water_level, 0 ) AS maxLevel,
(select (select
......
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