| | |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.moral.common.bean.Constants; |
| | | import com.moral.common.bean.PageBean; |
| | | import com.moral.common.bean.PageResult; |
| | | import com.moral.common.bean.ResultBean; |
| | | import com.moral.entity.Account; |
| | | import com.moral.entity.Device; |
| | | 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 com.moral.service.*; |
| | | import lombok.extern.log4j.Log4j; |
| | | import org.apache.log4j.Logger; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | @Controller |
| | | @RequestMapping("map") |
| | | public class MapController { |
| | | public static Logger log = Logger.getLogger(MapController.class); |
| | | @Resource |
| | | DeviceService deviceService; |
| | | @Resource |
| | | AreaService areaService; |
| | | @Resource |
| | |
| | | SensorService sensorService; |
| | | @Resource |
| | | MonitorPointService monitorPointService; |
| | | |
| | | @RequestMapping(value = "/main-page", method = RequestMethod.GET) |
| | | 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"; |
| | | if(account!=null&®ionName!=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.addAttribute("mapParams",paramsJson); |
| | | return "map"; |
| | | } else { |
| | | StringBuilder msg = new StringBuilder(); |
| | | msg.append(" param[0] areaCode:"); |
| | | msg.append(code); |
| | | msg.append(" param[0] accountId:"); |
| | | msg.append(accountId); |
| | | log.warn(msg); |
| | | return "401"; |
| | | } |
| | | } |
| | | @RequestMapping(value="/getmonitorpoints",method = RequestMethod.GET) |
| | | @RequestMapping(value="/get-monitorpoints",method = RequestMethod.GET) |
| | | @ResponseBody |
| | | public ResultBean getMonitorpointList(@RequestParam("orgId")String orgId,MapBounds mapBounds){ |
| | | ResultBean< List<MonitorPoint>> resultBean = new ResultBean(); |
| | |
| | | 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); |
| | | } |
| | | } |