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 +++++++++++++++++++++++++++++++------- src/main/java/com/moral/service/impl/WebTokenServiceImpl.java | 2 +- src/main/java/com/moral/controller/ScreenController.java | 4 ++++ src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java | 2 -- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/moral/controller/ScreenController.java b/src/main/java/com/moral/controller/ScreenController.java index 637e37d..11141a5 100644 --- a/src/main/java/com/moral/controller/ScreenController.java +++ b/src/main/java/com/moral/controller/ScreenController.java @@ -695,6 +695,7 @@ public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgData(HttpServletRequest request) throws Exception { Map<String, Object> parameters = getParametersStartingWith(request, null); + //������������������������������������������������ ParameterUtils.getTimeType4Time(parameters); parameters.put("monitorPointId", parameters.remove("monitorPoint")); Object sensorKey = parameters.remove("sensorKey"); @@ -714,6 +715,9 @@ return new ResultBean<List<Map<String, Object>>>(list); } + + + @GetMapping("report_alarm_datas") public ResultBean<List<Map<String, Object>>> getAlarmData(HttpServletRequest request) throws Exception { Map<String, Object> parameters = getParametersStartingWith(request, null); 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); } } diff --git a/src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java b/src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java index ed28222..ff5c58b 100644 --- a/src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java +++ b/src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java @@ -385,8 +385,6 @@ @Override public void convertQueryParam(Map<String, Object> parameters) throws ParseException { if (!parameters.containsKey("field")) { - // String type = (String) parameters.get("type"); - // parameters.putAll(getElementByType(type)); ParameterUtils.getElementByType(parameters); if (parameters.containsKey("timeUnits")) { if ("minutely".equals(parameters.get("timeUnits"))) { diff --git a/src/main/java/com/moral/service/impl/WebTokenServiceImpl.java b/src/main/java/com/moral/service/impl/WebTokenServiceImpl.java index 49eff11..71cde4d 100644 --- a/src/main/java/com/moral/service/impl/WebTokenServiceImpl.java +++ b/src/main/java/com/moral/service/impl/WebTokenServiceImpl.java @@ -17,7 +17,7 @@ token= JWT.create() .withIssuer("qxpc")//��������� .withIssuedAt(new Date())//������������ - .withExpiresAt(DateUtils.addHours(new Date(),1))//������������ + .withExpiresAt(DateUtils.addHours(new Date(),24))//������������ .withClaim("aid",id)//������������ .sign(Algorithm.HMAC256(SECRET)); return token; -- Gitblit v1.8.0