소스 검색

Merge branch 'master' of https://172.16.32.165/lighter/web-server

xiaochan 2 년 전
부모
커밋
141160563f

+ 24 - 1
src/main/java/thyyxxk/webserver/dao/his/inpatient/DismissDao.java

@@ -278,6 +278,28 @@ public interface DismissDao {
                                        @Param("times") Integer times,
                                        @Param("ledgerSn") int ledgerSn);
 
+    @Select("select top 1 inpatient_no, admiss_times, depo_times, depo_date, op_id_code, depo_amount, depo_type, " +
+            "status, ledger_sn, window_no, deleted from zy_deposit_file where inpatient_no=#{patNo} " +
+            "and admiss_times=#{times} order by depo_times desc")
+    DepositFile selectLatestDepositFile(@Param("patNo") String patNo,
+                                        @Param("times") Integer times);
+
+    @Select("select settle from zy_ledger_file where inpatient_no=#{patNo} and admiss_times=#{times} and " +
+            "ledger_sn=#{ledgerSn}")
+    String selectLastLedgerSettle(@Param("patNo") String patNo,
+                                  @Param("times") Integer times,
+                                  @Param("ledgerSn") Integer ledgerSn);
+
+    @Insert("insert into zy_deposit_file (inpatient_no, admiss_times, depo_times, depo_date, op_id_code, " +
+            "depo_amount, depo_type, status, ledger_sn, window_no, deleted) " +
+            "values (#{inpatientNo},#{admissTimes},#{depoTimes},#{depoDate},#{opIdCode},#{depoAmount}, " +
+            "#{depoType},#{status},#{ledgerSn},#{windowNo},#{deleted})")
+    void insertNewDeposit(DepositFile depositFile);
+
+    @Delete("delete from zy_deposit_file where inpatient_no=#{patNo} and admiss_times=#{times} and depo_type='B' ")
+    void deleteZjdzSettleDeposit(@Param("patNo") String patNo,
+                                 @Param("times") Integer times);
+
     @Update("update zy_detail_charge set ledger_sn=#{ledgerSn} where inpatient_no=#{patNo} " +
             "and admiss_times=#{times} and ledger_sn=#{lastSn} and charge_date>#{zjdzDate}")
     void updateFeesLedgerSn(@Param("patNo") String patNo,
@@ -350,7 +372,8 @@ public interface DismissDao {
                               @Param("ledgerSn") int ledgerSn);
 
     @Select("select cast(isnull(sum(depo_amount),0) as varchar(16)) from zy_deposit_file where " +
-            "inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} and status in (1,2) ")
+            "inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} and " +
+            "depo_type!='B' and status in (1,2) ")
     String selectDepositSumamt(@Param("patNo") String patNo,
                                @Param("times") int times,
                                @Param("ledgerSn") int ledgerSn);

+ 4 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiManageDao.java

@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.inpatient.patient.Overview;
 import thyyxxk.webserver.entity.medicalinsurance.manage.InstSetlLdgChkBrf;
 import thyyxxk.webserver.entity.medicalinsurance.manage.clinicinfo.ClinicDiseinfo;
 import thyyxxk.webserver.entity.medicalinsurance.manage.clinicinfo.ClinicRegistration;
@@ -251,4 +252,7 @@ public interface SiManageDao {
             " where patient_id = #{patNo} and times = #{times} ")
     Map<String, Object> selectMzBl(@Param("patNo") String patNo, @Param("times") int times);
 
+    @Select("select rtrim(bah) as inpatientNo,admiss_times from t_case_frontsheet_main " +
+            "where datediff(day, sign_date, getdate())=1 and isnull(uploaded_flag,0)=0")
+    List<Overview> selectNotUploadedSheet();
 }

+ 40 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/dismiss/DepositFile.java

