├── src ├── main │ ├── resources │ │ ├── static │ │ │ ├── css │ │ │ │ ├── main.css │ │ │ │ └── common.css │ │ │ ├── image │ │ │ │ ├── logo.png │ │ │ │ └── main.png │ │ │ └── js │ │ │ │ └── common.js │ │ ├── application.properties │ │ └── templates │ │ │ ├── setting.html │ │ │ ├── list.html │ │ │ ├── date.html │ │ │ ├── main.html │ │ │ ├── selectYear.html │ │ │ ├── office.html │ │ │ ├── officeSetting.html │ │ │ ├── subject.html │ │ │ ├── officeInsert.html │ │ │ ├── officeReport.html │ │ │ ├── officeUpdate.html │ │ │ ├── input.html │ │ │ ├── select.html │ │ │ ├── view.html │ │ │ ├── actionInput.html │ │ │ ├── delete.html │ │ │ ├── actionUpdate.html │ │ │ ├── actionInsert.html │ │ │ ├── cash.html │ │ │ ├── cashResult.html │ │ │ ├── daily.html │ │ │ ├── monthly.html │ │ │ └── year.html │ └── java │ │ └── com │ │ └── iwamih31 │ │ ├── AccountBookApplication.java │ │ ├── ShutdownController.java │ │ ├── CashRepository.java │ │ ├── State.java │ │ ├── OfficeRepository.java │ │ ├── Office.java │ │ ├── Set.java │ │ ├── Action.java │ │ ├── MainController.java │ │ ├── Cash.java │ │ ├── LabelSet.java │ │ ├── ActionRepository.java │ │ ├── LogAspct.java │ │ ├── WorkSheet.java │ │ ├── YearWorkSheet.java │ │ ├── MonthlyWorkSheet.java │ │ ├── DailyWorkSheet.java │ │ ├── OptionData.java │ │ ├── Excel.java │ │ ├── AccountBookController.java │ │ └── AccountBookService.java └── test │ └── java │ └── com │ └── iwamih31 │ └── AccountBookApplicationTests.java ├── AccountBookDB.mv.db ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw /src/main/resources/static/css/main.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; -------------------------------------------------------------------------------- /AccountBookDB.mv.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwamih31/AccountBook/HEAD/AccountBookDB.mv.db -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwamih31/AccountBook/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/static/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwamih31/AccountBook/HEAD/src/main/resources/static/image/logo.png -------------------------------------------------------------------------------- /src/main/resources/static/image/main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iwamih31/AccountBook/HEAD/src/main/resources/static/image/main.png -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /src/test/java/com/iwamih31/AccountBookApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AccountBookApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/static/js/common.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | 5 | var n3 = document.getElementsByClassName('num3'); 6 | for (var i = 0; n3.length; i++){ 7 | let p = n3[i].textContent.replace('\xA5', ''); 8 | if(isFinite(p)){ 9 | n3[i].innerHTML = Number(p).toLocaleString('ja-JP', {"style":"currency", "currency":"JPY"}); 10 | } 11 | } -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/AccountBookApplication.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class AccountBookApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(AccountBookApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # DataSource 2 | spring.datasource.driver-class-name=org.h2.Driver 3 | spring.datasource.url=jdbc:h2:file:./AccountBookDB 4 | spring.datasource.username=sa 5 | spring.datasource.password= 6 | spring.sql.init.encoding=UTF-8 7 | spring.sql.init.mode=always 8 | spring.jpa.hibernate.ddl-auto=update 9 | spring.jpa.show-sql=true 10 | 11 | #これを付けないと警告が出る 12 | spring.jpa.open-in-view= true 13 | 14 | #Spring Bootのバージョン2.5以上では下の行が必要(エンティティクラスからテーブル生成の場合) 15 | spring.jpa.defer-datasource-initialization=true 16 | 17 | #プロセスの停止操作の為に必要(pomにアクチュエーターも必要) 18 | management.endpoints.web.exposure.include=shutdown 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/ShutdownController.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | @RestController 10 | class ShutdownController { 11 | @PostMapping("/shutdown") 12 | void shutdownContext() { 13 | SpringApplication.exit(applicationContext,(() -> 0)); 14 | } 15 | 16 | @Autowired 17 | private ApplicationContext applicationContext; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/CashRepository.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | import org.springframework.stereotype.Repository; 10 | 11 | @Repository 12 | public interface CashRepository extends JpaRepository { 13 | 14 | /** Cash取得(日付指定) */ 15 | @Query("select cash" 16 | + " from Cash cash" 17 | + " where cash.date = :date") 18 | public List cash( 19 | @Param("date") LocalDate date 20 | ); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/State.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | 5 | import org.springframework.format.annotation.DateTimeFormat; 6 | 7 | import com.fasterxml.jackson.annotation.JsonFormat; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | @Data 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class State { 17 | 18 | // ID 19 | private Integer id; 20 | 21 | // 名前 22 | private String name; 23 | 24 | // 日付 25 | @DateTimeFormat(pattern = "yyyy-MM-dd") // 入力時の期待フォーマット 26 | @JsonFormat(pattern = "yyyy/MM/dd") // 出力時の期待フォーマット 27 | private LocalDate date; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/OfficeRepository.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.jpa.repository.Query; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | @Repository 11 | public interface OfficeRepository extends JpaRepository { 12 | 13 | /** item_name 列の値が引数 item_name の値と同じ行の item_value 列の値を文字列で返す */ 14 | @Query("select office.item_value" 15 | + " from Office office" 16 | + " where office.item_name = :item_name") 17 | public List item_value(@Param("item_name")String item_name); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/templates/setting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 |
15 | 20 |
21 |
22 | メインページへ 23 |
24 | 25 | -------------------------------------------------------------------------------- /src/main/resources/templates/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 24 |
25 | メインページへ 26 |
27 | 28 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/Office.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | 14 | @Data 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | @Entity 18 | @Table(name = "office") 19 | public class Office { 20 | 21 | // ID 22 | @Id 23 | @GeneratedValue(strategy=GenerationType.IDENTITY) 24 | private Integer id; 25 | 26 | // 項目 27 | @Column(name = "item_name", nullable = false) 28 | private String item_name; 29 | 30 | // 内容 31 | @Column(name = "item_value", nullable = false) 32 | private String item_value; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/templates/date.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 15 |
16 |
17 |
18 | 19 | 20 | 23 |
24 |
25 |
26 |
27 | メインページへ 28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/Set.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | public class Set { 4 | public String name; 5 | public int value; 6 | 7 | public Set(String name, int value) { 8 | super(); 9 | this.name = name; 10 | this.value = value; 11 | } 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | public void setName(String name) { 18 | this.name = name; 19 | } 20 | 21 | public int getValue() { 22 | return value; 23 | } 24 | 25 | public void setValue(int value) { 26 | this.value = value; 27 | } 28 | 29 | public static String[] get_Name_Set(Set[] set_list) { 30 | String[] name_Set = new String[set_list.length]; 31 | for (int i = 0; i < name_Set.length; i++) { 32 | name_Set[i] = set_list[i].name; 33 | } 34 | return name_Set; 35 | } 36 | 37 | public static int[] get_Value_Set(Set[] set_list) { 38 | int[] value_Set = new int[set_list.length]; 39 | for (int i = 0; i < value_Set.length; i++) { 40 | value_Set[i] = set_list[i].value; 41 | } 42 | return value_Set; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/resources/templates/main.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | CareRecord 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 |
17 |

[[${title}]]

18 |
19 | 20 |
21 | 32 |
33 |
34 |
35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/templates/selectYear.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 15 |
16 |
17 |
18 | 19 | 20 | 25 | 28 |
29 |
30 |
31 |
32 | メインページへ 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/templates/office.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 |
18 | 21 |
22 |
23 | 24 |
25 | 26 | 27 | 28 | 31 | 34 | 35 | 36 |
29 | ● [[*{item_name}]] 30 | 32 | :[[*{item_value}]] 33 |
37 |
38 | 39 |
40 | メインページへ 41 |
42 | 43 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/Action.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.Table; 11 | 12 | import org.springframework.format.annotation.DateTimeFormat; 13 | 14 | import com.fasterxml.jackson.annotation.JsonFormat; 15 | 16 | import lombok.AllArgsConstructor; 17 | import lombok.Data; 18 | import lombok.NoArgsConstructor; 19 | 20 | @Data 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Entity 24 | @Table(name = "action") 25 | public class Action { 26 | 27 | // ID 28 | @Id 29 | @GeneratedValue(strategy=GenerationType.IDENTITY) 30 | private Integer id; 31 | 32 | // 日付 33 | @DateTimeFormat(pattern = "yyyy-MM-dd") // 入力時の期待フォーマット 34 | @JsonFormat(pattern = "yyyy/MM/dd") // 出力時の期待フォーマット 35 | @Column(name = "date", nullable = true) 36 | private LocalDate date; 37 | 38 | // 科目 39 | @Column(name = "subject", nullable = false) 40 | private String subject; 41 | 42 | // 適用 43 | @Column(name = "apply", nullable = true) 44 | private String apply; 45 | 46 | // 収入 47 | @Column(name = "income", nullable = false) 48 | private Integer income; 49 | 50 | // 支出 51 | @Column(name = "spending", nullable = false) 52 | private Integer spending; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/MainController.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | 8 | import lombok.AllArgsConstructor; 9 | 10 | @Controller 11 | @AllArgsConstructor 12 | public class MainController { 13 | 14 | @Autowired 15 | private AccountBookService service; 16 | 17 | @GetMapping("/") 18 | public String accountBook_index() { 19 | service.___consoleOut___("@PostMapping(\"/\")開始"); 20 | service.___consoleOut___("@PostMapping(\"/\")終了"); 21 | return "redirect:/AccountBook/"; 22 | } 23 | 24 | @GetMapping("/main") 25 | public String main0() { 26 | service.___consoleOut___("@PostMapping(\"/\")開始"); 27 | service.___consoleOut___("@PostMapping(\"/\")終了"); 28 | return "redirect:/AccountBook/"; 29 | } 30 | 31 | @GetMapping("/Main") 32 | public String main() { 33 | service.___consoleOut___("@PostMapping(\"/\")開始"); 34 | service.___consoleOut___("@PostMapping(\"/\")終了"); 35 | return "redirect:/AccountBook/"; 36 | } 37 | 38 | /** view 表示に必要な属性データをモデルに登録 */ 39 | private void add_View_Data_(Model model, String template, String title) { 40 | model.addAttribute("library", template + "::library"); 41 | model.addAttribute("main", template + "::main"); 42 | model.addAttribute("title", title); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/resources/templates/officeSetting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 15 |
16 | 24 | 25 | 26 | 27 | 30 | 33 | 36 | 44 | 45 | 46 |
28 | [[*{id}]].  29 | 31 | [[*{item_name}]] 32 | 34 | :[[*{item_value}]]  35 | 37 |
38 | 39 | 42 |
43 |
47 |
48 |
49 | メインページへ 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/resources/templates/subject.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 | 12 |

[[${title}]]

13 | 14 |
15 |
[[${message}]]
16 |
17 |
18 | 19 |
20 |
21 |
22 | [[${name}]] 23 |
24 |
25 |
26 |
27 | [[${year}]] 28 |
29 |
30 |
31 | 32 | 33 | 34 | 37 | 38 | 39 | 47 | 48 |
35 | [[${guide}]] 36 |
40 | 43 | 46 |
49 |
50 |
51 |
52 | メインページへ 53 |
54 | 55 | -------------------------------------------------------------------------------- /src/main/resources/templates/officeInsert.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 38 | 41 | 46 | 47 | 48 |
ID項目内容
32 | [[*{id}]] 33 | 34 | 36 | 37 | 39 | 40 | 42 | 45 |
49 |
50 |
51 |
52 | メインページへ 53 |
54 | 55 | -------------------------------------------------------------------------------- /src/main/resources/templates/officeReport.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 | 18 |
19 |
20 | 23 |
24 |
25 | 26 |
27 |
[[${message}]]
28 |
29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | 43 | 46 | 49 | 50 | 51 |
34 | [[${label.name}]] 35 |
41 | [[${office.id}]] 42 | 44 | [[${office.item_name}]] 45 | 47 | [[${office.item_value}]] 48 |
52 |
53 | 54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/resources/templates/officeUpdate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 15 |
16 |
17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 38 | 41 | 46 | 47 | 48 |
ID項目内容
32 | [[${id}]] 33 | 34 | 36 | 37 | 39 | 40 | 42 | 45 |
49 |
50 |
51 |
52 | メインページへ 53 |
54 | 55 | -------------------------------------------------------------------------------- /src/main/resources/templates/input.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 |
18 |
19 | [[${name}]] 20 |
21 |
22 |
23 |
24 | [[${displayed_Date}]] 25 |
26 |
27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 49 | 50 |
39 | [[${guide}]] 40 |
44 | 45 | 48 |
51 |
52 |
53 | 54 |
55 | メインページへ 56 |
57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/templates/select.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 |
18 |
19 | [[${name}]] 20 |
21 |
22 |
23 |
24 | [[${displayed_Date}]] 25 |
26 |
27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 51 | 52 |
39 | [[${guide}]] 40 |
44 | 47 | 50 |
53 |
54 |
55 | 56 |
57 | メインページへ 58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /src/main/resources/templates/view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | CareRecord 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 43 | 44 | 45 |
46 | 47 | 48 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/Cash.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.Table; 11 | 12 | import org.springframework.format.annotation.DateTimeFormat; 13 | 14 | import com.fasterxml.jackson.annotation.JsonFormat; 15 | 16 | import lombok.AllArgsConstructor; 17 | import lombok.Data; 18 | import lombok.NoArgsConstructor; 19 | 20 | @Data 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | @Entity 24 | @Table(name = "cash") 25 | public class Cash { 26 | 27 | // ID 28 | @Id 29 | @GeneratedValue(strategy=GenerationType.IDENTITY) 30 | private Integer id; 31 | 32 | // 日付 33 | @DateTimeFormat(pattern = "yyyy-MM-dd") // 入力時の期待フォーマット 34 | @JsonFormat(pattern = "yyyy/MM/dd") // 出力時の期待フォーマット 35 | @Column(name = "date", nullable = true) 36 | private LocalDate date; 37 | 38 | // 10,000 39 | @Column(name = "man1", nullable = false) 40 | private Integer man1; 41 | 42 | // 5,000 43 | @Column(name = "sen5", nullable = false) 44 | private Integer sen5; 45 | 46 | // 1,000 47 | @Column(name = "sen1", nullable = false) 48 | private Integer sen1; 49 | 50 | // 500 51 | @Column(name = "hyaku5", nullable = false) 52 | private Integer hyaku5; 53 | 54 | // 100 55 | @Column(name = "hyaku1", nullable = false) 56 | private Integer hyaku1; 57 | 58 | // 50 59 | @Column(name = "jyuu5", nullable = false) 60 | private Integer jyuu5; 61 | 62 | // 10 63 | @Column(name = "jyuu1", nullable = false) 64 | private Integer jyuu1; 65 | 66 | // 5 67 | @Column(name = "en5", nullable = false) 68 | private Integer en5; 69 | 70 | // 1 71 | @Column(name = "en1", nullable = false) 72 | private Integer en1; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/resources/templates/actionInput.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 |
18 |
19 | [[${name}]] 20 |
21 |
22 |
23 |
24 | [[${japanese_Date}]] 25 |
26 |
27 | 28 |
29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 42 | 46 | 47 | 48 | 53 | 54 | 55 |
35 | [[${label_Set.name}]] 36 |
43 | 45 | 49 | 52 |
56 |
57 |
58 |
59 | メインページへ 60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/LabelSet.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | public class LabelSet { 4 | 5 | public static Set[] daily_Set = { 6 | set("科目", 10), 7 | set("適用", 25), 8 | set("収入", 7), 9 | set("支出", 7), 10 | set("残高", 7) 11 | }; 12 | 13 | public static Set[] daily_Output_Set = { 14 | set("科目", 10), 15 | set("適用", 25), 16 | set("収入", 7), 17 | set("支出", 7), 18 | set("残高", 7) 19 | }; 20 | 21 | public static Set[] monthly_Output_Set = { 22 | set("日付", 7), 23 | set("科目", 10), 24 | set("適用", 15), 25 | set("収入", 7), 26 | set("支出", 7), 27 | set("残高", 7) 28 | }; 29 | 30 | public static Set[] year_Output_Set = { 31 | set("日付", 7), 32 | set("科目", 10), 33 | set("適用", 15), 34 | set("収入", 7), 35 | set("支出", 7), 36 | set("残高", 7) 37 | }; 38 | 39 | public static Set[] action_List_Set = { 40 | set("日付", 8), 41 | set("科目", 10), 42 | set("適用", 20), 43 | set("収入", 8), 44 | set("支出", 8), 45 | set("残高", 8), 46 | }; 47 | 48 | public static Set[] actionInsert_Set = { 49 | set("科目", 10), 50 | set("適用", 20), 51 | set("収入", 8), 52 | set("支出", 8), 53 | }; 54 | 55 | public static Set[] actionUpdate_Set = { 56 | set("ID", 4), 57 | set("日付", 6), 58 | set("科目", 6), 59 | set("適用", 20), 60 | set("収入", 5), 61 | set("支出", 5), 62 | }; 63 | 64 | public static Set[] actionDelete_Set = { 65 | set("ID", 4), 66 | set("日付", 6), 67 | set("科目", 6), 68 | set("適用", 20), 69 | set("収入", 6), 70 | set("支出", 6), 71 | }; 72 | 73 | public static Set[] officeReport_Set = { 74 | set("ID", 6), 75 | set("項目", 4), 76 | set("内容", 8) 77 | }; 78 | public static Set[] cash_Set = { 79 | set("金種",10), 80 | set("枚数",10) 81 | }; 82 | 83 | public static Set set(String label_Name, int width) { 84 | return new Set(label_Name, width); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/ActionRepository.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | import org.springframework.data.repository.query.Param; 9 | import org.springframework.stereotype.Repository; 10 | 11 | @Repository 12 | public interface ActionRepository extends JpaRepository { 13 | 14 | /** Action取得(日付指定) */ 15 | @Query("select action" 16 | + " from Action action" 17 | + " where action.date >= :start_date" 18 | + " and action.date <= :end_date" 19 | + " order by" 20 | + " action.date asc," 21 | + " action.subject asc," 22 | + " action.apply asc") 23 | public List action_List( 24 | @Param("start_date") LocalDate start_date, 25 | @Param("end_date") LocalDate end_date 26 | ); 27 | 28 | /** Action取得(日付指定) */ 29 | @Query("select action" 30 | + " from Action action" 31 | + " where action.date >= :start_date" 32 | + " and action.date <= :end_date" 33 | + " and action.subject = :subject" 34 | + " order by" 35 | + " action.date asc," 36 | + " action.subject asc," 37 | + " action.apply asc") 38 | public List action_List( 39 | @Param("start_date") LocalDate start_date, 40 | @Param("end_date") LocalDate end_date, 41 | @Param("subject") String subject 42 | ); 43 | 44 | /** subjects取得 */ 45 | @Query("select distinct action.subject" 46 | + " from Action action") 47 | public List subjects(); 48 | 49 | /** applys取得 */ 50 | @Query("select distinct action.apply" 51 | + " from Action action") 52 | public List applys(); 53 | 54 | /** Action取得(指定日まで) */ 55 | @Query("select distinct action" 56 | + " from Action action" 57 | + " where action.date <= :date" 58 | + " order by action.date desc") 59 | public List up_to_date( 60 | @Param("date") LocalDate localDate 61 | ); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/resources/templates/delete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 15 |
16 |
17 |
18 |
[[${guide}]]
19 |
20 | 21 | 22 | 25 |
26 |
27 | 28 | 29 | 32 |
33 |
34 |
35 | 36 | 37 | 38 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
40 | [[${label_Set.name}]] 41 |
[[*{id}]][[*{date}]][[*{subject}]][[*{apply}]][[*{income}]][[*{spending}]]
55 |
56 |
57 | メインページへ 58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/LogAspct.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import org.aspectj.lang.JoinPoint; 4 | import org.aspectj.lang.annotation.After; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.aspectj.lang.annotation.Before; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Aspect 10 | @Component 11 | public class LogAspct { 12 | 13 | // AOP実装(メソッドが実行される前に、Advice実行) 14 | // クラス名の最後に"Controller"が付くクラスの全てのメソッドをAOPの対象にする 15 | @Before("execution(* *..*.*Controller.*(..))") 16 | public void startLog_Controller(JoinPoint joinPoint){ 17 | System.out.println(""); 18 | System.out.println(joinPoint.getSignature() + "開始"); 19 | } 20 | 21 | // AOP実装(メソッドが実行された後に、Advice実行) 22 | // クラス名の最後に"Controller"が付くクラスの全てのメソッドをAOPの対象にする 23 | @After("execution(* *..*.*Controller.*(..))") 24 | public void endLog_Controller(JoinPoint joinPoint) { 25 | System.out.println(joinPoint.getSignature() + "終了"); 26 | System.out.println(""); 27 | } 28 | 29 | // AOP実装(メソッドが実行される前に、Advice実行) 30 | // クラス名の最後に"Service"が付くクラスの全てのメソッドをAOPの対象にする 31 | @Before("execution(* *..*.*Service.*(..))") 32 | public void startLog_Service(JoinPoint joinPoint){ 33 | System.out.println(""); 34 | System.out.println(joinPoint.getSignature() + "開始"); 35 | } 36 | 37 | // AOP実装(メソッドが実行された後に、Advice実行) 38 | // クラス名の最後に"Service"が付くクラスの全てのメソッドをAOPの対象にする 39 | @After("execution(* *..*.*Service.*(..))") 40 | public void endLog_Service(JoinPoint joinPoint) { 41 | System.out.println(joinPoint.getSignature() + "終了"); 42 | System.out.println(""); 43 | } 44 | 45 | // AOP実装(メソッドが実行される前に、Advice実行) 46 | // クラス名の最後に"Excel"が付くクラスの全てのメソッドをAOPの対象にする 47 | @Before("execution(* *..*.*Excel.*(..))") 48 | public void startLog_Excel(JoinPoint joinPoint){ 49 | System.out.println(""); 50 | System.out.println(joinPoint.getSignature() + "開始"); 51 | } 52 | 53 | // AOP実装(メソッドが実行された後に、Advice実行) 54 | // クラス名の最後に"Excel"が付くクラスの全てのメソッドをAOPの対象にする 55 | @After("execution(* *..*.*Excel.*(..))") 56 | public void endLog_Excel(JoinPoint joinPoint) { 57 | System.out.println(joinPoint.getSignature() + "終了"); 58 | System.out.println(""); 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/resources/templates/actionUpdate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |

[[${title}]]

13 |
14 | 15 |
16 |
17 |
18 |
[[${guide}]]
19 |
20 | 21 | 22 | 25 |
26 | 29 |
30 |
31 |
32 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
39 | [[${label_Set.name}]] 40 |
46 | [[*{id}]] 47 | 48 |
57 |
58 |
59 |
60 | メインページへ 61 |
62 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/templates/actionInsert.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 |
18 |
19 | [[${name}]] 20 |
21 |
22 |
23 |
24 | [[${japanese_Date}]] 25 |
26 |
27 | 28 |
29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 42 | 50 | 58 | 59 | 60 | 65 | 66 | 67 |
35 | [[${label_Set.name}]] 36 |
43 | 46 | 49 | 51 | 54 | 57 | 61 | 64 |
68 |
69 |
70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
78 |
79 |
80 | メインページへ 81 |
82 | 83 | 84 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.7.10 9 | 10 | 11 | com.iwamih31 12 | AccountBook 13 | 0.0.1-SNAPSHOT 14 | AccountBook 15 | Demo project for Spring Boot 16 | 17 | 11 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-jdbc 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-thymeleaf 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-devtools 40 | runtime 41 | true 42 | 43 | 44 | com.h2database 45 | h2 46 | runtime 47 | 48 | 49 | org.projectlombok 50 | lombok 51 | true 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-starter-test 56 | test 57 | 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-actuator 62 | 63 | 64 | 65 | 66 | org.apache.poi 67 | poi-ooxml 68 | 5.2.3 69 | 70 | 71 | 72 | 73 | 74 | 75 | org.springframework.boot 76 | spring-boot-maven-plugin 77 | 78 | 79 | 80 | org.projectlombok 81 | lombok 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/main/resources/templates/cash.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 |
18 | 19 | 20 |
21 | [[${japanese_Date}]] 22 | 23 |
24 | 25 | 26 | 30 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 44 | 47 | 48 | 49 | 52 | 55 | 56 | 57 | 60 | 63 | 64 | 65 | 68 | 71 | 72 | 73 | 76 | 79 | 80 | 81 | 84 | 87 | 88 | 89 | 92 | 95 | 96 | 97 | 100 | 103 | 104 | 105 |
28 | [[${label_Set.name}]] 29 |
34 | 10,000 35 | 37 | 38 |
42 | 5,000 43 | 45 | 46 |
50 | 1,000 51 | 53 | 54 |
58 | 500 59 | 61 | 62 |
66 | 100 67 | 69 | 70 |
74 | 50 75 | 77 | 78 |
82 | 10 83 | 85 | 86 |
90 | 5 91 | 93 | 94 |
98 | 1 99 | 101 | 102 |
106 | 107 | 108 |
109 | 112 |
113 |
114 |
115 |
116 | メインページへ 117 |
118 | 119 | -------------------------------------------------------------------------------- /src/main/resources/static/css/common.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | body { 4 | position: relative; 5 | } 6 | 7 | #main { 8 | margin: auto; 9 | width: 80%; 10 | } 11 | 12 | #header, 13 | #footer 14 | { 15 | background-color: silver; 16 | text-align: center; 17 | } 18 | 19 | #header nav { 20 | padding: 0.3em; 21 | } 22 | 23 | .to_index { 24 | text-align: left; 25 | } 26 | 27 | .title { 28 | text-align: left; 29 | border-bottom: solid thin; 30 | } 31 | 32 | .control { 33 | margin: 1em; 34 | font-size: large; 35 | } 36 | 37 | nav button, 38 | .btn, 39 | .margin_02 { 40 | margin: 0.2em; 41 | } 42 | 43 | .center { 44 | margin: auto; 45 | width: auto; 46 | text-align: center !important; 47 | } 48 | 49 | .right { 50 | margin: auto; 51 | width: auto; 52 | text-align: right; 53 | } 54 | 55 | .daily td:nth-child(n+3) { 56 | margin: auto; 57 | width: auto; 58 | text-align: right; 59 | } 60 | 61 | .monthly td:nth-child(n+4) { 62 | margin: auto; 63 | width: auto; 64 | text-align: right; 65 | } 66 | 67 | .vertical, 68 | .vertical div 69 | { 70 | display:table; 71 | margin: auto; 72 | margin-top: 0.3em; 73 | width: auto; 74 | text-align: left; 75 | } 76 | 77 | .vertical button { 78 | display:table; 79 | margin: auto; 80 | width: auto; 81 | } 82 | 83 | .guide, 84 | .label 85 | { 86 | font-size: x-large; 87 | } 88 | 89 | .flex_space_between { 90 | display:flex; 91 | justify-content:space-between; 92 | } 93 | 94 | .flex { 95 | display: flex; 96 | } 97 | 98 | 99 | .fixed { 100 | position: fixed; 101 | } 102 | 103 | .main { 104 | background-image: url("/image/main.png"); 105 | background-size: 100%; 106 | height: 40em; 107 | } 108 | 109 | .main nav { 110 | margin: auto; 111 | padding-top: 15em; 112 | } 113 | 114 | .main button { 115 | border-color: black; 116 | } 117 | 118 | .bg_yellow { 119 | background-color: yellow; 120 | } 121 | 122 | .bg_green { 123 | background-color: green; 124 | } 125 | 126 | .bg_red { 127 | background-color: red; 128 | } 129 | 130 | .bg_white { 131 | background-color: white; 132 | } 133 | 134 | .color_red { 135 | color: red; 136 | } 137 | 138 | 139 | .font-size-larger{ 140 | font-size: larger; 141 | } 142 | 143 | .font-size-x-large{ 144 | font-size: x-large; 145 | } 146 | 147 | .name { 148 | display: inline-flex; 149 | border: solid blue thin; 150 | border-radius: 0.2em; 151 | padding: 0.2em; 152 | margin: 0.2em; 153 | font-size: 1.5em; 154 | } 155 | 156 | .date, 157 | .subject 158 | { 159 | display: inline-flex; 160 | border: solid blue thin; 161 | border-radius: 0.2em; 162 | padding: 0.2em; 163 | margin: 0.2em; 164 | font-size: 1.3em; 165 | } 166 | 167 | .result { 168 | display: inline-flex; 169 | border: solid blue thin; 170 | border-radius: 0.2em; 171 | padding: 0.2em; 172 | margin: 0.2em; 173 | margin-top: 0.3em; 174 | font-size: 1.3em; 175 | } 176 | 177 | .padding_0{ 178 | padding: 0 !important; 179 | } 180 | 181 | .header { 182 | display: flex; 183 | } 184 | 185 | .alert { 186 | margin: 0 187 | } 188 | 189 | .cash td, 190 | .cash input 191 | { 192 | text-align: right; 193 | max-width: 4em; 194 | } 195 | 196 | .cash th { 197 | text-align: center; 198 | } 199 | 200 | .width_Max { 201 | width: 100%; 202 | } 203 | 204 | .table input { 205 | width: 100%; 206 | } 207 | -------------------------------------------------------------------------------- /src/main/resources/templates/cashResult.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 |

[[${title}]]

14 |
15 | 16 |
17 |
18 | 19 | 20 |
21 | [[${japanese_Date}]] 22 | 23 |
24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 38 | 42 | 43 | 44 | 47 | 51 | 52 | 53 | 56 | 60 | 61 | 62 | 65 | 69 | 70 | 71 | 74 | 78 | 79 | 80 | 83 | 87 | 88 | 89 | 92 | 96 | 97 | 98 | 101 | 105 | 106 | 107 | 110 | 114 | 115 | 116 |
29 | [[${label_Set.name}]] 30 |
36 | 10,000 37 | 39 | [[*{man1}]] 40 | 41 |
45 | 5,000 46 | 48 | [[*{sen5}]] 49 | 50 |
54 | 1,000 55 | 57 | [[*{sen1}]] 58 | 59 |
63 | 500 64 | 66 | [[*{hyaku5}]] 67 | 68 |
72 | 100 73 | 75 | [[*{hyaku1}]] 76 | 77 |
81 | 50 82 | 84 | [[*{jyuu5}]] 85 | 86 |
90 | 10 91 | 93 | [[*{jyuu1}]] 94 | 95 |
99 | 5 100 | 102 | [[*{en5}]] 103 | 104 |
108 | 1 109 | 111 | [[*{en1}]] 112 | 113 |
117 | 118 |
119 | 現金残高
[[${total}]]
120 |
121 |
122 |  差額 
[[${balance}]]
123 |
124 | 125 |
126 | 129 |
130 |
131 |
132 |
133 | メインページへ 134 |
135 | 136 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/WorkSheet.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class WorkSheet { 9 | 10 | // 罫線("□"," ̄","_"," |","| ","二","冂","凵","匚","コ","ノ","乚","r","¬") 11 | // 位置("|","CS","DD","FL","JY","←","→") 12 | // 1行目 13 | String[] row_1_Border = {" "," "," "," "," "," "," "," "}; // 罫線 14 | String[] row_1_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 15 | // 2行目 16 | String[] row_2_Border = {" "," "," "," "," "," "," "," "}; // 罫線 17 | String[] row_2_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 18 | // 3行目 19 | String[] row_3_Border = {" "," "," "," "," "," "," "," "}; // 罫線 20 | String[] row_3_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 21 | // 4行目(ラベル行) 22 | String[] label_Border = {" "," "," "," "," "," "," "," "}; // 罫線 23 | String[] label_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 24 | // その他(データ行) 25 | String[] data__Border = {" "," "," "," "," "," "," "," "}; // 罫線 26 | String[] data__Align_ = {" "," "," "," "," "," "," "," "}; // 位置 27 | 28 | protected String sheet_Name; 29 | protected int[] column_Width; 30 | protected String[][] value_Data; 31 | protected int print_Scale = 100; 32 | //印刷の向き(横にする場合は true) 33 | protected boolean printSetup = false; 34 | 35 | public WorkSheet() {} 36 | 37 | public WorkSheet(String sheet_Name, int[] column_Width, String[][] value_Data) { 38 | this.sheet_Name = sheet_Name; 39 | this.column_Width = column_Width; 40 | this.value_Data = value_Data; 41 | } 42 | 43 | /** フォント定義用 Map リスト */ 44 | public List> fonts(){ 45 | // リスト作成 46 | List> fonts = new ArrayList<>(); 47 | // マップ作成 48 | Map font0 = new HashMap<>(); 49 | Map font1 = new HashMap<>(); 50 | // フォント0 51 | font0.put("fontName", "游ゴシック"); 52 | font0.put("fontHeight", "200"); 53 | // フォント1 54 | font1.put("fontName", "游ゴシック"); 55 | font1.put("fontHeight", "150"); 56 | // リストに追加 57 | fonts.add(font0); 58 | fonts.add(font1); 59 | return fonts; 60 | }; 61 | 62 | /** 行毎の書式 */ 63 | public List> row_Format(int row_Size){ 64 | List> row_Format = new ArrayList<>(); 65 | for (int i = 0; i < row_Size; i++) { 66 | // default の値 67 | int height = 400; 68 | int font = 0; 69 | String[] border; 70 | String[] align; 71 | switch (i + 1) { 72 | case 1: // 1行目の場合 73 | border = row_1_Border; 74 | align = row_1_Align_; 75 | break; 76 | case 2: // 2行目の場合 77 | border = row_2_Border; 78 | align = row_2_Align_; 79 | break; 80 | case 3: // 3行目の場合 81 | border = row_3_Border; 82 | align = row_3_Align_; 83 | break; 84 | case 4: // 4行目(ラベル行)の場合 85 | border = label_Border; 86 | align = label_Align_; 87 | break; 88 | default: // その他(データ行)の場合 89 | border = data__Border; 90 | align = data__Align_; 91 | } 92 | Map row_Map = new HashMap<>(); 93 | row_Map.put("border", border); 94 | row_Map.put("align", align); 95 | row_Map.put("height", array(height)); 96 | row_Map.put("font", array(font)); 97 | row_Format.add(row_Map); 98 | } 99 | return row_Format; 100 | } 101 | 102 | private String[] array(String value) { 103 | return new String[] {value}; 104 | } 105 | 106 | private String[] array(int value) { 107 | return new String[] {String.valueOf(value)}; 108 | } 109 | 110 | public String getSheet_Name() { 111 | return sheet_Name; 112 | } 113 | 114 | public void setSheet_Name(String sheet_Name) { 115 | this.sheet_Name = sheet_Name; 116 | } 117 | 118 | public int[] getColumn_Width() { 119 | return column_Width; 120 | } 121 | 122 | public void setColumn_Width(int[] column_Width) { 123 | this.column_Width = column_Width; 124 | } 125 | 126 | public String[][] getValue_Data() { 127 | return value_Data; 128 | } 129 | 130 | public void setValue_Data(String[][] value_Data) { 131 | this.value_Data = value_Data; 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /src/main/resources/templates/daily.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 |

[[${title}]]

15 | 16 |
17 |
[[${message}]]
18 |
19 |
20 | 21 |
22 |
23 |
24 | [[${name}]] 25 |
26 |
27 | 28 | 31 |
32 |
33 |
34 |
35 | [[${japanese_Date}]] 36 |
37 |
38 | 39 | 42 |
43 |   44 |
45 | 46 | 49 |
50 |   51 |
52 | 53 | 56 |
57 |
58 | 59 | 60 | 61 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |
63 | [[${label_Set.name}]] 64 |
前日繰り越し [[${account["carryover"]}]]
[[*{subject}]] [[*{apply}]] [[*{income}]] [[*{spending}]] 94 |
95 | 96 | 97 | 100 |
101 |
102 | 103 | 104 | 107 |
108 |
[[${account["income_today"]}]] [[${account["spending_today"]}]][[${account["remainder"]}]] 現金差額
累計 [[${account["income_cumulative"]}]] [[${account["spending_cumulative"]}]] [[${account["balance"]}]]
128 |
129 |
130 | メインページへ 131 |
132 | 133 | 134 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/YearWorkSheet.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.apache.poi.ss.usermodel.IndexedColors; 9 | 10 | public class YearWorkSheet extends WorkSheet{ 11 | 12 | // コンストラクター 13 | public YearWorkSheet() { 14 | // 印刷時のサイズ 15 | print_Scale = 78; 16 | // 印刷向きを縦にする 17 | this.printSetup = false; 18 | } 19 | public YearWorkSheet(String sheet_Name, int[] column_Width, String[][] value_Data) { 20 | this.sheet_Name = sheet_Name; 21 | this.column_Width = column_Width; 22 | this.value_Data = value_Data; 23 | // 印刷時のサイズ 24 | print_Scale = 78; 25 | // 印刷向きを縦にする 26 | this.printSetup = false; 27 | } 28 | 29 | // 罫線("□"," ̄","_"," |","| ","二","冂","凵","匚","コ","ノ","乚","r","¬") 30 | // 位置("|","CS","DD","FL","JY","←","→") 31 | // 1行目 32 | String[] row_1_Border = {" "," "," "," "," "," "," "," "}; // 罫線 33 | String[] row_1_Align_ = {" "," "," "," ","→"," "," "," "}; // 位置 34 | // 2行目 35 | String[] row_2_Border = {" "," "," "," "," "," "," "," "}; // 罫線 36 | String[] row_2_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 37 | // 3行目(ラベル行) 38 | String[] label_Border = {"□","□","□","□","□","□","□","□"}; // 罫線 39 | String[] label_Align_ = {"|","|","|","|","|","|","|","|"}; // 位置 40 | // 前月繰越行 41 | String[] row_4_Border = {"□","□","□","□","□","□","□","□"}; // 罫線 42 | String[] row_4_Align_ = {" "," ","|","→","→","→","|","|"}; // 位置 43 | // 翌月繰り越し行 44 | String[] foot_1_Border = {"□","□","□","□","□","□","□","□"}; // 罫線 45 | String[] foot_1_Align_ = {" "," ","|","→","→","→","|","|"}; // 位置 46 | // 合計行 47 | String[] foot_2_Border = {"□","匚","コ","□","□","□","□","□"}; // 罫線 48 | String[] foot_2_Align_ = {" "," ","→","→","→","→","|","|"}; // 位置 49 | // その他(データ行) 50 | String[] data__Border = {"□","□","□","□","□","□","□","□"}; // 罫線 51 | String[] data__Align_ = {"→"," "," ","→","→","→","|","|"}; // 位置 52 | 53 | /** フォント定義用 Map リスト */ 54 | public List> fonts(){ 55 | List> fonts = new ArrayList<>(); 56 | Map font0 = new HashMap<>(); 57 | Map font1 = new HashMap<>(); 58 | // フォント0 59 | font0.put("fontName", "游ゴシック"); 60 | font0.put("fontHeight", "250"); 61 | // フォント1 62 | font1.put("fontName", "游ゴシック"); 63 | font1.put("fontHeight", "300"); 64 | fonts.add(font0); 65 | fonts.add(font1); 66 | return fonts; 67 | }; 68 | 69 | /** 行毎の書式設定用 Map リスト */ 70 | public List> row_Format(int row_Size){ 71 | 72 | // 行毎の書式設定用データ配列格納用 Map リスト 73 | List> row_Format = new ArrayList<>(); 74 | for (int i = 0; i < row_Size; i++) { 75 | // default の値 76 | int height = 400; 77 | int font = 0; 78 | String dataFormat = "G/標準"; 79 | short bg_color = IndexedColors.AUTOMATIC.getIndex(); 80 | String[] border = {" "," "," "," "," "," "," "," "}; 81 | String[] align = {" "," "," "," "," "," "," "," "}; 82 | if (i < row_Size - 2) { 83 | switch (i + 1) { 84 | case 1: // 1行目の場合 85 | font = 1; 86 | height = 500; 87 | border = row_1_Border; 88 | align = row_1_Align_; 89 | break; 90 | case 2: // 2行目の場合 91 | font = 1; 92 | height = 100; 93 | border = row_2_Border; 94 | align = row_2_Align_; 95 | break; 96 | case 3: // 3行目(ラベル行)の場合 97 | bg_color = IndexedColors.GREY_25_PERCENT.getIndex(); 98 | border = label_Border; 99 | align = label_Align_; 100 | break; 101 | case 4: // 4行目(前月繰越行)の場合 102 | dataFormat = "#,##0"; 103 | border = row_4_Border; 104 | align = row_4_Align_; 105 | break; 106 | default: // その他(データ行)の場合 107 | dataFormat = "#,##0"; 108 | border = data__Border; 109 | align = data__Align_; 110 | } 111 | } else if (i == row_Size - 2) { // 最後から2行目(翌月繰り越し行)の場合 112 | dataFormat = "#,##0"; 113 | height = 400; 114 | border = foot_1_Border; 115 | align = foot_1_Align_; 116 | } else if (i == row_Size - 1) { // 最後から1行目(合計行)の場合 117 | dataFormat = "#,##0"; 118 | height = 400; 119 | border = foot_2_Border; 120 | align = foot_2_Align_; 121 | } 122 | Map row_Map = new HashMap<>(); 123 | row_Map.put("border", border); 124 | row_Map.put("align", align); 125 | row_Map.put("height", array(height)); 126 | row_Map.put("font", array(font)); 127 | row_Map.put("dataFormat", array(dataFormat)); 128 | row_Map.put("bg_color", array(bg_color)); 129 | row_Format.add(row_Map); 130 | } 131 | return row_Format; 132 | } 133 | 134 | private String[] array(String value) { 135 | return new String[] {value}; 136 | } 137 | 138 | private String[] array(int value) { 139 | return new String[] {String.valueOf(value)}; 140 | } 141 | 142 | public String getSheet_Name() { 143 | return sheet_Name; 144 | } 145 | 146 | public void setSheet_Name(String sheet_Name) { 147 | this.sheet_Name = sheet_Name; 148 | } 149 | 150 | public int[] getColumn_Width() { 151 | return column_Width; 152 | } 153 | 154 | public void setColumn_Width(int[] column_Width) { 155 | this.column_Width = column_Width; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/MonthlyWorkSheet.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.apache.poi.ss.usermodel.IndexedColors; 9 | 10 | public class MonthlyWorkSheet extends WorkSheet{ 11 | 12 | // コンストラクター 13 | public MonthlyWorkSheet() { 14 | // 印刷時のサイズ 15 | print_Scale = 78; 16 | // 印刷向きを縦にする 17 | this.printSetup = false; 18 | } 19 | public MonthlyWorkSheet(String sheet_Name, int[] column_Width, String[][] value_Data) { 20 | this.sheet_Name = sheet_Name; 21 | this.column_Width = column_Width; 22 | this.value_Data = value_Data; 23 | // 印刷時のサイズ 24 | print_Scale = 78; 25 | // 印刷向きを縦にする 26 | this.printSetup = false; 27 | } 28 | 29 | // 罫線("□"," ̄","_"," |","| ","二","冂","凵","匚","コ","ノ","乚","r","¬") 30 | // 位置("|","CS","DD","FL","JY","←","→") 31 | // 1行目 32 | String[] row_1_Border = {" "," "," "," "," "," "," "," "}; // 罫線 33 | String[] row_1_Align_ = {" "," "," "," ","→"," "," "," "}; // 位置 34 | // 2行目 35 | String[] row_2_Border = {" "," "," "," "," "," "," "," "}; // 罫線 36 | String[] row_2_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 37 | // 3行目(ラベル行) 38 | String[] label_Border = {"□","□","□","□","□","□","□","□"}; // 罫線 39 | String[] label_Align_ = {"|","|","|","|","|","|","|","|"}; // 位置 40 | // 前月繰越行 41 | String[] row_4_Border = {"□","□","□","□","□","□","□","□"}; // 罫線 42 | String[] row_4_Align_ = {" "," ","|","→","→","→","|","|"}; // 位置 43 | // 翌月繰り越し行 44 | String[] foot_1_Border = {"□","□","□","□","□","□","□","□"}; // 罫線 45 | String[] foot_1_Align_ = {" "," ","|","→","→","→","|","|"}; // 位置 46 | // 合計行 47 | String[] foot_2_Border = {"□","匚","コ","□","□","□","□","□"}; // 罫線 48 | String[] foot_2_Align_ = {" "," ","→","→","→","→","|","|"}; // 位置 49 | // その他(データ行) 50 | String[] data__Border = {"□","□","□","□","□","□","□","□"}; // 罫線 51 | String[] data__Align_ = {"→"," "," ","→","→","→","|","|"}; // 位置 52 | 53 | /** フォント定義用 Map リスト */ 54 | public List> fonts(){ 55 | List> fonts = new ArrayList<>(); 56 | Map font0 = new HashMap<>(); 57 | Map font1 = new HashMap<>(); 58 | // フォント0 59 | font0.put("fontName", "游ゴシック"); 60 | font0.put("fontHeight", "250"); 61 | // フォント1 62 | font1.put("fontName", "游ゴシック"); 63 | font1.put("fontHeight", "300"); 64 | fonts.add(font0); 65 | fonts.add(font1); 66 | return fonts; 67 | }; 68 | 69 | /** 行毎の書式設定用 Map リスト */ 70 | public List> row_Format(int row_Size){ 71 | // 行毎の書式設定用データ配列格納用 Map リスト 72 | List> row_Format = new ArrayList<>(); 73 | for (int i = 0; i < row_Size; i++) { 74 | // default の値 75 | int height = 400; 76 | int font = 0; 77 | String dataFormat = "G/標準"; 78 | short bg_color = IndexedColors.AUTOMATIC.getIndex(); 79 | String[] border = {" "," "," "," "," "," "," "," "}; 80 | String[] align = {" "," "," "," "," "," "," "," "}; 81 | if (i < row_Size - 2) { 82 | switch (i + 1) { 83 | case 1: // 1行目の場合 84 | font = 1; 85 | height = 500; 86 | border = row_1_Border; 87 | align = row_1_Align_; 88 | break; 89 | case 2: // 2行目の場合 90 | font = 1; 91 | height = 100; 92 | border = row_2_Border; 93 | align = row_2_Align_; 94 | break; 95 | case 3: // 3行目(ラベル行)の場合 96 | bg_color = IndexedColors.GREY_25_PERCENT.getIndex(); 97 | border = label_Border; 98 | align = label_Align_; 99 | break; 100 | case 4: // 4行目(前月繰越行)の場合 101 | dataFormat = "#,##0"; 102 | border = row_4_Border; 103 | align = row_4_Align_; 104 | break; 105 | default: // その他(データ行)の場合 106 | dataFormat = "#,##0"; 107 | border = data__Border; 108 | align = data__Align_; 109 | } 110 | } else if (i == row_Size - 2) { // 最後から2行目(翌月繰り越し行)の場合 111 | dataFormat = "#,##0"; 112 | height = 400; 113 | border = foot_1_Border; 114 | align = foot_1_Align_; 115 | } else if (i == row_Size - 1) { // 最後から1行目(合計行)の場合 116 | dataFormat = "#,##0"; 117 | height = 400; 118 | border = foot_2_Border; 119 | align = foot_2_Align_; 120 | } 121 | Map row_Map = new HashMap<>(); 122 | row_Map.put("border", border); 123 | row_Map.put("align", align); 124 | row_Map.put("height", array(height)); 125 | row_Map.put("font", array(font)); 126 | row_Map.put("dataFormat", array(dataFormat)); 127 | row_Map.put("bg_color", array(bg_color)); 128 | row_Format.add(row_Map); 129 | } 130 | return row_Format; 131 | } 132 | 133 | private String[] array(String value) { 134 | return new String[] {value}; 135 | } 136 | 137 | private String[] array(int value) { 138 | return new String[] {String.valueOf(value)}; 139 | } 140 | 141 | public String getSheet_Name() { 142 | return sheet_Name; 143 | } 144 | 145 | public void setSheet_Name(String sheet_Name) { 146 | this.sheet_Name = sheet_Name; 147 | } 148 | 149 | public int[] getColumn_Width() { 150 | return column_Width; 151 | } 152 | 153 | public void setColumn_Width(int[] column_Width) { 154 | this.column_Width = column_Width; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/main/resources/templates/monthly.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 |

[[${title}]]

15 | 16 |
17 |
[[${message}]]
18 |
19 |
20 | 21 |
22 |
23 |
24 | [[${name}]] 25 |
26 |
27 | 28 | 31 |
32 |
33 |
34 |
35 | [[${japanese_Date}]] 36 |
37 |
38 | 39 | 42 |
43 |   44 |
45 | 46 | 49 |
50 |   51 |
52 | 53 | 56 |
57 |
58 | 59 | 60 | 61 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 |
63 | [[${label_Set.name}]] 64 |
前月繰り越し [[${carryover}]]
[[*{#temporals.format(date, 'd日')}]] [[*{subject}]] [[*{apply}]] [[*{income}]][[*{spending}]] 93 | [[${carryover} + ${income.get(status.index)} - ${spending.get(status.index)}]] 94 |
翌月繰り越し 113 | [[${carryover} + ${income.get(status.index)} - ${spending.get(status.index)}]] 114 | [[${carryover}]]
合 計 [[${income.get(status.index)}]] [[${spending.get(status.index)}]]
147 |
148 |
149 | メインページへ 150 |
151 | 152 | 153 | -------------------------------------------------------------------------------- /src/main/resources/templates/year.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 |

[[${title}]]

15 | 16 |
17 |
[[${message}]]
18 |
19 |
20 | 21 |
22 |
23 |
24 | [[${name}]] 25 |
26 |
27 | 28 | 29 | 32 |
33 |
34 |
35 |
36 | [[${year}]] 37 |
38 |
39 | 40 | 41 | 44 |
45 |   46 |
47 | [[${subject}]] 48 |
49 |   50 |
51 | 52 | 53 | 56 |
57 |
58 | 59 | 60 | 61 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 |
63 | [[${label_Set.name}]] 64 |
前年度繰り越し [[${carryover}]]
[[*{#temporals.format(date, 'M月d日')}]] [[*{subject}]] [[*{apply}]] [[*{income}]][[*{spending}]] 94 | [[${carryover} + ${income.get(status.index)} - ${spending.get(status.index)}]] 95 |
翌年繰り越し 115 | [[${carryover} + ${income.get(status.index)} - ${spending.get(status.index)}]] 116 | [[${carryover}]]
合 計 [[${income.get(status.index)}]] [[${spending.get(status.index)}]]
149 |
150 |
151 | メインページへ 152 |
153 | 154 | 155 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/DailyWorkSheet.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | import org.apache.poi.ss.usermodel.IndexedColors; 9 | 10 | public class DailyWorkSheet extends WorkSheet{ 11 | 12 | // コンストラクター 13 | public DailyWorkSheet() { 14 | // 印刷時のサイズ 15 | print_Scale = 72; 16 | // 印刷向きを縦にする 17 | this.printSetup = false; 18 | } 19 | public DailyWorkSheet(String sheet_Name, int[] column_Width, String[][] value_Data) { 20 | this.sheet_Name = sheet_Name; 21 | this.column_Width = column_Width; 22 | this.value_Data = value_Data; 23 | // 印刷時のサイズ 24 | print_Scale = 72; 25 | // 印刷向きを縦にする 26 | this.printSetup = false; 27 | } 28 | 29 | // 罫線("□"," ̄","_"," |","| ","二","冂","凵","匚","コ","ノ","乚","r","¬") 30 | // 位置("|","CS","DD","FL","JY","←","→") 31 | // 1行目 32 | String[] row_1_Border = {" "," "," "," "," "," "," "," "}; // 罫線 33 | String[] row_1_Align_ = {" ","→"," "," "," "," "," "," "}; // 位置 34 | // 2行目 35 | String[] row_2_Border = {" "," "," "," "," "," "," "," "}; // 罫線 36 | String[] row_2_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 37 | // 3行目 38 | String[] row_3_Border = {" "," "," "," "," "," "," "," "}; // 罫線 39 | String[] row_3_Align_ = {" "," "," "," ","→"," "," "," "}; // 位置 40 | // 4行目(ラベル行) 41 | String[] label_Border = {"□","□","□","□","□","□","□","□"}; // 罫線 42 | String[] label_Align_ = {"|","|","|","|","|","|","|","|"}; // 位置 43 | // 集計行 44 | String[] total_Border = {"匚","コ","□","□","□","□","□","□"}; // 罫線 45 | String[] total_Align_ = {"|","|","→","→","→","|","|","|"}; // 位置 46 | // フッター行 1行目 47 | String[] foot_1_Border = {" "," "," "," "," "," "," "," "}; // 罫線 48 | String[] foot_1_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 49 | // フッター行 2行目 50 | String[] foot_2_Border = {" "," "," "," "," "," "," "," "}; // 罫線 51 | String[] foot_2_Align_ = {" "," "," "," "," "," "," "," "}; // 位置 52 | // その他(データ行) 53 | String[] data__Border = {"□","□","□","□","□","□","□","□"}; // 罫線 54 | String[] data__Align_ = {" "," ","→","→","→","|","|","|"}; // 位置 55 | 56 | /** フォント定義用 Map リスト */ 57 | public List> fonts(){ 58 | List> fonts = new ArrayList<>(); 59 | Map font0 = new HashMap<>(); 60 | Map font1 = new HashMap<>(); 61 | // フォント0 62 | font0.put("fontName", "游ゴシック"); 63 | font0.put("fontHeight", "250"); 64 | // フォント1 65 | font1.put("fontName", "游ゴシック"); 66 | font1.put("fontHeight", "300"); 67 | fonts.add(font0); 68 | fonts.add(font1); 69 | return fonts; 70 | }; 71 | 72 | /** 行毎の書式設定用 Map リスト */ 73 | public List> row_Format(int row_Size){ 74 | 75 | // 行毎の書式設定用データ配列格納用 Map リスト 76 | List> row_Format = new ArrayList<>(); 77 | for (int i = 0; i < row_Size; i++) { 78 | // default の値 79 | int height = 400; 80 | int font = 0; 81 | String dataFormat = "G/標準"; 82 | short bg_color = IndexedColors.AUTOMATIC.getIndex(); 83 | String[] border = {" "," "," "," "," "," "," "," "}; 84 | String[] align = {" "," "," "," "," "," "," "," "}; 85 | if (i < row_Size - 4) { 86 | switch (i + 1) { 87 | case 1: // 1行目の場合 88 | font = 1; 89 | height = 500; 90 | border = row_1_Border; 91 | align = row_1_Align_; 92 | break; 93 | case 2: // 2行目の場合 94 | font = 1; 95 | height = 200; 96 | border = row_2_Border; 97 | align = row_2_Align_; 98 | break; 99 | case 3: // 3行目の場合 100 | height = 400; 101 | border = row_3_Border; 102 | align = row_3_Align_; 103 | break; 104 | case 4: // 4行目(ラベル行)の場合 105 | bg_color = IndexedColors.GREY_25_PERCENT.getIndex(); 106 | border = label_Border; 107 | align = label_Align_; 108 | break; 109 | case 5: // 5行目(前日繰越行)の場合 110 | dataFormat = "#,##0"; 111 | border = total_Border; 112 | align = total_Align_; 113 | break; 114 | default: // その他(データ行)の場合 115 | dataFormat = "#,##0"; 116 | border = data__Border; 117 | align = data__Align_; 118 | } 119 | } else if (i == row_Size - 4) { // 最後から4行目(合計行)の場合 120 | dataFormat = "#,##0"; 121 | height = 400; 122 | border = total_Border; 123 | align = total_Align_; 124 | } else if (i == row_Size - 3) { // 最後から3行目(累計行)の場合 125 | dataFormat = "#,##0"; 126 | height = 400; 127 | border = total_Border; 128 | align = total_Align_; 129 | } else if (i == row_Size - 2) { // 最後から2行目(フッター1行目)の場合 130 | dataFormat = "#,##0"; 131 | height = 400; 132 | border = foot_1_Border; 133 | align = foot_1_Align_; 134 | } else if (i == row_Size - 1) { // 最後から1行目(フッター2行目)の場合 135 | dataFormat = "#,##0"; 136 | height = 400; 137 | border = foot_2_Border; 138 | align = foot_2_Align_; 139 | } 140 | Map row_Map = new HashMap<>(); 141 | row_Map.put("border", border); 142 | row_Map.put("align", align); 143 | row_Map.put("height", array(height)); 144 | row_Map.put("font", array(font)); 145 | row_Map.put("dataFormat", array(dataFormat)); 146 | row_Map.put("bg_color", array(bg_color)); 147 | row_Format.add(row_Map); 148 | } 149 | return row_Format; 150 | } 151 | 152 | private String[] array(String value) { 153 | return new String[] {value}; 154 | } 155 | 156 | private String[] array(int value) { 157 | return new String[] {String.valueOf(value)}; 158 | } 159 | 160 | public String getSheet_Name() { 161 | return sheet_Name; 162 | } 163 | 164 | public void setSheet_Name(String sheet_Name) { 165 | this.sheet_Name = sheet_Name; 166 | } 167 | 168 | public int[] getColumn_Width() { 169 | return column_Width; 170 | } 171 | 172 | public void setColumn_Width(int[] column_Width) { 173 | this.column_Width = column_Width; 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/OptionData.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | import java.time.LocalDateTime; 5 | import java.time.LocalTime; 6 | import java.time.format.DateTimeFormatter; 7 | import java.util.ArrayList; 8 | 9 | public class OptionData { 10 | 11 | // 部屋番号 12 | public static Integer[] rooms = nums(1, 20 , 1); 13 | 14 | // 名前 15 | public static String[] names = names(); 16 | 17 | // 日付 18 | public static String[] dates = dates(40); 19 | 20 | // 時間 21 | public static String[] times = times(0, 0, 5); 22 | 23 | // 科目 24 | public static String[] subjects = subjects(); 25 | 26 | // 利用状況 27 | public static String[] use = {"利用中", "利用終了"}; 28 | 29 | // 曜日 30 | public static String[] day_of_week = {"月", "火", "水", "木", "金", "土", "日"}; 31 | 32 | // 年 33 | public static Integer[] year = nums(this_Year() - 50, this_Year() , 1); 34 | 35 | // 年/月 36 | public static String[] year_month = year_month((50 * 12), 1); 37 | 38 | // 月/日 39 | public static ArrayList month_day = month_day(); 40 | 41 | /** start から end まで add ずつ増やした数を代入した配列を作成 */ 42 | public static Integer[] nums(int start, int end, int add) { 43 | Integer[] nums = new Integer[(end - start) / add + 1]; 44 | for (int i = 0; i < nums.length; i++) { 45 | nums[i] = i * add + start; 46 | } 47 | return nums; 48 | } 49 | 50 | private static String[] subjects() { 51 | return null; 52 | } 53 | 54 | public static String[] names() { 55 | // TODO 自動生成されたメソッド・スタブ 56 | return null; 57 | } 58 | 59 | /** 開始時刻の末尾を 0 または 5 に変換し、そこから chopped_Minute 分ずつ増やした時刻の配列を作成 */ 60 | public static String[] times(int start_Hour, int start_Minute, int chopped_Minute) { 61 | // 表示形式を指定 62 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm"); 63 | // 開始の 時刻 を設定 64 | LocalDateTime dateTime = null; 65 | try { 66 | dateTime = LocalDateTime.now().with(LocalTime.of(start_Hour, start_Minute)); 67 | } catch (Exception e) { 68 | dateTime = LocalDateTime.now().with(LocalTime.of(0, 0)); 69 | } 70 | // 配列を作成し5分刻みの時刻を代入 71 | String[] times = new String[60 / chopped_Minute * 24]; 72 | for (int i = 0; i < times.length; i++) { 73 | // フォーマット 74 | String data = dateTimeFormatter.format(dateTime); 75 | // 末尾を 0 または 5 に変換して times[i] に代入 76 | // minutes の1の位を取得 77 | String minutesLast = data.substring(data.length()-1, data.length()); 78 | // 0 にするか 5 にするか判定 79 | if (Integer.parseInt(minutesLast) < 5) { 80 | minutesLast = "0"; 81 | } else { 82 | minutesLast = "5"; 83 | } 84 | // 末尾を変換 85 | times[i] = data.substring(0, data.length()-1) + minutesLast; 86 | // dateTimeを chopped_Minute 分増やす 87 | dateTime = dateTime.plusMinutes(chopped_Minute); 88 | } 89 | return times; 90 | } 91 | 92 | public static String now() { 93 | // 現在日時を取得 94 | LocalDateTime dateTime = LocalDateTime.now(); 95 | // 表示形式を指定 96 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm"); 97 | return dateTimeFormatter.format(dateTime); 98 | } 99 | 100 | public static int this_Year() { 101 | // 現在日時を取得 102 | LocalDateTime dateTime = LocalDateTime.now(); 103 | // 表示形式を指定 104 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy"); 105 | return Integer.parseInt(dateTimeFormatter.format(dateTime)); 106 | } 107 | 108 | public static String[] dates(int years) { 109 | // 現在日時を取得 110 | LocalDateTime dateTime = LocalDateTime.now(); 111 | // dateTimeを years 年減らす 112 | dateTime = dateTime.minusYears(years); 113 | // 表示形式を指定 114 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd"); 115 | // 配列を作成し今日から years 年前迄の日付を代入 116 | String[] data = new String[years * 366]; 117 | for (int i = 0; i < data.length; i++) { 118 | // フォーマット 119 | data[i] = dateTimeFormatter.format(dateTime); 120 | // dateTimeを1日増やす 121 | dateTime = dateTime.plusDays(1); 122 | } 123 | return data; 124 | } 125 | 126 | public static String[] days(String month) { 127 | int lastDay = 31; 128 | switch(month) { 129 | case "2": 130 | lastDay = 29; 131 | break; 132 | case "4": 133 | case "6": 134 | case "9": 135 | case "11": 136 | lastDay = 30; 137 | break; 138 | } 139 | Integer[] days = nums(1, lastDay, 1); 140 | return arrayAlignment(days, 2, "0"); 141 | } 142 | 143 | public static String[] month() { 144 | // 1から12の配列を作成 145 | Integer[] month = nums(1, 12, 1); 146 | // 配列の中身の文字数を2文字に揃えて返す 147 | return arrayAlignment(month, 2, "0") ; 148 | } 149 | 150 | /** String date の年数部分から end まで add づつ増やした年数を 代入した配列を作成 */ 151 | public static String[] years(String date, int end_year, int add) { 152 | int year = Integer.parseInt(date.split("/")[0].split("_")[0].split("年")[0]); 153 | Integer[] years = nums(year, end_year, add); 154 | return arrayAlignment(years, 4, "0"); 155 | } 156 | 157 | /** months_Ago か月前から months_Later か月後迄の [年/月] を取得 */ 158 | public static String[] year_month(int months_Ago, int months_Later) { 159 | // year_Ago 月前(スタート値)を取得 160 | LocalDate localDate = LocalDate.now().minusMonths(months_Ago); 161 | // 表示形式を指定 162 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM"); 163 | // データ数分の要素を持つ配列を作成し [年/月] を代入 164 | String[] data = new String[months_Ago + months_Later + 1]; 165 | for (int i = 0; i < data.length; i++) { 166 | // localDateを "yyyy/MM" 形式に変換 167 | data[i] = dateTimeFormatter.format(localDate); 168 | // dateTimeを1月増やす 169 | localDate = localDate.plusMonths(1); 170 | } 171 | return data; 172 | } 173 | 174 | private static ArrayList month_day() { 175 | ArrayList monthDay = new ArrayList(); 176 | String[] month = month(); 177 | for (String mon : month) { 178 | String[] days = days(mon); 179 | for (String day : days) { 180 | monthDay.add(mon + "/" + day); 181 | } 182 | } 183 | return monthDay; 184 | } 185 | 186 | /** 配列の中身を同じ文字数に揃える */ 187 | public static String[] arrayAlignment(Object[] array, int word_count , String fill) { 188 | // fill を word_count の数だけ繋げる 189 | String fills = ""; 190 | for (int i = 0; i < word_count; i++) { 191 | fills += fill; 192 | } 193 | // Object[] array と同じ length の String 配列 alignmentArray を作成 194 | String[] alignmentArray = new String[array.length]; 195 | for (int i = 0; i < alignmentArray.length; i++) { 196 | // 先頭に fills を付ける 197 | String string = (fills + array[i]); 198 | //末尾から word_count の数だけ文字を抜き出し alignmentArray[i] に代入 199 | alignmentArray[i] = string.substring(string.length() - word_count); 200 | } 201 | return alignmentArray; 202 | } 203 | 204 | } 205 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Apache Maven Wrapper startup batch script, version 3.2.0 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 28 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 29 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 30 | @REM e.g. to debug Maven itself, use 31 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 32 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 33 | @REM ---------------------------------------------------------------------------- 34 | 35 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 36 | @echo off 37 | @REM set title of command window 38 | title %0 39 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 40 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 41 | 42 | @REM set %HOME% to equivalent of $HOME 43 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 44 | 45 | @REM Execute a user defined script before this one 46 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 47 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 48 | if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* 49 | if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* 50 | :skipRcPre 51 | 52 | @setlocal 53 | 54 | set ERROR_CODE=0 55 | 56 | @REM To isolate internal variables from possible post scripts, we use another setlocal 57 | @setlocal 58 | 59 | @REM ==== START VALIDATION ==== 60 | if not "%JAVA_HOME%" == "" goto OkJHome 61 | 62 | echo. 63 | echo Error: JAVA_HOME not found in your environment. >&2 64 | echo Please set the JAVA_HOME variable in your environment to match the >&2 65 | echo location of your Java installation. >&2 66 | echo. 67 | goto error 68 | 69 | :OkJHome 70 | if exist "%JAVA_HOME%\bin\java.exe" goto init 71 | 72 | echo. 73 | echo Error: JAVA_HOME is set to an invalid directory. >&2 74 | echo JAVA_HOME = "%JAVA_HOME%" >&2 75 | echo Please set the JAVA_HOME variable in your environment to match the >&2 76 | echo location of your Java installation. >&2 77 | echo. 78 | goto error 79 | 80 | @REM ==== END VALIDATION ==== 81 | 82 | :init 83 | 84 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 85 | @REM Fallback to current working directory if not found. 86 | 87 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 88 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 89 | 90 | set EXEC_DIR=%CD% 91 | set WDIR=%EXEC_DIR% 92 | :findBaseDir 93 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 94 | cd .. 95 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 96 | set WDIR=%CD% 97 | goto findBaseDir 98 | 99 | :baseDirFound 100 | set MAVEN_PROJECTBASEDIR=%WDIR% 101 | cd "%EXEC_DIR%" 102 | goto endDetectBaseDir 103 | 104 | :baseDirNotFound 105 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 106 | cd "%EXEC_DIR%" 107 | 108 | :endDetectBaseDir 109 | 110 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 111 | 112 | @setlocal EnableExtensions EnableDelayedExpansion 113 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 114 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 115 | 116 | :endReadAdditionalConfig 117 | 118 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 123 | 124 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 125 | IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | if "%MVNW_VERBOSE%" == "true" ( 132 | echo Found %WRAPPER_JAR% 133 | ) 134 | ) else ( 135 | if not "%MVNW_REPOURL%" == "" ( 136 | SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 137 | ) 138 | if "%MVNW_VERBOSE%" == "true" ( 139 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 140 | echo Downloading from: %WRAPPER_URL% 141 | ) 142 | 143 | powershell -Command "&{"^ 144 | "$webclient = new-object System.Net.WebClient;"^ 145 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 146 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 147 | "}"^ 148 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ 149 | "}" 150 | if "%MVNW_VERBOSE%" == "true" ( 151 | echo Finished downloading %WRAPPER_JAR% 152 | ) 153 | ) 154 | @REM End of extension 155 | 156 | @REM If specified, validate the SHA-256 sum of the Maven wrapper jar file 157 | SET WRAPPER_SHA_256_SUM="" 158 | FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 159 | IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B 160 | ) 161 | IF NOT %WRAPPER_SHA_256_SUM%=="" ( 162 | powershell -Command "&{"^ 163 | "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ 164 | "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ 165 | " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ 166 | " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ 167 | " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ 168 | " exit 1;"^ 169 | "}"^ 170 | "}" 171 | if ERRORLEVEL 1 goto error 172 | ) 173 | 174 | @REM Provide a "standardized" way to retrieve the CLI args that will 175 | @REM work with both Windows and non-Windows executions. 176 | set MAVEN_CMD_LINE_ARGS=%* 177 | 178 | %MAVEN_JAVA_EXE% ^ 179 | %JVM_CONFIG_MAVEN_PROPS% ^ 180 | %MAVEN_OPTS% ^ 181 | %MAVEN_DEBUG_OPTS% ^ 182 | -classpath %WRAPPER_JAR% ^ 183 | "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ 184 | %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 185 | if ERRORLEVEL 1 goto error 186 | goto end 187 | 188 | :error 189 | set ERROR_CODE=1 190 | 191 | :end 192 | @endlocal & set ERROR_CODE=%ERROR_CODE% 193 | 194 | if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost 195 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 196 | if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" 197 | if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" 198 | :skipRcPost 199 | 200 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 201 | if "%MAVEN_BATCH_PAUSE%"=="on" pause 202 | 203 | if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% 204 | 205 | cmd /C exit /B %ERROR_CODE% 206 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Apache Maven Wrapper startup batch script, version 3.2.0 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | # e.g. to debug Maven itself, use 32 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | # ---------------------------------------------------------------------------- 35 | 36 | if [ -z "$MAVEN_SKIP_RC" ] ; then 37 | 38 | if [ -f /usr/local/etc/mavenrc ] ; then 39 | . /usr/local/etc/mavenrc 40 | fi 41 | 42 | if [ -f /etc/mavenrc ] ; then 43 | . /etc/mavenrc 44 | fi 45 | 46 | if [ -f "$HOME/.mavenrc" ] ; then 47 | . "$HOME/.mavenrc" 48 | fi 49 | 50 | fi 51 | 52 | # OS specific support. $var _must_ be set to either true or false. 53 | cygwin=false; 54 | darwin=false; 55 | mingw=false 56 | case "$(uname)" in 57 | CYGWIN*) cygwin=true ;; 58 | MINGW*) mingw=true;; 59 | Darwin*) darwin=true 60 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 61 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 62 | if [ -z "$JAVA_HOME" ]; then 63 | if [ -x "/usr/libexec/java_home" ]; then 64 | JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME 65 | else 66 | JAVA_HOME="/Library/Java/Home"; export JAVA_HOME 67 | fi 68 | fi 69 | ;; 70 | esac 71 | 72 | if [ -z "$JAVA_HOME" ] ; then 73 | if [ -r /etc/gentoo-release ] ; then 74 | JAVA_HOME=$(java-config --jre-home) 75 | fi 76 | fi 77 | 78 | # For Cygwin, ensure paths are in UNIX format before anything is touched 79 | if $cygwin ; then 80 | [ -n "$JAVA_HOME" ] && 81 | JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 82 | [ -n "$CLASSPATH" ] && 83 | CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 84 | fi 85 | 86 | # For Mingw, ensure paths are in UNIX format before anything is touched 87 | if $mingw ; then 88 | [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && 89 | JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" 90 | fi 91 | 92 | if [ -z "$JAVA_HOME" ]; then 93 | javaExecutable="$(which javac)" 94 | if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then 95 | # readlink(1) is not available as standard on Solaris 10. 96 | readLink=$(which readlink) 97 | if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then 98 | if $darwin ; then 99 | javaHome="$(dirname "\"$javaExecutable\"")" 100 | javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" 101 | else 102 | javaExecutable="$(readlink -f "\"$javaExecutable\"")" 103 | fi 104 | javaHome="$(dirname "\"$javaExecutable\"")" 105 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 106 | JAVA_HOME="$javaHome" 107 | export JAVA_HOME 108 | fi 109 | fi 110 | fi 111 | 112 | if [ -z "$JAVACMD" ] ; then 113 | if [ -n "$JAVA_HOME" ] ; then 114 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 115 | # IBM's JDK on AIX uses strange locations for the executables 116 | JAVACMD="$JAVA_HOME/jre/sh/java" 117 | else 118 | JAVACMD="$JAVA_HOME/bin/java" 119 | fi 120 | else 121 | JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" 122 | fi 123 | fi 124 | 125 | if [ ! -x "$JAVACMD" ] ; then 126 | echo "Error: JAVA_HOME is not defined correctly." >&2 127 | echo " We cannot execute $JAVACMD" >&2 128 | exit 1 129 | fi 130 | 131 | if [ -z "$JAVA_HOME" ] ; then 132 | echo "Warning: JAVA_HOME environment variable is not set." 133 | fi 134 | 135 | # traverses directory structure from process work directory to filesystem root 136 | # first directory with .mvn subdirectory is considered project base directory 137 | find_maven_basedir() { 138 | if [ -z "$1" ] 139 | then 140 | echo "Path not specified to find_maven_basedir" 141 | return 1 142 | fi 143 | 144 | basedir="$1" 145 | wdir="$1" 146 | while [ "$wdir" != '/' ] ; do 147 | if [ -d "$wdir"/.mvn ] ; then 148 | basedir=$wdir 149 | break 150 | fi 151 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 152 | if [ -d "${wdir}" ]; then 153 | wdir=$(cd "$wdir/.." || exit 1; pwd) 154 | fi 155 | # end of workaround 156 | done 157 | printf '%s' "$(cd "$basedir" || exit 1; pwd)" 158 | } 159 | 160 | # concatenates all lines of a file 161 | concat_lines() { 162 | if [ -f "$1" ]; then 163 | # Remove \r in case we run on Windows within Git Bash 164 | # and check out the repository with auto CRLF management 165 | # enabled. Otherwise, we may read lines that are delimited with 166 | # \r\n and produce $'-Xarg\r' rather than -Xarg due to word 167 | # splitting rules. 168 | tr -s '\r\n' ' ' < "$1" 169 | fi 170 | } 171 | 172 | log() { 173 | if [ "$MVNW_VERBOSE" = true ]; then 174 | printf '%s\n' "$1" 175 | fi 176 | } 177 | 178 | BASE_DIR=$(find_maven_basedir "$(dirname "$0")") 179 | if [ -z "$BASE_DIR" ]; then 180 | exit 1; 181 | fi 182 | 183 | MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR 184 | log "$MAVEN_PROJECTBASEDIR" 185 | 186 | ########################################################################################## 187 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 188 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 189 | ########################################################################################## 190 | wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" 191 | if [ -r "$wrapperJarPath" ]; then 192 | log "Found $wrapperJarPath" 193 | else 194 | log "Couldn't find $wrapperJarPath, downloading it ..." 195 | 196 | if [ -n "$MVNW_REPOURL" ]; then 197 | wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 198 | else 199 | wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" 200 | fi 201 | while IFS="=" read -r key value; do 202 | # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) 203 | safeValue=$(echo "$value" | tr -d '\r') 204 | case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; 205 | esac 206 | done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 207 | log "Downloading from: $wrapperUrl" 208 | 209 | if $cygwin; then 210 | wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") 211 | fi 212 | 213 | if command -v wget > /dev/null; then 214 | log "Found wget ... using wget" 215 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" 216 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 217 | wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 218 | else 219 | wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" 220 | fi 221 | elif command -v curl > /dev/null; then 222 | log "Found curl ... using curl" 223 | [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" 224 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 225 | curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 226 | else 227 | curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" 228 | fi 229 | else 230 | log "Falling back to using Java to download" 231 | javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" 232 | javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" 233 | # For Cygwin, switch paths to Windows format before running javac 234 | if $cygwin; then 235 | javaSource=$(cygpath --path --windows "$javaSource") 236 | javaClass=$(cygpath --path --windows "$javaClass") 237 | fi 238 | if [ -e "$javaSource" ]; then 239 | if [ ! -e "$javaClass" ]; then 240 | log " - Compiling MavenWrapperDownloader.java ..." 241 | ("$JAVA_HOME/bin/javac" "$javaSource") 242 | fi 243 | if [ -e "$javaClass" ]; then 244 | log " - Running MavenWrapperDownloader.java ..." 245 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" 246 | fi 247 | fi 248 | fi 249 | fi 250 | ########################################################################################## 251 | # End of extension 252 | ########################################################################################## 253 | 254 | # If specified, validate the SHA-256 sum of the Maven wrapper jar file 255 | wrapperSha256Sum="" 256 | while IFS="=" read -r key value; do 257 | case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; 258 | esac 259 | done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" 260 | if [ -n "$wrapperSha256Sum" ]; then 261 | wrapperSha256Result=false 262 | if command -v sha256sum > /dev/null; then 263 | if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then 264 | wrapperSha256Result=true 265 | fi 266 | elif command -v shasum > /dev/null; then 267 | if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then 268 | wrapperSha256Result=true 269 | fi 270 | else 271 | echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." 272 | echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." 273 | exit 1 274 | fi 275 | if [ $wrapperSha256Result = false ]; then 276 | echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 277 | echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 278 | echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 279 | exit 1 280 | fi 281 | fi 282 | 283 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 284 | 285 | # For Cygwin, switch paths to Windows format before running java 286 | if $cygwin; then 287 | [ -n "$JAVA_HOME" ] && 288 | JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 289 | [ -n "$CLASSPATH" ] && 290 | CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 291 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 292 | MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 293 | fi 294 | 295 | # Provide a "standardized" way to retrieve the CLI args that will 296 | # work with both Windows and non-Windows executions. 297 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" 298 | export MAVEN_CMD_LINE_ARGS 299 | 300 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 301 | 302 | # shellcheck disable=SC2086 # safe args 303 | exec "$JAVACMD" \ 304 | $MAVEN_OPTS \ 305 | $MAVEN_DEBUG_OPTS \ 306 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 307 | "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 308 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 309 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/Excel.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | import java.io.UnsupportedEncodingException; 6 | import java.net.URLEncoder; 7 | import java.time.LocalDateTime; 8 | import java.time.format.DateTimeFormatter; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | import javax.servlet.http.HttpServletResponse; 14 | 15 | import org.apache.poi.ss.usermodel.BorderStyle; 16 | import org.apache.poi.ss.usermodel.Cell; 17 | import org.apache.poi.ss.usermodel.CellStyle; 18 | import org.apache.poi.ss.usermodel.DataFormat; 19 | import org.apache.poi.ss.usermodel.FillPatternType; 20 | import org.apache.poi.ss.usermodel.Font; 21 | import org.apache.poi.ss.usermodel.HorizontalAlignment; 22 | import org.apache.poi.ss.usermodel.IndexedColors; 23 | import org.apache.poi.ss.usermodel.PrintSetup; 24 | import org.apache.poi.ss.usermodel.Row; 25 | import org.apache.poi.ss.usermodel.Row.MissingCellPolicy; 26 | import org.apache.poi.ss.usermodel.Sheet; 27 | import org.apache.poi.ss.usermodel.VerticalAlignment; 28 | import org.apache.poi.ss.usermodel.Workbook; 29 | import org.apache.poi.xssf.usermodel.XSSFWorkbook; 30 | 31 | public class Excel { 32 | 33 | MissingCellPolicy cellPolicy = MissingCellPolicy.CREATE_NULL_AS_BLANK; 34 | 35 | /** alignment_Pattern に応じてセルの alignment を設定 */ 36 | public CellStyle alignment_Apply(CellStyle cellStyle, String alignment_Pattern) { 37 | if(alignment_Pattern != null) { 38 | switch(alignment_Pattern) { 39 | case "|": 40 | cellStyle.setAlignment(HorizontalAlignment.CENTER); 41 | break; 42 | case "CS": 43 | cellStyle.setAlignment(HorizontalAlignment.CENTER_SELECTION); 44 | break; 45 | case "DD": 46 | cellStyle.setAlignment(HorizontalAlignment.DISTRIBUTED); 47 | break; 48 | case "FL": 49 | cellStyle.setAlignment(HorizontalAlignment.FILL); 50 | break; 51 | case "JY": 52 | cellStyle.setAlignment(HorizontalAlignment.JUSTIFY); 53 | break; 54 | case "←": 55 | cellStyle.setAlignment(HorizontalAlignment.LEFT); 56 | break; 57 | case "→": 58 | cellStyle.setAlignment(HorizontalAlignment.RIGHT); 59 | break; 60 | default: 61 | cellStyle.setAlignment(HorizontalAlignment.GENERAL); 62 | } 63 | } 64 | return cellStyle; 65 | } 66 | 67 | /** border_Pattern に応じてセルの 罫線 を設定 */ 68 | public CellStyle border_Apply(CellStyle cellStyle, String border_Pattern) { 69 | if(border_Pattern != null) { 70 | switch(border_Pattern) { 71 | case "□": 72 | cellStyle.setBorderTop(BorderStyle.THIN); 73 | cellStyle.setBorderBottom(BorderStyle.THIN); 74 | cellStyle.setBorderLeft(BorderStyle.THIN); 75 | cellStyle.setBorderRight(BorderStyle.THIN); 76 | break; 77 | case " ̄": 78 | cellStyle.setBorderTop(BorderStyle.THIN); 79 | cellStyle.setBorderBottom(BorderStyle.NONE); 80 | cellStyle.setBorderLeft(BorderStyle.NONE); 81 | cellStyle.setBorderRight(BorderStyle.NONE); 82 | break; 83 | case "_": 84 | cellStyle.setBorderTop(BorderStyle.NONE); 85 | cellStyle.setBorderBottom(BorderStyle.THIN); 86 | cellStyle.setBorderLeft(BorderStyle.NONE); 87 | cellStyle.setBorderRight(BorderStyle.NONE); 88 | break; 89 | case " |": 90 | cellStyle.setBorderTop(BorderStyle.NONE); 91 | cellStyle.setBorderBottom(BorderStyle.NONE); 92 | cellStyle.setBorderLeft(BorderStyle.NONE); 93 | cellStyle.setBorderRight(BorderStyle.THIN); 94 | break; 95 | case "| ": 96 | cellStyle.setBorderTop(BorderStyle.NONE); 97 | cellStyle.setBorderBottom(BorderStyle.NONE); 98 | cellStyle.setBorderLeft(BorderStyle.THIN); 99 | cellStyle.setBorderRight(BorderStyle.NONE); 100 | break; 101 | case "二": 102 | cellStyle.setBorderTop(BorderStyle.THIN); 103 | cellStyle.setBorderBottom(BorderStyle.THIN); 104 | cellStyle.setBorderLeft(BorderStyle.NONE); 105 | cellStyle.setBorderRight(BorderStyle.NONE); 106 | break; 107 | case "||": 108 | cellStyle.setBorderTop(BorderStyle.NONE); 109 | cellStyle.setBorderBottom(BorderStyle.NONE); 110 | cellStyle.setBorderLeft(BorderStyle.THIN); 111 | cellStyle.setBorderRight(BorderStyle.THIN); 112 | break; 113 | case "冂": 114 | cellStyle.setBorderTop(BorderStyle.THIN); 115 | cellStyle.setBorderBottom(BorderStyle.NONE); 116 | cellStyle.setBorderLeft(BorderStyle.THIN); 117 | cellStyle.setBorderRight(BorderStyle.THIN); 118 | break; 119 | case "凵": 120 | cellStyle.setBorderTop(BorderStyle.NONE); 121 | cellStyle.setBorderBottom(BorderStyle.THIN); 122 | cellStyle.setBorderLeft(BorderStyle.THIN); 123 | cellStyle.setBorderRight(BorderStyle.THIN); 124 | break; 125 | case "匚": 126 | cellStyle.setBorderTop(BorderStyle.THIN); 127 | cellStyle.setBorderBottom(BorderStyle.THIN); 128 | cellStyle.setBorderLeft(BorderStyle.THIN); 129 | cellStyle.setBorderRight(BorderStyle.NONE); 130 | break; 131 | case "コ": 132 | cellStyle.setBorderTop(BorderStyle.THIN); 133 | cellStyle.setBorderBottom(BorderStyle.THIN); 134 | cellStyle.setBorderLeft(BorderStyle.NONE); 135 | cellStyle.setBorderRight(BorderStyle.THIN); 136 | break; 137 | case "ノ": 138 | cellStyle.setBorderTop(BorderStyle.NONE); 139 | cellStyle.setBorderBottom(BorderStyle.THIN); 140 | cellStyle.setBorderLeft(BorderStyle.NONE); 141 | cellStyle.setBorderRight(BorderStyle.THIN); 142 | break; 143 | case "乚": 144 | cellStyle.setBorderTop(BorderStyle.NONE); 145 | cellStyle.setBorderBottom(BorderStyle.THIN); 146 | cellStyle.setBorderLeft(BorderStyle.THIN); 147 | cellStyle.setBorderRight(BorderStyle.NONE); 148 | break; 149 | case "r": 150 | cellStyle.setBorderTop(BorderStyle.THIN); 151 | cellStyle.setBorderBottom(BorderStyle.NONE); 152 | cellStyle.setBorderLeft(BorderStyle.THIN); 153 | cellStyle.setBorderRight(BorderStyle.NONE); 154 | break; 155 | case "¬": 156 | cellStyle.setBorderTop(BorderStyle.THIN); 157 | cellStyle.setBorderBottom(BorderStyle.NONE); 158 | cellStyle.setBorderLeft(BorderStyle.NONE); 159 | cellStyle.setBorderRight(BorderStyle.THIN); 160 | break; 161 | case " ": 162 | cellStyle.setBorderTop(BorderStyle.NONE); 163 | cellStyle.setBorderBottom(BorderStyle.NONE); 164 | cellStyle.setBorderLeft(BorderStyle.NONE); 165 | cellStyle.setBorderRight(BorderStyle.NONE); 166 | break; 167 | } 168 | } 169 | return cellStyle; 170 | } 171 | 172 | /** 1シート分のデータを 1つのExcelファイル として出力 */ 173 | public String output_Excel_Sheet(String name_Head, WorkSheet workSheet, HttpServletResponse response) { 174 | ___console_Out___("output_Excel_Sheet() 開始"); 175 | String file_Name = with_Now(name_Head) + ".xlsx"; 176 | String message = file_Name + " のダウンロード"; 177 | try ( 178 | Workbook workbook = new XSSFWorkbook(); 179 | OutputStream outputStream = response.getOutputStream()){ 180 | // Sheetを 作成 181 | sheet_Making(workbook, workSheet); 182 | // ファイル名を指定して保存 183 | if (response_Making(response, file_Name)) { 184 | workbook.write(outputStream); 185 | message += "が完了しました"; 186 | } 187 | workbook.close(); 188 | message += " workbook を close() しました"; 189 | } catch (IOException e) { 190 | message += "が正常に完了出来ませんでした"; 191 | ___console_Out___(e.getMessage()); 192 | } 193 | ___console_Out___("output_Excel() 終了"); 194 | return message; 195 | } 196 | 197 | /** Sheetを 作成 */ 198 | public Sheet sheet_Making(Workbook workbook, WorkSheet work_Sheet) { 199 | ___console_Out___("sheet_Making() 開始"); 200 | /* シートを作成 */ 201 | // シート名取得 202 | String sheet_Name = work_Sheet.getSheet_Name(); 203 | ___console_Out___("sheet_Name = " + sheet_Name); 204 | // シート名 sheet_Name のシートを作成 205 | Sheet sheet = workbook.createSheet(sheet_Name); 206 | String[][] value_Data = work_Sheet.getValue_Data(); 207 | // 行数取得 208 | int row_Size = value_Data.length; 209 | // 書式定義用データのリスト取得 210 | List> row_Format = work_Sheet.row_Format(row_Size); 211 | /* 使用するフォントを定義 */ 212 | // フォント定義用データリスト取得 213 | List> work_Sheet_Fonts = work_Sheet.fonts(); 214 | // フォント格納用リスト作成 215 | Listfonts = new ArrayList<>(); 216 | // フォント格納用リスト分ループ 217 | for (Map work_Sheet_Font : work_Sheet_Fonts) { 218 | // 新しいフォント作成 219 | Font font = workbook.createFont(); 220 | // フォント名取得 221 | font.setFontName(work_Sheet_Font.get("fontName")); 222 | // フォントの高さ取得 223 | font.setFontHeight((short) Integer.parseInt(work_Sheet_Font.get("fontHeight"))); 224 | // フォント格納用リストにフォントをセット 225 | fonts.add(font); 226 | } 227 | // 数値の表示形式設定用object 228 | DataFormat dataFormat = workbook.createDataFormat(); 229 | // 行ループ 230 | for (int i = 0; i < row_Size; i++) { 231 | // 行を定義 232 | Row row = sheet.createRow(i); 233 | // 行フォーマット 234 | Map row_Map = row_Format.get(i); 235 | // 行の高さを取得 236 | int height = Integer.parseInt(row_Map.get("height")[0]); 237 | // 取得した高さを行にセット 238 | row.setHeight((short) height); 239 | // 列数取得 240 | int column_Size = value_Data[i].length; 241 | // 列数分ループ 242 | for (int j = 0; j < column_Size; j++) { 243 | // セルを定義 244 | Cell cell = row.createCell(j); 245 | String value = value_Data[i][j]; 246 | // セルに値をセット 247 | if(is_Double(value)){ 248 | cell.setCellValue(Double.parseDouble(value)); 249 | } else { 250 | if (!value.equals("")) cell.setCellValue(value); 251 | } 252 | // セルスタイルを定義 253 | CellStyle cellStyle = workbook.createCellStyle(); 254 | // セルのフォントスタイルのリスト番号を取得 255 | int font_Num = Integer.parseInt(row_Map.get("font")[0]); 256 | // 取得した番号からセルのフォント決定 257 | Font font = fonts.get(font_Num); 258 | // 決定したフォントを cellStyle にセット 259 | cellStyle.setFont(font); 260 | // 数値の表示形式を設定 261 | cellStyle.setDataFormat(dataFormat.getFormat(row_Map.get("dataFormat")[0])); 262 | // 背景色指定 263 | if (row_Map.get("bg_color") != null) { 264 | bg_color_Apply(cellStyle, row_Map.get("bg_color")[0]); 265 | } 266 | // 縦配置 267 | cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); 268 | // 横配置 269 | alignment_Apply(cellStyle, row_Map.get("align")[j]); 270 | // 罫線指定 271 | border_Apply(cellStyle, row_Map.get("border")[j]); 272 | // セルにセルスタイルを適用 273 | cell.setCellStyle(cellStyle); 274 | // 最後の行のみ 275 | if (i == row_Size - 1) { 276 | int[] column_Width = work_Sheet.getColumn_Width(); 277 | if (column_Width != null) { 278 | // 列幅設定(1文字分の横幅 × 文字数 + 微調整分の幅) 279 | sheet.setColumnWidth(j, 512 * column_Width[j] + 0); 280 | } 281 | // 列幅設定(オート) 282 | // sheet.autoSizeColumn(j); 283 | // 最後の列のみ印刷範囲設定 284 | if(j == column_Size - 1) { 285 | // 印刷範囲設定 286 | workbook.setPrintArea(0, 0, j, 0, i); 287 | } 288 | } 289 | } 290 | } 291 | 292 | // // 全改ページ位置削除 293 | // for (int rowBreak : sheet.getRowBreaks()) { 294 | // sheet.removeRowBreak(rowBreak); 295 | // } 296 | // for (int colBreak : sheet.getColumnBreaks()) { 297 | // sheet.removeColumnBreak(colBreak); 298 | // } 299 | // 300 | // sheet.setColumnBreak(7); // 改ページ位置設定 301 | // sheet.removeColumnBreak(4); // 改ページ位置削除 302 | 303 | // 印刷設定 304 | PrintSetup printSetup = sheet.getPrintSetup(); 305 | printSetup.setScale((short) work_Sheet.print_Scale); // 印刷のサイズを設定 306 | printSetup.setLandscape(work_Sheet.printSetup); // 縦横設定 307 | 308 | // printSetup.setFitWidth((short) 1); // 全列を1ページに 309 | // printSetup.setFitHeight((short) 0); // 全行のページ数は指定しない 310 | // sheet.setAutobreaks(true); 311 | 312 | ___console_Out___("sheet_Making() 終了"); 313 | return sheet; 314 | } 315 | 316 | // 色指定 317 | private void bg_color_Apply(CellStyle cellStyle, String color_Index) { 318 | if(color_Index != null) { 319 | short bg_Index = (short) Integer.parseInt(color_Index); 320 | // color_Index が AUTOMATIC のindexだったら何もしない 321 | if(bg_Index != IndexedColors.AUTOMATIC.getIndex()) { 322 | cellStyle.setFillForegroundColor((short) Integer.parseInt(color_Index)); 323 | cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); 324 | } 325 | } 326 | } 327 | 328 | private boolean response_Making(HttpServletResponse response, String file_Name) { 329 | boolean is_Make = false; 330 | String encodedFilename = with_Now("create") + ".xlsx"; 331 | try { 332 | encodedFilename = URLEncoder.encode(file_Name, "UTF-8"); 333 | } catch (UnsupportedEncodingException e) { 334 | e.printStackTrace(); 335 | } 336 | ___console_Out___("file_Name を " + encodedFilename + "に設定しました"); 337 | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); 338 | response.setHeader("Content-Disposition", "attachment;filename=\"" + encodedFilename + "\""); 339 | response.setCharacterEncoding("UTF-8"); 340 | is_Make = true; 341 | return is_Make; 342 | } 343 | 344 | /** Table データを Excel として出力 */ 345 | public String output_Excel(String name_Head, String[] column_Names, int[] column_Width, String[][] table_Data, HttpServletResponse response) { 346 | ___console_Out___("output_Excel() 開始"); 347 | 348 | String file_Name = with_Now(name_Head) + ".xlsx"; 349 | String sheet_Name = with_Now(name_Head); 350 | String message = file_Name + " のダウンロード"; 351 | try (Workbook workbook = new XSSFWorkbook(); 352 | OutputStream outputStream = response.getOutputStream()){ 353 | Sheet sheet = workbook.createSheet(sheet_Name); 354 | // 使用するフォントを定義 355 | Font font = workbook.createFont(); 356 | font.setFontName("游ゴシック"); 357 | 358 | // ヘッダー行 359 | // セルスタイルを定義 360 | CellStyle header_CellStyle = workbook.createCellStyle(); 361 | // 色指定 362 | header_CellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); 363 | header_CellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); 364 | // 罫線指定 365 | header_CellStyle.setBorderTop(BorderStyle.THIN); 366 | header_CellStyle.setBorderBottom(BorderStyle.THIN); 367 | header_CellStyle.setBorderLeft(BorderStyle.THIN); 368 | header_CellStyle.setBorderRight(BorderStyle.THIN); 369 | // 中央揃え 370 | header_CellStyle.setAlignment(HorizontalAlignment.CENTER); 371 | // フォントをセット 372 | header_CellStyle.setFont(font); 373 | 374 | // column_Names 分ループ 375 | Row row = sheet.createRow(0); 376 | for (int i = 0; i < column_Names.length; i++) { 377 | Cell cell = row.createCell(i); 378 | cell.setCellValue(column_Names[i]); 379 | // セルにセルスタイルを適用 380 | cell.setCellStyle(header_CellStyle); 381 | if (column_Width != null) { 382 | // 列幅設定(1文字分の横幅 × 文字数 + 微調整分の幅) 383 | sheet.setColumnWidth(i, 512 * column_Width[i] + 0); 384 | } 385 | } 386 | 387 | // データ行 388 | // セルスタイルを定義 389 | CellStyle data_CellStyle = workbook.createCellStyle(); 390 | // 罫線指定 391 | data_CellStyle.setBorderTop(BorderStyle.THIN); 392 | data_CellStyle.setBorderBottom(BorderStyle.THIN); 393 | data_CellStyle.setBorderLeft(BorderStyle.THIN); 394 | data_CellStyle.setBorderRight(BorderStyle.THIN); 395 | // フォントをセット 396 | data_CellStyle.setFont(font); 397 | for (int i = 0; i < table_Data.length; i++) { 398 | // 行を指定 399 | row = sheet.createRow(i + 1); 400 | for (int j = 0; j < table_Data[i].length; j++) { 401 | // セルを定義 402 | Cell cell = row.createCell(j); 403 | String value = table_Data[i][j]; 404 | // セルに値をセット 405 | if(is_Double(value)){ 406 | cell.setCellValue(Double.parseDouble(value)); 407 | } else { 408 | cell.setCellValue(value); 409 | } 410 | // セルにセルスタイルを適用 411 | cell.setCellStyle(data_CellStyle); 412 | // 最後の行のみ 413 | if (i == table_Data.length - 1) { 414 | // 列幅設定(オート) 415 | sheet.autoSizeColumn(j); 416 | } 417 | } 418 | } 419 | 420 | // ファイル名を指定して保存 421 | String encodedFilename = URLEncoder.encode(file_Name, "UTF-8"); 422 | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); 423 | response.setHeader("Content-Disposition", "attachment;filename=\"" + encodedFilename + "\""); 424 | response.setCharacterEncoding("UTF-8"); 425 | workbook.write(outputStream); 426 | message += "が完了しました"; 427 | workbook.close(); 428 | message += " workbook を close() しました"; 429 | } catch (IOException e) { 430 | message += "が正常に完了出来ませんでした"; 431 | ___console_Out___(e.getMessage()); 432 | } 433 | ___console_Out___("output_Excel() 終了"); 434 | return message; 435 | } 436 | 437 | private String with_Now(String head_String) { 438 | String now = now().replaceAll("[^0-9]", ""); // 現在日時の数字以外を "" に変換 439 | // String now = now().replaceAll("[^\\d]", ""); ←こちらでもOK 440 | now = now.substring(0, now.length()-3); // 後ろから3文字を取り除く 441 | return head_String + now; 442 | } 443 | 444 | public String now() { 445 | // 現在日時を取得 446 | LocalDateTime now = LocalDateTime.now(); 447 | // 表示形式を指定 448 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.SSS"); 449 | return dateTimeFormatter.format(now); 450 | } 451 | 452 | private static boolean is_Double(String string) { 453 | boolean is_Double = true; 454 | try { 455 | ___console_Out___("String = " + Double.parseDouble(string) + " は Double に変換出来ます"); 456 | } catch (Exception e) { 457 | ___console_Out___("string = " + string + " は Double に変換出来ません"); 458 | is_Double = false; 459 | } 460 | return is_Double; 461 | } 462 | 463 | /** コンソールに String を出力 */ 464 | public static void ___console_Out___(String message) { 465 | System.out.println(message); 466 | System.out.println("*"); 467 | } 468 | } 469 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/AccountBookController.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.data.repository.query.Param; 10 | import org.springframework.stereotype.Controller; 11 | import org.springframework.ui.Model; 12 | import org.springframework.web.bind.annotation.GetMapping; 13 | import org.springframework.web.bind.annotation.ModelAttribute; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 18 | 19 | import lombok.AllArgsConstructor; 20 | 21 | @Controller 22 | @AllArgsConstructor 23 | @RequestMapping("/AccountBook") 24 | public class AccountBookController { 25 | 26 | @Autowired 27 | private AccountBookService service; 28 | 29 | /** RequestMappingのURL */ 30 | public String req() { 31 | return "/AccountBook"; 32 | } 33 | 34 | /** RequestMappingのURL */ 35 | public String req(String path) { 36 | return req() + path; 37 | } 38 | 39 | /** このクラスの@GetMapping(path)にredirect */ 40 | public String redirect(String path) { 41 | return "redirect:" + req() + path; 42 | } 43 | 44 | @GetMapping("/") 45 | public String index() { 46 | return redirect("/Main"); 47 | } 48 | 49 | @GetMapping("/Main") 50 | public String main( 51 | Model model) { 52 | model.addAttribute("title", "メイン画面"); 53 | return "main"; 54 | } 55 | 56 | @GetMapping("/Setting") 57 | public String setting( 58 | Model model) { 59 | add_View_Data_(model, "setting", "各種設定"); 60 | return "view"; 61 | } 62 | 63 | @GetMapping("/List") 64 | public String list( 65 | Model model) { 66 | add_View_Data_(model, "list", "各種一覧"); 67 | return "view"; 68 | } 69 | 70 | @GetMapping("/Office") 71 | public String office( 72 | @Param("date")String date, 73 | Model model) { 74 | add_View_Data_(model, "office", "事業所情報"); 75 | String[] item_Names = service.office_Item_Names(); 76 | model.addAttribute("name", item_Names[0]); 77 | model.addAttribute("department", item_Names[1]); 78 | model.addAttribute("office_data", service.office_All()); 79 | return "view"; 80 | } 81 | 82 | @GetMapping("/OfficeSetting") 83 | public String officeSetting( 84 | Model model) { 85 | add_View_Data_(model, "officeSetting", "事業所設定"); 86 | model.addAttribute("officeList", service.office_Report()); 87 | return "view"; 88 | } 89 | 90 | @GetMapping("/OfficeInsert") 91 | public String officeInsert( 92 | Model model) { 93 | add_View_Data_(model, "officeInsert", "新規項目追加"); 94 | model.addAttribute("office", service.new_Office()); 95 | model.addAttribute("next_id", service.next_Office_Id()); 96 | return "view"; 97 | } 98 | 99 | @PostMapping("/ActionInsert") 100 | public String actionInsert( 101 | @RequestParam("date")String date, 102 | Model model) { 103 | add_View_Data_(model, "actionInsert", "新規出納追加"); 104 | model.addAttribute("date", date); 105 | model.addAttribute("japanese_Date", service.japanese_Date(date)); 106 | model.addAttribute("name", service.name()); 107 | model.addAttribute("action", service.new_Action(date)); 108 | model.addAttribute("next_id", service.next_Action_Id()); 109 | model.addAttribute("label_Set_List", LabelSet.actionInsert_Set); 110 | model.addAttribute("subjects", service.subjects()); 111 | return "view"; 112 | } 113 | 114 | @PostMapping("/ActionInput") 115 | public String actionInput( 116 | @RequestParam("post_date")String date, 117 | @ModelAttribute("action")Action action, 118 | Model model) { 119 | add_View_Data_(model, "actionInput", "新規出納追加"); 120 | model.addAttribute("date", date); 121 | model.addAttribute("japanese_Date", service.japanese_Date(date)); 122 | model.addAttribute("name", service.name()); 123 | model.addAttribute("action", action); 124 | model.addAttribute("next_id", service.next_Action_Id()); 125 | model.addAttribute("label_Set_List", LabelSet.actionInsert_Set); 126 | model.addAttribute("subjects", service.subjects()); 127 | return "view"; 128 | } 129 | 130 | @PostMapping("/ActionSubject/Select") 131 | public String actionSubject_Select( 132 | @RequestParam("date")String date, 133 | Model model) { 134 | add_View_Data_(model, "select", "科目選択"); 135 | model.addAttribute("url", "/ActionSubject/Input"); 136 | model.addAttribute("date", date); 137 | model.addAttribute("displayed_Date", service.japanese_Date(date)); 138 | model.addAttribute("name", service.name()); 139 | model.addAttribute("guide", "科目を選択して下さい"); 140 | Action object = service.new_Action(date); 141 | model.addAttribute("object", object); 142 | model.addAttribute("field", object.getSubject()); 143 | model.addAttribute("options", service.subjects()); 144 | return "view"; 145 | } 146 | 147 | @PostMapping("/ActionSubject/Input") 148 | public String actionSubject_Input( 149 | @RequestParam("post_date")String date, 150 | @RequestParam("field")String subject, 151 | @ModelAttribute("object")Action action, 152 | Model model) { 153 | add_View_Data_(model, "input", "科目入力"); 154 | model.addAttribute("url", "/ActionApply/Select"); 155 | model.addAttribute("date", date); 156 | model.addAttribute("displayed_Date", service.japanese_Date(date)); 157 | model.addAttribute("name", service.name()); 158 | model.addAttribute("guide", "科目を入力して下さい"); 159 | model.addAttribute("object", action); 160 | model.addAttribute("field", subject); 161 | return "view"; 162 | } 163 | 164 | @PostMapping("/ActionApply/Select") 165 | public String actionApply_Select( 166 | @RequestParam("post_date")String date, 167 | @RequestParam("field")String subject, 168 | @ModelAttribute("object")Action action, 169 | Model model) { 170 | add_View_Data_(model, "select", "適用選択"); 171 | model.addAttribute("url", "/ActionApply/Input"); 172 | model.addAttribute("date", date); 173 | model.addAttribute("displayed_Date", service.japanese_Date(date)); 174 | model.addAttribute("name", service.name()); 175 | model.addAttribute("guide", "適用を選択して下さい"); 176 | action.setSubject(subject); 177 | model.addAttribute("object", action); 178 | model.addAttribute("field", action.getApply()); 179 | model.addAttribute("options", service.applys()); 180 | return "view"; 181 | } 182 | 183 | @PostMapping("/ActionApply/Input") 184 | public String actionApply_Input( 185 | @RequestParam("post_date")String date, 186 | @RequestParam("field")String apply, 187 | @ModelAttribute("object")Action action, 188 | Model model) { 189 | add_View_Data_(model, "input", "適用入力"); 190 | model.addAttribute("url", "/ActionAccount/Select"); 191 | model.addAttribute("date", date); 192 | model.addAttribute("displayed_Date", service.japanese_Date(date)); 193 | model.addAttribute("name", service.name()); 194 | model.addAttribute("guide", "適用を入力して下さい"); 195 | model.addAttribute("object", action); 196 | model.addAttribute("field", apply); 197 | return "view"; 198 | } 199 | 200 | @PostMapping("/ActionAccount/Select") 201 | public String actionAccount_Select( 202 | @RequestParam("post_date")String date, 203 | @RequestParam("field")String apply, 204 | @ModelAttribute("object")Action action, 205 | Model model) { 206 | add_View_Data_(model, "select", "収支選択"); 207 | model.addAttribute("url", "/ActionAccount/Input"); 208 | model.addAttribute("date", date); 209 | model.addAttribute("displayed_Date", service.japanese_Date(date)); 210 | model.addAttribute("name", service.name()); 211 | model.addAttribute("guide", "収支を選択して下さい"); 212 | action.setApply(apply); 213 | model.addAttribute("object", action); 214 | model.addAttribute("field", ""); 215 | model.addAttribute("options", service.accounts()); 216 | return "view"; 217 | } 218 | 219 | @PostMapping("/ActionAccount/Input") 220 | public String actionAccount_Input( 221 | @RequestParam("post_date")String date, 222 | @RequestParam("field")String account, 223 | @ModelAttribute("object")Action action, 224 | Model model) { 225 | add_View_Data_(model, "input", "金額入力"); 226 | model.addAttribute("date", date); 227 | model.addAttribute("displayed_Date", service.japanese_Date(date)); 228 | model.addAttribute("name", service.name()); 229 | model.addAttribute("guide", account +"金額を入力して下さい"); 230 | model.addAttribute("object", action); 231 | switch (account) { 232 | case "収入": 233 | model.addAttribute("url", "/ActionIncome/Insert"); 234 | model.addAttribute("field", action.getIncome()); 235 | break; 236 | case "支出": 237 | model.addAttribute("url", "/ActionSpending/Insert"); 238 | model.addAttribute("field", action.getSpending()); 239 | break; 240 | } 241 | return "view"; 242 | } 243 | 244 | 245 | @PostMapping("/Office/Insert") 246 | public String office_Insert( 247 | @RequestParam("post_id")int id, 248 | @ModelAttribute("office")Office office, 249 | RedirectAttributes redirectAttributes) { 250 | String message = service.office_Insert(office, id); 251 | redirectAttributes.addFlashAttribute("message", message); 252 | return redirect("/OfficeSetting"); 253 | } 254 | 255 | @PostMapping("/Action/Insert") 256 | public String action_Insert( 257 | @RequestParam("date")String date, 258 | @ModelAttribute("action")Action action, 259 | RedirectAttributes redirectAttributes) { 260 | String message = service.action_Insert(action); 261 | redirectAttributes.addFlashAttribute("message", message); 262 | return redirect("/Daily?date=" + date); 263 | } 264 | 265 | @PostMapping("/ActionIncome/Insert") 266 | public String actionIncome_Insert( 267 | @RequestParam("post_date")String date, 268 | @RequestParam("field")int income, 269 | @ModelAttribute("object")Action action, 270 | RedirectAttributes redirectAttributes) { 271 | action.setIncome(income); 272 | action.setSpending(0); 273 | String message = service.action_Insert(action); 274 | redirectAttributes.addFlashAttribute("message", message); 275 | return redirect("/Daily?date=" + date); 276 | } 277 | 278 | @PostMapping("/ActionSpending/Insert") 279 | public String actionSpending_Insert( 280 | @RequestParam("post_date")String date, 281 | @RequestParam("field")int spending, 282 | @ModelAttribute("object")Action action, 283 | RedirectAttributes redirectAttributes) { 284 | action.setIncome(0); 285 | action.setSpending(spending); 286 | service.___consoleOut___(action.toString()); 287 | String message = service.action_Insert(action); 288 | redirectAttributes.addFlashAttribute("message", message); 289 | return redirect("/Daily?date=" + date); 290 | } 291 | 292 | @PostMapping("/OfficeUpdate") 293 | public String officeUpdate( 294 | @RequestParam("id")int id, 295 | Model model) { 296 | add_View_Data_(model, "officeUpdate", "事業所情報更新"); 297 | model.addAttribute("id", id); 298 | model.addAttribute("office", service.office(id)); 299 | return "view"; 300 | } 301 | 302 | @PostMapping("/ActionUpdate") 303 | public String actionUpdate( 304 | @RequestParam("id")int id, 305 | @RequestParam("date")String date, 306 | Model model) { 307 | add_View_Data_(model, "actionUpdate", "出納情報更新"); 308 | model.addAttribute("guide", "内容変更後更新ボタンを押してください"); 309 | model.addAttribute("do_Name", "更新"); 310 | model.addAttribute("cancel_url", req("/Daily")); 311 | model.addAttribute("do_url", req("/Action/Update")); 312 | model.addAttribute("id", id); 313 | model.addAttribute("date", date); 314 | model.addAttribute("object", service.action(id)); 315 | model.addAttribute("label_Set_List", LabelSet.actionUpdate_Set); 316 | model.addAttribute("subjects", service.subjects()); 317 | return "view"; 318 | } 319 | 320 | @PostMapping("/Action/Update") 321 | public String action_Update( 322 | @RequestParam("post_id")int id, 323 | @RequestParam("post_date")String date, 324 | @ModelAttribute("action")Action action, 325 | RedirectAttributes redirectAttributes) { 326 | String message = service.action_Update(action, id); 327 | redirectAttributes.addFlashAttribute("message", message); 328 | LocalDate localDate = service.to_LocalDate(date); 329 | return redirect("/Daily?date=" + localDate); 330 | } 331 | 332 | @PostMapping("/Office/Update") 333 | public String office_Update( 334 | @RequestParam("post_id")int id, 335 | @ModelAttribute("office")Office office, 336 | RedirectAttributes redirectAttributes) { 337 | String message = service.office_Update(office, id); 338 | redirectAttributes.addFlashAttribute("message", message); 339 | return redirect("/OfficeSetting"); 340 | } 341 | 342 | @PostMapping("/ActionDelete") 343 | public String actionDelete( 344 | @RequestParam("id")int id, 345 | @RequestParam("date")String date, 346 | Model model) { 347 | add_View_Data_(model, "delete", "出納情報削除"); 348 | model.addAttribute("guide", "この行を削除してもよろしいですか?"); 349 | model.addAttribute("cancel_url", req("/Daily")); 350 | model.addAttribute("delete_url", req("/Action/Delete")); 351 | model.addAttribute("id", id); 352 | model.addAttribute("date", date); 353 | model.addAttribute("object", service.action(id)); 354 | model.addAttribute("label_Set_List", LabelSet.actionDelete_Set); 355 | return "view"; 356 | } 357 | 358 | @PostMapping("/Action/Delete") 359 | public String action_Delete( 360 | @RequestParam("id")int id, 361 | @RequestParam("date")String date, 362 | RedirectAttributes redirectAttributes) { 363 | String message = service.action_Delete(id); 364 | redirectAttributes.addFlashAttribute("message", message); 365 | return redirect("/Daily?date=" + date); 366 | } 367 | 368 | @PostMapping("/OfficeReport") 369 | public String officeReport() { 370 | return "redirect:/CareRecord/RoutineReport"; 371 | } 372 | 373 | @GetMapping("/OfficeReport") 374 | public String officeReport( 375 | Model model) { 376 | add_View_Data_(model, "officeReport", "事業所情報印刷"); 377 | model.addAttribute("label_Set", LabelSet.officeReport_Set); 378 | model.addAttribute("office_Report", service.office_Report()); 379 | return "view"; 380 | } 381 | 382 | @PostMapping("/Office/Output/Excel") 383 | public String office_Output_Excel( 384 | HttpServletResponse httpServletResponse, 385 | RedirectAttributes redirectAttributes) { 386 | String message = service.office_Output_Excel(httpServletResponse); 387 | redirectAttributes.addFlashAttribute("message", message); 388 | return redirect("/OfficeReport"); 389 | } 390 | 391 | @PostMapping("/LastMonth") 392 | public String lastMonth( 393 | @RequestParam("date")String date, 394 | RedirectAttributes redirectAttributes) { 395 | LocalDate lastMonth = service.to_LocalDate(date).minusMonths(1); 396 | return redirect("/Monthly?date=" + lastMonth); 397 | } 398 | 399 | @PostMapping("/NextMonth") 400 | public String nextMonth( 401 | @RequestParam("date")String date, 402 | RedirectAttributes redirectAttributes) { 403 | LocalDate nextMonth = service.to_LocalDate(date).plusMonths(1); 404 | return redirect("/Monthly?date=" + nextMonth); 405 | } 406 | 407 | @PostMapping("/Monthly") 408 | public String monthly( 409 | @RequestParam("date")String date, 410 | RedirectAttributes redirectAttributes) { 411 | return redirect("/Monthly?date=" + date); 412 | } 413 | 414 | @GetMapping("/Monthly") 415 | public String monthly( 416 | @Param("year_month")String date, 417 | Model model) { 418 | add_View_Data_(model, "monthly", "月別出納一覧"); 419 | if(date == null) date = service.this_Year_Month(); 420 | model.addAttribute("name", service.name()); 421 | model.addAttribute("date", date); 422 | model.addAttribute("japanese_Date", service.japanese_Date(date, "G y 年 M 月")); 423 | model.addAttribute("carryover", service.carryover(date)); 424 | List action_List = service.monthly_List(date, 1); 425 | model.addAttribute("action_List", action_List); 426 | model.addAttribute("income", service.income_List(action_List)); 427 | model.addAttribute("spending",service.spending_List(action_List)); 428 | model.addAttribute("label_Set_List", LabelSet.action_List_Set); 429 | return "view"; 430 | } 431 | 432 | @PostMapping("/Year") 433 | public String year( 434 | @RequestParam("year")String year, 435 | @RequestParam("subject")String subject, 436 | RedirectAttributes redirectAttributes) { 437 | redirectAttributes.addAttribute("subject", subject); 438 | year = service.year(year + " 1 月 1 日", "G y 年 M 月 d 日"); 439 | return redirect("/Year?year=" + year); 440 | } 441 | 442 | @GetMapping("/Year") 443 | public String year( 444 | @Param("year")String year, 445 | @Param("subject")String subject, 446 | Model model) { 447 | add_View_Data_(model, "year", "年度別出納一覧"); 448 | if(year == null) year = service.this_Year(); 449 | model.addAttribute("name", service.name()); 450 | model.addAttribute("year", service.japanese_Date(year, "G y 年")); 451 | year += "/01"; 452 | model.addAttribute("carryover", service.carryover(year)); 453 | List action_List = service.year_List(year, 1, subject); 454 | model.addAttribute("action_List", action_List); 455 | model.addAttribute("income", service.income_List(action_List)); 456 | model.addAttribute("spending", service.spending_List(action_List)); 457 | model.addAttribute("label_Set_List", LabelSet.action_List_Set); 458 | if(subject == null) subject = "全科目"; 459 | if(subject.equals("")) subject = "全科目"; 460 | model.addAttribute("subject", subject); 461 | return "view"; 462 | } 463 | 464 | @PostMapping("/Subject") 465 | public String subject( 466 | @RequestParam("year")String year, 467 | @RequestParam("subject")String subject, 468 | Model model) { 469 | add_View_Data_(model, "subject", "科目指定"); 470 | if(year == null) year = service.this_Year(); 471 | model.addAttribute("year", year); 472 | model.addAttribute("name", service.name()); 473 | model.addAttribute("japanese_year", service.japanese_Date(year, "G y 年")); 474 | model.addAttribute("guide", "科目を選択して下さい"); 475 | if(subject.equals("全科目")) subject = ""; 476 | model.addAttribute("subject", subject); 477 | model.addAttribute("options", service.subjects()); 478 | return "view"; 479 | } 480 | 481 | @PostMapping("/SelectYear") 482 | public String selectYear( 483 | @RequestParam("year") String year, 484 | @RequestParam("subject") String subject, 485 | Model model) { 486 | add_View_Data_(model, "selectYear", "年度選択"); 487 | model.addAttribute("selected_year", year); 488 | model.addAttribute("subject", subject); 489 | model.addAttribute("years", service.years()); 490 | return "view"; 491 | } 492 | 493 | @PostMapping("/Daily/Output/Excel") 494 | public String daily_Output_Excel( 495 | @RequestParam("date") String date, 496 | HttpServletResponse httpServletResponse, 497 | RedirectAttributes redirectAttributes) { 498 | String message = service.daily_Output_Excel(date, httpServletResponse); 499 | redirectAttributes.addFlashAttribute("message", message); 500 | return redirect("/Daily?date=" + date); 501 | } 502 | 503 | @PostMapping("/Monthly/Output/Excel") 504 | public String monthly_Output_Excel( 505 | @RequestParam("date") String date, 506 | HttpServletResponse httpServletResponse, 507 | RedirectAttributes redirectAttributes) { 508 | String message = service.monthly_Output_Excel(date, httpServletResponse); 509 | redirectAttributes.addFlashAttribute("message", message); 510 | return redirect("/Monthly?date=" + date); 511 | } 512 | 513 | @PostMapping("/Year/Output/Excel") 514 | public String year_Output_Excel( 515 | @RequestParam("year") String date, 516 | @RequestParam("subject")String subject, 517 | HttpServletResponse httpServletResponse, 518 | RedirectAttributes redirectAttributes) { 519 | String message = service.year_Output_Excel(date, subject, httpServletResponse); 520 | redirectAttributes.addFlashAttribute("message", message); 521 | return redirect("/Year?date=" + date); 522 | } 523 | 524 | @PostMapping("/Daily") 525 | public String daily( 526 | @RequestParam("date") String date) { 527 | return redirect("/Daily?date=" + date); 528 | } 529 | 530 | @GetMapping("/Daily") 531 | public String daily( 532 | @Param("date") String date, 533 | Model model) { 534 | if (date == null) date = service.today(); 535 | add_View_Data_(model, "daily", "出納帳"); 536 | model.addAttribute("date", date); 537 | model.addAttribute("japanese_Date", service.japanese_Date(date)); 538 | model.addAttribute("name", service.name()); 539 | model.addAttribute("action_List", service.action_List(date)); 540 | model.addAttribute("account", service.account_Monthly(date)); 541 | model.addAttribute("label_Set_List", LabelSet.daily_Set); 542 | return "view"; 543 | } 544 | 545 | @PostMapping("/Daily/Date") 546 | public String daily_Date( 547 | @RequestParam("date") String date, 548 | Model model) { 549 | add_View_Data_(model, "date", "日付選択"); 550 | model.addAttribute("date", date); 551 | model.addAttribute("label", "日付を選んでください"); 552 | model.addAttribute("url", req("/Daily")); 553 | return "view"; 554 | } 555 | 556 | @PostMapping("/SelectMonth") 557 | public String selectMonth( 558 | @RequestParam("date") String date, 559 | Model model) { 560 | add_View_Data_(model, "date", "日付選択"); 561 | model.addAttribute("date", date); 562 | model.addAttribute("label", "日付を選んでください"); 563 | model.addAttribute("url", req("/Monthly")); 564 | return "view"; 565 | } 566 | 567 | @PostMapping("/DailyCash") 568 | public String daily_Cash( 569 | @RequestParam("date") String date, 570 | Model model) { 571 | add_View_Data_(model, "cash", "現金残高入力"); 572 | model.addAttribute("date", date); 573 | model.addAttribute("japanese_Date", service.japanese_Date(date)); 574 | model.addAttribute("cash", service.cash(date)); 575 | model.addAttribute("label_Set_List", LabelSet.cash_Set); 576 | return "view"; 577 | } 578 | 579 | @PostMapping("/DailyCashResult") 580 | public String dailyCashResult( 581 | @RequestParam("post_date") String date, 582 | @ModelAttribute("cash") Cash cash, 583 | Model model) { 584 | add_View_Data_(model, "cashResult", "現金残高確認"); 585 | model.addAttribute("date", date); 586 | model.addAttribute("japanese_Date", service.japanese_Date(date)); 587 | model.addAttribute("total", service.cash_Total(cash)); 588 | model.addAttribute("balance", service.cash_Balance(date, cash)); 589 | model.addAttribute("url", req("/DailyCash/Update")); 590 | model.addAttribute("label_Set_List", LabelSet.cash_Set); 591 | return "view"; 592 | } 593 | 594 | @PostMapping("/DailyCash/Update") 595 | public String dailyCash_Update( 596 | @RequestParam("post_date") String date, 597 | @ModelAttribute("cash") Cash cash, 598 | RedirectAttributes redirectAttributes) { 599 | String message = service.cash_Update(cash); 600 | redirectAttributes.addFlashAttribute("message", message); 601 | return redirect("/Daily?date=" + date); 602 | } 603 | 604 | /** view 表示に必要な属性データをモデルに登録 */ 605 | private void add_View_Data_(Model model, String template, String title) { 606 | model.addAttribute("library", template + "::library"); 607 | model.addAttribute("main", template + "::main"); 608 | model.addAttribute("title", title); 609 | model.addAttribute("req", req()); 610 | System.out.println("template = " + template); 611 | } 612 | } 613 | -------------------------------------------------------------------------------- /src/main/java/com/iwamih31/AccountBookService.java: -------------------------------------------------------------------------------- 1 | package com.iwamih31; 2 | 3 | import java.time.LocalDate; 4 | import java.time.LocalDateTime; 5 | import java.time.chrono.JapaneseChronology; 6 | import java.time.chrono.JapaneseDate; 7 | import java.time.format.DateTimeFormatter; 8 | import java.time.format.ResolverStyle; 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Locale; 13 | import java.util.Map; 14 | 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.stereotype.Service; 19 | 20 | @Service 21 | public class AccountBookService { 22 | 23 | @Autowired 24 | private ActionRepository actionRepository; 25 | @Autowired 26 | private OfficeRepository officeRepository; 27 | @Autowired 28 | private CashRepository cashRepository; 29 | 30 | /** アクションリスト(1日分) */ 31 | public List action_List(String date) { 32 | ___consoleOut___("date = " + date); 33 | LocalDate local_Date = to_LocalDate(date); 34 | return actionRepository.action_List(local_Date, local_Date); 35 | } 36 | 37 | /** アクションリスト(1カ月分) */ 38 | public List action_List_Monthly(String date) { 39 | LocalDate local_Date = to_LocalDate(date); 40 | LocalDate start_date = local_Date.withDayOfMonth(1); 41 | LocalDate end_date = start_date.plusMonths(1).minusDays(1); 42 | return actionRepository.action_List(start_date, end_date); 43 | } 44 | 45 | /** アクションリスト(月初めから date まで分) */ 46 | public List month_Till_Date(String date) { 47 | LocalDate local_Date = to_LocalDate(date); 48 | LocalDate start_date = local_Date.withDayOfMonth(1); 49 | LocalDate end_date = local_Date; 50 | return actionRepository.action_List(start_date, end_date); 51 | } 52 | 53 | public String name() { 54 | List name = officeRepository.item_value("事業所名"); 55 | if (name.isEmpty()) { 56 | Office office_Item = new Office(null, "事業所名", "出納帳"); 57 | officeRepository.save(office_Item); 58 | } 59 | return officeRepository.item_value("事業所名").get(0); 60 | } 61 | 62 | public Action action(int id) { 63 | return actionRepository.getReferenceById(id); 64 | } 65 | 66 | public Office office(int id) { 67 | return officeRepository.getReferenceById(id); 68 | } 69 | 70 | public List office_All() { 71 | if (next_Office_Id() == 1) 72 | set_Office(); 73 | return officeRepository.findAll(); 74 | } 75 | 76 | public String office_Insert(Office office_Item, int id) { 77 | office_Item.setId(id); 78 | String message = "ID = " + office_Item.getId() + " の事業所データ登録"; 79 | try { 80 | officeRepository.save(office_Item); 81 | message += "が完了しました"; 82 | } catch (Exception e) { 83 | message += "が正常に行われませんでした"; 84 | e.printStackTrace(); 85 | } 86 | return message; 87 | } 88 | 89 | public String action_Insert(Action action) { 90 | int id = next_Action_Id(); 91 | action.setId(id); 92 | String message = "ID = " + action.getId() + " の出納データ登録"; 93 | try { 94 | actionRepository.save(action); 95 | message += " が完了しました"; 96 | } catch (Exception e) { 97 | message += "が正常に行われませんでした"; 98 | e.printStackTrace(); 99 | } 100 | return message; 101 | } 102 | 103 | public String office_Update(Office office, int id) { 104 | office.setId(id); 105 | String message = "ID = " + office.getId() + " の事業所データ更新"; 106 | try { 107 | officeRepository.save(office); 108 | message += "が完了しました"; 109 | } catch (Exception e) { 110 | message += "が正常に行われませんでした"; 111 | e.printStackTrace(); 112 | } 113 | return message; 114 | } 115 | 116 | public String action_Update(Action action, int id) { 117 | action.setId(id); 118 | String message = "ID = " + action.getId() + " の出納データ更新"; 119 | try { 120 | actionRepository.save(action); 121 | message += "が完了しました"; 122 | } catch (Exception e) { 123 | message += "が正常に行われませんでした"; 124 | e.printStackTrace(); 125 | } 126 | return message; 127 | } 128 | 129 | public String action_Delete(int id) { 130 | String message = "ID = " + id + " のデータ削除"; 131 | try { 132 | actionRepository.deleteById(id); 133 | message += "が完了しました"; 134 | } catch (Exception e) { 135 | message += "が正常に行われませんでした" + e.getMessage(); 136 | } 137 | ___consoleOut___(message); 138 | return message; 139 | } 140 | 141 | public String[] office_Item_Names() { 142 | String[] item_Names = { "事業所名", "部署名" }; 143 | return item_Names; 144 | } 145 | 146 | public List office_Report() { 147 | return officeRepository.findAll(); 148 | } 149 | 150 | public Office new_Office() { 151 | Office new_Office = new Office(next_Office_Id(), "", ""); 152 | if (new_Office.getId() == 1) 153 | set_Office(); 154 | return new Office(next_Office_Id(), "", ""); 155 | } 156 | 157 | public Action new_Action() { 158 | return new Action(next_Action_Id(), null, "", "", 0, 0); 159 | } 160 | 161 | public Action new_Action(String date) { 162 | return new Action(next_Action_Id(), to_LocalDate(date), "", "", 0, 0); 163 | } 164 | 165 | public int next_Office_Id() { 166 | int nextId = 1; 167 | Office lastElement = getLastElement(officeRepository.findAll()); 168 | if (lastElement != null) 169 | nextId = lastElement.getId() + 1; 170 | ___consoleOut___("next_Office_Id = " + nextId); 171 | return nextId; 172 | } 173 | 174 | public int next_Action_Id() { 175 | int nextId = 1; 176 | Action lastElement = getLastElement(actionRepository.findAll()); 177 | if (lastElement != null) 178 | nextId = lastElement.getId() + 1; 179 | ___consoleOut___("next_Action_Id = " + nextId); 180 | return nextId; 181 | } 182 | 183 | public int next_Cash_Id() { 184 | int nextId = 1; 185 | Action lastElement = getLastElement(actionRepository.findAll()); 186 | if (lastElement != null) 187 | nextId = lastElement.getId() + 1; 188 | ___consoleOut___("next_Cash_Id = " + nextId); 189 | return nextId; 190 | } 191 | 192 | private void set_Office() { 193 | String[] item_Names = office_Item_Names(); 194 | officeRepository.save(new Office(1, item_Names[0], "")); 195 | officeRepository.save(new Office(2, item_Names[1], "")); 196 | } 197 | 198 | /** 事業所データをExcelファイルとして出力 */ 199 | public String office_Output_Excel(HttpServletResponse response) { 200 | Excel excel = new Excel(); 201 | String message = null; 202 | String[] column_Names = Set.get_Name_Set(LabelSet.officeReport_Set); 203 | int[] column_Width = Set.get_Value_Set(LabelSet.officeReport_Set); 204 | List office_Report = office_Report(); 205 | String[][] table_Data = new String[office_Report.size()][]; 206 | for (int i = 0; i < table_Data.length; i++) { 207 | Office office = office_Report.get(i); 208 | table_Data[i] = new String[] { 209 | String.valueOf(office.getId()), 210 | String.valueOf(office.getItem_name()), 211 | String.valueOf(office.getItem_value()) 212 | }; 213 | } 214 | message = excel.output_Excel("事業所", column_Names, column_Width, table_Data, response); 215 | return message; 216 | } 217 | 218 | /** 出納帳(1日分)をExcelファイルとして出力 */ 219 | public String daily_Output_Excel(String date, HttpServletResponse response) { 220 | Excel excel = new Excel(); 221 | String message = null; 222 | int[] column_Width = Set.get_Value_Set(LabelSet.daily_Output_Set); 223 | String[][] output_Data = daily_Sheet(date); 224 | String sheet_Name = date; 225 | WorkSheet workSheet = new DailyWorkSheet(sheet_Name, column_Width, output_Data); 226 | message = excel.output_Excel_Sheet("出納帳" + sheet_Name + "-", workSheet, response); 227 | return message; 228 | } 229 | 230 | /** 月別出納一覧をExcelファイルとして出力 */ 231 | public String monthly_Output_Excel(String date, HttpServletResponse response) { 232 | Excel excel = new Excel(); 233 | String message = null; 234 | int[] column_Width = Set.get_Value_Set(LabelSet.monthly_Output_Set); 235 | String[][] output_Data = monthly_Sheet(date); 236 | String sheet_Name = japanese_Date(date, "M月"); 237 | WorkSheet workSheet = new MonthlyWorkSheet(sheet_Name, column_Width, output_Data); 238 | message = excel.output_Excel_Sheet("現金出納帳" + japanese_Date(date, "Gyy年MM月") + "-", workSheet, response); 239 | return message; 240 | } 241 | 242 | /** 年度別出納一覧をExcelファイルとして出力 243 | * @param subject */ 244 | public String year_Output_Excel(String date, String subject, HttpServletResponse response) { 245 | Excel excel = new Excel(); 246 | String message = null; 247 | if (subject == null) subject = ""; 248 | int[] column_Width = Set.get_Value_Set(LabelSet.year_Output_Set); 249 | String[][] output_Data = year_Sheet(date, subject); 250 | String sheet_Name = japanese_Date(date, "Gy年") + subject; 251 | WorkSheet workSheet = new YearWorkSheet(sheet_Name, column_Width, output_Data); 252 | message = excel.output_Excel_Sheet("年度別現金出納帳" + japanese_Date(date, "Gy年") + subject, workSheet, response); 253 | return message; 254 | } 255 | 256 | private String[][] daily_Sheet(String date) { 257 | List head_Rows = head_Rows_Daily(date); 258 | String[] labels = Set.get_Name_Set(LabelSet.daily_Output_Set); 259 | List data_Rows = data_Row_Values_Daily(date); 260 | List foot_Rows = foot_Rows_Daily(); 261 | return make_Sheet(head_Rows, labels, data_Rows, foot_Rows); 262 | } 263 | 264 | private String[][] monthly_Sheet(String date) { 265 | List head_Rows = head_Rows_Monthly(date); 266 | String[] labels = Set.get_Name_Set(LabelSet.monthly_Output_Set); 267 | List data_Rows = data_Row_Values_Monthly(date); 268 | return make_Sheet(head_Rows, labels, data_Rows, null); 269 | } 270 | 271 | private String[][] year_Sheet(String date, String subject) { 272 | List head_Rows = head_Rows_Year(date, subject); 273 | String[] labels = Set.get_Name_Set(LabelSet.year_Output_Set); 274 | List data_Rows = data_Row_Values_Year(date, subject); 275 | return make_Sheet(head_Rows, labels, data_Rows, null); 276 | } 277 | 278 | private List head_Rows_Daily(String date) { 279 | String da = japanese_Date(date); 280 | String co = office_item_value("事業所名"); 281 | String[][] head_Rows = { 282 | { "", co, "", "", ""}, 283 | { "", "", "", "", ""}, 284 | { "", "", "", "", da} 285 | }; 286 | return to_List(head_Rows); 287 | } 288 | 289 | private List head_Rows_Monthly(String date) { 290 | String da = japanese_Date(date, "Gy年M月分"); 291 | String co = office_item_value("事業所名"); 292 | String[][] head_Rows = { 293 | { da, "", "", "", co, ""}, 294 | { "", "", "", "", "", ""} 295 | }; 296 | return to_List(head_Rows); 297 | } 298 | 299 | private List head_Rows_Year(String date, String subject) { 300 | String da = japanese_Date(date, "Gy年度分"); 301 | String su = subject; 302 | String co = office_item_value("事業所名"); 303 | String[][] head_Rows = { 304 | { da, "", su, "", co, ""}, 305 | { "", "", "", "", "", ""} 306 | }; 307 | return to_List(head_Rows); 308 | } 309 | 310 | private List foot_Rows_Daily() { 311 | String re = "【領収証添付】"; 312 | String[][] head_Rows = { 313 | { "", "", "", "", ""}, 314 | { re, "", "", "", ""} 315 | }; 316 | return to_List(head_Rows); 317 | } 318 | 319 | /** Excelシート(実績)作成用値データ */ 320 | public String[][] make_Sheet( 321 | List head_Rows, 322 | String[] labels, 323 | List data_Rows, 324 | List foot_Rows) { 325 | // 列追加用リスト作成 326 | List sheet_Rows = new ArrayList<>(); 327 | // ヘッド部分追加 328 | if (head_Rows != null) sheet_Rows.addAll(head_Rows); 329 | // ラベル行追加 330 | if (labels != null) sheet_Rows.add(labels); 331 | // データ行追加 332 | if (data_Rows != null) sheet_Rows.addAll(data_Rows); 333 | // フッター部分追加 334 | if (foot_Rows != null) sheet_Rows.addAll(foot_Rows); 335 | return to_Array(sheet_Rows); 336 | } 337 | 338 | /** 表部分 データ行(1日分) */ 339 | List data_Row_Values_Daily(String date) { 340 | // その日のデータ取得 341 | Map account = account_Monthly(date); 342 | Integer carryover = account.get("carryover"); 343 | Integer income_today = account.get("income_today"); 344 | Integer spending_today = account.get("spending_today"); 345 | Integer remainder = account.get("remainder"); 346 | Integer income_cumulative = account.get("income_cumulative"); 347 | Integer spending_cumulative = account.get("spending_cumulative"); 348 | // データ格納用リスト作成 349 | List data_Row_Values = new ArrayList<>(); 350 | data_Row_Values.add(data_Row_Daily_carryover(carryover)); 351 | // List を取得 352 | List action_List = action_List(date); 353 | // List があれば 354 | if (action_List.size() > 0) { 355 | // List 数分ループ 356 | for (Action action : action_List) { 357 | // Actionに応じた行を作成 358 | data_Row_Values.add(data_Row_Daily(action)); 359 | } 360 | } 361 | data_Row_Values.add(data_Row_total(income_today, spending_today, remainder)); 362 | data_Row_Values.add(data_Row_cumulative(income_cumulative, spending_cumulative)); 363 | return data_Row_Values; 364 | } 365 | 366 | /** 表部分 データ行(ひと月分) */ 367 | List data_Row_Values_Monthly(String date) { 368 | Integer carryover = carryover(date); 369 | Integer remainder = carryover; 370 | Integer income_cumulative = 0; 371 | Integer spending_cumulative = 0; 372 | // データ格納用リスト作成 373 | List data_Row_Values = new ArrayList<>(); 374 | data_Row_Values.add(data_Row_carryover(carryover, "前月繰越")); 375 | // List を取得 376 | List action_List = action_List_Monthly(date); 377 | // List があれば 378 | if (action_List.size() > 0) { 379 | // List 数分ループ 380 | for (Action action : action_List) { 381 | income_cumulative += action.getIncome(); 382 | spending_cumulative += action.getSpending(); 383 | remainder = carryover + income_cumulative - spending_cumulative; 384 | // Actionに応じた行を作成 385 | data_Row_Values.add(data_Row_Monthly(action, remainder)); 386 | } 387 | } 388 | data_Row_Values.add(data_Row_carried_forward(remainder, "翌月繰越")); 389 | data_Row_Values.add(data_Row_total_amount(income_cumulative, spending_cumulative)); 390 | return data_Row_Values; 391 | } 392 | 393 | /** 表部分 データ行(1年分) 394 | * @param subject */ 395 | List data_Row_Values_Year(String date, String subject) { 396 | Integer carryover = carryover(new_Year(date)); 397 | Integer remainder = carryover; 398 | Integer income_cumulative = 0; 399 | Integer spending_cumulative = 0; 400 | // データ格納用リスト作成 401 | List data_Row_Values = new ArrayList<>(); 402 | data_Row_Values.add(data_Row_carryover(carryover, "前年繰越")); 403 | // List を取得 404 | List action_List = year_List(date, 1, subject); 405 | // List があれば 406 | if (action_List.size() > 0) { 407 | // List 数分ループ 408 | for (Action action : action_List) { 409 | income_cumulative += action.getIncome(); 410 | spending_cumulative += action.getSpending(); 411 | remainder = carryover + income_cumulative - spending_cumulative; 412 | // Actionに応じた行を作成 413 | data_Row_Values.add(data_Row_Year(action, remainder)); 414 | } 415 | } 416 | data_Row_Values.add(data_Row_carried_forward(remainder, "翌年繰越")); 417 | data_Row_Values.add(data_Row_total_amount(income_cumulative, spending_cumulative)); 418 | return data_Row_Values; 419 | } 420 | 421 | private String new_Year(String date) { 422 | LocalDate new_Year = to_LocalDate(date).withDayOfYear(1); 423 | return new_Year.toString(); 424 | } 425 | 426 | private String[] data_Row_Daily_carryover(int carryover) { 427 | return new String[] {"", "前日繰越", "", "", make_String(carryover)}; 428 | } 429 | 430 | private String[] data_Row_carryover(int carryover, String label) { 431 | return new String[] {"", "", label, "", "", make_String(carryover)}; 432 | } 433 | 434 | private String[] data_Row_Daily(Action action) { 435 | return new String[] { 436 | make_String(action.getSubject()), 437 | make_String(action.getApply()), 438 | make_String(Zero_Blank(action.getIncome())), 439 | make_String(Zero_Blank(action.getSpending())), 440 | make_String("") 441 | }; 442 | } 443 | 444 | private String[] data_Row_Monthly(Action action, Integer remainder) { 445 | return new String[] { 446 | japanese_Date(action.getDate().toString(), "M月d日"), 447 | make_String(action.getSubject()), 448 | make_String(action.getApply()), 449 | make_String(Zero_Blank(action.getIncome())), 450 | make_String(Zero_Blank(action.getSpending())), 451 | make_String(remainder) 452 | }; 453 | } 454 | 455 | private String[] data_Row_Year(Action action, Integer remainder) { 456 | return new String[] { 457 | japanese_Date(action.getDate().toString(), "Gy/M/d"), 458 | make_String(action.getSubject()), 459 | make_String(action.getApply()), 460 | make_String(Zero_Blank(action.getIncome())), 461 | make_String(Zero_Blank(action.getSpending())), 462 | make_String(remainder) 463 | }; 464 | } 465 | 466 | private String[] data_Row_total(Integer income_today, Integer spending_today, Integer remainder) { 467 | return new String[] { 468 | "", 469 | "計", 470 | make_String(income_today), 471 | make_String(spending_today), 472 | make_String(remainder) 473 | }; 474 | } 475 | 476 | private String[] data_Row_total_amount(Integer income_cumulative, Integer spending_cumulative) { 477 | return new String[] { 478 | "", 479 | "", 480 | "合計", 481 | make_String(income_cumulative), 482 | make_String(spending_cumulative), 483 | "" 484 | }; 485 | } 486 | 487 | private String[] data_Row_cumulative(Integer income_cumulative, Integer spending_cumulative) { 488 | return new String[] {"", "累計", make_String(income_cumulative), make_String(spending_cumulative), ""}; 489 | } 490 | 491 | private String[] data_Row_carried_forward(Integer remainder, String label) { 492 | return new String[] {"", "", label, "", "", make_String(remainder)}; 493 | } 494 | 495 | private Object Zero_Blank(int number) { 496 | if (number == 0) return ""; 497 | return number; 498 | } 499 | 500 | private String make_String(Object object) { 501 | String make_String = ""; 502 | if (object != null) 503 | make_String = String.valueOf(object); 504 | return make_String; 505 | } 506 | 507 | private String[][] to_Array(List list) { 508 | // Listから2次配列へ変換 509 | String[][] array = new String[list.size()][]; 510 | for (int i = 0; i < array.length; i++) { 511 | array[i] = list.get(i); 512 | } 513 | return array; 514 | } 515 | 516 | private List to_List(String[][] array) { 517 | // Listから2次配列へ変換 518 | List list = new ArrayList<>(); 519 | for (int i = 0; i < array.length; i++) { 520 | list.add(array[i]); 521 | } 522 | return list; 523 | } 524 | 525 | private String office_item_value(String item_name) { 526 | String value = ""; 527 | List item_value = officeRepository.item_value(item_name); 528 | if (item_value.size() > 0) 529 | value = officeRepository.item_value(item_name).get(0); 530 | return value; 531 | } 532 | 533 | /** List の最後の Element を返すジェネリックメソッド */ 534 | public E getLastElement(List list) { 535 | E lastElement = null; 536 | if (list.size() > 0) { 537 | int lastIdx = list.size() - 1; 538 | lastElement = list.get(lastIdx); 539 | } 540 | return lastElement; 541 | } 542 | 543 | /** コンソールに String を出力 */ 544 | public void ___consoleOut___(String message) { 545 | System.out.println("*"); 546 | System.out.println(message); 547 | System.out.println(""); 548 | } 549 | 550 | // 今日の日付の文字列を取得 551 | public String today() { 552 | // 今日の日付を取得 553 | LocalDate now = LocalDate.now(); 554 | // 表示形式を指定 555 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); 556 | return dateTimeFormatter.format(now); 557 | } 558 | 559 | // 和暦に変換 560 | public String japanese_Date(String date, String format_Pattern) { 561 | Integer[] split_Date = split_Date(date); 562 | JapaneseDate japaneseDate = JapaneseDate.of(split_Date[0], split_Date[1], split_Date[2]); 563 | // 表示形式を指定 564 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format_Pattern); 565 | return dateTimeFormatter.format(japaneseDate); 566 | } 567 | 568 | // 和暦に変換 569 | public String japanese_Date(String date) { 570 | return japanese_Date(date, "G y 年 M 月 d 日"); 571 | } 572 | 573 | // 和暦に変換(年) 574 | public String japanese_Year(String date) { 575 | return japanese_Date(date, "G y 年"); 576 | } 577 | 578 | // 和暦に変換(年 月) 579 | public String japanese_Year_Month(String date) { 580 | return japanese_Date(date, "G y 年 M 月"); 581 | } 582 | 583 | // 和暦に変換 584 | public String japanese_Date(LocalDate localDate) { 585 | return japanese_Date(localDate.toString()); 586 | } 587 | 588 | // 和暦の文字列をLocalDateに変換 589 | public LocalDate to_LocalDate(String japanese_Date, String format_Pattern) { 590 | 591 | // DateTimeFormatterオブジェクトを生成し、和暦のパターンを設定する 592 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format_Pattern, Locale.JAPAN) 593 | .withChronology(JapaneseChronology.INSTANCE) 594 | .withResolverStyle(ResolverStyle.SMART); 595 | 596 | // 和暦の文字列を JapaneseDate に変換する 597 | JapaneseDate wareki = JapaneseDate.from(formatter.parse(japanese_Date)); 598 | 599 | // JapaneseDateからLocalDateに変換する 600 | return LocalDate.from(wareki); 601 | } 602 | 603 | public State state(int id, String name, String date) { 604 | return new State(id, name, to_LocalDate(date)); 605 | } 606 | 607 | public LocalDate to_LocalDate(String date) { 608 | Integer[] split_Date = split_Date(date); 609 | int year = split_Date[0]; 610 | int month = split_Date[1]; 611 | int day = split_Date[2]; 612 | return to_LocalDate(year, month, day); 613 | } 614 | 615 | private LocalDate to_LocalDate(int year, int month, int day) { 616 | LocalDate localDate = LocalDate.of(year, month, day); 617 | ___consoleOut___("localDate = " + localDate); 618 | return localDate; 619 | } 620 | 621 | private Integer[] split_Date(String date) { 622 | Integer[] split_Date = null; 623 | LocalDateTime localDateTime = LocalDateTime.now(); 624 | if (date != null) { 625 | int year = localDateTime.getYear(); 626 | int month = localDateTime.getMonthValue(); 627 | int day = 1; 628 | date = date.trim(); 629 | date = date.split(" ")[0]; 630 | date = date.split("T")[0]; 631 | date = date.replace("年", "-"); 632 | date = date.replace("月", "-"); 633 | date = date.replace("日", "-"); 634 | date = date.replace("/", "-"); 635 | String[] array = date.split("-"); 636 | if (array.length > 0 && is_Int(array[0])) 637 | year = Integer.parseInt(array[0]); 638 | if (array.length > 1) 639 | month = Integer.parseInt(array[1]); 640 | if (array.length > 2) 641 | day = Integer.parseInt(array[2]); 642 | split_Date = new Integer[] { year, month, day }; 643 | } 644 | return split_Date; 645 | } 646 | 647 | private boolean is_Int(String string) { 648 | boolean is_Int = true; 649 | try { 650 | ___consoleOut___("String = " + Integer.parseInt(string) + " は Integer に変換出来ます"); 651 | } catch (Exception e) { 652 | ___consoleOut___("string = " + string + " は Integer に変換出来ません"); 653 | is_Int = false; 654 | } 655 | return is_Int; 656 | } 657 | 658 | public OptionData options() { 659 | return new OptionData(); 660 | } 661 | 662 | public List subjects() { 663 | 664 | List subjects = actionRepository.subjects(); 665 | subjects.add(0, ""); 666 | return subjects; 667 | } 668 | 669 | public List applys() { 670 | List applys = actionRepository.applys(); 671 | applys.add(0, ""); 672 | return applys; 673 | } 674 | 675 | public String[] accounts() { 676 | return new String[] {"支出", "収入"}; 677 | } 678 | 679 | public int remainder(String date) { 680 | int income_total = 0; 681 | int spending_total = 0; 682 | List actions = actionRepository.up_to_date(to_LocalDate(date)); 683 | if (actions.size() < 1) return 0; 684 | for (Action action : actions) { 685 | income_total += action.getIncome(); 686 | spending_total += action.getSpending(); 687 | } 688 | return income_total - spending_total; 689 | } 690 | 691 | /** 1日前の残高を返す */ 692 | public int carryover(String date) { 693 | LocalDate localDate = to_LocalDate(date); 694 | String yesterday = localDate.minusDays(1).toString(); 695 | return remainder(yesterday); 696 | } 697 | 698 | // localDate の年の1日から volume 年分の Action リストを返す 699 | public List year_List(LocalDate localDate, int volume) { 700 | LocalDate start_date = localDate.withDayOfYear(1); 701 | LocalDate end_date = start_date.plusYears(volume).minusDays(1); 702 | return actionRepository.action_List(start_date, end_date); 703 | } 704 | 705 | // localDate の年の1日から volume 年分の Action リストを返す(subject 指定) 706 | public List year_List(LocalDate localDate, int volume, String subject) { 707 | LocalDate start_date = localDate.withDayOfYear(1); 708 | LocalDate end_date = start_date.plusYears(volume).minusDays(1); 709 | if(subject == null || subject.equals("")) { 710 | return actionRepository.action_List(start_date, end_date); 711 | } 712 | return actionRepository.action_List(start_date, end_date, subject); 713 | } 714 | 715 | // localDate の月の1日から volume 月分の Action リストを返す 716 | public List monthly_List(LocalDate localDate, int volume) { 717 | LocalDate start_date = localDate.withDayOfMonth(1); 718 | LocalDate end_date = start_date.plusMonths(volume).minusDays(1); 719 | return actionRepository.action_List(start_date, end_date); 720 | } 721 | 722 | // date の年の1日から volume 月分の Action リストを返す 723 | public List year_List(String date, int volume) { 724 | LocalDate localDate = to_LocalDate(date); 725 | return year_List(localDate, volume); 726 | } 727 | 728 | //date の年の1日から volume 月分の Action リストを返す(subject 指定) 729 | public List year_List(String year, int volume, String subject) { 730 | LocalDate localDate = to_LocalDate(year); 731 | return year_List(localDate, volume, subject); 732 | } 733 | 734 | // date の月の1日から volume 月分の Action リストを返す 735 | public List monthly_List(String date, int volume) { 736 | LocalDate localDate = to_LocalDate(date); 737 | return monthly_List(localDate, volume); 738 | } 739 | 740 | // localDate の年の1日から localDate までの Action リストを返す 741 | public List year_List(LocalDate localDate) { 742 | return actionRepository.action_List(localDate.withDayOfYear(1), localDate); 743 | } 744 | 745 | // localDate の月の1日から localDate までの Action リストを返す 746 | public List monthly_List(LocalDate localDate) { 747 | return actionRepository.action_List(localDate.withDayOfMonth(1), localDate); 748 | } 749 | 750 | // date の年の1日から date までの Action リストを返す 751 | public List year_List(String date) { 752 | LocalDate localDate = to_LocalDate(date); 753 | return actionRepository.action_List(localDate.withDayOfYear(1), localDate); 754 | } 755 | 756 | // date の月の1日から date までの Action リストを返す 757 | public List monthly_List(String date) { 758 | LocalDate localDate = to_LocalDate(date); 759 | return actionRepository.action_List(localDate.withDayOfYear(1), localDate); 760 | } 761 | 762 | public Map account(String date) { 763 | Map account = new HashMap<>(); 764 | int carryover = carryover(date); 765 | int remainder = remainder(date); 766 | int income_today = 0; 767 | int spending_today = 0; 768 | int income_tihs_year = 0; 769 | int spending_tihs_year = 0; 770 | int balance = cash_Balance(date, cash(date)); 771 | List today_List = action_List(date); 772 | for (Action action : today_List) { 773 | income_today += action.getIncome(); 774 | spending_today += action.getSpending(); 775 | } 776 | List year_List = year_List(date); 777 | for (Action action : year_List) { 778 | income_tihs_year += action.getIncome(); 779 | spending_tihs_year += action.getSpending(); 780 | } 781 | account.put("carryover", carryover); 782 | account.put("remainder", remainder); 783 | account.put("income_today", income_today); 784 | account.put("spending_today", spending_today); 785 | account.put("income_tihs_year", income_tihs_year); 786 | account.put("spending_tihs_year", spending_tihs_year); 787 | account.put("balance", balance); 788 | return account; 789 | } 790 | 791 | public Map account_Monthly(String date) { 792 | Map account = new HashMap<>(); 793 | int carryover = carryover(date); 794 | int remainder = remainder(date); 795 | int income_today = 0; 796 | int spending_today = 0; 797 | int income_cumulative = 0; 798 | int spending_cumulative = 0; 799 | int balance = cash_Balance(date, cash(date)); 800 | List today_List = action_List(date); 801 | for (Action action : today_List) { 802 | income_today += action.getIncome(); 803 | spending_today += action.getSpending(); 804 | } 805 | List monthly_List = month_Till_Date(date); 806 | for (Action action : monthly_List) { 807 | income_cumulative += action.getIncome(); 808 | spending_cumulative += action.getSpending(); 809 | } 810 | account.put("carryover", carryover); 811 | account.put("remainder", remainder); 812 | account.put("income_today", income_today); 813 | account.put("spending_today", spending_today); 814 | account.put("income_cumulative", income_cumulative); 815 | account.put("spending_cumulative", spending_cumulative); 816 | account.put("balance", balance); 817 | return account; 818 | } 819 | 820 | public Cash cash(String date) { 821 | Cash cash; 822 | LocalDate localDate = to_LocalDate(date); 823 | ___consoleOut___("localDate = " + localDate); 824 | if(cashRepository.cash(localDate).size() < 1) { 825 | int id = next_Cash_Id(); 826 | cashRepository.save(new Cash(id, localDate, 0, 0, 0, 0, 0, 0, 0, 0, 0)); 827 | } 828 | cash = cashRepository.cash(localDate).get(0); 829 | return cash; 830 | } 831 | 832 | public int cash_Total(Cash cash) { 833 | int total = 0; 834 | total += cash.getMan1() * 10000; 835 | total += cash.getSen5() * 5000; 836 | total += cash.getSen1() * 1000; 837 | total += cash.getHyaku5() * 500; 838 | total += cash.getHyaku1() * 100; 839 | total += cash.getJyuu5() * 50; 840 | total += cash.getJyuu1() * 10; 841 | total += cash.getEn5() * 5; 842 | total += cash.getEn1() * 1; 843 | return total; 844 | } 845 | 846 | public String cash_Update(Cash cash) { 847 | String message = cash.getDate() + " の現金残高更新"; 848 | try { 849 | cashRepository.save(cash); 850 | message += "が完了しました"; 851 | } catch (Exception e) { 852 | message += "が正常に行われませんでした"; 853 | e.printStackTrace(); 854 | } 855 | return message; 856 | } 857 | 858 | public int cash_Balance(String date, Cash cash) { 859 | int remainder = remainder(date); 860 | int cash_Total = cash_Total(cash); 861 | return cash_Total - remainder; 862 | } 863 | 864 | public String this_Year_Month() { 865 | // 今日の日付を取得 866 | LocalDateTime now = LocalDateTime.now(); 867 | // 表示形式を指定 868 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy/MM"); 869 | return dateTimeFormatter.format(now); 870 | } 871 | 872 | public String this_Year() { 873 | // 今日の日付を取得 874 | LocalDateTime now = LocalDateTime.now(); 875 | // 表示形式を指定 876 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy"); 877 | return dateTimeFormatter.format(now); 878 | } 879 | 880 | public String this_Month() { 881 | // 今日の日付を取得 882 | LocalDateTime now = LocalDateTime.now(); 883 | // 表示形式を指定 884 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM"); 885 | return dateTimeFormatter.format(now); 886 | } 887 | 888 | public List income_List(List action_List) { 889 | int income = 0; 890 | List income_List = new ArrayList<>(); 891 | for (Action action : action_List) { 892 | income += action.getIncome(); 893 | income_List.add(income); 894 | } 895 | return income_List; 896 | } 897 | 898 | public List spending_List(List action_List) { 899 | int spending = 0; 900 | List spending_List = new ArrayList<>(); 901 | for (Action action : action_List) { 902 | spending += action.getSpending(); 903 | spending_List.add(spending); 904 | } 905 | return spending_List; 906 | } 907 | 908 | public Object years() { 909 | int size = 100; 910 | LocalDate localDate = LocalDate.now(); 911 | localDate = localDate.minusYears(size); 912 | List years = new ArrayList<>(); 913 | for (int i = 0; i <= size; i++) { 914 | years.add(japanese_Year(localDate.plusYears(i).toString())); 915 | } 916 | return years; 917 | } 918 | 919 | public String year(String year, String format_Pattern) { 920 | ___consoleOut___("year = " + year + "format_Pattern = " + format_Pattern ); 921 | LocalDate localDate = to_LocalDate(year, format_Pattern); 922 | return String.valueOf(localDate.getYear()); 923 | } 924 | } 925 | --------------------------------------------------------------------------------