提交 8a854f28 authored 作者: wangqiang's avatar wangqiang

no qr

上级 478be0f6
......@@ -13,15 +13,14 @@
<artifactId>apq-pc-control</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>4.12</junit.version>
<lombok.version>1.16.18</lombok.version>
<jna.version>3.0.9</jna.version>
<spring-boot.version>2.4.10</spring-boot.version>
<jna.version>3.0.9</jna.version>
<winsw.version>2.0.1</winsw.version>
<pkg.name>apq-pc-control</pkg.name>
<pkg.user>priusis-iot</pkg.user>
......@@ -37,6 +36,15 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<version>${winsw.version}</version>
<classifier>bin</classifier>
<type>exe</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......@@ -48,31 +56,26 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.11</version>
</dependency>
<dependency>
<groupId>com.sun.jna</groupId>
<artifactId>jna</artifactId>
<version>${jna.version}</version>
</dependency>
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<version>${winsw.version}</version>
<classifier>bin</classifier>
<type>exe</type>
<scope>provided</scope>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
......
package com;
import com.priusis.utils.ICQrDecode;
import com.priusis.utils.IHwPortController;
import com.zy.QrDecode.CQrDecode;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TestDemo {
//static String qrString = "0000000D920A7111688CEDA9D7E27F2AE7C98D2E";
static String qrString = "0000000D9BBC6C567944AF514A1AD0A252491B99";
public static void main2(String[] args) {
String path = CQrDecode.parseAbsolutePath("/qr/dat/", "smart-property/0000000d.dat");
int[] result = new int[4];
CQrDecode qrInstance = new CQrDecode();
int ret = qrInstance.ZOOYAPI_GetCodeII(path + "0000000d.dat", qrString, result);
log.info("ret:{}", ret);
log.info("卡号 " + Integer.toHexString(result[0]));
log.info("校验码 " + Integer.toString(result[1]));
log.info("*********************************");
}
public static void main(String[] args) {
/*String path = CQrDecode.parseAbsolutePath("/qr/dat/", "smart-property/0000000d.dat");
......@@ -44,8 +27,8 @@ public class TestDemo {
int result31 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(4);
log.info("APQ_HWPORT_get_normal_device_permit ret:{}", result31);
// 设置普通设备权限
int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_normal_device_permit(4, 1, null);
log.info("APQ_HWPORT_set_normal_device_permit ret:{}", result32);
//int result32 = IHwPortController.instanceDll.APQ_HWPORT_set_normal_device_permit(4, 1, null);
//log.info("APQ_HWPORT_set_normal_device_permit ret:{}", result32);
// 应用硬件接口管理模块的配置内容
int result5 = IHwPortController.instanceDll.APQ_HWPORT_Apply();
log.info("APQ_HWPORT_Apply ret:{}", result5);
......@@ -53,9 +36,9 @@ public class TestDemo {
int result33 = IHwPortController.instanceDll.APQ_HWPORT_get_normal_device_permit(4);
log.info("Check APQ_HWPORT_get_normal_device_permit ret:{}", result33);
// 获取网络设备权限
//int speed = 0;
//int result4 = IHwPortController.instanceDll.APQ_HWPORT_get_net_device_permit(0, speed);
//log.info("APQ_HWPORT_get_net_device_permit ret:{}, speed:{}", result4, speed);
int speed = 0;
int result4 = IHwPortController.instanceDll.APQ_HWPORT_get_net_device_permit(0);
log.info("APQ_HWPORT_get_net_device_permit ret:{}, speed:{}", result4, speed);
// 清理硬件接口管理模块
int result2 = IHwPortController.instanceDll.APQ_HWPORT_Uninitialize();
log.info("APQ_HWPORT_Uninitialize ret:{}", result2);
......
......@@ -37,7 +37,7 @@ public class ApqControlApplication {
SpringApplication.run(ApqControlApplication.class, args);
}
@Scheduled(fixedDelay = FIXED_DELAY)
@Scheduled(fixedDelay = 60000L)
protected void controlProgramTask() {
// 获取硬件监控配置 params == data
ResponseEntity<MqttRpcDataMessage> forEntity = restTemplate.getForEntity("http://localhost:8765/rpc_cmd/controll", MqttRpcDataMessage.class);
......
package com.priusis.utils;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
public interface ICQrDecode extends Library {
ICQrDecode INSTANCE = (ICQrDecode) Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"), ICQrDecode.class);
void printf(String format, Object... args);
ICQrDecode instanceDll = (ICQrDecode) Native.loadLibrary("D:\\work\\priusis\\priusis-iot\\apq-iot\\apq-client\\apq-pc-control\\src\\main\\resources\\QrDecode.dll", ICQrDecode.class);
public int hello(String str);
public int ZOOYAPI_GetCode(String path, String qrString, int[] result);
public int ZOOYAPI_GetCodeII(String path, String qrString, int[] result);
}
......@@ -118,6 +118,14 @@ public interface IHwPortController extends Library {
*/
int APQ_HWPORT_get_net_device_permit(int device_id, int speed);
/**
* 获取网络设备权限
*
* @param device_id 指定网络设备硬件接口类型 {@link HwportNetDevidEnum}
* @return 返回存放配置内的带宽限速值 {@link HwportNetPermEnum} 权限类型
*/
int APQ_HWPORT_get_net_device_permit(int device_id);
/**
* 设置网络设备权限
* 设置限速选项会启动限速线程,退出程序时需要调用APQ_HWPORT_NET_PERM_NO_LIMIT或者其他不限速的权限清理限速线程
......
package com.priusis.utils;
import lombok.Data;
/**
* @author yanghan
* @date 2020/11/27 16:15
*/
@Data
public class QrCode {
/**设备卡号*/
private String card;
/**校验码*/
private String checkCode;
@Override
public String toString() {
return "QrCode{" +
"card='" + card + '\'' +
", checkCode='" + checkCode + '\'' +
'}';
}
}
package com.priusis.utils;
import com.priusis.exception.ServiceException;
import com.zy.QrDecode.CQrDecode;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class QrCodeUtils {
static int[] result = new int[4];
public static QrCode qrCodeUt(String qrString) {
String path = CQrDecode.parseAbsolutePath("/qr/dat/0000000d.dat", "smart-property/0000000d.dat");
CQrDecode cQrDecode = new CQrDecode();
int i = cQrDecode.ZOOYAPI_GetCodeII(path, qrString, result);
log.info("二维码解码状态:{}, datPath:{}", i, path);
switch (i) {
case 0:
QrCode qrCode = new QrCode();
qrCode.setCard(Integer.toHexString(result[0]));
qrCode.setCheckCode(Integer.toString(result[1]));
return qrCode;
case 4001:
throw new ServiceException("key file path error or not exist");
case 4003:
throw new ServiceException("key file open fail");
case 4005:
throw new ServiceException("qr-code is not match current key file");
default:
return null;
}
}
}
package com.zy.QrDecode;
import com.sun.jna.Platform;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.system.ApplicationHome;
import java.io.File;
import java.io.UnsupportedEncodingException;
@Slf4j
public class CQrDecode {
static {
/*
dll 问题
IDEA中通过load加载
或者配置loadLibrary,都是要配置 -Djava.library.path=D:\work\priusis\projects\ower\QrDecode
*/
try {
String path = parseAbsolutePath("/qr/dll", "/qr/dll");
log.debug("load加载path:{}", path);
if (Platform.isWindows()) {
System.load(path + "/QrDecode.dll");
} else if (Platform.isLinux()) {
String lib = System.getProperty("java.library.path");
lib = path + ":" + lib;
log.debug("load加载 java.library.path:{}", lib);
System.setProperty("java.library.path", lib);
System.loadLibrary("QrDecode");
}
} catch (Exception e) {
log.error("loadLibrary Exception");
}
}
public native int hello(String str);
public native int ZOOYAPI_GetCode(String path, String qrString, int[] result);
public native int ZOOYAPI_GetCodeII(String path, String qrString, int[] result);
/**
* @param relatePath 相对路径 /qr/dat/
* @return
*/
public static String parseAbsolutePath(String relatePath, String defaultPath) {
String path = defaultPath;
if (Platform.isWindows()) {
path = CQrDecode.class.getResource(relatePath).getPath();
path = path.replaceFirst("/", "");//排除中文空格
path = path.replaceAll("%20", " ");//排除中文空格
path = path.replaceAll("/", "\\\\");//排除中文空格
try {
path = java.net.URLDecoder.decode(path, "utf-8"); //解决路径包含中文的情况
} catch (UnsupportedEncodingException e) {
log.error("巡检二维码异常", e);
}
}
if (Platform.isLinux()) {
try {
ApplicationHome h = new ApplicationHome(CQrDecode.class);
File jarF = h.getSource();
log.debug("load加载jarF:{}", jarF);
log.debug("load加载jarF:{}", jarF.getPath());
path = jarF.getParentFile().toString() + relatePath;
} catch (Exception e) {
log.error("巡检二维码获取path异常:{}", e);
path = "/app/smart-property/qr/dll";
}
}
return path;
}
}
server:
# Server bind address
address: "0.0.0.0"
port: ${random.int[20000,29999]}
port: ${random.int[10000,19999]}
}nsgm?!7G*X2pErfK0%XjStԮr{=^<Sa
\ No newline at end of file
......@@ -48,7 +48,7 @@ public class ApqRegisterApplication {
@Autowired
private RestTemplate restTemplate;
@Scheduled(fixedDelay = FIXED_DELAY)
@Scheduled(fixedDelay = 60000L)
protected void registerProgramTask() {
// 获取软件检测监控配置 params == data
ResponseEntity<MqttRpcDataMessage> forEntity = restTemplate.getForEntity("http://localhost:8765/rpc_cmd/register", MqttRpcDataMessage.class);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论