@@ -0,0 +1,40 @@
+package thyyxxk.webserver.entity.inpatient.dismiss;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class DepositFile {
+    private String inpatientNo;
+    private Integer admissTimes;
+    private Integer ledgerSn;
+    private Integer depoTimes;
+    private Date depoDate;
+    private String opIdCode;
+    private String depoAmount;
+    private String depoType;
+    private String status;
+    private String windowNo;
+    private Integer deleted;
+
+    public DepositFile() {
+    }
+
+    public DepositFile(String inpatientNo, Integer admissTimes, Integer ledgerSn) {
+        this.inpatientNo = inpatientNo;
+        this.admissTimes = admissTimes;
+        this.ledgerSn = ledgerSn;
+    }
+
+    public void initZjdzSettleDeposit(String depoAmount) {
+        this.depoTimes += 1;
+        this.depoDate = new Date();
+        this.opIdCode = "00000";
+        this.depoAmount = depoAmount;
+        this.depoType = "B";
+        this.status = "1";
+        this.windowNo = "1";
+        this.deleted = 0;
+    }
+}

+ 39 - 0
src/main/java/thyyxxk/webserver/scheduled/UploadFrontSheetTask.java

@@ -0,0 +1,39 @@
+package thyyxxk.webserver.scheduled;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import thyyxxk.webserver.dao.his.medicalinsurance.SiManageDao;
+import thyyxxk.webserver.entity.inpatient.patient.Overview;
+import thyyxxk.webserver.service.medicalinsurance.SiManageService;
+
+import java.util.List;
+
+@Component
+public class UploadFrontSheetTask {
+    @Value("${execute-scheduled}")
+    private Boolean executeScheduled;
+    private final SiManageDao dao;
+    private final SiManageService service;
+
+    @Autowired
+    public UploadFrontSheetTask(SiManageDao dao, SiManageService service) {
+        this.dao = dao;
+        this.service = service;
+    }
+
+    @Scheduled(cron = "0 20 2 * * ?")
+    public void uploadStatistics() {
+        if (executeScheduled) {
+            startUploadStatistics();
+        }
+    }
+
+    private void startUploadStatistics() {
+        List<Overview> list = dao.selectNotUploadedSheet();
+        for (Overview item : list) {
+            service.uploadFrontSheet(item.getInpatientNo(), item.getAdmissTimes());
+        }
+    }
+}

+ 37 - 22
src/main/java/thyyxxk/webserver/service/inpatient/DismissService.java

