From beae673180dad056f7174cf8bcca12c943d1f4ed Mon Sep 17 00:00:00 2001 From: kaiyu <404897439@qq.com> Date: Tue, 22 Sep 2020 13:30:30 +0800 Subject: [PATCH] 接口请求方式更改 --- src/main/java/com/moral/controller/WebController.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/moral/controller/WebController.java b/src/main/java/com/moral/controller/WebController.java index fde7b89..5fef648 100644 --- a/src/main/java/com/moral/controller/WebController.java +++ b/src/main/java/com/moral/controller/WebController.java @@ -1,24 +1,25 @@ 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.RedisHashUtil; -import com.moral.common.util.WebTokenUtils; +import com.moral.common.util.*; import com.moral.common.webAnno.UserLoginToken; import com.moral.entity.AreaNames; +import com.moral.entity.MonitorPoint; 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 io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import jdk.nashorn.internal.runtime.logging.Logger; import org.springframework.web.bind.annotation.*; 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 +41,16 @@ WebTokenService webTokenService; @Resource RedisHashUtil redisHashUtil; + @Resource + HistoryMinutelyService historyMinutelyService; + @Resource + MonitorPointService monitorPointService; + + @UserLoginToken + @GetMapping("test") + public String add() { + return "test success!"; + } @PostMapping("login") public Map<String, Object> login(@RequestBody Map<String, Object> parameters) { @@ -183,9 +194,35 @@ return resultMap; } + @UserLoginToken - @GetMapping("test") - public String add() { - return "test success!"; + @GetMapping("report_avg_datas") + public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgData(HttpServletRequest request) + throws Exception { + Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); + //������������������������������������������������ + 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); + } + + @UserLoginToken + @GetMapping("monitorpoints-devices") + public ResultBean<List<MonitorPoint>> getMonitorPointsAndDevicesByRegion(HttpServletRequest request) + throws Exception { + Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); + List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters); + return new ResultBean<List<MonitorPoint>>(monitorPoints); } } -- Gitblit v1.8.0