Commit f6be2967 authored by wangjinjing's avatar wangjinjing

修改bug

parent 42907d34
...@@ -206,7 +206,7 @@ public class ExtController { ...@@ -206,7 +206,7 @@ public class ExtController {
headers.setContentType(MediaType.APPLICATION_JSON_UTF8); headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
Map<String, Object> maps = new HashMap<String, Object>(); Map<String, Object> maps = new HashMap<String, Object>();
maps.put("rtspvalue", rtspValue); maps.put("rtspvalue", rtspValue);
maps.put("refresh", 0); maps.put("refresh",1);
HttpEntity<String> formEntity = new HttpEntity<String>(null, headers); HttpEntity<String> formEntity = new HttpEntity<String>(null, headers);
TraffAlarmRecord record = new TraffAlarmRecord(); TraffAlarmRecord record = new TraffAlarmRecord();
Map<String, Object> transferRecordMap = new HashMap<>(); Map<String, Object> transferRecordMap = new HashMap<>();
...@@ -277,14 +277,16 @@ public class ExtController { ...@@ -277,14 +277,16 @@ public class ExtController {
BASE64Decoder base64Decoder=new BASE64Decoder(); BASE64Decoder base64Decoder=new BASE64Decoder();
int count = 0; int count = 0;
//开启多线程 //开启多线程
//调用结构化服务,获得图片返回结果
HttpHeaders headers = new HttpHeaders();
BASE64Encoder base64Encoder = new BASE64Encoder(); BASE64Encoder base64Encoder = new BASE64Encoder();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> requestEntity=null;
for (TraffAlarmRecord transferRecord : traffalarmrecordlist) { for (TraffAlarmRecord transferRecord : traffalarmrecordlist) {
count = 0; count = 0;
GoalStructureParam param = FileTransferManager.getGoalStructureParam(count, Integer.parseInt(model == null ? "1" : model.equals("") ? "1" : model), base64Encoder, transferRecord); GoalStructureParam param = FileTransferManager.getGoalStructureParam(count, Integer.parseInt(model == null ? "1" : model.equals("") ? "1" : model), base64Encoder, transferRecord);
//调用结构化服务,获得图片返回结果 if(param.getImageList().size()<1)continue;
HttpHeaders headers = new HttpHeaders(); requestEntity= new HttpEntity<String>(JSONObject.toJSONString(param), headers);
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> requestEntity = new HttpEntity<String>(JSONObject.toJSONString(param), headers);
ResponseEntity<String> response = restTemplate.exchange(recogurl, HttpMethod.POST, requestEntity, String.class); ResponseEntity<String> response = restTemplate.exchange(recogurl, HttpMethod.POST, requestEntity, String.class);
String body = response.getBody(); String body = response.getBody();
JSONObject result = JSONObject.parseObject(body); JSONObject result = JSONObject.parseObject(body);
...@@ -292,7 +294,8 @@ public class ExtController { ...@@ -292,7 +294,8 @@ public class ExtController {
//获得返回结果,根据 Metadata.type 判断是人,车,人骑车,并将详细信息入对应的表 //获得返回结果,根据 Metadata.type 判断是人,车,人骑车,并将详细信息入对应的表
List<TraffpictureParam> objectList = (List<TraffpictureParam>) JSONArray.parseArray(String.valueOf(result.get("ObjectList")), TraffpictureParam.class); List<TraffpictureParam> objectList = (List<TraffpictureParam>) JSONArray.parseArray(String.valueOf(result.get("ObjectList")), TraffpictureParam.class);
//获得 type //获得 type
//更新 recordalarm 为一分析
traffAlarmRecordService.updateTraffAlarmRecordProcess(transferRecord);
for (TraffpictureParam traffpictureParam : objectList) { for (TraffpictureParam traffpictureParam : objectList) {
//根据imageid 获得 base64图片 //根据imageid 获得 base64图片
...@@ -316,8 +319,7 @@ public class ExtController { ...@@ -316,8 +319,7 @@ public class ExtController {
//新增到picture //新增到picture
int id = traffPictureService.inserTraffpicture(traffpictureParam); int id = traffPictureService.inserTraffpicture(traffpictureParam);
//更新 recordalarm 为一分析
traffAlarmRecordService.updateTraffAlarmRecordProcess(transferRecord);
if (null != metadata && metadata.get("Type").equals("1"))//行人 if (null != metadata && metadata.get("Type").equals("1"))//行人
{ {
Pedestrian meta = JSON.toJavaObject(metadata, Pedestrian.class); Pedestrian meta = JSON.toJavaObject(metadata, Pedestrian.class);
......
...@@ -34,8 +34,8 @@ public class FTPUtil { ...@@ -34,8 +34,8 @@ public class FTPUtil {
// @PostConstruct // @PostConstruct
// private void initHostMap(){ // private void initHostMap(){
// if(ftpHost==null){ // if(ftpHost==null){
// log.error("ftp存储组未配置,请先配置"); // log.error("ftp�洢��δ���ã���������");
// log.error("ftp存储组未配置,请先配置"); // log.error("ftp�洢��δ���ã���������");
// return; // return;
// } // }
// //
...@@ -58,7 +58,7 @@ public class FTPUtil { ...@@ -58,7 +58,7 @@ public class FTPUtil {
return; return;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("FTP下载图片出错", e); log.error("FTP����ͼƬ����", e);
} finally { } finally {
IOUtils.closeQuietly(toClient); IOUtils.closeQuietly(toClient);
IOUtils.closeQuietly(is); IOUtils.closeQuietly(is);
...@@ -71,7 +71,7 @@ public class FTPUtil { ...@@ -71,7 +71,7 @@ public class FTPUtil {
try { try {
url = new URL(path); url = new URL(path);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
log.error("FTP URL路径错误"+e.toString()); log.error("FTP URL·������"+e.toString());
} }
byte[] buffer = null; byte[] buffer = null;
try (InputStream is = url.openStream();ByteArrayOutputStream bos = new ByteArrayOutputStream(1000)){ try (InputStream is = url.openStream();ByteArrayOutputStream bos = new ByteArrayOutputStream(1000)){
...@@ -83,13 +83,13 @@ public class FTPUtil { ...@@ -83,13 +83,13 @@ public class FTPUtil {
buffer = bos.toByteArray(); buffer = bos.toByteArray();
}catch (Exception e) { }catch (Exception e) {
log.error("FTP下载图片出错", e); log.error("FTP����ͼƬ����", e);
} }
return buffer; return buffer;
} }
//ftp图片上传,图片参数为base64封装的String //ftpͼƬ�ϴ���ͼƬ����Ϊbase64��װ��String
public static boolean uploadFile(Ftp ftpUrl, String path, String filename, String inputImg) { public static boolean uploadFile(Ftp ftpUrl, String path, String filename, String inputImg) {
boolean flag = true; boolean flag = true;
FTPClient ftpClient = null; FTPClient ftpClient = null;
...@@ -98,7 +98,7 @@ public class FTPUtil { ...@@ -98,7 +98,7 @@ public class FTPUtil {
if (inputImg == null) { if (inputImg == null) {
return false; return false;
} }
//base64解码 //base64����
BASE64Decoder decoder = new BASE64Decoder(); BASE64Decoder decoder = new BASE64Decoder();
byte[] b_img = decoder.decodeBuffer(inputImg); byte[] b_img = decoder.decodeBuffer(inputImg);
input = new ByteArrayInputStream(b_img); input = new ByteArrayInputStream(b_img);
...@@ -108,15 +108,15 @@ public class FTPUtil { ...@@ -108,15 +108,15 @@ public class FTPUtil {
changeWorkingDirectory(ftpClient, path); changeWorkingDirectory(ftpClient, path);
flag = ftpClient.storeFile(filename, input); flag = ftpClient.storeFile(filename, input);
if (flag) { if (flag) {
// log.info("FTP上传文件成功!"); // log.info("FTP�ϴ��ļ��ɹ���");
} else { } else {
flag = false; flag = false;
log.info("FTP上传文件失败!"); log.info("FTP�ϴ��ļ�ʧ�ܣ�");
} }
} }
} catch (Exception e) { } catch (Exception e) {
flag = false; flag = false;
log.error("FTP文件上传失败!", e.toString()); log.error("FTP�ļ��ϴ�ʧ�ܣ�", e.toString());
} finally { } finally {
IOUtils.closeQuietly(input); IOUtils.closeQuietly(input);
closeConnect(ftpClient); closeConnect(ftpClient);
...@@ -133,20 +133,20 @@ public class FTPUtil { ...@@ -133,20 +133,20 @@ public class FTPUtil {
changeWorkingDirectory(ftpClient, path); changeWorkingDirectory(ftpClient, path);
flag = ftpClient.storeFile(filename, input); flag = ftpClient.storeFile(filename, input);
if (flag) { if (flag) {
// log.info("FTP upload success"); // log.info("FTP upload success��");
} else { } else {
log.info("FTP upload fail"); log.info("FTP upload fail��");
} }
} else { } else {
flag = false; flag = false;
// log.info("FTP server refused connection "); // log.info("FTP server refused connection ��");
} }
} catch (IOException e) { } catch (IOException e) {
flag = false; flag = false;
log.error("FTP upload fail", e); log.error("FTP upload fail��", e);
} catch (Exception e) { } catch (Exception e) {
flag = false; flag = false;
log.error("FTP upload fail", e); log.error("FTP upload fail��", e);
} finally { } finally {
IOUtils.closeQuietly(input); IOUtils.closeQuietly(input);
closeConnect(ftpClient); closeConnect(ftpClient);
...@@ -155,7 +155,7 @@ public class FTPUtil { ...@@ -155,7 +155,7 @@ public class FTPUtil {
} }
/* /*
* 得到配置文件中的FTP服务器地 * �õ������ļ��е�FTP��������ַ
*/ */
public static String getFtpUrl(Ftp ftpUrl) { public static String getFtpUrl(Ftp ftpUrl) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
...@@ -180,13 +180,13 @@ public class FTPUtil { ...@@ -180,13 +180,13 @@ public class FTPUtil {
* @param ftpUrl * @param ftpUrl
* @return * @return
* @throws Exception * @throws Exception
* @description 删除ftp上的文件 * @description ɾ��ftp�ϵ��ļ�
* @author sunw * @author sunw
*/ */
public static boolean deleteFileFromFtpUrl(String ftpUrl) throws Exception { public static boolean deleteFileFromFtpUrl(String ftpUrl) throws Exception {
boolean flag = false; boolean flag = false;
if (null == ftpUrl || StringUtils.isBlank(ftpUrl)) { if (null == ftpUrl || StringUtils.isBlank(ftpUrl)) {
throw new Exception("ftpUrl串为空"); throw new Exception("ftpUrl��Ϊ��");
} }
Map<String, String> result = getFtpInfoMapByFullPath(ftpUrl); Map<String, String> result = getFtpInfoMapByFullPath(ftpUrl);
String ftpUser = result.get("ftpUser"); String ftpUser = result.get("ftpUser");
...@@ -198,7 +198,7 @@ public class FTPUtil { ...@@ -198,7 +198,7 @@ public class FTPUtil {
Ftp ftp = FTPUtil.getFtpUrlObj(ftpIp, ftpPort, ftpUser, ftpPassword); Ftp ftp = FTPUtil.getFtpUrlObj(ftpIp, ftpPort, ftpUser, ftpPassword);
FTPClient ftpClient = connectServer(ftp); FTPClient ftpClient = connectServer(ftp);
if (null == ftpClient) { if (null == ftpClient) {
throw new Exception("ftp登录失败 "); throw new Exception("ftp��¼ʧ�� ");
} else { } else {
String fullPath = (null == path || "".equals(path.trim())) ? fileName : (path + "/" + fileName); String fullPath = (null == path || "".equals(path.trim())) ? fileName : (path + "/" + fileName);
try { try {
...@@ -216,12 +216,12 @@ public class FTPUtil { ...@@ -216,12 +216,12 @@ public class FTPUtil {
* @param ftpUrlStr * @param ftpUrlStr
* @return * @return
* @throws Exception * @throws Exception
* @author sunw 通过图片路径 * @author sunw ͨ��ͼƬ·��
* 获得ftpuser,ftppassword,ftpip,ftpport,在fpt上的文件路径,文件realname * ���ftpuser,ftppassword,ftpip,ftpport,��fpt�ϵ��ļ�·��,�ļ�realname
*/ */
private static Map<String, String> getFtpInfoMapByFullPath(String ftpUrlStr) throws Exception { private static Map<String, String> getFtpInfoMapByFullPath(String ftpUrlStr) throws Exception {
if (null == ftpUrlStr || "".equals(ftpUrlStr.trim())) { if (null == ftpUrlStr || "".equals(ftpUrlStr.trim())) {
throw new Exception("ftpstr串为空"); throw new Exception("ftpstr��Ϊ��");
} }
ftpUrlStr = ftpUrlStr.replaceAll("\\\\", "/"); ftpUrlStr = ftpUrlStr.replaceAll("\\\\", "/");
ftpUrlStr = changeUrlCharater(ftpUrlStr); ftpUrlStr = changeUrlCharater(ftpUrlStr);
...@@ -233,7 +233,7 @@ public class FTPUtil { ...@@ -233,7 +233,7 @@ public class FTPUtil {
String ftpPassword = ftpUserAndPassword[1]; String ftpPassword = ftpUserAndPassword[1];
String ftpIp = ftpIpAndPort[0]; String ftpIp = ftpIpAndPort[0];
String ftpPort = ftpIpAndPort.length > 1 ? ftpIpAndPort[1] : ""; String ftpPort = ftpIpAndPort.length > 1 ? ftpIpAndPort[1] : "";
String fileName = array[array.length - 1];// 获得文件名 String fileName = array[array.length - 1];// ����ļ���
Map<String, String> resultMap = new HashMap<String, String>(); Map<String, String> resultMap = new HashMap<String, String>();
resultMap.put("ftpUser", ftpUser); resultMap.put("ftpUser", ftpUser);
resultMap.put("ftpPassword", ftpPassword); resultMap.put("ftpPassword", ftpPassword);
...@@ -258,7 +258,7 @@ public class FTPUtil { ...@@ -258,7 +258,7 @@ public class FTPUtil {
boolean flag = deleteFileFromFtpUrl(temp); boolean flag = deleteFileFromFtpUrl(temp);
System.out.println(flag); System.out.println(flag);
} catch (Exception e) { } catch (Exception e) {
System.out.println("删除文件失败"); System.out.println(���ļ�ʧ��");
} }
// String [] strSplit = temp.split("/"); // String [] strSplit = temp.split("/");
// for(int i = 0 ; i < strSplit.length ; i++) { // for(int i = 0 ; i < strSplit.length ; i++) {
...@@ -273,7 +273,7 @@ public class FTPUtil { ...@@ -273,7 +273,7 @@ public class FTPUtil {
} }
/** /**
* 连接到服务器 * ���ӵ�������
*/ */
private static FTPClient connectServer(Ftp ftpUrl) { private static FTPClient connectServer(Ftp ftpUrl) {
FTPClient ftpClient = null; FTPClient ftpClient = null;
...@@ -293,18 +293,18 @@ public class FTPUtil { ...@@ -293,18 +293,18 @@ public class FTPUtil {
if (!FTPReply.isPositiveCompletion(reply)) { if (!FTPReply.isPositiveCompletion(reply)) {
ftpClient.disconnect(); ftpClient.disconnect();
System.err.println("FTP server refused connection."); System.err.println("FTP server refused connection.");
log.info("FTP 服务拒绝连接!"); log.info("FTP ����ܾ����ӣ�");
} }
} catch (SocketException e) { } catch (SocketException e) {
log.error("登录ftp服务器 " + ftpUrl.getFtpIp() + " 失败,连接超时!", e); log.error("��¼ftp������ " + ftpUrl.getFtpIp() + " ʧ��,���ӳ�ʱ��", e);
} catch (IOException e) { } catch (IOException e) {
log.error("登录ftp服务器 " + ftpUrl.getFtpIp() + " 失败,FTP服务器无法打开!", e); log.error("��¼ftp������ " + ftpUrl.getFtpIp() + " ʧ�ܣ�FTP�������޷��򿪣�", e);
} }
return ftpClient; return ftpClient;
} }
/** /**
* 关闭连接 * �ر�����
*/ */
private static void closeConnect(FTPClient ftpClient) { private static void closeConnect(FTPClient ftpClient) {
try { try {
...@@ -315,12 +315,12 @@ public class FTPUtil { ...@@ -315,12 +315,12 @@ public class FTPUtil {
ftpClient.disconnect(); ftpClient.disconnect();
} }
} catch (Exception e) { } catch (Exception e) {
log.error("关闭ftp连接失败", e); log.error("�ر�ftp����ʧ��", e);
} }
} }
/** /**
* 进入到服务器的某个目录下 * ���뵽��������ij��Ŀ¼��
* *
* @param directory * @param directory
*/ */
...@@ -337,12 +337,12 @@ public class FTPUtil { ...@@ -337,12 +337,12 @@ public class FTPUtil {
ftpClient.changeWorkingDirectory(subPath); ftpClient.changeWorkingDirectory(subPath);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
log.error("改变ftp工作路径失败", ioe); log.error("�ı�ftp����·��ʧ��", ioe);
} }
} }
/** /**
* 转码[ISO-8859-1 -> GBK] 不同的平台需要不同的转码 * ת��[ISO-8859-1 -> GBK] ��ͬ��ƽ̨��Ҫ��ͬ��ת��
* *
* @param obj * @param obj
* @return "" * @return ""
......
...@@ -163,7 +163,8 @@ public class FileTransferManager { ...@@ -163,7 +163,8 @@ public class FileTransferManager {
if (null != img1path && !"".equals(img1path)) { if (null != img1path && !"".equals(img1path)) {
byte[] Img = FTPUtil.getFtpPicBytes(img1path); byte[] Img = FTPUtil.getFtpPicBytes(img1path);
if (Img != null) { if (Img != null) {
list.add(new ImageList(id, base64Encoder.encode(Img))); list.add(new ImageList(id, base64Encoder.encode(Img).replaceAll("\r|\n", "")));
} }
} }
} }
......
...@@ -2,6 +2,6 @@ file.uploadpath=D:\\imp\\VideoPic ...@@ -2,6 +2,6 @@ file.uploadpath=D:\\imp\\VideoPic
file.alarmpath=D:\\imp\\VideoPic file.alarmpath=D:\\imp\\VideoPic
file.recordurl=http://www.zjwwzf.cn/xzzfSpv/ext/patrolCtrlRecord file.recordurl=http://www.zjwwzf.cn/xzzfSpv/ext/patrolCtrlRecord
file.alarmurl=http://www.zjwwzf.cn/xzzfSpv/ext/alarm/camera file.alarmurl=http://www.zjwwzf.cn/xzzfSpv/ext/alarm/camera
file.rtspurl=http://localhost:8089/getrealcamerasnapshot file.rtspurl=http://172.16.24.153:8081/getrealcamerasnapshot.php
file.recogurl=http://localhost:8089/images/recog file.recogurl=http://172.16.24.153:9098/images/recog
redis.cachekey.ftplist=gs:traff:global:cache:ftplist redis.cachekey.ftplist=gs:traff:global:cache:ftplist
...@@ -6,6 +6,7 @@ import org.junit.Test; ...@@ -6,6 +6,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import sun.misc.BASE64Decoder;
import java.util.List; import java.util.List;
...@@ -15,8 +16,8 @@ import java.util.List; ...@@ -15,8 +16,8 @@ import java.util.List;
@Test @Test
public void contextLoads() { public void contextLoads() {
SbtdspsrImpl mapper=new SbtdspsrImpl(); BASE64Decoder decoder=new BASE64Decoder();
List<Sbtdspsr> sbtdspsrs = mapper.selectByRtsp("rtsp://33.55.1.81:5544/1_20200305112049753_0_0");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment