Browse Source

补全暂提

dev
zxc 3 years ago
parent
commit
2e1c025c61
  1. 26
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RelationAndNatResultDTO.java
  2. 20
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java
  3. 1
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java
  4. 66
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java
  5. 48
      epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml
  6. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

26
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/RelationAndNatResultDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2022/10/25 09:37
*/
@Data
public class RelationAndNatResultDTO implements Serializable {
private static final long serialVersionUID = 5245015978083295931L;
private String relationId;
private String natId;
private String staffAgencyIdPath;
private String idCard;
/**
* 默认不是本辖区居民
*/
private String isLocalResiUser = NumConstant.ZERO_STR;
}

20
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcNatDao.java

@ -6,7 +6,9 @@ import com.epmet.dto.form.MyNatListFormDTO;
import com.epmet.dto.result.MyNatListResultDTO; import com.epmet.dto.result.MyNatListResultDTO;
import com.epmet.dto.result.NatListResultDTO; import com.epmet.dto.result.NatListResultDTO;
import com.epmet.dto.result.NatUserInfoResultDTO; import com.epmet.dto.result.NatUserInfoResultDTO;
import com.epmet.dto.result.RelationAndNatResultDTO;
import com.epmet.entity.IcNatEntity; import com.epmet.entity.IcNatEntity;
import com.epmet.entity.IcResiUserEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -66,4 +68,22 @@ public interface IcNatDao extends BaseDao<IcNatEntity> {
void updateBatchNat(@Param("list")List<IcNatEntity> entities); void updateBatchNat(@Param("list")List<IcNatEntity> entities);
List<RelationAndNatResultDTO> getRelationAndNat();
List<IcResiUserEntity> getResiByIdCards(@Param("idCards")List<String> idCards);
/**
* @Description 批量更新关系
* @param list
* @Author zxc
* @Date 2022/10/25 10:56
*/
void updateRelation(@Param("list") List<RelationAndNatResultDTO> list);
/**
* @Description 更新的 userType != 'import'
* @Author zxc
* @Date 2022/10/25 11:13
*/
void updateRelationOther();
} }

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

@ -557,6 +557,7 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao
e.setAgencyId(ne.getAgencyId()); e.setAgencyId(ne.getAgencyId());
e.setPids(ne.getPids()); e.setPids(ne.getPids());
e.setIcNatId(ne.getId()); e.setIcNatId(ne.getId());
e.setIsLocalResiUser(NumConstant.ONE_STR);
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync"); e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync");
relationEntities.add(e); relationEntities.add(e);
} }

66
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java

@ -14,6 +14,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; 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.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.utils.*;
@ -129,6 +130,10 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp
if (null == agencyInfo) { if (null == agencyInfo) {
throw new RenException(String.format("获取组织缓存信息失败%s", formDTO.getAgencyId())); 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.新增核酸基础信息数据 //2.新增核酸基础信息数据
IcNatEntity entity = ConvertUtils.sourceToTarget(formDTO, IcNatEntity.class); IcNatEntity entity = ConvertUtils.sourceToTarget(formDTO, IcNatEntity.class);
if (StringUtils.isNotBlank(formDTO.getUserId())) { if (StringUtils.isNotBlank(formDTO.getUserId())) {
@ -136,9 +141,12 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp
} }
insert(entity); insert(entity);
//3.核酸记录关系表新增与组织的关系数据 //3.核酸记录关系表新增与组织的关系数据
ResiAndLocalResiResultDTO resiCount = icResiUserDao.getResiCount(formDTO.getAgencyId(), formDTO.getIdCard(), formDTO.getCustomerId());
IcNatRelationEntity relationEntity = ConvertUtils.sourceToTarget(formDTO, IcNatRelationEntity.class); IcNatRelationEntity relationEntity = ConvertUtils.sourceToTarget(formDTO, IcNatRelationEntity.class);
relationEntity.setIcNatId(entity.getId()); 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); icNatRelationDao.insert(relationEntity);
//3.新增通知表信息 //3.新增通知表信息
@ -476,7 +484,47 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp
public void initNatLocal() { public void initNatLocal() {
Integer no = NumConstant.ONE; Integer no = NumConstant.ONE;
Integer size; 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为import2除了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; return;
} }
// 存在某时间的核酸检测信息
if (resiNat != null) { if (resiNat != null) {
boolean needUpdate = false; boolean needUpdate = false;
// 有这个人,也是导入的,那就要更新le // 有这个人,也是导入的,那就要更新le
@ -593,8 +642,9 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp
} }
// 还要创建关系。只有本辖区及下级居民,才建立关系 // 还要创建关系。只有本辖区及下级居民,才建立关系
// 2022-10-25 修改:导入的都插入关系
if (resi != null) { if (resi != null) {
createNatRelation(resiNat.getId(), resi.getAgencyId(), resi.getPids()); createNatRelation(resiNat.getId(), resi.getAgencyId(), agencyPids,agencyId);
} }
return; return;
@ -609,7 +659,7 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp
// 还要创建关系。只有本辖区及下级居民,才建立关系 // 还要创建关系。只有本辖区及下级居民,才建立关系
if (resi != null) { 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关系 * 创建nat关系
* @param natId * @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<>(); LambdaQueryWrapper<IcNatRelationEntity> query = new LambdaQueryWrapper<>();
query.eq(IcNatRelationEntity::getIcNatId, natId); query.eq(IcNatRelationEntity::getIcNatId, natId);
query.eq(IcNatRelationEntity::getAgencyId, currentUserAgencyId); 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.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId)));
relation.setIcNatId(natId); relation.setIcNatId(natId);
relation.setUserType("import"); relation.setUserType("import");
relation.setIsLocalResiUser(agencyPids.contains(currentUserAgencyId) ? NumConstant.ONE_STR : NumConstant.ZERO_STR);
icNatRelationDao.insert(relation); icNatRelationDao.insert(relation);
} }
} }

