|
@@ -23,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.xml.bind.DatatypeConverter;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.SocketTimeoutException;
|
|
|
import java.util.ArrayList;
|
|
@@ -85,18 +86,20 @@ public class TrafficRecordsAnalyseServiceImpl implements TrafficRecordsAnalyseSe
|
|
|
try {
|
|
|
// 大文件拆分,放入临时文件夹
|
|
|
CsvUtil.splitFile(files.get(i).getAbsolutePath(), 30, tempFolder);
|
|
|
- for (int j = 1; j <= 30; j++) {
|
|
|
- // 数据脱敏
|
|
|
- List<MonthResult> maskResults = desensitize(j + "", tempFolder + "/temp_" + j + ".csv");
|
|
|
+ } catch (IOException e) {
|
|
|
+ log.error("splitFileError:{}", files.get(i).getAbsolutePath(), e);
|
|
|
+ return new CommonResponseObject().failed();
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int j = 1; j <= 30; j++) {
|
|
|
+ // 数据脱敏
|
|
|
+ List<MonthResult> maskResults = desensitize(j + "", tempFolder + "/temp_" + j + ".csv");
|
|
|
|
|
|
- // 数据分割,推送数据
|
|
|
- push(maskResults);
|
|
|
- boolean deleteResult = FileUtil.INSTANCE.deleteFile(tempFolder + "/temp_" + j + ".csv");
|
|
|
- log.info("deleteTempFile:{}, deleteResult:{}", tempFolder + "/temp_" + j + ".csv", deleteResult);
|
|
|
- maskResults = null;
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ // 数据分割,推送数据
|
|
|
+ push(maskResults);
|
|
|
+ boolean deleteResult = FileUtil.INSTANCE.deleteFile(tempFolder + "/temp_" + j + ".csv");
|
|
|
+ log.info("deleteTempFile:{}, deleteResult:{}", tempFolder + "/temp_" + j + ".csv", deleteResult);
|
|
|
+ maskResults = null;
|
|
|
}
|
|
|
boolean deleteResult = FileUtil.INSTANCE.deleteDirectory(tempFolder);
|
|
|
log.info("deleteTempDir:{}, deleteResult:{}", tempFolder, deleteResult);
|
|
@@ -107,6 +110,8 @@ public class TrafficRecordsAnalyseServiceImpl implements TrafficRecordsAnalyseSe
|
|
|
|
|
|
@Override
|
|
|
public CommonResponseObject pushErrorRecords(String filePath) {
|
|
|
+ log.info("pushErrorRecordsBegin");
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
List<File> files = new ArrayList<>();
|
|
|
File folder = new File(filePath);
|
|
|
File[] tempList = folder.listFiles();
|
|
@@ -125,6 +130,7 @@ public class TrafficRecordsAnalyseServiceImpl implements TrafficRecordsAnalyseSe
|
|
|
List<MonthResult> errorRecords = getMonthResult("ErrorRecord" + i, files.get(i).getAbsolutePath());
|
|
|
push(errorRecords);
|
|
|
}
|
|
|
+ log.info("pushErrorRecordsEnd, costTime:{}", System.currentTimeMillis() - startTime);
|
|
|
return new CommonResponseObject().success();
|
|
|
}
|
|
|
|
|
@@ -256,8 +262,8 @@ public class TrafficRecordsAnalyseServiceImpl implements TrafficRecordsAnalyseSe
|
|
|
.build();
|
|
|
OkHttpClient client = okHttpClient.newBuilder()
|
|
|
.connectTimeout(1000, TimeUnit.MILLISECONDS)
|
|
|
- .readTimeout(10000, TimeUnit.MILLISECONDS)
|
|
|
- .writeTimeout(10000, TimeUnit.MILLISECONDS)
|
|
|
+ .readTimeout(5000, TimeUnit.MILLISECONDS)
|
|
|
+ .writeTimeout(5000, TimeUnit.MILLISECONDS)
|
|
|
.build();
|
|
|
String responseContext = "";
|
|
|
List<MonthResult> errorList = new ArrayList<>();
|