From b6379a2c8bbf1c93a1c19ce98038872d45153a70 Mon Sep 17 00:00:00 2001 From: 4670101279 Date: Thu, 4 Aug 2022 12:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=94=AF-=E5=88=86=E7=A6=BB=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=92=8C=E6=91=84=E5=83=8F=E6=9C=BA=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/RuoYiApplication.java | 8 +- .../camera/controller/CameraController.java | 314 +++++++++--------- .../controller/CameraNetFtpController.java | 38 +-- .../code/camera/scheduled/RegisterServer.java | 120 +++---- .../service/impl/SysJobServiceImpl.java | 46 +-- 5 files changed, 263 insertions(+), 263 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java index 0eebb7d..5368468 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java @@ -17,10 +17,10 @@ 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); +// System.setProperty("spring.devtools.restart.enabled", "false"); + SpringApplication.run(RuoYiApplication.class, args); +// SpringApplicationBuilder builder = new SpringApplicationBuilder(RuoYiApplication.class); +// builder.headless(false).run(args); System.out.println("(♥◠‿◠)ノ゙ 启动成功 ლ(´ڡ`ლ)゙ "); } diff --git a/ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java b/ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java index 2182f91..e5ebadf 100644 --- a/ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java +++ b/ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java @@ -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 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 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 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 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 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 map = cfg.getLigntCfg(loginID); - return R.ok().put("data",map); - } - - @RequestMapping("/setLightCfg") - public R setLightCfg(@RequestBody Map 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 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 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 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 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 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 map = cfg.getLigntCfg(loginID); +// return R.ok().put("data",map); +// } +// +// @RequestMapping("/setLightCfg") +// public R setLightCfg(@RequestBody Map 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(); +// } } diff --git a/ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraNetFtpController.java b/ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraNetFtpController.java index 276b51d..915ab77 100644 --- a/ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraNetFtpController.java +++ b/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); } - @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().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().eq("devsn",cameraNetFtp.getDevsn()).eq("status","1")); +// if(camera == null){ +// return R.error("设备未在线"); +// } +// cameraNetFtp.setLoginId(camera.getLoginId()); +// return cameraNetFtpService.editNetCfg(cameraNetFtp); +// } /** diff --git a/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java b/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java index 1666421..8a20510 100644 --- a/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java +++ b/ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java @@ -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("主动注册服务启动失败"); +// } +// } +// } +// +//} diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java index 0d9a53d..eb39768 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java @@ -19,7 +19,7 @@ import com.ruoyi.quartz.util.ScheduleUtils; /** * 定时任务调度信息 服务层 - * + * * @author ruoyi */ @Service @@ -34,20 +34,20 @@ public class SysJobServiceImpl implements ISysJobService /** * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据) */ - @PostConstruct - public void init() throws SchedulerException, TaskException - { - scheduler.clear(); - List jobList = jobMapper.selectJobAll(); - for (SysJob job : jobList) - { - ScheduleUtils.createScheduleJob(scheduler, job); - } - } +// @PostConstruct +// public void init() throws SchedulerException, TaskException +// { +// scheduler.clear(); +// List jobList = jobMapper.selectJobAll(); +// for (SysJob job : jobList) +// { +// ScheduleUtils.createScheduleJob(scheduler, job); +// } +// } /** * 获取quartz调度器的计划任务列表 - * + * * @param job 调度信息 * @return */ @@ -59,7 +59,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 通过调度任务ID查询调度信息 - * + * * @param jobId 调度任务ID * @return 调度任务对象信息 */ @@ -71,7 +71,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 暂停任务 - * + * * @param job 调度信息 */ @Override @@ -91,7 +91,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 恢复任务 - * + * * @param job 调度信息 */ @Override @@ -111,7 +111,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 删除任务后,所对应的trigger也将被删除 - * + * * @param job 调度信息 */ @Override @@ -130,7 +130,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 批量删除调度信息 - * + * * @param jobIds 需要删除的任务ID * @return 结果 */ @@ -147,7 +147,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 任务调度状态修改 - * + * * @param job 调度信息 */ @Override @@ -169,7 +169,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 立即运行任务 - * + * * @param job 调度信息 */ @Override @@ -187,7 +187,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 新增任务 - * + * * @param job 调度信息 调度信息 */ @Override @@ -205,7 +205,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 更新任务的时间表达式 - * + * * @param job 调度信息 */ @Override @@ -223,7 +223,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 更新任务 - * + * * @param job 任务对象 * @param jobGroup 任务组名 */ @@ -242,7 +242,7 @@ public class SysJobServiceImpl implements ISysJobService /** * 校验cron表达式是否有效 - * + * * @param cronExpression 表达式 * @return 结果 */