From 60163c2fb5098fc522f8e80b131128d2c9a33e42 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Fri, 26 Jan 2018 14:44:05 +0800
Subject: [PATCH] 组织配置

---
 src/main/java/com/moral/controller/ReportController.java |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/moral/controller/ReportController.java b/src/main/java/com/moral/controller/ReportController.java
index 73c0897..d866077 100644
--- a/src/main/java/com/moral/controller/ReportController.java
+++ b/src/main/java/com/moral/controller/ReportController.java
@@ -2,35 +2,36 @@
 
 import static com.moral.common.util.ExportExcelUtils.exportData;
 import static com.moral.common.util.WebUtils.getParametersStartingWith;
+import static org.springframework.util.ObjectUtils.isEmpty;
 
 import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.springframework.beans.factory.annotation.Autowired;
-import static org.springframework.util.ObjectUtils.*;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.moral.common.exception.BusinessException;
+import com.moral.common.util.ValidateUtil;
 import com.moral.service.DeviceService;
 import com.moral.service.HistoryService;
 
 @RestController
-@RequestMapping(value = "report")
+@RequestMapping("report")
 @CrossOrigin(origins = "*", maxAge = 3600)
 public class ReportController {
 
-	@Autowired
+	@Resource
 	private HistoryService historyService;
 	
-	@Autowired
+	@Resource
 	private DeviceService deviceService;
 
 	@GetMapping("sensors-average")
@@ -41,26 +42,25 @@
 			Object mac = parameters.get("mac");
 			Object time = parameters.get("time");
 			Object type = parameters.get("type");
-			if (isEmpty(mac) || isEmpty(time) || isEmpty(type)) {
-				result.put("msg", "���������������������");
+			ValidateUtil.notNull(mac, "param.is.null");
+			ValidateUtil.notNull(time, "param.is.null");
+			ValidateUtil.notNull(type, "param.is.null");
+			List<Map<String, Object>> sensors = deviceService.getSensorsByDevice(mac.toString());
+			List<Map<String, Object>> sensorsAverage = historyService.getSensorsAverageByDevice4Report(parameters,sensors);
+			if (isEmpty(sensorsAverage)) {
+				result.put("msg", "���������������");
 			} else {
-				List<Map<String, Object>> sensors = deviceService.getSensorsByDevice(mac.toString());
-				List<Map<String, Object>> sensorsAverage = historyService.getSensorsAverageByDevice4Report(parameters,sensors);
-				if (isEmpty(sensorsAverage)) {
-					result.put("msg", "���������������");
-				} else {
-					String[][] exportColumn = new String[sensors.size() + 1][];
-					exportColumn[0] = new String[] { "������", "20", "time" };
-					for (int i = 0; i < sensors.size(); i++) {
-						String name = (String) sensors.get(i).get("name");
-						String key = (String) sensors.get(i).get("key");
-						exportColumn[i + 1] = new String[] { name, "10", key };
-					}
-					
-					OutputStream outputStream = exportData(response, time + "_" + mac + "_" + type, sensorsAverage, exportColumn);
-					outputStream.flush();
-					outputStream.close();
+				String[][] exportColumn = new String[sensors.size() + 1][];
+				exportColumn[0] = new String[] { "������", "20", "time" };
+				for (int i = 0; i < sensors.size(); i++) {
+					String name = (String) sensors.get(i).get("name");
+					String key = (String) sensors.get(i).get("key");
+					exportColumn[i + 1] = new String[] { name, "10", key };
 				}
+				
+				OutputStream outputStream = exportData(response, time + "_" + mac + "_" + type, sensorsAverage, exportColumn);
+				outputStream.flush();
+				outputStream.close();
 			}
 		} catch (BusinessException be) {
 			be.printStackTrace();

--
Gitblit v1.8.0