|
|
@ -11,7 +11,6 @@ import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|
|
|
import com.epmet.commons.tools.dto.result.YtDataSyncResDTO; |
|
|
|
import com.epmet.commons.tools.dto.result.YtHsjcResDTO; |
|
|
|
import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
@ -24,6 +23,7 @@ import com.epmet.commons.tools.utils.YtHsResUtils; |
|
|
|
import com.epmet.dao.DataSyncConfigDao; |
|
|
|
import com.epmet.dao.IcNatDao; |
|
|
|
import com.epmet.dto.DataSyncConfigDTO; |
|
|
|
import com.epmet.dto.DataSyncRecordDeathDTO; |
|
|
|
import com.epmet.dto.DataSyncRecordDisabilityDTO; |
|
|
|
import com.epmet.dto.form.ConfigSwitchFormDTO; |
|
|
|
import com.epmet.dto.form.DataSyncTaskParam; |
|
|
@ -216,20 +216,22 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
do { |
|
|
|
switch (anEnum) { |
|
|
|
case HE_SUAN: |
|
|
|
dbResiList = getNatUserInfoFromDB(formDTO, anEnum, pageNo, pageSize); |
|
|
|
//查询正常状态的居民
|
|
|
|
dbResiList = getNatUserInfoFromDb(formDTO, anEnum, pageNo, pageSize); |
|
|
|
if (CollectionUtils.isEmpty(dbResiList)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
hsjc(dbResiList, config.getCustomerId()); |
|
|
|
break; |
|
|
|
case CAN_JI: |
|
|
|
//查询正常状态的居民 并回显 残疾状态
|
|
|
|
formDTO.setCategoryColumn("IS_CJ"); |
|
|
|
dbResiList = getNatUserInfoFromDB(formDTO, anEnum, pageNo, pageSize); |
|
|
|
dbResiList = getNatUserInfoFromDb(formDTO, anEnum, pageNo, pageSize); |
|
|
|
canJi(dbResiList); |
|
|
|
break; |
|
|
|
case SI_WANG: |
|
|
|
formDTO.setResiSubStatus(IcResiUserSubStatusEnum.DIED.getSubStatus()); |
|
|
|
dbResiList = getNatUserInfoFromDB(formDTO, anEnum, pageNo, pageSize); |
|
|
|
//查询正常状态的居民
|
|
|
|
dbResiList = getNatUserInfoFromDb(formDTO, anEnum, pageNo, pageSize); |
|
|
|
siWang(dbResiList); |
|
|
|
break; |
|
|
|
default: |
|
|
@ -243,7 +245,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void siWang(List<NatUserInfoResultDTO> dbResiList) { |
|
|
|
List<DataSyncRecordDisabilityEntity> list = new ArrayList<>(); |
|
|
|
List<DataSyncRecordDeathEntity> list = new ArrayList<>(); |
|
|
|
for (NatUserInfoResultDTO dbResi : dbResiList) { |
|
|
|
YtDataSyncResDTO thirdResult = YtHsResUtils.siWang(dbResi.getIdCard(), dbResi.getName()); |
|
|
|
if (200 != thirdResult.getCode()) { |
|
|
@ -271,74 +273,50 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
String thirdResultData = thirdResult.getData(); |
|
|
|
JSONObject thirdResultObject = JSON.parseObject(thirdResultData); |
|
|
|
|
|
|
|
LambdaQueryWrapper<DataSyncRecordDisabilityEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(DataSyncRecordDisabilityEntity::getIdCard, dbResi.getIdCard()); |
|
|
|
LambdaQueryWrapper<DataSyncRecordDeathEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(DataSyncRecordDeathEntity::getIdCard, dbResi.getIdCard()); |
|
|
|
//获取数据库里的记录
|
|
|
|
DataSyncRecordDisabilityDTO dbDisablityEntity = dataSyncRecordDisabilityService.selectOne(queryWrapper); |
|
|
|
DataSyncRecordDeathDTO dbDeathEntity = dataSyncRecordDeathService.selectOne(queryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
DataSyncRecordDisabilityEntity entity = new DataSyncRecordDisabilityEntity(); |
|
|
|
entity.setId(dbDisablityEntity.getId()); |
|
|
|
//居民库里 是否是残疾
|
|
|
|
String categoryColumn = dbResi.getCategoryColumn(); |
|
|
|
|
|
|
|
|
|
|
|
JudgeDealStatus judgeDealStatus = null; |
|
|
|
//居民是残疾
|
|
|
|
if (NumConstant.ONE_STR.equals(categoryColumn)) { |
|
|
|
// 第三方返回了该人的 残疾记录 说明和居民库的状态一致 只需要处理 同步记录中的数据即可
|
|
|
|
if (thirdResultObject != null) { |
|
|
|
//todo 联调时看一下 为什么db == null 总是true
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).invoke(); |
|
|
|
if (judgeDealStatus.isStop()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} else { |
|
|
|
//没有返回该人是残疾的数据 说明需要处理居民库的数据
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).notSame(); |
|
|
|
} |
|
|
|
} else if (NumConstant.ZERO_STR.equals(categoryColumn)) { |
|
|
|
//居民不是残疾
|
|
|
|
|
|
|
|
// 第三方没有返回了该人的 残疾记录 说明和居民库的状态一致 只需要处理 同步记录中的数据即可
|
|
|
|
if (thirdResultObject == null) { |
|
|
|
//todo 联调时看一下 为什么db == null 总是true
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).invoke(); |
|
|
|
if (judgeDealStatus.isStop()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
//蓝图返回该人是残疾的数据 说明需要处理居民库的数据
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).notSame(); |
|
|
|
} |
|
|
|
JudgeDealStatus judgeDealStatus= new JudgeDealStatus(thirdResultObject,dbDeathEntity).invokeDeath(); |
|
|
|
if (judgeDealStatus.isStop()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
DataSyncRecordDeathEntity entity = new DataSyncRecordDeathEntity(); |
|
|
|
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(thirdResultObject.getString("citizenId")); |
|
|
|
entity.setMobile(thirdResultObject.getString("phoneNo")); |
|
|
|
entity.setIdCard(dbResi.getIdCard()); |
|
|
|
entity.setIcResiUserId(dbResi.getUserId()); |
|
|
|
entity.setCardNum(thirdResultObject.getString("cardNum")); |
|
|
|
//todo 残疾等级 从字典获取
|
|
|
|
entity.setCjzk(thirdResultObject.getString("idtLevelName")); |
|
|
|
entity.setCjlb(thirdResultObject.getString("idtKindName")); |
|
|
|
entity.setEduLevel(thirdResultObject.getString("eduLevelName")); |
|
|
|
entity.setMaritalStatus(thirdResultObject.getString("marriagerName")); |
|
|
|
entity.setGuardian(thirdResultObject.getString("guardian")); |
|
|
|
entity.setGuardianPhone(thirdResultObject.getString("guardianPhone")); |
|
|
|
|
|
|
|
entity.setAge(thirdResultObject.getString("AGE")); |
|
|
|
entity.setAddress(thirdResultObject.getString("FAMILY_ADD")); |
|
|
|
entity.setDeathDate(thirdResultObject.getString("DEATH_DATE")); |
|
|
|
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("RECORD_ID")); |
|
|
|
entity.setDealStatus(NumConstant.ZERO); |
|
|
|
entity.setDealRedult(StrConstant.EPMETY_STR); |
|
|
|
entity.setDealResult(StrConstant.EPMETY_STR); |
|
|
|
if (judgeDealStatus.isNeedSetStatus) { |
|
|
|
entity.setDealRedult(judgeDealStatus.dealResult); |
|
|
|
entity.setDealResult(judgeDealStatus.dealResult); |
|
|
|
entity.setDealStatus(judgeDealStatus.dealStatus); |
|
|
|
} |
|
|
|
list.add(entity); |
|
|
|
} |
|
|
|
dataSyncRecordDisabilityService.saveOrUpdateBatch(list); |
|
|
|
if (list.size()==NumConstant.ZERO){ |
|
|
|
return; |
|
|
|
} |
|
|
|
dataSyncRecordDeathService.saveOrUpdateBatch(list,NumConstant.TWO_HUNDRED); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -350,14 +328,14 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
* @param pageSize |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<NatUserInfoResultDTO> getNatUserInfoFromDB(DataSyncTaskParam formDTO, DataSyncEnum anEnum, int pageNo, int pageSize) { |
|
|
|
private List<NatUserInfoResultDTO> getNatUserInfoFromDb(DataSyncTaskParam formDTO, DataSyncEnum anEnum, int pageNo, int pageSize) { |
|
|
|
//根据 组织 分页获取 居民数据
|
|
|
|
PageInfo<NatUserInfoResultDTO> pageInfo = PageHelper.startPage(pageNo, pageSize, false) |
|
|
|
.doSelectPageInfo(() -> baseDao.getIdCardsByScope(formDTO)); |
|
|
|
List<NatUserInfoResultDTO> dbResiList; |
|
|
|
dbResiList = pageInfo.getList(); |
|
|
|
//如果传了身份证号 则按照身份证号查询 并同步记录, userId如果为空则是 手动录入的 此人没有录入居民库 但是也可以同步
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getIdCards()) && DataSyncEnum.HE_SUAN.equals(anEnum.getCode())) { |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getIdCards()) && DataSyncEnum.HE_SUAN.getCode().equals(anEnum.getCode())) { |
|
|
|
List<NatUserInfoResultDTO> collect = formDTO.getIdCards().stream().map(id -> { |
|
|
|
NatUserInfoResultDTO e = new NatUserInfoResultDTO(); |
|
|
|
e.setIdCard(id); |
|
|
@ -412,7 +390,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
|
|
|
|
|
|
|
|
JudgeDealStatus judgeDealStatus = null; |
|
|
|
Integer disabilityStatus = 0; |
|
|
|
int disabilityStatus = 0; |
|
|
|
//居民是残疾
|
|
|
|
if (NumConstant.ONE_STR.equals(categoryColumn)) { |
|
|
|
// 第三方返回了该人的 残疾记录 说明和居民库的状态一致 只需要处理 同步记录中的数据即可
|
|
|
@ -428,7 +406,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).notSame(); |
|
|
|
disabilityStatus = 0; |
|
|
|
} |
|
|
|
} else if (NumConstant.ZERO_STR.equals(categoryColumn)) { |
|
|
|
} else { |
|
|
|
//居民不是残疾
|
|
|
|
|
|
|
|
// 第三方没有返回了该人的 残疾记录 说明和居民库的状态一致 只需要处理 同步记录中的数据即可
|
|
|
@ -465,14 +443,14 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
entity.setGuardianPhone(thirdResultObject.getString("guardianPhone")); |
|
|
|
entity.setDealStatus(NumConstant.ZERO); |
|
|
|
entity.setDisabilityStatus(disabilityStatus); |
|
|
|
entity.setDealRedult(StrConstant.EPMETY_STR); |
|
|
|
entity.setDealResult(StrConstant.EPMETY_STR); |
|
|
|
if (judgeDealStatus.isNeedSetStatus) { |
|
|
|
entity.setDealRedult(judgeDealStatus.getDealResult()); |
|
|
|
entity.setDealResult(judgeDealStatus.getDealResult()); |
|
|
|
entity.setDealStatus(judgeDealStatus.getDealStatus()); |
|
|
|
} |
|
|
|
list.add(entity); |
|
|
|
} |
|
|
|
dataSyncRecordDisabilityService.saveOrUpdateBatch(list); |
|
|
|
dataSyncRecordDisabilityService.saveOrUpdateBatch(list, NumConstant.TWO_HUNDRED); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -543,18 +521,29 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
} |
|
|
|
|
|
|
|
private class JudgeDealStatus { |
|
|
|
private boolean myResult; |
|
|
|
private boolean isNext; |
|
|
|
private DataSyncRecordDisabilityDTO dbDisablityEntity; |
|
|
|
private DataSyncRecordDeathDTO dbDeathEntity; |
|
|
|
private Integer dealStatus; |
|
|
|
private String dealResult; |
|
|
|
private boolean isNeedSetStatus; |
|
|
|
|
|
|
|
/** |
|
|
|
* http请求返回的结果 |
|
|
|
*/ |
|
|
|
private JSONObject thirdResultObject; |
|
|
|
|
|
|
|
public JudgeDealStatus(DataSyncRecordDisabilityDTO dbDisablityEntity) { |
|
|
|
this.dbDisablityEntity = dbDisablityEntity; |
|
|
|
} |
|
|
|
|
|
|
|
public JudgeDealStatus(JSONObject thirdResultObject,DataSyncRecordDeathDTO dbDeathEntity) { |
|
|
|
this.thirdResultObject = thirdResultObject; |
|
|
|
this.dbDeathEntity = dbDeathEntity; |
|
|
|
} |
|
|
|
|
|
|
|
boolean isStop() { |
|
|
|
return myResult; |
|
|
|
return isNext; |
|
|
|
} |
|
|
|
|
|
|
|
public Integer getDealStatus() { |
|
|
@ -572,12 +561,12 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
public JudgeDealStatus invoke() { |
|
|
|
//对比记录里 也没有信息 则不用处理
|
|
|
|
if (dbDisablityEntity == null || StringUtils.isBlank(dbDisablityEntity.getId())) { |
|
|
|
myResult = true; |
|
|
|
isNext = true; |
|
|
|
return this; |
|
|
|
} else { |
|
|
|
//对比记录里 有数据 且是已处理状态 则继续下一个居民
|
|
|
|
if (dbDisablityEntity.getDealStatus().equals(NumConstant.ONE)) { |
|
|
|
myResult = true; |
|
|
|
isNext = true; |
|
|
|
return this; |
|
|
|
} else { |
|
|
|
//如果是其他处理状态 则改为已处理即可
|
|
|
@ -586,7 +575,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
isNeedSetStatus = true; |
|
|
|
} |
|
|
|
} |
|
|
|
myResult = false; |
|
|
|
isNext = false; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
@ -603,7 +592,41 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
dealResult = ""; |
|
|
|
isNeedSetStatus = true; |
|
|
|
} |
|
|
|
myResult = false; |
|
|
|
isNext = false; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
public JudgeDealStatus invokeDeath() { |
|
|
|
//获取到了死亡记录 同步记录不存在 或者存在且状态不为为已处理 则返回true 继续下一个数据
|
|
|
|
if (thirdResultObject != null) { |
|
|
|
if (dbDeathEntity != null && StringUtils.isNotBlank(dbDeathEntity.getId())){ |
|
|
|
Integer dealStatusDb = dbDeathEntity.getDealStatus(); |
|
|
|
//数据库中的状态如果是已处理 改为未处理
|
|
|
|
if (dealStatusDb.equals(NumConstant.ONE)){ |
|
|
|
dealStatus = 0; |
|
|
|
dealResult = ""; |
|
|
|
isNeedSetStatus = true; |
|
|
|
}else{ |
|
|
|
isNext = true; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
//没有获取到 死亡记录
|
|
|
|
if (dbDeathEntity != null && StringUtils.isNotBlank(dbDeathEntity.getId())){ |
|
|
|
Integer dealStatusDb = dbDeathEntity.getDealStatus(); |
|
|
|
//数据库中的状态如果是未处理 或处理失败 则继续下一条
|
|
|
|
if (dealStatusDb.equals(NumConstant.ONE)){ |
|
|
|
isNext = true; |
|
|
|
return this; |
|
|
|
}else{ |
|
|
|
dealStatus = 1; |
|
|
|
dealResult = "系统比对数据一致,自动处理"; |
|
|
|
isNeedSetStatus = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
isNext = false; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|