@ -1,5 +1,7 @@
@@ -1,5 +1,7 @@
package com.ruoyi.code.camera.controller ;
import com.alibaba.fastjson.JSON ;
import com.ruoyi.code.camera.domain.LogInfo ;
import com.ruoyi.common.annotation.Log ;
import com.ruoyi.common.core.controller.BaseController ;
import com.ruoyi.common.core.page.R ;
@ -16,6 +18,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
@@ -16,6 +18,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.* ;
import sdk.java.lib.netmanager.NetEnums ;
import sdk.java.lib.netmanager.NetLib ;
import sdk.java.lib.netmanager.NetStructs ;
import utils.CameraUtil ;
import utils.RegisterUtil ;
import utils.run_device_cfg ;
@ -25,6 +28,7 @@ import javax.annotation.Resource;
@@ -25,6 +28,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletResponse ;
import java.util.Arrays ;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
@ -60,7 +64,6 @@ public class CameraController extends BaseController
@@ -60,7 +64,6 @@ public class CameraController extends BaseController
@PreAuthorize ( "@ss.hasPermi('web:camera:query')" )
public R info ( @PathVariable ( "id" ) Long id ) {
Camera camera = cameraService . getById ( id ) ;
return R . ok ( ) . put ( "data" , camera ) ;
}
@ -195,44 +198,50 @@ public class CameraController extends BaseController
@@ -195,44 +198,50 @@ public class CameraController extends BaseController
public R getAutoCfg ( @PathVariable ( "id" ) Long id ) {
int nCommand = NetEnums . EM_DEVICE_CFG_TYPE . DEVICE_CFG_AUTO_MAINTAIN ;
Camera camera = cameraService . getCameraBySid ( id ) ;
IntByReference nError = new IntByReference ( 0 ) ;
NativeLong loginID = NetLib . instance . Net_LoginDevice ( camera . getIp ( ) , camera . getPort ( ) , camera . getUsername ( ) , camera . getPassword ( ) , null , nError ) ;
Camera camera = cameraService . getById ( id ) ;
run_device_cfg cfg = new run_device_cfg ( ) ;
cfg . getAutoCfg ( loginID , nCommand ) ;
return R . ok ( ) ;
// Object data = JSON.toJSON(cfg.getAutoCfg(new NativeLong(Long.parseLong(camera.getLoginId())),nCommand)).toString();
NetStructs . STU_CFG_AUTO_MAINTAIN cc = cfg . getAutoCfg ( new NativeLong ( Long . parseLong ( camera . getLoginId ( ) ) ) , nCommand ) ;
Map < String , Object > data = new HashMap < > ( ) ;
data . put ( "bEnable" , cc . bEnable ) ;
data . put ( "uWeekDay" , cc . uWeekDay ) ;
data . put ( "uHour" , cc . uHour ) ;
return R . ok ( ) . put ( "data" , data ) ;
}
/ * *
* 设置摄像头重启
* /
@RequestMapping ( "/setautocfg/" )
public R setAutoCfg ( @RequestParam Map < String , Object > params ) {
Camera camera = cameraService . getCameraBySid ( ( Long ) params . get ( "sid" ) ) ;
IntByReference nError = new IntByReference ( 0 ) ;
NativeLong loginID = NetLib . instance . Net_LoginDevice ( camera . getIp ( ) , camera . getPort ( ) , camera . getUsername ( ) , camera . getPassword ( ) , null , nError ) ;
@RequestMapping ( "/setautocfg" )
public R setAutoCfg ( @RequestBody Map < String , Object > params ) {
String id = ( String ) params . get ( "id" ) ;
Camera camera = cameraService . getById ( id ) ;
run_device_cfg cfg = new run_device_cfg ( ) ;
cfg . setAutoFtpCfg ( loginID , ( int ) params . get ( "benable" ) , ( int ) params . get ( "uHour" ) , ( int ) params . get ( "uWeekDay" ) ) ;
return cfg . setAutoFtpCfg ( new NativeLong ( Long . parseLong ( camera . getLoginId ( ) ) ) ,
Integer . parseInt ( params . get ( "bEnable" ) . toString ( ) ) ,
Integer . parseInt ( params . get ( "uHour" ) . toString ( ) ) ,
Integer . parseInt ( params . get ( "uWeekDay" ) . toString ( ) ) ) ;
return R . ok ( ) ;
}
/ * *
* 获取日志
* /
@RequestMapping ( "/getloginfo/ " )
@RequestMapping ( "/getloginfo" )
public R getloginfo ( @RequestParam Map < String , Object > params ) {
Camera camera = cameraService . getCameraBySid ( ( Long ) params . get ( "sid" ) ) ;
IntByReference nError = new IntByReference ( 0 ) ;
NativeLong loginID = NetLib . instance . Net_LoginDevice ( camera . getIp ( ) , camera . getPort ( ) , camera . getUsername ( ) , camera . getPassword ( ) , null , nError ) ;
String id = ( String ) params . get ( "id" ) ;
String startTime = ( String ) params . get ( "startTime" ) ;
String endTime = ( String ) params . get ( "endTime" ) ;
Camera camera = cameraService . getById ( id ) ;
run_device_log_search logSearch = new run_device_log_search ( ) ;
logSearch . logInfoSearchByTime ( loginID , ( String ) params . get ( "strStartTime" ) , ( String ) params . get ( "strEndTime" ) ) ;
return R . ok ( ) ;
List < LogInfo > data = logSearch . logInfoSearchByTime ( new NativeLong ( Long . parseLong ( camera . getLoginId ( ) ) ) , startTime , endTime ) ;
System . out . println ( data ) ;
return R . ok ( ) . put ( "data" , data ) ;
}
}