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. 28
      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. 169
      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.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
@ -54,6 +55,11 @@ public class IcNeighborHoodDTO implements Serializable {
*/ */
private String agencyId; private String agencyId;
/**
* agencyId列表
*/
private List<String> agencyIds;
/** /**
* 上级组织id * 上级组织id
*/ */
@ -69,6 +75,11 @@ public class IcNeighborHoodDTO implements Serializable {
*/ */
private String gridId; 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; package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -8,6 +10,7 @@ import java.io.Serializable;
* @Date 2023/4/6 16:46 * @Date 2023/4/6 16:46
* @Author lichao * @Author lichao
**/ **/
@Data
public class AgencyCountCensusResultDTO implements Serializable { public class AgencyCountCensusResultDTO implements Serializable {
private static final long serialVersionUID = 4360690752084258055L; 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); 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") @GetMapping("getAgencyCountList")
public Result<List<AgencyCountCensusResultDTO>> getAgencyCountList(@RequestParam String agencyId){ public Result<List<AgencyCountCensusResultDTO>> getAgencyCountList(@RequestParam String agencyId){
return new Result<List<AgencyCountCensusResultDTO>>().ok(customerAgencyService.getAgencyCountList(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 * @Param dto
* @Return {@link Result< List< OptionResultDTO>>} * @Return {@link Result< List< OptionResultDTO>>}
* @Author zhaoqifeng * @Author zhaoqifeng
@ -149,7 +149,13 @@ public class IcNeighborHoodController {
*/ */
@PostMapping("neighborhoodoption") @PostMapping("neighborhoodoption")
public Result<List<OptionResultDTO>> getNeighborHoodOptions(@LoginUser TokenDto tokenDto, @RequestBody IcNeighborHoodDTO dto) { 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); 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 * @return
*/ */
String getOrgIdPath(String orgId); String getOrgIdPath(String orgId);
/**
* 返回下级数量
* @param agencyId
* @return
*/
List<AgencyCountCensusResultDTO> getAgencyCountList(String agencyId); 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 * @Author zhaoqifeng
* @Date 2021/10/26 14:32 * @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.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.PidUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant; import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.constant.CustomerGridConstant; import com.epmet.constant.CustomerGridConstant;
@ -1624,6 +1625,14 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
} }
return customerAgencyEntity.getPids().concat(StrConstant.COLON).concat(orgId); 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 @Override
public List<AgencyCountCensusResultDTO> getAgencyCountList(String agencyId) { public List<AgencyCountCensusResultDTO> getAgencyCountList(String agencyId) {
@ -1631,23 +1640,21 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
CustomerAgencyEntity customerAgency = baseDao.selectById(agencyId); CustomerAgencyEntity customerAgency = baseDao.selectById(agencyId);
if (customerAgency != null){ if (customerAgency != null){
// pidu String pids = PidUtils.convertPid2OrgIdPath(customerAgency.getId(),customerAgency.getPids());
// 区县级 agencyCountCensusResultDTOS = baseDao.agencyCount(pids);
if (customerAgency.getLevel().equals("district")){ AgencyCountCensusResultDTO agencyCountCensusResultDTOGrid = new AgencyCountCensusResultDTO();
// Integer count = baseDao.agencyCount() agencyCountCensusResultDTOGrid.setLevel("grid");
// 镇街级 agencyCountCensusResultDTOGrid.setCount(baseDao.agencyGridCount(pids));
}else if (customerAgency.getLevel().equals("street")){ agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOGrid);
AgencyCountCensusResultDTO agencyCountCensusResultDTOStaff = new AgencyCountCensusResultDTO();
}else{ agencyCountCensusResultDTOStaff.setLevel("staff");
agencyCountCensusResultDTOStaff.setCount(baseDao.agencyStaffCount(pids));
agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOStaff);
}
}else{ }else{
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取用户组织信息异常","获取用户组织信息异常"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取用户组织信息异常","获取用户组织信息异常");
} }
return agencyCountCensusResultDTOS; return agencyCountCensusResultDTOS;
} }

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

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

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 @Override
public PageData<AccountActivityInfo> getAccountActivityInfo(CountActivityFormDTO formDTO) { 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); List<AccountActivityInfo> accountActivityInfos = baseDao.selectListActivityInfo(formDTO);
int total = CollectionUtils.isEmpty(accountActivityInfos) ? NumConstant.ZERO : accountActivityInfos.size(); int total = CollectionUtils.isEmpty(accountActivityInfos) ? NumConstant.ZERO : accountActivityInfos.size();
return new PageData<>(accountActivityInfos, total); 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 CUSTOMER_ID = #{customerId}
AND pids LIKE concat('%',#{agencyId}, '%' ) AND pids LIKE concat('%',#{agencyId}, '%' )
</update> </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 from customer_agency
where DEL_FLAG = 0 where DEL_FLAG = 0
and LEVEL = #{level}
and PIDS like concat(#{pids},'%') 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> </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 ( INSERT INTO ic_coverage_category_dict (
id, id,
customer_id, customer_id,
category_key, CATEGORY_KEY,
category_name, CATEGORY_NAME,
place_type, PLACE_TYPE,
coverage_type, PLACE_TYPE_IN_ANALYSIS,
sort, MENU_URL,
DATA_TYPE,
COVERAGE_TYPE,
SORT,
del_flag, del_flag,
revision, revision,
created_by, created_by,
@ -21,11 +24,14 @@
) SELECT ) SELECT
MD5(UUID()), MD5(UUID()),
#{customerId}, #{customerId},
category_key, CATEGORY_KEY,
category_name, CATEGORY_NAME,
place_type, PLACE_TYPE,
coverage_type, PLACE_TYPE_IN_ANALYSIS,
sort, MENU_URL,
DATA_TYPE,
COVERAGE_TYPE,
SORT,
del_flag, del_flag,
revision, revision,
'APP_USER', 'APP_USER',

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

@ -176,13 +176,11 @@
customer_agency a customer_agency a
LEFT JOIN staff_login_log l ON a.ID = l.AGENCY_ID LEFT JOIN staff_login_log l ON a.ID = l.AGENCY_ID
WHERE WHERE
a.PIDS LIKE CONCAT( a.`LEVEL` = 'community'
'%',
#{orgId},
'%'
)
AND a.`LEVEL` = 'community'
AND a.DEL_FLAG = '0' AND a.DEL_FLAG = '0'
<if test="orgId!= null and orgId.trim() != ''">
AND a.PIDS LIKE CONCAT('%',#{orgId},'%')
</if>
GROUP BY GROUP BY
a.ID a.ID
) t; ) 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("conditions") List<ResiUserQueryValueDTO> conditions,
@Param("resultColumns") List<IcFormResColumnDTO> resultColumns, @Param("resultColumns") List<IcFormResColumnDTO> resultColumns,
@Param("subTables") List<String> subTables, @Param("subTables") List<String> subTables,
@Param("currentStaffAgencyId") String currentStaffAgencyId, @Param("currentStaffAgencyId") List<String> currentStaffAgencyIds,
@Param("staffOrgPath") String staffOrgPath, @Param("staffOrgPaths") List<String> staffOrgPaths,
@Param("gridIds") Set<String> gridIds,
@Param("resultTableName") String resultTableName, @Param("resultTableName") String resultTableName,
@Param("keyword") String keyword, @Param("keyword") String keyword,
@Param("groupByTables") Set<String> groupByTables); @Param("groupByTables") Set<String> groupByTables);

