@ -2,6 +2,7 @@ package com.ruoyi.code.camera.controller;
@@ -2,6 +2,7 @@ package com.ruoyi.code.camera.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.ruoyi.code.camera.domain.Camera ;
import com.ruoyi.code.camera.domain.LogInfo ;
import com.ruoyi.code.camera.service.ICameraService ;
import com.ruoyi.common.annotation.Log ;
import com.ruoyi.common.core.controller.BaseController ;
@ -12,15 +13,16 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -12,15 +13,16 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.sun.jna.NativeLong ;
import org.springframework.security.access.prepost.PreAuthorize ;
import org.springframework.web.bind.annotation.* ;
import sdk.java.lib.netmanager.NetEnums ;
import sdk.java.lib.netmanager.NetStructs ;
import utils.CameraUtil ;
import utils.RegisterUtil ;
import utils.run_device_cfg ;
import utils.run_device_log_search ;
import javax.annotation.Resource ;
import javax.servlet.http.HttpServletResponse ;
import java.util.Arrays ;
import java.util.Date ;
import java.util.List ;
import java.util.Map ;
import java.util.* ;
/ * *
* 摄像机Controller
@ -48,4 +50,141 @@ public class ApiController extends BaseController
@@ -48,4 +50,141 @@ public class ApiController extends BaseController
return R . ok ( ) ;
}
/ * *
* 重启注册服务
* /
@RequestMapping ( "register" )
public R register ( ) {
return cameraService . register ( ) ;
}
/ * *
* 清空所有摄像机状态
* /
@RequestMapping ( "outLine" )
public R outLine ( ) {
return cameraService . outLine ( ) ;
}
/ * *
* 重启摄像机
* /
@RequestMapping ( "reboot/{id}" )
public R reboot ( @PathVariable ( "id" ) Long id ) {
Camera c = cameraService . getById ( id ) ;
return cameraService . rebootByLoginId ( c ) ;
}
/ * *
* 刷新4G信号强度
* /
@RequestMapping ( "/refreshRssi/{id}" )
public R refreshRssiLevel ( @PathVariable ( "id" ) Long id ) {
Camera c = cameraService . getById ( id ) ;
if ( c . getStatus ( ) = = 0 | | StringUtils . isBlank ( c . getLoginId ( ) ) ) {
return R . error ( "设备未在线" ) ;
}
int level = CameraUtil . get4gRssiLevel ( new NativeLong ( Long . parseLong ( c . getLoginId ( ) ) ) ) ;
c . setRssiLevel ( level ) ;
cameraService . updateById ( c ) ;
return R . ok ( ) ;
}
/ * *
* 查询摄像头重启数据
* /
@RequestMapping ( "/getautocfg/{id}" )
public R getAutoCfg ( @PathVariable ( "id" ) Long id ) {
int nCommand = NetEnums . EM_DEVICE_CFG_TYPE . DEVICE_CFG_AUTO_MAINTAIN ;
Camera camera = cameraService . getById ( id ) ;
run_device_cfg cfg = new run_device_cfg ( ) ;
// 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 ( @RequestBody Map < String , Object > params ) {
int id = ( Integer ) params . get ( "id" ) ;
Camera camera = cameraService . getById ( id ) ;
run_device_cfg cfg = new run_device_cfg ( ) ;
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 ( ) ) ) ;
}
/ * *
* 获取日志
* /
@RequestMapping ( "/getloginfo" )
public R getloginfo ( @RequestParam Map < String , Object > params ) {
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 ( ) ;
List < LogInfo > data = logSearch . logInfoSearchByTime ( new NativeLong ( Long . parseLong ( camera . getLoginId ( ) ) ) , startTime , endTime ) ;
return R . ok ( ) . put ( "data" , data ) ;
}
/ * *
* 获取补光灯配置
* /
@RequestMapping ( "/getLigntCfg/{id}" )
public R getLigntCfg ( @PathVariable ( "id" ) Long id ) {
Camera camera = cameraService . getById ( id ) ;
run_device_cfg cfg = new run_device_cfg ( ) ;
NativeLong loginID = new NativeLong ( Long . parseLong ( camera . getLoginId ( ) ) ) ;
Map < String , Object > map = cfg . getLigntCfg ( loginID ) ;
return R . ok ( ) . put ( "data" , map ) ;
}
/ * *
* 修改补光灯配置
* /
@RequestMapping ( "/setLightCfg" )
public R setLightCfg ( @RequestBody Map < String , Object > params ) {
Integer id = ( Integer ) params . get ( "id" ) ;
Integer emMode = Integer . parseInt ( ( String ) params . get ( "emMode" ) ) ;
Integer nPreValue = ( Integer ) params . get ( "nPreValue" ) ;
Integer nBrightness = ( Integer ) params . get ( "nBrightness" ) ;
String startTime1 = ( String ) params . get ( "startTime1" ) ;
String startTime2 = ( String ) params . get ( "startTime2" ) ;
String endTime1 = ( String ) params . get ( "endTime1" ) ;
String endTime2 = ( String ) params . get ( "endTime2" ) ;
Camera camera = cameraService . getById ( id ) ;
run_device_cfg cfg = new run_device_cfg ( ) ;
NativeLong nativeID = new NativeLong ( Long . parseLong ( camera . getLoginId ( ) ) ) ;
boolean flag = cfg . setLightCfg ( nativeID , emMode , nPreValue , nBrightness , startTime1 , endTime1 , startTime2 , endTime2 ) ;
if ( flag ) {
return R . ok ( ) ;
}
return R . error ( ) ;
}
/ * *
* 校准时间
* /
@RequestMapping ( "/setNowTime/{id}" )
public R setNowTime ( @PathVariable ( "id" ) Long id ) {
Camera camera = cameraService . getById ( id ) ;
CameraUtil . setNowTime ( new NativeLong ( Long . parseLong ( camera . getLoginId ( ) ) ) ) ;
return R . ok ( ) ;
}
}