From f62ce761a5c2dd1f281acbf72a66fd752af3d75d Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Fri, 23 Jul 2021 14:19:51 +0800
Subject: [PATCH] 设备状态判断更新

---
 screen-api/src/main/java/com/moral/api/controller/WebController.java |  173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 173 insertions(+), 0 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/controller/WebController.java b/screen-api/src/main/java/com/moral/api/controller/WebController.java
new file mode 100644
index 0000000..6a3caac
--- /dev/null
+++ b/screen-api/src/main/java/com/moral/api/controller/WebController.java
@@ -0,0 +1,173 @@
+package com.moral.api.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.moral.api.service.DeviceService;
+import com.moral.api.service.HistoryDailyService;
+import com.moral.api.service.HistoryFiveMinutelyService;
+import com.moral.api.service.HistoryHourlyService;
+import com.moral.api.service.SysAreaService;
+import com.moral.constant.ResponseCodeEnum;
+import com.moral.constant.ResultMessage;
+import com.moral.util.WebUtils;
+
+/**
+ * web���������
+ * @author  moral
+ * @version  v1.0
+ * */
+@Slf4j
+@Api(tags = {"web���������"})
+@RestController
+@RequestMapping("/web")
+public class WebController {
+
+    @Autowired
+    private HistoryHourlyService historyHourlyService;
+
+    @Autowired
+    private HistoryDailyService historyDailyService;
+
+    @Autowired
+    private HistoryFiveMinutelyService historyFiveMinutelyService;
+
+    @Autowired
+    private DeviceService deviceService;
+
+    @Autowired
+    private SysAreaService sysAreaService;
+
+    /**
+     * @param request ������������
+     * @return ������������������������������������
+     * */
+    @GetMapping("getHourlyAqi")
+    @ApiOperation(value = "���������������AQI", notes = "���������������AQI")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+            @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String")
+    })
+    public ResultMessage getHourlyAqi(HttpServletRequest request) {
+        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+        if (!params.containsKey("mac")) {
+            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+        }
+        Map<String, Object> response = historyHourlyService.getHourlyAqiByMac(params.get("mac").toString());
+        return ResultMessage.ok(response);
+    }
+
+    /**
+     * @param request ������������
+     * @return ������������������������������������
+     * */
+    @GetMapping("getMonthAvg")
+    @ApiOperation(value = "������������������������������������", notes = "������������������������������������")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+            @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "sensorCode", value = "������code", required = true, paramType = "query", dataType = "String")
+    })
+    public ResultMessage getMonthAvg(HttpServletRequest request) {
+        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+        if (!params.containsKey("mac") || !params.containsKey("sensorCode")) {
+            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+        }
+        Map<String, Object> response = historyDailyService.getMonthAvg(params);
+        return ResultMessage.ok(response);
+    }
+
+    /**
+     * @param request ������������
+     * @return ������������������������������������
+     * */
+    @GetMapping("getWindData")
+    @ApiOperation(value = "������������������", notes = "������������������")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+            @ApiImplicitParam(name = "monitorPointId", value = "������id", required = true, paramType = "query", dataType = "String")
+    })
+    public ResultMessage getWindData(HttpServletRequest request) {
+        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+        if (!params.containsKey("monitorPointIds")) {
+            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+        }
+        String[] monitorPointIds = params.remove("monitorPointIds").toString().split(",");
+        params.put("monitorPointIds", monitorPointIds);
+        List<Object> response = historyFiveMinutelyService.getAreaWindData(params);
+        return ResultMessage.ok(response);
+    }
+
+    /**
+     * @param request ������������
+     * @return ������������������������������������
+     * */
+    @GetMapping("getMacSensors")
+    @ApiOperation(value = "������mac������������������������", notes = "������mac������������������������")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+            @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String")
+    })
+    public ResultMessage getMacSensors(HttpServletRequest request) {
+        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+        if (!params.containsKey("mac")) {
+            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+        }
+        Map<String, Object> response = deviceService.getSensorsByMac(params.get("mac").toString());
+        return ResultMessage.ok(response);
+    }
+
+    /**
+     * @param request ������������
+     * @return ������������������������������������
+     * */
+    @GetMapping("getTrendChartData")
+    @ApiOperation(value = "���������������������������������", notes = "���������������������������������")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+            @ApiImplicitParam(name = "mac", value = "������mac", required = true, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "sensorCode", value = "������code", required = true, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "type", value = "���������������������day���,������month���,������year���", required = true, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "time", value = "������������", required = true, paramType = "query", dataType = "String")
+    })
+    public ResultMessage getTrendChartData(HttpServletRequest request) {
+        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+        if (!params.containsKey("mac") || !params.containsKey("sensorCode") || !params.containsKey("type") || !params.containsKey("time")) {
+            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+        }
+        List<Map<String, Object>> response = deviceService.getTrendChartData(params);
+        return ResultMessage.ok(response);
+    }
+
+    /**
+     * @param request ������������
+     * @return ������������������������������������
+     * */
+    @GetMapping("getMapPath")
+    @ApiOperation(value = "������������������������������", notes = "������������������������������")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+            @ApiImplicitParam(name = "organizationId", value = "������id", required = true, paramType = "query", dataType = "String")
+    })
+    public ResultMessage getMapPath(HttpServletRequest request) {
+        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
+        if (!params.containsKey("organizationId")) {
+            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+        }
+        List<Map<String, Object>> response = sysAreaService.getMapPath(Integer.parseInt(params.get("organizationId").toString()));
+        return ResultMessage.ok(response);
+    }
+
+}

--
Gitblit v1.8.0