|
@@ -14,7 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Optional;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -22,12 +24,18 @@ public class SyncPatientDataByDeptCodeImpl implements SyncPatientDataByDeptCode
|
|
@Autowired
|
|
@Autowired
|
|
OperatorDataMapper operatorDataMapper;
|
|
OperatorDataMapper operatorDataMapper;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ PatientDataMapper patientDataMapper;
|
|
|
|
+ @Autowired
|
|
HgWebService hgWebService;
|
|
HgWebService hgWebService;
|
|
@Value("${hospital_id}")
|
|
@Value("${hospital_id}")
|
|
private Integer hospitalId;
|
|
private Integer hospitalId;
|
|
@Override
|
|
@Override
|
|
public void saveCdm2() {
|
|
public void saveCdm2() {
|
|
List<OperatorDataDO> operatorDataDOS = operatorDataMapper.selectList(new LambdaQueryWrapper<>());
|
|
List<OperatorDataDO> operatorDataDOS = operatorDataMapper.selectList(new LambdaQueryWrapper<>());
|
|
|
|
+
|
|
|
|
+ LambdaQueryWrapper<PatientDataDO> patientDataDOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ patientDataDOLambdaQueryWrapper.eq(PatientDataDO::getHospitalId,hospitalId);
|
|
|
|
+ List<PatientDataDO> patientDataDOS1 = patientDataMapper.selectList(patientDataDOLambdaQueryWrapper);
|
|
// if (CollUtil.isNotEmpty(operatorDataDOS)){
|
|
// if (CollUtil.isNotEmpty(operatorDataDOS)){
|
|
// List<String> collect = operatorDataDOS.stream().map(OperatorDataDO::getDeptCode).distinct().collect(Collectors.toList());
|
|
// List<String> collect = operatorDataDOS.stream().map(OperatorDataDO::getDeptCode).distinct().collect(Collectors.toList());
|
|
// if (CollUtil.isNotEmpty(collect)){
|
|
// if (CollUtil.isNotEmpty(collect)){
|
|
@@ -42,6 +50,16 @@ public class SyncPatientDataByDeptCodeImpl implements SyncPatientDataByDeptCode
|
|
// }
|
|
// }
|
|
List<PatientData> patientData = hgWebService.getPatientDataByDeptCode("55");
|
|
List<PatientData> patientData = hgWebService.getPatientDataByDeptCode("55");
|
|
if (CollUtil.isNotEmpty(patientData)){
|
|
if (CollUtil.isNotEmpty(patientData)){
|
|
|
|
+ List<Integer> deletedIds=new ArrayList<>();
|
|
|
|
+ for (PatientDataDO patientDataDO : patientDataDOS1) {
|
|
|
|
+ Optional<PatientData> first = patientData.stream().filter(item -> item.getPatientNo().equals(patientDataDO.getPatientNo())).findFirst();
|
|
|
|
+ if (!first.isPresent()){
|
|
|
|
+ deletedIds.add(patientDataDO.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isNotEmpty(deletedIds)){
|
|
|
|
+ patientDataMapper.deleteBatchIds(deletedIds);
|
|
|
|
+ }
|
|
List<PatientDataDO> patientDataDOS = BeanUtil.copyToList(patientData, PatientDataDO.class);
|
|
List<PatientDataDO> patientDataDOS = BeanUtil.copyToList(patientData, PatientDataDO.class);
|
|
operatorDataMapper.replacePatientData(patientDataDOS,hospitalId);
|
|
operatorDataMapper.replacePatientData(patientDataDOS,hospitalId);
|
|
}
|
|
}
|