From 4cf58f4ae6ce05233f391f0b267784a5b4f359fa Mon Sep 17 00:00:00 2001 From: lichao <326994889@qq.com> Date: Wed, 24 May 2023 13:33:25 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=AE=8C=E5=96=84=E6=AD=BB?= =?UTF-8?q?=E4=BA=A1=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DataSyncConfigServiceImpl.java | 247 ++++++++++-------- 1 file changed, 132 insertions(+), 115 deletions(-) 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 ab13fec3d5..188addebb6 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 @@ -1,4 +1,9 @@ package com.epmet.service.impl; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.Period; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.Date; import com.alibaba.fastjson.JSON; @@ -667,145 +672,157 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl dbResiList) { - try { - List list = new ArrayList<>(); - for (NatUserInfoResultDTO dbResi : dbResiList) { - YtDataSyncResDTO thirdResult = YtHsResUtils.siWang(dbResi.getIdCard(), dbResi.getName()); - if (200 != thirdResult.getCode()) { - log.warn("canJi 调用蓝图接口失败了 继续处理下一个人"); - continue; - } +// List list = new ArrayList<>(); + for (NatUserInfoResultDTO dbResi : dbResiList) { + try { + YtDataSyncResDTO thirdResult = YtHsResUtils.siWang(dbResi.getIdCard(), dbResi.getName()); + if (200 != thirdResult.getCode()) { + log.warn("canJi 调用蓝图接口失败了 继续处理下一个人"); + continue; + } - String thirdResultData = thirdResult.getData(); - if(StringUtils.isBlank(thirdResultData)){ - continue; - } - JSONObject thirdResultObject = JSON.parseObject(thirdResultData); + String thirdResultData = thirdResult.getData(); + if(StringUtils.isBlank(thirdResultData)){ + continue; + } + JSONObject thirdResultObject = JSON.parseObject(thirdResultData); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(DataSyncRecordDeathEntity::getIdCard, dbResi.getIdCard()); - //获取数据库里的记录 - DataSyncRecordDeathDTO dbDeathEntity = dataSyncRecordDeathService.selectOne(queryWrapper); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(DataSyncRecordDeathEntity::getIdCard, dbResi.getIdCard()); + //获取数据库里的记录 + DataSyncRecordDeathDTO dbDeathEntity = dataSyncRecordDeathService.selectOne(queryWrapper); - JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultObject, dbDeathEntity).invokeDeath(); - if (judgeDealStatus.isStop()) { - continue; - } + JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultObject, dbDeathEntity).invokeDeath(); + if (judgeDealStatus.isStop()) { + continue; + } - DataSyncRecordDeathEntity entity = new DataSyncRecordDeathEntity(); - if (dbDeathEntity != null && StringUtils.isNotBlank(dbDeathEntity.getId())) { - entity.setId(dbDeathEntity.getId()); - } - entity.setCustomerId(dbResi.getCustomerId()); - entity.setAgencyId(dbResi.getAgencyId()); - entity.setPids(dbResi.getPids()); - entity.setGridId(dbResi.getGridId()); - entity.setName(dbResi.getName()); - entity.setIdCard(dbResi.getIdCard()); - entity.setIcResiUserId(dbResi.getUserId()); - //死亡未获取到数据 - if (thirdResultObject != null) { -// entity.setAge(thirdResultObject.getString("AGE")); -// entity.setAddress(thirdResultObject.getString("FAMILY_ADD")); - entity.setDeathDate(thirdResultObject.getString("issueDate")); -// entity.setCremationTime(thirdResultObject.getString("CREMATION_TIME")); -// entity.setMz(thirdResultObject.getString("FAMILY_ADD")); -// entity.setOrganName(thirdResultObject.getString("CREATE_ORGAN_NAME")); -// entity.setNation(thirdResultObject.getString("NATION")); - entity.setThirdRecordId(thirdResultObject.getString("certificateID")); - JSONArray jsonArray = thirdResultObject.getJSONArray("surface"); - if (jsonArray!=null && jsonArray.size()>0){ - jsonArray.forEach(json->{ - JSONObject jsonObject = JSON.parseObject(json.toString()); - if (jsonObject.get("name").equals("户籍地址")){ - entity.setAddress(jsonObject.get("value").toString()); + DataSyncRecordDeathEntity entity = new DataSyncRecordDeathEntity(); + if (dbDeathEntity != null && StringUtils.isNotBlank(dbDeathEntity.getId())) { + entity.setId(dbDeathEntity.getId()); + } + entity.setCustomerId(dbResi.getCustomerId()); + entity.setAgencyId(dbResi.getAgencyId()); + entity.setPids(dbResi.getPids()); + entity.setGridId(dbResi.getGridId()); + entity.setName(dbResi.getName()); + entity.setIdCard(dbResi.getIdCard()); + entity.setIcResiUserId(dbResi.getUserId()); + //死亡未获取到数据 + if (thirdResultObject != null) { + // entity.setAge(thirdResultObject.getString("AGE")); + // entity.setAddress(thirdResultObject.getString("FAMILY_ADD")); + entity.setDeathDate(thirdResultObject.getString("issueDate")); + // entity.setCremationTime(thirdResultObject.getString("CREMATION_TIME")); + // entity.setMz(thirdResultObject.getString("FAMILY_ADD")); + // entity.setOrganName(thirdResultObject.getString("CREATE_ORGAN_NAME")); + // entity.setNation(thirdResultObject.getString("NATION")); + entity.setThirdRecordId(thirdResultObject.getString("certificateID")); + JSONArray jsonArray = thirdResultObject.getJSONArray("surface"); + if (jsonArray!=null && jsonArray.size()>0){ + jsonArray.forEach(json->{ + JSONObject jsonObject = JSON.parseObject(json.toString()); + if (jsonObject.get("name").equals("户籍地址")){ + entity.setAddress(jsonObject.get("value").toString()); + } + if (jsonObject.get("name").equals("年龄")){ + if (jsonObject.get("value")!=null && !jsonObject.get("value").equals("")){ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); + LocalDateTime localBirthDate = LocalDateTime.parse(jsonObject.get("value").toString(), formatter); + LocalDateTime dateTime = LocalDateTime.parse(thirdResultObject.getString("issueDate"), formatter); + LocalDate localDate = dateTime.toLocalDate(); + Period period = Period.between(localBirthDate.toLocalDate(), localDate); + entity.setAge(String.valueOf(period.getYears())); } - }); + } + }); - } } + } - entity.setDealStatus(NumConstant.ZERO); - entity.setDealResult(StrConstant.EPMETY_STR); - if (judgeDealStatus.isNeedSetStatus) { - entity.setDealResult(judgeDealStatus.dealResult); - entity.setDealStatus(judgeDealStatus.dealStatus); - } - entity.setUpdatedTime(new Date()); -// list.add(entity); - dataSyncRecordDeathService.saveOrUpdate(entity); + entity.setDealStatus(NumConstant.ZERO); + entity.setDealResult(StrConstant.EPMETY_STR); + if (judgeDealStatus.isNeedSetStatus) { + entity.setDealResult(judgeDealStatus.dealResult); + entity.setDealStatus(judgeDealStatus.dealStatus); } - if (list.size() == NumConstant.ZERO) { - return; + entity.setUpdatedTime(new Date()); + // list.add(entity); + dataSyncRecordDeathService.saveOrUpdate(entity); + } catch (Exception e) { + log.error("siwang exception", e); } -// dataSyncRecordDeathService.saveOrUpdateBatch(list, NumConstant.TWO_HUNDRED); - } catch (Exception e) { - log.error("siwang exception", e); } + /* if (list.size() == NumConstant.ZERO) { + return; + }*/ + // dataSyncRecordDeathService.saveOrUpdateBatch(list, NumConstant.TWO_HUNDRED); + } private void hunYin(List dbResiList) { - try { - List list = new ArrayList<>(); - for (NatUserInfoResultDTO dbResi : dbResiList) { - YtDataSyncResDTO thirdResult = YtHsResUtils.hunYin(dbResi.getIdCard(), dbResi.getName()); - if (200 != thirdResult.getCode()) { - log.warn("hunyin 调用蓝图接口失败了 继续处理下一个人"); - continue; - } - String thirdResultData = thirdResult.getData(); - if(StringUtils.isBlank(thirdResultData)){ - continue; - } - if (thirdResultData.equals("INR:匹配不成功") || thirdResultData.equals("null:null")){ - continue; - } + // List list = new ArrayList<>(); + for (NatUserInfoResultDTO dbResi : dbResiList) { + try { + YtDataSyncResDTO thirdResult = YtHsResUtils.hunYin(dbResi.getIdCard(), dbResi.getName()); + if (200 != thirdResult.getCode()) { + log.warn("hunyin 调用蓝图接口失败了 继续处理下一个人"); + continue; + } + + String thirdResultData = thirdResult.getData(); + if(StringUtils.isBlank(thirdResultData)){ + continue; + } + if (thirdResultData.equals("INR:匹配不成功") || thirdResultData.equals("null:null")){ + continue; + } // JSONObject thirdResultObject = JSON.parseObject(thirdResultData); - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(DataSyncRecordMaritalEntity::getIdCard, dbResi.getIdCard()); - //获取数据库里的记录 - DataSyncRecordMaritalDTO dbMaritaEntity = dataSyncRecordMaritalService.selectOne(queryWrapper); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(DataSyncRecordMaritalEntity::getIdCard, dbResi.getIdCard()); + //获取数据库里的记录 + DataSyncRecordMaritalDTO dbMaritaEntity = dataSyncRecordMaritalService.selectOne(queryWrapper); - JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultData, dbMaritaEntity).invokeMarital(); - if (judgeDealStatus.isStop()) { - continue; - } + JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultData, dbMaritaEntity).invokeMarital(); + if (judgeDealStatus.isStop()) { + continue; + } - DataSyncRecordMaritalEntity entity = new DataSyncRecordMaritalEntity(); - if (dbMaritaEntity != null && StringUtils.isNotBlank(dbMaritaEntity.getId())) { - entity.setId(dbMaritaEntity.getId()); - } - entity.setCustomerId(dbResi.getCustomerId()); - entity.setAgencyId(dbResi.getAgencyId()); - entity.setPids(dbResi.getPids()); - entity.setGridId(dbResi.getGridId()); - entity.setName(dbResi.getName()); - entity.setIdCard(dbResi.getIdCard()); - entity.setIcResiUserId(dbResi.getUserId()); - //死亡未获取到数据 - if (thirdResultData != null) { - entity.setMaritalStatusName(thirdResultData); - } + DataSyncRecordMaritalEntity entity = new DataSyncRecordMaritalEntity(); + if (dbMaritaEntity != null && StringUtils.isNotBlank(dbMaritaEntity.getId())) { + entity.setId(dbMaritaEntity.getId()); + } + entity.setCustomerId(dbResi.getCustomerId()); + entity.setAgencyId(dbResi.getAgencyId()); + entity.setPids(dbResi.getPids()); + entity.setGridId(dbResi.getGridId()); + entity.setName(dbResi.getName()); + entity.setIdCard(dbResi.getIdCard()); + entity.setIcResiUserId(dbResi.getUserId()); + //死亡未获取到数据 + if (thirdResultData != null) { + entity.setMaritalStatusName(thirdResultData); + } - entity.setDealStatus(NumConstant.ZERO); - entity.setDealResult(StrConstant.EPMETY_STR); - if (judgeDealStatus.isNeedSetStatus) { - entity.setDealResult(judgeDealStatus.dealResult); - entity.setDealStatus(judgeDealStatus.dealStatus); - } - entity.setUpdatedTime(new Date()); + entity.setDealStatus(NumConstant.ZERO); + entity.setDealResult(StrConstant.EPMETY_STR); + if (judgeDealStatus.isNeedSetStatus) { + entity.setDealResult(judgeDealStatus.dealResult); + entity.setDealStatus(judgeDealStatus.dealStatus); + } + entity.setUpdatedTime(new Date()); // list.add(entity); - dataSyncRecordMaritalService.saveOrUpdate(entity); + dataSyncRecordMaritalService.saveOrUpdate(entity); + } catch (Exception e) { + log.error("hunyin exception", e); } - if (list.size() == NumConstant.ZERO) { + } + /* if (list.size() == NumConstant.ZERO) { return; - } + }*/ // dataSyncRecordMaritalService.saveOrUpdateBatch(list, NumConstant.TWO_HUNDRED); - } catch (Exception e) { - log.error("hunyin exception", e); - } } /**