From 065142057ba3983af899991085e37ac1ec502320 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期二, 19 九月 2023 14:06:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 88 insertions(+), 25 deletions(-)
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 bf19a74..6cd7616 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
@@ -5,6 +5,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;
@@ -16,24 +17,22 @@
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.utils.gis.GisUtil;
+import com.ruoyi.utils.gis.Point;
import com.ruoyi.scheduling.domian.SchedulingParam;
import com.ruoyi.sy.domain.ArdSyCarDay;
import com.ruoyi.sy.mapper.ArdSyCarDayMapper;
-import com.ruoyi.utils.tools.GisTool;
+import com.ruoyi.utils.minio.MinioUtil;
import com.ruoyi.utils.websocket.util.WebSocketUtils;
-import com.ruoyi.device.hiksdk.config.MinioClientSingleton;
-import com.ruoyi.storage.minio.utils.MinioUtils;
import com.ruoyi.sy.domain.ArdSyUser;
import com.ruoyi.sy.gps31.PositionContainer;
import com.ruoyi.sy.mapper.ArdSyUserMapper;
-import com.ruoyi.system.domain.SysConfig;
+import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.utils.forest.SYClient;
import com.ruoyi.utils.result.Results;
import io.minio.GetPresignedObjectUrlArgs;
-import io.minio.ListObjectsArgs;
-import io.minio.PutObjectArgs;
import io.minio.Result;
import io.minio.http.Method;
import io.minio.messages.Item;
@@ -144,7 +143,7 @@
objectNames.add(ardSyCar.getCarPicture().split("/sycar/")[1]);
}
}
- MinioUtils.removeObjects("sycar", objectNames);
+ MinioUtil.removeObjects("sycar", objectNames);
return ardSyCarMapper.deleteArdSyCarByIds(ids);
}
@@ -261,12 +260,12 @@
@Override
public List<Map<String, String>> getAllCarModel() {
- boolean exsit = MinioUtils.exitsBucket("sycar");
+ boolean exsit = MinioUtil.exitsBucket("sycar");
if (exsit) {
List<Map<String, String>> listObjetcName = new ArrayList<>();
try {
- ListObjectsArgs listObjectsArgs = ListObjectsArgs.builder().prefix("carmodel/").bucket("sycar").build();
- Iterable<Result<Item>> myObjects = MinioClientSingleton.getMinioClient().listObjects(listObjectsArgs);
+ // ListObjectsArgs listObjectsArgs = ListObjectsArgs.builder().prefix("carmodel/").bucket("sycar").build();
+ Iterable<Result<Item>> myObjects = MinioUtil.getObjectsByBucket("sycar","carmodel");
for (Result<Item> result : myObjects) {
Item item = result.get();
Map<String, String> map = new HashMap();
@@ -329,16 +328,16 @@
if (ardSyCarr.getCarPicture() != null || !ardSyCarr.getCarPicture().equals("")) {
String objectName = ardSyCarr.getCarPicture().split("/sycar/")[1];
objectNames.add(objectName);
- MinioUtils.removeObjects("sycar", objectNames);
+ MinioUtil.removeObjects("sycar", objectNames);
}
}
//鍒ゆ柇鏂囦欢鏄惁涓虹┖
if (null == carPicture || 0 == carPicture.getSize()) {
return "";
}
- boolean exsit = MinioUtils.exitsBucket("sycar");
+ boolean exsit = MinioUtil.exitsBucket("sycar");
if (!exsit) {
- boolean bucket = MinioUtils.createBucket("sycar");
+ boolean bucket = MinioUtil.createBucket("sycar");
}
//鏂囦欢鍚�
String originalFilename = carPicture.getOriginalFilename();
@@ -347,14 +346,15 @@
try {
InputStream inputStream = carPicture.getInputStream();
/*涓婁紶瀵硅薄*/
- PutObjectArgs putObjectArgs = PutObjectArgs
- .builder()
- .bucket("sycar")
- .object(fileName)
- .stream(inputStream, carPicture.getSize(), -1)
- .contentType(carPicture.getContentType())
- .build();
- MinioClientSingleton.getMinioClient().putObject(putObjectArgs);
+// PutObjectArgs putObjectArgs = PutObjectArgs
+// .builder()
+// .bucket("sycar")
+// .object(fileName)
+// .stream(inputStream, carPicture.getSize(), -1)
+// .contentType(carPicture.getContentType())
+// .build();
+// MinioConfig.getMinioClient().putObject(putObjectArgs);
+ MinioUtil.uploadObject("sycar",fileName,inputStream,carPicture.getSize(),carPicture.getContentType());
inputStream.close();
/*鑾峰彇url*/
GetPresignedObjectUrlArgs getPresignedObjectUrlArgs = GetPresignedObjectUrlArgs
@@ -363,8 +363,8 @@
.object(fileName)
.method(Method.GET)
.build();
- String presignedObjectUrl = MinioClientSingleton.getMinioClient().getPresignedObjectUrl(getPresignedObjectUrlArgs);
- String ObjectUrl = presignedObjectUrl.substring(0, presignedObjectUrl.indexOf("?"));
+ //String presignedObjectUrl = MinioConfig.getMinioClient().getPresignedObjectUrl(getPresignedObjectUrlArgs);
+ String ObjectUrl = MinioUtil.getBucketObjectUrl("sycar", fileName);
if (id != null && !id.equals("")) {//id涓洪潪蹇呰
ArdSyCar ardSyCar = new ArdSyCar();
ardSyCar.setId(id);
@@ -1032,7 +1032,6 @@
/**
* 鑾峰彇闄勮繎鑼冨洿鍐呯殑杞﹁締淇℃伅
*/
-
@Override
public List<Map<String, Object>> getNearCar(SchedulingParam param) {
Double longitude = param.getLongitude();
@@ -1083,7 +1082,7 @@
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"));
- double distance = GisTool.getDistance( new double[]{longitude,latitude}, new double[]{lng, lat});
+ double distance = GisUtil.getDistance( new double[]{longitude,latitude}, new double[]{lng, lat});
if (distance <= radius) {
carMap.put("longitude",lng);
carMap.put("latitude",lat);
@@ -1092,4 +1091,68 @@
}
return filteredList;
}
+ /**
+ * 鑾峰彇鑼冨洿鍐呯殑杞﹁締淇℃伅(澶氳竟褰�)
+ */
+ @Override
+ public List<Map<String, Object>> getNearCarWithPolygon(SchedulingParam param) {
+ List<Map<String, Object>> filteredList = new ArrayList<>();
+ try {
+ List<Point> partitionLocation = param.getPartitionLocation();
+ if (partitionLocation == null) {
+ log.debug("澶氳竟褰㈠潗鏍囬泦鍚堜负绌�");
+ return null;
+ }
+ String userId = SecurityUtils.getUserId();
+ ArdSyUser syUser = new ArdSyUser();
+ syUser.setSysUserId(userId);
+ List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(syUser);
+ if (ardSyUserList.size() == 0) {
+ log.debug("鐢ㄦ埛鏈寕鎺ヤ笁涓�杞﹁締");
+ return null;
+ }
+ ArdSyUser ardSyUser = ardSyUserList.get(0);
+ String syUrl = redisCache.getCacheObject("sys_config:syCarPT");
+ String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
+ Map<String, Object> LogInResult = sYClient.logIn(syUrl, passwordMd5, ardSyUser.getUserId());
+ String sessionId = (String) LogInResult.get("sessionId");
+
+ Map<String, Object> teamList = sYClient.getTeamList(syUrl, ardSyUser.getUserId(), sessionId);
+ List<Map<String, Object>> listMap = (List<Map<String, Object>>) teamList.get("list");
+ List<Map<String, Object>> allList = new ArrayList<>();
+ for (Map<String, Object> team : listMap) {
+ String teamId = (String) team.get("teamId");
+ Map<String, Object> carListMap = sYClient.getCarList1(syUrl, teamId, ardSyUser.getUserId(), sessionId);
+ if (((String) carListMap.get("rspCode")).equals("1")) {
+ List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list");
+ allList.addAll(list);
+ }
+ }
+ //杩囨护鍦ㄧ嚎杞﹁締
+ List<Map<String, Object>> onlineList = allList.stream()
+ .filter(map -> !"绂荤嚎".equals(map.get("stateCn")))
+ .collect(Collectors.toList());
+
+ //杩囨护鍗婂緞
+ for (Map<String, Object> carMap : onlineList) {
+ String carId = (String) carMap.get("carId");
+ Map<String, Object> carGPSTrack = sYClient.getCarNearPositionByCarId(syUrl, carId, ardSyUser.getUserId(), sessionId);
+ 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"));
+ Point point = new Point(lng,lat);
+ boolean inPolygon = GisUtil.isInPolygon(point, partitionLocation);
+ if (inPolygon) {
+ carMap.put("longitude", lng);
+ carMap.put("latitude", lat);
+ filteredList.add(carMap); // 灏嗘弧瓒虫潯浠剁殑杞﹁締娣诲姞鍒扮瓫閫夊垪琛ㄤ腑
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ log.error("鑾峰彇鑼冨洿鍐呯殑杞﹁締淇℃伅(澶氳竟褰�)寮傚父:" + ex.getMessage());
+ }
+ return filteredList;
+ }
}
--
Gitblit v1.9.3