4670101279 2 years ago
parent
commit
8941e716a1
  1. 52
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/CameraController.java
  2. 11
      ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/WaterPhotoInfoController.java
  3. 40
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/LogInfo.java
  4. 13
      ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/TableData.java
  5. 3
      ruoyi-code/src/main/java/com/ruoyi/code/camera/mapper/WaterPhotoInfoMapper.java
  6. 9
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/IWaterPhotoInfoService.java
  7. 60
      ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/WaterPhotoInfoServiceImpl.java
  8. 2
      ruoyi-code/src/main/java/utils/CameraUtil.java
  9. 73
      ruoyi-code/src/main/java/utils/run_device_cfg.java
  10. 477
      ruoyi-code/src/main/java/utils/run_device_log_search.java
  11. 20
      ruoyi-code/src/main/resources/mapper/camera/WaterPhotoInfoMapper.xml

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

@ -10,11 +10,16 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
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.sun.jna.NativeLong; import com.sun.jna.NativeLong;
import com.sun.jna.ptr.IntByReference;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import sdk.java.lib.netmanager.NetEnums;
import sdk.java.lib.netmanager.NetLib;
import utils.CameraUtil; import utils.CameraUtil;
import utils.RegisterUtil; import utils.RegisterUtil;
import utils.run_device_cfg;
import utils.run_device_log_search;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -183,4 +188,51 @@ public class CameraController extends BaseController
cameraService.updateById(c); cameraService.updateById(c);
return R.ok(); 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.getCameraBySid(id);
IntByReference nError = new IntByReference(0);
NativeLong loginID = NetLib.instance.Net_LoginDevice(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), null,nError);
run_device_cfg cfg = new run_device_cfg();
cfg.getAutoCfg(loginID,nCommand);
return R.ok();
}
/**
* 设置摄像头重启
*/
@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);
run_device_cfg cfg = new run_device_cfg();
cfg.setAutoFtpCfg(loginID,(int)params.get("benable"),(int)params.get("uHour"),(int)params.get("uWeekDay"));
return R.ok();
}
/**
* 获取日志
*/
@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);
run_device_log_search logSearch = new run_device_log_search();
logSearch.logInfoSearchByTime(loginID,(String) params.get("strStartTime"),(String) params.get("strEndTime"));
return R.ok();
}
} }

11
ruoyi-code/src/main/java/com/ruoyi/code/camera/controller/WaterPhotoInfoController.java

@ -1,5 +1,6 @@
package com.ruoyi.code.camera.controller; package com.ruoyi.code.camera.controller;
import com.ruoyi.code.camera.domain.TableData;
import com.ruoyi.code.camera.service.IWaterPhotoInfoService; import com.ruoyi.code.camera.service.IWaterPhotoInfoService;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.R; import com.ruoyi.common.core.page.R;
@ -9,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -42,4 +44,13 @@ public class WaterPhotoInfoController extends BaseController
Map<String, Object> map = waterPhotoInfoService.getChart(params); Map<String, Object> map = waterPhotoInfoService.getChart(params);
return R.ok().put("data",map); return R.ok().put("data",map);
} }
/**
* 生成表数据
*/
@RequestMapping("/getTableData")
public R getTableData(@RequestParam Map<String, Object> params){
List<TableData> list = waterPhotoInfoService.getTableData(params);
return R.ok().put("data",list);
}
} }

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

@ -0,0 +1,40 @@
package com.ruoyi.code.camera.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.*;
@Data
public class LogInfo implements Serializable{
private static final long serialVersionUID = 1L;
/** 记录时间 */
private String cLogTime;
/** 用户名 */
private String cOperUserName;
/** 主类型 */
private String cMainType;
/** 次类型 */
private String cSubType;
/** 远程ip */
private String cRemoteIP;
/** 通道号 */
private String iChannel;
/** 配置名称 */
private String cConfigName;
/** 网络适配 */
private String cNetAdapter;
/** 客户端类型 */
private String cClientType;
}

13
ruoyi-code/src/main/java/com/ruoyi/code/camera/domain/TableData.java

