Commit 1344bc5d authored by 张森's avatar 张森

30546 运行趋势页签接口开发1

parent 2856d284
...@@ -852,7 +852,7 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -852,7 +852,7 @@ public class SupervisionConfigureController extends AbstractBaseController {
} }
@PersonIdentify @PersonIdentify
@RequestMapping(value = "/operatingTrendWater", method = RequestMethod.GET) @RequestMapping(value = "/operatingTrendPressurePump", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "设备平台运行趋势 稳压泵启动频次趋势API", produces = "application/json;charset=UTF-8", notes = "设备平台运行趋势 稳压泵启动频次趋势API") @ApiOperation(httpMethod = "GET", value = "设备平台运行趋势 稳压泵启动频次趋势API", produces = "application/json;charset=UTF-8", notes = "设备平台运行趋势 稳压泵启动频次趋势API")
public ResponseModel operatingTrendPressurePump(@RequestParam(value = "startTime", required = false) String startTime, public ResponseModel operatingTrendPressurePump(@RequestParam(value = "startTime", required = false) String startTime,
......
...@@ -2345,16 +2345,22 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2345,16 +2345,22 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
@Override @Override
public EquipTrendResultVo operatingTrendPressurePump(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey) { public EquipTrendResultVo operatingTrendPressurePump(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey) {
// 定义一个DateTimeFormatter来匹配时间字符串的格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 使用parse方法将字符串解析为LocalDateTime对象
LocalDateTime startTimeLocal = LocalDateTime.parse(startTime, formatter);
LocalDateTime endTimeLocal = LocalDateTime.parse(endTime, formatter);
//横坐标数据
List<String> allTimeList = getHourlyTimes(startTimeLocal, endTimeLocal);
List<EquipTrendInfoVo> equipList = equipmentSpecificMapper.getEquipListByCode(equipCode, indexKey, bizOrgCode); List<EquipTrendInfoVo> equipList = equipmentSpecificMapper.getEquipListByCode(equipCode, indexKey, bizOrgCode);
List<String> allTimeList = new ArrayList<>();
ResponseModel entity = null; ResponseModel entity = null;
//返回数据组装定义 //返回数据组装定义
List<String> legends = new ArrayList<>(); List<String> legends = new ArrayList<>();
List<List<String>> threshold = new ArrayList<>(); List<List<String>> threshold = new ArrayList<>();
Map<String, Map<String, String>> dateValueMapInfo = new HashMap<>(); List<List<String>> yaxisList = new ArrayList<>();
EquipTrendResultVo equipTrendResultVo = new EquipTrendResultVo(); EquipTrendResultVo equipTrendResultVo = new EquipTrendResultVo();
for (EquipTrendInfoVo equipInfo : equipList) { for (EquipTrendInfoVo equipInfo : equipList) {
//返回数据组装 //返回数据组装
...@@ -2383,45 +2389,19 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2383,45 +2389,19 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) { if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) {
String json = JSON.toJSONString(entity.getResult()); String json = JSON.toJSONString(entity.getResult());
List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(json); List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(json);
List<String> values = new ArrayList<>();
Map<String, String> timeAndValue = new HashMap<>();
for (Map<String, String> mapList : listObject) { for (Map<String, String> mapList : listObject) {
if (mapList.containsKey(indexKey)) { if (mapList.containsKey(indexKey)) {
timeAndValue.put(mapList.get("time"), mapList.get(indexKey)); long countNum = allTimeList.stream().filter(item -> mapList.get("time").contains(item)).count();
allTimeList.add(mapList.get("time")); values.add(String.valueOf(countNum));
} }
} }
dateValueMapInfo.put(equipInfo.getId(), timeAndValue); yaxisList.add(values);
} }
} }
allTimeList = allTimeList.stream().distinct().collect(Collectors.toList()); equipTrendResultVo.setXAxisData(allTimeList);
equipTrendResultVo.setLegends(legends); equipTrendResultVo.setLegends(legends);
equipTrendResultVo.setThreshold(threshold); equipTrendResultVo.setThreshold(threshold);
List<List<String>> yaxisList = new ArrayList<>();
for (EquipTrendInfoVo info : equipList) {
//key:时间 value:数值
Map<String, String> dateValueDataMap = dateValueMapInfo.get(info.getId());
List<String> values = new ArrayList<>();
String lastValue = "0";
List<String> allTimeListNew = new ArrayList<>();
for (int i = 0; i < allTimeList.size(); i++) {
if (!ObjectUtils.isEmpty(dateValueDataMap) && dateValueDataMap.containsKey(allTimeList.get(i))) {
lastValue = dateValueDataMap.get(allTimeList.get(i));
}
values.add(lastValue);
try {
allTimeListNew.add(change(allTimeList.get(i)));
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
yaxisList.add(values);
equipTrendResultVo.setXAxisData(allTimeListNew);
}
equipTrendResultVo.setYAxisData(yaxisList); equipTrendResultVo.setYAxisData(yaxisList);
return equipTrendResultVo; return equipTrendResultVo;
} }
......
...@@ -3002,22 +3002,22 @@ ...@@ -3002,22 +3002,22 @@
a.id, a.id,
a.iot_code AS iotCode, a.iot_code AS iotCode,
a.`name` AS `name`, a.`name` AS `name`,
<if test="equipCode == '92011000'"> <if test="code == '92011000'">
max( CASE WHEN b.field_name = 'maxPressure' THEN b.field_value END ) AS maxNum, max( CASE WHEN b.field_name = 'maxPressure' THEN b.field_value END ) AS maxNum,
max( CASE WHEN b.field_name = 'minPressure' THEN b.field_value END ) AS minNum, max( CASE WHEN b.field_name = 'minPressure' THEN b.field_value END ) AS minNum,
concat('压力(', ifnull(c.unit, 'Mpa'), ')') as unit concat('压力(', ifnull(c.unit, 'Mpa'), ')') as unit
</if> </if>
<if test="(equipCode == '92032000' and indexKey == 'CAFS_WaterTank_WaterTankLevel') or (equipCode == '92031900')"> <if test="(code == '92032000' and indexKey == 'CAFS_WaterTank_WaterTankLevel') or (code == '92031900')">
max( CASE WHEN b.field_name = 'maxLevel' THEN b.field_value END ) AS maxNum, max( CASE WHEN b.field_name = 'maxLevel' THEN b.field_value END ) AS maxNum,
max( CASE WHEN b.field_name = 'minLevel' THEN b.field_value END ) AS minNum, max( CASE WHEN b.field_name = 'minLevel' THEN b.field_value END ) AS minNum,
concat('液位(', ifnull(c.unit, 'M'), ')') as unit concat('液位(', ifnull(c.unit, 'M'), ')') as unit
</if> </if>
<if test="equipCode == '92032000' and indexKey == 'CAFS_WaterTank_EffluentFlow'"> <if test="code == '92032000' and indexKey == 'CAFS_WaterTank_EffluentFlow'">
max( CASE WHEN b.field_name = 'maxLevel' THEN b.field_value END ) AS maxNum, max( CASE WHEN b.field_name = 'maxLevel' THEN b.field_value END ) AS maxNum,
max( CASE WHEN b.field_name = 'minLevel' THEN b.field_value END ) AS minNum, max( CASE WHEN b.field_name = 'minLevel' THEN b.field_value END ) AS minNum,
concat('出口流量(', ifnull(c.unit, 'L/S'), ')') as unit concat('出口流量(', ifnull(c.unit, 'L/S'), ')') as unit
</if> </if>
<if test="equipCode == '92010800'"> <if test="code == '92010800'">
'频次(次/小时)' as unit '频次(次/小时)' as unit
</if> </if>
FROM FROM
......
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