From 5a292756180242c83dcb4603a7c425b52be69f6d Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Mon, 21 Sep 2020 14:50:37 +0800
Subject: [PATCH] update

---
 src/main/java/com/moral/service/impl/ForecastWeatherServiceImpl.java |   52 +++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/moral/service/impl/ForecastWeatherServiceImpl.java b/src/main/java/com/moral/service/impl/ForecastWeatherServiceImpl.java
index 4bbbbfa..bbe110c 100644
--- a/src/main/java/com/moral/service/impl/ForecastWeatherServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/ForecastWeatherServiceImpl.java
@@ -1,5 +1,6 @@
 package com.moral.service.impl;
 
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -69,6 +70,7 @@
         Calendar c = Calendar.getInstance();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        DecimalFormat df = new DecimalFormat("0.0");
         c.add(Calendar.DAY_OF_MONTH, 1);
         String nextDay = sdf.format(c.getTime());
         c.setTime(c.getTime());
@@ -121,6 +123,20 @@
             hashMap.put("parentCode", parentCode);
             hashSet.add(hashMap);
         }
+
+        Map<String, Object> bmap = new HashMap<>();
+        bmap.put("name1", "���������");
+        bmap.put("parentName", "���������");
+        bmap.put("cityCode", 110000);
+        bmap.put("parentCode", 110000);
+        hashSet.add(bmap);
+        Map<String, Object> smap = new HashMap<>();
+        smap.put("name1", "���������");
+        smap.put("parentName", "���������");
+        smap.put("cityCode", 320500);
+        smap.put("parentCode", 320000);
+        hashSet.add(smap);
+
         List<Element> elements = Dom4jUtils.readDocument();
         String cityID = "101190404";
         for (Map<String, Object> map : hashSet) {
@@ -174,6 +190,10 @@
             }
             nextDayList.remove(0);
             for (Map<String, Object> nextDayMap : nextDayList) {
+                //������km/h->m/s
+                Double windSpeed = Double.valueOf(nextDayMap.get("windSpeed").toString());
+                windSpeed = windSpeed * 1000 / 3600;
+                nextDayMap.put("windSpeed", df.format(windSpeed));
                 String text = nextDayMap.get("text").toString();
                 String condition = "";
                 if ("���".equals(text)) {
@@ -188,6 +208,8 @@
                     condition = "20";
                 } else if ("���".equals(text)) {
                     condition = "0";
+                } else {
+                    condition = "50";
                 }
                 nextDayMap.put("condition", condition);
             }
@@ -233,13 +255,13 @@
                 String nextDayTemp = dataMap.get("temp").toString();
                 String nextDayCloud = dataMap.get("cloud").toString();
                 Integer condition = Integer.valueOf(dataMap.get("condition").toString());
-                String value="";
+                Integer value = 0;
                 if (condition >= 80) {
-                    value = "80";
+                    value = 80;
                 } else if (condition >= 40) {
-                    value = "40";
+                    value = 40;
                 } else if (condition >= 0) {
-                    value = "0";
+                    value = 0;
                 }
                 map.put("condition", value);
                 List<Map<String, Object>> tempAndCloudList = realWeatherMapper.getTempAndCloud(map);
@@ -250,15 +272,19 @@
                 map.put("times", times);
                 map1.put("times", times);
                 map1.put("time", hour);
-                List<Map<String, Object>> O3List = aqiMapper.getO3(map1);
-                if (O3List.size() == 0) {
-                    map1.put("cityCode", Integer.valueOf(map.get("parentCode").toString()));
+                List<Map<String, Object>> O3List = new ArrayList<>();
+                List<Map<String, Object>> beamList=new ArrayList<>();
+                if (times.size() != 0) {
                     O3List = aqiMapper.getO3(map1);
+                    if (O3List.size() == 0) {
+                        map1.put("cityCode", Integer.valueOf(map.get("parentCode").toString()));
+                        O3List = aqiMapper.getO3(map1);
+                    }
+                    if (map.get("macs") != null) {
+                        beamList = historyHourlyMapper.getBeamByMacs(map);
+                    }
                 }
-                List<Map<String, Object>> beamList = new ArrayList<>();
-                if (map.get("macs") != null) {
-                    beamList = historyHourlyMapper.getBeamByMacs(map);
-                }
+
                 for (Map<String, Object> tempAndCloudMap : tempAndCloudList) {
                     String time1 = tempAndCloudMap.get("time").toString();
                     for (Map<String, Object> beamMap : beamList) {
@@ -338,7 +364,7 @@
                     Double b = Double.valueOf(cmap.get("b").toString());
                     double O3C = b * Double.valueOf(nextDayTemp) + a;
                     if (O3C < 1.0) {
-                        O3C=1.0;
+                        O3C = 1.0;
                     }
                     dataMap.put("O3C", String.valueOf(Math.round(O3C)));
                 }
@@ -347,7 +373,7 @@
                     Double n = Double.valueOf(cmap.get("n").toString());
                     double beam = n * Double.valueOf(nextDayCloud) + m;
                     if (beam < 1.0) {
-                        beam=0.0;
+                        beam = 0.0;
                     }
                     dataMap.put("beam", String.valueOf(Math.round(beam)));
                 }

--
Gitblit v1.8.0