工业级运维app手机api
xufenglei
2017-11-16 c95b4b1890598b1e451fa593c173d37952cff58d
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;
   }
}