@@ -467,34 +467,37 @@ public class DismissService {
 
     private int setHisStatusOut(MedinsSettleFee settle) {
         final Date disDate;
+        String patNo = settle.getInpatientNo();
+        int times = settle.getAdmissTimes();
         if ("zy_actpatient".equals(settle.getTable())) {
-            disDate = dao.selectActOrderDisDate(settle.getInpatientNo(), settle.getAdmissTimes());
+            disDate = dao.selectActOrderDisDate(patNo, times);
         } else {
-            disDate = dao.selectActOrderDisDate2(settle.getInpatientNo(), settle.getAdmissTimes());
+            disDate = dao.selectActOrderDisDate2(patNo, times);
         }
-        if (dao.updateZyActpatient(settle.getInpatientNo(), settle.getAdmissTimes(),
+        if (dao.updateZyActpatient(patNo, times,
                 disDate, settle.getStaffId(), settle.getTable()) < 1) {
             return -1;
         }
         if ("zy_actpatient".equals(settle.getTable())) {
-            dao.deleteZyInactpatient(settle.getInpatientNo(), settle.getAdmissTimes());
-            if (dao.insertZyInactpatient(settle.getInpatientNo(), settle.getAdmissTimes()) < 1) {
+            dao.deleteZyInactpatient(patNo, times);
+            if (dao.insertZyInactpatient(patNo, times) < 1) {
                 return -2;
             }
         }
-        final String patNo1 = settle.getInpatientNo() + "$1";
-        final String patNo6 = settle.getInpatientNo() + "$6";
-        dao.updateZyActpatientAgain(patNo1, patNo6, settle.getAdmissTimes(), disDate, settle.getTable());
+        final String patNo1 = patNo + "$1";
+        final String patNo6 = patNo + "$6";
+        dao.updateZyActpatientAgain(patNo1, patNo6, times, disDate, settle.getTable());
         if ("zy_actpatient".equals(settle.getTable())) {
-            dao.insertZyInactpatientAgain(patNo1, patNo6, settle.getAdmissTimes());
+            dao.insertZyInactpatientAgain(patNo1, patNo6, times);
         }
-        if (dao.updateZyAdt(settle.getInpatientNo(), settle.getAdmissTimes(), settle.getWardCode(), settle.getDeptCode(),
+        if (dao.updateZyAdt(patNo, times, settle.getWardCode(), settle.getDeptCode(),
                 settle.getBedNo(), disDate) < 1) {
             return -3;
         }
-        dao.updateZyBedMi(settle.getInpatientNo(), settle.getAdmissTimes());
-        dao.deleteZyActpatient(settle.getInpatientNo());
-        dao.deleteZyActpatientAgain(patNo1, patNo6, settle.getAdmissTimes());
+        dao.updateZyBedMi(patNo, times);
+        dao.deleteZyActpatient(patNo);
+        dao.deleteZyActpatientAgain(patNo1, patNo6, times);
+        dao.deleteZjdzSettleDeposit(patNo, times);
         return insertNewZyWorkLog(settle);
     }
 
@@ -506,15 +509,27 @@ public class DismissService {
     }
 
     private int hisMiddleSettle(MedinsSettleFee param) {
-        param.setLedgerSn(dao.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes()));
-        int newLedgerSn = param.getLedgerSn() + 1;
-        dao.updateTimesBilledByIncreaseOne(param.getInpatientNo(), param.getAdmissTimes(), param.getTable());
-        dao.insertNewLedgerFile(param.getInpatientNo(), param.getAdmissTimes(), newLedgerSn);
-        dao.updateFeesLedgerSn(param.getInpatientNo(), param.getAdmissTimes(), newLedgerSn,
-                param.getLedgerSn(), param.getZjdzDatetime());
-        dao.updateZyLedgerFileTotalCharge(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn());
-        dao.updateZyLedgerFileTotalCharge(param.getInpatientNo(), param.getAdmissTimes(), newLedgerSn);
-        dao.clearMedinsInfo(param.getInpatientNo(), param.getAdmissTimes(), DateUtil.addOneSecond(param.getZjdzDatetime()));
+        String patNo = param.getInpatientNo();
+        int times = param.getAdmissTimes();
+        int currentLedgerSn = dao.getLedgerSn(patNo, times);
+        int newLedgerSn = currentLedgerSn + 1;
+
+        dao.updateTimesBilledByIncreaseOne(patNo, times, param.getTable());
+        dao.insertNewLedgerFile(patNo, times, newLedgerSn);
+        dao.updateFeesLedgerSn(patNo, times, newLedgerSn, currentLedgerSn, param.getZjdzDatetime());
+        dao.updateZyLedgerFileTotalCharge(patNo, times, currentLedgerSn);
+        dao.updateZyLedgerFileTotalCharge(patNo, times, newLedgerSn);
+
+        DepositFile depositFile = dao.selectLatestDepositFile(patNo, times);
+        if (null == depositFile) {
+            depositFile = new DepositFile(patNo, times, newLedgerSn);
+        }
+        depositFile.initZjdzSettleDeposit(dao.selectLastLedgerSettle(patNo, times, currentLedgerSn));
+        dao.insertNewDeposit(depositFile);
+
+        dao.clearMedinsInfo(patNo, times, DateUtil.addOneSecond(param.getZjdzDatetime()));
+
+        param.setLedgerSn(currentLedgerSn);
         return insertNewZyWorkLog(param);
     }