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 | 984 +++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 881 insertions(+), 103 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 f788f0d..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
@@ -1,33 +1,46 @@
package com.ruoyi.sy.service.impl;
+import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
import java.util.List;
-import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
-import com.ruoyi.common.websocket.util.WebSocketUtils;
-import com.ruoyi.device.hiksdk.config.MinioClientSingleton;
-import com.ruoyi.device.hiksdk.util.minio.MinioUtils;
+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.minio.MinioUtil;
+import com.ruoyi.utils.websocket.util.WebSocketUtils;
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;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.sy.mapper.ArdSyCarMapper;
@@ -37,7 +50,7 @@
import javax.annotation.Resource;
-import static com.ruoyi.common.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS;
+import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS;
/**
* 涓変竴杞﹁締Service涓氬姟灞傚鐞�
@@ -46,6 +59,7 @@
* @date 2023-06-26
*/
@Service
+@Slf4j(topic = "sy")
public class ArdSyCarServiceImpl implements IArdSyCarService {
@Resource
private ArdSyCarMapper ardSyCarMapper;
@@ -61,6 +75,14 @@
@Resource
private SYClient sYClient;
+ @Resource
+ RedisCache redisCache;
+ @Resource
+ private ArdSyCarDayMapper ardSyCarDayMapper;
+
+ private Map<Integer, Map<String, String>> logInMap = new HashMap();
+
+ private Map<String, Timer> userCarTimerMap = new HashMap();
/**
* 鏌ヨ涓変竴杞﹁締
@@ -92,7 +114,7 @@
*/
@Override
public int insertArdSyCar(ArdSyCar ardSyCar) {
- return ardSyCarMapper.insertArdSyCar(ardSyCar);
+ return ardSyCarMapper.insertArdSyCar(ardSyCar);
}
/**
@@ -116,12 +138,12 @@
public int deleteArdSyCarByIds(String[] ids) {
List<ArdSyCar> result = ardSyCarMapper.selectArdSyCarByIds(ids);
List<String> objectNames = new ArrayList();
- for(ArdSyCar ardSyCar : result){
- if(ardSyCar.getCarPicture() != null && !ardSyCar.getCarPicture().equals("")){
+ for (ArdSyCar ardSyCar : result) {
+ if (ardSyCar.getCarPicture() != null && !ardSyCar.getCarPicture().equals("")) {
objectNames.add(ardSyCar.getCarPicture().split("/sycar/")[1]);
}
}
- MinioUtils.removeObjects("sycar", objectNames);
+ MinioUtil.removeObjects("sycar", objectNames);
return ardSyCarMapper.deleteArdSyCarByIds(ids);
}
@@ -140,54 +162,54 @@
* 鑾峰彇鏈寕鎺ユ潈闄愮殑涓変竴杞﹁締
*/
@Override
- public Map<String,Object> getArdSyCarNoRight(String userId) {
+ public Map<String, Object> getArdSyCarNoRight(String userId) {
SysConfig config = new SysConfig();
config.setConfigKey("syCarPT");
List<SysConfig> sysConfigResult = sysConfigMapper.selectConfigList(config);
String syURL = "";
- Map<String,Object> result = new HashMap();
- if(sysConfigResult.size() == 0){
- result.put("data","涓変竴杞﹁締url娌℃湁褰曞叆");
- result.put("code","500");
+ Map<String, Object> result = new HashMap();
+ if (sysConfigResult.size() == 0) {
+ result.put("data", "涓変竴杞﹁締url娌℃湁褰曞叆");
+ result.put("code", "500");
return result;
- }else{
+ } else {
syURL = sysConfigResult.get(0).getConfigValue();
ArdSyUser ardSyUserPara = new ArdSyUser();
ardSyUserPara.setSysUserId(userId);
List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara);
- if(ardSyUserList.size() == 0){
- result.put("data","鐢ㄦ埛鏈寕鎺ヤ笁涓�杞﹁締");
- result.put("code","500");
+ if (ardSyUserList.size() == 0) {
+ result.put("data", "鐢ㄦ埛鏈寕鎺ヤ笁涓�杞﹁締");
+ result.put("code", "500");
return result;
- }else{
+ } else {
ArdSyUser ardSyUser = ardSyUserList.get(0);
//Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword());
String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
- Map<String,Object> LogInResult = sYClient.logIn(syURL,passwordMd5,ardSyUser.getUserId());
+ Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
String sessionId = (String) LogInResult.get("sessionId");
//Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId);
- Map<String,Object> carListMap = sYClient.getCarList(syURL,sessionId);
- if(((String)carListMap.get("rspCode")).equals("1")){
- List<Map<String,Object>> list = (List<Map<String,Object>>) carListMap.get("list");
+ Map<String, Object> carListMap = sYClient.getCarList(syURL, sessionId);
+ if (((String) carListMap.get("rspCode")).equals("1")) {
+ List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list");
ArdSyCar ardSyCar = new ArdSyCar();
List<ArdSyCar> ardSyCarList = ardSyCarMapper.selectArdSyCarList(ardSyCar);
List<String> carIdList = new ArrayList();
- for(ArdSyCar innerArdSyCar : ardSyCarList){
+ for (ArdSyCar innerArdSyCar : ardSyCarList) {
carIdList.add(innerArdSyCar.getCarId());
}
- List<Map<String,Object>> carList = list.stream().filter(new Predicate<Map<String,Object>>(){
+ List<Map<String, Object>> carList = list.stream().filter(new Predicate<Map<String, Object>>() {
@Override
- public boolean test(Map<String,Object> map) {
- return !carIdList.contains((String)map.get("carId"));
+ public boolean test(Map<String, Object> map) {
+ return !carIdList.contains((String) map.get("carId"));
}
}).collect(Collectors.toList());
- result.put("data",carList);
- result.put("code","200");
+ result.put("data", carList);
+ result.put("code", "200");
return result;
- }else{
- result.put("data","涓変竴杞﹁締骞冲彴鍑洪敊");
- result.put("code","500");
+ } else {
+ result.put("data", "涓変竴杞﹁締骞冲彴鍑洪敊");
+ result.put("code", "500");
return result;
}
}
@@ -200,36 +222,36 @@
config.setConfigKey("syCarPT");
List<SysConfig> sysConfigResult = sysConfigMapper.selectConfigList(config);
String syURL = "";
- Map<String,Object> result = new HashMap();
- if(sysConfigResult.size() == 0){
- result.put("data","涓変竴杞﹁締url娌℃湁褰曞叆");
- result.put("code","500");
+ Map<String, Object> result = new HashMap();
+ if (sysConfigResult.size() == 0) {
+ result.put("data", "涓変竴杞﹁締url娌℃湁褰曞叆");
+ result.put("code", "500");
return result;
- }else{
+ } else {
syURL = sysConfigResult.get(0).getConfigValue();
ArdSyUser ardSyUserPara = new ArdSyUser();
ardSyUserPara.setSysUserId(userId);
List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara);
- if(ardSyUserList.size() == 0){
- result.put("data","鐢ㄦ埛鏈寕鎺ヤ笁涓�杞﹁締");
- result.put("code","500");
+ if (ardSyUserList.size() == 0) {
+ result.put("data", "鐢ㄦ埛鏈寕鎺ヤ笁涓�杞﹁締");
+ result.put("code", "500");
return result;
- }else{
+ } else {
ArdSyUser ardSyUser = ardSyUserList.get(0);
//Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword());
String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
- Map<String,Object> LogInResult = sYClient.logIn(syURL,passwordMd5,ardSyUser.getUserId());
+ Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
String sessionId = (String) LogInResult.get("sessionId");
//Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId);
- Map<String,Object> carListMap = sYClient.getCarList(syURL,sessionId);
- if(((String)carListMap.get("rspCode")).equals("1")){
- List<Map<String,Object>> list = (List<Map<String,Object>>) carListMap.get("list");
- result.put("data",list);
- result.put("code","200");
+ Map<String, Object> carListMap = sYClient.getCarList(syURL, sessionId);
+ if (((String) carListMap.get("rspCode")).equals("1")) {
+ List<Map<String, Object>> list = (List<Map<String, Object>>) carListMap.get("list");
+ result.put("data", list);
+ result.put("code", "200");
return result;
- }else{
- result.put("data","涓変竴杞﹁締骞冲彴鍑洪敊");
- result.put("code","500");
+ } else {
+ result.put("data", "涓変竴杞﹁締骞冲彴鍑洪敊");
+ result.put("code", "500");
return result;
}
}
@@ -237,30 +259,54 @@
}
@Override
- public List<Map<String,String>> getAllCarModel() {
- boolean exsit = MinioUtils.exitsBucket("sycar");
+ public List<Map<String, String>> getAllCarModel() {
+ boolean exsit = MinioUtil.exitsBucket("sycar");
if (exsit) {
- List<Map<String,String>> listObjetcName = new ArrayList<>();
+ 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();
- map.put("carModel","sycar/" + item.objectName());
- switch(item.objectName()){
- case "carmodel/aodi.glb":map.put("carType","濂ヨ开");break;
- case "carmodel/baolai.glb":map.put("carType","瀹濇潵");break;
- case "carmodel/bieke.glb":map.put("carType","鍒厠");break;
- case "carmodel/bus1.glb":map.put("carType","澶у杞�");break;
- case "carmodel/car.glb":map.put("carType","灏忓瀷杞�");break;
- case "carmodel/fire(1).glb":map.put("carType","娑堥槻杞�");break;
- case "carmodel/fute.glb":map.put("carType","绂忕壒");break;
- case "carmodel/jingche_a.glb":map.put("carType","璀﹁溅");break;
- case "carmodel/jiuhu.glb":map.put("carType","鏁戞姢杞�");break;
- case "carmodel/oil.glb":map.put("carType","娌圭綈杞�");break;
- case "carmodel/truck.glb":map.put("carType","宸ョ▼鐢ㄨ溅");break;
- case "carmodel/van1.glb":map.put("carType","澶ц揣杞�");break;
+ Map<String, String> map = new HashMap();
+ map.put("carModel", "sycar/" + item.objectName());
+ switch (item.objectName()) {
+ case "carmodel/aodi.glb":
+ map.put("carType", "濂ヨ开");
+ break;
+ case "carmodel/baolai.glb":
+ map.put("carType", "瀹濇潵");
+ break;
+ case "carmodel/bieke.glb":
+ map.put("carType", "鍒厠");
+ break;
+ case "carmodel/bus1.glb":
+ map.put("carType", "澶у杞�");
+ break;
+ case "carmodel/car.glb":
+ map.put("carType", "灏忓瀷杞�");
+ break;
+ case "carmodel/fire(1).glb":
+ map.put("carType", "娑堥槻杞�");
+ break;
+ case "carmodel/fute.glb":
+ map.put("carType", "绂忕壒");
+ break;
+ case "carmodel/jingche_a.glb":
+ map.put("carType", "璀﹁溅");
+ break;
+ case "carmodel/jiuhu.glb":
+ map.put("carType", "鏁戞姢杞�");
+ break;
+ case "carmodel/oil.glb":
+ map.put("carType", "娌圭綈杞�");
+ break;
+ case "carmodel/truck.glb":
+ map.put("carType", "宸ョ▼鐢ㄨ溅");
+ break;
+ case "carmodel/van1.glb":
+ map.put("carType", "澶ц揣杞�");
+ break;
default:
break;
}
@@ -276,38 +322,39 @@
@Override
public String uploadCarPicture(String id, MultipartFile carPicture) {
- if(id != null && !id.equals("")){//id涓洪潪蹇呰
+ if (id != null && !id.equals("")) {//id涓洪潪蹇呰
ArdSyCar ardSyCarr = ardSyCarMapper.selectArdSyCarById(id);
List<String> objectNames = new ArrayList();
- if(ardSyCarr.getCarPicture() != null || !ardSyCarr.getCarPicture().equals("")){
+ 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();
//鏂扮殑鏂囦欢鍚�
- String fileName = "carpicture/" + IdUtils.fastSimpleUUID()+"_"+ originalFilename;
+ String fileName = "carpicture/" + IdUtils.fastSimpleUUID() + "_" + originalFilename;
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
@@ -316,9 +363,9 @@
.object(fileName)
.method(Method.GET)
.build();
- String presignedObjectUrl = MinioClientSingleton.getMinioClient().getPresignedObjectUrl(getPresignedObjectUrlArgs);
- String ObjectUrl = presignedObjectUrl.substring(0, presignedObjectUrl.indexOf("?"));
- if(id != null && !id.equals("")){//id涓洪潪蹇呰
+ //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);
ardSyCar.setCarPicture(ObjectUrl);
@@ -341,10 +388,10 @@
public Results carListById(String id) {
try {
List<ArdSyCar> list = ardSyCarMapper.carListById(id);
- if(list.size()>0){
+ if (list.size() > 0) {
ArdSyCar ardSyCar = list.get(0);
return Results.succeed(ardSyCar);
- }else {
+ } else {
return Results.succeed();
}
} catch (Exception e) {
@@ -355,26 +402,757 @@
@Override
public Map<String, Object> getArdSyCarAndDeptByCarId(String carId) {
Map<String, Object> result = ardSyCarMapper.getArdSyCarAndDeptByCarId(carId);
+ if (result != null) {
+ if (result.get("carPicture") != null) {
+ if (!((String) result.get("carPicture")).equals("")) {
+ String url = ((String) result.get("carPicture")).split("sycar")[0];
+ String carModel = url + (String) result.get("carModel");
+ result.put("carModel", carModel);
+ }
+ }
+ }
return result;
}
@Override
public void sendArdSyCarPosition() {
- for(String key : ONLINE_USER_SESSIONS.keySet()){
- SysUser sysUser = userMapper.selectUserById(key);
- String deptId = String.valueOf(sysUser.getDeptId());
- Map<String,Map<String,Object>> map = PositionContainer.getDeptPositionMap().get(deptId);
- Map<Integer,Object> data = new HashMap();
- data.put(30000, map.values());
- WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data));
+ for (String key : ONLINE_USER_SESSIONS.keySet()) {
+ if (PositionContainer.getUserPositionMap().keySet().contains(key)) {//褰撹拷韪殑杞﹁締瀹瑰櫒鍖呭惈姝ょ敤鎴稩d锛屽垯瀹炴椂浣嶇疆鎺ㄩ�侀渶瑕佸墧闄よ杞﹁締
+ SysUser sysUser = userMapper.selectUserById(key);
+ if (sysUser == null) {
+ //return;
+ continue;
+ }
+ String deptId = String.valueOf(sysUser.getDeptId());
+ Map<String, Map<String, Object>> map = PositionContainer.getDeptPositionMap().get(deptId);
+ List<String> carIdList = new ArrayList();
+ carIdList.addAll(PositionContainer.getUserPositionMap().get(key).keySet());
+ String carId = carIdList.get(0);
+ map.remove(carId);
+ if (map != null) {
+ Map<String, Object> data = new HashMap();
+ data.put("30000", map.values());
+ WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data));
+ }
+ } else {
+ SysUser sysUser = userMapper.selectUserById(key);
+ if (sysUser == null) {
+ //return;
+ continue;
+ }
+ String deptId = String.valueOf(sysUser.getDeptId());
+ Map<String, Map<String, Object>> map = PositionContainer.getDeptPositionMap().get(deptId);
+ if (map != null) {
+ Map<String, Object> data = new HashMap();
+ data.put("30000", map.values());
+ WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data));
+ }
+ }
+ }
+ for (String userId : userCarTimerMap.keySet()) {//鐢ㄦ埛绂荤嚎鍚庡皢杞﹁締杩借釜璧勬簮閲婃斁
+ if (!ONLINE_USER_SESSIONS.keySet().contains(userId)) {
+ userCarTimerMap.get(userId).cancel();
+ userCarTimerMap.remove(userId);
+ PositionContainer.getUserPositionMap().remove(userId);
+ }
}
}
@Override
- public void sendArdSyCarAlarmByCarId(String carId, Map<Integer,Object> data) {
+ public void sendArdSyCarAlarmByCarId(String carId, Map<String, Object> data) {
List<SysUser> result = userMapper.getSysUserByCarId(carId);
- for(SysUser sysUser : result){
+ for (SysUser sysUser : result) {
WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sysUser.getUserId()), JSON.toJSONString(data));
}
}
+
+ /**
+ * 鏍规嵁鐢ㄦ埛鑾峰彇涓変竴鍒楄〃
+ *
+ * @return
+ */
+ @Override
+ public Map<String, Object> allListByUser(ArdSyUser ardSyUser, String syURL, String usersId) {
+ Map<String, Object> result0 = new HashMap();
+ //鍒ゆ柇鍏宠仈琛ㄦ槸鍚︽湁鏁版嵁
+ if (ardSyUser != null) {
+ Map<String, String> result = logInMap.get(Integer.parseInt(usersId));
+ //31鐢ㄦ埛鍚嶅瘑鐮�
+ String username31 = ardSyUser.getUserId();
+ String password31 = ardSyUser.getPassword();
+ String passwordMd5 = DigestUtils.md5Hex(password31);
+ Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31);
+ result = new HashMap();
+ result.put("userId", username31);
+ result.put("sessionId", (String) result1.get("sessionId"));
+ try {
+ result0 = sYClient.getTeamList(syURL, result.get("userId"), result.get("sessionId"));
+ } catch (Exception e) {
+ Map<String, Object> map = new HashMap();
+ map.put("rspCode", 0);
+ map.put("list", new ArrayList());
+ return map;
+ }
+ int online = 0;
+ for (Map<String, Object> map : (List<Map<String, Object>>) result0.get("list")) {
+ Map<String, Object> resultMap = sYClient.getTeamCarList(syURL, (String) map.get("teamId"), result.get("sessionId"));
+ List<Map<String, Object>> carList = (List<Map<String, Object>>) resultMap.get("carList");
+ for (Map<String, Object> m : carList) {
+ if (((String) m.get("stateCn")).contains("鍦ㄧ嚎")) {
+ online = online + 1;
+ } else {
+ continue;
+ }
+ }
+ for (Map<String, Object> m : (List<Map<String, Object>>) result0.get("list")) {
+ if (((String) m.get("teamId")).equals(((String) map.get("teamId")))) {
+ map.put("count", Integer.parseInt((String) m.get("carNum")));
+ }
+ }
+ map.put("online", online);
+ online = 0;
+ }
+ } else {
+ result0.put("鍒楄〃涓虹┖锛�", "鏃犲叧鑱旇处鍙凤紒");
+ }
+ return result0;
+ }
+
+ @Override
+ public List<Map<String, String>> getCarList(ArdSyUser ardSyUser, String syURL, String usersId, String teamId) {
+ List<Map<String, String>> list = new ArrayList<>();
+ Map<String, String> result = logInMap.get(Integer.parseInt(usersId));
+ //31鐢ㄦ埛鍚嶅瘑鐮�
+ String username31 = ardSyUser.getUserId();
+ String password31 = ardSyUser.getPassword();
+ String passwordMd5 = DigestUtils.md5Hex(password31);
+ Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31);
+ result = new HashMap();
+ result.put("userId", username31);
+ result.put("sessionId", (String) result1.get("sessionId"));
+ //鏌ヨ璇eamId涓嬬殑杞﹁締鏁版嵁
+ Map<String, Object> carList31 = new HashMap();
+ carList31 = sYClient.getCarList1(syURL, teamId, result.get("userId"), result.get("sessionId"));
+ //鎷垮埌杞﹁締鏁版嵁
+ list = (List) carList31.get("list");
+ if (list.isEmpty()) {
+ return list;
+ } else {
+ List<String> carIdList = new ArrayList();
+ //鎵�鏈塩arId
+ for (Map<String, String> m : list) {
+ carIdList.add(m.get("carId"));
+ }
+ if (carIdList.size() == 0) {
+ Map<String, String> map0 = new HashMap();
+ map0.put("list", "{}");
+ map0.put("rspCode", "1");
+ list.add(map0);
+ return list;
+ }
+ //娣诲姞杞﹁締灞炴��
+ for (Map<String, String> m : list) {
+ switch (m.get("state")) {
+ case "1":
+ m.put("carState", "绂荤嚎-浠庢湭鎶ュ畾浣�");
+ break;
+ case "2":
+ m.put("carState", "绂荤嚎-娆犺垂");
+ break;
+ case "3":
+ m.put("carState", "绂荤嚎");
+ break;
+ case "4":
+ m.put("carState", "绂荤嚎-鎶ヨ");
+ break;
+ case "5":
+ m.put("carState", "鍦ㄧ嚎-浠庢湭鎶ュ畾浣�");
+ break;
+ case "6":
+ m.put("carState", "鍦ㄧ嚎-娆犺垂");
+ break;
+ case "7":
+ m.put("carState", "鍦ㄧ嚎-琛岄┒");
+ break;
+ case "8":
+ m.put("carState", "鍦ㄧ嚎-琛岄┒-鎶ヨ");
+ break;
+ case "9":
+ m.put("carState", "鍦ㄧ嚎-鍋滆溅-ACC鍏�");
+ break;
+ case "10":
+ m.put("carState", "鍦ㄧ嚎-鍋滆溅-ACC寮�");
+ break;
+ case "11":
+ m.put("carState", "鍦ㄧ嚎-鍋滆溅-ACC鍏�-鎶ヨ");
+ break;
+ case "12":
+ m.put("carState", "鍦ㄧ嚎-鍋滆溅-ACC寮�-鎶ヨ");
+ break;
+ case "13":
+ m.put("carState", "鍦ㄧ嚎-鏃犳晥瀹氫綅");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * 鏍规嵁dept闆嗗悎鏌ヨ鍑烘墍鏈夊搴旂殑carId
+ *
+ * @param deptList
+ * @return
+ */
+ @Override
+ public List<Map<String, String>> carIdByDeptList(List<Long> deptList, List<Map<String, String>> list) {
+ QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>();
+ queryWrapper.in("dept_id", deptList);
+ List<ArdSyCar> carList = ardSyCarMapper.selectList(queryWrapper);
+ //瀵规瘮鎶婂尮閰嶅埌鐨勬暟鎹坊鍔犲埌list涓�
+ for (Map<String, String> m : list) {
+ String carId = m.get("carId");
+ for (int i = 0; i < carList.size(); i++) {
+ ArdSyCar ardSyCar = carList.get(i);
+ if (carId.equals(ardSyCar.getCarId())) {
+ String url = "";
+ if (ardSyCar.getCarPicture() != null) {
+ if (!ardSyCar.getCarPicture().equals("")) {
+ url = ardSyCar.getCarPicture().split("sycar")[0];
+ }
+ }
+ m.put("carModel", url + ardSyCar.getCarModel());//zns
+ //m.put("carModel",ardSyCar.getCarModel());
+ m.put("carTypeArd", ardSyCar.getCarType());
+ m.put("carBrand", ardSyCar.getCarBrand());
+ m.put("carPicture", ardSyCar.getCarPicture());
+ }
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public Results getCarGPSTrack(Map<String, String> map, String syURL, ArdSyUser ardSyUser) {
+ String carId = map.get("carId");
+ //String startTime = map.get("startTime").replace(" ", "").replace("-", "").replace(":", "");
+ //String endTime = map.get("endTime").replace(" ", "").replace("-", "").replace(":", "");
+ String time = map.get("time");
+ time = time.replace("-", "");
+ String startTime = time + "000000";
+ String endTime = time + "235959";
+ String maxSpeed = map.get("maxSpeed");
+ //31鐢ㄦ埛鍚嶅瘑鐮�
+ String username31 = ardSyUser.getUserId();
+ String password31 = ardSyUser.getPassword();
+ String passwordMd5 = DigestUtils.md5Hex(password31);
+ Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31);
+ Map<String, Object> result0 = new HashMap();
+ result0 = sYClient.getCarGPSTrack(syURL, carId, startTime, endTime, maxSpeed, (String) result1.get("sessionId"));
+ List<Map<String, Object>> list = (List<Map<String, Object>>) result0.get("list");
+ if (list.isEmpty()) {
+ return Results.succeed();
+ } else {
+ for (Map<String, Object> m : list) {
+ String alarmStts = (String) m.get("alarmStts");
+ Map<String, List<String>> alarmMap = getInfo("alarm", alarmStts);
+ m.putAll(alarmMap);
+ String carStts = (String) m.get("carStts");
+ Map<String, List<String>> carMap = getInfo("car", carStts);
+ m.putAll(carMap);
+ String sgnStts = (String) m.get("sgnStts");
+ Map<String, List<String>> sgnMap = getInfo("sgn", sgnStts);
+ m.putAll(sgnMap);
+ }
+ return Results.succeed(list);
+ }
+ }
+
+
+ public Map<String, List<String>> getInfo(String type, String stts) {
+ if (stts.isEmpty()) {
+ return new HashMap<>();
+ }
+ String[] alarmTypes = {"绱ф�ユ姤璀�", "瓒呴�熸姤璀�", "鐤插姵椹鹃┒", "鍗遍櫓棰勮", "GNSS 妯″潡鍙戠敓鏁呴殰", "GNSS 澶╃嚎鏈帴鎴栬鍓柇", "GNSS 澶╃嚎鐭矾",
+ "缁堢涓荤數婧愭瑺鍘�", "缁堢涓荤數婧愭帀鐢�", "缁堢LCD 鎴栨樉绀哄櫒鏁呴殰", "TTS 妯″潡鏁呴殰", "鎽勫儚澶存晠闅�", "閬撹矾杩愯緭璇両C 鍗℃ā鍧楁晠闅�", "瓒呴�熼璀�",
+ "鐤插姵椹鹃┒棰勮", "杩濊琛岄┒鎶ヨ", "鑳庡帇棰勮", "鍙宠浆鐩插尯寮傚父鎶ヨ", "褰撳ぉ绱椹鹃┒瓒呮椂", "瓒呮椂鍋滆溅", "杩涘嚭鍖哄煙", "杩涘嚭璺嚎", "璺琛岄┒鏃堕棿涓嶈冻/杩囬暱",
+ "璺嚎鍋忕鎶ヨ", "杞﹁締VSS 鏁呴殰", "杞﹁締娌归噺寮傚父", "杞﹁締琚洍", "杞﹁締闈炴硶鐐圭伀", "杞﹁締闈炴硶浣嶇Щ", "纰版挒棰勮", "渚х炕棰勮", "闈炴硶寮�闂ㄦ姤璀�"};
+
+ String[] carTypes89 = {"绌鸿溅", "鍗婅浇", "淇濈暀", "婊¤浇"};
+
+ Object[] carTypes = {"ACC寮�", "瀹氫綅", "鍗楃含", "瑗跨粡", "鍋滆繍鐘舵��", "缁忕含搴﹀凡缁忎繚瀵嗘彃浠跺姞瀵�", "淇濈暀", "淇濈暀", carTypes89, "杞﹁締娌硅矾鏂紑", "杞﹂棬鍔犻攣",
+ "杞﹁締鐢佃矾鏂紑", "闂�1寮�锛堝墠闂級", "闂�2寮�锛堜腑闂級", "闂�3寮�锛堝悗闂�", "闂�4寮�锛堥┚椹跺腑闂�", "闂�5寮�", "浣跨敤GPS 鍗槦杩涜瀹氫綅", "浣跨敤鍖楁枟鍗槦杩涜瀹氫綅",
+ "浣跨敤GLONASS鍗槦杩涜瀹氫綅", "浣跨敤Galileo鍗槦杩涜瀹氫綅", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀"};
+
+ String[] sgnTypes = {"杩戝厜鐏俊鍙�", "杩滃厜鐏俊鍙�", "鍙宠浆鍚戠伅淇″彿", "宸﹁浆鍚戠伅淇″彿", "鍒跺姩淇″彿", "鍊掓。淇″彿", "闆剧伅淇″彿", "绀哄粨鐏�", "鍠囧彮淇″彿", "绌鸿皟鐘舵��",
+ "绌烘尅淇″彿", "缂撻�熷櫒宸ヤ綔", "ABS 宸ヤ綔", "鍔犵儹鍣ㄥ伐浣�", "绂诲悎鍣ㄧ姸鎬�", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀",
+ "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀", "淇濈暀"};
+ //Integer sttsHex = Integer.parseInt(stts, 16);
+ Long sttsHex = Long.parseLong(stts, 16);
+ //String sttsBin = Integer.toBinaryString(sttsHex);
+ String sttsBin = Long.toBinaryString(sttsHex);
+ if (sttsBin.length() < 32) {
+ while (sttsBin.length() < 32) {
+ sttsBin = "0" + sttsBin;
+ }
+ }
+ String[] sttsBinArray = sttsBin.split("");
+ switch (type) {
+ case "alarm":
+ List<String> alarmTypeArray = new ArrayList();
+ for (int i = 0; i < sttsBinArray.length; i++) {
+ if (sttsBinArray[i].equals("1")) {
+ alarmTypeArray.add(alarmTypes[i]);
+ }
+ }
+ Map<String, List<String>> alarmMap = new HashMap();
+ alarmMap.put(type, alarmTypeArray);
+ return alarmMap;
+ case "car":
+ List<String> carTypeArray = new ArrayList();
+ for (int i = 0; i < sttsBinArray.length; i++) {
+ if (i <= 7 || i >= 10) {
+ if (sttsBinArray[i].equals("1")) {
+ carTypeArray.add(alarmTypes[i]);
+ }
+ } else if (i == 8) {
+ switch (sttsBinArray[8] + sttsBinArray[9]) {
+ case "00":
+ carTypeArray.add(carTypes89[0]);
+ break;
+ case "01":
+ carTypeArray.add(carTypes89[1]);
+ break;
+ case "10":
+ carTypeArray.add(carTypes89[2]);
+ break;
+ case "11":
+ carTypeArray.add(carTypes89[3]);
+ break;
+ default:
+ break;
+ }
+ } else if (i == 9) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ Map<String, List<String>> carMap = new HashMap();
+ List<String> carTypeArray0 = new ArrayList();
+ for (String str : carTypeArray) {
+ if (!str.equals("淇濈暀")) {
+ carTypeArray0.add(str);
+ }
+ }
+ carMap.put(type, carTypeArray0);
+ return carMap;
+ case "sgn":
+ List<String> sgnTypeArray = new ArrayList();
+ for (int i = 0; i < sttsBinArray.length; i++) {
+ if (sttsBinArray[i].equals("1")) {
+ sgnTypeArray.add(alarmTypes[i]);
+ }
+ }
+ Map<String, List<String>> sgnMap = new HashMap();
+ List<String> sgnTypeArray0 = new ArrayList();
+ for (String str : sgnTypeArray) {
+ if (!str.equals("淇濈暀")) {
+ sgnTypeArray0.add(str);
+ }
+ }
+ sgnMap.put(type, sgnTypeArray0);
+ return sgnMap;
+ default:
+ return new HashMap<String, List<String>>();
+ }
+ }
+
+ @Override
+ public Results getCarGPSBycarId(String usersId, String carId, String syURL, ArdSyUser ardSyUser) {
+ Map<String, String> result = logInMap.get(Integer.parseInt(usersId));
+ //31鐢ㄦ埛鍚嶅瘑鐮�
+ String username31 = ardSyUser.getUserId();
+ String password31 = ardSyUser.getPassword();
+ String passwordMd5 = DigestUtils.md5Hex(password31);
+ Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31);
+ result = new HashMap();
+ result.put("userId", username31);
+ result.put("sessionId", (String) result1.get("sessionId"));
+ Map<String, Object> result0 = new HashMap();
+ result0 = sYClient.getCarNearPositionByCarId(syURL, carId, result.get("userId"), result.get("sessionId"));
+ return Results.succeed(result0);
+ }
+
+ @Override
+ public Results chaseCarByCarId(String usersId, String carId, String cycle) {
+ try {
+ /*Map<String,Map<String,Object>> map = new HashMap();
+ map.put(carId,new HashMap());
+ PositionContainer.getUserPositionMap().put(usersId,map);*/
+ if (cycle.equals("0")) {
+ if (userCarTimerMap.get(usersId) != null) {
+ userCarTimerMap.get(usersId).cancel();
+ userCarTimerMap.remove(usersId);
+ PositionContainer.getUserPositionMap().remove(usersId);
+ }
+ return Results.succeed("鍋滄杩借釜");
+ } else {
+ if (userCarTimerMap.get(usersId) != null) {
+ userCarTimerMap.get(usersId).cancel();
+ userCarTimerMap.remove(usersId);
+ PositionContainer.getUserPositionMap().remove(usersId);
+ Map<String, Map<String, Object>> map = new HashMap();
+ map.put(carId, new HashMap());
+ PositionContainer.getUserPositionMap().put(usersId, map);
+ Date date = new Date();
+ Timer carPositionTimer = new Timer();//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃�
+ TimerTask carPositionTask = new TimerTask() {
+ @Override
+ public void run() {
+ Map<String, Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId);
+ if (position != null) {
+ if (position.size() != 0) {
+ Map<String, Map<String, Object>> data = new HashMap();
+ data.put("31000", position);
+ WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data));
+ }
+ }
+ }
+ };
+ carPositionTimer.scheduleAtFixedRate(carPositionTask, date, Integer.parseInt(cycle));//鍚敤
+ this.userCarTimerMap.put(usersId, carPositionTimer);
+ return Results.succeed("寮�濮嬭拷韪�");
+ } else {
+ Map<String, Map<String, Object>> map = new HashMap();
+ map.put(carId, new HashMap());
+ PositionContainer.getUserPositionMap().put(usersId, map);
+ Date date = new Date();
+ Timer carPositionTimer = new Timer();//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃�
+ TimerTask carPositionTask = new TimerTask() {
+ @Override
+ public void run() {
+ Map<String, Object> position = PositionContainer.getUserPositionMap().get(usersId).get(carId);
+ if (position != null) {
+ if (position.size() != 0) {
+ Map<String, Map<String, Object>> data = new HashMap();
+ data.put("31000", position);
+ WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(usersId), JSON.toJSONString(data));
+ }
+ }
+ }
+ };
+ carPositionTimer.scheduleAtFixedRate(carPositionTask, date, Integer.parseInt(cycle));//鍚敤
+ this.userCarTimerMap.put(usersId, carPositionTimer);
+ return Results.succeed("寮�濮嬭拷韪�");
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return Results.error("杩借釜澶辫触");
+ }
+ }
+
+ /*@Override
+ public Results getExistTraceByCarIdAndMonth(String userId, String carId, String time) {
+ SysConfig config = new SysConfig();
+ config.setConfigKey("syCarPT");
+ List<SysConfig> sysConfigResult = sysConfigMapper.selectConfigList(config);
+ String syURL = "";
+ if(sysConfigResult.size() == 0){
+ return Results.succeed("涓変竴杞﹁締url娌℃湁褰曞叆");
+ }else{
+ syURL = sysConfigResult.get(0).getConfigValue();
+ ArdSyUser ardSyUserPara = new ArdSyUser();
+ ardSyUserPara.setSysUserId(userId);
+ List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara);
+ if(ardSyUserList.size() == 0){
+ return Results.succeed("鐢ㄦ埛鏈寕鎺ヤ笁涓�杞﹁締");
+ }else{
+ ArdSyUser ardSyUser = ardSyUserList.get(0);
+ String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
+ Map<String,Integer> existTraceMap = getExistTraceByCarIdAndMonth(syURL,ardSyUser.getUserId(),passwordMd5,carId,time);
+ return Results.succeed(existTraceMap);
+ }
+ }
+ }*/
+
+ @Override
+ public Results getExistTraceByCarIdAndMonth(String userId, String carId, String time) {
+ List<ArdSyCarDay> result = ardSyCarDayMapper.selectArdSyCarDayByCarIdAndDay(carId, time + "%");
+ List<String> list = new ArrayList();
+ for (ArdSyCarDay ardSyCarDay : result) {
+// list.add(ardSyCarDay.getDay().split("-")[2]);
+ list.add(ardSyCarDay.getDay());
+ }
+ return Results.succeed(list);
+ }
+
+ public Map<String, Integer> getExistTraceByCarIdAndMonth(String url, String usersId, String password, String carId, String time) {
+ Map<String, Object> LogInResult = sYClient.logIn(url, password, usersId);
+ String sessionId = (String) LogInResult.get("sessionId");
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+ Date date = null;
+ try {
+ date = sdf.parse(time);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);//鑾峰彇璇ユ湀澶╂暟
+ Map<String, Integer> existTraceMap = new HashMap();
+ ExecutorService newCachedThreadPoll = Executors.newCachedThreadPool();
+ for (int i = 1; i <= maxDay; i = i + 7) {
+ int temp = i;
+ String finalTime = time.replace("-", "");
+ String finalsyURL = url;
+ newCachedThreadPoll.execute(new Runnable() {
+ @Override
+ public void run() {
+ int temp0 = temp + 6;
+ if (temp0 > maxDay) {
+ temp0 = maxDay;
+ }
+ for (int j = temp; j <= temp0; j++) {
+ if (j <= 9) {
+ existTraceMap.put("0" + String.valueOf(j), -1);
+ } else {
+ existTraceMap.put(String.valueOf(j), -1);
+ }
+ }
+ if (temp <= 9) {
+ if (temp0 <= 9) {
+ String startTime = finalTime + "0" + temp + "000000";
+ String endTime = finalTime + "0" + temp0 + "235959";
+ Map<String, Object> result = getCarGPSTrack(finalsyURL, carId, startTime, endTime, sessionId);
+ String rspCode = (String) result.get("rspCode");
+ if (rspCode.equals("1")) {
+ List<Map<String, Object>> list = (List<Map<String, Object>>) result.get("list");
+ for (Map<String, Object> m : list) {
+ String time = (String) m.get("time");
+ time = time.split(" ")[0];
+ time = time.split("-")[2];
+ existTraceMap.put(time, 1);
+ }
+ }
+ } else {
+ String startTime = finalTime + "0" + temp + "000000";
+ String endTime = finalTime + temp0 + "235959";
+ Map<String, Object> result = getCarGPSTrack(finalsyURL, carId, startTime, endTime, sessionId);
+ String rspCode = (String) result.get("rspCode");
+ if (rspCode.equals("1")) {
+ List<Map<String, Object>> list = (List<Map<String, Object>>) result.get("list");
+ for (Map<String, Object> m : list) {
+ String time = (String) m.get("time");
+ time = time.split(" ")[0];
+ time = time.split("-")[2];
+ existTraceMap.put(time, 1);
+ }
+ }
+ }
+ } else {
+ String startTime = finalTime + temp + "000000";
+ String endTime = finalTime + temp0 + "235959";
+ Map<String, Object> result = getCarGPSTrack(finalsyURL, carId, startTime, endTime, sessionId);
+ String rspCode = (String) result.get("rspCode");
+ if (rspCode.equals("1")) {
+ List<Map<String, Object>> list = (List<Map<String, Object>>) result.get("list");
+ for (Map<String, Object> m : list) {
+ String time = (String) m.get("time");
+ time = time.split(" ")[0];
+ time = time.split("-")[2];
+ existTraceMap.put(time, 1);
+ }
+ }
+ }
+ for (int j = temp; j <= temp0; j++) {
+ String key = "";
+ if (j <= 9) {
+ key = "0" + j;
+ } else {
+ key = String.valueOf(j);
+ }
+ if (existTraceMap.get(key) == -1) {
+ existTraceMap.put(key, 0);
+ }
+
+ }
+ }
+ });
+ }
+ while (true) {
+ if (!existTraceMap.values().contains(-1)) {
+ if (existTraceMap.size() == maxDay) {
+ break;
+ }
+ }
+ }
+ try {
+ return existTraceMap;
+ } finally {
+ newCachedThreadPoll.shutdown();
+ }
+ }
+
+ public static Map<String, Object> getCarGPSTrack(String syURL, String carId, String startTime, String endTime, String sessionId) {
+ OkHttpClient okHttpClient = new OkHttpClient();
+
+ Request request = new Request.Builder()
+ .url(syURL + "/gps-web/api/get_gps_h.jsp?carId=" + carId + "&startTime=" + startTime + "&endTime=" + endTime + "&filter0=true&maxSpeed=&stopLong=5&queryAlarm=false&userId=yanshi&loginType=user&loginWay=android&loginLang=zh_CN&appDevId=&sessionId=" + sessionId)
+ .build();
+
+ Response response = null;
+ try {
+ response = okHttpClient.newCall(request).execute();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ response.headers(); //鍝嶅簲澶�
+
+ ResponseBody responseBody = response.body();
+
+ try {
+ String message = responseBody.string();// 鍝嶅簲浣�
+ Map<String, Object> map = (Map<String, Object>) JSON.parse(message);
+ //System.out.println(message);
+ return map;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new HashMap();
+ }
+ }
+
+ /**
+ * 鑾峰彇闄勮繎鑼冨洿鍐呯殑杞﹁締淇℃伅
+ */
+ @Override
+ public List<Map<String, Object>> getNearCar(SchedulingParam param) {
+ Double longitude = param.getLongitude();
+ Double latitude = param.getLatitude();
+ Integer radius = param.getSealingRadius();
+ if (longitude == null && latitude == null) {
+ log.debug("鍘熺偣鍧愭爣涓虹┖");
+ return null;
+ }
+ if (radius == 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());
+ List<Map<String, Object>> filteredList = new ArrayList<>();
+ //杩囨护鍗婂緞
+ 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"));
+ double distance = GisUtil.getDistance( new double[]{longitude,latitude}, new double[]{lng, lat});
+ if (distance <= radius) {
+ carMap.put("longitude",lng);
+ carMap.put("latitude",lat);
+ filteredList.add(carMap); // 灏嗘弧瓒虫潯浠剁殑杞﹁締娣诲姞鍒扮瓫閫夊垪琛ㄤ腑
+ }
+ }
+ 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