|
@ -1172,84 +1172,99 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
// 1.获取核酸采样信息
|
|
|
// 1.获取核酸采样信息
|
|
|
Map<String, Object> args = new HashMap<>(); |
|
|
Map<String, Object> args = new HashMap<>(); |
|
|
args.put("idcards", idCards); |
|
|
args.put("idcards", idCards); |
|
|
List<Map<String,Object>> vaccineList = yantaiNamedParamLantuJdbcTemplate.queryForList( |
|
|
List<Map<String,Object>> vaccineListGetted = yantaiNamedParamLantuJdbcTemplate.queryForList( |
|
|
"select data, name, cardno, vaccineCount from t_ymjz_info where cardno in (:idcards)", args); |
|
|
"select data, name, cardno, vaccineCount from t_ymjz_info where cardno in (:idcards)", args); |
|
|
|
|
|
if (CollectionUtils.isEmpty(vaccineListGetted)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 将获取到的json数据进行日期格式转化,暂存到java对象
|
|
|
List<YTVaccineListDTO> ytVaccineListFromApi = new ArrayList<>(); |
|
|
List<YTVaccineListDTO> ytVaccineListFromApi = new ArrayList<>(); |
|
|
if (CollectionUtils.isNotEmpty(vaccineList)) { |
|
|
vaccineListGetted.forEach(vGetted -> { |
|
|
vaccineList.forEach(v -> { |
|
|
if (vGetted.containsKey("data")){ |
|
|
if (v.containsKey("data")){ |
|
|
JSONObject jo = JSON.parseObject((String) vGetted.get("data")); |
|
|
JSONObject jo = JSON.parseObject((String) v.get("data")); |
|
|
if (jo.containsKey("vaccineList")) { |
|
|
if (jo.containsKey("vaccineList")) { |
|
|
JSONArray vaccineListJA = jo.getJSONArray("vaccineList"); |
|
|
JSONArray vaccineListJA = jo.getJSONArray("vaccineList"); |
|
|
List<YTVaccineListDTO> vaccineList1 = vaccineListJA.toJavaList(YTVaccineListDTO.class); |
|
|
List<YTVaccineListDTO> vaccineList1 = vaccineListJA.toJavaList(YTVaccineListDTO.class); |
|
|
vaccineList1.forEach(v1 -> { |
|
|
vaccineList1.forEach(v1 -> { |
|
|
v1.setCardno(vGetted.get("cardno").toString()); |
|
|
v1.setCardno(v.get("cardno").toString()); |
|
|
|
|
|
|
|
|
// 秒转换成:00
|
|
|
// 秒转换成:00
|
|
|
Matcher matcher = VACCINE_DATE_OF_API_PATTERN.matcher(v1.getInoculateDate()); |
|
|
Matcher matcher = VACCINE_DATE_OF_API_PATTERN.matcher(v1.getInoculateDate()); |
|
|
if (matcher.matches()) { |
|
|
if (matcher.matches()) { |
|
|
v1.setInoculateDate(matcher.group(1).concat(":00")); |
|
|
v1.setInoculateDate(matcher.group(1).concat(":00")); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
ytVaccineListFromApi.addAll(vaccineList1); |
|
|
ytVaccineListFromApi.addAll(vaccineList1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
} |
|
|
List<IcVaccineEntity> entities = new ArrayList<>(); |
|
|
}); |
|
|
|
|
|
|
|
|
// 过滤已存在的记录
|
|
|
if (CollectionUtils.isEmpty(ytVaccineListFromApi)) { |
|
|
List<YTVaccineListDTO> existVaccines = icVaccineDao.getExistVaccine(ytVaccineListFromApi); |
|
|
return; |
|
|
if (CollectionUtils.isNotEmpty(existVaccines)){ |
|
|
} |
|
|
for (YTVaccineListDTO existVaccineItem : existVaccines) { |
|
|
|
|
|
Iterator<YTVaccineListDTO> iterator = ytVaccineListFromApi.iterator(); |
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
|
YTVaccineListDTO vaccineFromApi = iterator.next(); |
|
|
|
|
|
|
|
|
|
|
|
// 身份证号和接种时间都一致,移除
|
|
|
// 过滤已存在的记录
|
|
|
if (vaccineFromApi.getCardno().equals(existVaccineItem.getCardno()) |
|
|
List<YTVaccineListDTO> existVaccines = icVaccineDao.getExistVaccine(ytVaccineListFromApi); |
|
|
&& vaccineFromApi.getInoculateDate().equals(existVaccineItem.getInoculateDate())) { |
|
|
if (CollectionUtils.isNotEmpty(existVaccines)){ |
|
|
|
|
|
for (YTVaccineListDTO existVaccineItem : existVaccines) { |
|
|
|
|
|
Iterator<YTVaccineListDTO> iterator = ytVaccineListFromApi.iterator(); |
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
|
YTVaccineListDTO vaccineFromApi = iterator.next(); |
|
|
|
|
|
|
|
|
|
|
|
String inoculateDate = vaccineFromApi.getInoculateDate(); |
|
|
|
|
|
if (StringUtils.isBlank(inoculateDate)) { |
|
|
|
|
|
// 没有接种时间,移除
|
|
|
|
|
|
log.warn("【疫苗接种同步】证件号为{}的记录,没有接种时间,移除。", vaccineFromApi.getCardno()); |
|
|
|
|
|
iterator.remove(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
iterator.remove(); |
|
|
// 身份证号和接种时间都一致,移除
|
|
|
} |
|
|
if (vaccineFromApi.getCardno().equals(existVaccineItem.getCardno()) |
|
|
|
|
|
&& inoculateDate.equals(existVaccineItem.getInoculateDate())) { |
|
|
|
|
|
|
|
|
|
|
|
iterator.remove(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (CollectionUtils.isNotEmpty(ytVaccineListFromApi)){ |
|
|
|
|
|
ytVaccineListFromApi.forEach(v -> { |
|
|
|
|
|
resiInfos.forEach(u -> { |
|
|
|
|
|
if (v.getCardno().equals(u.getIdCard())){ |
|
|
|
|
|
IcVaccineEntity e = new IcVaccineEntity(); |
|
|
|
|
|
e.setCustomerId(customerId); |
|
|
|
|
|
e.setName(u.getName()); |
|
|
|
|
|
e.setMobile(u.getMobile()); |
|
|
|
|
|
e.setIdCard(u.getIdCard()); |
|
|
|
|
|
e.setIsResiUser(StringUtils.isBlank(u.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
|
|
e.setUserId(StringUtils.isBlank(u.getUserId()) ? "" : u.getUserId()); |
|
|
|
|
|
e.setUserType("ytPull"); |
|
|
|
|
|
e.setInoculateTime(DateUtils.parseDate(v.getInoculateDate(),DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)); |
|
|
|
|
|
e.setInoculateAddress(v.getLastStationName()); |
|
|
|
|
|
e.setAgencyId(u.getAgencyId()); |
|
|
|
|
|
e.setPids(u.getPids()); |
|
|
|
|
|
entities.add(e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
icVaccineService.insertBatch(entities,NumConstant.ONE_HUNDRED); |
|
|
|
|
|
List<IcVaccineRelationEntity> relationEntities = new ArrayList<>(); |
|
|
|
|
|
entities.forEach(e -> { |
|
|
|
|
|
IcVaccineRelationEntity re = new IcVaccineRelationEntity(); |
|
|
|
|
|
re.setIcVaccineId(e.getId()); |
|
|
|
|
|
re.setPids(e.getPids()); |
|
|
|
|
|
re.setCustomerId(customerId); |
|
|
|
|
|
re.setUserType("ytPull"); |
|
|
|
|
|
re.setAgencyId(e.getAgencyId()); |
|
|
|
|
|
// 拉取居民的疫苗接种信;因为查询的就是组织下的居民,所以都是本地居民。
|
|
|
|
|
|
re.setIsLocalResiUser(NumConstant.ONE_STR); |
|
|
|
|
|
relationEntities.add(re); |
|
|
|
|
|
}); |
|
|
|
|
|
icVaccineRelationService.insertBatch(relationEntities,NumConstant.ONE_HUNDRED); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 转化为entity,插入vaccine和vaccine_relation
|
|
|
|
|
|
List<IcVaccineEntity> entities2Insert = new ArrayList<>(); |
|
|
|
|
|
ytVaccineListFromApi.forEach(v -> { |
|
|
|
|
|
resiInfos.forEach(u -> { |
|
|
|
|
|
if (v.getCardno().equals(u.getIdCard())){ |
|
|
|
|
|
IcVaccineEntity e = new IcVaccineEntity(); |
|
|
|
|
|
e.setCustomerId(customerId); |
|
|
|
|
|
e.setName(u.getName()); |
|
|
|
|
|
e.setMobile(u.getMobile()); |
|
|
|
|
|
e.setIdCard(u.getIdCard()); |
|
|
|
|
|
e.setIsResiUser(StringUtils.isBlank(u.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
|
|
e.setUserId(StringUtils.isBlank(u.getUserId()) ? "" : u.getUserId()); |
|
|
|
|
|
e.setUserType("ytPull"); |
|
|
|
|
|
e.setInoculateTime(DateUtils.parseDate(v.getInoculateDate(),DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)); |
|
|
|
|
|
e.setInoculateAddress(v.getLastStationName()); |
|
|
|
|
|
e.setAgencyId(u.getAgencyId()); |
|
|
|
|
|
e.setPids(u.getPids()); |
|
|
|
|
|
entities2Insert.add(e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
icVaccineService.insertBatch(entities2Insert,NumConstant.ONE_HUNDRED); |
|
|
|
|
|
List<IcVaccineRelationEntity> relationEntities = new ArrayList<>(); |
|
|
|
|
|
entities2Insert.forEach(e -> { |
|
|
|
|
|
IcVaccineRelationEntity re = new IcVaccineRelationEntity(); |
|
|
|
|
|
re.setIcVaccineId(e.getId()); |
|
|
|
|
|
re.setPids(e.getPids()); |
|
|
|
|
|
re.setCustomerId(customerId); |
|
|
|
|
|
re.setUserType("ytPull"); |
|
|
|
|
|
re.setAgencyId(e.getAgencyId()); |
|
|
|
|
|
// 拉取居民的疫苗接种信;因为查询的就是组织下的居民,所以都是本地居民。
|
|
|
|
|
|
re.setIsLocalResiUser(NumConstant.ONE_STR); |
|
|
|
|
|
relationEntities.add(re); |
|
|
|
|
|
}); |
|
|
|
|
|
icVaccineRelationService.insertBatch(relationEntities,NumConstant.ONE_HUNDRED); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -1283,6 +1298,11 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
// 本地数据库中,居民信息
|
|
|
// 本地数据库中,居民信息
|
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
|
|
|
|
|
|
|
|
|
if (currentResiInfo == null) { |
|
|
|
|
|
log.warn("【核酸检测同步任务】同步采样,证件号为{}的居民,竟然没找到居民信息。", cardNo); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
e.setCustomerId(customerId); |
|
|
e.setCustomerId(customerId); |
|
|
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
@ -1324,6 +1344,11 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
// 本地数据库中,居民信息
|
|
|
// 本地数据库中,居民信息
|
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
|
|
|
|
|
|
|
|
|
if (currentResiInfo == null) { |
|
|
|
|
|
log.warn("【核酸检测同步任务】同步检测结果,证件号为{}的居民,竟然没找到居民信息。", cardNo); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
e.setCustomerId(customerId); |
|
|
e.setCustomerId(customerId); |
|
|
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|