| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- package com.its.traf;
- import com.its.traf.dto.its.IfscCngsDto;
- import com.its.traf.global.eTrafPrcsJob;
- import lombok.extern.slf4j.Slf4j;
- import org.junit.jupiter.api.Test;
- import org.springframework.boot.test.context.SpringBootTest;
- import java.text.SimpleDateFormat;
- import java.util.*;
- @Slf4j
- @SpringBootTest
- public class TrafPrcsServerApplicationTests {
- enum LogLevel {
- VERB,
- INFO,
- DEBUG,
- WARN,
- ERROR,
- }
- @Test
- void test1() {
- for (int ii = 0; ii < 24; ii++) {
- for (int jj = 0; jj < 12; jj++) {
- log.error("{}:{}", ii, jj*5);
- }
- }
- String prcsDt = "20220120173526";
- log.error("{}", prcsDt.substring(0, 2));
- log.error("{}", prcsDt.substring(8, 10));
- log.error("{}", prcsDt.substring(10, 12));
- String svcDt = "20210120173526";
- log.error("compareTo: {}", svcDt.compareTo(prcsDt));
- }
- void test2Func(LogLevel level) {
- log.error("{}", level.name());
- }
- @Test
- void test2() {
- test2Func(LogLevel.INFO);
- test2Func(LogLevel.ERROR);
- test2Func(LogLevel.DEBUG);
- }
- @Test
- void test3() {
- Calendar calStat = Calendar.getInstance();
- String YMD = new SimpleDateFormat("yyyyMMddHHmmss").format(calStat.getTime());
- log.error("{}", YMD);
- calStat.add(Calendar.DAY_OF_MONTH, -1); // 하루전
- calStat.set(Calendar.HOUR_OF_DAY, 0);
- calStat.set(Calendar.MINUTE, 0);
- calStat.set(Calendar.SECOND, 0);
- YMD = new SimpleDateFormat("yyyyMMddHHmmss").format(calStat.getTime());
- log.error("{}", YMD);
- }
- Hashtable<Long, Hashtable<String, List<IfscCngsDto>>> cngsMap = new Hashtable<>();
- private void addIfscCngs(IfscCngsDto cngs) {
- if (cngs != null) {
- Long key = cngs.getIfscId();
- Hashtable<String, List<IfscCngsDto>> hhMiMap = cngsMap.computeIfAbsent(key, k -> new Hashtable<>());
- List<IfscCngsDto> lists = hhMiMap.computeIfAbsent(cngs.getPrcnTm(), k -> new ArrayList<>());
- lists.add(cngs);
- }
- }
- @Test
- void test4() {
- Long ifscId = 3505426700L;
- IfscCngsDto cngs1 = IfscCngsDto.builder()
- .ifscId(ifscId)
- .prcnDt("20220101000000")
- .prcnHh("00")
- .prcnMi("00")
- .prcnTm("0000")
- .timeIdx(0)
- .sped(10)
- .trvlHh(10)
- .build();
- IfscCngsDto cngs2 = IfscCngsDto.builder()
- .ifscId(ifscId)
- .prcnDt("20220101000000")
- .prcnHh("00")
- .prcnMi("05")
- .prcnTm("0005")
- .timeIdx(1)
- .sped(10)
- .trvlHh(10)
- .build();
- IfscCngsDto cngs3 = IfscCngsDto.builder()
- .ifscId(ifscId)
- .prcnDt("20220101000000")
- .prcnHh("00")
- .prcnMi("10")
- .prcnTm("0010")
- .timeIdx(2)
- .sped(10)
- .trvlHh(10)
- .build();
- addIfscCngs(cngs3);
- addIfscCngs(cngs1);
- addIfscCngs(cngs2);
- log.error("{}", cngsMap);
- TreeMap<Integer, IfscCngsDto> treeMap = new TreeMap<>();
- treeMap.put(cngs3.getTimeIdx(), cngs3);
- treeMap.put(cngs1.getTimeIdx(), cngs1);
- treeMap.put(cngs2.getTimeIdx(), cngs2);
- log.error("{}", treeMap);
- }
- @Test
- void test5() {
- eTrafPrcsJob arr[] = eTrafPrcsJob.values();
- for (eTrafPrcsJob col : arr) {
- log.info("{}, {}, {}, {}", col.ordinal(), col.getValue(), col.getName(), col.getDesc());
- }
- }
- }
|