完成同步远程病患数据到本地
This commit is contained in:
parent
a2798f7a1f
commit
63d72d7f51
@ -2,6 +2,9 @@ package com.ruoyi.system.fantang.mapper;
|
||||
|
||||
import com.ruoyi.system.fantang.domain.FtPatientDao;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 病人管理Mapper接口
|
||||
@ -9,6 +12,19 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
* @author ft
|
||||
* @date 2020-11-24
|
||||
*/
|
||||
@Repository
|
||||
public interface FtPatientDaoMapper extends BaseMapper<FtPatientDao> {
|
||||
@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")
|
||||
public int syncEqualHospitalId();
|
||||
|
||||
@Insert("Insert into ft_patient (name, bed_id, hospital_id, sync_flag) select name, bed_id, hospital_id, 2 from ft_sync where hospital_id not in (select hospital_id from ft_patient)")
|
||||
public int syncNewHospitalId();
|
||||
|
||||
@Update("update ft_patient set off_flag = 1 where sync_flag = 0")
|
||||
public int updateOffHospitalFlag();
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
|
||||
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.FtPatientDaoMapper;
|
||||
import com.ruoyi.system.fantang.mapper.FtSyncPatientDaoMapper;
|
||||
import com.ruoyi.system.service.ISyncPatientService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -16,11 +17,38 @@ public class SyncPatientServiceImpl implements ISyncPatientService {
|
||||
@Autowired
|
||||
private FtSyncPatientDaoMapper syncPatientDaoMapper;
|
||||
|
||||
@Autowired
|
||||
private FtPatientDaoMapper patientDaoMapper;
|
||||
|
||||
// 从远程数据源插上病患数据
|
||||
@Override
|
||||
public Integer insertToLocalSync(List<FtRemotePatientDao> remotePatientDaoList) {
|
||||
// 情况本地中间表数据
|
||||
syncPatientDaoMapper.delete(null);
|
||||
|
||||
// 遍历数据源,逐条插入本地中间表
|
||||
for (FtRemotePatientDao dao : remotePatientDaoList) {
|
||||
syncPatientDaoMapper.insert(dao);
|
||||
}
|
||||
return null;
|
||||
|
||||
// 初始化本地病患表准备同步,将标志位置“0”
|
||||
int ret = patientDaoMapper.initForSync();
|
||||
|
||||
// 更新住院号相同的记录,并标注
|
||||
ret = patientDaoMapper.syncEqualHospitalId();
|
||||
System.out.println(ret);
|
||||
|
||||
// 从中间表添加新增病患数据
|
||||
ret = patientDaoMapper.syncNewHospitalId();
|
||||
System.out.println(ret);
|
||||
|
||||
// 将没有同步的病患数据设置为出院状态
|
||||
patientDaoMapper.updateOffHospitalFlag();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return remotePatientDaoList.size();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user