|
|
|
@ -94,6 +94,9 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
@Value("${file.ftpUrlPort:10000}") |
|
|
|
private Integer ftpUrlPort; |
|
|
|
|
|
|
|
@Value("${file.produceEnvironment:test}") |
|
|
|
private Boolean produceEnvironment; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private SftpClient sftpClient; |
|
|
|
|
|
|
|
@ -958,7 +961,7 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
|
|
|
|
//华软上传图片到ftp |
|
|
|
public boolean pic2Ftp(String newPath, InputStream originalPath, String ftpUrlAddress, Integer ftpUrlPort, String ftpUrlAccount, String ftpUrlPwd) { |
|
|
|
FTPClient ftps = new FTPClient();; |
|
|
|
FTPClient ftps = new FTPClient(); |
|
|
|
ftps.setConnectTimeout(2000); // 连接超时3秒 |
|
|
|
ftps.setDataTimeout(2000); // 数据传输超时3秒 |
|
|
|
ftps.setDefaultTimeout(2000); // 控制通道超时3秒 |
|
|
|
@ -1099,7 +1102,7 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
AnalyseResPoint analyseResPoint = new AnalyseResPoint(); |
|
|
|
// analyseResPoint.setValue("0"); |
|
|
|
// analyseResPoint.setConf("0.85"); |
|
|
|
if (String.valueOf((double) infraredInfo.getFrameMax()) != null) { |
|
|
|
if (String.valueOf((double) infraredInfo.getFrameMax()) != null && infraredInfo.getOutPath() !=null) { |
|
|
|
analyseResPoint.setValue("0");//成功 |
|
|
|
} else { |
|
|
|
analyseResPoint.setValue("1");//失败 |
|
|
|
@ -1183,55 +1186,74 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
// sdk版本调用x64 |
|
|
|
|
|
|
|
// float[][] imageTem = djService.getImageTem("D:/projects/pic/hw/1.JPG"); |
|
|
|
|
|
|
|
//调用华软接口 |
|
|
|
String protocol = hrFtpUrl.substring(0, 6); // "ftp://" |
|
|
|
String withoutProtocol = hrFtpUrl.substring(6); // "zthr02:zthr02@123.184.14.138:50021/" |
|
|
|
String[] userAndHost = withoutProtocol.split("@"); |
|
|
|
if (userAndHost.length != 2) { |
|
|
|
throw new IllegalArgumentException("URL 格式错误,缺少 @ 分隔符"); |
|
|
|
} |
|
|
|
String[] userPass = userAndHost[0].split(":"); |
|
|
|
String username = userPass[0]; |
|
|
|
String password = userPass[1]; |
|
|
|
String hostPort = userAndHost[1].replace("/", ""); // 移除末尾的 "/" |
|
|
|
String[] hostAndPort = hostPort.split(":"); |
|
|
|
String host = hostAndPort[0]; |
|
|
|
int port = Integer.parseInt(hostAndPort[1]); |
|
|
|
String imageName = Paths.get(imagePath).getFileName().toString(); |
|
|
|
boolean isLoginHr = pic2Ftp(imageName, inputStream, host, port, username, password); |
|
|
|
String ftpUrlName = "[\"" + hrFtpUrl + imageName + "\"]"; |
|
|
|
|
|
|
|
|
|
|
|
float[][] imageTem = new float[0][]; |
|
|
|
if (isLoginHr) { |
|
|
|
//可以登陆华软ftp |
|
|
|
imageTem = UploadFtpImage(hrUavUrl, null, ftpUrlName); |
|
|
|
if (imageTem != null && imageTem.length > 0 && imageTem[0].length > 0) { |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
if (!produceEnvironment) { |
|
|
|
//调用华软接口 |
|
|
|
String protocol = hrFtpUrl.substring(0, 6); // "ftp://" |
|
|
|
String withoutProtocol = hrFtpUrl.substring(6); // "zthr02:zthr02@123.184.14.138:50021/" |
|
|
|
String[] userAndHost = withoutProtocol.split("@"); |
|
|
|
if (userAndHost.length != 2) { |
|
|
|
throw new IllegalArgumentException("URL 格式错误,缺少 @ 分隔符"); |
|
|
|
} |
|
|
|
String[] userPass = userAndHost[0].split(":"); |
|
|
|
String username = userPass[0]; |
|
|
|
String password = userPass[1]; |
|
|
|
String hostPort = userAndHost[1].replace("/", ""); // 移除末尾的 "/" |
|
|
|
String[] hostAndPort = hostPort.split(":"); |
|
|
|
String host = hostAndPort[0]; |
|
|
|
int port = Integer.parseInt(hostAndPort[1]); |
|
|
|
String imageName = Paths.get(imagePath).getFileName().toString(); |
|
|
|
boolean isLoginHr = pic2Ftp(imageName, inputStream, host, port, username, password); |
|
|
|
String ftpUrlName = "[\"" + hrFtpUrl + imageName + "\"]"; |
|
|
|
|
|
|
|
float[][] imageTem = new float[0][]; |
|
|
|
if (isLoginHr) { |
|
|
|
//可以登陆华软ftp |
|
|
|
imageTem = UploadFtpImage(hrUavUrl, null, ftpUrlName); |
|
|
|
if (imageTem != null && imageTem.length > 0 && imageTem[0].length > 0) { |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} else { |
|
|
|
//不能调用华软接口,使用本地csv |
|
|
|
try { |
|
|
|
imageTem = exceptionHandling(); |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("温度解析错误,接口无法调用!"); |
|
|
|
} |
|
|
|
} |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} else { |
|
|
|
//不能调用华软接口,使用本地csv |
|
|
|
//华软ftp不能登录,使用本地csv |
|
|
|
try { |
|
|
|
imageTem = exceptionHandling(); |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("温度解析错误,接口无法调用!"); |
|
|
|
log.error("温度解析错误,ftp无法登陆!" + e); |
|
|
|
} |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} else { |
|
|
|
//华软ftp不能登录,使用本地csv |
|
|
|
try { |
|
|
|
imageTem = exceptionHandling(); |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("温度解析错误,ftp无法登陆!"+ e); |
|
|
|
String imageName = Paths.get(imagePath).getFileName().toString(); |
|
|
|
String ftpUrlName = "[\"ftp://" + ftpUrlAccount + ":" + ftpUrlPwd + "@" + ftpUrlAddress + ":" + ftpUrlPort + "/" + imageName + "\"]"; |
|
|
|
float[][] floats =new float[0][]; |
|
|
|
floats =UploadFtpImage(hrUavUrl, null, ftpUrlName); |
|
|
|
if (floats != null && floats.length > 0 && floats[0].length > 0) { |
|
|
|
infraredInfo.setTemperatureMatrix(floats); |
|
|
|
} else { |
|
|
|
//不能调用华软接口,使用本地csv |
|
|
|
try { |
|
|
|
floats = exceptionHandling(); |
|
|
|
infraredInfo.setTemperatureMatrix(floats); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("温度解析错误,接口无法调用!"); |
|
|
|
} |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} |
|
|
|
} |
|
|
|
return infraredInfo; |
|
|
|
|