From f7ebc6a95846ab66e9e4eabda86e065b4e2d0763 Mon Sep 17 00:00:00 2001 From: dearlin <1261008090@qq.com> Date: Fri, 1 Mar 2024 11:41:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AB=E9=A1=B9=E4=BD=9C=E4=B8=9A=E4=B8=8E?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=89=E6=96=B9=E5=AE=9A=E4=BD=8D=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=90=8E=E5=8F=B0=E5=9C=B0=E5=9D=80=E7=9A=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/zcloud/util/PLSUtil.java | 75 +++++++++++-------- .../datasource/eightwork/EightWorkMapper.xml | 2 +- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/zcloud/util/PLSUtil.java b/src/main/java/com/zcloud/util/PLSUtil.java index 420c5ca..5f08950 100644 --- a/src/main/java/com/zcloud/util/PLSUtil.java +++ b/src/main/java/com/zcloud/util/PLSUtil.java @@ -39,7 +39,7 @@ public class PLSUtil { headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); ResponseEntity exchange = restTemplate.exchange( - PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/deploy/card/list?sortThePowerLevel=1&pageNum=" + + getBakeAddr(CORPINFO_ID) + "/deploy/card/list?sortThePowerLevel=1&pageNum=" + currentPage + "&pageSize=" + showCount, HttpMethod.GET, httpEntity, @@ -52,7 +52,7 @@ public class PLSUtil { headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); ResponseEntity exchange = restTemplate.exchange( - PLSUtil.BAKEADDR.get(CORPINFO_ID) + url, + getBakeAddr(CORPINFO_ID) + url, HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); @@ -77,7 +77,7 @@ public class PLSUtil { headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); ResponseEntity exchange = restTemplate.exchange( - PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/region/alarm/alarmStatistics?type=day", + getBakeAddr(CORPINFO_ID) + "/region/alarm/alarmStatistics?type=day", HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); @@ -88,7 +88,7 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(uriVariables, headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + Url, + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + Url, HttpMethod.POST, httpEntity, JSONObject.class); @@ -99,7 +99,7 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + Url + id, + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + Url + id, HttpMethod.GET, httpEntity, JSONObject.class); @@ -112,7 +112,7 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + Url + params, + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + Url + params, HttpMethod.GET, httpEntity, JSONObject.class); @@ -124,7 +124,7 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(uriVariables, headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + Url, + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + Url, HttpMethod.PUT, httpEntity, JSONObject.class); @@ -135,7 +135,7 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + Url + id, + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + Url + id, HttpMethod.DELETE, httpEntity, JSONObject.class); @@ -158,7 +158,7 @@ public class PLSUtil { if (Tools.notEmpty(keywords)) { url = url + keywords; } - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + url + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + url , HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -177,7 +177,7 @@ public class PLSUtil { // "/region/alarm/list?pageNum=" + // currentPage + "&pageSize=" + showCount +"&str=" + "&eleType="+eleType+ "&status="+status HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/region/alarm/list?eleType=" + eleType + "+&status=" + status + "&pageNum=" + currentPage + "&pageSize=" + showCount + "&str=" , HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); @@ -200,7 +200,7 @@ public class PLSUtil { url = url + keywords; } HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + url + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + url , HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -217,7 +217,7 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/device/camera/list?pageNum=1&pageSize=100000&str=", HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -246,11 +246,11 @@ public class PLSUtil { uriVariables.put("alt", ""); HttpEntity httpEntity = new HttpEntity<>(uriVariables, headers); // HttpEntity httpEntity = new HttpEntity<>(uriVariables,headers); -// ResponseEntity jsonObjectResponseEntity = restTemplate.postForEntity(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/device/camera", +// ResponseEntity jsonObjectResponseEntity = restTemplate.postForEntity(getBakeAddr(CORPINFO_ID) + "/device/camera", // httpEntity, JSONObject.class); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/device/camera", + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/device/camera", HttpMethod.POST, httpEntity, JSONObject.class); @@ -273,7 +273,7 @@ public class PLSUtil { uriVariables.put("camName", camera.getString("VIDEONAME")); uriVariables.put("camId", camera.getString("PLS_ID")); HttpEntity httpEntity = new HttpEntity<>(uriVariables, headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/device/camera", + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/device/camera", HttpMethod.PUT, httpEntity, JSONObject.class, uriVariables); return exchange.getBody(); @@ -290,7 +290,7 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/device/camera/" + Integer.parseInt(camera.getString("PLS_ID")), HttpMethod.DELETE, httpEntity, JSONObject.class); + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/device/camera/" + Integer.parseInt(camera.getString("PLS_ID")), HttpMethod.DELETE, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -311,7 +311,7 @@ public class PLSUtil { if (Tools.notEmpty(keywords)) url += keywords; headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + url, HttpMethod.GET, httpEntity, JSONObject.class); + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + url, HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -325,7 +325,7 @@ public class PLSUtil { headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/region/region/list?pageNum=" + + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/region/region/list?pageNum=" + currentPage + "&pageSize=" + showCount, HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); @@ -341,7 +341,7 @@ public class PLSUtil { headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/region/region/" + + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/region/region/" + id, HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -355,7 +355,7 @@ public class PLSUtil { headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/location/loca/personnelTrajectories",HttpMethod.GET, httpEntity, JSONObject.class); + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/location/loca/personnelTrajectories",HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -375,7 +375,7 @@ public class PLSUtil { uriVariables.put("type", type); HttpEntity httpEntity = new HttpEntity<>(uriVariables, headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/location/loca/characterTrajectories", + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/location/loca/characterTrajectories", HttpMethod.POST, httpEntity, JSONObject.class); @@ -393,7 +393,7 @@ public class PLSUtil { headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/api/prod-api/coordinate/realTime/data", HttpMethod.GET, httpEntity, JSONObject.class); + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/api/prod-api/coordinate/realTime/data", HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } @@ -408,21 +408,30 @@ public class PLSUtil { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + "/region/api/electronicFence/determineWhetherThePersonIsInTheElectronicFence2?psn=" + + ResponseEntity exchange = restTemplate.exchange(getBakeAddr(CORPINFO_ID) + "/region/api/electronicFence/determineWhetherThePersonIsInTheElectronicFence2?psn=" + PLS_ID + "&id=" + ELECTRONIC_FENCE_ID, HttpMethod.GET, httpEntity, Boolean.class); return exchange.getBody(); } - @PostConstruct - private void initBakeAddr() throws Exception { - List dataList = corpplsinfoService.listAll(new PageData()); + private static void initBakeAddr(){ + List dataList = null; + try { + dataList = corpplsinfoService.listAll(new PageData()); + } catch (Exception e) { + throw new RuntimeException(e); + } dataList.forEach(item -> { BAKEADDR.put(item.getString("CORPINFO_ID"), item.getString("POST_URL")); }); } - + private static String getBakeAddr(String CORPINFO_ID) throws Exception { + return BAKEADDR.computeIfAbsent(CORPINFO_ID, key -> { + initBakeAddr(); + return BAKEADDR.get(CORPINFO_ID); + }); + } /** * @Description: 获取token * @Author: dearLin @@ -449,7 +458,7 @@ public class PLSUtil { if (response != null) { PageData valueData = JSONObject.parseObject(response.getString("data"), PageData.class); token = valueData.getString("access_token"); - String newExpireTime = DateUtil.getAfterHourDate("12"); + String newExpireTime = DateUtil.getAfterHourDate("24"); pd.put("TOKEN", token); pd.put("EXPIRE_TIME", newExpireTime); corpplsinfoService.edit(pd); @@ -472,7 +481,7 @@ public class PLSUtil { public static boolean hasCardNumber(PageData user) throws Exception { if (Tools.isEmpty(user.getString("CARDNO"))) {return true;} // 根据 定位卡号获取对应的人 - String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/card/peopleDisplay/" + user.getString("CARDNO"); + String url = getBakeAddr(Jurisdiction.getCORPINFO_ID()) + "/deploy/card/peopleDisplay/" + user.getString("CARDNO"); PageData response = sendGetHttpRequest(url, null, getToken(Jurisdiction.getCORPINFO_ID())); if (response != null) { if (!"200".equals(response.getString("code"))) { @@ -493,7 +502,7 @@ public class PLSUtil { */ public static PageData getCardNumberPeople(PageData user) throws Exception { // 根据 定位卡号获取对应的人 - String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/card/peopleDisplay/" + user.getString("CARDNO"); + String url = getBakeAddr(Jurisdiction.getCORPINFO_ID()) + "/deploy/card/peopleDisplay/" + user.getString("CARDNO"); PageData response = sendGetHttpRequest(url, null, getToken(Jurisdiction.getCORPINFO_ID())); if (response != null) { if (!"200".equals(response.getString("code"))) { @@ -513,7 +522,7 @@ public class PLSUtil { * @Return: void */ public static PageData saveUser(PageData user) throws Exception { - String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt/insertPsnIfon"; + String url = getBakeAddr(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt/insertPsnIfon"; JSONObject loginPayload = new JSONObject(); loginPayload.put("name", user.getString("NAME")); loginPayload.put("cardNo", user.getString("CARDNO")); @@ -555,7 +564,7 @@ public class PLSUtil { } return false; } - String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt/updPsnInfoById"; + String url = getBakeAddr(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt/updPsnInfoById"; JSONObject loginPayload = new JSONObject(); loginPayload.put("name", user.getString("NAME")); loginPayload.put("psnId", user.getString("PLS_ID")); @@ -582,7 +591,7 @@ public class PLSUtil { } public static boolean removeUser(PageData user) throws Exception { - String url = BAKEADDR.get(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt"; + String url = getBakeAddr(Jurisdiction.getCORPINFO_ID()) + "/deploy/psnmgt"; PageData removeUser = usersService.findById(user); PageData response = sendDeleteHttpRequest(url, Long.parseLong(removeUser.getString("PLS_ID")), getToken(Jurisdiction.getCORPINFO_ID())); return "200".equals(response.getString("code")); diff --git a/src/main/resources/mybatis/datasource/eightwork/EightWorkMapper.xml b/src/main/resources/mybatis/datasource/eightwork/EightWorkMapper.xml index 3f88384..755f332 100644 --- a/src/main/resources/mybatis/datasource/eightwork/EightWorkMapper.xml +++ b/src/main/resources/mybatis/datasource/eightwork/EightWorkMapper.xml @@ -98,6 +98,6 @@ ) tmp group by tmp.WORK_ID) log on log.WORK_ID = f.${TYPE}_ID where f.ISDELETE = '0' and f.WORK_POSITION is not null and f.CORPINFO_ID = #{CORPINFO_ID} - and f.STEP_ID > 0 and log.NEXT_STEP_ID != 99 +-- and f.STEP_ID > 0 and log.NEXT_STEP_ID != 99