|
|
@ -60,6 +60,8 @@ import java.util.*; |
|
|
|
import java.util.concurrent.CountDownLatch; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static com.epmet.constant.EpidemicConstant.*; |
|
|
@ -74,6 +76,9 @@ import static com.epmet.constant.EpidemicConstant.*; |
|
|
|
@Service |
|
|
|
public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao, DataSyncConfigEntity> implements DataSyncConfigService { |
|
|
|
|
|
|
|
//2022-01-05 08:53:26
|
|
|
|
public static final Pattern VACCINE_DATE_OF_API_PATTERN = Pattern.compile("^(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}):\\d{2}"); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DataSyncScopeService dataSyncScopeService; |
|
|
|
@Autowired |
|
|
@ -1105,7 +1110,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
// List<Map> vaccineList = JSON.parseArray(json,Map.class);
|
|
|
|
List<Map<String,Object>> vaccineList = yantaiNamedParamLantuJdbcTemplate.queryForList( |
|
|
|
"select data, name, cardno, vaccineCount from t_ymjz_info where cardno in (:idcards)", args); |
|
|
|
List<YTVaccineListDTO> ytVaccineListDTOS = new ArrayList<>(); |
|
|
|
List<YTVaccineListDTO> ytVaccineListFromApi = new ArrayList<>(); |
|
|
|
if (CollectionUtils.isNotEmpty(vaccineList)) { |
|
|
|
vaccineList.forEach(v -> { |
|
|
|
if (v.containsKey("data")){ |
|
|
@ -1116,7 +1121,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
vaccineList1.forEach(v1 -> { |
|
|
|
v1.setCardno(v.get("cardno").toString()); |
|
|
|
}); |
|
|
|
ytVaccineListDTOS.addAll(vaccineList1); |
|
|
|
ytVaccineListFromApi.addAll(vaccineList1); |
|
|
|
} |
|
|
|
|
|
|
|
//Map<String, Object> data = (Map<String, Object>) v.get("data");
|
|
|
@ -1130,18 +1135,36 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
} |
|
|
|
}); |
|
|
|
List<IcVaccineEntity> entities = new ArrayList<>(); |
|
|
|
List<YTVaccineListDTO> existVaccine = icVaccineDao.getExistVaccine(ytVaccineListDTOS); |
|
|
|
if (CollectionUtils.isNotEmpty(existVaccine)){ |
|
|
|
for (YTVaccineListDTO e : existVaccine) { |
|
|
|
for (int i = 0; i < ytVaccineListDTOS.size(); i++) { |
|
|
|
if (ytVaccineListDTOS.get(i).getCardno().equals(e.getCardno()) && ytVaccineListDTOS.get(i).getInoculateDate().equals(e.getInoculateDate())){ |
|
|
|
ytVaccineListDTOS.remove(i); |
|
|
|
|
|
|
|
// 过滤已存在的记录
|
|
|
|
List<YTVaccineListDTO> existVaccines = icVaccineDao.getExistVaccine(ytVaccineListFromApi); |
|
|
|
if (CollectionUtils.isNotEmpty(existVaccines)){ |
|
|
|
for (YTVaccineListDTO existVaccineItem : existVaccines) { |
|
|
|
Iterator<YTVaccineListDTO> iterator = ytVaccineListFromApi.iterator(); |
|
|
|
while (iterator.hasNext()) { |
|
|
|
YTVaccineListDTO vaccineFromApi = iterator.next(); |
|
|
|
Matcher matcher = VACCINE_DATE_OF_API_PATTERN.matcher(vaccineFromApi.getInoculateDate()); |
|
|
|
if (vaccineFromApi.getCardno().equals(existVaccineItem.getCardno()) |
|
|
|
&& matcher.matches() |
|
|
|
&& matcher.group(1).equals(existVaccineItem.getInoculateDate()) |
|
|
|
) { |
|
|
|
iterator.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//for (int i = 0; i < ytVaccineListFromApi.size(); i++) {
|
|
|
|
// String inoculateDateFromApi = ytVaccineListFromApi.get(i).getInoculateDate();
|
|
|
|
// Matcher matcher = VACCINE_DATE_OF_API_PATTERN.matcher(inoculateDateFromApi);
|
|
|
|
// if (ytVaccineListFromApi.get(i).getCardno().equals(e.getCardno())
|
|
|
|
// && matcher.matches()
|
|
|
|
// && matcher.group(1).equals(e.getInoculateDate())){
|
|
|
|
// ytVaccineListFromApi.remove(i);
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(ytVaccineListDTOS)){ |
|
|
|
ytVaccineListDTOS.forEach(v -> { |
|
|
|
if (CollectionUtils.isNotEmpty(ytVaccineListFromApi)){ |
|
|
|
ytVaccineListFromApi.forEach(v -> { |
|
|
|
resiInfos.forEach(u -> { |
|
|
|
if (v.getCardno().equals(u.getIdCard())){ |
|
|
|
IcVaccineEntity e = new IcVaccineEntity(); |
|
|
|