diff --git a/src/main/java/com/docus/server/archive/job/PatientInfoSyncJob.java b/src/main/java/com/docus/server/archive/job/PatientInfoSyncJob.java index 909dec1..0e430af 100644 --- a/src/main/java/com/docus/server/archive/job/PatientInfoSyncJob.java +++ b/src/main/java/com/docus/server/archive/job/PatientInfoSyncJob.java @@ -30,31 +30,45 @@ public class PatientInfoSyncJob { @XxlJob("FoShanSyPatientInfoSyncJob") public void foShanSyPatientInfoSyncJob() { log.info("====================> 佛山三院基础数据同步任务开始 ==================="); - String jobConfigPath = "data-config\\job-config"; - String jobConfigName = "FoShanSyPatientInfoSyncJob.json"; - TableJsonRead jsonReader = new TableJsonRead(); - FoShanSyPatientInfoSyncJobConfig syncJobConfig = jsonReader.Read(jobConfigPath, jobConfigName, FoShanSyPatientInfoSyncJobConfig.class); - syncJobConfig = FoShanSyPatientInfoSyncJobConfig.checkAndInit(syncJobConfig); - Integer pageSize = syncJobConfig.getPageSize(); - Integer pageNumber = syncJobConfig.getPageNumber(); - String startDate = syncJobConfig.getStartDate(); - LocalDate runLocalDate = LocalDate.now(); - String runJobDate = runLocalDate.toString(); - - patientInfoSyncService.syncInHospitalData(); - while (true) { - int syscCount = patientInfoSyncService.syncDischargeData(startDate + " 00:00:00", runJobDate + " 23:59:59", pageNumber, pageSize); - if (syscCount < pageSize) { - break; + try { + String jobConfigPath = "data-config\\job-config"; + String jobConfigName = "FoShanSyPatientInfoSyncJob.json"; + TableJsonRead jsonReader = new TableJsonRead(); + FoShanSyPatientInfoSyncJobConfig syncJobConfig = jsonReader.Read(jobConfigPath, jobConfigName, FoShanSyPatientInfoSyncJobConfig.class); + syncJobConfig = FoShanSyPatientInfoSyncJobConfig.checkAndInit(syncJobConfig); + Integer pageSize = syncJobConfig.getPageSize(); + Integer pageNumber = syncJobConfig.getPageNumber(); + String startDate = syncJobConfig.getStartDate(); + LocalDate runLocalDate = LocalDate.now(); + String runJobDate = runLocalDate.toString(); + log.info("====================> 佛山三院基础数据同步在院开始 ==================="); + patientInfoSyncService.syncInHospitalData(); + log.info("====================> 佛山三院基础数据同步在院结束 ==================="); + + log.info("====================> 佛山三院基础数据同步出院开始 ==================="); + while (true) { + int syscCount = patientInfoSyncService.syncDischargeData(startDate + " 00:00:00", runJobDate + " 23:59:59", pageNumber, pageSize); + if (syscCount < pageSize) { + break; + } + pageNumber += 1; } - pageNumber += 1; + log.info("====================> 佛山三院基础数据同步出院结束 ==================="); + + log.info("====================> 佛山三院基础数据同步退院开始 ==================="); + patientInfoSyncService.syncCancelHospitalData(); + log.info("====================> 佛山三院基础数据同步退院结束 ==================="); + // 下次同步则开始多同步一天,防止时间差引起同步缺漏 例如 10分钟同步一次 导致 23:50:01 出院未同步到 + String nexRunStartDate = runLocalDate.plusDays(-1).toString(); + syncJobConfig.setPageNumber(1); + syncJobConfig.setStartDate(nexRunStartDate); + jsonReader.Save(jobConfigPath, jobConfigName, Func.toJson(syncJobConfig)); + log.info("====================> 佛山三院基础数据同步任务结束 ==================="); + }catch (Exception e){ + log.info("====================> 佛山三院基础数据同步任务异常 ==================="+e.getMessage(),e); } - // 下次同步则开始多同步一天,防止时间差引起同步缺漏 例如 10分钟同步一次 导致 23:50:01 出院未同步到 - String nexRunStartDate = runLocalDate.plusDays(-1).toString(); - syncJobConfig.setPageNumber(1); - syncJobConfig.setStartDate(nexRunStartDate); - jsonReader.Save(jobConfigPath, jobConfigName, Func.toJson(syncJobConfig)); - log.info("====================> 佛山三院基础数据同步任务结束 ==================="); + + } private static class FoShanSyPatientInfoSyncJobConfig { diff --git a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java index 5b5ca5a..01b7b8e 100644 --- a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java @@ -23,4 +23,6 @@ public interface TBasicMapper { int updateBatch(@Param("basicList") List updateList); int cancelFileBySource(@Param("source")String source,@Param("patientId") String patientId); + + int cancelBasicByJzhs(@Param("jzhs") List jzhs); } diff --git a/src/main/java/com/docus/server/archive/service/PatientInfoSyncService.java b/src/main/java/com/docus/server/archive/service/PatientInfoSyncService.java index ee4dcdc..9e932cc 100644 --- a/src/main/java/com/docus/server/archive/service/PatientInfoSyncService.java +++ b/src/main/java/com/docus/server/archive/service/PatientInfoSyncService.java @@ -12,20 +12,33 @@ public interface PatientInfoSyncService { /** * 同步在院数据 + * * @date 2024/3/27 16:56 * @author YongBin Wen */ void syncInHospitalData(); + + /** + * 同步退院数据,作废基础数据 + * + * @date 2026/3/19 10:13 + * @author YongBin Wen + */ + void syncCancelHospitalData(); + /** * * 根据时间和页码同步出院数据 + * * @param startDateTime 开始时间 - * @param endDateTime 结束时间 - * @param pageNumber 页码 - * @param pageSize 页大小 + * @param endDateTime 结束时间 + * @param pageNumber 页码 + * @param pageSize 页大小 * @return int 同步出院数据数量 */ int syncDischargeData(String startDateTime, String endDateTime, Integer pageNumber, Integer pageSize); void insertOrUpdate(List tBasicList); + + } diff --git a/src/main/java/com/docus/server/archive/service/impl/PatientInfoSyncServiceImpl.java b/src/main/java/com/docus/server/archive/service/impl/PatientInfoSyncServiceImpl.java index 5450324..1ef611a 100644 --- a/src/main/java/com/docus/server/archive/service/impl/PatientInfoSyncServiceImpl.java +++ b/src/main/java/com/docus/server/archive/service/impl/PatientInfoSyncServiceImpl.java @@ -48,6 +48,14 @@ public class PatientInfoSyncServiceImpl implements PatientInfoSyncService { convertAndSave(inHospital); } + @Override + public void syncCancelHospitalData() { + List cancelHospital = jswzhPatientInfoViewMapper.getCancelHospital(); + if(Func.isNotEmpty(cancelHospital)){ + List cancelJzhs = cancelHospital.stream().map(JswzhPatientInfoView::getJZH).collect(Collectors.toList()); + tBasicMapper.cancelBasicByJzhs(cancelJzhs); + } + } @Override public int syncDischargeData(String startDateTime, String endDateTime, Integer pageNumber, Integer pageSize) { diff --git a/src/main/java/com/docus/server/fsy/mapper/JswzhPatientInfoViewMapper.java b/src/main/java/com/docus/server/fsy/mapper/JswzhPatientInfoViewMapper.java index 5eefd70..e10b3dd 100644 --- a/src/main/java/com/docus/server/fsy/mapper/JswzhPatientInfoViewMapper.java +++ b/src/main/java/com/docus/server/fsy/mapper/JswzhPatientInfoViewMapper.java @@ -17,10 +17,20 @@ public interface JswzhPatientInfoViewMapper { */ List getInHospital(); + /** + * + * 获取全部作废数据 + */ + List getCancelHospital(); + + /** * 根据出院时间范围(yyyy-MM-dd HH:mm:ss),分页 获取出院数据 + * * @param startRow oracle ROWNUM 起始 - * @param endRow oracle ROWNUM 结束(包含) + * @param endRow oracle ROWNUM 结束(包含) */ List getDischarge(@Param("disDateBegin") String disDateBegin, @Param("disDateEnd") String disDateEnd, @Param("startRow") int startRow, @Param("endRow") int endRow); + + } diff --git a/src/main/resources/mapper/JswzhPatientInfoViewMapper.xml b/src/main/resources/mapper/JswzhPatientInfoViewMapper.xml index 01dbae6..50c8844 100644 --- a/src/main/resources/mapper/JswzhPatientInfoViewMapper.xml +++ b/src/main/resources/mapper/JswzhPatientInfoViewMapper.xml @@ -13,6 +13,12 @@ WHERE ZYZT = 'I' + +