Browse Source

自己做室外天气的定义

menglu 3 years ago
parent
commit
c8e90b7a5c

+ 52 - 48
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -74,6 +74,43 @@ public class RWDLoadUtil {
 					log.warn(e.getMessage(), e);
 				}
 			}
+			{
+				JSONArray array = new JSONArray();
+				for (String key : Constant.weather_nowMap.keySet()) {
+					Map<String, String> oneMap = Constant.weather_nowMap.get(key);
+					String dataType = oneMap.get("dataType");
+					String info_code = oneMap.get("info_code");
+					String name = oneMap.get("name");
+					String unit = oneMap.get("unit");
+					JSONObject info = new JSONObject();
+					info.put("code", info_code);
+					info.put("name", name);
+					info.put("category", "SEQUENTIAL");
+					info.put("firstTag", "运行参数");
+					info.put("dataType", dataType);
+					info.put("unit", unit);
+					array.add(info);
+				}
+				for (String key : Constant.weather_forecastMap.keySet()) {
+					Map<String, String> oneMap = Constant.weather_forecastMap.get(key);
+					String dataType = oneMap.get("dataType");
+					String info_code = oneMap.get("info_code");
+					String name = oneMap.get("name");
+					String unit = oneMap.get("unit");
+					JSONObject info = new JSONObject();
+					info.put("code", info_code);
+					info.put("name", name);
+					info.put("category", "SEQUENTIAL");
+					info.put("firstTag", "运行参数");
+					info.put("dataType", dataType);
+					info.put("unit", unit);
+					array.add(info);
+				}
+				SceneDataSet SceneDataSet = new SceneDataSet(false);
+				SceneDataSet.set = RWDUtil.array2SDOList(array);
+				infoArrayDic.put("weather", SceneDataSet);
+				infoJsonArray.put("weather", array);
+			}
 			Repository.infoArrayJson = infoJsonArray;
 			Repository.infoArrayDic = infoArrayDic;
 		}
@@ -1102,43 +1139,6 @@ public class RWDLoadUtil {
 	}
 
 	public static void LoadWeather(RepositoryImpl Repository) throws Exception {
-		{
-			JSONArray array = new JSONArray();
-			for (String key : Constant.weather_nowMap.keySet()) {
-				Map<String, String> oneMap = Constant.weather_nowMap.get(key);
-				String dataType = oneMap.get("dataType");
-				String info_code = oneMap.get("info_code");
-				String name = oneMap.get("name");
-				String unit = oneMap.get("unit");
-				JSONObject info = new JSONObject();
-				info.put("code", info_code);
-				info.put("name", name);
-				info.put("category", "SEQUENTIAL");
-				info.put("firstTag", "运行参数");
-				info.put("dataType", dataType);
-				info.put("unit", unit);
-				array.add(info);
-			}
-			for (String key : Constant.weather_forecastMap.keySet()) {
-				Map<String, String> oneMap = Constant.weather_forecastMap.get(key);
-				String dataType = oneMap.get("dataType");
-				String info_code = oneMap.get("info_code");
-				String name = oneMap.get("name");
-				String unit = oneMap.get("unit");
-				JSONObject info = new JSONObject();
-				info.put("code", info_code);
-				info.put("name", name);
-				info.put("category", "SEQUENTIAL");
-				info.put("firstTag", "运行参数");
-				info.put("dataType", dataType);
-				info.put("unit", unit);
-				array.add(info);
-			}
-			SceneDataSet SceneDataSet = new SceneDataSet(false);
-			SceneDataSet.set = RWDUtil.array2SDOList(array);
-			Repository.infoArrayDic.put("weather", SceneDataSet);
-		}
-
 		String cityCode = RepositoryContainer.RepositoryProject.projectId.substring(2, 8);
 		{
 			JSONObject arrayItem = new JSONObject();
@@ -1153,20 +1153,21 @@ public class RWDLoadUtil {
 				if (content.size() > 0) {
 					JSONObject contentItem = content.getJSONObject(0);
 					for (String key : Constant.weather_nowMap.keySet()) {
+						Map<String, String> oneMap = Constant.weather_nowMap.get(key);
+						String info_code = (String) oneMap.get("info_code");
 						Object value = contentItem.get(key);
 						if (value instanceof String) {
 							String valueString = (String) value;
-							Map<String, String> oneMap = Constant.weather_nowMap.get(key);
 							String dataType = oneMap.get("dataType");
 							if (dataType.equals("INTEGER")) {
-								arrayItem.put(key, Long.parseLong(valueString));
+								arrayItem.put(info_code, Long.parseLong(valueString));
 							} else if (dataType.equals("DOUBLE")) {
-								arrayItem.put(key, Double.parseDouble(valueString));
+								arrayItem.put(info_code, Double.parseDouble(valueString));
 							} else {
-								arrayItem.put(key, valueString);
+								arrayItem.put(info_code, valueString);
 							}
 						} else {
-							arrayItem.put(key, value);
+							arrayItem.put(info_code, value);
 						}
 					}
 				}
@@ -1182,27 +1183,30 @@ public class RWDLoadUtil {
 				if (content.size() > 0) {
 					JSONObject contentItem = content.getJSONObject(0);
 					for (String key : Constant.weather_forecastMap.keySet()) {
+						Map<String, String> oneMap = Constant.weather_forecastMap.get(key);
+						String info_code = (String) oneMap.get("info_code");
 						Object value = contentItem.get(key);
 						if (value instanceof String) {
 							String valueString = (String) value;
-							Map<String, String> oneMap = Constant.weather_forecastMap.get(key);
 							String dataType = oneMap.get("dataType");
 							if (dataType.equals("INTEGER")) {
-								arrayItem.put(key, Long.parseLong(valueString));
+								arrayItem.put(info_code, Long.parseLong(valueString));
 							} else if (dataType.equals("DOUBLE")) {
-								arrayItem.put(key, Double.parseDouble(valueString));
+								arrayItem.put(info_code, Double.parseDouble(valueString));
 							} else {
-								arrayItem.put(key, valueString);
+								arrayItem.put(info_code, valueString);
 							}
 						} else {
-							arrayItem.put(key, value);
+							arrayItem.put(info_code, value);
 						}
 					}
 				}
 			}
 			JSONArray array = new JSONArray();
 			array.add(arrayItem);
-			Repository.weather.set = RWDUtil.array2SDOList(array);
+			Repository.weather.set.clear();
+			Repository.weather.set.addAll(RWDUtil.array2SDOList(array));
+			Repository.addWaitCompute(Repository.weather);
 		}
 	}
 }