Эх сурвалжийг харах

feat(1): TenpayRegInfo(个人注册信息)

洪海涛 5 сар өмнө
parent
commit
76c86300c0

+ 60 - 49
src/main/java/ieven/server/webapp/domain/file/FileService.java

@@ -256,60 +256,22 @@ public class FileService {
                         int curRow = 0;
                         boolean processNext = false;
                         boolean lineAccount = false;
-
+                        boolean tenpayPersonalRegInfo = false; // 判断是否: TenpayRegInfo(个人注册信息)
+                        int isMerchant = 0; // 判断是否: 商户注册信息
+                        HashMap<String, String> merchantMap = new HashMap<>();
+                        List<String> headers = TenpayHeaders.getHeaders(11);
 
                         for (String line : lines) {
-                            if (line.equals("注销信息")) {
-                                continue;
-                            }
-                            if (processNext) {
-                                List<String> values = Arrays.asList(line.split("\t"));
-                                if (values.size() > 1) {
-                                    mongoExcelService.getRows(
-                                            0,
-                                            curRow,
-                                            values.stream().map(PublicStatic::removeAllSpecial).collect(Collectors.toList())
-                                    );
-                                    curRow++;
-                                }
-                                break;
-                            }
-                            /*
-                            *   // 定义需要检查的字段
-                            String[] requiredFields = {"账户状态", "账号", "注册姓名", "注册时间", "注册身份证号"};
-                            // 将行拆分为字段数组
-                            String[] fields = line.split("\t");
-
-                            // 检查每个必要字段是否存在
-                            for (String field : requiredFields) {
-                                if (contains(fields, field) && !lineAccount) {
-                                    lineAccount = true;
-                                }
-                            }
-                            * */
-                            if (line.contains("账户状态\t账号\t注册姓名\t注册时间\t注册身份证号\t绑定手机\t绑定状态")) {
-                                // 先存储表头行
-                                mongoExcelService.getRows(
-                                        0,
-                                        curRow,
-                                        Arrays.stream(line.split("\t"))
-                                                .map(PublicStatic::removeAllSpecial)
-                                                .collect(Collectors.toList())
-                                );
-                                curRow++;
-                                processNext = true;
+                            if (line.contains("账户状态\t账号\t注册姓名\t注册时间\t注册身份证号\t绑定手机\t绑定状态") && !tenpayPersonalRegInfo) {
+                                tenpayPersonalRegInfo = true;
                             }
                         }
 
-                        int isMerchant = 0; // 商户注册信息
-                        HashMap<String, String> merchantMap = new HashMap<>();
-                        List<String> headers = TenpayHeaders.getHeaders(11);
+
                         for (String line : lines) {
                             try {
-
                                 for (String header : headers) {
                                     if (line.contains(header)) {
-                                        // Split each line into left and right parts
                                         String[] merchantLine = line.split(":");
                                         String key = merchantLine[0].trim();
                                         String value = merchantLine.length < 2 ? "" : merchantLine[1].trim();
@@ -328,12 +290,44 @@ public class FileService {
                             }
                         }
                         System.out.println(merchantMap);
-                        /*财付通-商户注册信息 */
-                        if(merchantMap.size() > 8) {
+
+                        if(tenpayPersonalRegInfo) {
+                            /*财付通-用户注册信息处理逻辑*/
+                            for (String line : lines) {
+                                if (line.equals("注销信息")) {
+                                    continue;
+                                }
+                                if (processNext) {
+                                    List<String> values = Arrays.asList(line.split("\t"));
+                                    if (values.size() > 1) {
+                                        mongoExcelService.getRows(
+                                                0,
+                                                curRow,
+                                                values.stream().map(PublicStatic::removeAllSpecial).collect(Collectors.toList())
+                                        );
+                                        curRow++;
+                                    }
+                                    break;
+                                }
+                                if (line.contains("账户状态\t账号\t注册姓名\t注册时间\t注册身份证号\t绑定手机\t绑定状态")) {
+                                    // 先存储表头行
+                                    mongoExcelService.getRows(
+                                            0,
+                                            curRow,
+                                            Arrays.stream(line.split("\t"))
+                                                    .map(PublicStatic::removeAllSpecial)
+                                                    .collect(Collectors.toList())
+                                    );
+                                    curRow++;
+                                    processNext = true;
+                                }
+                            }
+                        } else if(merchantMap.size() > 8) {
+                            /*财付通-商户注册信息 */
                             String bankNo = merchantMap.get("绑定银行卡号");
                             /*
-                            * "商户账号", "商户名", "注册时间", "证件号",  "邮箱", "绑定手机", "银行账户名", "绑定银行", "绑定银行卡号", "商户地址"
-                            * */
+                             * "商户账号", "商户名", "注册时间", "证件号",  "邮箱", "绑定手机", "银行账户名", "绑定银行", "绑定银行卡号", "商户地址"
+                             * */
                             String[] bankNoArray = bankNo.split(",");
                             mongoExcelService.getRows(
                                     0,
@@ -363,6 +357,23 @@ public class FileService {
                                         row
                                 );
                             }
+                        } else {
+                             // 其他
+                            for (String string : lines) {
+                                if (string.equals("注销信息")) {
+                                    break;
+                                }
+                                List<String> values = Arrays.asList(string.split("\t"));
+                                if (values.size() <= 1) {
+                                    continue;
+                                }
+                                mongoExcelService.getRows(
+                                        0,
+                                        curRow,
+                                        values.stream().map(PublicStatic::removeAllSpecial).collect(Collectors.toList())
+                                );
+                                curRow++;
+                            }
                         }
                         mongoExcelService.insertRest();
                     }