Browse Source

Merge branch 'yantai_zhengwu_master'

master
lichao 2 years ago
parent
commit
65723c90b1
  1. 247
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java

247
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java

@ -1,4 +1,9 @@
package com.epmet.service.impl; 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 java.util.Date;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -667,145 +672,157 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao
} }
private void siWang(List<NatUserInfoResultDTO> dbResiList) { private void siWang(List<NatUserInfoResultDTO> dbResiList) {
try { // List<DataSyncRecordDeathEntity> list = new ArrayList<>();
List<DataSyncRecordDeathEntity> list = new ArrayList<>(); for (NatUserInfoResultDTO dbResi : dbResiList) {
for (NatUserInfoResultDTO dbResi : dbResiList) { try {
YtDataSyncResDTO thirdResult = YtHsResUtils.siWang(dbResi.getIdCard(), dbResi.getName()); YtDataSyncResDTO thirdResult = YtHsResUtils.siWang(dbResi.getIdCard(), dbResi.getName());
if (200 != thirdResult.getCode()) { if (200 != thirdResult.getCode()) {
log.warn("canJi 调用蓝图接口失败了 继续处理下一个人"); log.warn("canJi 调用蓝图接口失败了 继续处理下一个人");
continue; continue;
} }
String thirdResultData = thirdResult.getData(); String thirdResultData = thirdResult.getData();
if(StringUtils.isBlank(thirdResultData)){ if(StringUtils.isBlank(thirdResultData)){
continue; continue;
} }
JSONObject thirdResultObject = JSON.parseObject(thirdResultData); JSONObject thirdResultObject = JSON.parseObject(thirdResultData);
LambdaQueryWrapper<DataSyncRecordDeathEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DataSyncRecordDeathEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DataSyncRecordDeathEntity::getIdCard, dbResi.getIdCard()); queryWrapper.eq(DataSyncRecordDeathEntity::getIdCard, dbResi.getIdCard());
//获取数据库里的记录 //获取数据库里的记录
DataSyncRecordDeathDTO dbDeathEntity = dataSyncRecordDeathService.selectOne(queryWrapper); DataSyncRecordDeathDTO dbDeathEntity = dataSyncRecordDeathService.selectOne(queryWrapper);
JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultObject, dbDeathEntity).invokeDeath(); JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultObject, dbDeathEntity).invokeDeath();
if (judgeDealStatus.isStop()) { if (judgeDealStatus.isStop()) {
continue; continue;
} }
DataSyncRecordDeathEntity entity = new DataSyncRecordDeathEntity(); DataSyncRecordDeathEntity entity = new DataSyncRecordDeathEntity();
if (dbDeathEntity != null && StringUtils.isNotBlank(dbDeathEntity.getId())) { if (dbDeathEntity != null && StringUtils.isNotBlank(dbDeathEntity.getId())) {
entity.setId(dbDeathEntity.getId()); entity.setId(dbDeathEntity.getId());
} }
entity.setCustomerId(dbResi.getCustomerId()); entity.setCustomerId(dbResi.getCustomerId());
entity.setAgencyId(dbResi.getAgencyId()); entity.setAgencyId(dbResi.getAgencyId());
entity.setPids(dbResi.getPids()); entity.setPids(dbResi.getPids());
entity.setGridId(dbResi.getGridId()); entity.setGridId(dbResi.getGridId());
entity.setName(dbResi.getName()); entity.setName(dbResi.getName());
entity.setIdCard(dbResi.getIdCard()); entity.setIdCard(dbResi.getIdCard());
entity.setIcResiUserId(dbResi.getUserId()); entity.setIcResiUserId(dbResi.getUserId());
//死亡未获取到数据 //死亡未获取到数据
if (thirdResultObject != null) { if (thirdResultObject != null) {
// entity.setAge(thirdResultObject.getString("AGE")); // entity.setAge(thirdResultObject.getString("AGE"));
// entity.setAddress(thirdResultObject.getString("FAMILY_ADD")); // entity.setAddress(thirdResultObject.getString("FAMILY_ADD"));
entity.setDeathDate(thirdResultObject.getString("issueDate")); entity.setDeathDate(thirdResultObject.getString("issueDate"));
// entity.setCremationTime(thirdResultObject.getString("CREMATION_TIME")); // entity.setCremationTime(thirdResultObject.getString("CREMATION_TIME"));
// entity.setMz(thirdResultObject.getString("FAMILY_ADD")); // entity.setMz(thirdResultObject.getString("FAMILY_ADD"));
// entity.setOrganName(thirdResultObject.getString("CREATE_ORGAN_NAME")); // entity.setOrganName(thirdResultObject.getString("CREATE_ORGAN_NAME"));
// entity.setNation(thirdResultObject.getString("NATION")); // entity.setNation(thirdResultObject.getString("NATION"));
entity.setThirdRecordId(thirdResultObject.getString("certificateID")); entity.setThirdRecordId(thirdResultObject.getString("certificateID"));
JSONArray jsonArray = thirdResultObject.getJSONArray("surface"); JSONArray jsonArray = thirdResultObject.getJSONArray("surface");
if (jsonArray!=null && jsonArray.size()>0){ if (jsonArray!=null && jsonArray.size()>0){
jsonArray.forEach(json->{ jsonArray.forEach(json->{
JSONObject jsonObject = JSON.parseObject(json.toString()); JSONObject jsonObject = JSON.parseObject(json.toString());
if (jsonObject.get("name").equals("户籍地址")){ if (jsonObject.get("name").equals("户籍地址")){
entity.setAddress(jsonObject.get("value").toString()); 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.setDealStatus(NumConstant.ZERO);
entity.setDealResult(StrConstant.EPMETY_STR); entity.setDealResult(StrConstant.EPMETY_STR);
if (judgeDealStatus.isNeedSetStatus) { if (judgeDealStatus.isNeedSetStatus) {
entity.setDealResult(judgeDealStatus.dealResult); entity.setDealResult(judgeDealStatus.dealResult);
entity.setDealStatus(judgeDealStatus.dealStatus); entity.setDealStatus(judgeDealStatus.dealStatus);
}
entity.setUpdatedTime(new Date());
// list.add(entity);
dataSyncRecordDeathService.saveOrUpdate(entity);
} }
if (list.size() == NumConstant.ZERO) { entity.setUpdatedTime(new Date());
return; // 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<NatUserInfoResultDTO> dbResiList) { private void hunYin(List<NatUserInfoResultDTO> dbResiList) {
try {
List<DataSyncRecordMaritalEntity> 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(); // List<DataSyncRecordMaritalEntity> list = new ArrayList<>();
if(StringUtils.isBlank(thirdResultData)){ for (NatUserInfoResultDTO dbResi : dbResiList) {
continue; try {
} YtDataSyncResDTO thirdResult = YtHsResUtils.hunYin(dbResi.getIdCard(), dbResi.getName());
if (thirdResultData.equals("INR:匹配不成功") || thirdResultData.equals("null:null")){ if (200 != thirdResult.getCode()) {
continue; 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); // JSONObject thirdResultObject = JSON.parseObject(thirdResultData);
LambdaQueryWrapper<DataSyncRecordMaritalEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DataSyncRecordMaritalEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DataSyncRecordMaritalEntity::getIdCard, dbResi.getIdCard()); queryWrapper.eq(DataSyncRecordMaritalEntity::getIdCard, dbResi.getIdCard());
//获取数据库里的记录 //获取数据库里的记录
DataSyncRecordMaritalDTO dbMaritaEntity = dataSyncRecordMaritalService.selectOne(queryWrapper); DataSyncRecordMaritalDTO dbMaritaEntity = dataSyncRecordMaritalService.selectOne(queryWrapper);
JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultData, dbMaritaEntity).invokeMarital(); JudgeDealStatus judgeDealStatus = new JudgeDealStatus(thirdResultData, dbMaritaEntity).invokeMarital();
if (judgeDealStatus.isStop()) { if (judgeDealStatus.isStop()) {
continue; continue;
} }
DataSyncRecordMaritalEntity entity = new DataSyncRecordMaritalEntity(); DataSyncRecordMaritalEntity entity = new DataSyncRecordMaritalEntity();
if (dbMaritaEntity != null && StringUtils.isNotBlank(dbMaritaEntity.getId())) { if (dbMaritaEntity != null && StringUtils.isNotBlank(dbMaritaEntity.getId())) {
entity.setId(dbMaritaEntity.getId()); entity.setId(dbMaritaEntity.getId());
} }
entity.setCustomerId(dbResi.getCustomerId()); entity.setCustomerId(dbResi.getCustomerId());
entity.setAgencyId(dbResi.getAgencyId()); entity.setAgencyId(dbResi.getAgencyId());
entity.setPids(dbResi.getPids()); entity.setPids(dbResi.getPids());
entity.setGridId(dbResi.getGridId()); entity.setGridId(dbResi.getGridId());
entity.setName(dbResi.getName()); entity.setName(dbResi.getName());
entity.setIdCard(dbResi.getIdCard()); entity.setIdCard(dbResi.getIdCard());
entity.setIcResiUserId(dbResi.getUserId()); entity.setIcResiUserId(dbResi.getUserId());
//死亡未获取到数据 //死亡未获取到数据
if (thirdResultData != null) { if (thirdResultData != null) {
entity.setMaritalStatusName(thirdResultData); entity.setMaritalStatusName(thirdResultData);
} }
entity.setDealStatus(NumConstant.ZERO); entity.setDealStatus(NumConstant.ZERO);
entity.setDealResult(StrConstant.EPMETY_STR); entity.setDealResult(StrConstant.EPMETY_STR);
if (judgeDealStatus.isNeedSetStatus) { if (judgeDealStatus.isNeedSetStatus) {
entity.setDealResult(judgeDealStatus.dealResult); entity.setDealResult(judgeDealStatus.dealResult);
entity.setDealStatus(judgeDealStatus.dealStatus); entity.setDealStatus(judgeDealStatus.dealStatus);
} }
entity.setUpdatedTime(new Date()); entity.setUpdatedTime(new Date());
// list.add(entity); // 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; return;
} }*/
// dataSyncRecordMaritalService.saveOrUpdateBatch(list, NumConstant.TWO_HUNDRED); // dataSyncRecordMaritalService.saveOrUpdateBatch(list, NumConstant.TWO_HUNDRED);
} catch (Exception e) {
log.error("hunyin exception", e);
}
} }
/** /**

Loading…
Cancel
Save