Browse Source

Merge remote-tracking branch 'origin/yantai_zhengwu_master' into yantai_zhengwu_master

dev
yinzuomei 2 years ago
parent
commit
1c32c8a3da
  1. 27
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/PidUtils.java
  2. 11
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcNeighborHoodDTO.java
  3. 3
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyCountCensusResultDTO.java
  4. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  5. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java
  6. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  7. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  8. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
  9. 33
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  10. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  11. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java
  12. 27
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  13. 26
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcCoverageCategoryDictDao.xml
  14. 10
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffLoginLogDao.xml
  15. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java
  16. 165
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  17. 19
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

27
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/PidUtils.java

@ -0,0 +1,27 @@
package com.epmet.commons.tools.utils;
import org.apache.commons.lang3.StringUtils;
/**
* pid用到的工具
*/
public class PidUtils {
/**
* 将orgId和pids组合传话为orgIdPath(包含自己)
* @param orgId
* @param pids
* @return
*/
public static String convertPid2OrgIdPath(String orgId,String pids) {
StringBuilder orgIdPath = new StringBuilder();
if (StringUtils.isBlank(pids) || pids.equals("0")) {
orgIdPath.append(orgId);
} else {
orgIdPath.append(pids).append(":").append(orgId);
}
return orgIdPath.toString();
}
}

11
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/IcNeighborHoodDTO.java

