Просмотр исходного кода

1. 푸시 발송 로직 변경
2. 매일발송건 중 발송 상태가 발송중에서 변경되지 않는 건수 발송 대기로 업데이트 기능 추가

jksong 3 лет назад
Родитель
Сommit
b35c7d7f5e

+ 16 - 6
src/main/java/com/lemon/lifecenter/scheduler/common/HomeController.java

@@ -84,22 +84,32 @@ public class HomeController {
         pushController.deleteEndCenterSchedule();
     }
     
+    /**
+     * 하루에 한번 매일 발송건 중에서 발송 중 상태에서
+     * 대기로 변경되지 않은 것들을 발송 대기 상태로 변경해준다
+     */
+    @Scheduled(cron = "* * 04 * * *", zone = "Asia/Seoul")
+    public void updateIngToWait() {
+        pushController.updateIngStateToWaitState();
+    }
+    
     /**
      * 1초 31초 
      * 16초 46초
      * 매분 지정한 초 마다
      */
-//    @Scheduled(cron = "01 * * * * *", zone = "Asia/Seoul")
-//    public void sendTask1() {
-//        pushController.selectSendPushList();
-//        pushController.everyDayPushSend();
-//    }
-//    
+    @Scheduled(cron = "01 * * * * *", zone = "Asia/Seoul")
+    public void sendTask1() {
+        pushController.selectSendPushList();
+        pushController.everyDayPushSend();
+    }
+    
     @Scheduled(cron = "31 * * * * *", zone = "Asia/Seoul")
     public void sendTask2() {
         pushController.selectSendPushList();
         pushController.everyDayPushSend();
     }
+    
 //    
 //    @Scheduled(cron = "16 * * * * *", zone = "Asia/Seoul")
 //    public void sendTask3() {

+ 17 - 10
src/main/java/com/lemon/lifecenter/scheduler/controller/PushController.java

@@ -47,8 +47,6 @@ public class PushController {
         pushUtils.compareTime("18:00:01");
     }
     
