diff --git a/code/east-datafile-utils/.editorconfig1 b/code/east-datafile-utils/.editorconfig
similarity index 69%
rename from code/east-datafile-utils/.editorconfig1
rename to code/east-datafile-utils/.editorconfig
index 424ecba..b1aa8c0 100644
--- a/code/east-datafile-utils/.editorconfig1
+++ b/code/east-datafile-utils/.editorconfig
@@ -4,16 +4,22 @@ root = true
[*]
charset = utf-8
indent_style = space
-indent_size = 2
+indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.js]
-indent_size = 2
+indent_size = 4
+
+[*.ts]
+indent_size = 4
[*.py]
indent_size = 4
-# [*.java]
-# indent_size = 4
+[*.java]
+indent_size = 4
+
+[*.xml]
+indent_size = 2
diff --git a/code/east-datafile-utils/pom.xml b/code/east-datafile-utils/pom.xml
index 7e180d7..4d73d89 100644
--- a/code/east-datafile-utils/pom.xml
+++ b/code/east-datafile-utils/pom.xml
@@ -15,9 +15,9 @@
UTF-8
17
- 2.24.3
+ 2.25.1
2.19.2
-
+
@@ -44,6 +44,7 @@
junit-jupiter-params
test
+
org.apache.poi
@@ -65,7 +66,8 @@
poi-ooxml-schemas
4.1.2
-
+
+
com.fasterxml.jackson.core
jackson-databind
@@ -83,6 +85,23 @@
jackson-annotations
${jackson.version}
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-slf4j2-impl
+ ${log4j.version}
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j.version}
+
@@ -150,4 +169,4 @@
-
\ No newline at end of file
+
diff --git a/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileConverter.java b/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileConverter.java
index ea06c47..371f6fe 100644
--- a/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileConverter.java
+++ b/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileConverter.java
@@ -12,41 +12,125 @@ package com.cpic.xim.east.utils;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class DataFileConverter
{
+ private static Logger logger = LoggerFactory.getLogger( DataFileConverter.class );
+
+ /**
+ *
+ * @param eastDataFilePath
+ * @param xlsxFilePath
+ * @param spliterString
+ * @throws FileNotFoundException
+ * @throws IOException
+ */
public static void convertEASTDataFileToXLSX( String eastDataFilePath,
String xlsxFilePath,
- String spliteString
+ String spliterString
)
throws FileNotFoundException,
IOException
{
- Workbook workbook = new XSSFWorkbook();
- Sheet sheet = workbook.createSheet( "sheet1" );
- BufferedReader reader = null;
- String line;
- int rowIndex = 0;
-
- reader = new BufferedReader( new FileReader( eastDataFilePath ) );
-
- while ( (line = reader.readLine()) != null )
+ FileOutputStream xlsxFile = null;
+ BufferedReader reader = null;
+ Workbook workbook = null;
+ Sheet sheet = null;
+
+ String line;
+ int rowIndex = 0;
+
+ try
{
- String[] rowData = line.split( spliteString );
-
- for ( String cellData : rowData )
+ reader = new BufferedReader( new FileReader( eastDataFilePath ) );
+ }
+ catch ( IOException error )
+ {
+ logger.error( "打开文件" + eastDataFilePath + "失败!!!!" );
+
+ throw error;
+ }
+
+ try
+ {
+ workbook = new XSSFWorkbook();
+ sheet = workbook.createSheet( "sheet1" );
+
+ while ( (line = reader.readLine()) != null )
{
-
+ String[] rowData = line.split( spliterString );
+ Row row = sheet.createRow( rowIndex );
+ int cellIndex = 0;
+
+ for ( String cellData : rowData )
+ {
+ row.createCell( cellIndex++ ).setCellValue( cellData );
+ }
+
+ rowIndex++;
+ }
+
+ xlsxFile = new FileOutputStream( xlsxFilePath );
+ workbook.write( xlsxFile );
+
+ xlsxFile.close();
+ workbook.close();
+ reader.close();
+ }
+ catch ( IOException error )
+ {
+ throw error;
+ }
+ finally
+ {
+ if ( xlsxFile != null )
+ {
+ try
+ {
+ xlsxFile.close();
+ }
+ catch ( IOException error )
+ {
+ error.printStackTrace();
+ }
+ }
+
+ if ( workbook != null )
+ {
+ try
+ {
+ workbook.close();
+ }
+ catch ( IOException error )
+ {
+ error.printStackTrace();
+ }
+ }
+
+ if ( reader != null )
+ {
+ try
+ {
+ reader.close();
+ }
+ catch ( IOException error )
+ {
+ error.printStackTrace();
+ }
}
}
-
- reader.close();
-
+
}
}
diff --git a/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileSpliter.java b/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileSpliter.java
index d83411b..5c8f7ff 100644
--- a/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileSpliter.java
+++ b/code/east-datafile-utils/src/main/java/com/cpic/xim/east/utils/DataFileSpliter.java
@@ -16,6 +16,8 @@ import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Kane
@@ -23,6 +25,7 @@ import java.io.IOException;
*/
public class DataFileSpliter
{
+ private static Logger logger = LoggerFactory.getLogger( DataFileSpliter.class );
public static void splitFile( File inputFile,
int lineCountPerFile,
diff --git a/code/east-datafile-utils/src/main/resources/log4j2.xml b/code/east-datafile-utils/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..6d2616c
--- /dev/null
+++ b/code/east-datafile-utils/src/main/resources/log4j2.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+ [%t][%level][%d{HH:mm:ss.SSS}][%logger.%M{36}#%L] %msg%n
+
+
+
+
+
+
+
+
+
+ [%t][%level][%d{HH:mm:ss.SSS}][%logger.%M{36}#%L] %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+