完善远程病患同步逻辑

This commit is contained in:
czx 2020-11-26 14:29:20 +08:00
parent 63d72d7f51
commit 820bb00831
2 changed files with 9 additions and 7 deletions

View File

@ -26,5 +26,8 @@ public interface FtPatientDaoMapper extends BaseMapper<FtPatientDao> {
@Update("update ft_patient set off_flag = 1 where sync_flag = 0")
public int updateOffHospitalFlag();
@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();
}

View File

@ -23,7 +23,7 @@ public class SyncPatientServiceImpl implements ISyncPatientService {
// 从远程数据源插上病患数据
@Override
public Integer insertToLocalSync(List<FtRemotePatientDao> remotePatientDaoList) {
// 情况本地中间表数据
// 清空本地中间表数据准备接收同步数据
syncPatientDaoMapper.delete(null);
// 遍历数据源逐条插入本地中间表
@ -34,20 +34,19 @@ public class SyncPatientServiceImpl implements ISyncPatientService {
// 初始化本地病患表准备同步将标志位置0
int ret = patientDaoMapper.initForSync();
// 更新住院号相同的记录并标注
// 更新住院号相同的记录并标注flag=1
ret = patientDaoMapper.syncEqualHospitalId();
System.out.println(ret);
// 从中间表添加新增病患数据
// 从中间表添加新增病患数据并标注flag=2
ret = patientDaoMapper.syncNewHospitalId();
System.out.println(ret);
// 将没有同步的病患数据设置为出院状态
// 将没有同步的病患数据设置为出院状态, off_flag=1
patientDaoMapper.updateOffHospitalFlag();
// 为新病患记录填入对应的科室id
patientDaoMapper.updateDepartIDToNewPatient();
return remotePatientDaoList.size();
}