cc 3 miesięcy temu
rodzic
commit
f43d81a163

BIN
QingJian/db/5w8mf4kf


+ 1 - 0
src/main/java/com/qingjian/common/cache/CaseDataCache.java

@@ -38,6 +38,7 @@ public class CaseDataCache {
     private static final Object lock = new Object();
 
     public static void initCache() {
+        PERSON_LIB_NO_MAP.clear();
         initPersonLibNoCache();
     }
 

+ 40 - 5
src/main/java/com/qingjian/common/utils/TowerUtils.java

@@ -1,6 +1,7 @@
 package com.qingjian.common.utils;
 
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ReUtil;
 import cn.hutool.core.util.StrUtil;
 import com.qingjian.common.constants.PathConst;
 import com.sun.jna.ptr.DoubleByReference;
@@ -24,8 +25,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
 @Slf4j
 public class TowerUtils {
 
-    private static final int ADDRESS_BUFFER_SIZE = 2048;
+    private static final int ADDRESS_BUFFER_SIZE = 1024;
     private static final AtomicBoolean FLAG = new AtomicBoolean(false);
+    // 16进制判断正则
+    private static final String lacCellReg = ".*[A-Fa-f].*";
 
     /**
      * 根据操作系统类型返回对应的动态链接库路径
@@ -93,12 +96,15 @@ public class TowerUtils {
      * 返回示例:[35.994564, 12.468795, 123, "北京市朝阳xxx4号楼;望京街xx163米"]
      * </p>
      */
-    public static Object[] getCells(int mcc, int mnc, int lac, int ci) {
+    public static Object[] getCells(int mcc, int mnc, String lac, String ci) {
         Object[] result = new Object[4];
         if (!FLAG.get()) {
             return result;
         }
-
+        Radix radix = convertRadix(lac, ci);
+        if (!radix.status) {
+            return result;
+        }
         // 创建用于接收查询结果的引用对象
         DoubleByReference latitude = new DoubleByReference(0.0);   // WGS84 纬度
         DoubleByReference longitude = new DoubleByReference(0.0);  // WGS84 经度
@@ -106,7 +112,7 @@ public class TowerUtils {
 
 
         // 调用本地库查询基站信息
-        int queryResult = CellDll.INSTANCE_DLL.cell_query_combined(mcc, mnc, lac, ci,
+        int queryResult = CellDll.INSTANCE_DLL.cell_query_combined(mcc, mnc, radix.lac, radix.cid,
                 CellDll.COORD_WGS84, latitude, longitude, combined, combined.length);
         // 如果查询失败,返回空数组
         if (queryResult != 0) {
@@ -122,7 +128,36 @@ public class TowerUtils {
         result[2] = 0;
 
         // 逆地理编码依旧使用原始 WGS84 坐标,保持与现有 native 接口行为一致。
-        result[3] = StrUtil.str(combined, StandardCharsets.UTF_8);
+        String str = StrUtil.str(combined, StandardCharsets.UTF_8);
+        if (StrUtil.isNotEmpty(str)) {
+            result[3] = str.trim();
+        }
         return result;
     }
+
+    private static Radix convertRadix(String lacStr, String ci) {
+        // 判断是否为16进制
+        boolean lacMatch = ReUtil.isMatch(lacCellReg, lacStr);
+        boolean ciMatch = ReUtil.isMatch(lacCellReg, ci);
+        long lac;
+        if (lacMatch) {
+            lac = Long.parseLong(lacStr, 16);
+        } else {
+            lac = Long.parseLong(lacStr);
+        }
+        long cid;
+        if (ciMatch) {
+            cid = Long.parseLong(ci, 16);
+        } else {
+            cid = Long.parseLong(ci);
+        }
+        if (cid <= Integer.MAX_VALUE) {
+            return new Radix(true, (int) lac, (int) cid);
+        }
+        return new Radix(false, 0, 0);
+    }
+
+    private record Radix(boolean status, int lac, int cid) {
+
+    }
 }

+ 2 - 3
src/main/java/com/qingjian/module/dm/clean/AbstractCallRecordDataLoader.java

@@ -64,9 +64,8 @@ public abstract class AbstractCallRecordDataLoader<S> extends AbstractDataLoader
             Integer mnc = phone(record.getOperatorId());
             if (mnc != -1) {
                 try {
-                    int lacInt = Integer.parseInt(lac);
-                    int cellIdInt = Integer.parseInt(cellId);
-                    Object[] cells = TowerUtils.getCells(460, mnc, lacInt, cellIdInt);
+
+                    Object[] cells = TowerUtils.getCells(460, mnc, lac, cellId);
                     // 纬度
                     Object lat = cells[0];
                     // 经度

+ 1 - 0
src/main/java/com/qingjian/module/person/service/PersonBasicInfoService.java

@@ -125,6 +125,7 @@ public class PersonBasicInfoService extends ServiceImpl<PersonBasicInfoMapper, P
         if (CollUtil.isNotEmpty(personLibNos)) {
             personLibNoMapper.insert(personLibNos);
         }
+        CaseDataCache.initCache();
     }
 
     /**

+ 7 - 0
src/test/java/features/HelloTest.java

@@ -3,6 +3,7 @@ package features;
 import com.qingjian.App;
 
 import com.qingjian.common.constants.PathConst;
+import com.qingjian.common.utils.TowerUtils;
 import org.junit.jupiter.api.Test;
 
 import org.noear.solon.test.HttpTester;
@@ -12,6 +13,7 @@ import java.io.IOException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
+import java.util.Arrays;
 import java.util.Properties;
 
 @SolonTest(App.class)
@@ -31,4 +33,9 @@ public class HelloTest extends HttpTester {
         connection.createStatement().execute("CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT)");
         connection.close();
     }
+
+    static void main() {
+        TowerUtils.init();
+        System.out.println(Arrays.toString(TowerUtils.getCells(460, 1, "829B", "A5F2")));
+    }
 }