From f257ee2f6c4378d2e74848a5c06bcf2bfe7dbc4c Mon Sep 17 00:00:00 2001 From: czx <28353131@qq.com> Date: Fri, 25 Dec 2020 17:59:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/quartz/task/ftSyncPatientTask.java | 5 +++++ .../com/ruoyi/system/fantang/mapper/FtPatientDaoMapper.java | 5 ++++- .../ruoyi/system/service/impl/SyncPatientServiceImpl.java | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/ftSyncPatientTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/ftSyncPatientTask.java index 1e3f19712..ae0e3fd25 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/ftSyncPatientTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/ftSyncPatientTask.java @@ -2,12 +2,15 @@ package com.ruoyi.quartz.task; import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.system.fantang.domain.FtRemotePatientDao; import com.ruoyi.system.fantang.mapper.FtFoodDaoMapper; import com.ruoyi.system.fantang.mapper.FtRemotePatientDaoMapper; import com.ruoyi.system.service.impl.SyncPatientServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; + /** * 定时任务调度测试 * @@ -24,6 +27,8 @@ public class ftSyncPatientTask { public void ftGetRemotePatient() { System.out.println("执行同步远程病患数据"); +// List list = ftRemotePatientDaoMapper.selectList(null); +// System.out.println(list); syncPatientService.insertToLocalSync(ftRemotePatientDaoMapper.selectList(null)); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtPatientDaoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtPatientDaoMapper.java index b1fb4d982..e16124f08 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtPatientDaoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/mapper/FtPatientDaoMapper.java @@ -21,7 +21,7 @@ public interface FtPatientDaoMapper extends BaseMapper { @Update("update ft_patient set sync_flag = 0 where off_flag = 0") public int initForSync(); - @Update("update ft_patient a, ft_sync b set a.name= b.name, a.bed_id = b.bed_id, a.sync_flag = 1 where a.hospital_id = b.hospital_id and a.name = b.name and a.bed_id = b.bed_id and a.depart_name = b.depart_name") + @Update("update ft_patient a, ft_sync b set a.name= b.name, a.bed_id = b.bed_id, a.sync_flag = 1 where a.hospital_id = b.hospital_id and a.name = b.name and a.bed_id = b.bed_id and a.depart_id = b.depart_id") public int syncEqual(); @Update("update ft_patient a, ft_sync b set a.name= b.name, a.bed_id = b.bed_id, a.sync_flag = 1 where a.hospital_id = b.hospital_id and a.name = b.name") @@ -39,6 +39,9 @@ public interface FtPatientDaoMapper extends BaseMapper { @Update("update ft_patient a inner join ft_sync b on a.hospital_id = b.hospital_id and a.sync_flag = 2 set a.depart_id = (select depart_id from ft_depart c where b.depart_name = c.depart_name )") public int updateDepartIDToNewPatient(); + @Update("update ft_sync, ft_depart set ft_sync.depart_id = ft_depart.depart_id where ft_sync.depart_name = ft_depart.depart_name") + public int updateDepartIDToPatient(); + @Select("select a.hospital_id, a.name, a.depart_name, a.bed_id, b.depart_id, c.hospital_id as old_hospital_id, c.name as old_name, a.depart_name as old_depart_name, c.bed_id as old_bed_id, c.depart_id as old_depart_id, c.patient_id as patient_id from ft_sync a LEFT JOIN ft_depart b on a.depart_name = b.depart_name LEFT JOIN ft_patient c on a.hospital_id = c.hospital_id where b.depart_id = c.depart_id and a.bed_id = c.bed_id and a.name != c.name") List syncConflictOnlyHospitalEqual(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SyncPatientServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SyncPatientServiceImpl.java index 7db404690..385dfd9e9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SyncPatientServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SyncPatientServiceImpl.java @@ -45,6 +45,7 @@ public class SyncPatientServiceImpl implements ISyncPatientService { @Transactional @Override public Integer insertToLocalSync(List remotePatientDaoList) { + System.out.println("开始同步.................."); StringBuilder syncMessage = new StringBuilder(); syncMessage.append("同步信息:"); // 清空本地中间表数据,准备接收同步数据 @@ -54,6 +55,8 @@ public class SyncPatientServiceImpl implements ISyncPatientService { for (FtRemotePatientDao dao : remotePatientDaoList) { syncPatientDaoMapper.insert(dao); } + // 为新记录填入对应的科室id + patientDaoMapper.updateDepartIDToPatient(); // 初始化本地病患表准备同步,将标志位置“0” int ret = patientDaoMapper.initForSync();