From 9d4aa553bed451177a9d7d8de5d60adf472d0359 Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 6 Apr 2023 16:01:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=EF=BC=9A=E5=B1=85=E6=B0=91=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=AF=BC=E5=87=BA-staffOrgPaths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dao/IcResiUserDao.java | 2 +- .../java/com/epmet/service/impl/IcResiUserServiceImpl.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 7ea3b00fbb..0a7f17ebff 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -117,7 +117,7 @@ public interface IcResiUserDao extends BaseDao { @Param("conditions") List conditions, @Param("subTables") List subTables, @Param("showSqlColumns") List showSqlColumns, @Param("currentStaffAgencyId") String currentStaffAgencyId, - @Param("staffOrgPath") String staffOrgPath, + @Param("staffOrgPaths") List staffOrgPaths, @Param("groupByTables") List groupByTables); /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index d8e5ea3c17..960a55fcbb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -1196,7 +1196,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl finalSubTables = getFinalSubables(customerId, formCode, resultTableName, conditions); Map> map = getFinalSubables(customerId, formCode, resultTableName, conditions, null); - return baseDao.dynamicQuery(customerId, resultTableName, conditions, map.get("finalSubTables"), null, currentStaffAgencyId, staffOrgPath, map.get("groupByTables")); + return baseDao.dynamicQuery(customerId, resultTableName, conditions, map.get("finalSubTables"), null, + currentStaffAgencyId, Arrays.asList(staffOrgPath), map.get("groupByTables")); } @NotNull @@ -2241,7 +2242,8 @@ public class IcResiUserServiceImpl extends BaseServiceImpl finalSubTables = getFinalSubables(customerId, formCode, resultTableName, conditions); List exportNeedTableList = showSqlColumns.stream().map(IcCustomExportResultDTO.SqlColumn::getTableName).collect(Collectors.toList()); Map> map = getFinalSubables(customerId, formCode, resultTableName, conditions, exportNeedTableList); - return baseDao.dynamicQuery(customerId, resultTableName, conditions, map.get("finalSubTables"), showSqlColumns, currentStaffAgencyId, staffOrgPath, map.get("groupByTables")); + return baseDao.dynamicQuery(customerId, resultTableName, conditions, map.get("finalSubTables"), showSqlColumns, + currentStaffAgencyId, Arrays.asList(staffOrgPath), map.get("groupByTables")); } @Override From bc90dcd82d3ac5fb6191c0789306669aa2e53ede Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 6 Apr 2023 16:15:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix=EF=BC=9A=E5=B1=85=E6=B0=91=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=AF=BC=E5=87=BA-gridIds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dao/IcResiUserDao.java | 4 +++- .../java/com/epmet/service/impl/IcResiUserServiceImpl.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 0a7f17ebff..9930c7338f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -116,8 +116,10 @@ public interface IcResiUserDao extends BaseDao { @Param("resultTableName") String resultTableName, @Param("conditions") List conditions, @Param("subTables") List subTables, - @Param("showSqlColumns") List showSqlColumns, @Param("currentStaffAgencyId") String currentStaffAgencyId, + @Param("showSqlColumns") List showSqlColumns, + @Param("currentStaffAgencyId") String currentStaffAgencyId, @Param("staffOrgPaths") List staffOrgPaths, + @Param("gridIds") List gridIds, @Param("groupByTables") List groupByTables); /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 960a55fcbb..c4148c3d6b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -1197,7 +1197,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl finalSubTables = getFinalSubables(customerId, formCode, resultTableName, conditions); Map> map = getFinalSubables(customerId, formCode, resultTableName, conditions, null); return baseDao.dynamicQuery(customerId, resultTableName, conditions, map.get("finalSubTables"), null, - currentStaffAgencyId, Arrays.asList(staffOrgPath), map.get("groupByTables")); + currentStaffAgencyId, Arrays.asList(staffOrgPath), null,map.get("groupByTables")); } @NotNull @@ -2243,7 +2243,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl exportNeedTableList = showSqlColumns.stream().map(IcCustomExportResultDTO.SqlColumn::getTableName).collect(Collectors.toList()); Map> map = getFinalSubables(customerId, formCode, resultTableName, conditions, exportNeedTableList); return baseDao.dynamicQuery(customerId, resultTableName, conditions, map.get("finalSubTables"), showSqlColumns, - currentStaffAgencyId, Arrays.asList(staffOrgPath), map.get("groupByTables")); + currentStaffAgencyId, Arrays.asList(staffOrgPath), null, map.get("groupByTables")); } @Override From e202417a9d1eae3433eec93f10dc8e402cef467d Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 6 Apr 2023 17:52:34 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix=EF=BC=9A=E5=B1=85=E6=B0=91=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/service/IcResiUserService.java | 9 ++- .../impl/IcResiUserExportServiceImpl.java | 59 ++++++++++++++++--- .../service/impl/IcResiUserServiceImpl.java | 11 +++- 3 files changed, 69 insertions(+), 10 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index c29d0cb69d..563365d414 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -290,7 +290,14 @@ public interface IcResiUserService extends BaseService { */ List listHomeUserBrief(String houseId, String customerId); - List> dynamicQuery(String loginUserCustomerId, String formCode, String icResiUser, List showSqlColumns, List conditions, String agencyId, String finalStaffOrgPath); + List> dynamicQuery(String loginUserCustomerId, + String formCode, + String icResiUser, + List showSqlColumns, + List conditions, + String agencyId, + List finalStaffOrgPath, + List gridIds); /** * 租客房东黑名单查询个人数据 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java index ec754bb2b8..49ac9c8d2a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserExportServiceImpl.java @@ -20,7 +20,9 @@ import com.epmet.commons.tools.enums.FormItemTypeEnum; import com.epmet.commons.tools.enums.IcFormCodeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.utils.poi.excel.handler.ExcelFillCellMergeStrategy; @@ -159,14 +161,49 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { writeSheet = EasyExcel.writerSheet("Sheet1").head(exportConfigData.getHeaders()).build(); } - String staffOrgPath = null; - if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { - staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(StrConstant.COLON).concat(staffInfoCacheResult.getAgencyId()); + allShowColumns.addAll(exportConfigData.getHiddenSqlColumns()); + + // 组织和网格单独处理 + Set queryAgencyIdList = new HashSet<>(); + Set queryGridIdList = new HashSet<>(); + + // 将以下几列单独提出来,组合起来,放入集合,自动去重 + searchForm.getConditions().stream().forEach(c -> { + if (IcResiUserConstant.IC_RESI_USER.equals(c.getTableName()) && CollectionUtils.isNotEmpty(c.getColumnValue()) + && StringUtils.isNotBlank(c.getColumnValue().get(NumConstant.ZERO))) { + if ("AGENCY_IDS".equals(c.getColumnName())) { + queryAgencyIdList.addAll(c.getColumnValue()); + } else if ("GRID_IDS".equals(c.getColumnName())) { + queryGridIdList.addAll(c.getColumnValue()); + } else if ("AGENCY_ID".equals(c.getColumnName())) { + queryAgencyIdList.addAll(c.getColumnValue()); + } else if ("GRID_ID".equals(c.getColumnName())) { + queryGridIdList.addAll(c.getColumnValue()); + } + } + }); + + // 移除grid grids agencyId agencyIds四种字段,改为 + searchForm.getConditions().removeIf(o->IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && IcResiUserServiceImpl.ORG_FIELDS.contains(o.getColumnName())); + + //添加数据权限 + List staffOrgPaths; + //如果查询条件中 没有有居民表的agencyId,则查询该工作人员所属组织的信息 + if (queryAgencyIdList.isEmpty() && queryGridIdList.isEmpty()){ + String staffOrgPath = PidUtils.convertPid2OrgIdPath(staffInfoCacheResult.getAgencyId(), staffInfoCacheResult.getAgencyPIds()); + staffOrgPaths = Arrays.asList(staffOrgPath); } else { - staffOrgPath = staffInfoCacheResult.getAgencyId(); + // 将组织id列表,转化为组织orgIdPath列表 + staffOrgPaths = queryAgencyIdList.stream().map(agId -> { + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agId); + if (agencyInfo == null) { + String errorMsg = "查询机关单位失败:" + agId; + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg); + } + return PidUtils.convertPid2OrgIdPath(agId, agencyInfo.getPids()); + }).collect(Collectors.toList()); } - allShowColumns.addAll(exportConfigData.getHiddenSqlColumns()); do { if(StringUtils.isNotBlank(exportResiUserFormDTO.getId())){ ResiUserQueryValueDTO idCondition=new ResiUserQueryValueDTO(); @@ -183,9 +220,17 @@ public class IcResiUserExportServiceImpl implements IcResiUserExportService { searchForm.setConditions(conditions); } } - String finalStaffOrgPath = staffOrgPath; + List finalStaffOrgPath = staffOrgPaths; + List finalGridIds = new ArrayList<>(queryGridIdList); mapListPage = PageHelper.startPage(searchForm.getPageNo(), searchForm.getPageSize(), searchForm.getIsPage()).doSelectPage(() -> { - icResiUserService.dynamicQuery(searchForm.getCustomerId(), searchForm.getFormCode(), IcResiUserConstant.IC_RESI_USER, allShowColumns, searchForm.getConditions(), staffInfoCacheResult.getAgencyId(), finalStaffOrgPath); + icResiUserService.dynamicQuery(searchForm.getCustomerId(), + searchForm.getFormCode(), + IcResiUserConstant.IC_RESI_USER, + allShowColumns, + searchForm.getConditions(), + staffInfoCacheResult.getAgencyId(), + finalStaffOrgPath, + finalGridIds); }); if (!searchForm.getIsPage()){ searchForm.setPageNo(searchForm.getPageNo() + NumConstant.ONE); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index c4148c3d6b..c49ecc7554 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -2238,12 +2238,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl> dynamicQuery(String customerId, String formCode, String resultTableName, List showSqlColumns, List conditions, String currentStaffAgencyId, String staffOrgPath) { + public List> dynamicQuery(String customerId, + String formCode, + String resultTableName, + List showSqlColumns, + List conditions, + String currentStaffAgencyId, + List staffOrgPath, + List gridIds) { // List finalSubTables = getFinalSubables(customerId, formCode, resultTableName, conditions); List exportNeedTableList = showSqlColumns.stream().map(IcCustomExportResultDTO.SqlColumn::getTableName).collect(Collectors.toList()); Map> map = getFinalSubables(customerId, formCode, resultTableName, conditions, exportNeedTableList); return baseDao.dynamicQuery(customerId, resultTableName, conditions, map.get("finalSubTables"), showSqlColumns, - currentStaffAgencyId, Arrays.asList(staffOrgPath), null, map.get("groupByTables")); + currentStaffAgencyId, staffOrgPath, gridIds, map.get("groupByTables")); } @Override