generated from dxfeng/secondev-wugang-dxfeng
refactor(backend): 优化部门查询逻辑
- 注释掉 ManagerPortalMapper.xml 中的部门 ID 查询条件 - 修改 getPerformanceInfo 查询中的字段名 - 优化 ManagerPortalServiceImpl 中的部门查询逻辑 - 增加对部门 ID 的非空判断 - 查询所属部门及其子部门 - 两个 set 取交集以获取最终的部门列表 - 如果没有找到相关部门,则返回 -1L - 在返回结果中添加当前页码和页面大小信息
This commit is contained in:
parent
1661fced35
commit
4cb3919e70
|
|
@ -24,6 +24,7 @@ import com.weaver.teams.security.user.User;
|
||||||
import com.weaver.workflow.common.cfg.org.service.DepartMentService;
|
import com.weaver.workflow.common.cfg.org.service.DepartMentService;
|
||||||
import com.weaver.workflow.common.entity.org.WeaDepartMent;
|
import com.weaver.workflow.common.entity.org.WeaDepartMent;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -252,9 +253,25 @@ public class ManagerPortalServiceImpl implements ManagerPortalService {
|
||||||
basicPersonnelParam.setCurrent(current);
|
basicPersonnelParam.setCurrent(current);
|
||||||
basicPersonnelParam.setPageSize(pageSize);
|
basicPersonnelParam.setPageSize(pageSize);
|
||||||
basicPersonnelParam.setSearchKey(searchKey);
|
basicPersonnelParam.setSearchKey(searchKey);
|
||||||
|
//log.error("departmentId==={}", departmentId);
|
||||||
basicPersonnelParam.setDepartmentId(departmentId);
|
basicPersonnelParam.setDepartmentId(departmentId);
|
||||||
Set<Long> allDepartmentIdList = getAllDepartmentIdList(basicPersonnelParam, currentUser.getEmployeeId());
|
Set<Long> allDepartmentIdList = getAllDepartmentIdList(basicPersonnelParam, currentUser.getEmployeeId());
|
||||||
|
//log.error("allDepartmentIdList111==={}", JSON.toJSONString(allDepartmentIdList));
|
||||||
basicPersonnelParam.setDepartmentIdList(allDepartmentIdList);
|
basicPersonnelParam.setDepartmentIdList(allDepartmentIdList);
|
||||||
|
if (StringUtils.isNotBlank(departmentId)) {
|
||||||
|
List<WeaDepartMent> beLongDeps = departMentService.getBeLongDeps(Long.parseLong(departmentId));
|
||||||
|
Set<Long> collect = beLongDeps.stream().map(WeaDepartMent::getDepartMentId).collect(Collectors.toSet());
|
||||||
|
collect.add(Long.parseLong(departmentId));
|
||||||
|
// 两个set取交集
|
||||||
|
allDepartmentIdList.retainAll(collect);
|
||||||
|
//log.error("collect==={}", JSON.toJSONString(collect));
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(allDepartmentIdList)) {
|
||||||
|
allDepartmentIdList.add(-1L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//log.error("allDepartmentIdList222==={}", JSON.toJSONString(allDepartmentIdList));
|
||||||
|
|
||||||
|
|
||||||
List<TeamEmployeePo> teamEmployee = managerPortalMapper.getTeamEmployee(basicPersonnelParam);
|
List<TeamEmployeePo> teamEmployee = managerPortalMapper.getTeamEmployee(basicPersonnelParam);
|
||||||
int total = managerPortalMapper.getTeamEmployeeTotal(basicPersonnelParam);
|
int total = managerPortalMapper.getTeamEmployeeTotal(basicPersonnelParam);
|
||||||
|
|
@ -263,6 +280,8 @@ public class ManagerPortalServiceImpl implements ManagerPortalService {
|
||||||
Map<String, Object> returnMap = new HashMap<>();
|
Map<String, Object> returnMap = new HashMap<>();
|
||||||
returnMap.put("list", teamEmployee);
|
returnMap.put("list", teamEmployee);
|
||||||
returnMap.put("total", total);
|
returnMap.put("total", total);
|
||||||
|
returnMap.put("current", current);
|
||||||
|
returnMap.put("pageSize", pageSize);
|
||||||
|
|
||||||
return WeaResult.success(returnMap);
|
return WeaResult.success(returnMap);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -217,9 +217,9 @@
|
||||||
#{departmentId}
|
#{departmentId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="departmentId != null and departmentId != ''">
|
<!-- <if test="departmentId != null and departmentId != ''">-->
|
||||||
and t.department = #{departmentId}
|
<!-- and t.department = #{departmentId}-->
|
||||||
</if>
|
<!-- </if>-->
|
||||||
|
|
||||||
<if test="searchKey != null and searchKey != ''">
|
<if test="searchKey != null and searchKey != ''">
|
||||||
and (t.username like concat('%',#{searchKey},'%') or t.job_num like concat('%',#{searchKey},'%'))
|
and (t.username like concat('%',#{searchKey},'%') or t.job_num like concat('%',#{searchKey},'%'))
|
||||||
|
|
@ -239,16 +239,16 @@
|
||||||
#{departmentId}
|
#{departmentId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="departmentId != null and departmentId != ''">
|
<!-- <if test="departmentId != null and departmentId != ''">-->
|
||||||
and t.department = #{departmentId}
|
<!-- and t.department = #{departmentId}-->
|
||||||
</if>
|
<!-- </if>-->
|
||||||
<if test="searchKey != null and searchKey != ''">
|
<if test="searchKey != null and searchKey != ''">
|
||||||
and (t.username like concat('%',#{searchKey},'%') or t.job_num like concat('%',#{searchKey},'%'))
|
and (t.username like concat('%',#{searchKey},'%') or t.job_num like concat('%',#{searchKey},'%'))
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
<select id="getPerformanceInfo" resultType="com.weaver.seconddev.portal.entity.po.PortalPO">
|
<select id="getPerformanceInfo" resultType="com.weaver.seconddev.portal.entity.po.PortalPO">
|
||||||
select count(t.id) as value , t.ppdj as id
|
select count(t.id) as value , t.ppdj as name
|
||||||
from ${e10_common}.uf_jxsjtz t
|
from ${e10_common}.uf_jxsjtz t
|
||||||
where t.delete_type = 0 and t.tenant_key = #{tenantKey}
|
where t.delete_type = 0 and t.tenant_key = #{tenantKey}
|
||||||
and t.khnf = #{belongYear} and t.khzq = #{searchKey}
|
and t.khnf = #{belongYear} and t.khzq = #{searchKey}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue