fengxiang
2018-01-26 60163c2fb5098fc522f8e80b131128d2c9a33e42
src/main/java/com/moral/controller/MapController.java
@@ -2,12 +2,23 @@
import com.alibaba.fastjson.JSONObject;
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Account;
import com.moral.entity.MapBounds;
import com.moral.entity.MonitorPoint;
import com.moral.service.AccountService;
import com.moral.service.AreaService;
import com.moral.service.MonitorPointService;
import com.moral.service.SensorService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@@ -16,9 +27,39 @@
@Controller
@RequestMapping("map")
public class MapController {
    @Resource
    AreaService areaService;
    @Resource
    AccountService accountService;
    @Resource
    SensorService sensorService;
    @Resource
    MonitorPointService monitorPointService;
    @RequestMapping(value = "/main-page", method = RequestMethod.GET)
    public String map(){
        ModelAndView mv = new ModelAndView("map");
    public String map(Model model,@RequestParam("areaCode")int code,@RequestParam("accountId")int accountId){
        Account account = accountService.getAccountById(accountId);
        String regionName = areaService.selectFullNameByCode(code);
        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.addAttribute("mapParams",paramsJson);
        return "map";
    }
    @RequestMapping(value="/getmonitorpoints",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;
    }
}