Browse Source

youhua

master
4670101279 2 years ago
parent
commit
999d9a4467
  1. 4
      ruoyi-admin/src/main/resources/application.yml
  2. 7
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/ApiController.java
  3. 9
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java
  4. 2
      ruoyi-code/src/main/java/com/ruoyi/code/camera/scheduled/RegisterServer.java
  5. 4
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/ICameraService.java
  6. 13
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/CameraServiceImpl.java
  7. 14
      ruoyi-code/src/main/java/utils/RegisterUtil.java
  8. 14
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java

4
ruoyi-admin/src/main/resources/application.yml

@ -129,5 +129,7 @@ xss: @@ -129,5 +129,7 @@ xss:
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
localip: 172.16.46.58
#服务器ip
localip: 192.168.1.7
#公网ip,用于判断视频播放
serverip: 121.40.203.197

7
ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/ApiController.java

@ -13,6 +13,7 @@ import com.ruoyi.common.enums.BusinessType; @@ -13,6 +13,7 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.sun.jna.NativeLong;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import sdk.java.lib.netmanager.NetEnums;
@ -36,6 +37,8 @@ import java.util.*; @@ -36,6 +37,8 @@ import java.util.*;
@RequestMapping("/api")
public class ApiController extends BaseController
{
@Value("${localip}")
private String localIp;
@Resource
private ICameraService cameraService;
@Resource
@ -60,7 +63,7 @@ public class ApiController extends BaseController @@ -60,7 +63,7 @@ public class ApiController extends BaseController
*/
@RequestMapping("register")
public R register(){
return cameraService.register();
return cameraService.register(localIp);
}
/**
@ -68,7 +71,7 @@ public class ApiController extends BaseController @@ -68,7 +71,7 @@ public class ApiController extends BaseController
*/
@RequestMapping("outLine")
public R outLine(){
return cameraService.outLine();
return cameraService.outLine(localIp);
}
/**

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

@ -42,6 +42,9 @@ public class CameraController extends BaseController @@ -42,6 +42,9 @@ public class CameraController extends BaseController
@Value("${serverip}")
private String serverIp;
@Value("${localip}")
private String localIp;
/**
* 查询列表
*/
@ -111,13 +114,13 @@ public class CameraController extends BaseController @@ -111,13 +114,13 @@ public class CameraController extends BaseController
@RequestMapping("register")
public R register(){
return cameraService.register();
return cameraService.register(localIp);
}
@RequestMapping("outLine")
public R outLine(){
return cameraService.outLine();
return cameraService.outLine(localIp);
}
@RequestMapping("reboot/{id}")
@ -136,7 +139,7 @@ public class CameraController extends BaseController @@ -136,7 +139,7 @@ public class CameraController extends BaseController
if(ipArr.contains(ip)) {
Camera c = cameraService.getById(id);
System.out.println("show loginID:" + c.getLoginId());
RegisterUtil window = new RegisterUtil();
RegisterUtil window = new RegisterUtil(localIp);
window.m_frame.setVisible(true);
window.showVideo(new NativeLong(Long.parseLong(c.getLoginId())));
return R.ok();

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

@ -49,7 +49,7 @@ public class RegisterServer { @@ -49,7 +49,7 @@ public class RegisterServer {
String ip = IPUtils.getLocalIpAddress();
System.out.println(ip);
if(sercer_ip.equals(ip)){
R result = cameraService.register();
R result = cameraService.register(sercer_ip);
if("0".equals(result.get("code").toString())){
System.out.println("主动注册服务已启动");
}else{

4
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/ICameraService.java

@ -20,11 +20,11 @@ public interface ICameraService extends IService<Camera> @@ -20,11 +20,11 @@ public interface ICameraService extends IService<Camera>
*/
R queryPage(Map<String, Object> params);
R register();
R register(String localIp);
R rebootByLoginId(Camera c);
R outLine();
R outLine(String localIp);
void online(String ip,int port,String username,String password,String devsn,String loginID);

13
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/CameraServiceImpl.java

@ -28,6 +28,7 @@ import java.util.Map; @@ -28,6 +28,7 @@ import java.util.Map;
@Service("cameraService")
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService
{
@Override
public R queryPage(Map<String, Object> params) {
IPage<Camera> page = baseMapper.queryPage(
@ -40,11 +41,11 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> impleme @@ -40,11 +41,11 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> impleme
}
@Override
public R register(){
public R register(String localIp){
//清空所有摄像机状态
List<Camera> list = list();
RegisterUtil window = new RegisterUtil();
RegisterUtil window = new RegisterUtil(localIp);
for (Camera c : list) {
if(StringUtils.isNotBlank(c.getLoginId())){
@ -55,9 +56,9 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> impleme @@ -55,9 +56,9 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> impleme
}
}
updateBatchById(list);
//先停
// //先停
window.onBtnStopRegServer();
//再开
// //再开
boolean result = window.onBtnStartRegServer();
if(result){
return R.ok("服务启动成功,请等待几分钟后重新使用");
@ -82,10 +83,10 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> impleme @@ -82,10 +83,10 @@ public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> impleme
}
@Override
public R outLine(){
public R outLine(String localIp){
//清空所有摄像机状态
List<Camera> list = list();
RegisterUtil window = new RegisterUtil();
RegisterUtil window = new RegisterUtil(localIp);
for (Camera c : list) {
if(StringUtils.isNotBlank(c.getLoginId())){
window.logout(new NativeLong(Long.parseLong(c.getLoginId())));

14
ruoyi-code/src/main/java/utils/RegisterUtil.java

@ -15,6 +15,8 @@ import com.sun.jna.Structure; @@ -15,6 +15,8 @@ import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import sdk.java.common.GlobalTool;
import sdk.java.lib.DataUtils;
@ -57,10 +59,7 @@ import java.util.*; @@ -57,10 +59,7 @@ import java.util.*;
/////////////////////////////////////////////////////////////////////////////////////////////////////
@Component
public class RegisterUtil implements ActionListener {
//linux服务器
// private String m_jtfServerIP = "192.168.1.219";
//公司windows服务器
private String m_jtfServerIP = "172.16.46.58";
private String m_jtfServerIP = "";
private String m_jtfServerPort = "8020";
private String m_jtfDevUsername = "admin";
private String m_jtfDevPassword = "admin123";
@ -127,9 +126,10 @@ public class RegisterUtil implements ActionListener { @@ -127,9 +126,10 @@ public class RegisterUtil implements ActionListener {
/**
* Create the application.
*/
public RegisterUtil()
public RegisterUtil(String m_jtfServerIP)
{
this.m_jtfServerIP = m_jtfServerIP;
System.out.println("this.m_jtfServerIP="+this.m_jtfServerIP);
String os = System.getProperty("os.name");
if(os.toLowerCase().startsWith("win")){
initialize();
@ -1096,7 +1096,7 @@ public class RegisterUtil implements ActionListener { @@ -1096,7 +1096,7 @@ public class RegisterUtil implements ActionListener {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
RegisterUtil window = new RegisterUtil();
RegisterUtil window = new RegisterUtil("");
window.m_frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();

14
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java

@ -10,10 +10,13 @@ import com.ruoyi.code.camera.service.IScImageUploadAlarmService; @@ -10,10 +10,13 @@ import com.ruoyi.code.camera.service.IScImageUploadAlarmService;
import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.BeanUtil;
import com.sun.jna.NativeLong;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;
import utils.CameraUtil;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.List;
@ -25,6 +28,14 @@ import java.util.List; @@ -25,6 +28,14 @@ import java.util.List;
@Component("ryTask")
public class RyTask
{
private static String sercer_ip = "";
@Autowired
private Environment env;
@PostConstruct
public void config() {
sercer_ip = env.getProperty("localip");
}
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{
@ -75,10 +86,11 @@ public class RyTask @@ -75,10 +86,11 @@ public class RyTask
//重启注册服务
public void restartServer(){
System.out.println("sercer_ip="+sercer_ip);
ICameraService cameraService = BeanUtil.getBean(ICameraService.class);
List<Camera> list = cameraService.list(new QueryWrapper<Camera>().eq("status","1").ne("login_id","").isNotNull("login_id"));
if(list.isEmpty()){
cameraService.register();
cameraService.register(sercer_ip);
}
}

Loading…
Cancel
Save