Ver código fonte

自动上传结算单上传

xiaochan 3 anos atrás
pai
commit
59a8f4bb22

+ 8 - 0
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SetlListUpldController.java

@@ -12,8 +12,10 @@ import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyInactpatient;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupld.PatientBldInfo;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupld.UpldCollection;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupldTemp.UpldCollectionTemp;
+import thyyxxk.webserver.entity.querydata.ConsumablesStatistics;
 import thyyxxk.webserver.entity.querydata.JieSuanDanChaXun;
 import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
+import thyyxxk.webserver.service.LoginService;
 import thyyxxk.webserver.service.medicalinsurance.SetlListUpldService;
 
 import javax.servlet.http.HttpServletResponse;
@@ -156,4 +158,10 @@ public class SetlListUpldController {
     public ResultVo<String> removeBloodTransfusion(@RequestParam("id") Integer id) {
         return service.removeBloodTransfusion(id);
     }
+
+    @PostMapping("/exportAutoUploadInfo")
+    public void exportAutoUploadInfo(HttpServletResponse response, @RequestBody ConsumablesStatistics param) {
+        service.exportAutoUploadInfo(response, param.getStartTime(), param.getEndTime());
+    }
+
 }

+ 34 - 5
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/UpIdCollectionDao.java

@@ -12,6 +12,7 @@ import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyDisDiagYb;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyInactpatient;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupld.*;
 import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
+import thyyxxk.webserver.entity.querydata.TAutoUploadBill;
 
 import java.util.Date;
 import java.util.List;
