kaiyu
2020-09-22 0c99deb331cb0aa749f3b7c7d802d64d67672685
B/S获取传感器平均值测试
4 files modified
46 ■■■■ changed files
src/main/java/com/moral/controller/ScreenController.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/WebController.java 38 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/HistoryMinutelyServiceImpl.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/WebTokenServiceImpl.java 2 ●●● patch | view | raw | blame | history
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);
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);
    }
}
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"))) {
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;