Compare commits

..

2 Commits

  1. 53
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java
  2. 12
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/LogInfo.java
  3. 20
      ruoyi-code/src/main/java/utils/run_device_cfg.java
  4. 9
      ruoyi-code/src/main/java/utils/run_device_log_search.java

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

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
package com.ruoyi.code.camera.controller;
import com.alibaba.fastjson.JSON;
import com.ruoyi.code.camera.domain.LogInfo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.R;
@ -16,6 +18,7 @@ import org.springframework.security.access.prepost.PreAuthorize; @@ -16,6 +18,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import sdk.java.lib.netmanager.NetEnums;
import sdk.java.lib.netmanager.NetLib;
import sdk.java.lib.netmanager.NetStructs;
import utils.CameraUtil;
import utils.RegisterUtil;
import utils.run_device_cfg;
@ -25,6 +28,7 @@ import javax.annotation.Resource; @@ -25,6 +28,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -60,7 +64,6 @@ public class CameraController extends BaseController @@ -60,7 +64,6 @@ public class CameraController extends BaseController
@PreAuthorize("@ss.hasPermi('web:camera:query')")
public R info(@PathVariable("id") Long id){
Camera camera = cameraService.getById(id);
return R.ok().put("data", camera);
}
@ -184,44 +187,50 @@ public class CameraController extends BaseController @@ -184,44 +187,50 @@ public class CameraController extends BaseController
public R getAutoCfg(@PathVariable("id") Long id){
int nCommand = NetEnums.EM_DEVICE_CFG_TYPE.DEVICE_CFG_AUTO_MAINTAIN;
Camera camera = cameraService.getCameraBySid(id);
IntByReference nError = new IntByReference(0);
NativeLong loginID = NetLib.instance.Net_LoginDevice(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), null,nError);
Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg();
cfg.getAutoCfg(loginID,nCommand);
return R.ok();
// 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<String,Object> 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(@RequestParam Map<String, Object> params){
Camera camera = cameraService.getCameraBySid((Long) params.get("sid"));
IntByReference nError = new IntByReference(0);
NativeLong loginID = NetLib.instance.Net_LoginDevice(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), null,nError);
@RequestMapping("/setautocfg")
public R setAutoCfg(@RequestBody Map<String, Object> params){
String id = (String) params.get("id");
Camera camera = cameraService.getById(id);
run_device_cfg cfg = new run_device_cfg();
cfg.setAutoFtpCfg(loginID,(int)params.get("benable"),(int)params.get("uHour"),(int)params.get("uWeekDay"));
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()));
return R.ok();
}
/**
* 获取日志
*/
@RequestMapping("/getloginfo/")
@RequestMapping("/getloginfo")
public R getloginfo(@RequestParam Map<String, Object> params){
Camera camera = cameraService.getCameraBySid((Long) params.get("sid"));
IntByReference nError = new IntByReference(0);
NativeLong loginID = NetLib.instance.Net_LoginDevice(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), null,nError);
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();
logSearch.logInfoSearchByTime(loginID,(String) params.get("strStartTime"),(String) params.get("strEndTime"));
return R.ok();
List<LogInfo> data = logSearch.logInfoSearchByTime(new NativeLong(Long.parseLong(camera.getLoginId())), startTime, endTime);
System.out.println(data);
return R.ok().put("data",data);
}
}

12
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/LogInfo.java

