From 3b0516a2959e25576e4f3fda697a3b025d06c8c9 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 24 六月 2025 14:09:07 +0800
Subject: [PATCH] 每日录像可用指标添加日志,修改大屏为查看当前月平均
---
ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java | 163 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 145 insertions(+), 18 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java b/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java
index 5d3b406..c169561 100644
--- a/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java
+++ b/ycl-server/src/main/java/com/ycl/api/DH/module/LoginModule.java
@@ -2,6 +2,7 @@
import com.sun.jna.Native;
import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import com.ycl.api.DH.lib.NetSDKLib;
import com.ycl.api.DH.lib.NetSDKLib.LLong;
@@ -17,12 +18,17 @@
import java.io.File;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.List;
+import static com.ycl.api.DH.lib.NetSDKLib.CFG_CMD_VIDEOWIDGET;
+import static com.ycl.api.DH.lib.NetSDKLib.NET_DEV_VIDEO_OSD_CFG;
import static com.ycl.api.DH.lib.NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN;
import static com.ycl.api.DH.lib.enumeration.NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_CUSTOMTITLE;
import static com.ycl.api.DH.lib.enumeration.NET_EM_CFG_OPERATE_TYPE.NET_EM_CFG_GBMODE;
@@ -153,14 +159,13 @@
return bRet;
}
- public static OSDResult getOsd(String serialNumber,LLong loginId) {
+ public static OSDResult getOsd(String serialNumber, LLong loginId) {
OSDResult osdResult = new OSDResult();
NetSDKLib.NET_TIME deviceTime = new NetSDKLib.NET_TIME();
if (!netsdk.CLIENT_QueryDeviceTime(loginId, deviceTime, 3000)) {
// log.error("CLIENT_QueryDeviceTime Failed!" + ToolKits.getErrorCodePrint());
return null;
}
- log.info("OSD鏃堕棿鍘熷鏁版嵁鏍煎紡,{},toString鏍煎紡{}",deviceTime,deviceTime.toStringTime());
Date checkTime = new Date();
osdResult.setCheckTime(checkTime);
String date = deviceTime.toStringTime();
@@ -173,7 +178,6 @@
// log.error("鏃堕棿瑙f瀽澶辫触");
}
NET_CFG_GBMODE_INFO reserve = new NET_CFG_GBMODE_INFO();
-
NET_CFG_GBMODE_INFO osdInfo = new NET_CFG_GBMODE_INFO();
osdInfo.write();
boolean b = false;
@@ -183,9 +187,9 @@
* 瀵逛簬澶у崕鏉ヨ锛� 鍥芥爣鍊�7: 0/鍏ㄦ櫙/閫氶亾1 1/缁嗚妭/閫氶亾2
* 瀹囪鍗曢�氶亾涓嶈�冭檻
*/
- if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All ) {
+ if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All) {
b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 0, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer());
- }else if(serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail){
+ } else if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail) {
b = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_GBMODE, 1, osdInfo.getPointer(), osdInfo.size(), 3000, reserve.getPointer());
}
@@ -196,34 +200,41 @@
osdInfo.read();
NET_GBMODE_CUSTOMTITLE_INFO[] stuCustomTitle = osdInfo.stuCustomTitle;
for (NET_GBMODE_CUSTOMTITLE_INFO title : stuCustomTitle) {
- log.info("OSD鍘熷鏁版嵁鏍煎紡{}",title);
String position = new String(title.szPositon, StandardCharsets.UTF_8).trim();
- if("LeftDown".equals(position)) {
+ if ("LeftDown".equals(position)) {
NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD;
for (NET_TITLE_OSD_INFO osd : stuOSD) {
String osdStr = null;
osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim();
-// log.info("TEXT锛�"+osdStr);
+ log.error("DHTEXTLeftDown锛�"+osdStr);
if (!StringUtils.isEmpty(osdStr)) {
osdResult.setOSD4(osdStr);
}
}
- }else if("RightDown".equals(position)){
+ } else if ("RightDown".equals(position)) {
NET_TITLE_OSD_INFO[] stuOSD = title.stuOSD;
int num = 0;
for (NET_TITLE_OSD_INFO osd : stuOSD) {
String osdStr = null;
osdStr = new String(osd.szText, StandardCharsets.UTF_8).trim();
-// log.info("TEXT锛�"+osdStr);
+ log.error("DHTEXTRightDown锛�"+osdStr);
if (!StringUtils.isEmpty(osdStr)) {
- if(num ==0){
- osdResult.setOSD1(osdStr);
- }else if(num ==1){
- osdResult.setOSD2(osdStr);
- }else if(num ==2){
- osdResult.setOSD3(osdStr);
- }else if(num ==3){
- osdResult.setName(osdStr);
+ if (osdStr.contains("|")) {
+ String[] osdNames = osdStr.split("\\|");
+ osdResult.setOSD1(osdNames[0]);
+ osdResult.setOSD2(osdNames[1]);
+ osdResult.setOSD3(osdNames[2]);
+ osdResult.setName(osdNames[3]);
+ } else {
+ if (num == 0) {
+ osdResult.setOSD1(osdStr);
+ } else if (num == 1) {
+ osdResult.setOSD2(osdStr);
+ } else if (num == 2) {
+ osdResult.setOSD3(osdStr);
+ } else if (num == 3) {
+ osdResult.setName(osdStr);
+ }
}
}
num++;
@@ -235,4 +246,120 @@
return osdResult;
}
+ /**
+ * 閽堝鍒╂棫璁惧鑾峰彇OSD鐨勬柟娉�
+ *
+ * @param serialNumber
+ * @param loginId
+ * @return
+ */
+ public static OSDResult getOsdOld(String moName,String serialNumber, LLong loginId) {
+ OSDResult result = new OSDResult();
+ NetSDKLib.NET_OSD_CUSTOM_TITLE osdInfo4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE();
+ osdInfo4.emOsdBlendType = NetSDKLib.NET_EM_OSD_BLEND_TYPE.NET_EM_OSD_BLEND_TYPE_MAIN;
+ NetSDKLib.NET_OSD_CUSTOM_TITLE reserve4 = new NetSDKLib.NET_OSD_CUSTOM_TITLE();
+ osdInfo4.write();
+ boolean e = false;
+ if (moName.startsWith("DX_R2")){ //鍒ゆ柇璁惧鏄惁鏄疍X_R2寮�澶�
+ if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All) {
+ e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer());
+ }
+ else if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail) {
+ e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 1, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer());
+ }
+ if (!e) {
+ log.error("e涓虹┖");
+ }
+ }else if(moName.startsWith("DX_RD")){ //鍒ゆ柇璁惧鏄惁鏄疍X_RD寮�澶�
+ if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_All) {
+ e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer());
+ }
+ else if (serialNumber.charAt(ApiConstants.SerialNumber_Channel) == ApiConstants.SerialNumber_Detail) {
+ e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 1, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer());
+ }
+ if (!e) {
+ log.error("e涓虹┖");
+ }
+ }else {
+ e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 0, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer());
+ if (!e) {
+ log.error("e涓虹┖,灏濊瘯鍙︿竴涓�氶亾");
+ e = netsdk.CLIENT_GetConfig(loginId, NET_EM_CFG_CUSTOMTITLE, 1, osdInfo4.getPointer(), osdInfo4.size(), 3000, reserve4.getPointer());
+ }
+ }
+ if (e) {
+ osdInfo4.read();
+ NetSDKLib.NET_CUSTOM_TITLE_INFO[] stuCustomTitle = osdInfo4.stuCustomTitle;
+ for (NetSDKLib.NET_CUSTOM_TITLE_INFO net_custom_title_info : stuCustomTitle) {
+ String name = new String(net_custom_title_info.szText, StandardCharsets.UTF_8).trim();
+ log.error("DHname:{}", name);
+ if (StringUtils.isNotEmpty(name) && name.contains("|")) {
+ String[] osdNames = name.split("\\|");
+ //鍓旈櫎鎺夌┖涓�
+// List<String> nonEmptyList = new ArrayList<>();
+// for (String osd : osdNames) {
+// if (StringUtils.isNotEmpty(osd)) {
+// nonEmptyList.add(osd);
+// }
+// }
+ for (int i = 0; i < osdNames.length; i++) {
+ if (i == 0) {
+ result.setOSD1(osdNames[i]);
+ }
+ if (i == 1) {
+ result.setOSD2(osdNames[i]);
+ }
+ if (i == 2) {
+ result.setOSD3(osdNames[i]);
+ }
+ if (i == 3) {
+ result.setName(osdNames[i]);
+ }
+ }
+
+
+ }
+ }
+
+
+ } else {
+ log.error(serialNumber, "鍒╂棫osd涓虹┖");
+ }
+
+ return result;
+ }
+
+ /**
+ * 鑾峰彇鍗曚釜閰嶇疆
+ *
+ * @param hLoginHandle 鐧婚檰鍙ユ焺
+ * @param nChn 閫氶亾鍙凤紝-1 琛ㄧず鍏ㄩ�氶亾
+ * @param strCmd 閰嶇疆鍚嶇О
+ * @param cmdObject 閰嶇疆瀵瑰簲鐨勭粨鏋勪綋瀵硅薄
+ * @return 鎴愬姛杩斿洖 true
+ */
+ public static boolean GetDevConfig(LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) {
+ boolean result = false;
+ IntByReference error = new IntByReference(0);
+ int nBufferLen = 2 * 1024 * 1024;
+ byte[] strBuffer = new byte[nBufferLen];
+
+ if (netsdk.CLIENT_GetNewDevConfig(hLoginHandle, strCmd, nChn, strBuffer, nBufferLen, error, 3000, null)) {
+ cmdObject.write();
+ if (netsdk.CLIENT_ParseData(strCmd, strBuffer, cmdObject.getPointer(),
+ cmdObject.size(), null)) {
+ cmdObject.read();
+ result = true;
+ } else {
+ System.err.println("Parse " + strCmd + " Config Failed!" + ToolKits.getErrorCodePrint());
+ result = false;
+ }
+ } else {
+ System.err.println("璋冪敤澶辫触");
+ result = false;
+ }
+
+ return result;
+ }
+
}
--
Gitblit v1.8.0