Browse Source

分支-分离平台和摄像机控制程序

platform-api
4670101279 2 years ago
parent
commit
b6379a2c8b
  1. 6
      ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
  2. 314
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java
  3. 38
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraNetFtpController.java
  4. 120
      ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java
  5. 20
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java

6
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java

@ -18,9 +18,9 @@ public class RuoYiApplication @@ -18,9 +18,9 @@ public class RuoYiApplication
public static void main(String[] args)
{
// System.setProperty("spring.devtools.restart.enabled", "false");
// SpringApplication.run(RuoYiApplication.class, args);
SpringApplicationBuilder builder = new SpringApplicationBuilder(RuoYiApplication.class);
builder.headless(false).run(args);
SpringApplication.run(RuoYiApplication.class, args);
// SpringApplicationBuilder builder = new SpringApplicationBuilder(RuoYiApplication.class);
// builder.headless(false).run(args);
System.out.println("(♥◠‿◠)ノ゙ 启动成功 ლ(´ڡ`ლ)゙ ");
}

314
ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java

@ -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();
// }
}

38
ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraNetFtpController.java

@ -51,25 +51,25 @@ public class CameraNetFtpController extends BaseController @@ -51,25 +51,25 @@ public class CameraNetFtpController extends BaseController
return cameraNetFtpService.queryPage(params);
}
@RequestMapping("/getNetCfg")
public R getNetCfg(Long cameraId){
Camera camera = cameraService.getById(cameraId);
if(camera.getStatus() == 0){
return R.error("设备未在线");
}
CameraNetFtp cfg = cameraNetFtpService.getNetCfg(camera);
return R.ok().put("data",cfg);
}
@RequestMapping("/editNetCfg")
public R editNetCfg(@RequestBody CameraNetFtp cameraNetFtp){
Camera camera = cameraService.getOne(new QueryWrapper<Camera>().eq("devsn",cameraNetFtp.getDevsn()).eq("status","1"));
if(camera == null){
return R.error("设备未在线");
}
cameraNetFtp.setLoginId(camera.getLoginId());
return cameraNetFtpService.editNetCfg(cameraNetFtp);
}
// @RequestMapping("/getNetCfg")
// public R getNetCfg(Long cameraId){
// Camera camera = cameraService.getById(cameraId);
// if(camera.getStatus() == 0){
// return R.error("设备未在线");
// }
// CameraNetFtp cfg = cameraNetFtpService.getNetCfg(camera);
// return R.ok().put("data",cfg);
// }
//
// @RequestMapping("/editNetCfg")
// public R editNetCfg(@RequestBody CameraNetFtp cameraNetFtp){
// Camera camera = cameraService.getOne(new QueryWrapper<Camera>().eq("devsn",cameraNetFtp.getDevsn()).eq("status","1"));
// if(camera == null){
// return R.error("设备未在线");
// }
// cameraNetFtp.setLoginId(camera.getLoginId());
// return cameraNetFtpService.editNetCfg(cameraNetFtp);
// }
/**

120
ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java

@ -1,60 +1,60 @@ @@ -1,60 +1,60 @@
package com.ruoyi.code.camera.scheduled;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.code.camera.domain.Camera;
import com.ruoyi.code.camera.service.ICameraService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.IPUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
/*@Author: tongw
*@CreateDate: 2020/8/11 8:58
*@Description:
**/
@Component
@Configuration
@EnableScheduling
public class RegisterServer {
private static String sercer_ip = "";
@Autowired
private Environment env;
@PostConstruct
public void config() {
sercer_ip = env.getProperty("localip");
}
@Autowired
private ICameraService cameraService;
@Scheduled(initialDelay = 5000, fixedRate = Long.MAX_VALUE)
public void synStart(){
start();
}
private void start(){
String ip = IPUtils.getLocalIpAddress();
if(sercer_ip.equals(ip)){
R result = cameraService.register();
if("0".equals(result.get("code").toString())){
System.out.println("主动注册服务已启动");
}else{
System.out.println("主动注册服务启动失败");
}
}
}
}
//package com.ruoyi.code.camera.scheduled;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.ruoyi.code.camera.domain.Camera;
//import com.ruoyi.code.camera.service.ICameraService;
//import com.ruoyi.common.core.page.R;
//import com.ruoyi.common.utils.IPUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.env.Environment;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.PostConstruct;
//import java.util.ArrayList;
//import java.util.List;
//
///*@Author: tongw
// *@CreateDate: 2020/8/11 8:58
// *@Description:
// **/
//
//@Component
//@Configuration
//@EnableScheduling
//public class RegisterServer {
// private static String sercer_ip = "";
//
// @Autowired
// private Environment env;
//
// @PostConstruct
// public void config() {
// sercer_ip = env.getProperty("localip");
// }
// @Autowired
// private ICameraService cameraService;
//
// @Scheduled(initialDelay = 5000, fixedRate = Long.MAX_VALUE)
// public void synStart(){
// start();
// }
//
// private void start(){
// String ip = IPUtils.getLocalIpAddress();
// if(sercer_ip.equals(ip)){
// R result = cameraService.register();
// if("0".equals(result.get("code").toString())){
// System.out.println("主动注册服务已启动");
// }else{
// System.out.println("主动注册服务启动失败");
// }
// }
// }
//
//}

20
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java

@ -34,16 +34,16 @@ public class SysJobServiceImpl implements ISysJobService @@ -34,16 +34,16 @@ public class SysJobServiceImpl implements ISysJobService
/**
* 项目启动时初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理不能手动修改数据库ID和任务组名否则会导致脏数据
*/
@PostConstruct
public void init() throws SchedulerException, TaskException
{
scheduler.clear();
List<SysJob> jobList = jobMapper.selectJobAll();
for (SysJob job : jobList)
{
ScheduleUtils.createScheduleJob(scheduler, job);
}
}
// @PostConstruct
// public void init() throws SchedulerException, TaskException
// {
// scheduler.clear();
// List<SysJob> jobList = jobMapper.selectJobAll();
// for (SysJob job : jobList)
// {
// ScheduleUtils.createScheduleJob(scheduler, job);
// }
// }
/**
* 获取quartz调度器的计划任务列表

Loading…
Cancel
Save