From b894ac8fee88a741de4ce07c41c4bd529a66ff53 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期五, 03 十一月 2023 17:31:35 +0800
Subject: [PATCH] 车辆图片
---
ard-work/src/main/java/com/ruoyi/utils/forest/SYClient.java | 10 +++++
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java | 38 ++++++++++++++++++-
ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java | 7 +++
ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java | 2 +
ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java | 1
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java | 49 ++++++++++++++++++++++++
6 files changed, 105 insertions(+), 2 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
index a68a2e4..fcb0887 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
@@ -1,5 +1,8 @@
package com.ruoyi.sy.controller;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
import java.util.*;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
@@ -393,19 +396,50 @@
@GetMapping("getCarPicture")
@ApiOperation("娓呮筏鑾峰彇鐓х墖")
- public AjaxResult getCarNearPositionByCarId(String carId){
+ public AjaxResult getCarNearPositionByCarId(String carId) throws UnsupportedEncodingException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+ Date currentTime = new Date();
+ long tenSeconds = 1000L;
+ Date beforeTenSeconds = new Date(currentTime.getTime() - tenSeconds);
+ String startTime = sdf.format(beforeTenSeconds);
String usersId = SecurityUtils.getUserId();
ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
String syURL = sysConfigService.getSYURL();
+ //鑾峰彇鎽勫儚閫氶亾淇℃伅
Map<String, Object> result = ardSyCarService.getCarPicture(carId,syURL,ardSyUser);
String vs = "";
try {
+ //鎻愬彇閫氶亾淇℃伅
Map<String,Object> map = ((List<Map<String,Object>>)result.get("list")).get(0);
Map<String, Object> videos = (Map<String, Object>) JSON.parse((String) map.get("videos"));
+// System.out.println(videos);
vs = (String) videos.get("vs");
} catch (Exception e) {
return AjaxResult.error("璇ヨ溅杈嗘病鏈夋憚鍍忛�氶亾鏃犵収鐗囨暟鎹紒");
}
- return AjaxResult.success(vs);
+ //绛涢�夐�氶亾淇℃伅
+ String[] vsArray = vs.split(",");
+ List<String> channelList = new ArrayList<>();
+ for (int i = 0; i < vsArray.length; i++) {
+ channelList.add(vsArray[i].substring(0,1));
+ }
+ //鎷嶇収
+ Map<String,Object> sendCmdMap = ardSyCarService.sendCmd(syURL,ardSyUser,carId,channelList);
+// System.out.println(sendCmdMap);
+ //鑾峰彇鐓х墖
+ Map<String,Object> photoMap = ardSyCarService.getPhoto(syURL,carId,ardSyUser,startTime);
+// System.out.println(photoMap);
+ return AjaxResult.success(photoMap);
}
+
+ @GetMapping("getVideo")
+ @ApiOperation("娓呮筏鑾峰彇瑙嗛")
+ public AjaxResult getVideo(String carId){
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String syURL = sysConfigService.getSYURL();
+ Map<String,Object> video = ardSyCarService.getVideo(syURL,carId,ardSyUser);
+ return AjaxResult.success(video);
+ }
+
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java
index c3dd83c..bff2667 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/domain/ArdAccessFence.java
@@ -26,4 +26,5 @@
private String alarmLng;
private String alarmLat;
private String carModel;
+ private String drct;
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java b/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
index 011952a..bb6911b 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/gps31/PushClientImplPosition.java
@@ -91,6 +91,7 @@
String deptNum = (String) result.get("deptId").toString();//鑾峰彇閮ㄩ棬ID
String deptName = (String) result.get("deptName");//鑾峰彇閮ㄩ棬鍚嶇О
String carModel = (String) result.get("carModel");//鑾峰彇杞﹁締妯″瀷
+ String drct = (String) gpsMap.get("drct");//鑾峰彇杞﹁締妯″瀷
//瀹氫箟2缁寸┖闂�
Point2D.Double point = new Point2D.Double(Double.parseDouble(lng), Double.parseDouble(lat));
List<Point2D.Double> pts = new ArrayList<Point2D.Double>();
@@ -124,6 +125,7 @@
ardAccessFence1.setNowWallName(ardOilWall.getName());
ardAccessFence1.setCarModel(carModel);
ardAccessFence1.setIsWarning(0);
+ ardAccessFence1.setDrct(drct);
((ArdAccessFenceServiceImpl)SpringUtils.getBean("ArdAccessFenceServiceImpl")).access(ardAccessFence1);
break;
}
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java b/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java
index 447814c..d1ea79f 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/IArdSyCarService.java
@@ -1,5 +1,6 @@
package com.ruoyi.sy.service;
+import java.io.UnsupportedEncodingException;
import java.util.List;
import java.util.Map;
@@ -130,6 +131,12 @@
Map<String, Object> getCarPicture(String carId, String syURL, ArdSyUser ardSyUser);
+ Map<String, Object> sendCmd(String syURL,ArdSyUser ardSyUser,String carId, List<String> channelList) throws UnsupportedEncodingException;
+
+ Map<String, Object> getPhoto(String syURL,String carId,ArdSyUser ardSyUser,String startTime);
+
+ Map<String, Object> getVideo(String syURL,String carId,ArdSyUser ardSyUser);
+
/**
* 鏍规嵁鐢ㄦ埛鍙婅溅杈嗕富閿拷韪溅杈�
*/
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 f0133ad..e7d97ce 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
@@ -2,6 +2,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -808,6 +810,53 @@
}
@Override
+ public Map<String, Object> sendCmd(String syURL, ArdSyUser ardSyUser, String carId, List<String> channelList) throws UnsupportedEncodingException {
+ //31鐢ㄦ埛鍚嶅瘑鐮�
+ String userId = ardSyUser.getUserId();
+ String password31 = ardSyUser.getPassword();
+ String password = DigestUtils.md5Hex(password31);
+ Map<String, Object> result1 = sYClient.logIn(syURL, password, userId);
+ Map<String, Object> sendCmdMap = new HashMap();
+// for (int i = 0; i < channelList.size(); i++) {
+ Map<String,String> params = new HashMap();
+ params.put("channel", channelList.get(1));//閫夋嫨閫氶亾1
+ params.put("interval", "0");//姣忛殧0s鐓т竴娆�
+ params.put("photoNum", "1");//鐓�1寮�
+ params.put("action", "0");//涓婁紶妯″紡
+ String paramsStr = com.alibaba.fastjson2.JSON.toJSONString(params);
+ paramsStr = URLEncoder.encode(paramsStr,"UTF-8");
+ System.out.println(paramsStr);
+ sendCmdMap = sYClient.sendCmd(syURL,userId,carId,301,"MediaTake",paramsStr,(String) result1.get("sessionId"));
+// }
+ return sendCmdMap;
+ }
+
+ @Override
+ public Map<String, Object> getPhoto(String syURL, String carId, ArdSyUser ardSyUser,String startTime) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+ //31鐢ㄦ埛鍚嶅瘑鐮�
+ String username31 = ardSyUser.getUserId();
+ String password31 = ardSyUser.getPassword();
+ String passwordMd5 = DigestUtils.md5Hex(password31);
+// System.out.println(username31+"----------"+passwordMd5);
+ Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31);
+ Map<String, Object> photoMap = new HashMap();
+ photoMap = sYClient.getPhoto(syURL,carId,startTime,sdf.format(new Date()),(String) result1.get("sessionId"));
+ return photoMap;
+ }
+
+ @Override
+ public Map<String, Object> getVideo(String syURL,String carId,ArdSyUser ardSyUser) {
+ //31鐢ㄦ埛鍚嶅瘑鐮�
+ String username = ardSyUser.getUserId();
+ String password31 = ardSyUser.getPassword();
+ String password = DigestUtils.md5Hex(password31);
+// Map<String, Object> result1 = sYClient.logIn(syURL, passwordMd5, username31);
+ return sYClient.getVideo(syURL,username,password,"榛慐12401",1);
+ }
+
+
+ @Override
public Results chaseCarByCarId(String usersId, String carId, String cycle) {
try {
/*Map<String,Map<String,Object>> map = new HashMap();
diff --git a/ard-work/src/main/java/com/ruoyi/utils/forest/SYClient.java b/ard-work/src/main/java/com/ruoyi/utils/forest/SYClient.java
index 16076fe..62d60f7 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/forest/SYClient.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/forest/SYClient.java
@@ -29,4 +29,14 @@
@Get(url = "${syURL}/gps-web/api/get_car_list.jsp?carIds=${carId}&detail=true&sessionId=${sessionId}")
Map<String,Object> getCarPicture(@Var("syURL") String syURL, @Var("carId") String carId,@Var("sessionId") String sessionId);
+
+ @Get(url = "${syURL}/gps-web/api/send_cmd.jsp?params=${paramsStr}&userId=${userId}&carId=${carId}&cmdId=${cmdId}&cmd=${cmd}&sessionId=${sessionId}")
+ Map<String,Object> sendCmd(@Var("syURL") String syURL, @Var("userId") String userId, @Var("carId") String carId,@Var("cmdId") Integer cmdId,@Var("cmd") String cmd,@Var("paramsStr") String paramsStr,@Var("sessionId") String sessionId);
+
+ @Get(url = "${syURL}/gps-web/api/get_photo_h.jsp?carId=${carId}&startTime=${startTime}&endTime=${endTime}&sessionId=${sessionId}")
+ Map<String,Object> getPhoto(@Var("syURL") String syURL, @Var("carId") String carId,@Var("startTime") String startTime,@Var("endTime") String endTime,@Var("sessionId") String sessionId);
+
+ @Get(url = "${syURL}/gps-web/api/video/realplay.jsp?username=${username}&password=${password}&plate=${plate}&color=${color}")
+ Map<String,Object> getVideo(@Var("syURL") String syURL, @Var("username") String username,@Var("password") String password,@Var("plate") String plate,@Var("color") Integer color);
+
}
--
Gitblit v1.9.3