| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.DecimalFormat;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | |
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.mapper.ProvinceMapper;
|
| | | import com.moral.mapper.RealWeatherMapper;
|
| | | import com.moral.mapper.ShAreaMapper;
|
| | | import com.moral.service.OrganizationService;
|
| | | import com.moral.service.WeatherService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private HistoryHourlyMapper historyHourlyMapper;
|
| | |
|
| | | @Resource
|
| | | private ShAreaMapper shAreaMapper;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getWeatherDataByRegion(Map<String, Object> parameters) {
|
| | |
| | | parameters.put("typeFormat", "%Y-%m-%d %H:%i:%s");
|
| | | String cityName = parameters.get("city").toString();
|
| | | Area area = areaMapper.getAreaByName(cityName);
|
| | | Integer code = 0;
|
| | | String name = "";
|
| | | Integer code;
|
| | | String name;
|
| | | if (area == null) {
|
| | | City city = cityMapper.getCityByName(cityName);
|
| | | if (city == null) {
|
| | |
| | | cal.add(Calendar.DAY_OF_MONTH, 1);
|
| | | Date end = cal.getTime();
|
| | | cal.setTime(sdf.parse(time));
|
| | | Date time1 = cal.getTime();
|
| | | cal.add(Calendar.DAY_OF_MONTH, -1);
|
| | | String beforeDay = sdf.format(cal.getTime());
|
| | | parameters.put("start", selectTime);
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | DecimalFormat df = new DecimalFormat(".####");
|
| | | List<Map<String, Object>> realAqilist = new ArrayList<>();
|
| | | for (Map<String, Object> aqiMap : aqiList) {
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("time", aqiMap.get("time"));
|
| | | Map<String, Object> jsonMap = (Map<String, Object>) JSONObject.parse(aqiMap.get("json").toString());
|
| | | DecimalFormat df = new DecimalFormat(".####");
|
| | | if (jsonMap.get("longitude") != null) {
|
| | | double longitude = Double.valueOf(jsonMap.get("longitude").toString());
|
| | | jsonMap.put("longitude", df.format(longitude));
|
| | | }
|
| | | if (jsonMap.get("latitude") != null) {
|
| | | double longitude = Double.valueOf(jsonMap.get("latitude").toString());
|
| | | jsonMap.put("latitude", df.format(longitude));
|
| | | }
|
| | | hashMap.putAll(jsonMap);
|
| | | hashMap.put("city", parameters.get("name").toString());
|
| | | realAqilist.add(hashMap);
|
| | |
| | | for (Device device : deviceList) {
|
| | | macList.add(device.getMac());
|
| | | }
|
| | |
|
| | | parameters.put("macs", macList);
|
| | | beamList = historyHourlyMapper.getBeamByMacs(parameters);
|
| | | Map<String, Object> map = new HashMap<>();
|
| | |
| | | for (Map<String, Object> tvocMap : tvocList) {
|
| | | String ttime = tvocMap.get("time").toString();
|
| | | if (ttime.equals(rtime)) {
|
| | | realMap.put("TVOC", tvocMap.get("TVOC").toString());
|
| | | Double tvoc = Double.valueOf(tvocMap.get("TVOC").toString());
|
| | | BigDecimal bd = new BigDecimal(tvoc);
|
| | | tvoc = bd.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
|
| | | realMap.put("TVOC", tvoc);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | //后4小时保良值
|
| | | double value = 160.0 * 8;
|
| | | int nowHour = Integer.valueOf(sdf1.format(now).substring(11, 13));
|
| | | int nowMinute = Integer.valueOf(sdf1.format(now).substring(14, 16));
|
| | | String format = sdf1.format(now).substring(0, 13) + ":00:00";
|
| | | if (nowHour < 8) {
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | if (nowMinute >= 46) {
|
| | | nowHour = nowHour + 1;
|
| | | cal.setTime(now);
|
| | | cal.add(Calendar.HOUR_OF_DAY,1);
|
| | | format=sdf1.format(cal.getTime()).substring(0, 13) + ":00:00";
|
| | | }
|
| | |
|
| | | for (Map<String, Object> resultMap : resultList) {
|
| | | if (resultMap.get("type").equals("实测")) {
|
| | | if (sdf.parse(time).getTime() == sdf.parse(sdf.format(now)).getTime()) {
|
| | |
| | | hashMap.put("cityCode", Integer.valueOf(parameters.get("cityCode").toString()));
|
| | | hashMap.put("start", startTime);
|
| | | hashMap.put("end", endTime);
|
| | | if (rhour == 0) {
|
| | | rhour = 24;
|
| | | }
|
| | |
|
| | | if (rhour == nowHour) {
|
| | | Map<String, Object> sumO3Map = hangzhouAqiMapper.getSumO3(hashMap);
|
| | | double v = value - Double.valueOf(sumO3Map.get("O3Sum").toString());
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | //地理特征
|
| | | Map<String, Object> point = shAreaMapper.getgeography(name);
|
| | | for (Map<String, Object> map : resultList) {
|
| | | if (map.get("type").equals("预测")) {
|
| | | if (resultList.get(1).get("longitude") != null) {
|
| | | String longitude = resultList.get(1).get("longitude").toString();
|
| | | map.put("longitude",longitude);
|
| | | }
|
| | | if (resultList.get(1).get("latitude") != null) {
|
| | | String latitude = resultList.get(1).get("latitude").toString();
|
| | | map.put("latitude",latitude);
|
| | | }
|
| | | double longitude = Double.valueOf(point.get("lng").toString());
|
| | | double latitude = Double.valueOf(point.get("lat").toString());
|
| | | map.put("longitude", df.format(longitude));
|
| | | map.put("latitude", df.format(latitude));
|
| | | if (point.get("altitude") != null) {
|
| | | map.put("altitude", point.get("altitude").toString());
|
| | | }
|
| | | if (point.get("vegetation") != null) {
|
| | | map.put("vegetation", point.get("vegetation").toString());
|
| | | }
|
| | | if (point.get("river") != null) {
|
| | | map.put("river", point.get("river").toString());
|
| | | }
|
| | | }
|
| | | return resultList;
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|