@ -0,0 +1,13 @@
package com.ruoyi.code.camera.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TableData {
private String value;
private Object tm;
}

3
ruoyi-code/src/main/java/com/ruoyi/code/camera/mapper/WaterPhotoInfoMapper.java

@ -3,6 +3,7 @@ package com.ruoyi.code.camera.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.code.camera.domain.TableData;
import com.ruoyi.code.camera.domain.WaterPhotoInfo; import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.code.camera.domain.YcData; import com.ruoyi.code.camera.domain.YcData;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -25,4 +26,6 @@ public interface WaterPhotoInfoMapper extends BaseMapper<WaterPhotoInfo>
IPage<WaterPhotoInfo> selectWaterCurrentDataList(Page page, @Param("params") Map<String, Object> params); IPage<WaterPhotoInfo> selectWaterCurrentDataList(Page page, @Param("params") Map<String, Object> params);
List<YcData> selectWaterData(@Param("params") Map<String, Object> params); List<YcData> selectWaterData(@Param("params") Map<String, Object> params);
List<TableData> selectTableData(@Param("params") Map<String, Object> params);
} }

9
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/IWaterPhotoInfoService.java

@ -1,9 +1,11 @@
package com.ruoyi.code.camera.service; package com.ruoyi.code.camera.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.code.camera.domain.TableData;
import com.ruoyi.code.camera.domain.WaterPhotoInfo; import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.common.core.page.R; import com.ruoyi.common.core.page.R;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -20,4 +22,11 @@ public interface IWaterPhotoInfoService extends IService<WaterPhotoInfo>
R getScWaterCurrentDataList(Map<String, Object> params); R getScWaterCurrentDataList(Map<String, Object> params);
Map<String, Object> getChart(Map<String, Object> params); Map<String, Object> getChart(Map<String, Object> params);
/**
* 生成表格数据
* @param params
* @return
*/
List<TableData> getTableData(Map<String, Object> params);
} }

60
ruoyi-code/src/main/java/com/ruoyi/code/camera/service/impl/WaterPhotoInfoServiceImpl.java