@ -21,6 +21,7 @@ import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
@ -54,6 +55,11 @@ public class IcNeighborHoodDTO implements Serializable {
*/
private String agencyId;
/**
* agencyId列表
*/
private List<String> agencyIds;
/**
* 上级组织id
*/
@ -69,6 +75,11 @@ public class IcNeighborHoodDTO implements Serializable {
*/
private String gridId;
/**
* gridId列表
*/
private List<String> gridIds;
/**
* 网格
*/

3
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencyCountCensusResultDTO.java

@ -1,5 +1,7 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
@ -8,6 +10,7 @@ import java.io.Serializable;
* @Date 2023/4/6 16:46
* @Author lichao
**/
@Data
public class AgencyCountCensusResultDTO implements Serializable {
private static final long serialVersionUID = 4360690752084258055L;

11
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java

@ -517,7 +517,13 @@ public class CustomerAgencyController {
return customerAgencyService.getCurrentUserCommunityInfo(tokenDTO);
}
/**
* @Description: 返回下级数量统计
* @param agencyId:
* @Return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.AgencyCountCensusResultDTO>>
* @Author: lichao
* @Date: 2023/4/7 14:48
*/
@GetMapping("getAgencyCountList")
public Result<List<AgencyCountCensusResultDTO>> getAgencyCountList(@RequestParam String agencyId){
return new Result<List<AgencyCountCensusResultDTO>>().ok(customerAgencyService.getAgencyCountList(agencyId));
@ -525,4 +531,7 @@ public class CustomerAgencyController {
}

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java

@ -141,7 +141,7 @@ public class IcNeighborHoodController {
}
/**
* @Description 获取网格下小区列表
* @Description 获取组织/网格下小区列表支持单选和多选
* @Param dto
* @Return {@link Result< List< OptionResultDTO>>}
* @Author zhaoqifeng
@ -149,7 +149,13 @@ public class IcNeighborHoodController {
*/
@PostMapping("neighborhoodoption")
public Result<List<OptionResultDTO>> getNeighborHoodOptions(@LoginUser TokenDto tokenDto, @RequestBody IcNeighborHoodDTO dto) {
return new Result<List<OptionResultDTO>>().ok(icNeighborHoodService.getNeighborHoodOptions(dto.getAgencyId(), dto.getGridId(),tokenDto.getUserId(),tokenDto.getCustomerId()));
return new Result<List<OptionResultDTO>>().ok(icNeighborHoodService.getNeighborHoodOptions(
dto.getAgencyId(),
dto.getGridId(),
dto.getAgencyIds(),
dto.getGridIds(),
tokenDto.getUserId(),
tokenDto.getCustomerId()));
}
/**

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -430,6 +430,10 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
*/
List<AgencyResultDTO> getAllCommunity(String customerId);
Integer agencyCount(@Param("pids") String pids,@Param("level") String level);
List<AgencyCountCensusResultDTO> agencyCount(@Param("pids") String pids);
Integer agencyGridCount(@Param("pids") String pids);
Integer agencyStaffCount(@Param("pids") String pids);
}

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java

@ -362,5 +362,11 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @return
*/
String getOrgIdPath(String orgId);
/**
* 返回下级数量
* @param agencyId
* @return
*/
List<AgencyCountCensusResultDTO> getAgencyCountList(String agencyId);
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java

@ -117,7 +117,8 @@ public interface IcNeighborHoodService extends BaseService<IcNeighborHoodEntity>
* @Author zhaoqifeng
* @Date 2021/10/26 14:32
*/
List<OptionResultDTO> getNeighborHoodOptions(String agencyId, String gridId,String staffId,String customerId);
List<OptionResultDTO> getNeighborHoodOptions(String agencyId, String gridId, List<String> agencyIds, List<String> gridIds,
String staffId,String customerId);
/**
* 获取用户组织下小区列表

33
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -37,6 +37,7 @@ 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.ConvertUtils;
import com.epmet.commons.tools.utils.PidUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.constant.CustomerGridConstant;
@ -1624,6 +1625,14 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
}
return customerAgencyEntity.getPids().concat(StrConstant.COLON).concat(orgId);
}
/**
* @Description:
* @param agencyId:
* @Return java.util.List<com.epmet.dto.result.AgencyCountCensusResultDTO>
* @Author: lichao
* @Date: 2023/4/7 14:17
*/
@Override
public List<AgencyCountCensusResultDTO> getAgencyCountList(String agencyId) {
@ -1631,23 +1640,21 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
CustomerAgencyEntity customerAgency = baseDao.selectById(agencyId);
if (customerAgency != null){
// pidu
// 区县级
if (customerAgency.getLevel().equals("district")){
// Integer count = baseDao.agencyCount()
// 镇街级
}else if (customerAgency.getLevel().equals("street")){
}else{
}
String pids = PidUtils.convertPid2OrgIdPath(customerAgency.getId(),customerAgency.getPids());
agencyCountCensusResultDTOS = baseDao.agencyCount(pids);
AgencyCountCensusResultDTO agencyCountCensusResultDTOGrid = new AgencyCountCensusResultDTO();
agencyCountCensusResultDTOGrid.setLevel("grid");
agencyCountCensusResultDTOGrid.setCount(baseDao.agencyGridCount(pids));
agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOGrid);
AgencyCountCensusResultDTO agencyCountCensusResultDTOStaff = new AgencyCountCensusResultDTO();
agencyCountCensusResultDTOStaff.setLevel("staff");
agencyCountCensusResultDTOStaff.setCount(baseDao.agencyStaffCount(pids));
agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOStaff);
}else{
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取用户组织信息异常","获取用户组织信息异常");
}
return agencyCountCensusResultDTOS;
}

22
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java

@ -185,9 +185,14 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
* @Date 2021/10/26 14:32
*/
@Override
public List<OptionResultDTO> getNeighborHoodOptions(String agencyId, String gridId,String staffId,String customerId) {
if (StringUtils.isBlank(agencyId)&&StringUtils.isEmpty(gridId)) {
log.info("agencyId与gridId都为空时,默认查询当前工作人员所属组织下的小区");
public List<OptionResultDTO> getNeighborHoodOptions(String agencyId, String gridId,
List<String> agencyIds, List<String> gridIds,
String staffId,String customerId) {
if (StringUtils.isBlank(agencyId)
&& StringUtils.isEmpty(gridId)
&& CollectionUtils.isEmpty(agencyIds)
&& CollectionUtils.isEmpty(gridIds)) {
log.info("agencyId(s)与gridId(s)都为空时,默认查询当前工作人员所属组织下的小区");
CustomerStaffInfoCacheResult result = CustomerStaffRedis.getStaffInfo(customerId, staffId);
if (null == result || StringUtils.isBlank(result.getAgencyId())) {
log.error(String.format("staffId:%s,工作人员缓存信息查询异常", staffId));
@ -195,9 +200,16 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
}
agencyId = result.getAgencyId();
}
// 此处支持多种条件,or连接
LambdaQueryWrapper<IcNeighborHoodEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(agencyId),IcNeighborHoodEntity::getAgencyId, agencyId);
wrapper.eq(StringUtils.isNotBlank(gridId), IcNeighborHoodEntity::getGridId, gridId);
wrapper.eq(StringUtils.isNotBlank(agencyId), IcNeighborHoodEntity::getAgencyId, agencyId)
.or()
.eq(StringUtils.isNotBlank(gridId), IcNeighborHoodEntity::getGridId, gridId)
.or()
.in(!CollectionUtils.isEmpty(agencyIds), IcNeighborHoodEntity::getAgencyId, agencyIds)
.or()
.in(!CollectionUtils.isEmpty(gridIds), IcNeighborHoodEntity::getGridId, gridIds);
wrapper.last("ORDER BY CONVERT ( NEIGHBOR_HOOD_NAME USING gbk ) ASC");
List<IcNeighborHoodEntity> list = baseDao.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffLoginLogServiceImpl.java

@ -186,6 +186,12 @@ public class StaffLoginLogServiceImpl extends BaseServiceImpl<StaffLoginLogDao,
@Override
public PageData<AccountActivityInfo> getAccountActivityInfo(CountActivityFormDTO formDTO) {
if (formDTO.getIsPage()) {
List<AccountActivityInfo> accountActivityInfos = baseDao.selectListActivityInfo(formDTO);
int total = CollectionUtils.isEmpty(accountActivityInfos) ? NumConstant.ZERO : accountActivityInfos.size();
return new PageData<>(accountActivityInfos, total);
}
List<AccountActivityInfo> accountActivityInfos = baseDao.selectListActivityInfo(formDTO);
int total = CollectionUtils.isEmpty(accountActivityInfos) ? NumConstant.ZERO : accountActivityInfos.size();
return new PageData<>(accountActivityInfos, total);

27
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -863,13 +863,34 @@
AND CUSTOMER_ID = #{customerId}
AND pids LIKE concat('%',#{agencyId}, '%' )
</update>
<select id="agencyCount" resultType="java.lang.Integer">
<select id="agencyCount" resultType="com.epmet.dto.result.AgencyCountCensusResultDTO">
select count(*)
select level,count(*)
from customer_agency
where DEL_FLAG = 0
and LEVEL = #{level}
and PIDS like concat(#{pids},'%')
group by level
</select>
<select id="agencyGridCount" resultType="java.lang.Integer">
select count(*)
from customer_grid
where DEL_FLAG = 0
and PIDS like concat(#{pids},'%')
</select>
<select id="agencyStaffCount" resultType="java.lang.Integer">
select count(1)
from customer_staff_agency staff
left join customer_agency agency on staff.AGENCY_ID = agency.ID
where agency.DEL_FLAG = 0
and
staff.DEL_FLAG = 0
and agency.PIDS like concat(#{pids},'%')
</select>

26
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcCoverageCategoryDictDao.xml

@ -7,11 +7,14 @@
INSERT INTO ic_coverage_category_dict (
id,
customer_id,
category_key,
category_name,
place_type,
coverage_type,
sort,
CATEGORY_KEY,
CATEGORY_NAME,
PLACE_TYPE,
PLACE_TYPE_IN_ANALYSIS,
MENU_URL,
DATA_TYPE,
COVERAGE_TYPE,
SORT,
del_flag,
revision,
created_by,
@ -21,11 +24,14 @@
) SELECT
MD5(UUID()),
#{customerId},
category_key,
category_name,
place_type,
coverage_type,
sort,
CATEGORY_KEY,
CATEGORY_NAME,
PLACE_TYPE,
PLACE_TYPE_IN_ANALYSIS,
MENU_URL,
DATA_TYPE,
COVERAGE_TYPE,
SORT,
del_flag,
revision,
'APP_USER',

10
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/StaffLoginLogDao.xml

@ -176,13 +176,11 @@
customer_agency a
LEFT JOIN staff_login_log l ON a.ID = l.AGENCY_ID
WHERE
a.PIDS LIKE CONCAT(
'%',
#{orgId},
'%'
)
AND a.`LEVEL` = 'community'
a.`LEVEL` = 'community'
AND a.DEL_FLAG = '0'
<if test="orgId!= null and orgId.trim() != ''">
AND a.PIDS LIKE CONCAT('%',#{orgId},'%')
</if>
GROUP BY
a.ID
) t;

5
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java

@ -66,8 +66,9 @@ public interface IcResiUserDao extends BaseDao<IcResiUserEntity> {
@Param("conditions") List<ResiUserQueryValueDTO> conditions,
@Param("resultColumns") List<IcFormResColumnDTO> resultColumns,
@Param("subTables") List<String> subTables,
@Param("currentStaffAgencyId") String currentStaffAgencyId,
@Param("staffOrgPath") String staffOrgPath,
@Param("currentStaffAgencyId") List<String> currentStaffAgencyIds,
@Param("staffOrgPaths") List<String> staffOrgPaths,
@Param("gridIds") Set<String> gridIds,
@Param("resultTableName") String resultTableName,
@Param("keyword") String keyword,
@Param("groupByTables") Set<String> groupByTables);

165
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -181,7 +181,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
@Autowired
private IcVaccineRelationDao icVaccineRelationDao;
/**
* 组织字段目前用于居民信息动态查询接口将此条件从conditions中移除单独生成固定的sql片段
*/
public static final List<String> ORG_FIELDS = Arrays.asList("AGENCY_IDS", "GRID_IDS", "AGENCY_ID", "GRID_ID");
private QueryWrapper<IcResiUserEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
@ -918,36 +921,55 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData();
// 查询结果列对应的表:
Set<String> resultColumnTables = resultColumns.stream().map(IcFormResColumnDTO::getTableName).collect(Collectors.toSet());
List<String> queryAgencyIdList = formDTO.getConditions().stream()
.filter(o -> IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_ID".equals(o.getColumnName())
&& CollectionUtils.isNotEmpty(o.getColumnValue()) && StringUtils.isNotBlank(o.getColumnValue().get(NumConstant.ZERO)))
.flatMap(o -> o.getColumnValue().stream()).collect(Collectors.toList());
// List<String> queryAgencyIdList = formDTO.getConditions().stream()
// .filter(o -> IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_IDS".equals(o.getColumnName())
// && CollectionUtils.isNotEmpty(o.getColumnValue()) && StringUtils.isNotBlank(o.getColumnValue().get(NumConstant.ZERO)))
// .flatMap(o -> o.getColumnValue().stream()).collect(Collectors.toList());
// 组织和网格单独处理
Set<String> queryAgencyIdList = new HashSet<>();
Set<String> queryGridIdList = new HashSet<>();
// 将以下几列单独提出来,组合起来,放入集合,自动去重
formDTO.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());
}
}
});
// 移除需要特殊处理的conditions
formDTO.getConditions().removeIf(o->IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && ORG_FIELDS.contains(o.getColumnName()));
//添加数据权限
String staffOrgPath;
String agencyId;
//如果查询条件中 有居民表的agencyId 则匹配查询该组织下的 数据
if (queryAgencyIdList.isEmpty()){
List<String> staffOrgPaths;
List<String> agencyIds = null;
//如果查询条件中 没有有居民表的agencyId,则查询该工作人员所属组织的信息
if (queryAgencyIdList.isEmpty() && queryGridIdList.isEmpty()){
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
agencyId = staffInfoCacheResult.getAgencyId();
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId());
} else {
staffOrgPath = staffInfoCacheResult.getAgencyId();
}
agencyIds = Arrays.asList(staffInfoCacheResult.getAgencyId());
String op = PidUtils.convertPid2OrgIdPath(staffInfoCacheResult.getAgencyId(), staffInfoCacheResult.getAgencyPIds());
staffOrgPaths = Arrays.asList(op);
} else {
formDTO.getConditions().removeIf(o->IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_ID".equals(o.getColumnName()));
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(queryAgencyIdList.get(NumConstant.ZERO));
// 将组织id列表,转化为组织orgIdPath列表
staffOrgPaths = queryAgencyIdList.stream().map(agId -> {
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agId);
if (agencyInfo == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取组织信息失败");
}
agencyId = agencyInfo.getId();
staffOrgPath = agencyInfo.getPids();
if (StringUtils.isBlank(staffOrgPath)){
staffOrgPath = agencyId;
}else{
staffOrgPath = staffOrgPath+StrConstant.COLON+agencyInfo.getId();
String errorMsg = "查询机关单位失败:" + agId;
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
return PidUtils.convertPid2OrgIdPath(agId, agencyInfo.getPids());
}).collect(Collectors.toList());
}
// 查询列表展示项需要用到哪些子表
Result<List<SubTableJoinDTO>> subTablesRes = operCustomizeOpenFeignClient.querySubTables(queryDTO1);
@ -976,14 +998,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>();
if (null == formDTO.getIsPage() || formDTO.getIsPage()) {
//分页
String finalStaffOrgPath = staffOrgPath;
List<String> finalStaffOrgPath = staffOrgPaths;
List<String> finalAgencyIds = agencyIds;
pageInfo = PageHelper.startPage(formDTO.getPageNo(),
formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectListResiMap(formDTO.getCustomerId(),
formDTO.getFormCode(),
formDTO.getConditions(),
resultColumns,
finalSubTables,
agencyId, finalStaffOrgPath,null, formDTO.getKeyword(),
finalAgencyIds,
finalStaffOrgPath,
queryGridIdList,
null,
formDTO.getKeyword(),
groupByTables));
} else {
List<Map<String, Object>> list = baseDao.selectListResiMap(formDTO.getCustomerId(),
@ -991,8 +1018,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
formDTO.getConditions(),
resultColumns,
finalSubTables,
agencyId,
staffOrgPath,null,
agencyIds,
staffOrgPaths,
queryGridIdList,
null,
formDTO.getKeyword(),
groupByTables);
pageInfo.setTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size());
@ -3320,37 +3349,52 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData();
// 查询结果列对应的表:
Set<String> resultColumnTables = resultColumns.stream().map(IcFormResColumnDTO::getTableName).collect(Collectors.toSet());
List<String> queryAgencyIdList = formDTO.getConditions().stream()
.filter(o -> IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_ID".equals(o.getColumnName())
&& CollectionUtils.isNotEmpty(o.getColumnValue()) && StringUtils.isNotBlank(o.getColumnValue().get(NumConstant.ZERO)))
.flatMap(o -> o.getColumnValue().stream()).collect(Collectors.toList());
// 组织和网格单独处理
Set<String> queryAgencyIdList = new HashSet<>();
Set<String> queryGridIdList = new HashSet<>();
// 将以下几列单独提出来,组合起来,放入列表
formDTO.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());
}
}
});
// 移除需要特殊处理的conditions
formDTO.getConditions().removeIf(o->IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && ORG_FIELDS.contains(o.getColumnName()));
//添加数据权限
String staffOrgPath;
String agencyId;
//如果查询条件中 有居民表的agencyId 则匹配查询该组织下的 数据
if (queryAgencyIdList.isEmpty()){
List<String> staffOrgPaths;
List<String> agencyIds = null;
//如果查询条件中 没有有居民表的agencyId,则查询该工作人员所属组织的信息
if (queryAgencyIdList.isEmpty() && queryGridIdList.isEmpty()){
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
agencyId = staffInfoCacheResult.getAgencyId();
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId());
} else {
staffOrgPath = staffInfoCacheResult.getAgencyId();
}
agencyIds = Arrays.asList(staffInfoCacheResult.getAgencyId());
String op = PidUtils.convertPid2OrgIdPath(staffInfoCacheResult.getAgencyId(), staffInfoCacheResult.getAgencyPIds());
staffOrgPaths = Arrays.asList(op);
} else {
formDTO.getConditions().removeIf(o->IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_ID".equals(o.getColumnName()));
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(queryAgencyIdList.get(NumConstant.ZERO));
// 将组织id列表,转化为组织orgIdPath列表
staffOrgPaths = queryAgencyIdList.stream().map(agId -> {
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agId);
if (agencyInfo == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取组织信息失败");
}
agencyId = agencyInfo.getId();
staffOrgPath = agencyInfo.getPids();
if (StringUtils.isBlank(staffOrgPath)){
staffOrgPath = agencyId;
}else{
staffOrgPath = staffOrgPath+StrConstant.COLON+agencyInfo.getId();
String errorMsg = "查询机关单位失败:" + agId;
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
return PidUtils.convertPid2OrgIdPath(agId, agencyInfo.getPids());
}).collect(Collectors.toList());
}
// 查询列表展示项需要用到哪些子表
Result<List<SubTableJoinDTO>> subTablesRes = operCustomizeOpenFeignClient.querySubTables(queryDTO1);
List<SubTableJoinDTO> subTables = subTablesRes.getData();
@ -3378,14 +3422,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>();
if (null == formDTO.getIsPage() || formDTO.getIsPage()) {
//分页
String finalStaffOrgPath = staffOrgPath;
List<String> finalStaffOrgPath = staffOrgPaths;
List<String> finalAgencyIds = agencyIds;
pageInfo = PageHelper.startPage(formDTO.getPageNo(),
formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectListResiMap(formDTO.getCustomerId(),
formDTO.getFormCode(),
formDTO.getConditions(),
resultColumns,
finalSubTables,
agencyId, finalStaffOrgPath,null, formDTO.getKeyword(),
finalAgencyIds,
finalStaffOrgPath,
queryGridIdList,
null,
formDTO.getKeyword(),
groupByTables));
} else {
List<Map<String, Object>> list = baseDao.selectListResiMap(formDTO.getCustomerId(),
@ -3393,8 +3442,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
formDTO.getConditions(),
resultColumns,
finalSubTables,
agencyId,
staffOrgPath,null,
agencyIds,
staffOrgPaths,
queryGridIdList,
null,
formDTO.getKeyword(),
groupByTables);
pageInfo.setTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size());

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

@ -90,7 +90,24 @@
<if test="resultTableName != null and resultTableName != ''">
AND ${resultTableName}.ID IS NOT NULL
</if>
and ic_resi_user.pids like concat(#{staffOrgPath},'%')
<!-- orgIdPath过滤 -->
and (
<foreach collection="staffOrgPaths" item="orgIdPath" separator="or">
ic_resi_user.pids like concat(#{orgIdPath},'%')
</foreach>
<if test='staffOrgPaths != null and staffOrgPaths.size() > 0 and gridIds != null and gridIds.size() > 0'>
or
</if>
<!-- 网格id过滤 -->
<if test="gridIds != null and gridIds.size() > 0">
ic_resi_user.GRID_ID in (
<foreach collection="gridIds" item="gridId" separator=",">
#{gridId}
</foreach>
)
</if>
)
<if test="null != conditions and conditions.size() > 0">
<foreach item="subCondition" collection="conditions" open="" separator="" close="">
<if test="null != subCondition.columnValue and subCondition.columnValue.size() > 0">

Loading…
Cancel
Save