fengxiang
2018-02-05 5c6a71fbcad27a637c775358d1004ddb95f55729
src/main/java/com/moral/controller/ScreenController.java
@@ -8,19 +8,28 @@
import java.io.*;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSONObject;
import com.moral.common.bean.PageResult;
import com.moral.common.xml.Version;
import com.moral.entity.Account;
import com.moral.entity.MapBounds;
import com.moral.entity.MonitorPoint;
import com.moral.service.*;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;
@@ -28,11 +37,7 @@
import com.alibaba.fastjson.TypeReference;
import com.moral.common.bean.ResultBean;
import com.moral.common.util.ValidateUtil;
import com.moral.service.AccountService;
import com.moral.service.HistoryMinutelyService;
import com.moral.service.DeviceService;
import com.moral.service.HistoryService;
import com.moral.service.MachineActivateService;
import org.springframework.web.servlet.ModelAndView;
import org.xml.sax.InputSource;
/**
@@ -42,6 +47,15 @@
@RequestMapping("/screen")
//@CrossOrigin(origins = "*", maxAge = 3600)
public class ScreenController {
   public  static Logger log = Logger.getLogger(ScreenController.class);
   @Resource
   AreaService areaService;
   @Resource
   SensorService sensorService;
   @Resource
   MonitorPointService monitorPointService;
   /** The screen service. */
   @Resource
@@ -138,7 +152,7 @@
   /**
    * Gets the standard by sensor.获取某传感器标准值
    *
    * @param request
    * @param macKey
    *            the request
    * @return the standard by sensor
    */
@@ -263,4 +277,54 @@
      }
      return version;
   }
   @RequestMapping(value = "/map-page", method = RequestMethod.GET)
   public ModelAndView map(ModelAndView model, @RequestParam("areaCode")int code, @RequestParam("accountId")int accountId){
      Account account = accountService.getAccountById(accountId);
      String regionName = areaService.selectFullNameByCode(code);
      if(account!=null&&regionName!=null){
         Object sensors = sensorService.queryAll();
         JSONObject params = new JSONObject();
         params.put("regionCode",code);
         params.put("regionName",regionName);
         params.put("accountId", accountId);
         params.put("orgId", account.getOrganizationId());
         params.put("sensors", sensors);
         String paramsJson = params.toJSONString();
         model.addObject("mapParams",paramsJson);
         model.setViewName("map");
         return model;
      } else {
         StringBuilder msg = new StringBuilder();
         msg.append(" param[0] areaCode:");
         msg.append(code);
         msg.append(" param[0] accountId:");
         msg.append(accountId);
         log.warn(msg);
         model.setViewName("401");
         return model;
      }
   }
   @RequestMapping(value="/get-monitorpoints",method = RequestMethod.GET)
   @ResponseBody
   public ResultBean getMonitorpointList(@RequestParam("orgId")String orgId,MapBounds mapBounds){
      ResultBean<List<MonitorPoint>> resultBean = new ResultBean();
      Map<String,Object> paramMap = new HashMap<String, Object>();
      paramMap.put("orgId", orgId);
      paramMap.put("mapBounds",mapBounds);
      List<MonitorPoint> list = monitorPointService.queryWithStateByMap(paramMap);
      resultBean.setData(list);
      resultBean.setCode(ResultBean.SUCCESS);
      return resultBean;
   }
   @RequestMapping(value = "get-devices-for-popup",method = RequestMethod.GET)
   @ResponseBody
   public PageResult getDevicesForPopup(
         @RequestParam("orgId")Integer orgId,
         String name,
         Integer pageSize,
         Integer pageNo
   ){
      return  deviceService.query(orgId,name,pageSize,pageNo);
   }
}