@@ -176,10 +177,10 @@ public interface UpIdCollectionDao {
 
     @Select("select (select si_code from zd_country_code where code = country)                    as ntly, " +
             "       dis_date                               as setl_end_date, " +
-            "       begntime                            as setl_begn_date, " +
-            "       begntime                            as adm_time," +
-            "       case " + "           when datediff(day, begntime, dis_date) <= 0 then 1 " +
-            "           else datediff(day, begntime, dis_date) end  as act_ipt_days,/*实际住院天数*/ " +
+            "       admiss_date                            as setl_begn_date, " +
+            "       admiss_date                            as adm_time," +
+            "       case " + "           when datediff(day, admiss_date, dis_date) <= 0 then 1 " +
+            "           else datediff(day, admiss_date, dis_date) end  as act_ipt_days,/*实际住院天数*/ " +
             "       dis_date as dscg_time, " +
             "       isnull(nullif(occupation_code, ''), 90) as prfs," +
             "       adm_way = '2' " +
@@ -513,7 +514,7 @@ public interface UpIdCollectionDao {
     List<OpspdiseinfoUpld> outpatientDiagnosis(@Param("patNo") String patNo,
                                                @Param("times") Integer times);
 
-    @Select("select rtrim(a.name)                                        as psnName, " +
+    @Select("select top 1 rtrim(a.name)                                        as psnName, " +
             "       isnull(nullif(rtrim(b.occupation_code), " +
             "                     ''), " +
             "              90)                                           as prfs, " +
@@ -583,4 +584,32 @@ public interface UpIdCollectionDao {
                                    @Param("times") Integer times,
                                    @Param("ledgerSn") Integer ledgerSn);
 
+    @Select("select pat_no, times, ledger_sn " +
+            "from t_si_setlinfo " +
+            "where datediff(day, setl_time, getdate()) = 1 ")
+    List<SiSetlinfoTemp> getBillingPatientsToday();
+
+    /**
+     * 自动上传的信息
+     *
+     * @param patNo    住院号
+     * @param times    住院次数
+     * @param ledgerSn 账页号
+     * @param logText  日志
+     */
+    @Select("insert into t_auto_upload_bill (pat_no, times, ledger_sn, log_text,upload_date) " +
+            "values (#{patNo},#{times},#{ledgerSn},#{logText},'${uploadDate}')")
+    void insertAutoLongPassError(@Param("patNo") String patNo,
+                                 @Param("times") Integer times,
+                                 @Param("ledgerSn") Integer ledgerSn,
+                                 @Param("logText") String logText,
+                                 @Param("uploadDate") String uploadDate);
+
+    @Select("select * " +
+            "from t_auto_upload_bill " +
+            "where upload_date <= '${startTime}' " +
+            "  and upload_date >= '${endTime}'")
+    List<TAutoUploadBill> exportAutoUploadInfo(@Param("startTime") String startTime,
+                                               @Param("endTime") String endTime);
+
 }

+ 2 - 1
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/CaoYaoYiZhuDao.java

@@ -50,7 +50,8 @@ public interface CaoYaoYiZhuDao {
      *
      * @return 返回金额
      */
-    @Select("select isnull(charge_amount,0) from zd_charge_item with (NOLOCK) where code = (select charge_code_zydj from yz_sequence) ")
+    @Select("select isnull(charge_amount,0) from zd_charge_item " +
+            "with (NOLOCK) where code = (select charge_code_zydj from yz_sequence) ")
     BigDecimal huoQuDaiJianFei();
 
 

+ 54 - 0
src/main/java/thyyxxk/webserver/entity/querydata/TAutoUploadBill.java

@@ -0,0 +1,54 @@
+package thyyxxk.webserver.entity.querydata;
+
+import java.io.Serializable;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * @author 肖蟾
+ */
+@Data
+@Accessors(chain = true)
+public class TAutoUploadBill implements Serializable {
+
+    private static final long serialVersionUID = 1013877641737124615L;
+
+    /**
+     * id
+     */
+    private Integer id;
+
+    /**
+     * patNo
+     */
+    private String patNo;
+
+    /**
+     * times
+     */
+    private Integer times;
+
+    /**
+     * ledgerSn
+     */
+    private Integer ledgerSn;
+
+    /**
+     * logText
+     */
+    private String logText;
+
+    /**
+     * createdDate
+     */
+    private Date createdDate;
+
+    /**
+     * 上传的是哪一天的
+     */
+    private Date uploadDate;
+
+}

+ 54 - 0
src/main/java/thyyxxk/webserver/scheduled/UploadBillingList.java

@@ -0,0 +1,54 @@
+package thyyxxk.webserver.scheduled;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import thyyxxk.webserver.dao.his.medicalinsurance.TransHospRcdDao;
+import thyyxxk.webserver.dao.his.medicalinsurance.UpIdCollectionDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
+import thyyxxk.webserver.service.medicalinsurance.SetlListUpldService;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.ListUtil;
+
+import java.util.Date;
+import java.util.List;
+
+@Component
+@Slf4j
+public class UploadBillingList {
+    private final SetlListUpldService service;
+    private final UpIdCollectionDao dao;
+
+    @Value("${execute-scheduled}")
+    private Boolean executeScheduled;
+
+    public UploadBillingList(SetlListUpldService service, UpIdCollectionDao dao) {
+        this.service = service;
+        this.dao = dao;
+    }
+
+    @Scheduled(cron = "0 0 0 * * ?")
+    public void uploadStatement() {
+        if (!executeScheduled) {
+            return;
+        }
+        List<SiSetlinfoTemp> list = dao.getBillingPatientsToday();
+        log.info("结算单上传定时任务开启");
+        String uploadDate = DateUtil.formatDatetime(DateUtil.timeAddOrMinusDays(new Date(), -1), DateUtil.DATE);
+        if (ListUtil.notBlank(list)) {
+            for (SiSetlinfoTemp item : list) {
+                try {
+                    log.info("正在上传 ==> 住院号:{},住院次数:{},账页号:{}", item.getPatNo(), item.getTimes(), item.getLedgerSn());
+                    ResultVo<String> resultVo = service.upldSetlList(item.getPatNo(), item.getTimes(), item.getLedgerSn());
+                    dao.insertAutoLongPassError(item.getPatNo(), item.getTimes(), item.getLedgerSn(), resultVo.getMessage(), uploadDate);
+                } catch (Exception e) {
+                    dao.insertAutoLongPassError(item.getPatNo(), item.getTimes(), item.getLedgerSn(), e.getMessage(), uploadDate);
+                    log.info("上传错误", e);
+                }
+            }
+        }
+        log.info("上传结束");
+    }
+}

+ 22 - 0
src/main/java/thyyxxk/webserver/service/medicalinsurance/SetlListUpldService.java

@@ -34,6 +34,7 @@ import thyyxxk.webserver.entity.medicalinsurance.setllistupld.*;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupldTemp.*;
 import thyyxxk.webserver.entity.querydata.JieSuanDanChaXun;
 import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
+import thyyxxk.webserver.entity.querydata.TAutoUploadBill;
 import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.service.casefrontsheet.CaseFrontSheetMainService;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
@@ -1225,4 +1226,25 @@ public class SetlListUpldService {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
 
+    public void exportAutoUploadInfo(HttpServletResponse response, String startTime, String endTime) {
+        log.info("手术:{}", startTime);
+        List<TAutoUploadBill> list = dao.exportAutoUploadInfo(startTime, endTime);
+        if (ListUtil.isBlank(list)) {
+            throw new BizException(ExceptionEnum.INTERNAL_SERVER_ERROR, "没有查到数据");
+        }
+        String[] title = {"住院号", "住院次数", "上传时间", "日志", "患者结算时间"};
+        String[][] content = new String[list.size()][];
+        for (int i = 0, len = list.size(); i < len; i++) {
+            content[i] = new String[title.length];
+            TAutoUploadBill pojo = list.get(i);
+            content[i][0] = pojo.getPatNo();
+            content[i][1] = pojo.getTimes().toString();
+            content[i][2] = DateUtil.formatDatetime(pojo.getCreatedDate());
+            content[i][3] = pojo.getLogText();
+            content[i][4] = DateUtil.formatDatetime(pojo.getUploadDate(), DateUtil.DATE);
+        }
+        ExcelUtil.exportExcel(response, title, content);
+    }
+
+
 }

+ 9 - 0
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -20,6 +20,7 @@ import java.util.Date;
 public class DateUtil {
 
     public static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss";
+    public static final String DATE = "yyyy-MM-dd";
 
     public static String formatPriceTime(String priceTime) {
         return null == priceTime ? "" : priceTime.split("\\.")[0].replace("T", " ");
@@ -137,6 +138,14 @@ public class DateUtil {
         return df.format(yesterday);
     }
 
+
+    public static Date timeAddOrMinusDays(Date date, int day) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.DATE, day);
+        return cal.getTime();
+    }
+
     public static Integer calculateAge(Date birthDate, Date admdate) {
         if (null == birthDate) {
             return null;

+ 1 - 1
src/main/resources/application.yml

@@ -8,7 +8,7 @@ spring:
     cache: false
   datasource:
     dynamic:
-      primary: dev
+      primary: his
       strict: false
       datasource:
         his: