Commit 1f70b150 authored by zhangyanduan's avatar zhangyanduan

add: 添加集成业务系统逻辑代码

parent cc80fa48
package org.rcisoft.integration.video.Service;
import org.rcisoft.sys.doorreportdata.entity.DoorReportData;
import org.springframework.stereotype.Service;
/**
......@@ -14,4 +15,11 @@ public interface IDaHuaVideoService {
*/
public boolean grabVideoDevicePicData();
/**
* 抓取视频监控设备图像
* @param videoDeviceId
* @return
*/
public boolean grabVideoDevicePicData(Long videoDeviceId, DoorReportData reportData)
}
package org.rcisoft.integration.video.Service.impl;
import com.sun.jna.Pointer;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.integration.video.Service.IDaHuaVideoService;
import org.rcisoft.integration.video.common.VideoDeviceHandel;
......@@ -8,7 +7,6 @@ import org.rcisoft.integration.video.config.CapturePicCallBack;
import org.rcisoft.integration.video.config.DaHuaVideoInitConfig;
import org.rcisoft.integration.video.utils.CapturePictureUtils;
import org.rcisoft.sys.doorreportdata.entity.DoorReportData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -66,4 +64,48 @@ public class DahuaVideoServiceImpl implements IDaHuaVideoService {
boolean picture = CapturePictureUtils.remoteCapturePicture(handel.getDeviceLoginHandle(), 0);
return picture;
}
@Override
public boolean grabVideoDevicePicData(Long videoDeviceId, DoorReportData reportData) {
/**
* 先判断是否已经初始化,
* 2、获取设备的配置信息
* 3、判断设备是否已经登录
* 4、未登录登录 一登录获取登录句柄
* 5、调用抓图工具类
* 6、回调写入数据
*/
VideoDeviceHandel handel = null;
if(!DaHuaVideoInitConfig.videoDeviceMap.containsKey(videoDeviceId)){
String deviceIp="192.168.1.199";
int devicePort = 37777;
String deviceAccount = "admin";
String deviceSign = "admin123";
boolean login = DaHuaVideoInitConfig.login(deviceIp, devicePort, deviceAccount, deviceSign);
if(login){
handel = DaHuaVideoInitConfig.videoDeviceMap.get(videoDeviceId);
}
}else{
handel = DaHuaVideoInitConfig.videoDeviceMap.get(videoDeviceId);
if(handel.isLoginStatus()){
String deviceIp="192.168.1.199";
int devicePort = 37777;
String deviceAccount = "admin";
String deviceSign = "admin123";
boolean login = DaHuaVideoInitConfig.login(deviceIp, devicePort, deviceAccount, deviceSign);
if(login){
handel = DaHuaVideoInitConfig.videoDeviceMap.get(videoDeviceId);
}
}
}
if(handel == null ||!handel.isLoginStatus()){
return false;
}
String basePath = "E:\\DAHUAPIC";
String strFileName =basePath+"\\"+new Date().getTime()+".jpg";
CapturePicCallBack callBack = new CapturePicCallBack(reportData,strFileName);
CapturePictureUtils.setSnapRevCallBack(callBack,null);
boolean picture = CapturePictureUtils.remoteCapturePicture(handel.getDeviceLoginHandle(), 0);
return picture;
}
}
......@@ -15,19 +15,24 @@ import java.io.File;
import java.io.IOException;
import java.util.Date;
/**
* 抓拍数据回调方法
*/
@Slf4j
public class CapturePicCallBack implements NetSDKLib.fSnapRev{
private String dataId;
private DoorReportData reportData;
private String savePath;
private DoorReportDataService doorReportDataService = SpringBeanUtils.getBean(DoorReportDataService.class);
public CapturePicCallBack(String dataId, String savePath) {
this.dataId = dataId;
public CapturePicCallBack(DoorReportData reportData, String savePath) {
this.reportData = reportData;
this.savePath = savePath;
}
......@@ -44,13 +49,8 @@ public class CapturePicCallBack implements NetSDKLib.fSnapRev{
public void invoke(NetSDKLib.LLong lLoginID, Pointer pBuf, int RevLen, int EncodeType, int CmdSerial, Pointer dwUser) {
BufferedImage bufferedImage = null;
if(pBuf != null && RevLen > 0) {
// String basePath = "E:\\DAHUAPIC";
// String strFileName =basePath+"\\"+new Date().getTime()+".jpg";
String strFileName = savePath;
log.info("回调函数中的dataId:"+dataId);
DoorReportData byId = doorReportDataService.findById(1);
log.info(JSONObject.toJSONString(byId));
System.out.println("strFileName = " + strFileName);
byte[] buf = pBuf.getByteArray(0, RevLen);
ByteArrayInputStream byteArrInput = new ByteArrayInputStream(buf);
......@@ -60,6 +60,8 @@ public class CapturePicCallBack implements NetSDKLib.fSnapRev{
return;
}
ImageIO.write(bufferedImage, "jpg", new File(strFileName));
//开始保存数据到表中
} catch (IOException e) {
log.error("抓图回调函数出现异常:"+e.getMessage(),e);
}
......@@ -81,4 +83,12 @@ public class CapturePicCallBack implements NetSDKLib.fSnapRev{
public void setSavePath(String savePath) {
this.savePath = savePath;
}
public DoorReportData getReportData() {
return reportData;
}
public void setReportData(DoorReportData reportData) {
this.reportData = reportData;
}
}
......@@ -85,5 +85,13 @@ public class DoorDeviceInfo extends CyIdIncreEntity<DoorDeviceInfo> {
*/
private String devicePoint;
/**
* @desc 关联视频监控设备ID
* @column link_video_id
* @default
*/
private Long linkVideoId;
}
package org.rcisoft.sys.doorreportdata.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import org.rcisoft.core.entity.CyIdIncreEntity;
import java.math.BigInteger;
import java.util.Date;
......
......@@ -9,7 +9,8 @@
<result column="device_address" jdbcType="VARCHAR" property="deviceAddress"/>
<result column="device_area" jdbcType="VARCHAR" property="deviceArea"/>
<result column="device_point" jdbcType="VARCHAR" property="devicePoint"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="remark" jdbcType="VARCHAR" property="remarks"/>
<result column="link_video_id" jdbcType="BIGINT" property="linkVideoId"/>
<result column="del_flag" jdbcType="CHAR" property="delFlag"/>
</resultMap>
......
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