diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java index abb8f6184c..1b359b5624 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java @@ -478,6 +478,8 @@ public class IcNatServiceImpl extends BaseServiceImpl imp @Transactional(rollbackFor = Exception.class) public void persisNat(IcNatEntity e, String customerId, String currentUserId, IcNatExcelImportListener listener) { List otherRows = listener.getOtherRows(); + String agencyPids = listener.getCurrentAgencyPids(); + String agencyId = listener.getCurrentAgencyId(); Date natTime = e.getNatTime(); String idCard = e.getIdCard(); @@ -545,43 +547,50 @@ public class IcNatServiceImpl extends BaseServiceImpl imp resiNat.setUpdatedBy(currentUserId); resiNat.setUpdatedTime(new Date()); - IcResiUserEntity resi = getResi(customerId, idCard); + IcResiUserEntity resi = getResi(customerId, idCard, null); resiNat.setIsResiUser(resi != null ? "1" : "0"); resiNat.setUserId(resi != null ? resi.getId() : ""); baseDao.updateById(resiNat); } - // 还要创建关系 - createNatRelation(resiNat.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); + // 还要创建关系。只有本辖区及下级居民,才建立关系 + if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { + createNatRelation(resiNat.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); + } return; } // 执行新增操作 - IcResiUserEntity resi = getResi(customerId, idCard); + IcResiUserEntity resi = getResi(customerId, idCard, null); e.setIsResiUser(resi != null ? "1" : "0"); e.setUserId(resi != null ? resi.getId() : ""); e.setUserType("import"); baseDao.insert(e); - // 还要创建关系 - createNatRelation(e.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); + // 还要创建关系。只有本辖区及下级居民,才建立关系 + if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { + createNatRelation(e.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); + } } /** - * 是否是客户下的居民; + * 是否是指定条件下的居民; * 0:否 * 1:是 * @param customerId * @param idCard * @return */ - public IcResiUserEntity getResi(String customerId, String idCard) { + public IcResiUserEntity getResi(String customerId, String idCard, String pids) { LambdaQueryWrapper query = new LambdaQueryWrapper(); query.eq(IcResiUserEntity::getCustomerId, customerId); query.eq(IcResiUserEntity::getIdCard, idCard); + if (StringUtils.isNotBlank(pids)) { + query.likeRight(IcResiUserEntity::getPids, pids); + } return icResiUserDao.selectOne(query); } diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.37__ic_epidemic_special_attention.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.37__ic_epidemic_special_attention.sql new file mode 100644 index 0000000000..c16c75f965 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.37__ic_epidemic_special_attention.sql @@ -0,0 +1,21 @@ +CREATE TABLE `ic_epidemic_special_attention` ( + `ID` varchar(64) NOT NULL COMMENT 'ID', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', + `ORG_ID` varchar(64) NOT NULL COMMENT '当前工作人员所属组织ID', + `PID` varchar(64) NOT NULL COMMENT '组织ID上级', + `PIDS` varchar(255) NOT NULL COMMENT '组织ID所有上级', + `IS_ATTENTION` tinyint(1) NOT NULL COMMENT '是否关注 1:关注,0:取消关注', + `ATTENTION_TYPE` tinyint(1) NOT NULL COMMENT '关注类型,核酸检测:2,疫苗接种:1,行程上报:0', + `NAME` varchar(64) NOT NULL COMMENT '姓名', + `MOBILE` varchar(11) NOT NULL COMMENT '手机号', + `ID_CARD` varchar(18) NOT NULL COMMENT '身份证号', + `REASON` varchar(1000) DEFAULT NULL COMMENT '原因', + `REMARK` varchar(1000) DEFAULT NULL COMMENT '备注', + `DEL_FLAG` int(11) NOT NULL, + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='疫情特别关注'; \ No newline at end of file