-//    @RequestMapping(value = "/selectSendPushList", method = RequestMethod.POST)
-//    @Transactional(propagation=Propagation.REQUIRED, rollbackFor = Exception.class)
     public void selectSendPushList() {
         int count = service.selectSendPushCount();
         if (count == 0) {
@@ -75,14 +73,15 @@ public class PushController {
                 
                 if (useYn.equals("Y")) {
                     if (pushUtils.compareDateTime(startDate) == true) {
+                        
+                        list.get(i).setSendState("I");
+                        service.updatePushSchedule(list.get(i));
+                        
                         int idx = service.insertPushLog(list.get(i));
                         logIdx = list.get(i).getIdx();
-                        logger.error("idx -- > " + idx);
-                        logger.error("logIdx" + logIdx);
+                        
                         if (idx == 0) {
                         } else {
-                            list.get(i).setSendState("I");
-                            service.updatePushSchedule(list.get(i));
                             // sendType : D(즉시), R(발송중), E(매일 발송)
                             // sendState : W(대기), I(발송중), C(완료)
                             // targetType : A(전체), N(건강정보 미엽락자), M(본인관리환자), P(환자개별선택)
@@ -147,8 +146,6 @@ public class PushController {
         }
     }
     
-//    @RequestMapping(value = "/everyDayPushSend", method = RequestMethod.POST)
-    @Transactional(propagation=Propagation.REQUIRED, rollbackFor = Exception.class)
     public void everyDayPushSend() {
         int cnt = service.selectEveryDaySendPushCount();
         if (cnt == 0) {
@@ -166,13 +163,15 @@ public class PushController {
                 
                 if (useYn.equals("Y")) { // 사용중인 생활치료센터만
                     if (pushUtils.compareTime(sendTime) == true) {
+                        list.get(i).setSendState("I");
+                        service.updatePushSchedule(list.get(i));
+                        
                         int idx = service.insertEveryDayPushLog(list.get(i));
                         logIdx = list.get(i).getIdx();
                         
                         if (idx == 0) {
                         } else {
-                            list.get(i).setSendState("I");
-                            service.updatePushSchedule(list.get(i));
+                            
                             // sendType : D(즉시), R(발송중), E(매일 발송)
                             // sendState : W(대기), I(발송중), C(완료)
                             // targetType : A(전체), N(건강정보 미엽락자), M(본인관리환자), P(환자개별선택), T(정신건강 미입력자)
@@ -246,6 +245,14 @@ public class PushController {
         }
     }
     
+    public void updateIngStateToWaitState() {
+        int cnt = service.selectIngStateCount();
+        
+        if (cnt > 0) {
+            service.updateIngStateToWait();
+        }
+    }
+    
     private Connection con;
     private Statement stmt;
     @RequestMapping(value = "/createResultTable", method = RequestMethod.GET)

+ 4 - 0
src/main/java/com/lemon/lifecenter/scheduler/mapper/PushMapper.java

@@ -37,4 +37,8 @@ public interface PushMapper {
     public int insertEveryDayPushLog(ScheduleDTO dto);
     public int selectEndCenterScheduleCount();
     public void deleteEndCenterSchedule();
+    
+    
+    public int selectIngStateCount();
+    public void updateIngStateToWait();
 }

+ 13 - 0
src/main/java/com/lemon/lifecenter/scheduler/service/PushService.java

@@ -97,4 +97,17 @@ public class PushService {
     public void deleteEndCenterSchedule() {
         mapper.deleteEndCenterSchedule();
     }
+    
+    /** 매일발송
+     * 발송중 상태값이 변하지 않은것들 **/
+    public int selectIngStateCount() {
+        return mapper.selectIngStateCount();
+    }
+    
+    /** 매일발송 
+     * 발송중 상태 값이 변하지 않은 것들을 
+     * 발송 대기 중으로 다시 바꿔 준다 **/
+    public void updateIngStateToWait() {
+        mapper.updateIngStateToWait();
+    }
 }

+ 4 - 4
src/main/resources/application.properties

@@ -1,9 +1,9 @@
-#spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
+spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
 #spring.datasource.url=jdbc:log4jdbc:cubrid:118.67.133.187:30000:LIFE_CENTER:::?charset=UTF-8
-#spring.datasource.url=jdbc:log4jdbc:cubrid:localhost:30000:LIFE_CENTER:::?charset=UTF-8
+spring.datasource.url=jdbc:log4jdbc:cubrid:localhost:30000:LIFE_CENTER:::?charset=UTF-8
 
-spring.datasource.driver-class-name=cubrid.jdbc.driver.CUBRIDDriver
-spring.datasource.url=jdbc:cubrid:10.175.153.104:30000:LIFE_CENTER:::?altHosts=10.175.153.105:30000&charset=UTF-8
+#spring.datasource.driver-class-name=cubrid.jdbc.driver.CUBRIDDriver
+#spring.datasource.url=jdbc:cubrid:10.175.153.104:30000:LIFE_CENTER:::?altHosts=10.175.153.105:30000&charset=UTF-8
 
 spring.datasource.username=hcms
 spring.datasource.password=@Aser()02@#

+ 20 - 0
src/main/resources/mybatis/mapper/push/push.xml

@@ -335,4 +335,24 @@
                                         AND CI.USE_YN = 'N')
         ]]>
     </delete>
+    
+    <select id="selectIngStateCount" resultType="int">
+        <![CDATA[
+            SELECT COUNT(*) AS cnt
+              FROM PUSH_SCHEDULE
+             WHERE 1 = 1
+               AND SEND_TYPE = 'E'
+               AND SEND_STATE = 'I'
+        ]]>
+    </select>
+    
+    <update id="updateIngStateToWait">
+        <![CDATA[
+            UPDATE PUSH_SCHEDULE
+               SET SEND_STATE = 'W'
+             WHERE 1 = 1
+               AND SEND_TYPE = 'E'
+               AND SEND_STATE = 'I'
+        ]]>
+    </update>
 </mapper>