diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java index 469465901e..d165bfaa51 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java @@ -222,7 +222,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl idCards, String customerId) { + public void hsjc(List idCards, String customerId, String isSync) { try { List entities = new ArrayList<>(); idCards.forEach(idCard -> { - YtHscyResDTO sampleResult = YtHsResUtils.hscy(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); +// 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()); + /*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 (aBoolean || bBoolean) { + if (CollectionUtils.isNotEmpty(natInfoResult.getData())) { 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("sync"); + 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() : ""); @@ -479,7 +481,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl { + /*if (CollectionUtils.isNotEmpty(sampleResult.getData()) && CollectionUtils.isEmpty(natInfoResult.getData())){ + 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.setUserType("sync"); + e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); e.setName(StringUtils.isNotBlank(sampleInfo.getName()) ? sampleInfo.getName() : ""); - e.setMobile(StringUtils.isNotBlank(sampleInfo.getTelephone()) ? sampleInfo.getTelephone() : ""); + 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)); @@ -514,37 +516,38 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl 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))); - Map> groupByStatus = entities.stream().collect(Collectors.groupingBy(IcNatEntity::getExistStatus)); - if (CollectionUtils.isNotEmpty(groupByStatus.get(false))) { - for (List icNatEntities : ListUtils.partition(groupByStatus.get(false), NumConstant.FIVE_HUNDRED)) { - icNatService.insertBatch(icNatEntities); - //组织关系表 - List 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"); - relationEntities.add(e); + });*/ + if (CollectionUtils.isNotEmpty(entities)) { + List 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))); + Map> groupByStatus = entities.stream().collect(Collectors.groupingBy(IcNatEntity::getExistStatus)); + if (CollectionUtils.isNotEmpty(groupByStatus.get(false))) { + for (List icNatEntities : ListUtils.partition(groupByStatus.get(false), NumConstant.FIVE_HUNDRED)) { + icNatService.insertBatch(icNatEntities); + //组织关系表 + List 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"); + relationEntities.add(e); + } + }); + if (CollectionUtils.isNotEmpty(relationEntities)) { + icNatRelationService.insertBatch(relationEntities); } - }); - if (CollectionUtils.isNotEmpty(relationEntities)) { - icNatRelationService.insertBatch(relationEntities); } } - } - } + } + }); } catch (Exception e) { log.error("hsjc exception", e); }