Compare commits

...

3 Commits

  1. 99
      README.md
  2. 8
      ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
  3. 314
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java
  4. 38
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraNetFtpController.java
  5. 120
      ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java
  6. 20
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java

99
README.md

@ -1,97 +1,2 @@
<p align="center"> 程序运行需要将本地jar包安装到maven仓库
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png"> mvn install:install-file -Dfile=lib/jna.jar -DgroupId=com.sun -DartifactId=jna -Dversion=1.0 -Dpackaging=jar
</p>
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.8.2</h1>
<h4 align="center">基于SpringBoot+Vue前后端分离的Java快速开发框架</h4>
<p align="center">
<a href="https://gitee.com/y_project/RuoYi-Vue/stargazers"><img src="https://gitee.com/y_project/RuoYi-Vue/badge/star.svg?theme=dark"></a>
<a href="https://gitee.com/y_project/RuoYi-Vue"><img src="https://img.shields.io/badge/RuoYi-v3.8.2-brightgreen.svg"></a>
<a href="https://gitee.com/y_project/RuoYi-Vue/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
</p>
## 平台简介
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
* 前端采用Vue、Element UI。
* 后端采用Spring Boot、Spring Security、Redis & Jwt。
* 权限认证使用Jwt,支持多终端认证系统。
* 支持加载动态权限菜单,多方式轻松权限控制。
* 高效率开发,使用代码生成器可以一键生成前后端代码。
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Vue3](https://github.com/yangzongzhuan/RuoYi-Vue3),保持同步更新。
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast),Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
* 特别鸣谢:[element](https://github.com/ElemeFE/element),[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin),[eladmin-web](https://github.com/elunez/eladmin-web)。
* 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)&nbsp;&nbsp;
* 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)&nbsp;&nbsp;
## 内置功能
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
3. 岗位管理:配置系统用户所属担任职务。
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
7. 参数管理:对系统动态配置常用参数。
8. 通知公告:系统通知公告信息发布维护。
9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
10. 登录日志:系统登录日志记录查询包含登录异常。
11. 在线用户:当前系统中活跃用户状态监控。
12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。
13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。
14. 系统接口:根据业务代码自动生成相关的api接口文档。
15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。
16. 缓存监控:对系统的缓存信息查询,命令统计等。
17. 在线构建器:拖动表单元素生成相应的HTML代码。
18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。
## 在线体验
- admin/admin123
- 陆陆续续收到一些打赏,为了更好的体验已用于演示服务器升级。谢谢各位小伙伴。
演示地址:http://vue.ruoyi.vip
文档地址:http://doc.ruoyi.vip
## 演示图
<table>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/cd1f90be5f2684f4560c9519c0f2a232ee8.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/1cbcf0e6f257c7d3a063c0e3f2ff989e4b3.jpg"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-8074972883b5ba0622e13246738ebba237a.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-9f88719cdfca9af2e58b352a20e23d43b12.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-39bf2584ec3a529b0d5a3b70d15c9b37646.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-936ec82d1f4872e1bc980927654b6007307.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-b2d62ceb95d2dd9b3fbe157bb70d26001e9.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-d67451d308b7a79ad6819723396f7c3d77a.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/5e8c387724954459291aafd5eb52b456f53.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/644e78da53c2e92a95dfda4f76e6d117c4b.jpg"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-8370a0d02977eebf6dbf854c8450293c937.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-49003ed83f60f633e7153609a53a2b644f7.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/up-d4fe726319ece268d4746602c39cffc0621.png"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-c195234bbcd30be6927f037a6755e6ab69c.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-5e4daac0bb59612c5038448acbcef235e3a.png"/></td>
</tr>
</table>
## 若依前后端分离交流群
QQ群: [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/已满-104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) [![加入QQ群](https://img.shields.io/badge/已满-186866453-blue.svg)](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [![加入QQ群](https://img.shields.io/badge/已满-201396349-blue.svg)](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [![加入QQ群](https://img.shields.io/badge/已满-101456076-blue.svg)](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [![加入QQ群](https://img.shields.io/badge/已满-101539465-blue.svg)](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [![加入QQ群](https://img.shields.io/badge/已满-264312783-blue.svg)](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [![加入QQ群](https://img.shields.io/badge/167385320-blue.svg)](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) 点击按钮入群。

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("主动注册服务启动失败");
} // }
} // }
} // }
//
} //}

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

@ -34,16 +34,16 @@ 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调度器的计划任务列表

Loading…
Cancel
Save