TrafPrcsServerApplicationTests.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package com.its.traf;
  2. import com.its.traf.dto.its.IfscCngsDto;
  3. import com.its.traf.global.eTrafPrcsJob;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.junit.jupiter.api.Test;
  6. import org.springframework.boot.test.context.SpringBootTest;
  7. import java.text.SimpleDateFormat;
  8. import java.util.*;
  9. @Slf4j
  10. @SpringBootTest
  11. public class TrafPrcsServerApplicationTests {
  12. enum LogLevel {
  13. VERB,
  14. INFO,
  15. DEBUG,
  16. WARN,
  17. ERROR,
  18. }
  19. @Test
  20. void test1() {
  21. for (int ii = 0; ii < 24; ii++) {
  22. for (int jj = 0; jj < 12; jj++) {
  23. log.error("{}:{}", ii, jj*5);
  24. }
  25. }
  26. String prcsDt = "20220120173526";
  27. log.error("{}", prcsDt.substring(0, 2));
  28. log.error("{}", prcsDt.substring(8, 10));
  29. log.error("{}", prcsDt.substring(10, 12));
  30. String svcDt = "20210120173526";
  31. log.error("compareTo: {}", svcDt.compareTo(prcsDt));
  32. }
  33. void test2Func(LogLevel level) {
  34. log.error("{}", level.name());
  35. }
  36. @Test
  37. void test2() {
  38. test2Func(LogLevel.INFO);
  39. test2Func(LogLevel.ERROR);
  40. test2Func(LogLevel.DEBUG);
  41. }
  42. @Test
  43. void test3() {
  44. Calendar calStat = Calendar.getInstance();
  45. String YMD = new SimpleDateFormat("yyyyMMddHHmmss").format(calStat.getTime());
  46. log.error("{}", YMD);
  47. calStat.add(Calendar.DAY_OF_MONTH, -1); // 하루전
  48. calStat.set(Calendar.HOUR_OF_DAY, 0);
  49. calStat.set(Calendar.MINUTE, 0);
  50. calStat.set(Calendar.SECOND, 0);
  51. YMD = new SimpleDateFormat("yyyyMMddHHmmss").format(calStat.getTime());
  52. log.error("{}", YMD);
  53. }
  54. Hashtable<Long, Hashtable<String, List<IfscCngsDto>>> cngsMap = new Hashtable<>();
  55. private void addIfscCngs(IfscCngsDto cngs) {
  56. if (cngs != null) {
  57. Long key = cngs.getIfscId();
  58. Hashtable<String, List<IfscCngsDto>> hhMiMap = cngsMap.computeIfAbsent(key, k -> new Hashtable<>());
  59. List<IfscCngsDto> lists = hhMiMap.computeIfAbsent(cngs.getPrcnTm(), k -> new ArrayList<>());
  60. lists.add(cngs);
  61. }
  62. }
  63. @Test
  64. void test4() {
  65. Long ifscId = 3505426700L;
  66. IfscCngsDto cngs1 = IfscCngsDto.builder()
  67. .ifscId(ifscId)
  68. .prcnDt("20220101000000")
  69. .prcnHh("00")
  70. .prcnMi("00")
  71. .prcnTm("0000")
  72. .timeIdx(0)
  73. .sped(10)
  74. .trvlHh(10)
  75. .build();
  76. IfscCngsDto cngs2 = IfscCngsDto.builder()
  77. .ifscId(ifscId)
  78. .prcnDt("20220101000000")
  79. .prcnHh("00")
  80. .prcnMi("05")
  81. .prcnTm("0005")
  82. .timeIdx(1)
  83. .sped(10)
  84. .trvlHh(10)
  85. .build();
  86. IfscCngsDto cngs3 = IfscCngsDto.builder()
  87. .ifscId(ifscId)
  88. .prcnDt("20220101000000")
  89. .prcnHh("00")
  90. .prcnMi("10")
  91. .prcnTm("0010")
  92. .timeIdx(2)
  93. .sped(10)
  94. .trvlHh(10)
  95. .build();
  96. addIfscCngs(cngs3);
  97. addIfscCngs(cngs1);
  98. addIfscCngs(cngs2);
  99. log.error("{}", cngsMap);
  100. TreeMap<Integer, IfscCngsDto> treeMap = new TreeMap<>();
  101. treeMap.put(cngs3.getTimeIdx(), cngs3);
  102. treeMap.put(cngs1.getTimeIdx(), cngs1);
  103. treeMap.put(cngs2.getTimeIdx(), cngs2);
  104. log.error("{}", treeMap);
  105. }
  106. @Test
  107. void test5() {
  108. eTrafPrcsJob arr[] = eTrafPrcsJob.values();
  109. for (eTrafPrcsJob col : arr) {
  110. log.info("{}, {}, {}, {}", col.ordinal(), col.getValue(), col.getName(), col.getDesc());
  111. }
  112. }
  113. }