169
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 @Autowired
private IcVaccineRelationDao icVaccineRelationDao; 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) { private QueryWrapper<IcResiUserEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP); String id = (String) params.get(FieldConstant.ID_HUMP);
@ -918,36 +921,55 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData(); List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData();
// 查询结果列对应的表: // 查询结果列对应的表:
Set<String> resultColumnTables = resultColumns.stream().map(IcFormResColumnDTO::getTableName).collect(Collectors.toSet()); 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()) // List<String> queryAgencyIdList = formDTO.getConditions().stream()
&& CollectionUtils.isNotEmpty(o.getColumnValue()) && StringUtils.isNotBlank(o.getColumnValue().get(NumConstant.ZERO))) // .filter(o -> IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_IDS".equals(o.getColumnName())
.flatMap(o -> o.getColumnValue().stream()).collect(Collectors.toList()); // && 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; List<String> staffOrgPaths;
String agencyId; List<String> agencyIds = null;
//如果查询条件中 有居民表的agencyId 则匹配查询该组织下的 数据 //如果查询条件中 没有有居民表的agencyId,则查询该工作人员所属组织的信息
if (queryAgencyIdList.isEmpty()){ if (queryAgencyIdList.isEmpty() && queryGridIdList.isEmpty()){
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
agencyId = staffInfoCacheResult.getAgencyId(); agencyIds = Arrays.asList(staffInfoCacheResult.getAgencyId());
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); String op = PidUtils.convertPid2OrgIdPath(staffInfoCacheResult.getAgencyId(), staffInfoCacheResult.getAgencyPIds());
} else { staffOrgPaths = Arrays.asList(op);
staffOrgPath = staffInfoCacheResult.getAgencyId();
}
} else { } else {
formDTO.getConditions().removeIf(o->IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_ID".equals(o.getColumnName())); // 将组织id列表,转化为组织orgIdPath列表
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(queryAgencyIdList.get(NumConstant.ZERO)); staffOrgPaths = queryAgencyIdList.stream().map(agId -> {
if (agencyInfo == null){ AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agId);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取组织信息失败"); if (agencyInfo == null) {
} String errorMsg = "查询机关单位失败:" + agId;
agencyId = agencyInfo.getId(); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
staffOrgPath = agencyInfo.getPids();
if (StringUtils.isBlank(staffOrgPath)){
staffOrgPath = agencyId;
}else{
staffOrgPath = staffOrgPath+StrConstant.COLON+agencyInfo.getId();
} }
return PidUtils.convertPid2OrgIdPath(agId, agencyInfo.getPids());
}).collect(Collectors.toList());
} }
// 查询列表展示项需要用到哪些子表 // 查询列表展示项需要用到哪些子表
Result<List<SubTableJoinDTO>> subTablesRes = operCustomizeOpenFeignClient.querySubTables(queryDTO1); 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<>(); PageInfo<Map<String, Object>> pageInfo = new PageInfo<>();
if (null == formDTO.getIsPage() || formDTO.getIsPage()) { if (null == formDTO.getIsPage() || formDTO.getIsPage()) {
//分页 //分页
String finalStaffOrgPath = staffOrgPath; List<String> finalStaffOrgPath = staffOrgPaths;
List<String> finalAgencyIds = agencyIds;
pageInfo = PageHelper.startPage(formDTO.getPageNo(), pageInfo = PageHelper.startPage(formDTO.getPageNo(),
formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectListResiMap(formDTO.getCustomerId(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectListResiMap(formDTO.getCustomerId(),
formDTO.getFormCode(), formDTO.getFormCode(),
formDTO.getConditions(), formDTO.getConditions(),
resultColumns, resultColumns,
finalSubTables, finalSubTables,
agencyId, finalStaffOrgPath,null, formDTO.getKeyword(), finalAgencyIds,
finalStaffOrgPath,
queryGridIdList,
null,
formDTO.getKeyword(),
groupByTables)); groupByTables));
} else { } else {
List<Map<String, Object>> list = baseDao.selectListResiMap(formDTO.getCustomerId(), List<Map<String, Object>> list = baseDao.selectListResiMap(formDTO.getCustomerId(),
@ -991,8 +1018,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
formDTO.getConditions(), formDTO.getConditions(),
resultColumns, resultColumns,
finalSubTables, finalSubTables,
agencyId, agencyIds,
staffOrgPath,null, staffOrgPaths,
queryGridIdList,
null,
formDTO.getKeyword(), formDTO.getKeyword(),
groupByTables); groupByTables);
pageInfo.setTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size()); 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(); List<IcFormResColumnDTO> resultColumns = resultColumnRes.getData();
// 查询结果列对应的表: // 查询结果列对应的表:
Set<String> resultColumnTables = resultColumns.stream().map(IcFormResColumnDTO::getTableName).collect(Collectors.toSet()); 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))) Set<String> queryAgencyIdList = new HashSet<>();
.flatMap(o -> o.getColumnValue().stream()).collect(Collectors.toList()); 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; List<String> staffOrgPaths;
String agencyId; List<String> agencyIds = null;
//如果查询条件中 有居民表的agencyId 则匹配查询该组织下的 数据 //如果查询条件中 没有有居民表的agencyId,则查询该工作人员所属组织的信息
if (queryAgencyIdList.isEmpty()){ if (queryAgencyIdList.isEmpty() && queryGridIdList.isEmpty()){
CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId());
agencyId = staffInfoCacheResult.getAgencyId(); agencyIds = Arrays.asList(staffInfoCacheResult.getAgencyId());
if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) {
staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); String op = PidUtils.convertPid2OrgIdPath(staffInfoCacheResult.getAgencyId(), staffInfoCacheResult.getAgencyPIds());
} else { staffOrgPaths = Arrays.asList(op);
staffOrgPath = staffInfoCacheResult.getAgencyId();
}
} else { } else {
formDTO.getConditions().removeIf(o->IcResiUserConstant.IC_RESI_USER.equals(o.getTableName()) && "AGENCY_ID".equals(o.getColumnName())); // 将组织id列表,转化为组织orgIdPath列表
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(queryAgencyIdList.get(NumConstant.ZERO)); staffOrgPaths = queryAgencyIdList.stream().map(agId -> {
if (agencyInfo == null){ AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(agId);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取组织信息失败"); if (agencyInfo == null) {
} String errorMsg = "查询机关单位失败:" + agId;
agencyId = agencyInfo.getId(); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
staffOrgPath = agencyInfo.getPids();
if (StringUtils.isBlank(staffOrgPath)){
staffOrgPath = agencyId;
}else{
staffOrgPath = staffOrgPath+StrConstant.COLON+agencyInfo.getId();
} }
return PidUtils.convertPid2OrgIdPath(agId, agencyInfo.getPids());
}).collect(Collectors.toList());
} }
// 查询列表展示项需要用到哪些子表 // 查询列表展示项需要用到哪些子表
Result<List<SubTableJoinDTO>> subTablesRes = operCustomizeOpenFeignClient.querySubTables(queryDTO1); Result<List<SubTableJoinDTO>> subTablesRes = operCustomizeOpenFeignClient.querySubTables(queryDTO1);
List<SubTableJoinDTO> subTables = subTablesRes.getData(); List<SubTableJoinDTO> subTables = subTablesRes.getData();
@ -3378,14 +3422,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(); PageInfo<Map<String, Object>> pageInfo = new PageInfo<>();
if (null == formDTO.getIsPage() || formDTO.getIsPage()) { if (null == formDTO.getIsPage() || formDTO.getIsPage()) {
//分页 //分页
String finalStaffOrgPath = staffOrgPath; List<String> finalStaffOrgPath = staffOrgPaths;
List<String> finalAgencyIds = agencyIds;
pageInfo = PageHelper.startPage(formDTO.getPageNo(), pageInfo = PageHelper.startPage(formDTO.getPageNo(),
formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectListResiMap(formDTO.getCustomerId(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectListResiMap(formDTO.getCustomerId(),
formDTO.getFormCode(), formDTO.getFormCode(),
formDTO.getConditions(), formDTO.getConditions(),
resultColumns, resultColumns,
finalSubTables, finalSubTables,
agencyId, finalStaffOrgPath,null, formDTO.getKeyword(), finalAgencyIds,
finalStaffOrgPath,
queryGridIdList,
null,
formDTO.getKeyword(),
groupByTables)); groupByTables));
} else { } else {
List<Map<String, Object>> list = baseDao.selectListResiMap(formDTO.getCustomerId(), List<Map<String, Object>> list = baseDao.selectListResiMap(formDTO.getCustomerId(),
@ -3393,8 +3442,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
formDTO.getConditions(), formDTO.getConditions(),
resultColumns, resultColumns,
finalSubTables, finalSubTables,
agencyId, agencyIds,
staffOrgPath,null, staffOrgPaths,
queryGridIdList,
null,
formDTO.getKeyword(), formDTO.getKeyword(),
groupByTables); groupByTables);
pageInfo.setTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.size()); 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 != ''"> <if test="resultTableName != null and resultTableName != ''">
AND ${resultTableName}.ID IS NOT NULL AND ${resultTableName}.ID IS NOT NULL
</if> </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"> <if test="null != conditions and conditions.size() > 0">
<foreach item="subCondition" collection="conditions" open="" separator="" close=""> <foreach item="subCondition" collection="conditions" open="" separator="" close="">
<if test="null != subCondition.columnValue and subCondition.columnValue.size() > 0"> <if test="null != subCondition.columnValue and subCondition.columnValue.size() > 0">

Loading…
Cancel
Save