@ -37,4 +37,16 @@ public class LogInfo implements Serializable{ @@ -37,4 +37,16 @@ public class LogInfo implements Serializable{
/** 客户端类型 */
private String cClientType;
public LogInfo(String cLogTime,String cOperUserName,String cMainType,String cSubType,String cRemoteIP,String cClientType){
this.cLogTime=cLogTime;
this.cOperUserName=cOperUserName;
this.cMainType=cMainType;
this.cSubType=cSubType;
this.cRemoteIP=cRemoteIP;
this.cClientType=cClientType;
}
public LogInfo(){
}
}

20
ruoyi-code/src/main/java/utils/run_device_cfg.java

@ -29,6 +29,7 @@ import javax.swing.table.TableColumn; @@ -29,6 +29,7 @@ import javax.swing.table.TableColumn;
import com.alibaba.fastjson.JSON;
import com.ruoyi.code.camera.domain.Camera;
import com.ruoyi.code.camera.domain.CameraNetFtp;
import com.ruoyi.common.core.page.R;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
@ -3724,8 +3725,9 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { @@ -3724,8 +3725,9 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
6000);
STU_CFG_AUTO_MAINTAIN stuCfgAutoMaintain = new STU_CFG_AUTO_MAINTAIN();
DataUtils.sdk_data_ptrToStructure(ptrOutBuffer, stuCfgAutoMaintain);
System.out.println(stuCfgAutoMaintain);
return stuCfgAutoMaintain;
}
@ -3738,7 +3740,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { @@ -3738,7 +3740,7 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
* @param uWeekDay 周几重启
* @return
*/
public STU_CFG_AUTO_MAINTAIN setAutoFtpCfg(NativeLong loginID, int bEnable,int uHour,int uWeekDay){
public R setAutoFtpCfg(NativeLong loginID, int bEnable,int uHour,int uWeekDay){
@ -3753,16 +3755,17 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { @@ -3753,16 +3755,17 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
stuCfgAutoMaintain.uHour=uHour;
stuCfgAutoMaintain.uWeekDay=uWeekDay;
System.out.println(JSON.toJSON(stuCfgAutoMaintain));
inBufferSize.setValue(stuCfgAutoMaintain.size());
Pointer ptrInBuffer = DataUtils.sdk_data_createPtr(inBufferSize.getValue());
DataUtils.sdk_data_structureToPtr(stuCfgAutoMaintain, ptrInBuffer, 0);
if(null == ptrInBuffer)
return null;
if(null == ptrInBuffer) {
System.out.println(ptrInBuffer);
return R.error();
}
boolean bResult2 = NetLib.instance.Net_SetDeviceCfg(
loginID,
nCommand,
@ -3775,9 +3778,10 @@ public class run_device_cfg implements ActionListener, ListSelectionListener { @@ -3775,9 +3778,10 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
{
int error = NetLib.instance.Net_LastError();
String strError = String.format("Net_SetDeviceCfg fail, command = %d, errorCode = %d", nCommand, error);
return null;
System.out.println(strError);
return R.error(500,strError);
}
System.out.println(stuCfgAutoMaintain);
return stuCfgAutoMaintain;
return R.ok();
}
}

9
ruoyi-code/src/main/java/utils/run_device_log_search.java

@ -391,7 +391,7 @@ public class run_device_log_search implements ActionListener { @@ -391,7 +391,7 @@ public class run_device_log_search implements ActionListener {
STU_CFG_LOG stuLogSearch = new STU_CFG_LOG();
if(StringUtils.isEmpty(strStartTime))
strStartTime = "2000-01-01 00:00:00";
strStartTime = "2022-07-01 00:00:00";
byte[] tmpByArr = DataUtils.sdk_data_stringToByteArray(strStartTime, GlobalTool.getEncodeType());
System.arraycopy(tmpByArr, 0, stuLogSearch.stuSearchCondition.cStartTime, 0, tmpByArr.length);
@ -435,10 +435,10 @@ public class run_device_log_search implements ActionListener { @@ -435,10 +435,10 @@ public class run_device_log_search implements ActionListener {
DataUtils.sdk_data_ptrToStructure(pBuffer, stuLogSearch);
LogInfo logInfo = new LogInfo();
for(int i=0; i<stuLogSearch.stuLogResult.uCurAmount; i++)
{
LogInfo logInfo = new LogInfo();
STU_CFG_LOG_INFO stuLogInfo = stuLogSearch.stuLogResult.stuResult[i];
String cLogTime = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cLogTime, GlobalTool.getEncodeType());
@ -459,8 +459,7 @@ public class run_device_log_search implements ActionListener { @@ -459,8 +459,7 @@ public class run_device_log_search implements ActionListener {
String cClientType = DataUtils.sdk_data_byteArrayToString(stuLogInfo.stuLogDetail.cClientType, GlobalTool.getEncodeType());
logInfo.setCClientType(cClientType);
System.out.println(JSON.toJSON(logInfo));
System.out.println(cClientType);
logInfoList.add(logInfo);
}

Loading…
Cancel
Save