|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.zc.business.controller; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
@ -207,6 +208,47 @@ public class DcDeviceController extends BaseController { |
|
|
|
return JSON.parseObject(response.body().string(), AjaxResult.class); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询当天设备指定属性列表 |
|
|
|
* @param deviceId 设备id |
|
|
|
* @param propertyId 属性id |
|
|
|
* @return 属性列表 |
|
|
|
*/ |
|
|
|
@ApiOperation("查询当天设备指定属性列表") |
|
|
|
@GetMapping("/properties/history/day/{deviceId}/{propertyId}") |
|
|
|
public AjaxResult queryDevicePropertiesOneDay(@PathVariable @Parameter(description = "设备ID") String deviceId, |
|
|
|
@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException { |
|
|
|
|
|
|
|
HashMap<String, Object> props = new HashMap<>(); |
|
|
|
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
|
|
|
|
props.put("terms[0].column", "timestamp$BTW"); |
|
|
|
ArrayList<String> dateList = new ArrayList<>(); |
|
|
|
// 添加当前日期的开始和结束时间到列表,用于设定时间范围
|
|
|
|
dateList.add(DateUtil.beginOfDay(new Date()).toString()); |
|
|
|
dateList.add(DateUtil.endOfDay(new Date()).toString()); |
|
|
|
// 将日期列表以逗号分隔并设置为查询条件的值
|
|
|
|
props.put("terms[0].value", String.join(",", dateList)); |
|
|
|
props.put("paging", false); |
|
|
|
AjaxResult ajaxResult = queryDeviceProperties(deviceId, propertyId, props); |
|
|
|
if (!ajaxResult.get("code").equals(200)) { |
|
|
|
return ajaxResult; |
|
|
|
} |
|
|
|
|
|
|
|
Object data = JSON.parseObject(queryDeviceProperties(deviceId, propertyId, props).get("data").toString()).get("data"); |
|
|
|
JSONArray dataArray = JSON.parseArray(data.toString()); |
|
|
|
List<Object> list = new ArrayList<>(); |
|
|
|
dataArray.forEach(o -> { |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
JSONObject jsonObject = JSON.parseObject(o.toString()); |
|
|
|
JSONObject formatValue = JSON.parseObject(jsonObject.get("formatValue").toString()); |
|
|
|
map.put("1",formatValue.get("1")); |
|
|
|
map.put("3",formatValue.get("3")); |
|
|
|
map.put("timestamp",jsonObject.get("timestamp")); |
|
|
|
list.add(map); |
|
|
|
}); |
|
|
|
return AjaxResult.success(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询设备指定属性列表 |
|
|
|
* |
|
|
|