feat:基础数据同步JOB开发

master
wyb 1 year ago
parent b62db8c7d2
commit cf3b7d9ee1

@ -1 +1 @@
{"startDate": "2024-01-01", "pageNumber": 1, "pageSize": 100}
{"startDate": "2024-01-01"}

@ -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<String, DeptInfoSyncService> 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);
}
}
}

@ -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<String, PatientInfoSyncService> 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;
}
}
}

@ -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<String, UserInfoSyncService> 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);
}
}
}

@ -81,7 +81,6 @@ public class ZqDyRyPatientInfoSyncServiceImpl implements PatientInfoSyncService
List<TBasic> insertBasicList = new ArrayList<>();
List<TBasic> updateBasicList = new ArrayList<>();
// todo 未完成的逻辑处理哪些更新,哪些新增
for (TBasic iuBasic : iuBasicList) {
String maybeJzh = iuBasic.getJzh().trim() + "@" + iuBasic.getAdmissTimes();
if (existsJzhBasicMap.containsKey(iuBasic.getJzh()) || existsJzhBasicMap.containsKey(maybeJzh)) {

Loading…
Cancel
Save