From d6a0ac523af2db9216d30fabf1063c095c5b41e1 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Fri, 06 Jul 2018 15:52:39 +0800
Subject: [PATCH] app接口
---
src/main/java/com/moral/controller/ScreenController.java | 39 +++++++++++++++++++++++++++++++++++++--
1 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java
index ee66467..064270e 100644
--- a/src/main/java/com/moral/controller/ScreenController.java
+++ b/src/main/java/com/moral/controller/ScreenController.java
@@ -60,7 +60,7 @@
@RequestMapping("/screen")
//@CrossOrigin(origins = "*", maxAge = 3600)
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
-@Api(tags = "Screen", description = "������������")
+@Api(tags = "Screen", description = "������������")
public class ScreenController {
public static Logger log = Logger.getLogger(ScreenController.class);
@Resource
@@ -566,6 +566,7 @@
@ApiImplicitParam(name = "dimension", value = "������(profession���region���monitorPoint������)", required = true, paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "sensorKey", value = "���������key", required = true, paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "accountId", value = "������id", required = true, paramType = "query", dataType = "int"),
+ @ApiImplicitParam(name = "timeType", value = "������������(month���day���hour������)", required = true, paramType = "query", dataType = "int"),
})
public ResultBean<List<Map<String, Object>>> getRegionRankingData(HttpServletRequest request){
Map<String, Object> parameters = getParametersStartingWith(request, null);
@@ -598,7 +599,7 @@
} else {
MonitorPoint monitorPoint = monitorPointService.queryMonitorPointById(Integer.parseInt(primaryKey));
- List<DeviceVersion> versionList = deviceVersionService.queryByOrgId(monitorPoint.getOrganizationId());
+ List<DeviceVersion> versionList = deviceVersionService.queryByMpointId(monitorPoint.getId());
if(versionList.size() > 0) {
List<Integer> versionNolist = versionList.stream().map(item -> {
return item.getVersion();
@@ -615,4 +616,38 @@
return new ResultBean(rtdLayout == null? new RealTimeDeviceLayout():rtdLayout);
}
+ @GetMapping("report_avg_data")
+ @ApiOperation(value = "������������������������������", notes = "������������������������������")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "monitorPoint", value = "���������id", required = true, paramType = "query", dataType = "String"),
+ @ApiImplicitParam(name = "mac", value = "������mac", required = false, paramType = "query", dataType = "String"),
+ @ApiImplicitParam(name = "sensorKey", value = "���������key,���������������������������", required = true, paramType = "query", dataType = "String"),
+ @ApiImplicitParam(name = "time", value = "������,������(���������2018-03)", required = true, paramType = "query", dataType = "String"),
+ })
+ public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgDataBySensorKey(HttpServletRequest request) throws Exception {
+ Map<String, Object> parameters = getParametersStartingWith(request, null);
+ int length = ((String)parameters.get("time")).split("-").length;
+ if (length == 2) {
+ parameters.put("type", "month");
+ } else if (length == 3){
+ parameters.put("type", "day");
+ }
+ parameters.put("monitorPointId", parameters.remove("monitorPoint"));
+ String[] sensorKeys = parameters.remove("sensorKey").toString().split(",");
+ parameters.put("sensors", Arrays.asList(sensorKeys));
+ List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters);
+
+ for (Map<String, Object> map : list) {
+ String time = map.get("time").toString();
+ time = time.substring(time.length() - 2);
+ map.put("time", Integer.valueOf(time));
+ List<Number> values = new ArrayList<Number>();
+ for (String string : sensorKeys) {
+ values.add((Number) map.remove(string));
+ }
+ map.put("values", values);
+ }
+ return new ResultBean<List<Map<String, Object>>>(list);
+ }
+
}
--
Gitblit v1.8.0