Commit f6be2967 authored by wangjinjing's avatar wangjinjing

修改bug

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