提交 2a44938d authored 作者: wangqiang's avatar wangqiang

问题修改

上级 d7ec941f
package com; package com;
import com.priusis.service.control.DeviceChangeCallbackImpl;
import com.priusis.utils.IHwPortController; import com.priusis.utils.IHwPortController;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -24,8 +23,8 @@ public class TestDemo { ...@@ -24,8 +23,8 @@ public class TestDemo {
//System.out.println(System.getProperty("user.dir")); //System.out.println(System.getProperty("user.dir"));
// 初始化硬件接口管理模块 // 初始化硬件接口管理模块
int result = IHwPortController.instanceDll.APQ_HWPORT_Initialize(); // int result = IHwPortController.instanceDll.APQ_HWPORT_Initialize();
log.info("APQ_HWPORT_Initialize ret:{}", result); // log.info("APQ_HWPORT_Initialize ret:{}", result);
// 注册设备热插拔通知后,接收热插拔事件 // 注册设备热插拔通知后,接收热插拔事件
// DeviceChangeCallbackImpl deviceChangeCallback = new DeviceChangeCallbackImpl(); // DeviceChangeCallbackImpl deviceChangeCallback = new DeviceChangeCallbackImpl();
...@@ -46,20 +45,30 @@ public class TestDemo { ...@@ -46,20 +45,30 @@ public class TestDemo {
int result33 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(4); int result33 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(4);
log.info("Check APQ_HWPORT_get_normal_device_permit ret:{}", result33); log.info("Check APQ_HWPORT_get_normal_device_permit ret:{}", result33);
*/ */
boolean flag = true;
// 获取存储设备权限 // 获取存储设备权限
/*int result31 = IHwPortController.instanceDll.APQ_HWPORT_get_storage_device_permit(IHwPortController.HwportStorageDevidEnum.APQ_HWPORT_STORAGE_DEVID_UDISK.getCode()); while (flag) {
log.info("APQ_HWPORT_get_storage_device_permit ret:{}", result31); IHwPortController.instanceDll.APQ_HWPORT_Initialize();
int result31 = IHwPortController.instanceDll.APQ_HWPORT_get_storage_device_permit(IHwPortController.HwportStorageDevidEnum.APQ_HWPORT_STORAGE_DEVID_UDISK.getCode());
// APQ_HWPORT_STORAGE_PERM_ALLOW APQ_HWPORT_STORAGE_PERM_DENY log.info("APQ_HWPORT_get_storage_device_permit ret:{}", result31);
int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_storage_device_permit(IHwPortController.HwportStorageDevidEnum.APQ_HWPORT_STORAGE_DEVID_UDISK.getCode(), IHwPortController.HwportStoragePermEnum.APQ_HWPORT_STORAGE_PERM_ALLOW.getCode(), null); IHwPortController.instanceDll.APQ_HWPORT_Uninitialize();
log.info("APQ_HWPORT_set_storage_device_permit ret:{}", result32); try {
//应用硬件接口管理模块的配置内容 Thread.sleep(6000);
int result5 = IHwPortController.instanceDll.APQ_HWPORT_Apply(); } catch (InterruptedException e) {
log.info("APQ_HWPORT_Apply ret:{}", result5); // TODO Auto-generated catch block
// 再次获取存储设备权限,验证 e.printStackTrace();
int result33 = IHwPortController.instanceDll.APQ_HWPORT_get_storage_device_permit(IHwPortController.HwportStorageDevidEnum.APQ_HWPORT_STORAGE_DEVID_UDISK.getCode()); }
log.info("Check APQ_HWPORT_get_storage_device_permit ret:{}", result33);*/ }
// // APQ_HWPORT_STORAGE_PERM_ALLOW APQ_HWPORT_STORAGE_PERM_DENY
// int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_storage_device_permit(IHwPortController.HwportStorageDevidEnum.APQ_HWPORT_STORAGE_DEVID_UDISK.getCode(), IHwPortController.HwportStoragePermEnum.APQ_HWPORT_STORAGE_PERM_ALLOW.getCode(), null);
// log.info("APQ_HWPORT_set_storage_device_permit ret:{}", result32);
// //应用硬件接口管理模块的配置内容
// int result5 = IHwPortController.instanceDll.APQ_HWPORT_Apply();
// log.info("APQ_HWPORT_Apply ret:{}", result5);
// // 再次获取存储设备权限,验证
// int result33 = IHwPortController.instanceDll.APQ_HWPORT_get_storage_device_permit(IHwPortController.HwportStorageDevidEnum.APQ_HWPORT_STORAGE_DEVID_UDISK.getCode());
// log.info("Check APQ_HWPORT_get_storage_device_permit ret:{}", result33);
/* // 获取网络设备权限 /* // 获取网络设备权限
......
...@@ -3,10 +3,11 @@ package com.priusis.job; ...@@ -3,10 +3,11 @@ package com.priusis.job;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.priusis.client.service.MqttRpcDataMessage;
import com.priusis.dto.HwPortControllerDto; import com.priusis.dto.HwPortControllerDto;
import com.priusis.service.control.DeviceChangeCallbackImpl; import com.priusis.service.control.DeviceChangeCallbackImpl;
import com.priusis.utils.*; import com.priusis.utils.IHwPortController;
import com.priusis.client.service.MqttRpcDataMessage; import com.priusis.utils.USBCheck;
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.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
...@@ -17,7 +18,10 @@ import org.springframework.web.client.RestTemplate; ...@@ -17,7 +18,10 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import java.util.*; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
...@@ -86,133 +90,141 @@ public class ApqControlJob { ...@@ -86,133 +90,141 @@ public class ApqControlJob {
String params = body.getParams(); String params = body.getParams();
if (StrUtil.isNotBlank(params)) { if (StrUtil.isNotBlank(params)) {
Long sendTime = body.getSendTime(); int result = IHwPortController.instanceDll.APQ_HWPORT_Initialize();
long current = System.currentTimeMillis(); log.info("APQ_HWPORT_Initialize ret:{}", result);
List<HwPortControllerDto> hwPortControllerDtos = JSONUtil.toList(params, HwPortControllerDto.class);
try {
if (current - sendTime <= FIXED_DELAY && CollUtil.isNotEmpty(hwPortControllerDtos)) { Long sendTime = body.getSendTime();
// 收到硬件策略下发请求 long current = System.currentTimeMillis();
log.info("收到硬件策略下发请求, sendTime:{}, params:{}", sendTime, params); List<HwPortControllerDto> hwPortControllerDtos = JSONUtil.toList(params, HwPortControllerDto.class);
for (HwPortControllerDto hwPortControllerDto : hwPortControllerDtos) { if (current - sendTime <= FIXED_DELAY && CollUtil.isNotEmpty(hwPortControllerDtos)) {
HwPortControllerDto.DeviceHardwareEnum deviceHardwareEnum = hwPortControllerDto.getKey(); // 收到硬件策略下发请求
int doType = hwPortControllerDto.getDoType(); log.info("收到硬件策略下发请求, sendTime:{}, params:{}", sendTime, params);
int limitType = hwPortControllerDto.getLimitType();
int value = hwPortControllerDto.getValue(); for (HwPortControllerDto hwPortControllerDto : hwPortControllerDtos) {
HwPortControllerDto.DeviceHardwareEnum deviceHardwareEnum = hwPortControllerDto.getKey();
List<Integer> hwDeviceIds = deviceHardwareEnum.getHwDeviceIds(); int doType = hwPortControllerDto.getDoType();
String hwDeviceName = deviceHardwareEnum.getName(); int limitType = hwPortControllerDto.getLimitType();
// 设置普通设备权限 int value = hwPortControllerDto.getValue();
if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Normal")) {
// 1F/2T List<Integer> hwDeviceIds = deviceHardwareEnum.getHwDeviceIds();
for (Integer hwDeviceId : hwDeviceIds) { String hwDeviceName = deviceHardwareEnum.getName();
int perm = (doType == 1 ? 2 : 1); // 设置普通设备权限
int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_normal_device_permit(hwDeviceId, perm, null); if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Normal")) {
log.info("APQ_HWPORT_set_normal_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}", // 1F/2T
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32); for (Integer hwDeviceId : hwDeviceIds) {
} int perm = (doType == 1 ? 2 : 1);
} else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Storage")) { // 设置存储设备权限 int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_normal_device_permit(hwDeviceId, perm, null);
// 1F/2T/3T-ALL/4T-R/5T-CI/6T-CO 拷出目前无用!! Storage移动硬盘,TYPEC 无效 !! log.info("APQ_HWPORT_set_normal_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}",
for (Integer hwDeviceId : hwDeviceIds) { doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32);
int perm = (doType == 1 ? 2 : 1);
if (perm == 2) {
// limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速
perm = (limitType == 1 ? 3 : limitType == 2 ? 4 : limitType == 3 ? 5 : limitType == 4 ? 6 : 3);
} }
int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_storage_device_permit(hwDeviceId, perm, null); } else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Storage")) { // 设置存储设备权限
log.info("APQ_HWPORT_set_storage_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}", // 1F/2T/3T-ALL/4T-R/5T-CI/6T-CO 拷出目前无用!! Storage移动硬盘,TYPEC 无效 !!
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32); for (Integer hwDeviceId : hwDeviceIds) {
} int perm = (doType == 1 ? 2 : 1);
} else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "NET")) { // 设置网络设备权限 if (perm == 2) {
// 1F/2T/3T-NS/4T-S-200 网口,4G/5G模块,无线WIFI区分不了 !! // limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速
for (Integer hwDeviceId : hwDeviceIds) { perm = (limitType == 1 ? 3 : limitType == 2 ? 4 : limitType == 3 ? 5 : limitType == 4 ? 6 : 3);
int perm = (doType == 1 ? 2 : 1); }
if (perm == 2) { int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_storage_device_permit(hwDeviceId, perm, null);
// limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速 log.info("APQ_HWPORT_set_storage_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}",
perm = (limitType == 5 ? 3 : limitType == 6 ? 4 : 2); doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32);
}
} else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "NET")) { // 设置网络设备权限
// 1F/2T/3T-NS/4T-S-200 网口,4G/5G模块,无线WIFI区分不了 !!
for (Integer hwDeviceId : hwDeviceIds) {
int perm = (doType == 1 ? 2 : 1);
if (perm == 2) {
// limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速
perm = (limitType == 5 ? 3 : limitType == 6 ? 4 : 2);
}
int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_net_device_permit(hwDeviceId, perm, value, null);
log.info("APQ_HWPORT_set_net_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}",
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32);
} }
int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_net_device_permit(hwDeviceId, perm, value, null);
log.info("APQ_HWPORT_set_net_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}",
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32);
} }
}
// 应用硬件接口管理模块的配置内容 // 应用硬件接口管理模块的配置内容
int result5 = IHwPortController.instanceDll.APQ_HWPORT_Apply(); int result5 = IHwPortController.instanceDll.APQ_HWPORT_Apply();
log.info("APQ_HWPORT_Apply ret:{}", result5); log.info("APQ_HWPORT_Apply ret:{}", result5);
} }
} else { } else {
log.info("执行硬件监控, sendTime:{}, params:{}", sendTime, params); log.info("执行硬件监控, sendTime:{}, params:{}", sendTime, params);
// 上报硬件监控数据 // 上报硬件监控数据
Map mapRequest = new HashMap(); Map mapRequest = new HashMap();
for (HwPortControllerDto hwPortControllerDto : hwPortControllerDtos) { for (HwPortControllerDto hwPortControllerDto : hwPortControllerDtos) {
HwPortControllerDto.DeviceHardwareEnum deviceHardwareEnum = hwPortControllerDto.getKey(); HwPortControllerDto.DeviceHardwareEnum deviceHardwareEnum = hwPortControllerDto.getKey();
int doType = hwPortControllerDto.getDoType(); int doType = hwPortControllerDto.getDoType();
int limitType = hwPortControllerDto.getLimitType(); int limitType = hwPortControllerDto.getLimitType();
int value = hwPortControllerDto.getValue(); int value = hwPortControllerDto.getValue();
List<Integer> hwDeviceIds = deviceHardwareEnum.getHwDeviceIds(); List<Integer> hwDeviceIds = deviceHardwareEnum.getHwDeviceIds();
String hwDeviceName = deviceHardwareEnum.getName(); String hwDeviceName = deviceHardwareEnum.getName();
// 设置普通设备权限 // 设置普通设备权限
if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Normal")) { if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Normal")) {
// 1F/2T // 1F/2T
for (Integer hwDeviceId : hwDeviceIds) { for (Integer hwDeviceId : hwDeviceIds) {
int perm = (doType == 1 ? 2 : 1); int perm = (doType == 1 ? 2 : 1);
if (perm == 1) { if (perm == 1) {
// 获取普通设备权限 // 获取普通设备权限
int result31 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(hwDeviceId); int result31 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(hwDeviceId);
log.debug("APQ_HWPORT_get_normal_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}", log.debug("APQ_HWPORT_get_normal_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}",
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result31); doType, limitType, value, hwDeviceId, hwDeviceName, perm, result31);
if (result31 == 2) { if (result31 == 2) {
mapRequest.put(deviceHardwareEnum.name(), result31); mapRequest.put(deviceHardwareEnum.name(), result31);
}
} }
} }
} } else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Storage")) { // 设置存储设备权限
} else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "Storage")) { // 设置存储设备权限 // 1F/2T/3T-ALL/4T-R/5T-CI/6T-CO 拷出目前无用!! Storage移动硬盘,TYPEC 无效 !!
// 1F/2T/3T-ALL/4T-R/5T-CI/6T-CO 拷出目前无用!! Storage移动硬盘,TYPEC 无效 !! for (Integer hwDeviceId : hwDeviceIds) {
for (Integer hwDeviceId : hwDeviceIds) { int perm = (doType == 1 ? 2 : 1);
int perm = (doType == 1 ? 2 : 1); if (perm == 2) {
if (perm == 2) { // limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速存在硬件接口扫描告警
// limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速存在硬件接口扫描告警 perm = (limitType == 1 ? 3 : limitType == 2 ? 4 : limitType == 3 ? 5 : limitType == 4 ? 6 : 3);
perm = (limitType == 1 ? 3 : limitType == 2 ? 4 : limitType == 3 ? 5 : limitType == 4 ? 6 : 3); }
}
int result32 = IHwPortController.instanceDll.APQ_HWPORT_get_storage_device_permit(hwDeviceId); int result32 = IHwPortController.instanceDll.APQ_HWPORT_get_storage_device_permit(hwDeviceId);
log.info("APQ_HWPORT_get_storage_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}", log.info("APQ_HWPORT_get_storage_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}",
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32); doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32);
if (perm != result32) { if (perm != result32) {
mapRequest.put(deviceHardwareEnum.name(), result32); mapRequest.put(deviceHardwareEnum.name(), result32);
} }
}
} else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "NET")) { // 设置网络设备权限
// 1F/2T/3T-NS/4T-S-200 网口,4G/5G模块,无线WIFI区分不了 !!
for (Integer hwDeviceId : hwDeviceIds) {
int perm = (doType == 1 ? 2 : 1);
if (perm == 2) {
// limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速
perm = (limitType == 5 ? 3 : limitType == 6 ? 4 : 2);
} }
int result32 = IHwPortController.instanceDll.APQ_HWPORT_get_net_device_permit(hwDeviceId, 0); } else if (Objects.equals(deviceHardwareEnum.getHwGroup(), "NET")) { // 设置网络设备权限
log.info("APQ_HWPORT_get_net_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}", // 1F/2T/3T-NS/4T-S-200 网口,4G/5G模块,无线WIFI区分不了 !!
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32); for (Integer hwDeviceId : hwDeviceIds) {
if (perm != result32) { int perm = (doType == 1 ? 2 : 1);
mapRequest.put(deviceHardwareEnum.name(), result32); if (perm == 2) {
// limitType 1读写 2只读 3拷入 4拷出 5不限速 6限速
perm = (limitType == 5 ? 3 : limitType == 6 ? 4 : 2);
}
int result32 = IHwPortController.instanceDll.APQ_HWPORT_get_net_device_permit(hwDeviceId, 0);
log.info("APQ_HWPORT_get_net_device_permit doType:{}, limitType;{},value:{}, hwDeviceId:{}, name;{}, perm:{}, ret:{}",
doType, limitType, value, hwDeviceId, hwDeviceName, perm, result32);
if (perm != result32) {
mapRequest.put(deviceHardwareEnum.name(), result32);
}
} }
} }
} }
}
if (mapRequest.size() > 0) { if (mapRequest.size() > 0) {
Map eventMapRequest = new HashMap(); Map eventMapRequest = new HashMap();
eventMapRequest.put("requestId", 3); eventMapRequest.put("requestId", 3);
eventMapRequest.put("methodName", "control_warning"); eventMapRequest.put("methodName", "control_warning");
eventMapRequest.put("params", mapRequest); eventMapRequest.put("params", mapRequest);
Map map = restTemplate.postForObject("http://localhost:8765/uplink_event/oc-client", eventMapRequest, Map.class); Map map = restTemplate.postForObject("http://localhost:8765/uplink_event/oc-client", eventMapRequest, Map.class);
log.info("存在硬件接口扫描告警,上报告警事件: mapData:{}, ret:{}", mapRequest, map); log.info("存在硬件接口扫描告警,上报告警事件: mapData:{}, ret:{}", mapRequest, map);
}
} }
} finally {
result = IHwPortController.instanceDll.APQ_HWPORT_Uninitialize();
log.info("APQ_HWPORT_Uninitialize ret:{}", result);
} }
} else { } else {
log.info("未获取到获取硬件监控配置"); log.info("未获取到获取硬件监控配置");
......
...@@ -120,6 +120,7 @@ public class ApqRegister4BackListJob { ...@@ -120,6 +120,7 @@ public class ApqRegister4BackListJob {
// WinExecuteUtils.killProc("阿普奇检测客户端.exe"); // WinExecuteUtils.killProc("阿普奇检测客户端.exe");
// WinExecuteUtils.killProc("火绒文件粉碎机_v5.0.0.1单文件完整功能版.exe"); // WinExecuteUtils.killProc("火绒文件粉碎机_v5.0.0.1单文件完整功能版.exe");
WinExecuteUtils.killProc("火绒文件粉碎机_5.0.0.1单文件版.exe"); WinExecuteUtils.killProc("火绒文件粉碎机_5.0.0.1单文件版.exe");
// taskkill /pid 13124 -t -f
} catch (IOException e) { } catch (IOException e) {
log.error("杀进程异常", e); log.error("杀进程异常", e);
} }
......
...@@ -27,7 +27,7 @@ public class DeviceChangeCallbackImpl implements IDeviceChangeCallback { ...@@ -27,7 +27,7 @@ public class DeviceChangeCallbackImpl implements IDeviceChangeCallback {
@Override @Override
public void P_DEVICE_CHANGE_CB(int changeType, Pointer data) { public void P_DEVICE_CHANGE_CB(int changeType, Pointer data) {
String changeData = data.getString(0); String changeData = data.getString(0, "GBK");
log.info("回调成功!changeType: {}, data: {}", changeType, changeData); log.info("回调成功!changeType: {}, data: {}", changeType, changeData);
Map mapRequest = new HashMap(); Map mapRequest = new HashMap();
// 1代表插入,2代表拔出 // 1代表插入,2代表拔出
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论