48
epmet-user/epmet-user-server/src/main/resources/mapper/IcNatDao.xml

@ -75,7 +75,7 @@
AND b.sample_time <![CDATA[ <= ]]> #{sampleEndTime} AND b.sample_time <![CDATA[ <= ]]> #{sampleEndTime}
</if> </if>
<if test='null != isResiUser and "" != isResiUser'> <if test='null != isResiUser and "" != isResiUser'>
AND b.is_local_resi_user = #{isResiUser} AND a.is_local_resi_user = #{isResiUser}
</if> </if>
ORDER BY b.nat_time DESC, b.id ASC ORDER BY b.nat_time DESC, b.id ASC
</select> </select>
@ -169,6 +169,29 @@
</foreach> </foreach>
</select> </select>
<!-- 获取关系和核酸检测 -->
<select id="getRelationAndNat" resultType="com.epmet.dto.result.RelationAndNatResultDTO">
SELECT
r.ID AS relationId,
i.ID AS natId,
i.ID_CARD,
r.PIDS AS staffAgencyIdPath
FROM ic_nat_relation r
INNER JOIN ic_nat i ON i.ID = r.IC_NAT_ID AND i.DEL_FLAG = 0
WHERE r.DEL_FLAG = 0
AND r.USER_TYPE IN ('import')
</select>
<select id="getResiByIdCards" resultType="com.epmet.entity.IcResiUserEntity">
SELECT * FROM ic_resi_user
WHERE DEL_FLAG = '0'
AND `STATUS` = '0'
AND ID_CARD IN (
<foreach collection="idCards" item="idCard" separator=",">
#{idCard}
</foreach>
)
</select>
<delete id="delById"> <delete id="delById">
DELETE FROM ic_nat WHERE id = #{icNatId} DELETE FROM ic_nat WHERE id = #{icNatId}
</delete> </delete>
@ -222,4 +245,27 @@
</foreach>) </foreach>)
</update> </update>
<!-- 批量更新关系 -->
<update id="updateRelation">
UPDATE ic_nat_relation
<trim prefix="set" suffixOverrides=",">
<trim prefix="IS_LOCAL_RESI_USER =(case" suffix="end),">
<foreach collection="list" item="l">
when ID = #{l.relationId} then #{l.isLocalResiUser}
</foreach>
</trim>
UPDATED_TIME = NOW()
</trim>
WHERE ID IN(
<foreach collection="list" item="l" separator=",">
#{l.relationId}
</foreach>)
</update>
<update id="updateRelationOther">
UPDATE ic_nat_relation
set IS_LOCAL_RESI_USER = '1',
UPDATED_TIME = NOW()
where user_type != 'import'
</update>
</mapper> </mapper>

2
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -1391,7 +1391,7 @@
FROM ic_resi_user FROM ic_resi_user
WHERE DEL_FLAG = '0' WHERE DEL_FLAG = '0'
AND `STATUS` = 0 AND `STATUS` = 0
AND AGENCY_ID = #{agencyId} AND PIDS LIKE CONCAT('%',#{agencyId},'%')
AND ID_CARD = #{idCard}) AS isLocal, AND ID_CARD = #{idCard}) AS isLocal,
COUNT(ID) AS isResi, COUNT(ID) AS isResi,
id as userId id as userId

Loading…
Cancel
Save