From 7e68f81b38116bba40e70620c563168fcde66a37 Mon Sep 17 00:00:00 2001
From: L <L@132>
Date: 星期五, 05 十二月 2025 09:18:38 +0800
Subject: [PATCH] *

---
 src/main/java/com/zy/asrs/utils/BarcodeUtils.java |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/zy/asrs/utils/BarcodeUtils.java b/src/main/java/com/zy/asrs/utils/BarcodeUtils.java
index ac3c396..9823ef5 100644
--- a/src/main/java/com/zy/asrs/utils/BarcodeUtils.java
+++ b/src/main/java/com/zy/asrs/utils/BarcodeUtils.java
@@ -52,4 +52,40 @@
                 return Integer.parseInt(staNo);
         }
     }
+
+    public static String formatCode(String input) {
+        if (input == null || input.length() != 7 || !input.matches("\\d+")) {
+            throw new IllegalArgumentException("杈撳叆蹇呴』鏄�7浣嶆暟瀛�");
+        }
+
+        // 鏍规嵁绀轰緥鍒嗘瀽鎷嗗垎瑙勫垯锛�
+        // "0500708" -> "05", "07", "08" (璺宠繃绗�3浣�)
+        // "0201001" -> "02", "10", "01"
+        // "1001010" -> "10", "10", "10"
+        // "0500210" -> "05", "02", "10"
+
+        // 鎷嗗垎瑙勫垯锛氱1-2浣嶏紝绗�4-5浣嶏紝绗�6-7浣嶏紙璺宠繃绗�3浣嶏級
+        String part1 = input.substring(0, 2);  // 鍓嶄袱浣�
+        String part2 = input.substring(3, 5);  // 绗�4-5浣嶏紙璺宠繃绗�3浣嶏級
+        String part3 = input.substring(5, 7);  // 绗�6-7浣�
+
+        // 鍘婚櫎鍓嶅闆跺苟鏍煎紡鍖栦负涓や綅鏁�
+        String formattedPart1 = String.format("%02d", Integer.parseInt(part1));
+        String formattedPart2 = String.format("%02d", Integer.parseInt(part2));
+        String formattedPart3 = String.format("%02d", Integer.parseInt(part3));
+
+        return "F-F01-" + formattedPart1 + "-" + formattedPart2 + "-" + formattedPart3;
+    }
+
+    public static void main(String[] args) {
+        // 娴嬭瘯鎵�鏈夌ず渚�
+        System.out.println("0500708 -> " + formatCode("0500708")); // F-F01-05-07-08
+        System.out.println("0201001 -> " + formatCode("0201001")); // F-F01-02-10-01
+        System.out.println("1001010 -> " + formatCode("1001010")); // F-F01-10-10-10
+        System.out.println("0500210 -> " + formatCode("0500210")); // F-F01-05-02-10
+
+        // 楠岃瘉闀垮害鏄惁涓�14涓瓧绗�
+        String result = formatCode("1000110");
+        System.out.println("缁撴灉闀垮害: " + result.length() + " 瀛楃: " + result);
+    }
 }

--
Gitblit v1.9.1