| | |
| | | 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;
|
| | |
| | | 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.DataService;
|
| | | 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;
|
| | |
|
| | | /**
|
| | | * The Class ScreenController.大屏接口
|
| | | */
|
| | | @RestController
|
| | | @RequestMapping("screen")
|
| | | @CrossOrigin(origins = "*", maxAge = 3600)
|
| | | @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
|
| | |
| | | private DeviceService deviceService;
|
| | |
|
| | | @Resource
|
| | | private DataService dataService;
|
| | | private HistoryMinutelyService historyMinutelyService;
|
| | |
|
| | | @Resource
|
| | | private MachineActivateService machineActivateService;
|
| | |
| | | * the request
|
| | | * @return the equipment states
|
| | | */
|
| | | @GetMapping("equipment-state")
|
| | | @GetMapping("/equipment-state")
|
| | | @PreAuthorize("hasAnyRole('USER', 'ADMIN')")
|
| | | public Map<String, Object> getDeviceStatesByAccount(HttpServletRequest request) {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | return deviceService.getDeviceStatesByAccount(parameters);
|
| | |
| | | /**
|
| | | * Gets the standard by sensor.获取某传感器标准值
|
| | | *
|
| | | * @param request
|
| | | * @param macKey
|
| | | * the request
|
| | | * @return the standard by sensor
|
| | | */
|
| | |
| | | @GetMapping("day-aqi")
|
| | | public Map<String, Object> getDayAQIByDevice(HttpServletRequest request) {
|
| | | Map<String, Object> parameters = getParametersStartingWith(request, null);
|
| | | return dataService.getDayAQIByDevice(parameters);
|
| | | return historyMinutelyService.getDayAQIByDevice(parameters);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | }
|
| | | 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&®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.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);
|
| | | }
|
| | | }
|