@ -3,16 +3,22 @@ package com.ruoyi.code.camera.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.code.camera.domain.ChartData; import com.ruoyi.code.camera.domain.ChartData;
import com.ruoyi.code.camera.domain.TableData;
import com.ruoyi.code.camera.domain.WaterPhotoInfo; import com.ruoyi.code.camera.domain.WaterPhotoInfo;
import com.ruoyi.code.camera.domain.YcData; import com.ruoyi.code.camera.domain.YcData;
import com.ruoyi.code.camera.mapper.WaterPhotoInfoMapper; import com.ruoyi.code.camera.mapper.WaterPhotoInfoMapper;
import com.ruoyi.code.camera.service.IWaterPhotoInfoService; import com.ruoyi.code.camera.service.IWaterPhotoInfoService;
import com.ruoyi.code.sctaationinfo.domain.ScStationInfo;
import com.ruoyi.code.sctaationinfo.service.IScStationInfoService;
import com.ruoyi.common.core.page.R; import com.ruoyi.common.core.page.R;
import com.ruoyi.common.utils.Query; import com.ruoyi.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat; import java.util.ArrayList;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* Service业务层处理 * Service业务层处理
@ -24,6 +30,8 @@ import java.util.*;
public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper, WaterPhotoInfo> implements IWaterPhotoInfoService public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper, WaterPhotoInfo> implements IWaterPhotoInfoService
{ {
@Autowired
private IScStationInfoService scStationInfoService;
@Override @Override
public R queryPage(Map<String, Object> params) { public R queryPage(Map<String, Object> params) {
@ -48,11 +56,15 @@ public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper,
@Override @Override
public Map<String, Object> getChart(Map<String, Object> params) { public Map<String, Object> getChart(Map<String, Object> params) {
params.put("startTime",formatDate(new Long((String) params.get("startTime"))));
params.put("endTime",formatDate(new Long((String) params.get("endTime"))));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
List<String> legend = new ArrayList<>(); List<String> legend = new ArrayList<>();
List<ChartData> series = new ArrayList<>(); List<ChartData> series = new ArrayList<>();
// 获取表名
Integer dataType = Integer.parseInt((String) params.get("dataType"));
String dataTableName = getDataTableName(dataType);
params.put("tableName",dataTableName);
// 图表的数据 // 图表的数据
ChartData chartData = getChartOptionData(params); ChartData chartData = getChartOptionData(params);
if (chartData != null) { if (chartData != null) {
@ -64,10 +76,42 @@ public class WaterPhotoInfoServiceImpl extends ServiceImpl<WaterPhotoInfoMapper,
return map; return map;
} }
public String formatDate(Long d){ @Override
Date date = new Date(d); public List<TableData> getTableData(Map<String, Object> params) {
SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); List<TableData> tableDataList;
return sm.format(date); // 获取表名
Integer dataType = Integer.parseInt((String) params.get("dataType"));
String dataTableName = getDataTableName(dataType);
params.put("tableName",dataTableName);
// 根据id查询站点信息
Long stnmId = new Long((String)params.get("stnmId"));
ScStationInfo scStationInfo = scStationInfoService.getById(stnmId);
tableDataList = baseMapper.selectTableData(params);
// 去除 T
for (TableData tableData : tableDataList) {
tableData.setTm(tableData.getTm().toString().replace('T', ' '));
}
tableDataList.add(0,new TableData(scStationInfo.getStnm() ,"时间"));
return tableDataList;
}
/**
* 获取表名
* 0 小时 1 -1: 分钟
* @param dataType
* @return
*/
public String getDataTableName(Integer dataType){
if(dataType == 0){
return "sc_water_data_xs";
}else if(dataType == 1){
return "sc_water_data_day";
}else if(dataType == -1){
return "sc_water_data";
}
return "";
} }
public ChartData getChartOptionData(Map<String, Object> params){ public ChartData getChartOptionData(Map<String, Object> params){
ChartData data = null; ChartData data = null;

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

@ -1,6 +1,7 @@
package utils; package utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.ruoyi.code.camera.domain.LogInfo;
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;
@ -9,6 +10,7 @@ import sdk.java.lib.netmanager.NetLib;
import sdk.java.lib.netmanager.NetStructs; import sdk.java.lib.netmanager.NetStructs;
import java.util.Date; import java.util.Date;
import java.util.List;
public class CameraUtil { public class CameraUtil {
public static void main(String[] args) { public static void main(String[] args) {

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

@ -3707,4 +3707,77 @@ public class run_device_cfg implements ActionListener, ListSelectionListener {
return ftpCfg; return ftpCfg;
} }
//获取自动重启配置
public STU_CFG_AUTO_MAINTAIN getAutoCfg(NativeLong loginID ,int nCommand){
IntByReference outBufferSize = new IntByReference(0);
IntByReference nReturnSize = new IntByReference(0);
Pointer ptrOutBuffer = initStuData(nCommand, outBufferSize);
boolean bResult = NetLib.instance.Net_GetDeviceCfg(
loginID,
nCommand,
0,
ptrOutBuffer,
outBufferSize.getValue(),
nReturnSize,
6000);
STU_CFG_AUTO_MAINTAIN stuCfgAutoMaintain = new STU_CFG_AUTO_MAINTAIN();
DataUtils.sdk_data_ptrToStructure(ptrOutBuffer, stuCfgAutoMaintain);
System.out.println(stuCfgAutoMaintain);
return stuCfgAutoMaintain;
}
//设置自动重启
/**
*
* @param bEnable 使能 0- 1-
* @param uHour 几点重启
* @param uWeekDay 周几重启
* @return
*/
public STU_CFG_AUTO_MAINTAIN setAutoFtpCfg(NativeLong loginID, int bEnable,int uHour,int uWeekDay){
// 句柄 - 网络存储传输配置
int nCommand = EM_DEVICE_CFG_TYPE.DEVICE_CFG_AUTO_MAINTAIN;
STU_CFG_AUTO_MAINTAIN stuCfgAutoMaintain = getAutoCfg(loginID, nCommand);
IntByReference inBufferSize = new IntByReference(0);
stuCfgAutoMaintain.bEnable=bEnable;
stuCfgAutoMaintain.uHour=uHour;
stuCfgAutoMaintain.uWeekDay=uWeekDay;
inBufferSize.setValue(stuCfgAutoMaintain.size());
Pointer ptrInBuffer = DataUtils.sdk_data_createPtr(inBufferSize.getValue());
DataUtils.sdk_data_structureToPtr(stuCfgAutoMaintain, ptrInBuffer, 0);
if(null == ptrInBuffer)
return null;
boolean bResult2 = NetLib.instance.Net_SetDeviceCfg(
loginID,
nCommand,
0,
ptrInBuffer,
inBufferSize.getValue(),
6000);
if(!bResult2)
{
int error = NetLib.instance.Net_LastError();
String strError = String.format("Net_SetDeviceCfg fail, command = %d, errorCode = %d", nCommand, error);
return null;
}
System.out.println(stuCfgAutoMaintain);
return stuCfgAutoMaintain;
}
} }

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

@ -0,0 +1,477 @@
package utils;
import java.awt.EventQueue;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import com.alibaba.fastjson.JSON;
import com.ruoyi.code.camera.domain.LogInfo;
import com.ruoyi.common.utils.StringUtils;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import sdk.java.common.GlobalTool;
import sdk.java.lib.DataUtils;
import sdk.java.lib.netmanager.NetDefs;
import sdk.java.lib.netmanager.NetLib;
import sdk.java.lib.netmanager.NetEnums.EM_DEVICE_CFG_TYPE;
import sdk.java.lib.netmanager.NetStructs;
import sdk.java.lib.netmanager.NetStructs.STU_CFG_LOG;
import sdk.java.lib.netmanager.NetStructs.STU_CFG_LOG_INFO;
import javax.swing.JButton;
import javax.swing.JTable;
public class run_device_log_search implements ActionListener {
private JFrame m_frame;
private JTextField m_jtf_ip;
private JTextField m_jtf_port;
private JTextField m_jtf_username;
private JTextField m_jtf_password;
private JTable m_table_log_info;
private DefaultTableModel m_tableModel;
private JButton m_btn_login;
private JButton m_btn_logout;
private NativeLong m_loginID = new NativeLong(0);
private JButton m_btn_refresh;
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Create the application.
*/
public run_device_log_search()
{
initialize();
initilizeRyNetLib();
}
/**
* Initialize the contents of the frame.
*/
private void initialize()
{
m_frame = new JFrame();
m_frame.setBounds(100, 100, 562, 457);
Toolkit kit = Toolkit.getDefaultToolkit();
int x = kit.getScreenSize().width/2 - this.m_frame.getWidth()/2;
int y = kit.getScreenSize().height/2 - this.m_frame.getHeight()/2;
m_frame.setLocation(x, y);
m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_frame.getContentPane().setLayout(null);
JLabel label = new JLabel("IP:");
label.setBounds(10, 13, 79, 15);
m_frame.getContentPane().add(label);
m_jtf_ip = new JTextField();
m_jtf_ip.setColumns(10);
m_jtf_ip.setBounds(82, 10, 178, 21);
m_frame.getContentPane().add(m_jtf_ip);
JLabel label_1 = new JLabel("Port:");
label_1.setBounds(280, 13, 79, 15);
m_frame.getContentPane().add(label_1);
m_jtf_port = new JTextField();
m_jtf_port.setColumns(10);
m_jtf_port.setBounds(358, 10, 178, 21);
m_frame.getContentPane().add(m_jtf_port);
JLabel label_2 = new JLabel("Username:");
label_2.setBounds(10, 38, 79, 15);
m_frame.getContentPane().add(label_2);
m_jtf_username = new JTextField();
m_jtf_username.setColumns(10);
m_jtf_username.setBounds(81, 35, 179, 21);
m_frame.getContentPane().add(m_jtf_username);
JLabel label_3 = new JLabel("Password:");
label_3.setBounds(280, 38, 79, 15);
m_frame.getContentPane().add(label_3);
m_jtf_password = new JTextField();
m_jtf_password.setColumns(10);
m_jtf_password.setBounds(358, 35, 178, 21);
m_frame.getContentPane().add(m_jtf_password);
m_btn_login = new JButton("登陆");
m_btn_login.addActionListener(this);
m_btn_login.setBounds(340, 66, 93, 23);
m_frame.getContentPane().add(m_btn_login);
m_btn_logout = new JButton("登出");
m_btn_logout.addActionListener(this);
m_btn_logout.setEnabled(false);
m_btn_logout.setBounds(443, 66, 93, 23);
m_frame.getContentPane().add(m_btn_logout);
Vector<String> columTitle = new Vector<String>();
columTitle.addElement("记录时间");
columTitle.addElement("操作用户名");
columTitle.addElement("主日志类型");
columTitle.addElement("次日志类型");
columTitle.addElement("远程IP");
columTitle.addElement("通道号");
columTitle.addElement("配置名称");
columTitle.addElement("网络适配器");
columTitle.addElement("客户端类型");
Vector<Vector<String>> data = new Vector<Vector<String>>();
m_tableModel = new DefaultTableModel(data, columTitle);
m_table_log_info = new JTable(m_tableModel);
m_table_log_info.setBounds(10, 99, 474, 309);
JScrollPane jspLogInfo = new JScrollPane(m_table_log_info);
jspLogInfo.setBounds(10, 99, 526, 276);
m_frame.getContentPane().add(jspLogInfo);
m_btn_refresh = new JButton("刷新");
m_btn_refresh.addActionListener(this);
m_btn_refresh.setBounds(443, 385, 93, 23);
m_frame.getContentPane().add(m_btn_refresh);
refreshEnables();
}
private void initilizeRyNetLib()
{
NetLib.instance.Net_Init(null, null);
NetLib.instance.Net_SetLogOption(3);
}
protected void finalize()
{
NetLib.instance.Net_Exit();
}
private boolean checkParams()
{
String tmp = this.m_jtf_ip.getText().trim();
if(tmp.isEmpty())
{
return false;
}
tmp = this.m_jtf_port.getText().trim();
if(tmp.isEmpty())
{
return false;
}
tmp = this.m_jtf_username.getText().trim();
if(tmp.isEmpty())
{
return false;
}
tmp = this.m_jtf_password.getText().trim();
if(tmp.isEmpty())
{
return false;
}
return true;
}
private void refreshEnables()
{
boolean bLogin = this.m_loginID.longValue() != 0;
this.m_btn_login.setEnabled(!bLogin);
this.m_btn_logout.setEnabled(bLogin);
this.m_btn_refresh.setEnabled(bLogin);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
private boolean onBtnLogin()
{
if(checkParams())
{
int nPort = Integer.parseInt(m_jtf_port.getText());
IntByReference nError = new IntByReference(0);
this.m_loginID = NetLib.instance.Net_LoginDevice(m_jtf_ip.getText(), nPort, m_jtf_username.getText(), m_jtf_password.getText(), null, nError);
if(0 == this.m_loginID.longValue())
{
JOptionPane.showMessageDialog(null, "登陆失败", "提示", JOptionPane.ERROR_MESSAGE);
int error = NetLib.instance.Net_LastError();
String strError = String.format("Net_LoginDevice fail, errorCode = %d", error);
System.out.println(strError);
return false;
}
else
{
logInfoSearch();
}
refreshEnables();
}
return true;
}
private void onBtnLogout()
{
if(0 != this.m_loginID.longValue())
{
boolean bResult = NetLib.instance.Net_LogoutDevice(this.m_loginID);
if(!bResult)
{
int error = NetLib.instance.Net_LastError();
String strError = String.format("Net_GetAllFaceGroups fail, errorCode = %d", error);
System.out.println(strError);
return;
}
this.m_loginID = new NativeLong(0);
refreshEnables();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
private void onBtnRefresh()
{
logInfoSearch();
}
private void logInfoSearch()
{
this.m_tableModel.setRowCount(0);
STU_CFG_LOG stuLogSearch = new STU_CFG_LOG();
String strStartTime = "2000-01-01 00:00:00";
byte[] tmpByArr = DataUtils.sdk_data_stringToByteArray(strStartTime, GlobalTool.getEncodeType());
System.arraycopy(tmpByArr, 0, stuLogSearch.stuSearchCondition.cStartTime, 0, tmpByArr.length);
Calendar cal = Calendar.getInstance();
String strEndTime = String.format("%04d-%02d-%02d %02d:%02d:%02d",
cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND));
tmpByArr = DataUtils.sdk_data_stringToByteArray(strEndTime, GlobalTool.getEncodeType());
System.arraycopy(tmpByArr, 0, stuLogSearch.stuSearchCondition.cEndTime, 0, tmpByArr.length);
int nBufferSize = stuLogSearch.size();
Pointer pBuffer = DataUtils.sdk_data_createPtr(nBufferSize);
DataUtils.sdk_data_structureToPtr(stuLogSearch, pBuffer, 0);
IntByReference nReturnSize = new IntByReference(0);
while(true)
{
// 循环重复调用,获取日志信息,直到获取到最新的一条
boolean bResult = NetLib.instance.Net_GetDeviceCfg(
m_loginID,
EM_DEVICE_CFG_TYPE.DEVICE_CFG_LOGSEARCH,
0,
pBuffer,
nBufferSize,
nReturnSize,
6000);
if(!bResult)
{
int error = NetLib.instance.Net_LastError();
String strError = String.format("Net_GetDeviceCfg fail, errorCode = %d", error);
System.out.println(strError);
break;
}
else
{
DataUtils.sdk_data_ptrToStructure(pBuffer, stuLogSearch);
ui_showLogInfo(stuLogSearch);
if(NetDefs.MAX_LOG_AMOUNT > stuLogSearch.stuLogResult.uCurAmount)
{
// 此处判断成立,则表示已查完所有日志
break;
}
}
}
}
private void ui_showLogInfo(STU_CFG_LOG stuLogSearch)
{
for(int i=0; i<stuLogSearch.stuLogResult.uCurAmount; i++)
{
Vector<String> rowData = new Vector<String>();
STU_CFG_LOG_INFO stuLogInfo = stuLogSearch.stuLogResult.stuResult[i];
String value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cLogTime, GlobalTool.getEncodeType());
rowData.addElement(value);
value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cOperUserName, GlobalTool.getEncodeType());
rowData.addElement(value);
value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cMainType, GlobalTool.getEncodeType());
rowData.addElement(value);
value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cSubType, GlobalTool.getEncodeType());
rowData.addElement(value);
value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.stuLogDetail.cRemoteIP, GlobalTool.getEncodeType());
rowData.addElement(value);
value = String.format("%d", stuLogInfo.stuLogDetail.iChannel);
rowData.addElement(value);
value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.stuLogDetail.cConfigName, GlobalTool.getEncodeType());
rowData.addElement(value);
value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.stuLogDetail.cNetAdapter, GlobalTool.getEncodeType());
rowData.addElement(value);
value = DataUtils.sdk_data_byteArrayToString(stuLogInfo.stuLogDetail.cClientType, GlobalTool.getEncodeType());
rowData.addElement(value);
this.m_tableModel.addRow(rowData);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public void actionPerformed(ActionEvent e)
{
Object obj = e.getSource();
if(obj == this.m_btn_login)
{
onBtnLogin();
}
else if(obj == this.m_btn_logout)
{
onBtnLogout();
}
else if(obj == this.m_btn_refresh)
{
onBtnRefresh();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
run_device_log_search window = new run_device_log_search();
window.m_frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
public List<LogInfo> logInfoSearchByTime(NativeLong loginID , String strStartTime, String strEndTime)
{
STU_CFG_LOG stuLogSearch = new STU_CFG_LOG();
if(StringUtils.isEmpty(strStartTime))
strStartTime = "2000-01-01 00:00:00";
byte[] tmpByArr = DataUtils.sdk_data_stringToByteArray(strStartTime, GlobalTool.getEncodeType());
System.arraycopy(tmpByArr, 0, stuLogSearch.stuSearchCondition.cStartTime, 0, tmpByArr.length);
Calendar cal = Calendar.getInstance();
if (StringUtils.isEmpty(strEndTime))
strEndTime = String.format("%04d-%02d-%02d %02d:%02d:%02d",
cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND));
tmpByArr = DataUtils.sdk_data_stringToByteArray(strEndTime, GlobalTool.getEncodeType());
System.arraycopy(tmpByArr, 0, stuLogSearch.stuSearchCondition.cEndTime, 0, tmpByArr.length);
int nBufferSize = stuLogSearch.size();
Pointer pBuffer = DataUtils.sdk_data_createPtr(nBufferSize);
DataUtils.sdk_data_structureToPtr(stuLogSearch, pBuffer, 0);
IntByReference nReturnSize = new IntByReference(0);
List<LogInfo> logInfoList=new ArrayList<>();
while(true)
{
// 循环重复调用,获取日志信息,直到获取到最新的一条
boolean bResult = NetLib.instance.Net_GetDeviceCfg(
loginID,
EM_DEVICE_CFG_TYPE.DEVICE_CFG_LOGSEARCH,
0,
pBuffer,
nBufferSize,
nReturnSize,
6000);
if(!bResult)
{
int error = NetLib.instance.Net_LastError();
String strError = String.format("Net_GetDeviceCfg fail, errorCode = %d", error);
System.out.println(strError);
break;
}
else
{
DataUtils.sdk_data_ptrToStructure(pBuffer, stuLogSearch);
LogInfo logInfo = new LogInfo();
for(int i=0; i<stuLogSearch.stuLogResult.uCurAmount; i++)
{
STU_CFG_LOG_INFO stuLogInfo = stuLogSearch.stuLogResult.stuResult[i];
String cLogTime = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cLogTime, GlobalTool.getEncodeType());
logInfo.setCLogTime(cLogTime);
String cOperUserName = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cOperUserName, GlobalTool.getEncodeType());
logInfo.setCOperUserName(cOperUserName);
String cMainType = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cMainType, GlobalTool.getEncodeType());
logInfo.setCMainType(cMainType);
String cSubType = DataUtils.sdk_data_byteArrayToString(stuLogInfo.cSubType, GlobalTool.getEncodeType());
logInfo.setCSubType(cSubType);
String cRemoteIP = DataUtils.sdk_data_byteArrayToString(stuLogInfo.stuLogDetail.cRemoteIP, GlobalTool.getEncodeType());
logInfo.setCRemoteIP(cRemoteIP);
String cClientType = DataUtils.sdk_data_byteArrayToString(stuLogInfo.stuLogDetail.cClientType, GlobalTool.getEncodeType());
logInfo.setCClientType(cClientType);
System.out.println(JSON.toJSON(logInfo));
logInfoList.add(logInfo);
}
if(NetDefs.MAX_LOG_AMOUNT > stuLogSearch.stuLogResult.uCurAmount)
{
// 此处判断成立,则表示已查完所有日志
break;
}
}
}
return logInfoList;
}
}

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

@ -46,7 +46,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w.value w.value
from from
sc_station_info s sc_station_info s
left join sc_water_data w on w.stnm_id = s.id left join ${params.tableName} w on w.stnm_id = s.id
<where>
w.stnm_id = #{params.stnmId}
<if test="params.startTime != null">
and w.tm>=#{params.startTime}
</if>
<if test="params.endTime != null">
and w.tm &lt;=#{params.endTime}
</if>
</where>
order by w.tm
</select>
<select id="selectTableData" resultType="com.ruoyi.code.camera.domain.TableData">
select
w.tm,
w.value
from
sc_station_info s
left join ${params.tableName} w on w.stnm_id = s.id
<where> <where>
w.stnm_id = #{params.stnmId} w.stnm_id = #{params.stnmId}
<if test="params.startTime != null"> <if test="params.startTime != null">

Loading…
Cancel
Save