ZhuDongming
2019-11-28 70830c5b2e96cc1c76d4adb88ddced55e7476547
src/main/java/com/moral/controller/MobileController.java
@@ -13,6 +13,7 @@
import org.springframework.cglib.beans.BeanMap;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -20,6 +21,7 @@
import com.moral.common.bean.AppData;
import com.moral.common.bean.ResultBean;
import com.moral.common.util.Crypto;
import com.moral.common.util.WebUtils;
import com.moral.entity.Account;
import com.moral.entity.Device;
import com.moral.entity.MonitorPoint;
@@ -117,7 +119,8 @@
    */
   @RequestMapping("reportDevice")
   public AppData<String> installDevice(EquDeviceAdapter equDeviceAdapter) {
      deviceService.addOrModify(equDeviceAdapter.toDevice());
      //deviceService.addOrModify(equDeviceAdapter.toDevice());
      deviceService.saveOrUpdate4Mobile(equDeviceAdapter.toDevice(), equDeviceAdapter.getDeviceProperty());
      return new AppData<String>("");
   }
@@ -305,9 +308,9 @@
   @GetMapping("sensors")
   @ApiOperation(value = "获取设备传感器信息")
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "deviceVersionId", value = "设备版本Id", required = true, paramType = "query", dataType = "Integer"),
         @ApiImplicitParam(name = "deviceVersionId", value = "设备版本Id", required = true, paramType = "query", dataType = "int"),
         @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "deviceId", value = "设备id", required = true, paramType = "query", dataType = "Integer"),
         @ApiImplicitParam(name = "deviceId", value = "设备id", required = true, paramType = "query", dataType = "int"),
   })
   public ResultBean<List<Map<String, Object>>> getSensorsDataByDevice(HttpServletRequest request){
      Map<String, Object> parameters = getParametersStartingWith(request, null);
@@ -320,11 +323,55 @@
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "sensorKey", value = "传感器key", required = true, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "size", value = "获取数据条数", required = true, paramType = "query", dataType = "Integer"),
         @ApiImplicitParam(name = "size", value = "获取数据条数", required = true, paramType = "query", dataType = "int"),
   })
   public ResultBean<List<Map<String, Object>>> getSensorDataBySensorKey(HttpServletRequest request){
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      List<Map<String, Object>> sensors = historyService.getSensorDataBySensorKey(parameters);
      return new ResultBean<List<Map<String, Object>>>(sensors);
   }
   @GetMapping("profession-provincecode")
   @ApiOperation(value = "根据省code返回行业数据", notes = "根据省code返回行业数据")
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "provinceCode", value = "省code", required = true, paramType = "query", dataType = "String")
   })
   public ResultBean<List<Profession>> getProfessionByProvinceCode(HttpServletRequest request){
      Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
      List<Profession> professions = professionService.getProfessiontList(parameters);
      return new ResultBean<List<Profession>>(professions);
   }
   @PostMapping("update-maintenance")
   @ApiOperation(value = "设备状态从离线更新为维保", notes = "设备状态从离线更新为维保")
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "id", value = "设备ID", required = true, paramType = "query", dataType = "int") ,
         @ApiImplicitParam(name = "old_state", value = "旧的设备状态", required = true, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "new_state", value = "新的设备状态", required = true, paramType = "query", dataType = "String")
   })
   public ResultBean offLinToMaintenance(HttpServletRequest request) {
      Map<String, Object> parameters = getParametersStartingWith(request, null);
      deviceService.offLinToMaintenance(parameters);
      ResultBean resultBean = new ResultBean(parameters);
      return resultBean;
   }
   @GetMapping("mointorPointRank")
   @ApiOperation(value = "获取站点排名", notes = "获取站点排名")
   @ApiImplicitParams(value = {
         @ApiImplicitParam(name = "accountId", value = "账号id", required = true, paramType = "query", dataType = "String"),
         @ApiImplicitParam(name = "sensor", value = "因子", required = true, paramType = "query", dataType = "String")
   })
   public ResultBean<List<Map<String, Object>>> getMointorPointRank(HttpServletRequest request){
      Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null);
      String id = parameters.get("accountId").toString();
      String sensor = parameters.get("sensor").toString();
      Map<String, Object> account = accountService.getOrganizationIdByAccountId(id);
      //通过组织id来获取站点和设备信息
      account.put("sensor", sensor);
      List<Map<String, Object>> returnList = historyService.getMointorPointRankByOrganizationId(account);
      return new ResultBean<List<Map<String, Object>>>(returnList);
   }
}