|
|
@ -454,91 +454,107 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
* @author zxc |
|
|
|
* @date 2022/9/27 11:08 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void hsjc(List<NatUserInfoResultDTO> idCards, String customerId, String isSync) { |
|
|
|
try { |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
idCards.forEach(idCard -> { |
|
|
|
// YtHscyResDTO sampleResult = YtHsResUtils.hscy(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE);
|
|
|
|
YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); |
|
|
|
/*Boolean aBoolean = CollectionUtils.isEmpty(sampleResult.getData()) && CollectionUtils.isNotEmpty(natInfoResult.getData()); |
|
|
|
Boolean bBoolean = CollectionUtils.isNotEmpty(sampleResult.getData()) && CollectionUtils.isNotEmpty(natInfoResult.getData());*/ |
|
|
|
/** |
|
|
|
* 1.采样结果 和 检测结果 都不为空,以检测结果为准 |
|
|
|
* 2.采样结果为空,检测结果不为空 |
|
|
|
*/ |
|
|
|
// if (aBoolean || bBoolean) {
|
|
|
|
if (CollectionUtils.isNotEmpty(natInfoResult.getData())) { |
|
|
|
natInfoResult.getData().forEach(natInfo -> { |
|
|
|
YtHscyResDTO sampleResult = YtHsResUtils.hscy(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); |
|
|
|
if (CollectionUtils.isNotEmpty(sampleResult.getData())){ |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
sampleResult.getData().forEach(sampleInfo -> { |
|
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setIsResiUser(StringUtils.isBlank(idCard.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
e.setUserId(idCard.getUserId()); |
|
|
|
e.setMobile(""); |
|
|
|
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); |
|
|
|
e.setName(StringUtils.isNotBlank(natInfo.getName()) ? natInfo.getName() : ""); |
|
|
|
e.setMobile(StringUtils.isNotBlank(natInfo.getTelephone()) ? natInfo.getTelephone() : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(natInfo.getCard_no()) ? natInfo.getCard_no() : ""); |
|
|
|
e.setNatTime(DateUtils.parseDate(natInfo.getTest_time(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setSampleTime(DateUtils.parseDate(natInfo.getSample_time(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
String resultPcr = natInfo.getSample_result_pcr(); |
|
|
|
//检测结果 转换 我们 0:阴性 1:阳性, 他们 :1:阳性,2:阴性
|
|
|
|
e.setNatResult(NumConstant.ZERO_STR); |
|
|
|
if (NumConstant.ONE_STR.equals(resultPcr)) { |
|
|
|
e.setNatResult(NumConstant.ONE_STR); |
|
|
|
} |
|
|
|
e.setNatAddress(natInfo.getSampling_org_pcr()); |
|
|
|
e.setName(StringUtils.isNotBlank(sampleInfo.getName()) ? sampleInfo.getName() : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(sampleInfo.getCard_no()) ? sampleInfo.getCard_no() : ""); |
|
|
|
e.setSampleTime(DateUtils.parseDate(sampleInfo.getCreate_time(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setAgencyId(idCard.getAgencyId()); |
|
|
|
e.setPids(idCard.getPids()); |
|
|
|
e.setAttachmentType(""); |
|
|
|
e.setAttachmentUrl(""); |
|
|
|
entities.add(e); |
|
|
|
}); |
|
|
|
if (CollectionUtils.isNotEmpty(entities)){ |
|
|
|
List<NatUserInfoResultDTO> existSampleInfo = icNatDao.getExistNatInfo(entities); |
|
|
|
sampleAndNat(existSampleInfo,entities,NumConstant.ONE_STR,customerId,isSync); |
|
|
|
} |
|
|
|
/*if (CollectionUtils.isNotEmpty(sampleResult.getData()) && CollectionUtils.isEmpty(natInfoResult.getData())){ |
|
|
|
sampleResult.getData().forEach(sampleInfo -> { |
|
|
|
} |
|
|
|
YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); |
|
|
|
if (CollectionUtils.isNotEmpty(natInfoResult.getData())) { |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
natInfoResult.getData().forEach(natInfo -> { |
|
|
|
IcNatEntity e = new IcNatEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setIsResiUser(StringUtils.isBlank(idCard.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
e.setUserId(idCard.getUserId()); |
|
|
|
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); |
|
|
|
e.setName(StringUtils.isNotBlank(sampleInfo.getName()) ? sampleInfo.getName() : ""); |
|
|
|
e.setMobile(StringUtils.isNotBlank(sampleInfo.get()) ? sampleInfo.getTelephone() : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(sampleInfo.getCard_no()) ? sampleInfo.getCard_no() : ""); |
|
|
|
e.setNatTime(DateUtils.parseDate(sampleInfo.getTest_time(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setSampleTime(DateUtils.parseDate(sampleInfo.getSample_time(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
String resultPcr = sampleInfo.getSample_result_pcr(); |
|
|
|
e.setName(StringUtils.isNotBlank(natInfo.getName()) ? natInfo.getName() : ""); |
|
|
|
e.setMobile(StringUtils.isNotBlank(natInfo.getTelephone()) ? natInfo.getTelephone() : ""); |
|
|
|
e.setIdCard(StringUtils.isNotBlank(natInfo.getCard_no()) ? natInfo.getCard_no() : ""); |
|
|
|
e.setNatTime(DateUtils.parseDate(natInfo.getTest_time(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
e.setSampleTime(DateUtils.parseDate(natInfo.getSample_time(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
String resultPcr = natInfo.getSample_result_pcr(); |
|
|
|
//检测结果 转换 我们 0:阴性 1:阳性, 他们 :1:阳性,2:阴性
|
|
|
|
e.setNatResult(NumConstant.ZERO_STR); |
|
|
|
if (NumConstant.ONE_STR.equals(resultPcr)) { |
|
|
|
e.setNatResult(NumConstant.ONE_STR); |
|
|
|
} |
|
|
|
e.setNatAddress(sampleInfo.getSampling_org_pcr()); |
|
|
|
e.setNatAddress(natInfo.getSampling_org_pcr()); |
|
|
|
e.setAgencyId(idCard.getAgencyId()); |
|
|
|
e.setPids(idCard.getPids()); |
|
|
|
e.setAttachmentType(""); |
|
|
|
e.setAttachmentUrl(""); |
|
|
|
entities.add(e); |
|
|
|
}); |
|
|
|
} |
|
|
|
});*/ |
|
|
|
if (CollectionUtils.isNotEmpty(entities)) { |
|
|
|
List<NatUserInfoResultDTO> existNatInfos = icNatDao.getExistNatInfo(entities); |
|
|
|
entities.forEach(e -> existNatInfos.stream().filter(i -> i.getUserId().equals(e.getUserId()) && i.getIdCard().equals(e.getIdCard())).forEach(i -> e.setExistStatus(true))); |
|
|
|
sampleAndNat(existNatInfos,entities,NumConstant.TWO_STR,customerId,isSync); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("hsjc exception", e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 处理采样和检测结果 |
|
|
|
* @param existInfo 库里存在的【ic_nat】 |
|
|
|
* @param entities 所有的 |
|
|
|
* @param type 1:采样结果;2:检测结果 |
|
|
|
* @param isSync 1:页面调用同步;2:定时任务 |
|
|
|
* @author zxc |
|
|
|
* @date 2022/10/18 09:08 |
|
|
|
*/ |
|
|
|
private void sampleAndNat(List<NatUserInfoResultDTO> existInfo, List<IcNatEntity> entities, String type, String customerId, String isSync){ |
|
|
|
/** |
|
|
|
* 采样结果不为空 |
|
|
|
* 数据库采样时间+idCard+userId 存在的 不做操作 |
|
|
|
* 数据库采样时间+idCard+userId 不存在的 新增 |
|
|
|
* |
|
|
|
* 检测结果不为空 |
|
|
|
* 数据库采样时间+idCard+userId 存在的 做更新 |
|
|
|
* 数据库采样时间+idCard+userId 不存在的 新增 |
|
|
|
*/ |
|
|
|
entities.forEach(e -> existInfo.stream().filter(i -> i.getUserId().equals(e.getUserId()) && i.getIdCard().equals(e.getIdCard())).forEach(i -> e.setExistStatus(true))); |
|
|
|
Map<Boolean, List<IcNatEntity>> groupByStatus = entities.stream().collect(Collectors.groupingBy(IcNatEntity::getExistStatus)); |
|
|
|
if (CollectionUtils.isNotEmpty(groupByStatus.get(false))) { |
|
|
|
for (List<IcNatEntity> icNatEntities : ListUtils.partition(groupByStatus.get(false), NumConstant.FIVE_HUNDRED)) { |
|
|
|
// 主表新增
|
|
|
|
icNatService.insertBatch(icNatEntities); |
|
|
|
// 组织关系表
|
|
|
|
List<IcNatRelationEntity> relationEntities = new ArrayList<>(); |
|
|
|
icNatEntities.forEach(ne -> { |
|
|
|
// 不是居民的先不加关系表吧
|
|
|
|
if (ne.getIsResiUser().equals(NumConstant.ONE_STR)) { |
|
|
|
IcNatRelationEntity e = new IcNatRelationEntity(); |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setAgencyId(ne.getAgencyId()); |
|
|
|
e.setPids(ne.getPids()); |
|
|
|
e.setIcNatId(ne.getId()); |
|
|
|
e.setUserType("sync"); |
|
|
|
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); |
|
|
|
relationEntities.add(e); |
|
|
|
} |
|
|
|
}); |
|
|
@ -547,13 +563,13 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (NumConstant.TWO_STR.equals(type)){ |
|
|
|
if (CollectionUtils.isNotEmpty(groupByStatus.get(true))){ |
|
|
|
for (List<IcNatEntity> icNatEntities : ListUtils.partition(groupByStatus.get(true), NumConstant.ONE_HUNDRED)) { |
|
|
|
icNatService.updateBatchNat(icNatEntities); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("hsjc exception", e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private class JudgeDealStatus { |
|
|
|