From 7a880de423619dc266a60dc643794ba626f7131f Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期二, 22 八月 2023 10:48:55 +0800
Subject: [PATCH] 修复sdk请求用户为null的bug
---
ard-work/src/main/java/com/ruoyi/utils/tools/Point.java | 23 +++++++++++
ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java | 19 +++++++++
ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java | 26 ++++++------
ard-work/src/main/java/com/ruoyi/scheduling/controller/SchedulingController.java | 4 +-
ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java | 4 +-
ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java | 5 +-
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java | 5 +-
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java | 4 ++
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java | 8 ++-
9 files changed, 74 insertions(+), 24 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
index 905531f..a9d10ef 100644
--- a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
@@ -13,6 +13,7 @@
import com.ruoyi.scheduling.domian.SchedulingParam;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.tools.GisTool;
+import com.ruoyi.utils.tools.Point;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -183,7 +184,7 @@
List<SysUser> filteredList = new ArrayList<>();
try {
Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
- List<Point2D> partitionLocation = param.getPartitionLocation();
+ List<Point> partitionLocation = param.getPartitionLocation();
SysUser user = new SysUser();
user.setDeptId(deptId);
@@ -201,7 +202,7 @@
if (lon == null || lat == null) {
continue;
}
- Point2D point2D=new Point2D.Double(lon,lat);
+ Point point2D=new Point(lon,lat);
boolean inPolygon = GisTool.isInPolygon(point2D, partitionLocation);
if (inPolygon) {
Map<String, Object> params = new HashMap<>();
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
index 6792122..1af864c 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
@@ -26,6 +26,7 @@
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.utils.tools.GisTool;
+import com.ruoyi.utils.tools.Point;
import com.sun.org.apache.bcel.internal.generic.NEW;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -357,7 +358,7 @@
public List<ArdCameras> getNearCamerasWithPolygon(SchedulingParam param) {
try {
Long deptId=SecurityUtils.getLoginUser().getUser().getDeptId();
- List<Point2D> partitionLocation = param.getPartitionLocation();
+ List<Point> partitionLocation = param.getPartitionLocation();
if(partitionLocation==null)
{
log.debug("澶氳竟褰㈠潗鏍囬泦鍚堜负绌�");
@@ -374,7 +375,7 @@
continue;
}
/*鍒ゆ柇鍧愭爣鏄惁鍦ㄥ杈瑰舰鑼冨洿鍐�*/
- Point2D camPosition=new Point2D.Double(camera.getLongitude(), camera.getLatitude());
+ Point camPosition=new Point(camera.getLongitude(), camera.getLatitude());
boolean inPolygon = GisTool.isInPolygon(camPosition, partitionLocation);
if (inPolygon) {
/*鑾峰彇閫氶亾鍒楄〃*/
diff --git a/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java b/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java
index 8bd7d2f..5ea793d 100644
--- a/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java
@@ -83,6 +83,7 @@
@Log(title = "鍦ㄧ嚎鐘舵��", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult getOnlineState(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.isOnLine(cmd));
}
@@ -104,6 +105,7 @@
@Log(title = "璋冪敤棰勭疆鐐�", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult gotoPreset(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.gotoPreset(cmd));
}
@@ -113,6 +115,7 @@
@Log(title = "璁剧疆棰勭疆鐐�", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult setPreset(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.setPreset(cmd));
}
@@ -122,6 +125,7 @@
@Log(title = "鑾峰彇鑱氱劍鍊�", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult getFocusPos(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
Map<String, Object> Map = sdk.getFocusPos(cmd);
return AjaxResult.success("鑾峰彇鑱氱劍鍊�", Map);
}
@@ -132,6 +136,7 @@
@Log(title = "璁剧疆鑱氱劍鍊�", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult setFocusPos(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.setFocusPos(cmd));
}
@@ -141,6 +146,7 @@
@Log(title = "鑾峰彇PTZ", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult GetPTZ(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
Map<String, Object> ptzMap = sdk.getPtz(cmd);
return AjaxResult.success("鑾峰彇ptz", ptzMap);
}
@@ -151,6 +157,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum"})
public @ResponseBody
AjaxResult GetPTZScope(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
Map<String, Object> ptzMap = sdk.getPtzScope(cmd);
return AjaxResult.success("鑾峰彇ptz鑼冨洿", ptzMap);
}
@@ -171,6 +178,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.targetPosition"})
public @ResponseBody
AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.guideTargetPosition(cmd));
}
@@ -181,6 +189,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum"})
public @ResponseBody
AjaxResult SetZeroPTZ(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.setZeroPtz(cmd));
}
@@ -210,6 +219,7 @@
@Log(title = "鑾峰彇浜戝彴閿佸畾淇℃伅", businessType = BusinessType.CONTROL)
public @ResponseBody
AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
int byWorkMode = sdk.getPTZLockInfo(cmd);
if (byWorkMode == 0) {
return AjaxResult.success("浜戝彴閿佸畾鐘舵�侊細瑙i攣");
@@ -226,6 +236,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.enable"})
public @ResponseBody
AjaxResult defogcfg(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.controlDefogcfg(cmd));
}
@@ -235,6 +246,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.enable"})
public @ResponseBody
AjaxResult infrarecfg(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.controlInfrarecfg(cmd));
}
@@ -244,6 +256,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.enable"})
public @ResponseBody
AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.controlFocusMode(cmd));
}
@@ -251,6 +264,7 @@
@PostMapping("/getFocusMode")
public @ResponseBody
AjaxResult getFocusMode(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
String focusMode = sdk.getFocusMode(cmd);
return AjaxResult.success(focusMode);
}
@@ -261,6 +275,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.enable"})
public @ResponseBody
AjaxResult HeateRpwron(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.controlPTHeateRpwron(cmd));
}
@@ -271,12 +286,14 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.enable"})
public @ResponseBody
AjaxResult CameraDeicing(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
return toAjax(sdk.controlCameraDeicing(cmd));
}
@PostMapping("/captureJPEGPicture")
public @ResponseBody
AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
String base64Str = sdk.captureJPEGPicture(cmd);
return toAjaxString(base64Str, "鐩告満鎶撳浘");
}
@@ -287,6 +304,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum"})
public @ResponseBody
AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
String path = sdk.picCutCate(cmd);
return toAjaxString(path, "鐩告満鎶撳浘");
}
@@ -297,6 +315,7 @@
@ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.channelNum", "cmd.enable"})
public @ResponseBody
AjaxResult record(@RequestBody CameraCmd cmd) {
+ cmd.setOperator(SecurityUtils.getUserId());
String path = sdk.record(cmd);
return toAjaxString(path, "鎵嬪姩褰曞儚");
}
diff --git a/ard-work/src/main/java/com/ruoyi/scheduling/controller/SchedulingController.java b/ard-work/src/main/java/com/ruoyi/scheduling/controller/SchedulingController.java
index 5a75f3b..4727673 100644
--- a/ard-work/src/main/java/com/ruoyi/scheduling/controller/SchedulingController.java
+++ b/ard-work/src/main/java/com/ruoyi/scheduling/controller/SchedulingController.java
@@ -51,9 +51,9 @@
return AjaxResult.success(nearMap);
}
- @GetMapping("/getPolygonVehiPersonCam")
+ @PostMapping("/getPolygonVehiPersonCam")
@ApiOperation("鑾峰彇闄勮繎鐨勮溅浜虹浉鏈�(澶氳竟褰�)")
- AjaxResult getPolygonVehiPersonCam(SchedulingParam param) {
+ AjaxResult getPolygonVehiPersonCam(@RequestBody SchedulingParam param) {
Map<String, Object> nearMap = new HashMap<>();
List<Map<String, Object>> Cars = iArdSyCarService.getNearCarWithPolygon(param);
nearMap.put("car", Cars);
diff --git a/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java b/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java
index 0c85e9d..63840af 100644
--- a/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java
+++ b/ard-work/src/main/java/com/ruoyi/scheduling/domian/SchedulingParam.java
@@ -1,8 +1,8 @@
package com.ruoyi.scheduling.domian;
+import com.ruoyi.utils.tools.Point;
import lombok.Data;
-import java.awt.geom.Point2D;
import java.util.List;
/**
@@ -20,5 +20,5 @@
Double longitude;
Double latitude;
//澶氳竟褰㈠潗鏍囬泦鍚�
- List<Point2D> partitionLocation;
+ List<Point> partitionLocation;
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
index cb494e3..6624a81 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
@@ -6,6 +6,7 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Predicate;
@@ -17,6 +18,7 @@
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.utils.tools.Point;
import com.ruoyi.scheduling.domian.SchedulingParam;
import com.ruoyi.sy.domain.ArdSyCarDay;
import com.ruoyi.sy.mapper.ArdSyCarDayMapper;
@@ -1099,7 +1101,7 @@
public List<Map<String, Object>> getNearCarWithPolygon(SchedulingParam param) {
List<Map<String, Object>> filteredList = new ArrayList<>();
try {
- List<Point2D> partitionLocation = param.getPartitionLocation();
+ List<Point> partitionLocation = param.getPartitionLocation();
if (partitionLocation == null) {
log.debug("澶氳竟褰㈠潗鏍囬泦鍚堜负绌�");
return null;
@@ -1141,8 +1143,8 @@
List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list");
Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng"));
Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat"));
- Point2D point2D = new Point2D.Double(lng, lat);
- boolean inPolygon = GisTool.isInPolygon(point2D, partitionLocation);
+ Point point = new Point(lng, lat);
+ boolean inPolygon = GisTool.isInPolygon(point, partitionLocation);
if (inPolygon) {
carMap.put("longitude", lng);
carMap.put("latitude", lat);
diff --git a/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java b/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java
index bb36308..4682ff7 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java
@@ -36,14 +36,14 @@
public static void main(String[] args) {
// 琚娴嬬殑缁忕含搴︾偣
- Point2D point2D= new Point2D.Double(126.649261,45.687377);
+ Point point= new Point(126.649261,45.687377);
// 鍟嗕笟鍖哄煙锛堢櫨搴﹀杈瑰舰鍖哄煙缁忕含搴﹂泦鍚堬級
- List<Point2D> partitionLocation = new ArrayList<>();
- partitionLocation.add(new Point2D.Double(126.64459,45.688548));
- partitionLocation.add(new Point2D.Double(126.653376,45.68938));
- partitionLocation.add(new Point2D.Double(126.645776,45.685048));
- partitionLocation.add(new Point2D.Double(126.654184,45.685778));
- System.out.println(isInPolygon(point2D,partitionLocation));
+ List<Point> partitionLocation = new ArrayList<>();
+ partitionLocation.add(new Point(126.64459,45.688548));
+ partitionLocation.add(new Point(126.653376,45.68938));
+ partitionLocation.add(new Point(126.645776,45.685048));
+ partitionLocation.add(new Point(126.654184,45.685778));
+ System.out.println(isInPolygon(point,partitionLocation));
}
/**
@@ -52,17 +52,17 @@
* @param partitionLocation 鍖哄煙椤剁偣
* @return
*/
- public static boolean isInPolygon(Point2D orderLocation,List<Point2D> partitionLocation){
+ public static boolean isInPolygon(Point orderLocation,List<Point> partitionLocation){
- double p_x =orderLocation.getX();
- double p_y =orderLocation.getY();
+ double p_x =orderLocation.getLongitude();
+ double p_y =orderLocation.getLatitude();
Point2D.Double point = new Point2D.Double(p_x, p_y);
List<Point2D.Double> pointList= new ArrayList<Point2D.Double>();
- for (Point2D points : partitionLocation){
- double polygonPoint_x=points.getX();
- double polygonPoint_y=points.getY();
+ for (Point points : partitionLocation){
+ double polygonPoint_x=points.getLongitude();
+ double polygonPoint_y=points.getLatitude();
Point2D.Double polygonPoint = new Point2D.Double(polygonPoint_x,polygonPoint_y);
pointList.add(polygonPoint);
}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/tools/Point.java b/ard-work/src/main/java/com/ruoyi/utils/tools/Point.java
new file mode 100644
index 0000000..6035a64
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/utils/tools/Point.java
@@ -0,0 +1,23 @@
+package com.ruoyi.utils.tools;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+/**
+ * @Description:
+ * @ClassName: Point
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2023骞�08鏈�22鏃�9:56:58
+ * @Version: 1.0
+ **/
+@Data
+public class Point{
+ private static final long serialVersionUID = 1L;
+ private Double longitude;
+ private Double latitude;
+
+ public Point(Double x, Double y) {
+ this.longitude = x;
+ this.latitude = y;
+ }
+}
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java
index 156446a..79b736c 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java
@@ -100,6 +100,10 @@
} else {
/*褰撳墠鎺у埗鑰呬负鏅�氱敤鎴�*/
SysUser sysUser = sysUserService.selectUserById(currentOperator);
+ if(StringUtils.isNull(sysUser))
+ {
+ return false;
+ }
currentLevel = Integer.valueOf(sysUser.getCameraPriority());
}
Integer operatorLevel = 0;//鑾峰彇鐢宠鑰呯殑浼樺厛绾�
--
Gitblit v1.9.3