| | |
| | | package com.ycl.task; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.sun.jna.ptr.IntByReference; |
| | | import com.ycl.dto.video.Camera; |
| | | import com.ycl.dto.video.PageResult; |
| | | import com.ycl.entity.video.VideoPoint; |
| | | import com.ycl.service.video.impl.IVideoPointService; |
| | | import com.ycl.util.VideoUtil; |
| | | import com.ycl.util.dahua.alarm.AlarmDataCB; |
| | | import com.ycl.util.dahua.lib.LibraryLoad; |
| | | import com.ycl.util.dahua.lib.NetSDKLib; |
| | | import com.ycl.util.dahua.lib.module.LoginModule; |
| | | import com.ycl.util.dahua.login.DisConnectCallBack; |
| | | import com.ycl.util.dahua.login.HaveReConnectCallBack; |
| | | import com.ycl.util.dahua.module.AlarmListenModule; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | @Autowired |
| | | private VideoUtil videoUtil; |
| | | |
| | | // @Scheduled(cron = "0 */5 * * * ?") // 每5分钟执行 |
| | | // @Scheduled(cron = "0 */5 * * * ?") // 每5分钟执行 |
| | | @Scheduled(cron = "0 0 1 * * ?") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void scheduledTask() { |
| | |
| | | |
| | | } |
| | | |
| | | public static final NetSDKLib netSdk = NetSDKLib.NETSDK_INSTANCE; |
| | | // 登陆句柄 |
| | | private NetSDKLib.LLong loginHandle = new NetSDKLib.LLong(0); |
| | | |
| | | // 预览预览句柄 |
| | | private static NetSDKLib.LLong lRealHandle = new NetSDKLib.LLong(0); |
| | | |
| | | |
| | | // 设备信息扩展 |
| | | private NetSDKLib.NET_DEVICEINFO_Ex deviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); |
| | | |
| | | @Scheduled(cron = "0 */1 * * * ?") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void scheduledTestTask() { |
| | | try { |
| | | |
| | | System.out.println("大华:开始执行"); |
| | | LibraryLoad.setExtractPath("/home/sccg/libs/linux64"); |
| | | // LibraryLoad.setExtractPath("D:\\1.workcode\\ycyl\\sccg_server\\ycl-platform\\src\\main\\resources\\libs\\win64"); |
| | | AlarmDataCB cbMessage = new AlarmDataCB(); |
| | | String m_strIp = "172.28.194.186"; |
| | | int m_nPort = 37777; |
| | | String m_strUser = "admin"; |
| | | String m_strPassword = "scdx@123"; |
| | | InitTest(); |
| | | // 登陆设备 |
| | | int nSpecCap = NetSDKLib.EM_LOGIN_SPAC_CAP_TYPE.EM_LOGIN_SPEC_CAP_TCP; // TCP登入 |
| | | IntByReference nError = new IntByReference(0); |
| | | loginHandle = netSdk.CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, |
| | | m_strPassword, nSpecCap, null, deviceInfo, nError); |
| | | if (loginHandle.longValue() != 0) { |
| | | System.out.printf("Login Device[%s] Success!\n", m_strIp); |
| | | } else { |
| | | System.err.printf("Login Device[%s] Fail.Error[0x%x]\n", m_strIp, netSdk.CLIENT_GetLastError()); |
| | | // LoginOut(); |
| | | } |
| | | |
| | | AlarmListenModule.startListen(cbMessage, loginHandle); |
| | | |
| | | } catch (Exception ex) { |
| | | System.out.println(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | public void InitTest() { |
| | | // 初始化SDK库 |
| | | netSdk.CLIENT_Init(DisConnectCallBack.getInstance(), null); |
| | | |
| | | // 设置断线重连成功回调函数 |
| | | netSdk.CLIENT_SetAutoReconnect(HaveReConnectCallBack.getInstance(), null); |
| | | |
| | | //打开日志,可选 |
| | | NetSDKLib.LOG_SET_PRINT_INFO setLog = new NetSDKLib.LOG_SET_PRINT_INFO(); |
| | | String logPath = new File(".").getAbsoluteFile().getParent() + File.separator + "sdk_log" + File.separator + "sdk.log"; |
| | | setLog.bSetFilePath = 1; |
| | | System.arraycopy(logPath.getBytes(), 0, setLog.szLogFilePath, 0, logPath.getBytes().length); |
| | | setLog.bSetPrintStrategy = 1; |
| | | setLog.nPrintStrategy = 0; |
| | | if (!netSdk.CLIENT_LogOpen(setLog)) { |
| | | System.err.println("Open SDK Log Failed!!!"); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void findVideoList(Integer pageNo, Integer pageSize) { |
| | | try { |
| | | PageResult<Camera> pageResult = videoUtil.callPostCameras(pageNo, pageSize, "0"); |