blankk 2 years ago
parent
commit
2df9792c66
  1. 18
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java
  2. 3
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraNetFtpController.java
  3. 3
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/Camera.java
  4. 33
      ruoyi-code/src/main/java/utils/CameraUtil.java
  5. 4
      ruoyi-code/src/main/resources/mapper/camera/WaterPhotoInfoMapper.xml
  6. 6
      ruoyi-quartz/pom.xml
  7. 23
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java

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

@ -119,7 +119,7 @@ public class CameraController extends BaseController
} }
@RequestMapping("reboot/{id}") @RequestMapping("reboot/{id}")
public R reboot(@PathVariable Long id){ public R reboot(@PathVariable("id") Long id){
Camera c = cameraService.getById(id); Camera c = cameraService.getById(id);
if(StringUtils.isNotBlank(c.getLoginId())) { if(StringUtils.isNotBlank(c.getLoginId())) {
System.out.println("reboot loginID:"+c.getLoginId()); System.out.println("reboot loginID:"+c.getLoginId());
@ -137,7 +137,7 @@ public class CameraController extends BaseController
@RequestMapping("showVideo/{id}") @RequestMapping("showVideo/{id}")
public R showVideo(HttpServletRequest request,@PathVariable 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");
@ -169,4 +169,18 @@ public class CameraController extends BaseController
return R.ok().put("data",cameraService.getCameraBySid(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();
}
} }

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

@ -54,6 +54,9 @@ public class CameraNetFtpController extends BaseController
@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){
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);
} }

3
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/Camera.java

@ -48,6 +48,9 @@ public class Camera implements Serializable
/** 状态 */ /** 状态 */
private Integer status; private Integer status;
/** 4g信号强度 */
private Integer rssiLevel;
private String loginId; private String loginId;
/** 首次注册时间 */ /** 首次注册时间 */

33
ruoyi-code/src/main/java/utils/CameraUtil.java

@ -1,5 +1,6 @@
package utils; package utils;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.sun.jna.NativeLong; import com.sun.jna.NativeLong;
import com.sun.jna.ptr.IntByReference; import com.sun.jna.ptr.IntByReference;
@ -12,13 +13,23 @@ import java.util.Date;
public class CameraUtil { public class CameraUtil {
public static void main(String[] args) { public static void main(String[] args) {
// NetLib.instance.Net_Init(null, null); NetLib.instance.Net_Init(null, null);
run_device_cfg cfg = new run_device_cfg(); String strIp="192.168.1.64";
cfg.startCfg(); int nPort= 27778;
String strUsername="admin";
String strPassword="admin123";
String strDevSN="8R23R300003";
IntByReference nError = new IntByReference(0);
NativeLong loginID = NetLib.instance.Net_LoginDevice(strIp, nPort, strUsername, strPassword, null, nError);
System.out.println("loginID = "+loginID);
} }
/**
* 重启设备
*/
public static boolean deal(NativeLong loginID){ public static boolean deal(NativeLong loginID){
boolean res = NetLib.instance.Net_RebootDevice(loginID); boolean res = NetLib.instance.Net_RebootDevice(loginID);
int error = NetLib.instance.Net_LastError(); int error = NetLib.instance.Net_LastError();
@ -26,6 +37,22 @@ public class CameraUtil {
return res; return res;
} }
/**
* 获取4G信号强度
*/
public static int get4gRssiLevel(NativeLong loginID){
NetStructs.STU_GET_4G_RSSI_IN_PARAM.ByReference pstInParam = new NetStructs.STU_GET_4G_RSSI_IN_PARAM.ByReference();
NetStructs.STU_GET_4G_RSSI_OUT_PARAM.ByReference pstOutParam = new NetStructs.STU_GET_4G_RSSI_OUT_PARAM.ByReference();
boolean res = NetLib.instance.Net_GetDevice4GRSSI(loginID,pstInParam, pstOutParam,6000);
int level = 0;
if(res){
// System.out.println(JSON.toJSONString(pstOutParam));
// System.out.println("4G信号强度:"+pstOutParam.nRssiLevel);
level = pstOutParam.nRssiLevel;
}
return level;
}
private static void sleep(int nTime) private static void sleep(int nTime)
{ {
try { try {

4
ruoyi-code/src/main/resources/mapper/camera/WaterPhotoInfoMapper.xml

@ -14,11 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="params.stnm !=null and params.stnm !=''">and s.stnm like concat('%',#{params.stnm},'%')</if> <if test="params.stnm !=null and params.stnm !=''">and s.stnm like concat('%',#{params.stnm},'%')</if>
<if test="params.stcd !=null and params.stcd !=''">and c.name like concat('%',#{params.name},'%')</if> <if test="params.stcd !=null and params.stcd !=''">and c.name like concat('%',#{params.stcd},'%')</if>
<if test="params.startTime != null and params.startTime !=''"> and w.tm &gt;= #{params.startTime }</if> <if test="params.startTime != null and params.startTime !=''"> and w.tm &gt;= #{params.startTime }</if>
<if test="params.endTime != null and params.endTime !=''"> and w.tm &lt;= #{params.endTime}</if> <if test="params.endTime != null and params.endTime !=''"> and w.tm &lt;= #{params.endTime}</if>
</where> </where>
order by w.tm desc
</select> </select>
<select id="selectWaterCurrentDataList" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo"> <select id="selectWaterCurrentDataList" resultType="com.ruoyi.code.camera.domain.WaterPhotoInfo">
select select

6
ruoyi-quartz/pom.xml

@ -35,6 +35,12 @@
<artifactId>ruoyi-common</artifactId> <artifactId>ruoyi-common</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-api</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

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

@ -1,16 +1,26 @@
package com.ruoyi.quartz.task; package com.ruoyi.quartz.task;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.code.camera.domain.Camera;
import com.ruoyi.code.camera.service.ICameraService;
import com.sun.jna.NativeLong;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import utils.CameraUtil;
import java.util.List;
/** /**
* 定时任务调度测试 * 定时任务调度测试
* *
* @author ruoyi * @author ruoyi
*/ */
@Component("ryTask") @Component("ryTask")
public class RyTask public class RyTask
{ {
private ICameraService cameraService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
{ {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
@ -25,4 +35,15 @@ public class RyTask
{ {
System.out.println("执行无参方法"); System.out.println("执行无参方法");
} }
public void netRssiServer(){
List<Camera> list = cameraService.list(new QueryWrapper<Camera>().eq("status","1").isNotNull("login_id"));
for (Camera c : list) {
int level = CameraUtil.get4gRssiLevel(new NativeLong(Long.parseLong(c.getLoginId())));
c.setRssiLevel(level);
}
cameraService.updateBatchById(list);
}
} }

Loading…
Cancel
Save