From 34d95fcf18561c5c12721065442a4aa7fe3a037e Mon Sep 17 00:00:00 2001 From: dearlin <1261008090@qq.com> Date: Thu, 22 Feb 2024 09:19:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=8D=A1=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../positioning/MapSettingController.java | 119 +++++++++++++ .../positioning/PositAlarmController.java | 79 +++++++++ .../positioning/UserCardController.java | 164 ++++++++++++++++++ src/main/java/com/zcloud/util/PLSUtil.java | 115 +++++++++++- 4 files changed, 470 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/zcloud/controller/positioning/MapSettingController.java create mode 100644 src/main/java/com/zcloud/controller/positioning/PositAlarmController.java create mode 100644 src/main/java/com/zcloud/controller/positioning/UserCardController.java diff --git a/src/main/java/com/zcloud/controller/positioning/MapSettingController.java b/src/main/java/com/zcloud/controller/positioning/MapSettingController.java new file mode 100644 index 0000000..ca570f9 --- /dev/null +++ b/src/main/java/com/zcloud/controller/positioning/MapSettingController.java @@ -0,0 +1,119 @@ +package com.zcloud.controller.positioning; + +import com.alibaba.fastjson.JSONObject; +import com.zcloud.controller.base.BaseController; +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.util.Jurisdiction; +import com.zcloud.util.PLSUtil; +import com.zcloud.util.ReturnMap; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.List; + +/** + * 说明:定位管理-告警管理 + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ +@Controller +@RequestMapping("/positAlarm") +public class MapSettingController extends BaseController { + /** + * @Description: 创建图层 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/list") + @ResponseBody + public ReturnMap list(Page page) throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.getLayerList( + Jurisdiction.getCORPINFO_ID(), page.getCurrentPage() + 1, page.getShowCount(), pageData.getString("keywords")); + if (body != null) { + List list = body.getJSONArray("rows").toJavaList(JSONObject.class); + returnMap.put("varList", list); + page.setTotalResult(body.getIntValue("total")); + returnMap.put("page", page); + } + return returnMap; + } + /** + * @Description: 处理告警 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/save") + @ResponseBody + public ReturnMap save() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralPost("/region/layer",pageData, Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + /** + * @Description: 详情 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/goEdit") + @ResponseBody + public ReturnMap goEdit() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralGetById("/region/layer/",Integer.parseInt(pageData.getString("layId")), Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + /** + * @Description: 修改 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/edit") + @ResponseBody + public ReturnMap edit() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralPut("/region/layer",pageData, Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + /** + * @Description: 修改 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/remove") + @ResponseBody + public ReturnMap remove() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralDelete("/region/layer/",Integer.parseInt(pageData.getString("layId")), Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + +} diff --git a/src/main/java/com/zcloud/controller/positioning/PositAlarmController.java b/src/main/java/com/zcloud/controller/positioning/PositAlarmController.java new file mode 100644 index 0000000..2aa6cea --- /dev/null +++ b/src/main/java/com/zcloud/controller/positioning/PositAlarmController.java @@ -0,0 +1,79 @@ +package com.zcloud.controller.positioning; + +import com.alibaba.fastjson.JSONObject; +import com.zcloud.controller.base.BaseController; +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.util.Jurisdiction; +import com.zcloud.util.PLSUtil; +import com.zcloud.util.ReturnMap; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.HashMap; +import java.util.List; + +/** + * 说明:定位管理-告警管理 + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ +@Controller +@RequestMapping("/positAlarm") +public class PositAlarmController extends BaseController { + /** + * @Description: 告警数据 来自人员定位系统 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/getAlArmDataList") + @ResponseBody + public ReturnMap getAlArmDataList(Page page) throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.getAlArmDataList( + Jurisdiction.getCORPINFO_ID(), page.getCurrentPage() + 1, page.getShowCount(), "", Integer.parseInt(pageData.getString("status")), Integer.parseInt(pageData.getString("eleType")) + ); + if (body != null) { + List list = body.getJSONArray("rows").toJavaList(JSONObject.class); + returnMap.put("varList", list); + page.setTotalResult(body.getIntValue("total")); + returnMap.put("page", page); + } + return returnMap; + } + /** + * @Description: 处理告警 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/alarmHandling") + @ResponseBody + public ReturnMap alarmHandling() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralPost("/region/alarm/alarmHandling",pageData, Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + @RequestMapping(value = "/alarmHandlingAll") + @ResponseBody + public ReturnMap alarmHandlingAll() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralPost("/region/alarm/alarmHandlingAll",pageData, Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + + +} diff --git a/src/main/java/com/zcloud/controller/positioning/UserCardController.java b/src/main/java/com/zcloud/controller/positioning/UserCardController.java new file mode 100644 index 0000000..87b44ff --- /dev/null +++ b/src/main/java/com/zcloud/controller/positioning/UserCardController.java @@ -0,0 +1,164 @@ +package com.zcloud.controller.positioning; + +import com.alibaba.fastjson.JSONObject; +import com.zcloud.controller.base.BaseController; +import com.zcloud.entity.Page; +import com.zcloud.entity.PageData; +import com.zcloud.util.Jurisdiction; +import com.zcloud.util.PLSUtil; +import com.zcloud.util.ReturnMap; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.List; + +/** + * 说明:用户定位卡管理 + * 作者:wangxuan + * 官网:www.zcloudchina.com + */ +@Controller +@RequestMapping("/deploy/card") +public class UserCardController extends BaseController { + + /** + * @Description: 人员卡管理 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/list") + @ResponseBody + public ReturnMap list(Page page) throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + page.setPd(pageData); + JSONObject body = PLSUtil.getUserCardDataList( + Jurisdiction.getCORPINFO_ID(), Integer.parseInt(pageData.getString("currentPage")), Integer.parseInt(pageData.getString("showCount")), pageData.getString("KEYWORDS")); + if (body != null) { + List list = body.getJSONArray("rows").toJavaList(JSONObject.class); + returnMap.put("varList", list); + page.setTotalResult(body.getIntValue("total")); + returnMap.put("page", page); + } + return returnMap; + } + + /** + * @Description: 修改卡信息 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/edit") + @ResponseBody + public ReturnMap edit() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralPut("/deploy/card", pageData, Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + + /** + * @Description: 可绑卡人信息 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/thePersonWhoDidNotBindTheCard") + @ResponseBody + public ReturnMap thePersonWhoDidNotBindTheCard() throws Exception { + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GetGeneral("/deploy/card/thePersonWhoDidNotBindTheCard", Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + + + /** + * @Description: 查找信息 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/goEdit") + @ResponseBody + public ReturnMap goEdit() throws Exception { + PageData pageData = getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralGetById("/deploy/card/feign-client/", Integer.parseInt(pageData.getString("cardNo")), Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + + /** + * @Description: 删除卡 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/remove") + @ResponseBody + public ReturnMap remove() throws Exception { + PageData pageData = getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralDelete("/deploy/card/", pageData.getString("DATA_IDS"), Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + + /** + * @Description: 批量解绑 + * @Author: dearLin + * @Date: 2024/1/26/026 16:43 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/batchUnbinding") + @ResponseBody + public ReturnMap removeBatch() throws Exception { + PageData pageData = getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralDelete("/deploy/card/batchUnbinding/", pageData.getString("DATA_IDS"), Jurisdiction.getCORPINFO_ID()); + if (body != null) { + if (!body.getString("code").equals("200")) return ReturnMap.error(body.getString("msg")); + returnMap.putAll(body); + } + return returnMap; + } + + /** + * @Description: 批量制卡 + * @Author: dearLin + * @Date: 2024/2/21/021 15:33 + * @Param: [] [] + * @Return: com.zcloud.util.ReturnMap + */ + @RequestMapping(value = "/addInBulk") + @ResponseBody + public ReturnMap addInBulk() throws Exception { + PageData pageData = this.getPageData(); + ReturnMap returnMap = new ReturnMap(); + JSONObject body = PLSUtil.GeneralPost("/deploy/card/addInBulk", pageData, Jurisdiction.getCORPINFO_ID()); + if (body != null) { + returnMap.putAll(body); + } + return returnMap; + } + +} diff --git a/src/main/java/com/zcloud/util/PLSUtil.java b/src/main/java/com/zcloud/util/PLSUtil.java index 1e7d152..6eb331a 100644 --- a/src/main/java/com/zcloud/util/PLSUtil.java +++ b/src/main/java/com/zcloud/util/PLSUtil.java @@ -1,5 +1,6 @@ package com.zcloud.util; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.zcloud.entity.PageData; import com.zcloud.service.corp.CorpPlsInfoService; @@ -44,6 +45,17 @@ public class PLSUtil { return exchange.getBody(); } + public static JSONObject GetGeneral(String url, String CORPINFO_ID) throws Exception { + 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, + HttpMethod.GET, httpEntity, + JSONObject.class); + return exchange.getBody(); + } + @Autowired public void setCorpplsinfoService(CorpPlsInfoService corpplsinfoServicebean, UsersService usersServicebean, RestTemplate restTemplatebean) { corpplsinfoService = corpplsinfoServicebean; @@ -69,6 +81,69 @@ public class PLSUtil { return exchange.getBody(); } + public static JSONObject GeneralPost(String Url, PageData pageData, String CORPINFO_ID) throws Exception { + JSONObject uriVariables = JSONObject.parseObject(JSON.toJSONString(pageData)); + 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, + HttpMethod.POST, + httpEntity, + JSONObject.class); + return exchange.getBody(); + } + + public static JSONObject GeneralGetById(String Url, Integer id, String CORPINFO_ID) throws Exception { + 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, + HttpMethod.GET, + httpEntity, + JSONObject.class); + return exchange.getBody(); + } + public static JSONObject GeneralPut(String Url, PageData pageData, String CORPINFO_ID) throws Exception { + JSONObject uriVariables = JSONObject.parseObject(JSON.toJSONString(pageData)); + 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, + HttpMethod.PUT, + httpEntity, + JSONObject.class); + return exchange.getBody(); + } + public static JSONObject GeneralDelete(String Url, Object id, String CORPINFO_ID) throws Exception { + 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, + HttpMethod.DELETE, + httpEntity, + JSONObject.class); + return exchange.getBody(); + } + /** + * @Description: 电子围栏列表 + * @Author: dearLin + * @Date: 2024/1/25/025 14:37 + * @Param: [java.lang.String, java.lang.Integer, java.lang.Integer] [keywords, currentPage, showCount] + * @Return: com.alibaba.fastjson.JSONObject + */ + public static JSONObject getLayerList(String CORPINFO_ID, Integer currentPage, Integer showCount, String keywords) throws Exception { + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", getToken(CORPINFO_ID)); + + HttpEntity httpEntity = new HttpEntity<>(headers); + String url = "/region/layer/list?pageNum=" + currentPage + "&pageSize=" + showCount + "&str="; + if (Tools.notEmpty(keywords)) { + url = url + keywords; + } + ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + url + , HttpMethod.GET, httpEntity, JSONObject.class); + return exchange.getBody(); + } /** * @Description: 电子围栏列表 @@ -77,7 +152,7 @@ public class PLSUtil { * @Param: [java.lang.String, java.lang.Integer, java.lang.Integer] [keywords, currentPage, showCount] * @Return: com.alibaba.fastjson.JSONObject */ - public static JSONObject getAlArmDataList(String CORPINFO_ID, Integer currentPage, Integer showCount ,String keywords,Integer status,Integer eleType) throws Exception { + public static JSONObject getAlArmDataList(String CORPINFO_ID, Integer currentPage, Integer showCount, String keywords, Integer status, Integer eleType) throws Exception { HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", getToken(CORPINFO_ID)); @@ -85,11 +160,36 @@ public class PLSUtil { // currentPage + "&pageSize=" + showCount +"&str=" + "&eleType="+eleType+ "&status="+status HttpEntity httpEntity = new HttpEntity<>(headers); ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + - "/region/alarm/list?eleType="+eleType+"+&status="+status+"&pageNum="+currentPage+"&pageSize="+showCount+"&str=" - ,HttpMethod.GET, httpEntity, JSONObject.class); + "/region/alarm/list?eleType=" + eleType + "+&status=" + status + "&pageNum=" + currentPage + "&pageSize=" + showCount + "&str=" + , HttpMethod.GET, httpEntity, JSONObject.class); return exchange.getBody(); } + + /** + * @Description: 人员卡列表 + * @Author: dearLin + * @Date: 2024/1/25/025 14:37 + * @Param: [java.lang.String, java.lang.Integer, java.lang.Integer] [keywords, currentPage, showCount] + * @Return: com.alibaba.fastjson.JSONObject + */ + public static JSONObject getUserCardDataList(String CORPINFO_ID, Integer currentPage, Integer showCount, String keywords) throws Exception { + HttpHeaders headers = new HttpHeaders(); + + headers.set("Authorization", getToken(CORPINFO_ID)); + String url = "/deploy/card/list?pageNum=" + currentPage + "&pageSize=" + showCount + "&str="; + if (Tools.notEmpty(keywords)) { + url = url + keywords; + } + HttpEntity httpEntity = new HttpEntity<>(headers); + ResponseEntity exchange = restTemplate.exchange(PLSUtil.BAKEADDR.get(CORPINFO_ID) + url + , HttpMethod.GET, httpEntity, JSONObject.class); + return exchange.getBody(); + } + + + + /** * @Description: 查询摄像头 * @Author: dearLin @@ -214,7 +314,7 @@ public class PLSUtil { } /** - * @Description: 当前在线人员实时位置信息 + * @Description: 当前在线人员实时位置信息 * @Date: 2024/1/25/025 14:37 * @Return: com.alibaba.fastjson.JSONObject */ @@ -556,7 +656,7 @@ public class PLSUtil { * 获取区域内随机坐标点 * * @param polygon [[lng,lat,alt],[lng,lat,alt],[lng,lat,alt],...] - * @return [lng,lat,alt] + * @return [lng, lat, alt] * @throws IOException */ public static List getRandomPointInPolygon(List> polygon) { @@ -578,7 +678,7 @@ public class PLSUtil { Double y = minY + rand.nextDouble() * (maxY - minY); if (pointInPolygon(polygon, x, y)) { - List point = Arrays.asList(x.toString(),y.toString(),polygon.get(0).get(2).toString()); + List point = Arrays.asList(x.toString(), y.toString(), polygon.get(0).get(2).toString()); return point; } } @@ -586,12 +686,13 @@ public class PLSUtil { /** * 判断点是否在多边形内 + * * @param polygon * @param lng * @param lat * @return */ - private static boolean pointInPolygon(List> polygon,double lng, double lat) { + private static boolean pointInPolygon(List> polygon, double lng, double lat) { boolean inside = false; int n = polygon.size(); for (int i = 0, j = n - 1; i < n; j = i++) {