|
|
@ -14,6 +14,7 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
@ -129,6 +130,10 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
if (null == agencyInfo) { |
|
|
|
throw new RenException(String.format("获取组织缓存信息失败%s", formDTO.getAgencyId())); |
|
|
|
} |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); |
|
|
|
if (null == staffInfo){ |
|
|
|
throw new EpmetException(String.format("获取工作人员信息失败%s", formDTO.getStaffId())); |
|
|
|
} |
|
|
|
//2.新增核酸基础信息数据
|
|
|
|
IcNatEntity entity = ConvertUtils.sourceToTarget(formDTO, IcNatEntity.class); |
|
|
|
if (StringUtils.isNotBlank(formDTO.getUserId())) { |
|
|
@ -136,9 +141,12 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
} |
|
|
|
insert(entity); |
|
|
|
//3.核酸记录关系表新增与组织的关系数据
|
|
|
|
ResiAndLocalResiResultDTO resiCount = icResiUserDao.getResiCount(formDTO.getAgencyId(), formDTO.getIdCard(), formDTO.getCustomerId()); |
|
|
|
IcNatRelationEntity relationEntity = ConvertUtils.sourceToTarget(formDTO, IcNatRelationEntity.class); |
|
|
|
relationEntity.setIcNatId(entity.getId()); |
|
|
|
relationEntity.setPids(StringUtils.isNotBlank(agencyInfo.getPids()) ? agencyInfo.getPids() + ":" + formDTO.getAgencyId() : formDTO.getAgencyId()); |
|
|
|
relationEntity.setIsLocalResiUser(resiCount.getIsLocal() == NumConstant.ZERO ? NumConstant.ZERO_STR : NumConstant.ONE_STR); |
|
|
|
relationEntity.setAgencyId(staffInfo.getAgencyId()); |
|
|
|
relationEntity.setPids(StringUtils.isNotBlank(staffInfo.getAgencyPIds()) ? staffInfo.getAgencyPIds() + ":" + staffInfo.getAgencyId() : staffInfo.getAgencyId()); |
|
|
|
icNatRelationDao.insert(relationEntity); |
|
|
|
|
|
|
|
//3.新增通知表信息
|
|
|
@ -476,7 +484,47 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
public void initNatLocal() { |
|
|
|
Integer no = NumConstant.ONE; |
|
|
|
Integer size; |
|
|
|
// 查询关系表
|
|
|
|
do { |
|
|
|
// user_type = 'import'
|
|
|
|
PageInfo<RelationAndNatResultDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_THOUSAND).doSelectPageInfo(() -> baseDao.getRelationAndNat()); |
|
|
|
List<RelationAndNatResultDTO> list = pageInfo.getList(); |
|
|
|
size = list.size(); |
|
|
|
if (CollectionUtils.isNotEmpty(list)){ |
|
|
|
List<IcResiUserEntity> users = baseDao.getResiByIdCards(list.stream().map(m -> m.getIdCard()).distinct().collect(Collectors.toList())); |
|
|
|
if (CollectionUtils.isNotEmpty(users)){ |
|
|
|
for (RelationAndNatResultDTO l : list) { |
|
|
|
for (IcResiUserEntity u : users) { |
|
|
|
if (l.getStaffAgencyIdPath().contains(u.getAgencyId())){ |
|
|
|
l.setIsLocalResiUser(NumConstant.ONE_STR); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
updateRelation(list,NumConstant.ONE_STR); |
|
|
|
} |
|
|
|
} |
|
|
|
}while (size == NumConstant.ONE_THOUSAND); |
|
|
|
// 其他类型的userType直接是居民的组织信息,所以直接赋值 is_local_resi_user = '1'
|
|
|
|
updateRelation(null,NumConstant.TWO_STR); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 更新核酸关系表 |
|
|
|
* @param list |
|
|
|
* @param type 1:userType为import;2:除了import |
|
|
|
* @Author zxc |
|
|
|
* @Date 2022/10/25 10:55 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void updateRelation(List<RelationAndNatResultDTO> list,String type){ |
|
|
|
if (NumConstant.ONE_STR.equals(type)){ |
|
|
|
if (CollectionUtils.isNotEmpty(list)){ |
|
|
|
baseDao.updateRelation(list); |
|
|
|
} |
|
|
|
}else { |
|
|
|
baseDao.updateRelationOther(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -542,6 +590,7 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 存在某时间的核酸检测信息
|
|
|
|
if (resiNat != null) { |
|
|
|
boolean needUpdate = false; |
|
|
|
// 有这个人,也是导入的,那就要更新le
|
|
|
@ -593,8 +642,9 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
} |
|
|
|
|
|
|
|
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|
|
|
// 2022-10-25 修改:导入的都插入关系
|
|
|
|
if (resi != null) { |
|
|
|
createNatRelation(resiNat.getId(), resi.getAgencyId(), resi.getPids()); |
|
|
|
createNatRelation(resiNat.getId(), resi.getAgencyId(), agencyPids,agencyId); |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
@ -609,7 +659,7 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
|
|
|
|
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|
|
|
if (resi != null) { |
|
|
|
createNatRelation(e.getId(), resi.getAgencyId(), resi.getPids()); |
|
|
|
createNatRelation(e.getId(), resi.getAgencyId(), agencyPids,agencyId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -649,11 +699,15 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
/** |
|
|
|
* 创建nat关系 |
|
|
|
* @param natId |
|
|
|
* @param currentUserAgencyId |
|
|
|
* @param currentUserAgencyId 居民所属组织 |
|
|
|
* @param staffAgencyId 工作人员所属组织 |
|
|
|
* @param agencyPids 工作人员所属组织路径 |
|
|
|
*/ |
|
|
|
private void createNatRelation(String natId, String currentUserAgencyId, String agencyPids) { |
|
|
|
private void createNatRelation(String natId, String currentUserAgencyId, String agencyPids,String staffAgencyId) { |
|
|
|
|
|
|
|
// 没有关系创建关系,有关系就跳过
|
|
|
|
// 2022-10-25 修改:不管是不是本辖区居民,都创建关系,用 is_local_resi_user区分是不是本辖区居民
|
|
|
|
// 组织ID都改成工作人员所属组织ID
|
|
|
|
LambdaQueryWrapper<IcNatRelationEntity> query = new LambdaQueryWrapper<>(); |
|
|
|
query.eq(IcNatRelationEntity::getIcNatId, natId); |
|
|
|
query.eq(IcNatRelationEntity::getAgencyId, currentUserAgencyId); |
|
|
@ -666,6 +720,8 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
relation.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId))); |
|
|
|
relation.setIcNatId(natId); |
|
|
|
relation.setUserType("import"); |
|
|
|
relation.setIsLocalResiUser(agencyPids.contains(currentUserAgencyId) ? NumConstant.ONE_STR : NumConstant.ZERO_STR); |
|
|
|
icNatRelationDao.insert(relation); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|