shjung 2 سال پیش
والد
کامیت
cc7f680004

+ 1 - 2
src/main/java/com/its/traf/service/its/TbPtrnRoad15MService.java

@@ -8,7 +8,6 @@ import com.its.traf.vo.pattern.voPtrnQueryCond;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -75,7 +74,7 @@ public class TbPtrnRoad15MService extends AbstractDataService<Long, TbPtrnRoadDt
                 matching++;
             }
         }
-        log.info("[LOADING...]                     TbPtrnRoad15MService.load: PTRN_ROAD_05M, [{}], [{}], {} EA.", this.prcsTime.getCurrFiveMin(), cond.toString(), matching);
+        log.info("[LOADING...]                     TbPtrnRoad15MService.load: PTRN_ROAD_15M, [{}], [{}], {} EA.", this.prcsTime.getCurrFiveMin(), cond.toString(), matching);
         this.dataNum = lists.size();
         return this.dataNum;
     }

+ 14 - 4
src/main/java/com/its/traf/service/its/TrafPrcsTime.java

@@ -103,7 +103,7 @@ public class TrafPrcsTime {
 		cal.setTime(paramDt);
 		return new SimpleDateFormat(paramFmt).format(cal.getTime());
 	}
-	public String getCurrFiveMinString(Date paramDt) {
+	public String getCurr05MinString(Date paramDt) {
 		Calendar cal = Calendar.getInstance();
 		cal.setTime(paramDt);
 		cal.set(Calendar.SECOND, 0);
@@ -112,6 +112,15 @@ public class TrafPrcsTime {
 		cal.add(Calendar.MINUTE, -(min % 5));
 		return new SimpleDateFormat("yyyyMMddHHmmss").format(cal.getTime());
 	}
+	public String getCurr15MinString(Date paramDt) {
+		Calendar cal = Calendar.getInstance();
+		cal.setTime(paramDt);
+		cal.set(Calendar.SECOND, 0);
+		cal.set(Calendar.MILLISECOND, 0);
+		int min = cal.get(Calendar.MINUTE);
+		cal.add(Calendar.MINUTE, -(min % 15));
+		return new SimpleDateFormat("yyyyMMddHHmmss").format(cal.getTime());
+	}
 
 	public String calDate(String paramTm, int addSec/*초단위*/) {
 		String result = paramTm;
@@ -212,12 +221,13 @@ public class TrafPrcsTime {
 		 * 시간대 계산은 아직 안함(추후 시간대 계산이 필요하면 여기서 하면 됨)
 		 */
 		this.currTime = getCurrentTimeString();										/* 20170718153504 - 현재시각 */
-		this.currFiveMin = getCurrFiveMinString(convertString2Date(this.currTime));	/* 20170718153500 */
+		this.currFiveMin = getCurr05MinString(convertString2Date(this.currTime));	/* 20170718153500 */
 		this.prevFiveMin = calDate(this.currFiveMin, -60*5); 				/* 20170718153000 - 이전 정주기 5분 시각 */
 
 		String beforeOneWeek = calDate(this.currTime, -60*60*24*7);			/* 7일전 */
-		this.ptrn05M = getCurrFiveMinString(convertString2Date(beforeOneWeek));		/* 7일전 정주기 05분 패턴 시각 */
-		this.ptrn15M = calDate(this.ptrn05M, -60*15);						/* 7일전 정주기 15분 패턴 시각 */
+		this.ptrn05M = getCurr05MinString(convertString2Date(beforeOneWeek));		/* 7일전 정주기 05분 패턴 시각 */
+		//this.ptrn15M = calDate(this.ptrn05M, -60*15);						/* 7일전 정주기 15분 패턴 시각 */
+		this.ptrn15M = getCurr15MinString(convertString2Date(this.ptrn05M));		/* 7일전 정주기 15분 패턴 시각 */
 
 		this.prcsFiveMin     = this.prevFiveMin;									/* 20170718153000 - 이전 정주기 5분 시각 이용하여 입력 */
 		this.prcsFiveMinFrom = this.prevFiveMin;									/* 20170718153000 - 이전 정주기 5분 시각 */

+ 48 - 2
src/test/java/com/its/traf/TrafPrcsServerApplicationTests.java

@@ -4,13 +4,15 @@ 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 org.springframework.test.context.ActiveProfiles;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
 @Slf4j
-@SpringBootTest
+//@SpringBootTest
+@ActiveProfiles(profiles = "dev")
 public class TrafPrcsServerApplicationTests {
 
     enum LogLevel {
@@ -20,6 +22,50 @@ public class TrafPrcsServerApplicationTests {
         WARN,
         ERROR,
     }
+
+    public String getCurr05MinString(Date paramDt) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(paramDt);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        int min = cal.get(Calendar.MINUTE);
+        cal.add(Calendar.MINUTE, -(min % 5));
+        return new SimpleDateFormat("yyyyMMddHHmmss").format(cal.getTime());
+    }
+    public String getCurr15MinString(Date paramDt) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(paramDt);
+        cal.set(Calendar.SECOND, 0);
+        cal.set(Calendar.MILLISECOND, 0);
+        int min = cal.get(Calendar.MINUTE);
+        cal.add(Calendar.MINUTE, -(min % 15));
+        return new SimpleDateFormat("yyyyMMddHHmmss").format(cal.getTime());
+    }
+    public Date convertString2Date(String paramTime) {
+        SimpleDateFormat transFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+        Date to = null;
+        try {
+            to = transFormat.parse(paramTime);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return to;
+    }
+
+    @Test
+    void testTime() {
+        String[] timeArr = {
+                "20230309160000", "20230309160500", "20230309161000", "20230309161500",
+                "20230309162000", "20230309162500", "20230309163000", "20230309163500",
+                "20230309164000", "20230309164500", "20230309165000", "20230309165500",};
+        for (String t : timeArr) {
+            String str05M = getCurr05MinString(convertString2Date(t));
+            String str15M = getCurr15MinString(convertString2Date(str05M));
+            log.info("{}", str05M);
+            log.info("{}", str15M);
+        }
+    }
+
     @Test
     void test1() {
         for (int ii = 0; ii < 24; ii++) {