Browse Source

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

platform-api
4670101279 2 years ago
parent
commit
b6379a2c8b
  1. 8
      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. 46
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java

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

@ -17,10 +17,10 @@ public class RuoYiApplication
{ {
public static void main(String[] args) public static void main(String[] args)
{ {
// System.setProperty("spring.devtools.restart.enabled", "false"); // System.setProperty("spring.devtools.restart.enabled", "false");
// SpringApplication.run(RuoYiApplication.class, args); SpringApplication.run(RuoYiApplication.class, args);
SpringApplicationBuilder builder = new SpringApplicationBuilder(RuoYiApplication.class); // SpringApplicationBuilder builder = new SpringApplicationBuilder(RuoYiApplication.class);
builder.headless(false).run(args); // builder.headless(false).run(args);
System.out.println("(♥◠‿◠)ノ゙ 启动成功 ლ(´ڡ`ლ)゙ "); 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
return R.ok(); return R.ok();
} }
//
@RequestMapping("register") // @RequestMapping("register")
public R register(){ // public R register(){
return cameraService.register(); // return cameraService.register();
} // }
//
//
@RequestMapping("outLine") // @RequestMapping("outLine")
public R outLine(){ // public R outLine(){
return cameraService.outLine(); // return cameraService.outLine();
} // }
//
@RequestMapping("reboot/{id}") // @RequestMapping("reboot/{id}")
public R reboot(@PathVariable("id") Long id){ // public R reboot(@PathVariable("id") Long id){
Camera c = cameraService.getById(id); // Camera c = cameraService.getById(id);
return cameraService.rebootByLoginId(c); // return cameraService.rebootByLoginId(c);
} // }
//
//
@RequestMapping("showVideo/{id}") // @RequestMapping("showVideo/{id}")
public R showVideo(HttpServletRequest request,@PathVariable("id") Long id){ // public R showVideo(HttpServletRequest request,@PathVariable("id") Long id){
//解析ip地址,非服务器ip禁止打开视频 // //解析ip地址,非服务器ip禁止打开视频
String ip = IPUtils.getIpAddr(request); // String ip = IPUtils.getIpAddr(request);
List<String> ipArr = Arrays.asList(serverIp,"127.0.0.1"); // List<String> ipArr = Arrays.asList(serverIp,"127.0.0.1");
System.out.println("show video ip : " + ip); // System.out.println("show video ip : " + ip);
if(ipArr.contains(ip)) { // if(ipArr.contains(ip)) {
Camera c = cameraService.getById(id); // Camera c = cameraService.getById(id);
System.out.println("show loginID:" + c.getLoginId()); // System.out.println("show loginID:" + c.getLoginId());
RegisterUtil window = new RegisterUtil(); // RegisterUtil window = new RegisterUtil();
window.m_frame.setVisible(true); // window.m_frame.setVisible(true);
window.showVideo(new NativeLong(Long.parseLong(c.getLoginId()))); // window.showVideo(new NativeLong(Long.parseLong(c.getLoginId())));
return R.ok(); // return R.ok();
} // }
return R.error("请在服务器上查看视频"); // return R.error("请在服务器上查看视频");
} // }
//
/** // /**
* 查询摄像头未绑定站点的 // * 查询摄像头未绑定站点的
*/ // */
@RequestMapping("/cameraNoList") // @RequestMapping("/cameraNoList")
public R getCameraList(){ // public R getCameraList(){
return R.ok().put("data",cameraService.getCameraList()); // return R.ok().put("data",cameraService.getCameraList());
} // }
//
/** // /**
* 根据站点表的id查询摄像头信息 // * 根据站点表的id查询摄像头信息
*/ // */
@RequestMapping("/cameraBySid/{sid}") // @RequestMapping("/cameraBySid/{sid}")
public R getCameraBySid(@PathVariable("sid") Long sid) { // public R getCameraBySid(@PathVariable("sid") Long sid) {
return R.ok().put("data",cameraService.getCameraBySid(sid)); // return R.ok().put("data",cameraService.getCameraBySid(sid));
} // }
//
/** // /**
* 刷新4G信号强度 // * 刷新4G信号强度
*/ // */
@RequestMapping("/refreshRssi/{id}") // @RequestMapping("/refreshRssi/{id}")
public R refreshRssiLevel(@PathVariable("id") Long id){ // public R refreshRssiLevel(@PathVariable("id") Long id){
Camera c = cameraService.getById(id); // Camera c = cameraService.getById(id);
if(c.getStatus() == 0 || StringUtils.isBlank(c.getLoginId())){ // if(c.getStatus() == 0 || StringUtils.isBlank(c.getLoginId())){
return R.error("设备未在线"); // return R.error("设备未在线");
} // }
int level = CameraUtil.get4gRssiLevel(new NativeLong(Long.parseLong(c.getLoginId()))); // int level = CameraUtil.get4gRssiLevel(new NativeLong(Long.parseLong(c.getLoginId())));
c.setRssiLevel(level); // c.setRssiLevel(level);
cameraService.updateById(c); // cameraService.updateById(c);
return R.ok(); // return R.ok();
} // }
/** // /**
* 查询摄像头重启数据 // * 查询摄像头重启数据
*/ // */
@RequestMapping("/getautocfg/{id}") // @RequestMapping("/getautocfg/{id}")
public R getAutoCfg(@PathVariable("id") Long id){ // public R getAutoCfg(@PathVariable("id") Long id){
//
int nCommand = NetEnums.EM_DEVICE_CFG_TYPE.DEVICE_CFG_AUTO_MAINTAIN; // int nCommand = NetEnums.EM_DEVICE_CFG_TYPE.DEVICE_CFG_AUTO_MAINTAIN;
Camera camera = cameraService.getById(id); // Camera camera = cameraService.getById(id);
//
run_device_cfg cfg = new run_device_cfg(); // run_device_cfg cfg = new run_device_cfg();
// Object data = JSON.toJSON(cfg.getAutoCfg(new NativeLong(Long.parseLong(camera.getLoginId())),nCommand)).toString(); //// 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); // NetStructs.STU_CFG_AUTO_MAINTAIN cc = cfg.getAutoCfg(new NativeLong(Long.parseLong(camera.getLoginId())),nCommand);
Map<String,Object> data = new HashMap<>(); // Map<String,Object> data = new HashMap<>();
data.put("bEnable",cc.bEnable); // data.put("bEnable",cc.bEnable);
data.put("uWeekDay",cc.uWeekDay); // data.put("uWeekDay",cc.uWeekDay);
data.put("uHour",cc.uHour); // data.put("uHour",cc.uHour);
return R.ok().put("data", data); // return R.ok().put("data", data);
} // }
/** // /**
* 设置摄像头重启 // * 设置摄像头重启
*/ // */
@RequestMapping("/setautocfg") // @RequestMapping("/setautocfg")
public R setAutoCfg(@RequestBody Map<String, Object> params){ // public R setAutoCfg(@RequestBody Map<String, Object> params){
int id = (Integer) params.get("id"); // int id = (Integer) params.get("id");
Camera camera = cameraService.getById(id); // Camera camera = cameraService.getById(id);
//
run_device_cfg cfg = new run_device_cfg(); // run_device_cfg cfg = new run_device_cfg();
return cfg.setAutoFtpCfg(new NativeLong(Long.parseLong(camera.getLoginId())), // return cfg.setAutoFtpCfg(new NativeLong(Long.parseLong(camera.getLoginId())),
Integer.parseInt(params.get("bEnable").toString()), // Integer.parseInt(params.get("bEnable").toString()),
Integer.parseInt(params.get("uHour").toString()), // Integer.parseInt(params.get("uHour").toString()),
Integer.parseInt(params.get("uWeekDay").toString())); // Integer.parseInt(params.get("uWeekDay").toString()));
//
//
} // }
/** // /**
* 获取日志 // * 获取日志
*/ // */
@RequestMapping("/getloginfo") // @RequestMapping("/getloginfo")
public R getloginfo(@RequestParam Map<String, Object> params){ // public R getloginfo(@RequestParam Map<String, Object> params){
//
String id = (String) params.get("id"); // String id = (String) params.get("id");
String startTime = (String) params.get("startTime"); // String startTime = (String) params.get("startTime");
String endTime = (String) params.get("endTime"); // String endTime = (String) params.get("endTime");
//
Camera camera = cameraService.getById(id); // Camera camera = cameraService.getById(id);
//
run_device_log_search logSearch = new run_device_log_search(); // run_device_log_search logSearch = new run_device_log_search();
//
List<LogInfo> data = logSearch.logInfoSearchByTime(new NativeLong(Long.parseLong(camera.getLoginId())), startTime, endTime); // List<LogInfo> data = logSearch.logInfoSearchByTime(new NativeLong(Long.parseLong(camera.getLoginId())), startTime, endTime);
//
return R.ok().put("data",data); // return R.ok().put("data",data);
//
} // }
//
@RequestMapping("/getLigntCfg/{id}") // @RequestMapping("/getLigntCfg/{id}")
public R getLigntCfg(@PathVariable("id") Long id){ // public R getLigntCfg(@PathVariable("id") Long id){
Camera camera = cameraService.getById(id); // Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg(); // run_device_cfg cfg = new run_device_cfg();
NativeLong loginID = new NativeLong(Long.parseLong(camera.getLoginId())); // NativeLong loginID = new NativeLong(Long.parseLong(camera.getLoginId()));
Map<String,Object> map = cfg.getLigntCfg(loginID); // Map<String,Object> map = cfg.getLigntCfg(loginID);
return R.ok().put("data",map); // return R.ok().put("data",map);
} // }
//
@RequestMapping("/setLightCfg") // @RequestMapping("/setLightCfg")
public R setLightCfg(@RequestBody Map<String,Object> params){ // public R setLightCfg(@RequestBody Map<String,Object> params){
Integer id = (Integer) params.get("id"); // Integer id = (Integer) params.get("id");
Integer emMode = Integer.parseInt((String) params.get("emMode")); // Integer emMode = Integer.parseInt((String) params.get("emMode"));
Integer nPreValue = (Integer) params.get("nPreValue"); // Integer nPreValue = (Integer) params.get("nPreValue");
Integer nBrightness = (Integer) params.get("nBrightness"); // Integer nBrightness = (Integer) params.get("nBrightness");
String startTime1 = (String) params.get("startTime1"); // String startTime1 = (String) params.get("startTime1");
String startTime2 = (String) params.get("startTime2"); // String startTime2 = (String) params.get("startTime2");
String endTime1 = (String) params.get("endTime1"); // String endTime1 = (String) params.get("endTime1");
String endTime2 = (String) params.get("endTime2"); // String endTime2 = (String) params.get("endTime2");
//
Camera camera = cameraService.getById(id); // Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg(); // run_device_cfg cfg = new run_device_cfg();
NativeLong nativeID = new NativeLong(Long.parseLong(camera.getLoginId())); // NativeLong nativeID = new NativeLong(Long.parseLong(camera.getLoginId()));
//
boolean flag = cfg.setLightCfg(nativeID, emMode, nPreValue, nBrightness, startTime1, endTime1, startTime2, endTime2); // boolean flag = cfg.setLightCfg(nativeID, emMode, nPreValue, nBrightness, startTime1, endTime1, startTime2, endTime2);
if (flag){ // if (flag){
return R.ok(); // return R.ok();
} // }
return R.error(); // return R.error();
} // }
//
@RequestMapping("/setNowTime/{id}") // @RequestMapping("/setNowTime/{id}")
public R setNowTime(@PathVariable("id")Long id){ // public R setNowTime(@PathVariable("id")Long id){
Camera camera = cameraService.getById(id); // Camera camera = cameraService.getById(id);
CameraUtil.setNowTime(new NativeLong(Long.parseLong(camera.getLoginId()))); // CameraUtil.setNowTime(new NativeLong(Long.parseLong(camera.getLoginId())));
return R.ok(); // 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
return cameraNetFtpService.queryPage(params); return cameraNetFtpService.queryPage(params);
} }
@RequestMapping("/getNetCfg") // @RequestMapping("/getNetCfg")
public R getNetCfg(Long cameraId){ // public R getNetCfg(Long cameraId){
Camera camera = cameraService.getById(cameraId); // Camera camera = cameraService.getById(cameraId);
if(camera.getStatus() == 0){ // if(camera.getStatus() == 0){
return R.error("设备未在线"); // return R.error("设备未在线");
} // }
CameraNetFtp cfg = cameraNetFtpService.getNetCfg(camera); // CameraNetFtp cfg = cameraNetFtpService.getNetCfg(camera);
return R.ok().put("data",cfg); // return R.ok().put("data",cfg);
} // }
//
@RequestMapping("/editNetCfg") // @RequestMapping("/editNetCfg")
public R editNetCfg(@RequestBody CameraNetFtp cameraNetFtp){ // public R editNetCfg(@RequestBody CameraNetFtp cameraNetFtp){
Camera camera = cameraService.getOne(new QueryWrapper<Camera>().eq("devsn",cameraNetFtp.getDevsn()).eq("status","1")); // Camera camera = cameraService.getOne(new QueryWrapper<Camera>().eq("devsn",cameraNetFtp.getDevsn()).eq("status","1"));
if(camera == null){ // if(camera == null){
return R.error("设备未在线"); // return R.error("设备未在线");
} // }
cameraNetFtp.setLoginId(camera.getLoginId()); // cameraNetFtp.setLoginId(camera.getLoginId());
return cameraNetFtpService.editNetCfg(cameraNetFtp); // return cameraNetFtpService.editNetCfg(cameraNetFtp);
} // }
/** /**

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

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

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

@ -19,7 +19,7 @@ import com.ruoyi.quartz.util.ScheduleUtils;
/** /**
* 定时任务调度信息 服务层 * 定时任务调度信息 服务层
* *
* @author ruoyi * @author ruoyi
*/ */
@Service @Service
@ -34,20 +34,20 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 项目启动时初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理不能手动修改数据库ID和任务组名否则会导致脏数据 * 项目启动时初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理不能手动修改数据库ID和任务组名否则会导致脏数据
*/ */
@PostConstruct // @PostConstruct
public void init() throws SchedulerException, TaskException // public void init() throws SchedulerException, TaskException
{ // {
scheduler.clear(); // scheduler.clear();
List<SysJob> jobList = jobMapper.selectJobAll(); // List<SysJob> jobList = jobMapper.selectJobAll();
for (SysJob job : jobList) // for (SysJob job : jobList)
{ // {
ScheduleUtils.createScheduleJob(scheduler, job); // ScheduleUtils.createScheduleJob(scheduler, job);
} // }
} // }
/** /**
* 获取quartz调度器的计划任务列表 * 获取quartz调度器的计划任务列表
* *
* @param job 调度信息 * @param job 调度信息
* @return * @return
*/ */
@ -59,7 +59,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 通过调度任务ID查询调度信息 * 通过调度任务ID查询调度信息
* *
* @param jobId 调度任务ID * @param jobId 调度任务ID
* @return 调度任务对象信息 * @return 调度任务对象信息
*/ */
@ -71,7 +71,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 暂停任务 * 暂停任务
* *
* @param job 调度信息 * @param job 调度信息
*/ */
@Override @Override
@ -91,7 +91,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 恢复任务 * 恢复任务
* *
* @param job 调度信息 * @param job 调度信息
*/ */
@Override @Override
@ -111,7 +111,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 删除任务后所对应的trigger也将被删除 * 删除任务后所对应的trigger也将被删除
* *
* @param job 调度信息 * @param job 调度信息
*/ */
@Override @Override
@ -130,7 +130,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 批量删除调度信息 * 批量删除调度信息
* *
* @param jobIds 需要删除的任务ID * @param jobIds 需要删除的任务ID
* @return 结果 * @return 结果
*/ */
@ -147,7 +147,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 任务调度状态修改 * 任务调度状态修改
* *
* @param job 调度信息 * @param job 调度信息
*/ */
@Override @Override
@ -169,7 +169,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 立即运行任务 * 立即运行任务
* *
* @param job 调度信息 * @param job 调度信息
*/ */
@Override @Override
@ -187,7 +187,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 新增任务 * 新增任务
* *
* @param job 调度信息 调度信息 * @param job 调度信息 调度信息
*/ */
@Override @Override
@ -205,7 +205,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 更新任务的时间表达式 * 更新任务的时间表达式
* *
* @param job 调度信息 * @param job 调度信息
*/ */
@Override @Override
@ -223,7 +223,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 更新任务 * 更新任务
* *
* @param job 任务对象 * @param job 任务对象
* @param jobGroup 任务组名 * @param jobGroup 任务组名
*/ */
@ -242,7 +242,7 @@ public class SysJobServiceImpl implements ISysJobService
/** /**
* 校验cron表达式是否有效 * 校验cron表达式是否有效
* *
* @param cronExpression 表达式 * @param cronExpression 表达式
* @return 结果 * @return 结果
*/ */

Loading…
Cancel
Save