工业级运维app手机api
fengxiang
2017-10-31 465d1f03afa058d9ce210f2fc48e5c06ce291a68
src/main/java/com/moral/monitor/controller/ScreenController.java
@@ -1,6 +1,7 @@
package com.moral.monitor.controller;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -13,19 +14,22 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.WebUtils;
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.WebUtils;
@RestController
@RequestMapping(value = "screen")
@CrossOrigin(origins = "*", maxAge = 3600)
public class ScreenController {
   /** The screen service. */
   @Autowired
    private ScreenService screenService;
   private ScreenService screenService;
   /**
    * Screen login.
    *
@@ -65,18 +69,79 @@
      resultMap.put("accountId", accountId);
      return resultMap;
   }
   @RequestMapping(value = "/month-average", method = RequestMethod.GET)
   public Map<String, Object> getDataByEquipmentMac(HttpServletRequest request) {
      Map<String, Object> parameters = WebUtils.getParametersStartingWith(request,null);
      Map<String, Object> resu =  screenService.getDataByEquipmentMac(parameters);
      return resu;
   /**
    * Gets the month data by equipment.
    *
    * @param request the request
    * @return the month data by equipment
    */
   @RequestMapping(value = "/month", method = RequestMethod.GET)
   public Map<String, Object> getMonthDataByEquipment(HttpServletRequest request) {
      Map<String, Object> result = new LinkedHashMap<String, Object>();
      try {
         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
         if (!(parameters.containsKey("mac") && parameters.containsKey("macKey"))) {
            result.put("msg", "参数不能为空!");
         } else {
            result = screenService.getMonthDataByEquipment(parameters);
         }
      } catch (Exception e) {
         e.printStackTrace();
         result.put("msg", "系统正忙,请稍后再试");
      }
      return result;
   }
   /**
    * Gets the average by all.
    *
    * @param request the request
    * @return the average by all
    */
   @RequestMapping(value = "/all-average", method = RequestMethod.GET)
   public Map<String, Object> getAverageByAll(HttpServletRequest request) {
      Map<String, Object> parameters = WebUtils.getParametersStartingWith(request,null);
      Map<String, Object> resu =  screenService.getAverageByAll(parameters);
      return resu;
      Map<String, Object> result = new LinkedHashMap<String, Object>();
      try {
         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
         if (!(parameters.containsKey("areaCode") && parameters.containsKey("accountId"))) {
            result.put("msg", "参数不能为空!");
         } else {
            result = screenService.getAverageByAll(parameters);
         }
      } catch (BusinessException be) {
         be.printStackTrace();
         result.put("msg", be.getMessage());
      } catch (Exception e) {
         e.printStackTrace();
         result.put("msg", "系统正忙,请稍后再试");
      }
      return result;
   }
   /**
    * Gets the equipment states.
    *
    * @param request the request
    * @return the equipment states
    */
   @RequestMapping(value = "/equipment-state", method = RequestMethod.GET)
   public Map<String, Object> getEquipmentStates(HttpServletRequest request) {
      Map<String, Object> result = new LinkedHashMap<String, Object>();
      try {
         Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
         if (!parameters.containsKey("accountId")) {
            result.put("msg", "参数不能为空!");
         } else {
            result = screenService.getEquipmentStates(parameters);
         }
      } catch (BusinessException be) {
         be.printStackTrace();
         result.put("msg", be.getMessage());
      } catch (Exception e) {
         e.printStackTrace();
         result.put("msg", "系统正忙,请稍后再试");
      }
      return result;
   }
}