@ -110,161 +110,161 @@ public class CameraController extends BaseController
@@ -110,161 +110,161 @@ public class CameraController 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 ) ;
}
@RequestMapping ( "showVideo/{id}" )
public R showVideo ( HttpServletRequest request , @PathVariable ( "id" ) Long id ) {
//解析ip地址,非服务器ip禁止打开视频
String ip = IPUtils . getIpAddr ( request ) ;
List < String > ipArr = Arrays . asList ( serverIp , "127.0.0.1" ) ;
System . out . println ( "show video ip : " + ip ) ;
if ( ipArr . contains ( ip ) ) {
Camera c = cameraService . getById ( id ) ;
System . out . println ( "show loginID:" + c . getLoginId ( ) ) ;
RegisterUtil window = new RegisterUtil ( ) ;
window . m_frame . setVisible ( true ) ;
window . showVideo ( new NativeLong ( Long . parseLong ( c . getLoginId ( ) ) ) ) ;
return R . ok ( ) ;
}
return R . error ( "请在服务器上查看视频" ) ;
}
/ * *
* 查询摄像头未绑定站点的
* /
@RequestMapping ( "/cameraNoList" )
public R getCameraList ( ) {
return R . ok ( ) . put ( "data" , cameraService . getCameraList ( ) ) ;
}
/ * *
* 根据站点表的id查询摄像头信息
* /
@RequestMapping ( "/cameraBySid/{sid}" )
public R getCameraBySid ( @PathVariable ( "sid" ) Long sid ) {
return R . ok ( ) . put ( "data" , cameraService . getCameraBySid ( sid ) ) ;
}
/ * *
* 刷新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 ( ) ;
}
//
// @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);
// }
//
//
// @RequestMapping("showVideo/{id}")
// public R showVideo(HttpServletRequest request,@PathVariable("id") Long id){
// //解析ip地址,非服务器ip禁止打开视频
// String ip = IPUtils.getIpAddr(request);
// List<String> ipArr = Arrays.asList(serverIp,"127.0.0.1");
// System.out.println("show video ip : " + ip);
// if(ipArr.contains(ip)) {
// Camera c = cameraService.getById(id);
// System.out.println("show loginID:" + c.getLoginId());
// RegisterUtil window = new RegisterUtil();
// window.m_frame.setVisible(true);
// window.showVideo(new NativeLong(Long.parseLong(c.getLoginId())));
// return R.ok();
// }
// return R.error("请在服务器上查看视频");
// }
//
// /**
// * 查询摄像头未绑定站点的
// */
// @RequestMapping("/cameraNoList")
// public R getCameraList(){
// return R.ok().put("data",cameraService.getCameraList());
// }
//
// /**
// * 根据站点表的id查询摄像头信息
// */
// @RequestMapping("/cameraBySid/{sid}")
// public R getCameraBySid(@PathVariable("sid") Long sid) {
// return R.ok().put("data",cameraService.getCameraBySid(sid));
// }
//
// /**
// * 刷新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();
// }
}