| | |
| | | import com.moral.entity.alarm.AlarmSensorLevel; |
| | | import com.moral.entity.charts.DataSortCondition; |
| | | import com.moral.entity.layout.RealTimeDeviceLayout; |
| | | import com.moral.service.AccountService; |
| | | import com.moral.service.AlarmConfigService; |
| | | import com.moral.service.AlarmDailyService; |
| | | import com.moral.service.AreaService; |
| | | import com.moral.service.DeviceService; |
| | | import com.moral.service.DeviceVersionService; |
| | | import com.moral.service.DictionaryDataService; |
| | | import com.moral.service.HangzhouAqiService; |
| | | import com.moral.service.HistoryDailyService; |
| | | import com.moral.service.HistoryHourlyService; |
| | | import com.moral.service.HistoryMinutelyService; |
| | | import com.moral.service.HistoryService; |
| | | import com.moral.service.MachineActivateService; |
| | | import com.moral.service.MonitorPointService; |
| | | import com.moral.service.OrganizationLayoutService; |
| | | import com.moral.service.OrganizationService; |
| | | import com.moral.service.QualityDailyService; |
| | | import com.moral.service.SensorService; |
| | | import com.moral.service.SensorUnitService; |
| | | import com.moral.service.WeatherService; |
| | | import com.moral.service.*; |
| | | import com.moral.util.*; |
| | | |
| | | import com.rabbitmq.client.*; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import org.xml.sax.InputSource; |
| | | |
| | | import static com.moral.common.util.ResourceUtil.getValue; |
| | | import static com.moral.common.util.WebUtils.getParametersStartingWith; |
| | | import static java.util.Calendar.*; |
| | | |
| | | /** |
| | | * The Class ScreenController.大屏接口 |
| | |
| | | MonitorPointService monitorPointService; |
| | | @Resource |
| | | DeviceVersionService deviceVersionService; |
| | | |
| | | /* @Resource |
| | | HistorySpecialService historySpecialService;*/ |
| | | |
| | | /** |
| | | * The screen service. |
| | |
| | | |
| | | @Resource |
| | | private QualityDailyService qualityDailyService; |
| | | |
| | | |
| | | /** |
| | | * Screen login. 大屏登录 |
| | |
| | | return new ResultBean<List<MonitorPoint>>(monitorPoints); |
| | | } |
| | | |
| | | |
| | | /* |
| | | * 参数:monitorPoint=368&mac=p5dnd7a0392018&sensorKey=e92&time=2020-08-11 |
| | | * 获取传感器均值接口 |
| | | * */ |
| | | @GetMapping("report_avg_datas") |
| | | public ResultBean<List<Map<String, Object>>> getMonitorPointOrDeviceAvgData(HttpServletRequest request) |
| | | throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | //该方法用于判断时间是具体到年月日 |
| | | ParameterUtils.getTimeType4Time(parameters); |
| | | parameters.put("monitorPointId", parameters.remove("monitorPoint")); |
| | | Object sensorKey = parameters.remove("sensorKey"); |
| | | parameters.put("sensors", Arrays.asList(sensorKey)); |
| | | // monitorPointService.isCompensateCalculation(parameters); |
| | | List<Map<String, Object>> list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters); |
| | | |
| | | for (Map<String, Object> map : list) { |
| | | String time = map.get("time").toString(); |
| | | time = time.substring(time.length() - 2); |
| | | map.put("time", Integer.valueOf(time)); |
| | | if(parameters.get("type").equals("day")){ |
| | | map.put("time", Integer.valueOf(time)+1); |
| | | String time1= (String) parameters.get("time"); |
| | | String mac1= (String) parameters.get("mac"); |
| | | List<Map<String, Object>> list=null; |
| | | if (mac1!=null && mac1.equals("p5dnd7a0392018") && time1.substring(0,4).equals("2019") ){ |
| | | list=null; |
| | | }else { |
| | | parameters.put("monitorPointId", parameters.remove("monitorPoint")); |
| | | Object sensorKey = parameters.remove("sensorKey"); |
| | | parameters.put("sensors", Arrays.asList(sensorKey)); |
| | | // monitorPointService.isCompensateCalculation(parameters); |
| | | list = historyMinutelyService.getMonitorPointOrDeviceAvgData(parameters); |
| | | for (Map<String, Object> map : list) { |
| | | String time = map.get("time").toString(); |
| | | time = time.substring(time.length() - 2); |
| | | map.put("time", Integer.valueOf(time)); |
| | | if (parameters.get("type").equals("day")) { |
| | | map.put("time", Integer.valueOf(time) + 1); |
| | | } |
| | | map.put("value", map.remove(sensorKey)); |
| | | } |
| | | map.put("value", map.remove(sensorKey)); |
| | | } |
| | | return new ResultBean<List<Map<String, Object>>>(list); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @GetMapping("report_alarm_datas") |
| | | public ResultBean<List<Map<String, Object>>> getAlarmData(HttpServletRequest request) throws Exception { |
| | |
| | | throws Exception { |
| | | Map<String, Object> parameters = WebUtils.getParametersStartingWith(request, null); |
| | | List<MonitorPoint> monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(parameters); |
| | | //给每一个monitorPoint下的设备通过device.getName()进行排序 |
| | | for (MonitorPoint monitorPoint : monitorPoints) { |
| | | List<Device> deviceList=monitorPoint.getDevices(); |
| | | deviceList.sort((Device o1, Device o2) -> { |
| | | return o1.getName().compareTo(o2.getName()); |
| | | }); |
| | | } |
| | | return new ResultBean<List<MonitorPoint>>(monitorPoints); |
| | | } |
| | | |
| | |
| | | String startHour = st.substring(st.lastIndexOf("-") + 1); |
| | | String startTime = startYearAndDay + " " + startHour + ":00:00"; |
| | | String et = parameters.get("endTime").toString(); |
| | | String endYearAndDay = et.substring(0, st.lastIndexOf("-")); |
| | | String endHour = et.substring(et.lastIndexOf("-") + 1); |
| | | int endHourValue = Integer.valueOf(endHour); |
| | | String endTime=endYearAndDay + " " + endHour + ":00:00"; |
| | | /* int endHourValue = Integer.valueOf(endHour); |
| | | int startHourValue = Integer.valueOf(startHour); |
| | | if (endHourValue <= startHourValue) { |
| | | endHourValue = startHourValue + 1; |
| | | } |
| | | String endTime = startYearAndDay + " " + endHourValue + ":00:00"; |
| | | String endTime = startYearAndDay + " " + endHourValue + ":00:00";*/ |
| | | parameters.put("startTime", startTime); |
| | | parameters.put("endTime", endTime); |
| | | String mac = parameters.get("mac").toString(); |
| | |
| | | params.put("sensorInfo", sensorList); |
| | | params.put("sensorsMap", sensorsMap); |
| | | String paramsJson = params.toJSONString(); |
| | | //System.out.println(paramsJson); |
| | | model.addObject("carTrajectoryParams", paramsJson); |
| | | model.setViewName("cartrajectory"); |
| | | return model; |
| | |
| | | @RequestMapping(value = "/newMap-page", method = RequestMethod.GET) |
| | | public ModelAndView newMap(ModelAndView model, @RequestParam("areaCode") long code, |
| | | @RequestParam("accountId") int accountId) { |
| | | |
| | | Account account = accountService.getAccountById(accountId); |
| | | List<MonitorPoint> monitorPointList = monitorPointService.getMonitorPointListByAccountId(accountId); |
| | | String regionName = areaService.queryFullNameByCode(code); |
| | |
| | | if (mac!=null){ |
| | | Device device=deviceService.byMacGetDevice(mac); |
| | | List list1= LatLngTransformation.Convert_BD09_To_GCJ02(device.getLatitude(),device.getLongitude()); |
| | | if (device.getState()!=4+""){ |
| | | devMap.put("state",device.getState()); |
| | | } |
| | | devMap.put("lat",list1.get(1)); |
| | | devMap.put("lng",list1.get(0)); |
| | | devMap.put("monitorPointId",device.getMonitorPointId()); |
| | |
| | | |
| | | @GetMapping("/windAndDeviceData") |
| | | @ResponseBody |
| | | public List windAndDeviceData() { |
| | | String monitorPointId="539"; |
| | | Calendar c = Calendar.getInstance();//可以对每个时间域单独修改 对时间进行加减操作等 |
| | | int year = c.get(Calendar.YEAR); |
| | | int month = c.get(Calendar.MONTH); |
| | | String mon=""; |
| | | if (month+1<10){ |
| | | mon="0"+(month+1); |
| | | public List windAndDeviceData(String monitorPointId) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MINUTE, (calendar.get(Calendar.MINUTE) - 2)); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String time = df.format(calendar.getTime())+":00"; |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String mon; |
| | | if (month<10){ |
| | | mon="0"+month; |
| | | }else { |
| | | mon=(month+1)+""; |
| | | mon=""+month; |
| | | } |
| | | int date = c.get(Calendar.DATE); |
| | | String dt=""; |
| | | if(date<10){ |
| | | dt="0"+date; |
| | | }else { |
| | | dt=""+date; |
| | | } |
| | | int hour = c.get(Calendar.HOUR_OF_DAY); |
| | | String hu=""; |
| | | if (hour<10){ |
| | | hu="0"+hour; |
| | | }else { |
| | | hu=""+hour; |
| | | } |
| | | int minute = c.get(Calendar.MINUTE); |
| | | String mu=""; |
| | | if (minute<10){ |
| | | mu="0"+minute; |
| | | }else { |
| | | mu=""+minute; |
| | | } |
| | | String time=year + "-" + mon + "-" + dt + " " +hu + ":" +mu + ":" + "00"; |
| | | String table="history_minutely_"+year+mon; |
| | | List list=deviceService.byMonitorIdGetDeviceAndWind(monitorPointId,time,table); |
| | | return list; |
| | | } |
| | | |
| | | //局部风场 |
| | | @GetMapping("/windAndDeviceDataByArea") |
| | | @ResponseBody |
| | | public List windAndDeviceDataByArea(String monitorPointId) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MINUTE, (calendar.get(Calendar.MINUTE) - 2)); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String time = df.format(calendar.getTime())+":00"; |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH) + 1; |
| | | String mon; |
| | | if (month<10){ |
| | | mon="0"+month; |
| | | }else { |
| | | mon=""+month; |
| | | } |
| | | String table="history_minutely_"+year+mon; |
| | | List list=deviceService.byMonitorIdGetDeviceAndWindSpecial(monitorPointId,time,table); |
| | | return list; |
| | | } |
| | | |
| | | @GetMapping("forecastO3") |
| | | @ApiOperation(value = "预测和实际臭氧对比", notes = "预测和实际臭氧对比") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "monitorPointId", defaultValue = "1", value = "监控站id", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | | @ApiImplicitParam(name = "time", value = "时6间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | | public ResultBean<List<Map<String, Object>>> getWeatherNextDayDataByRegion(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | List<Map<String, Object>> resultList = weatherService.getForecastAndReal(parameters); |
| | |
| | | } |
| | | |
| | | @GetMapping("weatherData") |
| | | @ApiOperation(value = "根据city查询预测和实际数据", notes = "根据city查询预测和实际数据") |
| | | @ApiOperation(value = "根据city查询小时预测和实测数据", notes = "根据city查询小时预测和实测数据") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "city", value = "城市名", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | List<Map<String, Object>> weatherList = weatherService.getWeatherData(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(weatherList); |
| | | } |
| | | |
| | | @GetMapping("weatherDataDay") |
| | | @ApiOperation(value = "根据city查询日实测数据", notes = "根据city查询日实测数据") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "city", value = "城市名", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19)", required = true, paramType = "query", dataType = "String")}) |
| | | public ResultBean<List<Map<String, Object>>> getWeatherDataByDay(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | List<Map<String, Object>> weatherList = weatherService.getWeatherDataByDay(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(weatherList); |
| | | } |
| | | |
| | | @GetMapping("monitorDeviceData") |
| | | @ApiOperation(value = "获取微型站5分钟和半小时数据", notes = "获取微型站5分钟和半小时数据") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "city", value = "城市名", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-15)", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "type", value = "类型(5分钟:m,半小时:h)", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "range", value = "要查看的设备范围(国控站周边:m,全城:a)", required = true, paramType = "query", dataType = "String")}) |
| | | public ResultBean<List<Map<String, Object>>> get5MinutesOrHalfHour(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | List<Map<String, Object>> deviceData = historyMinutelyService.get5MinutesOrHalfHour(parameters); |
| | | return new ResultBean<List<Map<String, Object>>>(deviceData); |
| | | } |
| | | |
| | | @PostMapping("updateForecastWeather") |
| | |
| | | String startTime = parameters.get("startTime").toString(); |
| | | String endTime = parameters.get("endTime").toString(); |
| | | //对时间进行操作的接口 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | Calendar calendar = getInstance(); |
| | | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | List<Map<String, Object>> list = new ArrayList(); |
| | | Map device = deviceService.getAllFieldByMac(parameters); |
| | |
| | | return new ResultBean<List<Map<String, Object>>>(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @GetMapping("/contrastFactor") |
| | | @ApiOperation(value = "因子对比", notes = "因子对比") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "sensor", value = "因子", required = true, paramType = "query", dataType = "String"), |
| | | @ApiImplicitParam(name = "time", value = "时间(格式:2020-03-19、20、21)", required = true, paramType = "query", dataType = "String")}) |
| | | public ResultBean<List<Map<String, Object>>> contrastFactor(HttpServletRequest request) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | List list=historyHourlyService.getDataByMacAndTime(parameters); |
| | | //System.out.println(list); |
| | | return new ResultBean<List<Map<String, Object>>>(list); |
| | | } |
| | | |
| | | @GetMapping("/getAlarm") |
| | | @ResponseBody |
| | | public List<DeviceRoad> getAlarm(@Param("windData") String windData,@Param("code") String code,@Param("mac") String mac,@Param("speedLevel")String speedLevel){ |
| | | List<DeviceRoad> alarmData = deviceRoadService.getAlarmData(windData, code, mac, speedLevel); |
| | | return alarmData; |
| | | } |
| | | |
| | | @GetMapping("/lianxian") |
| | | @ApiOperation(value = "连线", notes = "连线" ) |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "lonAndLat", value = "经纬度", required = true, paramType = "query", dataType = "String")}) |
| | | public ModelAndView lianxian(HttpServletRequest request,ModelAndView model) throws Exception { |
| | | Map<String, Object> parameters = getParametersStartingWith(request, null); |
| | | String mac= (String) parameters.get("lonAndLat"); |
| | | String[] ll= mac.split(","); |
| | | |
| | | JSONObject params = new JSONObject(); |
| | | params.put("ll",ll); |
| | | Double[] array= {116.885217,38.299148}; |
| | | Double[] array1= {116.87061,38.322828}; |
| | | Double[] array2= {116.855206,38.325162}; |
| | | Double distance1=mapUtils.getDistance(Double.parseDouble(ll[0]),Double.parseDouble(ll[1]),116.885217,38.299148); |
| | | Double distance2=mapUtils.getDistance(Double.parseDouble(ll[0]),Double.parseDouble(ll[1]),116.87061,38.322828); |
| | | Double distance3=mapUtils.getDistance(Double.parseDouble(ll[0]),Double.parseDouble(ll[1]),116.855206,38.325162); |
| | | |
| | | params.put("mt",distance1); |
| | | params.put("mt1",distance2); |
| | | params.put("mt2",distance3); |
| | | model.addObject("params", params); |
| | | model.setViewName("lianxian"); |
| | | return model; |
| | | } |
| | | } |