Browse Source

优化自动撤销未收费的门诊医保结算的定时任务

lighter 2 năm trước cách đây
mục cha
commit
721cece1c1

+ 2 - 1
src/main/java/thyyxxk/simzfeeoprnsystm/dao/ScheduledDao.java

@@ -8,6 +8,7 @@ import java.util.List;
 
 @Mapper
 public interface ScheduledDao {
-    @Select("select * from t_si_setlinfo where setl_type=11 and mz_saved=0 and revoked=0 and datediff(day, endtime, getdate())=2")
+    @Select("select pat_no,times,ledger_sn,setl_id,mdtrt_id,psn_no from t_si_setlinfo where setl_type=11 " +
+            "and mz_saved=0 and revoked=0 and datediff(hour, endtime, getdate()) between 12 and 72 ")
     List<SiSetlinfo> selectSetlinfos();
 }

+ 6 - 4
src/main/java/thyyxxk/simzfeeoprnsystm/scheduled/ScheduledTask.java

@@ -8,6 +8,7 @@ import thyyxxk.simzfeeoprnsystm.pojo.SiSetlinfo;
 import thyyxxk.simzfeeoprnsystm.service.SiMzFeeService;
 
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 @Component
 public class ScheduledTask {
@@ -20,11 +21,12 @@ public class ScheduledTask {
         this.dao = dao;
     }
 
-    @Scheduled(cron = "0 0 2 * * ?")
-    public void cancelSettlement() {
+    @Scheduled(fixedRate = 1000 * 60 * 60 * 2)
+    public void cancelSettlement() throws Exception {
         List<SiSetlinfo> list = dao.selectSetlinfos();
-        if (null != list && !list.isEmpty()) {
-            list.forEach(service::revokeOutpatientSettlementForTask);
+        for (SiSetlinfo setlinfo : list) {
+            service.revokeOutpatientSettlementForTask(setlinfo);
+            TimeUnit.SECONDS.sleep(2);
         }
     }
 }