From 0c99deb331cb0aa749f3b7c7d802d64d67672685 Mon Sep 17 00:00:00 2001 From: kaiyu <404897439@qq.com> Date: Tue, 22 Sep 2020 08:34:41 +0800 Subject: [PATCH] B/S获取传感器平均值测试 --- src/main/java/com/moral/controller/WebController.java | 38 +++++++++++++++++++++++++++++++------- 1 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/moral/controller/WebController.java b/src/main/java/com/moral/controller/WebController.java index fde7b89..1450043 100644 --- a/src/main/java/com/moral/controller/WebController.java +++ b/src/main/java/com/moral/controller/WebController.java @@ -1,17 +1,16 @@ package com.moral.controller; import com.auth0.jwt.exceptions.JWTDecodeException; +import com.moral.common.bean.ResultBean; import com.moral.common.exception.WebAuthException; import com.moral.common.util.BeanUtils; +import com.moral.common.util.ParameterUtils; import com.moral.common.util.RedisHashUtil; import com.moral.common.util.WebTokenUtils; import com.moral.common.webAnno.UserLoginToken; import com.moral.entity.AreaNames; import com.moral.entity.Organization; -import com.moral.service.AccountService; -import com.moral.service.DictionaryDataService; -import com.moral.service.OrganizationService; -import com.moral.service.WebTokenService; +import com.moral.service.*; import com.moral.util.LatLngTransformation; import jdk.nashorn.internal.runtime.logging.Logger; import org.springframework.web.bind.annotation.*; @@ -19,6 +18,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,6 +40,14 @@ WebTokenService webTokenService; @Resource RedisHashUtil redisHashUtil; + @Resource + HistoryMinutelyService historyMinutelyService; + + @UserLoginToken + @GetMapping("test") + public String add() { + return "test success!"; + } @PostMapping("login") public Map<String, Object> login(@RequestBody Map<String, Object> parameters) { @@ -183,9 +191,25 @@ return resultMap; } + @UserLoginToken - @GetMapping("test") - public String add() { - return "test success!"; + @PostMapping("report_avg_datas") + public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgData(HttpServletRequest request,@RequestBody Map<String, Object> parameters) + throws Exception { + //������������������������������������������������ + ParameterUtils.getTimeType4Time(parameters); + Object sensorKey = parameters.remove("sensorKey"); + parameters.put("sensors", Arrays.asList(sensorKey)); + 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)); + if(parameters.get("type").equals("day")){ + map.put("time", Integer.valueOf(time)+1); + } + map.put("value", map.remove(sensorKey)); + } + return new ResultBean<List<Map<String, Object>>>(list); } } -- Gitblit v1.8.0