From 239927b057f65a040594f7a4cb08c8881b303797 Mon Sep 17 00:00:00 2001
From: cjl <276999030@qq.com>
Date: Fri, 18 Aug 2023 14:52:16 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/cjl-230812' into cjl-230812
---
screen-api/src/main/java/com/moral/api/controller/DeviceController.java | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 108 insertions(+), 1 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/controller/DeviceController.java b/screen-api/src/main/java/com/moral/api/controller/DeviceController.java
index 0e277e7..deea43e 100644
--- a/screen-api/src/main/java/com/moral/api/controller/DeviceController.java
+++ b/screen-api/src/main/java/com/moral/api/controller/DeviceController.java
@@ -2,18 +2,31 @@
import com.moral.api.entity.Sensor;
import com.moral.api.pojo.vo.alarm.AlarmLevelVO;
+import com.moral.api.service.DeviceService;
+import com.moral.api.service.HistoryDailyService;
+import com.moral.api.service.HistoryHourlyService;
import com.moral.api.service.OrganizationUnitAlarmService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
+import com.moral.util.WebUtils;
+
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.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
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;
/**
* @ClassName AlarmController
@@ -32,12 +45,106 @@
@Autowired
OrganizationUnitAlarmService organizationUnitAlarmService;
+ @Autowired
+ private HistoryHourlyService historyHourlyService;
+
+ @Autowired
+ private HistoryDailyService historyDailyService;
+
+ @Autowired
+ private DeviceService deviceService;
+
+ /**
+ * @Description: ������mac������������������
+ * @Param: [mac]
+ * @return: com.moral.constant.ResultMessage
+ * @Author: ���������
+ * @Date: 2021/8/23
+ */
@GetMapping("queryAlarmByMac")
- public ResultMessage queryAlarmByMac(String mac){
+ public ResultMessage queryAlarmByMac(String mac) {
+ if(mac==null)
+ return new ResultMessage(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg(),null);
List<Sensor> sensors = organizationUnitAlarmService.queryAlarmLevel(mac);
AlarmLevelVO vo = AlarmLevelVO.convert(sensors);
return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(), vo);
}
+ /**
+ * @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 params ������������
+ * @return ������������������������������������
+ */
+ @PostMapping("getMacSensors")
+ @ApiOperation(value = "������������mac���������������", notes = "������������mac���������������")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+ @ApiImplicitParam(name = "macs", value = "������mac���������������������", required = true, paramType = "query", dataType = "List")
+ })
+ public ResultMessage getMacSensors(@RequestBody Map<String, Object> params) {
+ if (!params.containsKey("macs")) {
+ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+ }
+ Map<String, Object> response = deviceService.getSensorsByMac(params);
+ return ResultMessage.ok(response);
+ }
+
+ /**
+ * @param params ������������
+ * @return ������������������������������������
+ */
+ @PostMapping("getTrendChartData")
+ @ApiOperation(value = "���������������������������������", notes = "���������������������������������.")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+ @ApiImplicitParam(name = "macs", value = "������mac���������������������", required = true, paramType = "body", dataType = "list"),
+ @ApiImplicitParam(name = "sensorCode", value = "������code", required = true, paramType = "body", dataType = "String"),
+ @ApiImplicitParam(name = "type", value = "���������������������day���,������month���,������year���", required = true, paramType = "body", dataType = "String"),
+ @ApiImplicitParam(name = "times", value = "���������������������2021-07-29������������2021-07������������2021������������������������", required = true, paramType = "body", dataType = "List")
+ })
+ public ResultMessage getTrendChartData(@RequestBody Map<String, Object> params) {
+ if (!params.containsKey("macs") || !params.containsKey("sensorCode") || !params.containsKey("type") || !params.containsKey("times")) {
+ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+ }
+ List<Map<String, Object>> response = deviceService.getTrendChartDataV2(params);
+ return ResultMessage.ok(response);
+ }
}
--
Gitblit v1.8.0