|
|
|
@ -19,7 +19,7 @@ import com.inspect.simulator.domain.algorithm.out.AnalyseResult; |
|
|
|
import com.inspect.simulator.domain.basedata.BasedataEqpBookChannel; |
|
|
|
import com.inspect.simulator.hikVision.utils.AjaxResult; |
|
|
|
import com.inspect.simulator.hikVision.utils.StringUtils; |
|
|
|
import com.inspect.simulator.hikVision.utils.jna.HikVisionUtils; |
|
|
|
//import com.inspect.simulator.hikVision.utils.jna.HikVisionUtils; |
|
|
|
import com.inspect.simulator.hikVision.utils.jna.HCNetSDK; |
|
|
|
import com.inspect.simulator.mapper.BasedataEqpBookChannelMapper; |
|
|
|
import com.inspect.simulator.service.HikVisionService; |
|
|
|
@ -91,18 +91,12 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
@Value("${file.ftpUrlPort:test}") |
|
|
|
private Integer ftpUrlPort; |
|
|
|
|
|
|
|
@Value("${file.infraredPath:null}") |
|
|
|
private String infraredPath; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private SftpClient sftpClient; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private BasedataEqpBookChannelMapper basedataEqpBookChannelMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private AnalysisRemoteService analysisRemoteService; |
|
|
|
|
|
|
|
// @Override |
|
|
|
// public AjaxResult login(NvrInfo nvrInfo) { |
|
|
|
// return login_V40(nvrInfo); |
|
|
|
@ -976,16 +970,24 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
|
|
|
|
//华软上传图片到ftp |
|
|
|
public boolean pic2Ftp(String newPath, InputStream originalPath, String ftpUrlAddress, Integer ftpUrlPort, String ftpUrlAccount, String ftpUrlPwd) { |
|
|
|
FTPClient ftps = null; |
|
|
|
FTPClient ftps = new FTPClient();; |
|
|
|
ftps.setConnectTimeout(2000); // 连接超时3秒 |
|
|
|
ftps.setDataTimeout(2000); // 数据传输超时3秒 |
|
|
|
ftps.setDefaultTimeout(2000); // 控制通道超时3秒 |
|
|
|
try { |
|
|
|
ftps = new FTPClient(); |
|
|
|
// 尝试连接(仅一次) |
|
|
|
ftps.connect(ftpUrlAddress, ftpUrlPort); |
|
|
|
boolean loginRes = ftps.login(ftpUrlAccount, ftpUrlPwd); |
|
|
|
System.out.println(loginRes); |
|
|
|
// 登录(同样受3秒超时限制) |
|
|
|
if (!loginRes) { |
|
|
|
throw new IOException("登录失败: " + ftps.getReplyString()); |
|
|
|
} |
|
|
|
|
|
|
|
ftps.setFileType(2); |
|
|
|
ftps.enterLocalPassiveMode(); |
|
|
|
ftps.setControlEncoding("UTF-8"); |
|
|
|
ftps.setFileTransferMode(10); |
|
|
|
// ftps.setFileTransferMode(10); |
|
|
|
boolean success = ftps.storeFile(newPath, originalPath); |
|
|
|
if (!success) { |
|
|
|
System.err.println("上传失败!FTP 返回: " + ftps.getReplyString()); |
|
|
|
@ -995,11 +997,14 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
} finally { |
|
|
|
// 5. 关闭资源 |
|
|
|
try { |
|
|
|
if (originalPath != null) originalPath.close(); |
|
|
|
if (ftps != null && ftps.isConnected()) { |
|
|
|
ftps.logout(); |
|
|
|
ftps.disconnect(); |
|
|
|
if (ftps.isConnected()) { |
|
|
|
ftps.disconnect(); // 直接断开,不执行logout(节省时间) |
|
|
|
} |
|
|
|
// if (originalPath != null) originalPath.close(); |
|
|
|
// if (ftps != null && ftps.isConnected()) { |
|
|
|
// ftps.logout(); |
|
|
|
// ftps.disconnect(); |
|
|
|
// } |
|
|
|
} catch (IOException e) { |
|
|
|
// e.printStackTrace(); |
|
|
|
return false; |
|
|
|
@ -1124,7 +1129,8 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
List<AnalyseResItem> analyseResItems = new ArrayList<>(); |
|
|
|
analyseResItems.add(analyseResItem); |
|
|
|
analyseResult.setResultList(analyseResItems); |
|
|
|
|
|
|
|
System.out.println("返回值打印: 是否成功(0成功;1失败)"+analyseResPoint.getValue()+ |
|
|
|
",最高温度值"+analyseResPoint.getConf()+",返回图片路径:"+analyseResPoint.getResImageUrl()); |
|
|
|
try { |
|
|
|
String analyseResultOutJson = JSONObject.toJSONString(analyseResult); |
|
|
|
System.out.println("打印json返回:" + analyseResultOutJson); |
|
|
|
@ -1139,12 +1145,10 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
|
|
|
|
public InfraredInfo calculatePicture(InfraPictureInfo infraPictureInfo, String picData) { |
|
|
|
|
|
|
|
log.info("进入红外图片接口!" ); |
|
|
|
InfraredInfo infraredInfo = new InfraredInfo(); |
|
|
|
String imagePath = infraPictureInfo.getFilePath(); |
|
|
|
InputStream inputStream = downloadFtp(imagePath); |
|
|
|
|
|
|
|
// Long channelId = infraPictureInfo.getChannelId(); |
|
|
|
// BasedataEqpBookChannel basedataEqpBookChannel = basedataEqpBookChannelMapper.selectBasedataEqpBookChannelByChannelId(channelId); |
|
|
|
int firstX = 1; |
|
|
|
int firstY = 1; |
|
|
|
int secondX = 639; |
|
|
|
@ -1215,17 +1219,19 @@ public class HikVisionServiceImpl implements HikVisionService { |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} else { |
|
|
|
//不能调用华软接口,使用本地csv |
|
|
|
System.out.println("温度解析错误,接口无法调用!"); |
|
|
|
try { |
|
|
|
imageTem = exceptionHandling(); |
|
|
|
infraredInfo.setTemperatureMatrix(imageTem); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("温度解析错误,接口无法调用!" + e); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
String s = ImageOverlays(infraPictureInfo, infraredInfo); |
|
|
|
infraredInfo.setOutPath(s); |
|
|
|
} else { |
|
|
|
System.out.println("温度解析错误,ftp无法登陆!"); |
|
|
|
//华软ftp不能登录,使用本地csv |
|
|
|
try { |
|
|
|
imageTem = exceptionHandling(); |
|
|
|
|