Ver Fonte

定时日结

hurugang há 5 anos atrás
pai
commit
4db52b4f01

+ 48 - 5
src/main/java/cn/hnthyy/thmz/common/ScheduledService.java

@@ -1,7 +1,9 @@
 package cn.hnthyy.thmz.common;
 
 import cn.hnthyy.thmz.entity.his.MzyRequest;
+import cn.hnthyy.thmz.service.his.ChargeFeeVoService;
 import cn.hnthyy.thmz.service.his.MzyRequestService;
+import cn.hnthyy.thmz.service.his.ZyDayclosingRecordService;
 import cn.hnthyy.thmz.service.thmz.TokenService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.time.DateFormatUtils;
@@ -26,6 +28,10 @@ public class ScheduledService {
     private TokenService tokenService;
     @Autowired
     private MzyRequestService mzyRequestService;
+    @Autowired
+    private ChargeFeeVoService chargeFeeVoService;
+    @Autowired
+    private ZyDayclosingRecordService zyDayclosingRecordService;
     /**
      * 每20分钟执行一次
      */
@@ -44,11 +50,13 @@ public class ScheduledService {
         process();
     }
 
-
-//    @Scheduled(cron = "15 27 11 * * *")
-//    public void scheduledFull() {
-//        process();
-//    }
+    /**
+     * 每天23时58分将自助收费做日结
+     */
+    @Scheduled(cron = "0 58 23 * * *")
+    public void scheduledFull() {
+        processZzRj();
+    }
 
 
 
@@ -66,4 +74,39 @@ public class ScheduledService {
 
 
 
+    /**
+     * 定时处理自助缴费日结
+     *
+     */
+    private void processZzRj() {
+       try {
+           Integer count = chargeFeeVoService.queryCountCanDaily(Constants.BRZZJF_CODE);
+           if (count == null || count == 0) {
+               log.warn("99999 费用结算失败,无可结算费用");
+               return;
+           }
+           count = chargeFeeVoService.queryTFWDFPCount(Constants.BRZZJF_CODE);
+           if (count > 0) {
+               log.warn("99999 存在退费后发票未重打的发票信息,请 处理后再结账!");
+               return;
+           }
+           chargeFeeVoService.dcountCharge(Constants.BRZZJF_CODE);
+       }catch (Exception e){
+           log.error("门诊自助日结出错。");
+       }
+
+        try{
+            zyDayclosingRecordService.dayclosing();
+        }catch (Exception e){
+            log.error("住院自助日结出错。");
+        }
+    }
+
+
+
+
+
+
+
+
 }

+ 39 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/ZyDayclosingRecordMapper.java

@@ -0,0 +1,39 @@
+package cn.hnthyy.thmz.mapper.his;
+
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.Date;
+
+/**
+ * 住院日结 99999的
+ */
+public interface ZyDayclosingRecordMapper {
+    /**
+     * 查询最后一次日结的结束时间
+     * @return
+     */
+    @Select("select top 1 date_end from zy_dayclosing_record where op_id ='99999' order by closing_date desc ")
+    Date selectLastCloseDate();
+
+    /**
+     * 保存住院日结记录
+     * @param closeDate
+     * @param lastCloseDate
+     * @return
+     */
+    @Insert("insert into zy_dayclosing_record ( op_id , closing_date , date_start , date_end , yjj_flag , bt_flag , account_patient_flag , account_ward_flag , ward_income_flag , account_deposit_flag , flag , input_id ) values " +
+            "( '99999' , #{closeDate} , #{lastCloseDate} , #{closeDate} , '1' , '1' , '1' , '1' , '1' , '1' , '1' , '99999' ) ")
+    int insertZyDayclosingRecord(@Param("closeDate") Date closeDate, @Param("lastCloseDate") Date lastCloseDate);
+
+    /**
+     * 更新日结记录
+     * @param closeDate
+     * @param lastCloseDate
+     * @return
+     */
+    @Update("update zy_ledger_file set dcount_no ='1' , dcount_date =#{closeDate} where cash_date > #{lastCloseDate} and cash_date <= #{closeDate} and cash_id like '99999' ")
+    int updateZyLedgerFile(@Param("closeDate") Date closeDate, @Param("lastCloseDate") Date lastCloseDate);
+}

+ 15 - 0
src/main/java/cn/hnthyy/thmz/service/his/ZyDayclosingRecordService.java

@@ -0,0 +1,15 @@
+package cn.hnthyy.thmz.service.his;
+
+
+
+/**
+ * 住院日结 99999的
+ */
+public interface ZyDayclosingRecordService {
+    /**
+     * 住院日结操作
+     * @return
+     */
+    void dayclosing();
+
+}

+ 28 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/ZyDayclosingRecordServiceImpl.java

@@ -0,0 +1,28 @@
+package cn.hnthyy.thmz.service.impl.his;
+
+import cn.hnthyy.thmz.mapper.his.ZyDayclosingRecordMapper;
+import cn.hnthyy.thmz.service.his.ZyDayclosingRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+
+@Service
+public class ZyDayclosingRecordServiceImpl implements ZyDayclosingRecordService {
+    @SuppressWarnings("all")
+    @Autowired
+    private ZyDayclosingRecordMapper zyDayclosingRecordMapper;
+
+    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
+    @Override
+    public void dayclosing() {
+        Date lastCloseDate = zyDayclosingRecordMapper.selectLastCloseDate();
+        Date closeDate = new Date();
+        zyDayclosingRecordMapper.insertZyDayclosingRecord(closeDate, lastCloseDate);
+        zyDayclosingRecordMapper.updateZyLedgerFile(closeDate, lastCloseDate);
+
+    }
+}