Skip to content

Commit

Permalink
Merge pull request #11 from iamsad5566/dev
Browse files Browse the repository at this point in the history
update: update singleton instance
  • Loading branch information
iamsad5566 authored Sep 20, 2022
2 parents 22dc310 + e3a3438 commit 9bf3b8a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/main/java/config/EnvironmentVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
import java.util.Map;

public class EnvironmentVariable {
private static EnvironmentVariable uniqueInstance;
InputStream inputStream;
static EnvironmentVariable env;
public Map<String, Object> data;

public EnvironmentVariable() throws FileNotFoundException {
private EnvironmentVariable() throws FileNotFoundException {
this.inputStream = new FileInputStream("config.yml");
Yaml yaml = new Yaml();
this.data = yaml.load(inputStream);
}

public static EnvironmentVariable getInstance() throws FileNotFoundException {
env = new EnvironmentVariable();
return env;
if (uniqueInstance == null) {
uniqueInstance = new EnvironmentVariable();
}
return uniqueInstance;
}
}
6 changes: 6 additions & 0 deletions src/main/java/module/DataProcessor.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package module;

import config.EnvironmentVariable;

import java.io.FileNotFoundException;
import java.util.ArrayList;

public class DataProcessor {
private static DataProcessor uniqueInstance;

private DataProcessor() {
}

public static DataProcessor getInstance() {
if (uniqueInstance == null) {
uniqueInstance = new DataProcessor();
}

return new DataProcessor();
}

Expand Down
14 changes: 9 additions & 5 deletions src/main/java/module/ExcelManipulate.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
import org.apache.poi.ss.util.CellRangeAddress;

public class ExcelManipulate {

private static ExcelManipulate excelManipulate;
static Workbook wb = new HSSFWorkbook();

private ExcelManipulate() {

}

public static ExcelManipulate getInstance() {
return new ExcelManipulate();
if (excelManipulate == null) {
excelManipulate = new ExcelManipulate();
}

return excelManipulate;
}

public void saveDataInExcel(List<String> list, String path) throws IOException {
Expand All @@ -51,7 +55,7 @@ private Sheet createFirstSheet(List<String> list) throws FileNotFoundException {
Cell title_cell = title_row.createCell(0);

// Set up the header
String headers[] = new String[] {"報帳條碼", "經費或計畫名稱", "計畫代碼", "經費別", "金額", "報帳日", "傳票號碼",
String headers[] = new String[]{"報帳條碼", "經費或計畫名稱", "計畫代碼", "經費別", "金額", "報帳日", "傳票號碼",
"付款資料", "報帳ID", "列印次數", "受款人", "備註", "稅前金額"};

Row header_row = first.createRow(1);
Expand Down Expand Up @@ -99,7 +103,7 @@ private Sheet createSecondSheet(List<String> list) {
title_row.setHeight((short) (40 * 20));
Cell title_cell = title_row.createCell(0);

String headers[] = new String[] {"報帳條碼", "經費或計畫名稱", "計畫代碼", "經費別", "金額", "報帳日", "傳票號碼",
String headers[] = new String[]{"報帳條碼", "經費或計畫名稱", "計畫代碼", "經費別", "金額", "報帳日", "傳票號碼",
"付款資料", "報帳ID", "列印次數", "受款人", "備註"};
Row header_row = second.createRow(1);
header_row.setHeight((short) (20 * 24));
Expand Down Expand Up @@ -135,7 +139,7 @@ private Sheet createThirdSheet(Sheet first, Sheet second) {
title_row.setHeight((short) (40 * 20));
Cell title_cell = title_row.createCell(0);

String headers[] = new String[] {"報帳條碼", "經費或計畫名稱", "計畫代碼", "經費別", "金額", "報帳日", "傳票號碼",
String headers[] = new String[]{"報帳條碼", "經費或計畫名稱", "計畫代碼", "經費別", "金額", "報帳日", "傳票號碼",
"付款資料", "報帳ID", "列印次數", "受款人", "備註"};
Row header_row = third.createRow(1);
header_row.setHeight((short) (20 * 24));
Expand Down

0 comments on commit 9bf3b8a

Please sign in to comment.