| | |
| | | import com.moral.api.entity.*; |
| | | import com.moral.api.mapper.HistoryFiveMinutelyMapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.mapper.HistoryHourlyMapper; |
| | | import com.moral.api.pojo.dto.Wind.WindData; |
| | | import com.moral.api.pojo.dto.historyFiveMinutely.DeviceAndFiveMinuteDataDTO; |
| | | import com.moral.api.pojo.form.device.MonitorPointQueryForm; |
| | |
| | | RedisTemplate redisTemplate; |
| | | @Autowired |
| | | HistoryFiveMinutelyMapper historyFiveMinutelyMapper; |
| | | |
| | | @Autowired |
| | | HistoryHourlyMapper historyHourlyMapper; |
| | | @Autowired |
| | | DeviceService deviceService; |
| | | |
| | |
| | | } |
| | | //查询所有设备对应的数据 |
| | | List<DeviceAndFiveMinuteDataDTO> dtos = new ArrayList<>(); |
| | | if (form.getChooseTime().equals("true")){ |
| | | String time = form.getTime(); |
| | | String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); |
| | | for (Device device : devices) { |
| | | DeviceAndFiveMinuteDataDTO dto = new DeviceAndFiveMinuteDataDTO(); |
| | | String mac = device.getMac(); |
| | | String dbDataStr = historyHourlyMapper.queryLastHourlyMac(mac, time, timeUnits); |
| | | // String dbDataStr = historyFiveMinutelyMapper.queryLastFiveMinutely(mac, time, timeUnits); |
| | | HashMap sensorValues = JSON.parseObject(dbDataStr, HashMap.class); |
| | | Map<String, Object> sensorValue = new HashMap<>(); |
| | | if (sensorValues != null && sensorValues.get(sensorCode) != null) |
| | | sensorValue.put(sensorCode, sensorValues.get(sensorCode)); |
| | | else |
| | | sensorValue.put(sensorCode, null); |
| | | dto.setDevice(device); |
| | | dto.setSensorValue(sensorValue); |
| | | dtos.add(dto); |
| | | } |
| | | return dtos; |
| | | } |
| | | for (Device device : devices) { |
| | | DeviceAndFiveMinuteDataDTO dto = new DeviceAndFiveMinuteDataDTO(); |
| | | String mac = device.getMac(); |
| | |
| | | |
| | | @Override |
| | | public List<Object> getAreaWindData(Map<String, Object> params) { |
| | | String timeUnits = DateUtils.dateToDateString(new Date(), DateUtils.yyyyMM_EN); |
| | | params.put("timeUnits", timeUnits); |
| | | //风场数据 |
| | | List<WindData> windData = historyFiveMinutelyMapper.getAreaWindData(params); |
| | | // String timeUnits = DateUtils.dateToDateString(new Date(), DateUtils.yyyyMM_EN); |
| | | // params.put("timeUnits", timeUnits); |
| | | // //风场数据 |
| | | // List<WindData> windData = historyFiveMinutelyMapper.getAreaWindData(params); |
| | | // return getWindData(windData); |
| | | String chooseTime = params.get("chooseTime").toString(); |
| | | List<WindData> windData=null; |
| | | if (chooseTime.equals("true")){ |
| | | String time = params.get("time").toString(); |
| | | String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); |
| | | params.put("timeUnits", timeUnits); |
| | | windData = historyHourlyMapper.getArea(params); |
| | | }else { |
| | | String timeUnits = DateUtils.dateToDateString(new Date(), DateUtils.yyyyMM_EN); |
| | | params.put("timeUnits", timeUnits); |
| | | //风场数据 |
| | | windData = historyFiveMinutelyMapper.getAreaWindData(params); |
| | | } |
| | | |
| | | return getWindData(windData); |
| | | } |
| | | |
| | | |
| | | //获取五分钟弹窗数据 |
| | | @Override |
| | | public Map<String, Object> getPopDataByMac(String mac) { |
| | | Map<String, Object> datas = queryLastDataByMac(mac); |
| | | public Map<String, Object> getPopDataByMac(Map<String, Object> params) { |
| | | // Map<String, Object> datas = queryLastDataByMac(mac); |
| | | String chooseTime = params.get("chooseTime").toString(); |
| | | String mac = params.get("mac").toString(); |
| | | Map<String, Object> datas=null; |
| | | if (chooseTime.equals("true")){ |
| | | String time = params.get("time").toString(); |
| | | String timeUnits = DateUtils.stringToDateString(time, "yyyy-MM-dd HH:mm", DateUtils.yyyyMM_EN); |
| | | String dbDataStr = historyHourlyMapper.queryLastHourlyMac(mac, time, timeUnits); |
| | | if (dbDataStr==null){ |
| | | return null; |
| | | } |
| | | // String dbDataStr = historyFiveMinutelyMapper.queryLastFiveMinutely(mac, time, timeUnits); |
| | | datas = JSON.parseObject(dbDataStr, HashMap.class); |
| | | datas.put("dataTime",time); |
| | | }else { |
| | | datas = queryLastDataByMac(mac); |
| | | } |
| | | //构建返回对象 |
| | | Map<String, Object> result = new HashMap<>(); |
| | | //创建返回因子code集合 |
| | | List<String> sensorCodes = Arrays.asList("a34004", "a34002", "a21005", "a21004", "a21026", "a05024", "a99054"); |
| | | List<String> sensorCodes = Arrays.asList("a34004", "a34002", "a21005", "a21004", "a21026", "a05024", "a99054","a01008","a01007"); |
| | | //获取设备信息 |
| | | Device device = deviceService.getDeviceUnitAlramInforByMac(mac); |
| | | //转换数据单位和名称 |
| | |
| | | Object NO2 = data.get("a21004"); |
| | | Object CO = data.get("a21005"); |
| | | Object O3 = data.get("a05024"); |
| | | Object a01008 = data.get("a01008"); |
| | | Object a01007 = data.get("a01007"); |
| | | Object name = data.get("name"); |
| | | Object time = data.get("dataTime"); |
| | | if(name!=null) |
| | |
| | | result.put("臭氧(O₃)",O3); |
| | | if(time!=null) |
| | | result.put("时间",time); |
| | | if (a01008!=null) |
| | | result.put("风向",a01008); |
| | | if (a01007!=null) |
| | | result.put("风速",a01007); |
| | | return result; |
| | | } |
| | | |
| | |
| | | List<Object> list = new ArrayList<>(); |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | for (WindData data : windData) { |
| | | //经度 |
| | | Double longitude = data.getLongitude(); |
| | | //纬度 |
| | | Double latitude = data.getLatitude(); |
| | | GeoCoordinates geoCoordinates = GeoCoordinates.create(longitude, latitude); |
| | | points.add(geoCoordinates); |
| | |
| | | laList.add(latitude); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | //风向 |
| | | Double windDir = data.getWindDir(); |
| | | //风速 |
| | | Double windSpeed = data.getWindSpeed(); |
| | | if (windDir == null) { |
| | | windDir = 0d; |
| | | windSpeed = 0d; |
| | | } |
| | | double dir = (360.0 - (windDir + 180.0) * Math.PI / 180.0); |
| | | //余弦值 |
| | | U = windSpeed * Math.cos(dir); |
| | | //三角正弦值 |
| | | V = windSpeed * Math.sin(dir); |
| | | map.put("lo", longitude); |
| | | map.put("la", latitude); |
| | |
| | | laLaMap.put("minLa", lami); |
| | | |
| | | Double lo1 = lomi - length * 0.00001141; |
| | | // Double lo1 = lomi - length * 0.000001141 * 2; |
| | | Double lo2 = loma + length * 0.00001141; |
| | | // Double lo2 = loma + length * 0.000001141 * 2; |
| | | // Double la2 = lami - length * 0.000000899 * 2; |
| | | Double la2 = lami - length * 0.00000899; |
| | | // Double la1 = lama + length * 0.000000899 * 2; |
| | | Double la1 = lama + length * 0.00000899; |
| | | |
| | | double dx = 0.00001141 * perdlen; |
| | | double dy = 0.00000899 * perdlen; |
| | | |
| | | // double dx = 0.000001141 * perdlen * 2; |
| | | // double dy = 0.000000899 * perdlen * 2; |
| | | |
| | | int nx = (int) Math.floor((lo2 - lo1) / dx); |
| | | int ny = (int) Math.floor((la1 - la2) / dy); |
| | | |