| 
														
															@@ -1,5 +1,6 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 package com.skyversation.poiaddr.util.dms; 
														 | 
														
														 | 
														
															 package com.skyversation.poiaddr.util.dms; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.skyversation.poiaddr.addquery.Constant; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.skyversation.poiaddr.util.RequestUtils; 
														 | 
														
														 | 
														
															 import com.skyversation.poiaddr.util.RequestUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.json.JSONArray; 
														 | 
														
														 | 
														
															 import org.json.JSONArray; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.json.simple.JSONObject; 
														 | 
														
														 | 
														
															 import org.json.simple.JSONObject; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -15,10 +16,9 @@ import java.util.Map; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 public class DmsTools { 
														 | 
														
														 | 
														
															 public class DmsTools { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public static String DmsToken; 
														 | 
														
														 | 
														
															     public static String DmsToken; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     //  登录操作,请求token 
														 | 
														
														 | 
														
															     //  登录操作,请求token 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public static String getDmsToken() { 
														 | 
														
														 | 
														
															     public static String getDmsToken() { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        JSONObject resultObject = RequestUtils.requestPost("http://121.43.55.7:2101/proxy_oauth/user/login?userName=user001&password=1234567890&clientId=2", null, null); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        JSONObject resultObject = RequestUtils.requestPost(Constant.Oauth_login_URL, null, null); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (resultObject != null && resultObject.containsKey("message") && resultObject.get("message") != null) { 
														 | 
														
														 | 
														
															         if (resultObject != null && resultObject.containsKey("message") && resultObject.get("message") != null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             DmsToken = resultObject.get("message").toString(); 
														 | 
														
														 | 
														
															             DmsToken = resultObject.get("message").toString(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -37,7 +37,7 @@ public class DmsTools { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         formDatas.put("states", "0"); 
														 | 
														
														 | 
														
															         formDatas.put("states", "0"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         formDatas.put("pageSize", "9999"); 
														 | 
														
														 | 
														
															         formDatas.put("pageSize", "9999"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         formDatas.put("page", "0"); 
														 | 
														
														 | 
														
															         formDatas.put("page", "0"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        return RequestUtils.requestPost("http://121.43.55.7:2101/proxy_dms/content/selectContentList", headers, formDatas); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return RequestUtils.requestPost(Constant.DMS_selectContentList_URL, headers, formDatas); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public static JSONObject addContent(org.json.JSONObject formDatas) { 
														 | 
														
														 | 
														
															     public static JSONObject addContent(org.json.JSONObject formDatas) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -47,7 +47,7 @@ public class DmsTools { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } else { 
														 | 
														
														 | 
														
															         } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             headers.put("Token", getDmsToken()); 
														 | 
														
														 | 
														
															             headers.put("Token", getDmsToken()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        return RequestUtils.requestPost2("http://121.43.55.7:2101/proxy_dms/content/addContent", headers, formDatas); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return RequestUtils.requestPost2(Constant.DMS_addContent_URL, headers, formDatas); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public static JSONObject updateContent(org.json.JSONObject formDatas) { 
														 | 
														
														 | 
														
															     public static JSONObject updateContent(org.json.JSONObject formDatas) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -57,94 +57,6 @@ public class DmsTools { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } else { 
														 | 
														
														 | 
														
															         } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             headers.put("Token", getDmsToken()); 
														 | 
														
														 | 
														
															             headers.put("Token", getDmsToken()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        return RequestUtils.requestPost2("http://121.43.55.7:2101/proxy_dms/content/updateContent", headers, formDatas); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    public static void main(String[] args) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//      解析geojson文件并将学校名称和招生区域保存为一个Map<String(学校名称),String(招生区域geojson)> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//      是否检查数据(true:不更新DMS只检查文件数据,false:数据正确的前提下执行DMS更新操作) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Boolean ifDatas = false; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Map<String, org.json.JSONObject> fileDatas = new HashMap<>(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        String filePath = "C:\\Users\\Liumouren\\Desktop\\临时文件\\元以科技\\青浦\\教育局\\geojsonUpdate\\幼儿园更新.json"; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            StringBuilder stringBuilder = new StringBuilder(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            String line; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            while ((line = reader.readLine()) != null) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                stringBuilder.append(line); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            String jsonString = stringBuilder.toString(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            org.json.JSONObject jsonObject1 = new org.json.JSONObject(jsonString); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            JSONArray features = jsonObject1.getJSONArray("features"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//            System.out.println(features); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            for (int i = 0; i < features.length(); i++) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (features.getJSONObject(i).getJSONObject("properties").has("name") && features.getJSONObject(i).getJSONObject("geometry").getJSONArray("coordinates").length() > 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    String schoolName = features.getJSONObject(i).getJSONObject("properties").getString("name"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    features.getJSONObject(i).remove("properties"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    fileDatas.put(schoolName, features.getJSONObject(i)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } catch (IOException e) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            e.printStackTrace(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//      查询columnId为1477的所有数据 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        JSONObject dmsDatas1 = selectDms("1477"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//      遍历数据 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//        System.out.println(dmsDatas1); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        List<String> hasName = new ArrayList<>(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Map<String, org.json.JSONObject> newSchoolGeojson = new HashMap<>(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if ("200".equals(dmsDatas1.get("code").toString())) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//          请求成功,遍历数据 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            org.json.JSONObject dmsDataContents = new org.json.JSONObject(dmsDatas1.get("content").toString()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            JSONArray dmsDataList = dmsDataContents.getJSONArray("data"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            for (int i = 0; i < dmsDataList.length(); i++) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                org.json.JSONObject item = dmsDataList.getJSONObject(i); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (fileDatas.containsKey(item.getString("title"))) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//                  是否名字能匹配上,能的话记录一下id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    hasName.add(item.getString("title")); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    String id = item.getString("id"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    if (ifDatas) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        newSchoolGeojson.put(item.getString("title"), fileDatas.get(item.getString("title"))); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        newSchoolGeojson.put(item.getString("title") + "_" + id, fileDatas.get(item.getString("title"))); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    if (item.has("c_geojson") && item.getString("c_geojson").length() > 2) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        System.out.println("替换geojson的学校名称:" + item.getString("title")); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        System.out.println("新增geojson的学校名称:" + item.getString("title")); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if(ifDatas){ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            System.out.println("解析到的文件数据:" + fileDatas.size()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            System.out.println(newSchoolGeojson); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            for (String schoolName : fileDatas.keySet()) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (!newSchoolGeojson.containsKey(schoolName)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    System.err.println("DMS中不存在学校:" + schoolName); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        }else{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//      准备更新数据 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//      首先得到关键数据(id\columnId\modelId) 1542\1445 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            org.json.JSONObject params = new org.json.JSONObject(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            params.put("columnId", "1542"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            params.put("modelId", "1445"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            for (String schoolNameAndId : newSchoolGeojson.keySet()) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                String schoolName = schoolNameAndId.split("_")[0]; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                String id = schoolNameAndId.split("_")[1]; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                org.json.JSONObject paramsContent = new org.json.JSONObject(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                paramsContent.put("id", id); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                org.json.JSONObject cGeojson = new org.json.JSONObject(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                cGeojson.put("type", "FeatureCollection"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                JSONArray coordinates = new JSONArray(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                coordinates.put(newSchoolGeojson.get(schoolNameAndId)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                cGeojson.put("features", coordinates); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                paramsContent.put("c_geojson", cGeojson.toString()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                params.put("content", paramsContent); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                System.out.println("更新" + schoolName + updateContent(params)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-//      更新结束 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return RequestUtils.requestPost2(Constant.DMS_updateContent_URL, headers, formDatas); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 |