Commit da401e13c162bd49017537d3af365afc9bfa722a
Merge branch 'dev' of http://61.169.120.202:8888/youxiw20000/trash into dev
Showing
2 changed files
with
71 additions
and
3 deletions
trash-common/src/main/java/com/trash/common/utils/RemoteServerUtils.java
| ... | ... | @@ -99,6 +99,8 @@ public class RemoteServerUtils { |
| 99 | 99 | |
| 100 | 100 | public static String GETAUTH = "/api/gpsservice/cs/authority"; |
| 101 | 101 | |
| 102 | + public static String AREAS = "/api/gisservice/v2/jurisdictions/areas?dict=1"; | |
| 103 | + | |
| 102 | 104 | public static JSONArray getUnitetransport(String id) { |
| 103 | 105 | JSONArray list = null; |
| 104 | 106 | try { |
| ... | ... | @@ -1301,8 +1303,29 @@ public class RemoteServerUtils { |
| 1301 | 1303 | return get(GETAUTH, null, token.replace("Bearer ", "")); |
| 1302 | 1304 | } |
| 1303 | 1305 | |
| 1304 | - | |
| 1305 | - | |
| 1306 | - | |
| 1306 | + | |
| 1307 | + public static String getAreasList(){ | |
| 1308 | + if (okHttpClient == null) { | |
| 1309 | + okHttpClient = getOkClient(); | |
| 1310 | + } | |
| 1311 | + | |
| 1312 | + String token = SecurityUtils.getLoginUser().getToken(); | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + if (token.contains("durable:")) { | |
| 1316 | + token = "Bearer " + token; | |
| 1317 | + } else { | |
| 1318 | + token = "Bearer auth:token:" + token; | |
| 1319 | + } | |
| 1320 | + Request request = new Request.Builder().url(remote + AREAS).addHeader("Authorization", token).get().build(); | |
| 1321 | + try { | |
| 1322 | + okhttp3.Response response = okHttpClient.newCall(request).execute(); | |
| 1323 | + String result = response.body().string(); | |
| 1324 | + return result; | |
| 1325 | + } catch (Exception e) { | |
| 1326 | + e.printStackTrace(); | |
| 1327 | + return null; | |
| 1328 | + } | |
| 1329 | + } | |
| 1307 | 1330 | |
| 1308 | 1331 | } | ... | ... |
trash-unit/src/main/java/com/trash/dropPointInfo/controller/DropPointInfoController.java
| 1 | 1 | package com.trash.dropPointInfo.controller; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | + | |
| 5 | +import com.alibaba.fastjson.JSONArray; | |
| 6 | +import com.alibaba.fastjson.JSONObject; | |
| 7 | +import com.trash.common.utils.RemoteServerUtils; | |
| 4 | 8 | import org.springframework.security.access.prepost.PreAuthorize; |
| 5 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | 10 | import org.springframework.web.bind.annotation.GetMapping; |
| ... | ... | @@ -54,6 +58,47 @@ public class DropPointInfoController extends BaseController |
| 54 | 58 | public AjaxResult export(DropPointInfo dropPointInfo) |
| 55 | 59 | { |
| 56 | 60 | List<DropPointInfo> list = dropPointInfoService.selectDropPointInfoList(dropPointInfo); |
| 61 | + JSONArray jsonArray = new JSONArray(); | |
| 62 | + try{ | |
| 63 | + jsonArray = JSONArray.parseArray(RemoteServerUtils.getAreasList()); | |
| 64 | + }catch(NullPointerException exception){ | |
| 65 | + return AjaxResult.error("获取区县信息失败"); | |
| 66 | + } | |
| 67 | + | |
| 68 | + JSONArray cs = new JSONArray(); | |
| 69 | + for(Object jsonObject : jsonArray){ | |
| 70 | + JSONObject jsonObject1 = (JSONObject) jsonObject; | |
| 71 | + if(jsonObject1.getString("code").equals("430100")){ | |
| 72 | + cs = jsonObject1.getJSONArray("items"); | |
| 73 | + break; | |
| 74 | + } | |
| 75 | + } | |
| 76 | + for(DropPointInfo dropPointInfo1 : list){ | |
| 77 | + for(Object jsonObject : cs){ | |
| 78 | + JSONObject jsonObject1 = (JSONObject) jsonObject; | |
| 79 | + if(dropPointInfo1.getDistrict().equals(jsonObject1.getString("code"))){ | |
| 80 | + dropPointInfo1.setDistrict(jsonObject1.getString("name")); | |
| 81 | + } | |
| 82 | + if(jsonObject1.getJSONArray("items")!=null) { | |
| 83 | + for(Object jsonObject2 : jsonObject1.getJSONArray("items")){ | |
| 84 | + JSONObject jsonObject3 = (JSONObject) jsonObject2; | |
| 85 | + if(dropPointInfo1.getStreet().equals(jsonObject3.getString("code"))){ | |
| 86 | + dropPointInfo1.setStreet(jsonObject3.getString("name")); | |
| 87 | + } | |
| 88 | + if(jsonObject3.getJSONArray("items")!=null){ | |
| 89 | + for(Object jsonObject4 : jsonObject3.getJSONArray("items")){ | |
| 90 | + JSONObject jsonObject5 = (JSONObject) jsonObject4; | |
| 91 | + if(dropPointInfo1.getCommunity().equals(jsonObject5.getString("code"))){ | |
| 92 | + dropPointInfo1.setCommunity(jsonObject5.getString("name")); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + } | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 99 | + } | |
| 100 | + } | |
| 101 | + System.out.println(cs); | |
| 57 | 102 | ExcelUtil<DropPointInfo> util = new ExcelUtil<DropPointInfo>(DropPointInfo.class); |
| 58 | 103 | return util.exportExcel(list, "投放点信息管理"); |
| 59 | 104 | } | ... | ... |