Forráskód Böngészése

修改:文件分割算法更新

GDW 1 hete
szülő
commit
1bee9ca2b7

+ 14 - 1
src/main/java/cn/lttc/modules/lttcsamplescan/service/impl/SampleScanServiceImpl.java

@@ -8,6 +8,7 @@ import cn.lttc.modules.lttcsamplescan.mapper.SampleScanMapper;
 import cn.lttc.modules.lttcsamplescan.service.ISampleScanService;
 import cn.lttc.modules.utils.HttpUtils;
 import com.alibaba.fastjson.JSON;
+import lombok.val;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -131,7 +132,8 @@ public class SampleScanServiceImpl implements ISampleScanService {
                 imgList.add(mulReq.getFile(paramName));
             } else if (paramName.startsWith("detail")) {
                 //name是detail开头的为单据详情所属图片
-                String substring = paramName.substring(7, 9);
+//                String substring = paramName.substring(7, 9);
+                String substring = extractBetweenDashes(paramName);
                 if (!detailsImgMapList.containsKey(substring)) {
                     detailsImgMapList.put(substring, new ArrayList<>());
                 }
@@ -316,4 +318,15 @@ public class SampleScanServiceImpl implements ISampleScanService {
 
         return result;
     }
+
+    public String extractBetweenDashes(String input) {
+        int firstDash = input.indexOf('-'); // 找到第一个"-"的位置
+        if (firstDash == -1) return null; // 没有找到第一个"-"
+
+        int secondDash = input.indexOf('-', firstDash + 1); // 从第一个"-"后开始找第二个"-"的位置
+        if (secondDash == -1) return null; // 没有找到第二个"-"
+
+        // 提取两个"-"之间的子串
+        return input.substring(firstDash + 1, secondDash);
+    }
 }