fengxiang
2018-05-08 606c896c1b7c9d986cfb13d8464f3482160a1389
src/main/java/com/moral/controller/MobileController.java
@@ -2,6 +2,7 @@
import static com.moral.common.util.WebUtils.getParametersStartingWith;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -12,6 +13,7 @@
import com.moral.util.MessageUtils;
import com.taobao.api.ApiException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.web.bind.annotation.*;
import com.moral.common.bean.AppData;
@@ -75,14 +77,38 @@
      return new AppData<OperateUser>(operateUser); 
   }
   /**
    * Install device.终端采集
    *
    * @param device the device
    * @return the result bean
    */
    /**
     *
     * @param request
     * @param uid
     * @param deviceName
     * @param address
     * @param longitude
     * @param latitude
     * @param mac
     * @param monitorpoint
     * @return
     */
   @PostMapping("reportDevice")
   public AppData<String> installDevice(Device device) {
   public AppData<String> installDevice(
            HttpServletRequest request ,
            @RequestParam(value ="uid") Integer uid,
            @RequestParam(value ="device_name")  String deviceName,
            @RequestParam(value ="address")  String address,
            @RequestParam(value ="longitude")  double longitude,
            @RequestParam(value ="latitude")  double latitude,
            @RequestParam(value ="mac")  String mac,
            @RequestParam(value ="monitorpoint")  Integer monitorpoint
    ) {
       // device 适配
       Device device = new Device();
       device.setOperateUserId(uid);
       device.setName(deviceName);
       device.setAddress(address);
       device.setLongitude(longitude);
       device.setLatitude(latitude);
       device.setMac(mac);
       device.setMonitorPointId(monitorpoint);
      deviceService.saveOrUpdateDevice(device);
      return new AppData<String>("");
   }
@@ -109,9 +135,12 @@
    * @return the device by mac
    */
   @GetMapping("getEquInfoByMac")
   public AppData<Device> getDeviceByMac(@RequestParam(value="mac", required=true)String mac) {
      Device device = deviceService.getDeviceByMac(mac);
      return new AppData<Device>(device);
   public AppData<Map> getDeviceByMac(@RequestParam(value="mac", required=true)String mac) {
      Device device = deviceService.getDeviceByMac(mac,false);//不从缓存取
      Map<String,Object> deviceMap = new HashMap<>(BeanMap.create(device));
      deviceMap.put("monitorpointDetail",deviceMap.get("monitorPoint"));
      deviceMap.remove("monitorPoint");
      return new AppData<Map>(deviceMap);
   }
   /**
@@ -120,7 +149,7 @@
    * @param request the area name
    * @return the monitor points by area name
    */
   @PostMapping("getMpointsByAreaName")
   @GetMapping("getMpointsByAreaName")
   public AppData<List<MonitorPoint>> getMonitorPointsByAreaName(HttpServletRequest request) {
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsByAreaName(parameters);
@@ -133,7 +162,7 @@
    * @param request the area name
    * @return the organizations by area name
    */
   @PostMapping("getOrgsByAreaName")
   @GetMapping("getOrgsByAreaName")
   public AppData<List<Organization>> getOrganizationsByAreaName(HttpServletRequest request) {
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      List<Organization> organizations = organizationService.getOrganizationsByAreaName(parameters);
@@ -190,9 +219,10 @@
   }
   /**
    * Send SMS
    *
    * @param mobile
    * @param username
    * @param password
    * @param code
    * @return
    */
   @PostMapping("password")