|
@@ -8,6 +8,7 @@ import com.hgwebservice.dal.dataobject.data.OperatorDataDO;
|
|
import com.hgwebservice.dal.dataobject.data.PatientDataDO;
|
|
import com.hgwebservice.dal.dataobject.data.PatientDataDO;
|
|
import com.hgwebservice.dal.mysql.data.DispatchDataMapper;
|
|
import com.hgwebservice.dal.mysql.data.DispatchDataMapper;
|
|
import com.hgwebservice.dal.mysql.data.OperatorDataMapper;
|
|
import com.hgwebservice.dal.mysql.data.OperatorDataMapper;
|
|
|
|
+import com.hgwebservice.dal.mysql.data.PatientDataMapper;
|
|
import com.hgwebservice.entity.hisview.DispatchData;
|
|
import com.hgwebservice.entity.hisview.DispatchData;
|
|
import com.hgwebservice.entity.hisview.OperatorData;
|
|
import com.hgwebservice.entity.hisview.OperatorData;
|
|
import com.hgwebservice.entity.hisview.PatientData;
|
|
import com.hgwebservice.entity.hisview.PatientData;
|
|
@@ -29,6 +30,10 @@ public class SyncDispatchDataByDeptCodeImpl implements SyncDispatchDataByDeptCod
|
|
@Autowired
|
|
@Autowired
|
|
DispatchDataMapper dispatchDataMapper;
|
|
DispatchDataMapper dispatchDataMapper;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ PatientDataMapper patientDataMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ SyncDispatchInfoByDeptCode syncDispatchInfoByDeptCode;
|
|
|
|
+ @Autowired
|
|
HgWebService hgWebService;
|
|
HgWebService hgWebService;
|
|
@Value("${hospital_id}")
|
|
@Value("${hospital_id}")
|
|
private Integer hospitalId;
|
|
private Integer hospitalId;
|
|
@@ -38,26 +43,51 @@ public class SyncDispatchDataByDeptCodeImpl implements SyncDispatchDataByDeptCod
|
|
LambdaQueryWrapper<DispatchDataDO> dispatchDataDOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<DispatchDataDO> dispatchDataDOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
dispatchDataDOLambdaQueryWrapper.eq(DispatchDataDO::getHospitalId,hospitalId);
|
|
dispatchDataDOLambdaQueryWrapper.eq(DispatchDataDO::getHospitalId,hospitalId);
|
|
List<DispatchDataDO> dispatchDataDOS1 = dispatchDataMapper.selectList(dispatchDataDOLambdaQueryWrapper);
|
|
List<DispatchDataDO> dispatchDataDOS1 = dispatchDataMapper.selectList(dispatchDataDOLambdaQueryWrapper);
|
|
|
|
+ LambdaQueryWrapper<PatientDataDO> patientDataDOLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ patientDataDOLambdaQueryWrapper.eq(PatientDataDO::getHospitalId,hospitalId);
|
|
|
|
+ List<PatientDataDO> patientDataDOS = 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)) {
|
|
for (String deptCode : collect) {
|
|
for (String deptCode : collect) {
|
|
List<DispatchData> dispatchData = hgWebService.getDispatchDataByDeptCode(deptCode);
|
|
List<DispatchData> dispatchData = hgWebService.getDispatchDataByDeptCode(deptCode);
|
|
if (CollUtil.isNotEmpty(dispatchData)){
|
|
if (CollUtil.isNotEmpty(dispatchData)){
|
|
|
|
+ for (DispatchData dispatchDatum : dispatchData) {
|
|
|
|
+ if (dispatchDatum.getPatientNo()!=null){
|
|
|
|
+ Optional<PatientDataDO> first = patientDataDOS.stream().filter(item -> item.getPatientNo().equals(dispatchDatum.getPatientNo())).findFirst();
|
|
|
|
+ if (first.isPresent()){
|
|
|
|
+ dispatchDatum.setHospitalNo(first.get().getHospitalNo());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
List<Integer> deletedIds=new ArrayList<>();
|
|
List<Integer> deletedIds=new ArrayList<>();
|
|
|
|
+ List<String> updateIds=new ArrayList<>();
|
|
List<DispatchDataDO> collect1 = dispatchDataDOS1.stream().filter(item -> item.getDeptCode().equals(deptCode)).collect(Collectors.toList());
|
|
List<DispatchDataDO> collect1 = dispatchDataDOS1.stream().filter(item -> item.getDeptCode().equals(deptCode)).collect(Collectors.toList());
|
|
for (DispatchDataDO dispatchDataDO : collect1) {
|
|
for (DispatchDataDO dispatchDataDO : collect1) {
|
|
- Optional<DispatchData> first = dispatchData.stream().filter(item -> item.getPatientNo().equals(dispatchDataDO.getDispatchNo())).findFirst();
|
|
|
|
|
|
+ Optional<DispatchData> first = dispatchData.stream().filter(item -> item.getDispatchNo().equals(dispatchDataDO.getDispatchNo())).findFirst();
|
|
if (!first.isPresent()){
|
|
if (!first.isPresent()){
|
|
deletedIds.add(dispatchDataDO.getId());
|
|
deletedIds.add(dispatchDataDO.getId());
|
|
|
|
+ }else{
|
|
|
|
+ // 如果存在则不用新增
|
|
|
|
+ updateIds.add(dispatchDataDO.getDispatchNo());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (CollUtil.isNotEmpty(deletedIds)){
|
|
if (CollUtil.isNotEmpty(deletedIds)){
|
|
dispatchDataMapper.deleteBatchIds(deletedIds);
|
|
dispatchDataMapper.deleteBatchIds(deletedIds);
|
|
}
|
|
}
|
|
|
|
+ List<DispatchData> insertDispatchData;
|
|
|
|
+ if (CollUtil.isNotEmpty(updateIds)){
|
|
|
|
+ insertDispatchData=dispatchData.stream().filter(item->!updateIds.contains(item.getDispatchNo())).collect(Collectors.toList());
|
|
|
|
+ }else{
|
|
|
|
+ insertDispatchData=dispatchData;
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isNotEmpty(insertDispatchData)){
|
|
|
|
+ List<DispatchDataDO> dispatchDataDOS = BeanUtil.copyToList(insertDispatchData, DispatchDataDO.class);
|
|
|
|
+ operatorDataMapper.insertDispatchData(dispatchDataDOS,hospitalId);
|
|
|
|
+ }
|
|
|
|
|
|
- List<DispatchDataDO> dispatchDataDOS = BeanUtil.copyToList(dispatchData, DispatchDataDO.class);
|
|
|
|
- operatorDataMapper.replaceDispatchData(dispatchDataDOS,hospitalId);
|
|
|
|
|
|
+ // 更新到dispatch_info表
|
|
|
|
+ syncDispatchInfoByDeptCode.saveCdm2(dispatchData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|