| 
					
				 | 
			
			
				@@ -1,125 +0,0 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-package com.nokia.tsl_data; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.csv.CSVFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.csv.CSVParser; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.csv.CSVPrinter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.apache.commons.csv.CSVRecord; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.junit.jupiter.api.Test; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.nio.charset.StandardCharsets; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.text.DateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.text.ParseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.concurrent.CompletableFuture; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.concurrent.ExecutionException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-@Slf4j 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-public class MainTest { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Test 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    void test() throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String path1 = "D:\\src\\20231023\\移网网络体验明细_202310230930.csv"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String path2 = "D:\\src\\20231023\\customerservice_firstline_log_202310231617.csv"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String out = "D:\\src\\20231023\\移网网络体验明细_202310230930--.csv"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        DateFormat dateFormat1 = new SimpleDateFormat("yyyy/M/d HH:mm"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        DateFormat dateFormat2 = new SimpleDateFormat("yyyyMMdd=="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CSVFormat csvFormat = CSVFormat.DEFAULT.builder().setHeader().build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CSVParser parse1 = csvFormat.parse(new InputStreamReader(new FileInputStream(path1), "gbk")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CSVParser parse2 = csvFormat.parse(new InputStreamReader(new FileInputStream(path2), "gbk")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        parse2.getHeaderMap().forEach((k, v) -> System.out.println(k + "===" + v)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 存储2表对应关系 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, CSVRecord> map2 = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (CSVRecord record : parse2.getRecords()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String key = record.get(78).substring(0, 8) + "==" + record.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                map2.put(key, record); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                System.out.println("=============" + record.get(78)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        System.out.println(parse2.getRecords().size() + "=============================="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<String> outHeader = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        outHeader.addAll(parse1.getHeaderNames()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        outHeader.addAll(parse2.getHeaderNames()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CSVPrinter printer = CSVFormat.DEFAULT.builder().setHeader(outHeader.toArray(new String[0])).build().print(new OutputStreamWriter(new FileOutputStream(out), "gbk")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        parse1.forEach(record -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String key = dateFormat2.format(dateFormat1.parse(record.get(2))) + record.get(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                for (String s : record) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    printer.print(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                CSVRecord record1 = map2.get(key); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (record1 != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    for (String s : record1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        printer.print(s); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                printer.println(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } catch (ParseException | IOException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Test 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    void test1() throws ExecutionException, InterruptedException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 线程池 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        taskScheduler.setPoolSize(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        taskScheduler.setThreadNamePrefix("taskSchedulerThreadPool-"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        taskScheduler.initialize(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 数据入库1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CompletableFuture<Void> task1 = CompletableFuture.runAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("数据入库1==="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new RuntimeException("数据入库1出错"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }, taskScheduler).exceptionally(e -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new RuntimeException("数据入库1出错==="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 数据入库2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CompletableFuture<Void> task2 = CompletableFuture.runAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("数据入库2==="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new RuntimeException("数据入库2出错"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }, taskScheduler); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 数据入库3 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CompletableFuture<Void> task3 = CompletableFuture.runAsync(() -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("数据入库3==="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new RuntimeException("数据入库3出错"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }, taskScheduler); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CompletableFuture.allOf(task1, task2, task3).thenRunAsync(() -> log.info("入库完成......")).exceptionally(e -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("exceptionally......"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        }).get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("done!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Test 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    void test2() throws IOException { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String filePath = "D:\\src\\DM_M_QT_VOLET_USER_PROV_202309_1170011851488288768.csv"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String filePath2 = "D:\\src\\DM_M_QT_VOLET_USER_PROV_202309_1170011851488288768-筛选后.csv"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CSVFormat csvFormat = CSVFormat.DEFAULT.builder().build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CSVParser csvParser = csvFormat.parse(new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        CSVPrinter csvPrinter = csvFormat.print(new OutputStreamWriter(new FileOutputStream(filePath2), "gbk")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        for (CSVRecord record : csvParser.getRecords()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ("1".equals(record.get(12))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                csvPrinter.printRecord(record); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        csvParser.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        csvPrinter.close(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-} 
			 |