|
|
@ -1,11 +1,17 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
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; |
|
|
@ -18,19 +24,14 @@ 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.DataSyncRecordDisabilityDTO; |
|
|
|
import com.epmet.dto.form.ConfigSwitchFormDTO; |
|
|
|
import com.epmet.dto.form.NatInfoScanTaskFormDTO; |
|
|
|
import com.epmet.dto.form.DataSyncTaskParam; |
|
|
|
import com.epmet.dto.form.ScopeSaveFormDTO; |
|
|
|
import com.epmet.dto.result.NatUserInfoResultDTO; |
|
|
|
import com.epmet.entity.DataSyncConfigEntity; |
|
|
|
import com.epmet.entity.DataSyncScopeEntity; |
|
|
|
import com.epmet.entity.IcNatEntity; |
|
|
|
import com.epmet.entity.IcNatRelationEntity; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.enums.DataSyncEnum; |
|
|
|
import com.epmet.service.DataSyncConfigService; |
|
|
|
import com.epmet.service.DataSyncScopeService; |
|
|
|
import com.epmet.service.IcNatRelationService; |
|
|
|
import com.epmet.service.IcNatService; |
|
|
|
import com.epmet.service.*; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -65,9 +66,13 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
private IcNatService icNatService; |
|
|
|
@Autowired |
|
|
|
private IcNatRelationService icNatRelationService; |
|
|
|
@Autowired |
|
|
|
private DataSyncRecordDeathService dataSyncRecordDeathService; |
|
|
|
@Autowired |
|
|
|
private DataSyncRecordDisabilityService dataSyncRecordDisabilityService; |
|
|
|
|
|
|
|
private QueryWrapper<DataSyncConfigEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<DataSyncConfigEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<DataSyncConfigEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -104,6 +109,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 【数据配置】配置开关 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/9/26 14:36 |
|
|
@ -116,6 +122,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 【数据配置】列表 |
|
|
|
* |
|
|
|
* @param tokenDto |
|
|
|
* @author zxc |
|
|
|
* @date 2022/9/26 15:04 |
|
|
@ -125,7 +132,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
PageData<DataSyncConfigDTO> result = new PageData<>(new ArrayList<>(), NumConstant.ZERO_L); |
|
|
|
PageInfo<DataSyncConfigDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()) |
|
|
|
.doSelectPageInfo(() -> baseDao.list(tokenDto.getCustomerId(), null)); |
|
|
|
if (CollectionUtils.isNotEmpty(pageInfo.getList())){ |
|
|
|
if (CollectionUtils.isNotEmpty(pageInfo.getList())) { |
|
|
|
result.setList(pageInfo.getList()); |
|
|
|
result.setTotal(Integer.parseInt(String.valueOf(pageInfo.getTotal()))); |
|
|
|
} |
|
|
@ -134,6 +141,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 【数据配置】范围保存 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/9/26 15:41 |
|
|
@ -142,21 +150,21 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void scopeSave(ScopeSaveFormDTO formDTO) { |
|
|
|
baseDao.delScope(formDTO.getDataSyncConfigId()); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getScopeList())){ |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getScopeList())) { |
|
|
|
formDTO.getScopeList().forEach(o -> { |
|
|
|
o.setCustomerId(formDTO.getCustomerId()); |
|
|
|
o.setDataSyncConfigId(formDTO.getDataSyncConfigId()); |
|
|
|
if (o.getOrgType().equals("grid")){ |
|
|
|
if (o.getOrgType().equals("grid")) { |
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(o.getOrgId()); |
|
|
|
if (null == gridInfo){ |
|
|
|
throw new EpmetException("查询网格信息失败"+o.getOrgId()); |
|
|
|
if (null == gridInfo) { |
|
|
|
throw new EpmetException("查询网格信息失败" + o.getOrgId()); |
|
|
|
} |
|
|
|
o.setPid(gridInfo.getPid()); |
|
|
|
o.setOrgIdPath(gridInfo.getPids() + ":" + gridInfo.getId()); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(o.getOrgId()); |
|
|
|
if (null == agencyInfo){ |
|
|
|
throw new EpmetException("查询组织信息失败"+o.getOrgId()); |
|
|
|
if (null == agencyInfo) { |
|
|
|
throw new EpmetException("查询组织信息失败" + o.getOrgId()); |
|
|
|
} |
|
|
|
o.setPid(agencyInfo.getPid()); |
|
|
|
o.setOrgIdPath(agencyInfo.getPids().equals(NumConstant.EMPTY_STR) || agencyInfo.getPids().equals(NumConstant.ZERO_STR) ? agencyInfo.getId() : agencyInfo.getPids() + ":" + agencyInfo.getId()); |
|
|
@ -171,145 +179,432 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao |
|
|
|
* 大数据局部门配置on |
|
|
|
* 根据范围搜索居民,调接口查询最近一次核酸检测记录 |
|
|
|
* 检测时间 + 身份证 不存在就插入 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/9/26 17:16 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void dataSyncForYanTaiTask(NatInfoScanTaskFormDTO formDTO) { |
|
|
|
List<DataSyncConfigDTO> allConfigList = baseDao.list(formDTO.getCustomerId() ,"open"); |
|
|
|
if (CollectionUtils.isEmpty(allConfigList)){ |
|
|
|
public void dataSyncForYanTaiTask(DataSyncTaskParam formDTO) { |
|
|
|
List<DataSyncConfigDTO> allConfigList = baseDao.list(formDTO.getCustomerId(), "open"); |
|
|
|
if (CollectionUtils.isEmpty(allConfigList)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO 根据dataCode 调用不同的方法 抽取数据
|
|
|
|
if (CollectionUtils.isNotEmpty(allConfigList)){ |
|
|
|
if (CollectionUtils.isNotEmpty(allConfigList)) { |
|
|
|
log.warn("dataSyncForYanTaiTask don't have any resi data to pull data form YanTai interface"); |
|
|
|
return; |
|
|
|
} |
|
|
|
for (DataSyncConfigDTO config : allConfigList) { |
|
|
|
|
|
|
|
//没有配置 数据拉取范围 继续下次循环
|
|
|
|
if (CollectionUtils.isEmpty(config.getScopeList())){ |
|
|
|
if (CollectionUtils.isEmpty(config.getScopeList())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//如果传了身份证号 则按照身份证号查询 并同步记录, userId如果为空则是 手动录入的 此人没有录入居民库 但是也可以同步
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getIdCards())){ |
|
|
|
List<NatUserInfoResultDTO> userIdByIdCard = baseDao.getIdCardsByScope(config.getScopeList(),formDTO.getIdCards()); |
|
|
|
List<NatUserInfoResultDTO> collect = formDTO.getIdCards().stream().map(id -> { |
|
|
|
NatUserInfoResultDTO e = new NatUserInfoResultDTO(); |
|
|
|
e.setIdCard(id); |
|
|
|
e.setUserId(""); |
|
|
|
return e; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
collect.forEach(c -> userIdByIdCard.stream().filter(u -> u.getIdCard().equals(c.getIdCard())).forEach(u -> c.setUserId(u.getUserId()))); |
|
|
|
executeSyncData(config, collect); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
//没传具体参数 则 按照
|
|
|
|
int pageNo = NumConstant.ONE; |
|
|
|
int pageSize = NumConstant.ONE_THOUSAND; |
|
|
|
PageInfo<NatUserInfoResultDTO> pageInfo = null; |
|
|
|
do { |
|
|
|
//根据 组织 分页获取 居民数据
|
|
|
|
pageInfo = PageHelper.startPage(pageNo, pageSize, false) |
|
|
|
.doSelectPageInfo(() -> baseDao.getIdCardsByScope(config.getScopeList(),formDTO.getIdCards())); |
|
|
|
executeSyncData(config, pageInfo.getList()); |
|
|
|
|
|
|
|
pageNo++; |
|
|
|
} while (pageInfo != null && pageInfo.getSize() == pageSize); |
|
|
|
|
|
|
|
//没传具体参数 则 按照
|
|
|
|
int pageNo = NumConstant.ONE; |
|
|
|
int pageSize = NumConstant.ONE_THOUSAND; |
|
|
|
List<NatUserInfoResultDTO> dbResiList = null; |
|
|
|
//设置查询数据范围
|
|
|
|
formDTO.setOrgList(config.getScopeList()); |
|
|
|
DataSyncEnum anEnum = DataSyncEnum.getEnum(config.getDataCode()); |
|
|
|
|
|
|
|
do { |
|
|
|
switch (anEnum) { |
|
|
|
case HE_SUAN: |
|
|
|
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); |
|
|
|
canJi(dbResiList); |
|
|
|
break; |
|
|
|
case SI_WANG: |
|
|
|
formDTO.setResiSubStatus(IcResiUserSubStatusEnum.DIED.getSubStatus()); |
|
|
|
dbResiList = getNatUserInfoFromDB(formDTO, anEnum, pageNo, pageSize); |
|
|
|
siWang(dbResiList); |
|
|
|
break; |
|
|
|
default: |
|
|
|
log.warn("没有要处理的数据"); |
|
|
|
} |
|
|
|
pageNo++; |
|
|
|
} while (dbResiList != null && dbResiList.size() == pageSize); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void siWang(List<NatUserInfoResultDTO> dbResiList) { |
|
|
|
List<DataSyncRecordDisabilityEntity> list = new ArrayList<>(); |
|
|
|
for (NatUserInfoResultDTO dbResi : dbResiList) { |
|
|
|
YtDataSyncResDTO thirdResult = YtHsResUtils.siWang(dbResi.getIdCard(), dbResi.getName()); |
|
|
|
if (200 != thirdResult.getCode()) { |
|
|
|
log.warn("canJi 调用蓝图接口失败了 继续处理下一个人"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
/*{ |
|
|
|
"AGE": "73", |
|
|
|
"CARD_TYPE": "9", |
|
|
|
"CREATE_ORGAN_NAME": "菏泽市巨野县殡仪馆", |
|
|
|
"CREMATION_TIME": "2014-04-17 14:46", |
|
|
|
"DEAD_ID": "SZ-371724-2012-1006560", |
|
|
|
"DEATH_DATE": "2014-04-17", |
|
|
|
"FAMILY_ADD": "菏泽市巨野县开发区马庄村", |
|
|
|
"FOLK": "01", |
|
|
|
"ID_CARD": "1", |
|
|
|
"NAME": "郭**", |
|
|
|
"NATION": "156", |
|
|
|
"POPULACE": "3381C3014B60439FE05319003C0A0897", |
|
|
|
"POPULACE_NAME": "菏泽市巨野县开发区马庄村", |
|
|
|
"RECORD_ID": "E-371724-2012-100000000000407849", |
|
|
|
"RN": "1", |
|
|
|
"SEX": "1" |
|
|
|
}*/ |
|
|
|
String thirdResultData = thirdResult.getData(); |
|
|
|
JSONObject thirdResultObject = JSON.parseObject(thirdResultData); |
|
|
|
|
|
|
|
LambdaQueryWrapper<DataSyncRecordDisabilityEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(DataSyncRecordDisabilityEntity::getIdCard, dbResi.getIdCard()); |
|
|
|
//获取数据库里的记录
|
|
|
|
DataSyncRecordDisabilityDTO dbDisablityEntity = dataSyncRecordDisabilityService.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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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.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.setDealStatus(NumConstant.ZERO); |
|
|
|
entity.setDealRedult(StrConstant.EPMETY_STR); |
|
|
|
if (judgeDealStatus.isNeedSetStatus) { |
|
|
|
entity.setDealRedult(judgeDealStatus.dealResult); |
|
|
|
entity.setDealStatus(judgeDealStatus.dealStatus); |
|
|
|
} |
|
|
|
list.add(entity); |
|
|
|
} |
|
|
|
dataSyncRecordDisabilityService.saveOrUpdateBatch(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:根据居民身份证号 从蓝图api接口 获取数据到本地 |
|
|
|
* @param config |
|
|
|
* @param resiList |
|
|
|
* desc:从数据库获取居民信息 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @param anEnum |
|
|
|
* @param pageNo |
|
|
|
* @param pageSize |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private void executeSyncData(DataSyncConfigDTO config, List<NatUserInfoResultDTO> resiList) { |
|
|
|
DataSyncEnum anEnum = DataSyncEnum.getEnum(config.getDataCode()); |
|
|
|
switch (anEnum) { |
|
|
|
case HE_SUAN: |
|
|
|
hsjc(resiList, config.getCustomerId()); |
|
|
|
break; |
|
|
|
case CAN_JI: |
|
|
|
//todo
|
|
|
|
break; |
|
|
|
case SI_WANG: |
|
|
|
//todo
|
|
|
|
break; |
|
|
|
default: |
|
|
|
log.warn("没有要处理的数据"); |
|
|
|
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())) { |
|
|
|
List<NatUserInfoResultDTO> collect = formDTO.getIdCards().stream().map(id -> { |
|
|
|
NatUserInfoResultDTO e = new NatUserInfoResultDTO(); |
|
|
|
e.setIdCard(id); |
|
|
|
e.setUserId(""); |
|
|
|
return e; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
for (NatUserInfoResultDTO c : collect) { |
|
|
|
dbResiList.stream().filter(u -> u.getIdCard().equals(c.getIdCard())).forEach(u -> c.setUserId(u.getUserId())); |
|
|
|
} |
|
|
|
dbResiList = collect; |
|
|
|
} |
|
|
|
return dbResiList; |
|
|
|
} |
|
|
|
|
|
|
|
/*\"code\":300, |
|
|
|
\"name\":\"姓名\", |
|
|
|
\"genderName\":\"性别\", |
|
|
|
\"citizenId\":\"身份证号\", |
|
|
|
\"cardNum\":\"残疾证号\", |
|
|
|
\"idtKindName\":\"残疾类别\", |
|
|
|
\"idtLevelName\":\"残疾等级\", |
|
|
|
\"eduLevelName\":\"教育程度\", |
|
|
|
\"marriagerName\":\"婚姻状况\", |
|
|
|
\"guardian\":\"监护人\", |
|
|
|
\"guardianPhone\":\"监护人联系方式\", |
|
|
|
\"residentAdd\":\"户籍地址\", |
|
|
|
\"nowAdd\":'现居住地\", |
|
|
|
\"phoneNo\":'联系电话\",*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void canJi(List<NatUserInfoResultDTO> resiList) { |
|
|
|
List<DataSyncRecordDisabilityEntity> list = new ArrayList<>(); |
|
|
|
for (NatUserInfoResultDTO dbResi : resiList) { |
|
|
|
YtDataSyncResDTO thirdResult = YtHsResUtils.canji(dbResi.getIdCard(), dbResi.getName()); |
|
|
|
if (200 != thirdResult.getCode()) { |
|
|
|
log.warn("canJi 调用蓝图接口失败了 继续处理下一个人"); |
|
|
|
continue; |
|
|
|
} |
|
|
|
String thirdResultData = thirdResult.getData(); |
|
|
|
JSONObject thirdResultObject = JSON.parseObject(thirdResultData); |
|
|
|
|
|
|
|
LambdaQueryWrapper<DataSyncRecordDisabilityEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.eq(DataSyncRecordDisabilityEntity::getIdCard, dbResi.getIdCard()); |
|
|
|
//获取数据库里的记录
|
|
|
|
DataSyncRecordDisabilityDTO dbDisablityEntity = dataSyncRecordDisabilityService.selectOne(queryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
DataSyncRecordDisabilityEntity entity = new DataSyncRecordDisabilityEntity(); |
|
|
|
entity.setId(dbDisablityEntity.getId()); |
|
|
|
//居民库里 是否是残疾
|
|
|
|
String categoryColumn = dbResi.getCategoryColumn(); |
|
|
|
|
|
|
|
|
|
|
|
JudgeDealStatus judgeDealStatus = null; |
|
|
|
Integer disabilityStatus = 0; |
|
|
|
//居民是残疾
|
|
|
|
if (NumConstant.ONE_STR.equals(categoryColumn)) { |
|
|
|
// 第三方返回了该人的 残疾记录 说明和居民库的状态一致 只需要处理 同步记录中的数据即可
|
|
|
|
if (thirdResultObject != null) { |
|
|
|
//todo 联调时看一下 为什么db == null 总是true
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).invoke(); |
|
|
|
if (judgeDealStatus.isStop()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
disabilityStatus = 1; |
|
|
|
} else { |
|
|
|
//没有返回该人是残疾的数据 说明需要处理居民库的数据
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).notSame(); |
|
|
|
disabilityStatus = 0; |
|
|
|
} |
|
|
|
} else if (NumConstant.ZERO_STR.equals(categoryColumn)) { |
|
|
|
//居民不是残疾
|
|
|
|
|
|
|
|
// 第三方没有返回了该人的 残疾记录 说明和居民库的状态一致 只需要处理 同步记录中的数据即可
|
|
|
|
if (thirdResultObject == null) { |
|
|
|
//todo 联调时看一下 为什么db == null 总是true
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).invoke(); |
|
|
|
if (judgeDealStatus.isStop()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
disabilityStatus = 0; |
|
|
|
} else { |
|
|
|
//蓝图返回该人是残疾的数据 说明需要处理居民库的数据
|
|
|
|
judgeDealStatus = new JudgeDealStatus(dbDisablityEntity).notSame(); |
|
|
|
disabilityStatus = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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.setIcResiUserId(dbResi.getUserId()); |
|
|
|
entity.setCardNum(thirdResultObject.getString("cardNum")); |
|
|
|
|
|
|
|
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.setDealStatus(NumConstant.ZERO); |
|
|
|
entity.setDisabilityStatus(disabilityStatus); |
|
|
|
entity.setDealRedult(StrConstant.EPMETY_STR); |
|
|
|
if (judgeDealStatus.isNeedSetStatus) { |
|
|
|
entity.setDealRedult(judgeDealStatus.getDealResult()); |
|
|
|
entity.setDealStatus(judgeDealStatus.getDealStatus()); |
|
|
|
} |
|
|
|
list.add(entity); |
|
|
|
} |
|
|
|
dataSyncRecordDisabilityService.saveOrUpdateBatch(list); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 根据证件号 查询nat 存在 ? 不处理 : 新增 |
|
|
|
* |
|
|
|
* @param idCards |
|
|
|
* @param customerId |
|
|
|
* @author zxc |
|
|
|
* @date 2022/9/27 11:08 |
|
|
|
*/ |
|
|
|
private void hsjc(List<NatUserInfoResultDTO> idCards,String customerId){ |
|
|
|
if (CollectionUtils.isNotEmpty(idCards)){ |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
idCards.forEach(idCard -> { |
|
|
|
YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); |
|
|
|
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.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.setNatResult(natInfo.getSample_result_pcr()); |
|
|
|
e.setNatAddress(natInfo.getSampling_org_pcr()); |
|
|
|
e.setAgencyId(idCard.getAgencyId()); |
|
|
|
e.setPids(idCard.getPids()); |
|
|
|
e.setAttachmentType(""); |
|
|
|
e.setAttachmentUrl(""); |
|
|
|
entities.add(e); |
|
|
|
}); |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void hsjc(List<NatUserInfoResultDTO> idCards, String customerId) { |
|
|
|
List<IcNatEntity> entities = new ArrayList<>(); |
|
|
|
idCards.forEach(idCard -> { |
|
|
|
YtHsjcResDTO natInfoResult = YtHsResUtils.hsjc(idCard.getIdCard(), NumConstant.ONE, NumConstant.ONE); |
|
|
|
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.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.setNatResult(natInfo.getSample_result_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))); |
|
|
|
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), 500)) { |
|
|
|
icNatService.insertBatch(icNatEntities); |
|
|
|
} |
|
|
|
} |
|
|
|
//组织关系表
|
|
|
|
List<IcNatRelationEntity> relationEntities = new ArrayList<>(); |
|
|
|
entities.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<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))); |
|
|
|
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), 500)) { |
|
|
|
icNatService.insertBatch(icNatEntities); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(relationEntities)) { |
|
|
|
for (List<IcNatRelationEntity> icNatRelationEntities : ListUtils.partition(relationEntities, 500)) { |
|
|
|
icNatRelationService.insertBatch(icNatRelationEntities); |
|
|
|
} |
|
|
|
//组织关系表
|
|
|
|
List<IcNatRelationEntity> relationEntities = new ArrayList<>(); |
|
|
|
entities.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)){ |
|
|
|
for (List<IcNatRelationEntity> icNatRelationEntities : ListUtils.partition(relationEntities, 500)) { |
|
|
|
icNatRelationService.insertBatch(icNatRelationEntities); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private class JudgeDealStatus { |
|
|
|
private boolean myResult; |
|
|
|
private DataSyncRecordDisabilityDTO dbDisablityEntity; |
|
|
|
private Integer dealStatus; |
|
|
|
private String dealResult; |
|
|
|
private boolean isNeedSetStatus; |
|
|
|
|
|
|
|
public JudgeDealStatus(DataSyncRecordDisabilityDTO dbDisablityEntity) { |
|
|
|
this.dbDisablityEntity = dbDisablityEntity; |
|
|
|
} |
|
|
|
|
|
|
|
boolean isStop() { |
|
|
|
return myResult; |
|
|
|
} |
|
|
|
|
|
|
|
public Integer getDealStatus() { |
|
|
|
return dealStatus; |
|
|
|
} |
|
|
|
|
|
|
|
public String getDealResult() { |
|
|
|
return dealResult; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isNeedSetStatus() { |
|
|
|
return isNeedSetStatus; |
|
|
|
} |
|
|
|
|
|
|
|
public JudgeDealStatus invoke() { |
|
|
|
//对比记录里 也没有信息 则不用处理
|
|
|
|
if (dbDisablityEntity == null || StringUtils.isBlank(dbDisablityEntity.getId())) { |
|
|
|
myResult = true; |
|
|
|
return this; |
|
|
|
} else { |
|
|
|
//对比记录里 有数据 且是已处理状态 则继续下一个居民
|
|
|
|
if (dbDisablityEntity.getDealStatus().equals(NumConstant.ONE)) { |
|
|
|
myResult = true; |
|
|
|
return this; |
|
|
|
} else { |
|
|
|
//如果是其他处理状态 则改为已处理即可
|
|
|
|
dealStatus = 1; |
|
|
|
dealResult = "系统比对数据一致,自动处理"; |
|
|
|
isNeedSetStatus = true; |
|
|
|
} |
|
|
|
} |
|
|
|
myResult = false; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:蓝图返回该人是残疾的数据 说明需要处理居民库的数据 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public JudgeDealStatus notSame() { |
|
|
|
|
|
|
|
if (dbDisablityEntity != null && StringUtils.isNotBlank(dbDisablityEntity.getId()) |
|
|
|
&& dbDisablityEntity.getDealStatus().equals(NumConstant.ONE)) { |
|
|
|
dealStatus = 0; |
|
|
|
dealResult = ""; |
|
|
|
isNeedSetStatus = true; |
|
|
|
} |
|
|
|
myResult = false; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|