Administrator 1 lună în urmă
părinte
comite
2ba9b197fa
2 a modificat fișierele cu 81 adăugiri și 13 ștergeri
  1. 3 2
      src/main/kotlin/cn/qqck/kotlin/tools/Extra.kt
  2. 78 11
      src/test/kotlin/Main.kt

+ 3 - 2
src/main/kotlin/cn/qqck/kotlin/tools/Extra.kt

@@ -31,11 +31,12 @@ class DeferScope {
     private val defers = ArrayDeque<() -> Unit>()
 
     fun defer(block: () -> Unit) {
-        this.defers.addLast(block)
+        this.defers.addFirst(block)
     }
 
     fun release() {
-        while (this.defers.isNotEmpty()) this.defers.removeLast()()
+        this.defers.forEach { it() }
+        this.defers.clear()
     }
 }
 

+ 78 - 11
src/test/kotlin/Main.kt

@@ -1,25 +1,25 @@
 import cn.qqck.kotlin.tools.*
+import java.io.File
 
 fun main() {
-    // println("Date.day(1)".toIntOrNull())
-    // println("192.168.1.1".isIpv4())
-    println("2409:8c1e:75b0:1120::16".hide(pre_len = 5, suf_len = 7, hs_max = 3))
-    // println("fe80::1ff:fe23:4567:890a".isIpv6())
-    // println(Android.random())
-    // println(register_queue.isNet())
-    // register_queue.get()
+    // 机型对比()
     // ggcz_用户()
+    runDefer {
+        defer { println(1) }
+        defer { println(2) }
+        defer { println(3) }
+    }
 }
 
 fun ggcz_用户() {
     val j_索引 = mutableMapOf<String, String>()
     j_索引["1"] = "admin"
-    "C:\\Users\\Administrator\\Desktop\\用户.sql".fget()?.string()?.split("\n")?.forEach {
+    "C:\\Users\\Administrator\\Desktop\\web_20250322_153400".fget()?.string()?.split("\n")?.forEach {
         val j_item = it.split("----")
         if (j_item.size != 10) return@forEach
         j_索引[j_item[0]] = j_item[2]
     }
-    "C:\\Users\\Administrator\\Desktop\\用户.sql".fget()?.string()?.split("\n")?.forEach {
+    "C:\\Users\\Administrator\\Desktop\\web_20250322_153400".fget()?.string()?.split("\n")?.forEach {
         val j_item = it.split("----")
         if (j_item.size != 10) return@forEach
         val j_id = j_item[0]
@@ -36,8 +36,75 @@ fun ggcz_用户() {
         if (j_备注 == "\"\"") j_备注 = ""
         if (j_权限.startsWith("\"")) j_权限 = j_权限.removePrefix("\"").removeSuffix("\"")
         val j_sql =
-            "INSERT INTO ggcz_用户 (uid, 账号, 密码, 昵称, 备注, 权限, 状态, 上级id) VALUES ('${Rand.str.num_aZ(68)}','${j_账号}','${j_密码}','${j_昵称}','${j_备注}','${j_权限}','${j_状态}',(SELECT id FROM ggcz_用户 WHERE 账号 = '${j_索引[j_上级id]}'));\n"
-        "C:\\Users\\Administrator\\Desktop\\用户2.sql".fset(j_sql, append = true)
+            "INSERT INTO ggcz_用户 (uid, 账号, 密码, 昵称, 备注, 权限, 状态, 上级id) VALUES ('${j_uid}','${j_账号}','${j_密码}','${j_昵称}','${j_备注}','${j_权限}','${j_状态}',(SELECT id FROM ggcz_用户 WHERE 账号 = '${j_索引[j_上级id]}'));\n"
+        "C:\\Users\\Administrator\\Desktop\\用户.sql".fset(j_sql, append = true)
         print(j_sql)
     }
 }
+
+fun 机型对比() {
+    val j_原始 = mutableMapOf<String, String>()
+    val j_社死 = mutableMapOf<String, String>()
+    val j_存活机型 = mutableListOf<String>()
+    val j_社死机型 = mutableListOf<String>()
+    val j_root = "C:\\Users\\Administrator\\Desktop\\3\\3.10\\"
+    "${j_root}存活机型.txt".fget()?.string()?.split("\r\n")?.forEach { if (it.isNotEmpty()) j_存活机型.add(it) }
+    "${j_root}社死机型.txt".fget()?.string()?.split("\r\n")?.forEach { if (it.isNotEmpty()) j_社死机型.add(it) }
+
+    "${j_root}原始.txt".fget()?.string()?.split("\r\n")?.forEach {
+        val j_item = it.split("----")
+        if (j_item.isEmpty()) return@forEach
+        val j_uin = j_item[0].toLongOrNull() ?: return@forEach
+        if (j_uin in 10000..9999999999) j_原始[j_item[0]] = ""
+    }
+    "${j_root}成功.txt".fget()?.string()?.split("\r\n")?.forEach {
+        val j_item = it.split("----")
+        if (j_item.isEmpty()) return@forEach
+        val j_uin = j_item[0].toLongOrNull() ?: return@forEach
+        if (j_uin in 10000..9999999999 && !j_原始.containsKey(j_item[0])) j_社死[j_item[0]] = ""
+    }
+    File("${j_root}备份包").listFiles { j_file -> j_file.isFile && j_file.extension == "txt" }?.forEach { j_file ->
+        // 文件名: _1742117856_3977410109.txt
+        """_(\d+)_(\d+)\.txt""".toRegex().matchEntire(j_file.name)?.also {
+            val (_, j_uin) = it.destructured
+            val j_json = j_file.readText().json().asObject() ?: return@also
+            val j_brand = j_json["brand"]?.asString() ?: return@also
+            val j_board = j_json["board"]?.asString() ?: return@also
+            val j_device = j_json["device"]?.asString() ?: return@also
+            val j_model = j_json["model"]?.asString() ?: return@also
+            val j_bootId = j_json["bootId"]?.asString() ?: return@also
+            val j_phoneNumber = j_json["phoneNumber"]?.asString() ?: return@also
+            // val j_标识 = "品牌:${j_brand},型号:${j_model},设备:${j_device},主板:${j_board}"
+            val j_标识 = j_phoneNumber
+            if (j_原始.containsKey(j_uin)) {
+                j_原始[j_uin] = j_标识
+                j_存活机型.add(j_标识)
+            } else if (j_社死.containsKey(j_uin)) {
+                j_社死[j_uin] = j_标识
+                j_社死机型.add(j_标识)
+            }
+        }
+    }
+    j_存活机型.forEach {
+        if (j_社死机型.contains(it)) {
+            println("存活机型在社死机型中:${it}")
+        }
+    }
+    var j_data = ""
+    j_存活机型.forEach {
+        j_data += it + "\r\n"
+    }
+    "${j_root}存活机型.txt".fset(j_data)
+    println("---------------------------------------------------------")
+    j_社死机型.forEach {
+        if (j_存活机型.contains(it)) {
+            println("社死机型在存活机型中:${it}")
+        }
+    }
+    j_data = ""
+    j_社死机型.forEach {
+        j_data += it + "\r\n"
+    }
+    "${j_root}社死机型.txt".fset(j_data)
+    println("---------------------------------------------------------")
+}