From c95b4b1890598b1e451fa593c173d37952cff58d Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Thu, 16 Nov 2017 11:14:21 +0800
Subject: [PATCH] 接口拆分

---
 src/main/java/com/moral/monitor/controller/ScreenController.java |   67 ++++++++++++++++++++++++++++++++-
 1 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/moral/monitor/controller/ScreenController.java b/src/main/java/com/moral/monitor/controller/ScreenController.java
index 4f6fe2d..1376544 100644
--- a/src/main/java/com/moral/monitor/controller/ScreenController.java
+++ b/src/main/java/com/moral/monitor/controller/ScreenController.java
@@ -9,25 +9,27 @@
 
 import javax.servlet.http.HttpServletRequest;
 
-import com.alibaba.fastjson.JSON;
-import com.moral.monitor.util.RedisUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.Resource;
 import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONReader;
 import com.alibaba.fastjson.TypeReference;
 import com.moral.monitor.entity.AccountEntity;
 import com.moral.monitor.service.ScreenService;
 import com.moral.monitor.util.BusinessException;
 import com.moral.monitor.util.Crypto;
+import com.moral.monitor.util.RedisUtil;
+import com.moral.monitor.util.ResourceUtil;
 import com.moral.monitor.util.WebUtils;
 
 @RestController
@@ -201,4 +203,65 @@
 		}
 		return result;
 	}
+	
+	@RequestMapping(value = "month-sensor-average", method = RequestMethod.GET)
+	public Map<String, Object> getMonthAverageBySensor(HttpServletRequest request) {
+		Map<String, Object> result = new HashMap<String, Object>();
+		try {
+			Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
+			if (!(parameters.containsKey("mac") && parameters.containsKey("macKey"))) {
+				result.put("msg", "���������������������");
+			} else {
+				result = screenService.getMonthAverageBySensor(parameters);
+			}
+		} catch (BusinessException be) {
+			be.printStackTrace();
+			result.put("msg", be.getMessage());
+		} catch (Exception e) {
+			e.printStackTrace();
+			result.put("msg", "���������������������������������������������������"+e.getMessage());
+		}
+		return result;
+	}
+
+	@RequestMapping(value = "day-aqi", method = RequestMethod.GET)
+	public Map<String, Object> getDayAQIBySensor(HttpServletRequest request) {
+		Map<String, Object> result = new HashMap<String, Object>();
+		try {
+			Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
+			if (!parameters.containsKey("mac")) {
+				result.put("msg", "���������������������");
+			} else {
+				result = screenService.getDayAQIBySensor(parameters);
+			}
+		} catch (BusinessException be) {
+			be.printStackTrace();
+			result.put("msg", be.getMessage());
+		} catch (Exception e) {
+			e.printStackTrace();
+			result.put("msg", "���������������������������������������������������"+e.getMessage());
+		}
+		return result;
+	}
+
+	@RequestMapping(value = "sensor-standard", method = RequestMethod.GET)
+	public Map<String, Object> getStandardBySensor(HttpServletRequest request) {
+		Map<String, Object> result = new HashMap<String, Object>();
+		try {
+			String macKey = request.getParameter("macKey");
+			if (ObjectUtils.isEmpty(macKey)) {
+				result.put("msg", "���������������������");
+			} else {
+				result.put("standard", ResourceUtil.getValue(macKey + "-standard"));
+			}
+		} catch (BusinessException be) {
+			be.printStackTrace();
+			result.put("msg", be.getMessage());
+		} catch (Exception e) {
+			e.printStackTrace();
+			result.put("msg", "���������������������������������������������������"+e.getMessage());
+		}
+		return result;
+	}
+
 }

--
Gitblit v1.8.0