|
|
|
|
@ -38,7 +38,7 @@ public class GMCService { |
|
|
|
|
* @return list |
|
|
|
|
*/ |
|
|
|
|
public List<Patient> syncPatientData(HttpServletRequest request, String wxOpenId, String gmcOpenId, String unionId) throws ServiceException { |
|
|
|
|
log.error("[医共体-数据同步]wxOpenId={}, gmcOpenId={}", wxOpenId, gmcOpenId); |
|
|
|
|
log.info("[医共体-数据同步]wxOpenId={}, gmcOpenId={}", wxOpenId, gmcOpenId); |
|
|
|
|
if (ObjectUtils.isEmpty(wxOpenId) || ObjectUtils.isEmpty(gmcOpenId)) { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
@ -66,12 +66,19 @@ public class GMCService { |
|
|
|
|
item.setBirthday(AesWxHelper.decode(item.getBirthday())); |
|
|
|
|
item.setHealthCardId(AesWxHelper.decode(item.getHealthCardId())); |
|
|
|
|
} |
|
|
|
|
List<Patient> dbPatients = new PatientService().queryGmcCachePatientsByOpenId(wxOpenId, unionId); |
|
|
|
|
|
|
|
|
|
List<Patient> addList = new ArrayList<>(); // 需添加用户
|
|
|
|
|
List<Integer> removeIds = new ArrayList<>(); // 需删除用户ids
|
|
|
|
|
|
|
|
|
|
List<Patient> dbPatients = new PatientService().queryGmcCachePatientsByOpenId(wxOpenId, unionId); |
|
|
|
|
List<Patient> patientList = new ArrayList<>();// 返回的数据
|
|
|
|
|
for (Patient item : gmcPatients) { |
|
|
|
|
if (item.isTestUser()) { |
|
|
|
|
System.out.println("[测试账号]"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
patientList.add(item); |
|
|
|
|
|
|
|
|
|
item.setId(null); |
|
|
|
|
item.setOpenid(wxOpenId); |
|
|
|
|
if (HCardTypeEnum.NO_CARD.WX_CODE.equals(item.getCardType()) || ObjectUtils.isEmpty(item.getIdCardNo())) { // 无证绑定->不做处理
|
|
|
|
|
@ -95,7 +102,7 @@ public class GMCService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (Patient item : dbPatients) { |
|
|
|
|
Patient findItem = gmcPatients.stream().filter(o -> ( |
|
|
|
|
Patient findItem = patientList.stream().filter(o -> ( |
|
|
|
|
!ObjectUtils.isEmpty(o.getEmpiId()) && o.getEmpiId().equals(item.getEmpiId())) |
|
|
|
|
&& !ObjectUtils.isEmpty(o.getIdCardNo()) && o.getIdCardNo().equals(item.getIdCardNo()) |
|
|
|
|
).findFirst().orElse(null); |
|
|
|
|
@ -123,7 +130,7 @@ public class GMCService { |
|
|
|
|
log.error("[医共体]同步用户数据,修改医共体绑定状态失败 id:{}", item.getId()); |
|
|
|
|
item.setEmpiId(empiId); |
|
|
|
|
item.setGmcUniqueId(gmcUniqueId); |
|
|
|
|
gmcPatients.add(item); |
|
|
|
|
patientList.add(item); |
|
|
|
|
} |
|
|
|
|
} else { // 已校验过=>多余数据=>移除
|
|
|
|
|
removeIds.add(item.getId()); |
|
|
|
|
@ -145,8 +152,8 @@ public class GMCService { |
|
|
|
|
|
|
|
|
|
long endTime = System.currentTimeMillis(); |
|
|
|
|
String takeTime = (endTime - begTime) + "ms"; // 耗时
|
|
|
|
|
log.info("[医共体-数据同步][{}]][耗时:{}]-共[{}]条数据, 删除:[{}]条, 同步:[{}]条", wxOpenId, takeTime, gmcPatients.size(), delRows, addRows); |
|
|
|
|
return gmcPatients; |
|
|
|
|
log.info("[医共体-数据同步][{}]][耗时:{}]-共[{}]条数据, 删除:[{}]条, 同步:[{}]条", wxOpenId, takeTime, patientList.size(), delRows, addRows); |
|
|
|
|
return patientList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|