|
|
@ -41,6 +41,7 @@ import org.apache.commons.collections4.ListUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
@ -76,6 +77,9 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
@Autowired |
|
|
|
private ExecutorService executorService; |
|
|
|
|
|
|
|
@Resource(name = "yantaiNamedParamLantuJdbcTemplate") |
|
|
|
private NamedParameterJdbcTemplate yantaiNamedParamLantuJdbcTemplate; |
|
|
|
|
|
|
|
@Resource(name = "yantaiLantuJdbcTemplate") |
|
|
|
private JdbcTemplate yantaiJdbcTemplate; |
|
|
|
|
|
|
@ -786,35 +790,43 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
public void yantaiHsjcByDbView(List<NatUserInfoResultDTO> resiInfos, String customerId, String isSync) { |
|
|
|
List<List<NatUserInfoResultDTO>> resiInfobatchs = ListUtils.partition(resiInfos, 50); |
|
|
|
for (List<NatUserInfoResultDTO> resibatch : resiInfobatchs) { |
|
|
|
// 50个一批,来处理他们的核酸信息,太多怕给数据库查崩了。
|
|
|
|
yantaiHsjcByDbViewBatch(resibatch, customerId, isSync); |
|
|
|
// n个一批,来处理他们的核酸信息,太多怕给数据库查崩了。
|
|
|
|
try { |
|
|
|
yantaiHsjcByDbViewPartition(resibatch, customerId, isSync); |
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
log.error("【更新核酸检测信息(from 兰图)】失败,信息:{}", errorMsg); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 50个一批,来处理他们的核酸信息,太多怕给数据库查崩了。 |
|
|
|
* n个一批,来处理他们的核酸信息,太多怕给数据库查崩了。 |
|
|
|
* @param resiInfos |
|
|
|
* @param customerId |
|
|
|
* @param isSync |
|
|
|
*/ |
|
|
|
public void yantaiHsjcByDbViewBatch(List<NatUserInfoResultDTO> resiInfos, String customerId, String isSync) { |
|
|
|
public void yantaiHsjcByDbViewPartition(List<NatUserInfoResultDTO> resiInfos, String customerId, String isSync) { |
|
|
|
// 将居民信息转化为<idCard,resiInfo>的map
|
|
|
|
Map<String, NatUserInfoResultDTO> idCardAndResiInfo = resiInfos.stream().collect(Collectors.toMap(resi -> resi.getIdCard(), Function.identity())); |
|
|
|
Set<String> idCards = idCardAndResiInfo.keySet();//resiInfos.stream().map(resi -> resi.getIdCard()).collect(Collectors.toList());
|
|
|
|
// String idCardsStr = "''" + String.join("','", idCards) + "''";
|
|
|
|
List<String> idCards = new ArrayList<>(idCardAndResiInfo.keySet()); |
|
|
|
// 1.获取核酸采样信息
|
|
|
|
String sql = "select id, name,card_no, create_time, realname from hscyxxb where card_no in (:idCards) order by create_time desc"; |
|
|
|
HashMap<String, Object> args = new HashMap<>(); |
|
|
|
args.put("idCards", idCards); |
|
|
|
Map<String, Object> args = new HashMap<>(); |
|
|
|
args.put("idcards", idCards); |
|
|
|
|
|
|
|
log.info("【更新核酸检测信息(from 兰图)】本批次身份证号为:{}", String.join(",", idCards)); |
|
|
|
|
|
|
|
// 2.=====================核酸采样=========================
|
|
|
|
// 这一批居民的核酸采样列表
|
|
|
|
List<Map<String, Object>> hscyList = yantaiJdbcTemplate.queryForList(sql, args); |
|
|
|
List<Map<String, Object>> hscyList = yantaiNamedParamLantuJdbcTemplate.queryForList( |
|
|
|
"select id, name,card_no, create_time, realname from hscyxxb where card_no in (:idcards) order by create_time desc", args); |
|
|
|
if (CollectionUtils.isNotEmpty(hscyList)) { |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
hscyList.forEach(sampleInfo -> { |
|
|
|
hscyList.forEach(resiHscyInfo -> { |
|
|
|
// 从视图中获取到的核酸采样相关信息
|
|
|
|
String name = (String) sampleInfo.get("name"); |
|
|
|
String cardNo = (String) sampleInfo.get("card_no"); |
|
|
|
Date createTime = (Date) sampleInfo.get("create_time"); |
|
|
|
String name = (String) resiHscyInfo.get("name"); |
|
|
|
String cardNo = (String) resiHscyInfo.get("card_no"); |
|
|
|
String createTime = (String) resiHscyInfo.get("create_time"); |
|
|
|
|
|
|
|
// 本地数据库中,居民信息
|
|
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
@ -827,8 +839,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); |
|
|
|
e.setName(StringUtils.isNotBlank(name) ? name : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(cardNo) ? cardNo : ""); |
|
|
|
e.setSampleTime(createTime); |
|
|
|
// e.setSampleTime(DateUtils.parseDate(createTime, DateUtils.DATE_TIME_PATTERN));
|
|
|
|
e.setSampleTime(DateUtils.parseDate(createTime, DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setAgencyId(currentResiInfo.getAgencyId()); |
|
|
|
e.setPids(currentResiInfo.getPids()); |
|
|
|
e.setAttachmentType(""); |
|
|
@ -840,5 +851,54 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
sampleAndNat(existSampleInfo,entities,NumConstant.ONE_STR,customerId,isSync); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 2.=====================核酸采样=========================
|
|
|
|
|
|
|
|
// 这一批居民的核酸采样列表
|
|
|
|
List<Map<String, Object>> hsjcResultList = yantaiNamedParamLantuJdbcTemplate.queryForList( |
|
|
|
"select name, telephone, card_no, test_time, SAMPLE_TIME, SAMPLE_RESULT_PCR, SAMPLING_ORG_PCR from hsjcxxb where card_no in (:idcards)", args); |
|
|
|
if (CollectionUtils.isNotEmpty(hsjcResultList)) { |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
hsjcResultList.forEach(natResult -> { |
|
|
|
// 从视图中获取到的核酸采样相关信息
|
|
|
|
String name = (String) natResult.get("name"); |
|
|
|
String cardNo = (String) natResult.get("card_no"); |
|
|
|
String testTime = (String) natResult.get("test_time"); |
|
|
|
String telephone = (String) natResult.get("telephone"); |
|
|
|
String sampleTime = (String) natResult.get("SAMPLE_TIME"); |
|
|
|
String sampleResultPcr = (String) natResult.get("SAMPLE_RESULT_PCR"); |
|
|
|
String samplingOrgPcr = (String) natResult.get("SAMPLING_ORG_PCR"); |
|
|
|
|
|
|
|
// 本地数据库中,居民信息
|
|
|
|
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo); |
|
|
|
|
|
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
e.setUserId(currentResiInfo.getUserId()); |
|
|
|
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); |
|
|
|
e.setName(StringUtils.isNotBlank(name) ? name : ""); |
|
|
|
e.setMobile(StringUtils.isNotBlank(telephone) ? telephone : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(cardNo) ? cardNo : ""); |
|
|
|
e.setNatTime(DateUtils.parseDate(testTime, DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setSampleTime(DateUtils.parseDate(sampleTime, DateUtils.DATE_TIME_PATTERN)); |
|
|
|
String resultPcr = sampleResultPcr; |
|
|
|
//检测结果 转换 我们 0:阴性 1:阳性, 他们 :1:阳性,2:阴性
|
|
|
|
e.setNatResult(NumConstant.ZERO_STR); |
|
|
|
if (NumConstant.ONE_STR.equals(resultPcr)) { |
|
|
|
e.setNatResult(NumConstant.ONE_STR); |
|
|
|
} |
|
|
|
e.setNatAddress(samplingOrgPcr); |
|
|
|
e.setAgencyId(currentResiInfo.getAgencyId()); |
|
|
|
e.setPids(currentResiInfo.getPids()); |
|
|
|
e.setAttachmentType(""); |
|
|
|
e.setAttachmentUrl(""); |
|
|
|
entities.add(e); |
|
|
|
}); |
|
|
|
if (CollectionUtils.isNotEmpty(entities)) { |
|
|
|
List<NatUserInfoResultDTO> existNatInfos = icNatDao.getExistNatInfo(entities); |
|
|
|
sampleAndNat(existNatInfos,entities,NumConstant.TWO_STR,customerId,isSync); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|