From 6d1509ab9e5aa911a6a2cdc2ab5a0887210f0b41 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Thu, 12 Jul 2018 16:07:38 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/com/moral/controller/ScreenController.java | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java index e549d66..759c759 100644 --- a/src/main/java/com/moral/controller/ScreenController.java +++ b/src/main/java/com/moral/controller/ScreenController.java @@ -28,14 +28,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import org.xml.sax.InputSource; import com.alibaba.fastjson.JSONArray; @@ -58,9 +51,9 @@ */ @RestController @RequestMapping("/screen") -//@CrossOrigin(origins = "*", maxAge = 3600) +@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 +559,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 +592,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(); @@ -609,10 +603,44 @@ } } } - if(rtdLayout.getDefaultMonitorItems().size() == 0 ) { + if(rtdLayout!=null && rtdLayout.getDefaultMonitorItems().size() == 0 ) { rtdLayout.getDefaultMonitorItems().addAll(rtdLayout.getCoreMonitorItems()); } - return new ResultBean(rtdLayout); + 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