diff --git a/data-config/job-config/ViewPatientInfoSyncJob.json b/data-config/job-config/ViewPatientInfoSyncJob.json index 0aad88c..f978a92 100644 --- a/data-config/job-config/ViewPatientInfoSyncJob.json +++ b/data-config/job-config/ViewPatientInfoSyncJob.json @@ -1 +1 @@ -{"startDate": "2024-01-01", "pageNumber": 1, "pageSize": 100} \ No newline at end of file +{"startDate": "2024-01-01"} \ No newline at end of file diff --git a/src/main/java/com/docus/server/archive/job/DeptInfoSyncJob.java b/src/main/java/com/docus/server/archive/job/DeptInfoSyncJob.java new file mode 100644 index 0000000..1d0d82c --- /dev/null +++ b/src/main/java/com/docus/server/archive/job/DeptInfoSyncJob.java @@ -0,0 +1,48 @@ +package com.docus.server.archive.job; + +import com.docus.server.archive.config.DocusProperties; +import com.docus.server.archive.constans.SyncConstant; +import com.docus.server.archive.service.DeptInfoSyncService; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 科室数据同步job + * + * @author YongBin Wen + * @date 2024/5/27 9:16 + */ +@Component +@Slf4j +public class DeptInfoSyncJob { + @Resource + private DocusProperties docusProperties; + @Autowired + private Map deptInfoSyncServiceMap = new ConcurrentHashMap<>(); + + @XxlJob("DeptInfoSyncJob") + public void deptInfoSync() { + String syncServicePrefix = docusProperties.getSyncServicePrefix(); + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {} 科室基础数据同步开始了!", syncServicePrefix); + String serviceName = syncServicePrefix + SyncConstant.DEPT_INFO_SYNC_SERVICE_SUFFIX; + DeptInfoSyncService deptInfoSyncService = deptInfoSyncServiceMap.get(serviceName); + if (deptInfoSyncService == null) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 科室基础数据同步服务 {} 未找到!", serviceName); + return; + } + try { + deptInfoSyncService.fullSync(); + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {} 科室基础数据同步结束了!", syncServicePrefix); + } catch (Exception ex) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + syncServicePrefix + " 科室基础数据同步出现异常!" + ex.getMessage(), ex); + } + } + + +} diff --git a/src/main/java/com/docus/server/archive/job/PatientInfoSyncJob.java b/src/main/java/com/docus/server/archive/job/PatientInfoSyncJob.java new file mode 100644 index 0000000..e55dd98 --- /dev/null +++ b/src/main/java/com/docus/server/archive/job/PatientInfoSyncJob.java @@ -0,0 +1,89 @@ +package com.docus.server.archive.job; + +import com.docus.core.util.Func; +import com.docus.infrastructure.core.utils.TableJsonRead; +import com.docus.server.archive.config.DocusProperties; +import com.docus.server.archive.constans.SyncConstant; +import com.docus.server.archive.service.PatientInfoSyncService; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 患者基础数据同步job + * + * @author YongBin Wen + * @date 2024/5/27 9:16 + */ +@Component +@Slf4j +public class PatientInfoSyncJob { + + @Resource + private DocusProperties docusProperties; + @Autowired + private Map patientInfoSyncServiceMap = new ConcurrentHashMap<>(); + + @XxlJob("PatientInfoSyncByModifyTimeJob") + public void patientInfoSyncByModifyTime() { + String syncServicePrefix = docusProperties.getSyncServicePrefix(); + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {} 患者基础数据按照最后修改时间同步开始了!", syncServicePrefix); + String serviceName = syncServicePrefix + SyncConstant.PATIENT_INFO_SYNC_SERVICE_SUFFIX; + PatientInfoSyncService patientInfoSyncService = patientInfoSyncServiceMap.get(serviceName); + if (patientInfoSyncService == null) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 患者基础数据同步服务 {} 未找到!", serviceName); + return; + } + String jobConfigPath = "data-config\\job-config"; + String jobConfigName = "ViewPatientInfoSyncJob.json"; + TableJsonRead jsonReader = new TableJsonRead(); + PatientInfoSyncJobConfig syncJobConfig = jsonReader.Read(jobConfigPath, jobConfigName, PatientInfoSyncJobConfig.class); + syncJobConfig = PatientInfoSyncJobConfig.checkAndInit(syncJobConfig); + String startDate = syncJobConfig.getStartDate(); + LocalDate runLocalDate = LocalDate.now(); + String startDateTimeStr = startDate + " 00:00:00"; + String endDateTimeStr = runLocalDate.toString() + " 23:59:59"; + try { + patientInfoSyncService.syncByModifyTime(Func.parseDateTime(startDateTimeStr), Func.parseDateTime(endDateTimeStr)); + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {} 患者基础数据按照最后修改时间 {} ,{} 同步结束了!", syncServicePrefix, startDateTimeStr, endDateTimeStr); + // 下次同步则开始多同步一天,防止时间差引起同步缺漏 例如 10分钟同步一次 导致 23:50:01 出院未同步到 + String nexRunStartDate = runLocalDate.plusDays(-1).toString(); + syncJobConfig.setStartDate(nexRunStartDate); + jsonReader.Save(jobConfigPath, jobConfigName, Func.toJson(syncJobConfig)); + } catch (Exception ex) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + syncServicePrefix + " 患者基础数据按照最后修改时间 " + startDateTimeStr + "," + endDateTimeStr + " 出现异常!" + ex.getMessage(), ex); + } + + } + + + private static class PatientInfoSyncJobConfig { + private String startDate; + + + public static PatientInfoSyncJobConfig checkAndInit(PatientInfoSyncJobConfig jobConfig) { + if (Objects.isNull(jobConfig)) { + jobConfig = new PatientInfoSyncJobConfig(); + } + if (Objects.isNull(jobConfig.getStartDate())) { + jobConfig.setStartDate(LocalDate.now().toString()); + } + return jobConfig; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + } +} diff --git a/src/main/java/com/docus/server/archive/job/UserInfoSyncJob.java b/src/main/java/com/docus/server/archive/job/UserInfoSyncJob.java new file mode 100644 index 0000000..d5bd5b7 --- /dev/null +++ b/src/main/java/com/docus/server/archive/job/UserInfoSyncJob.java @@ -0,0 +1,48 @@ +package com.docus.server.archive.job; + +import com.docus.server.archive.config.DocusProperties; +import com.docus.server.archive.constans.SyncConstant; +import com.docus.server.archive.service.UserInfoSyncService; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 员工用户数据同步job + * + * @author YongBin Wen + * @date 2024/5/27 9:16 + */ +@Component +@Slf4j +public class UserInfoSyncJob { + @Resource + private DocusProperties docusProperties; + @Autowired + private Map userInfoSyncServiceMap = new ConcurrentHashMap<>(); + + + @XxlJob("UserInfoSyncJob") + public void userInfoSync() { + String syncServicePrefix = docusProperties.getSyncServicePrefix(); + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {} 用户基础数据同步开始了!", syncServicePrefix); + String serviceName = syncServicePrefix + SyncConstant.USER_INFO_SYNC_SERVICE_SUFFIX; + UserInfoSyncService userInfoSyncService = userInfoSyncServiceMap.get(serviceName); + if (userInfoSyncService == null) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 用户基础数据同步服务 {} 未找到!", serviceName); + return; + } + try { + userInfoSyncService.fullSync(); + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {} 用户基础数据同步结束了!", syncServicePrefix); + } catch (Exception ex) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " + syncServicePrefix + " 用户基础数据同步出现异常!" + ex.getMessage(), ex); + } + } + +} diff --git a/src/main/java/com/docus/server/archive/service/impl/ZqDyRyPatientInfoSyncServiceImpl.java b/src/main/java/com/docus/server/archive/service/impl/ZqDyRyPatientInfoSyncServiceImpl.java index 5697cda..e02fe30 100644 --- a/src/main/java/com/docus/server/archive/service/impl/ZqDyRyPatientInfoSyncServiceImpl.java +++ b/src/main/java/com/docus/server/archive/service/impl/ZqDyRyPatientInfoSyncServiceImpl.java @@ -81,7 +81,6 @@ public class ZqDyRyPatientInfoSyncServiceImpl implements PatientInfoSyncService List insertBasicList = new ArrayList<>(); List updateBasicList = new ArrayList<>(); - // todo 未完成的逻辑处理哪些更新,哪些新增 for (TBasic iuBasic : iuBasicList) { String maybeJzh = iuBasic.getJzh().trim() + "@" + iuBasic.getAdmissTimes(); if (existsJzhBasicMap.containsKey(iuBasic.getJzh()) || existsJzhBasicMap.containsKey(maybeJzh)) {