Browse Source

【通讯录】组织/部门/网格下人员列表

dev_shibei_match
sunyuchao 4 years ago
parent
commit
d95c654291
  1. 39
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java
  2. 12
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/OrgStaffListResultDTO.java
  3. 12
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java
  4. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/CustomerStaffDao.java
  5. 6
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerStaffAgencyDao.java
  6. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  7. 14
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  8. 2
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  9. 24
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  10. 59
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml
  11. 38
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml

39
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java

@ -1,9 +1,12 @@
package com.epmet.dataaggre.dto.govorg.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* @Description 通讯录组织/部门/网格下人员列表-接口入参
@ -12,20 +15,30 @@ import java.io.Serializable;
@Data
public class OrgStaffListFormDTO implements Serializable {
private static final long serialVersionUID = -1974456701949979946L;
@NotBlank(message = "parentAgencyId不能为空",groups = AddUserInternalGroup.class)
private String parentAgencyId;
private String areaCode;
/**
* 社区级community
* 街道:street,
* 区县级: district,
* 市级: city
* 省级:province
* 组织部门网格Id
*/
@NotBlank(message = "level不能为空",groups = AddUserInternalGroup.class)
private String level;
public interface AddUserInternalGroup {
}
@NotBlank(message = "类型Id不能为空", groups = OrgStaffListFormDTO.OrgStaff.class)
private String orgId;
/**
* 类型组织:agency 部门:dept 网格:grid
*/
@NotBlank(message = "类型不能为空", groups = OrgStaffListFormDTO.OrgStaff.class)
private String orgType;
/**
* 页码从1开始
*/
@Min(value = 1, message = "页码必须大于0", groups = OrgStaffListFormDTO.OrgStaff.class)
private Integer pageNo;
/**
* 页容量默认10页
*/
@Min(value = 1, message = "每页条数必须大于0", groups = OrgStaffListFormDTO.OrgStaff.class)
private Integer pageSize = 10;
//客户Id
private String customerId;
//工作人员id集合
private List<String> staffIds;
public interface OrgStaff extends CustomerClientShowGroup {}
}

12
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/OrgStaffListResultDTO.java

@ -17,9 +17,11 @@
package com.epmet.dataaggre.dto.govorg.result;
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
@ -30,10 +32,14 @@ import java.io.Serializable;
public class OrgStaffListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 树结构对象
* 人员总数
*/
private Integer staffCount;
/**
* 人员列表
*/
private AgencyGridResultDTO agencyGridList;
private List<ListStaffResultDTO> staffList;
}

12
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java

@ -130,8 +130,13 @@ public class GovOrgController {
* @author sun
*/
@PostMapping("stafflist")
public Result<List<OrgStaffListResultDTO>> staffList(@LoginUser OrgStaffListFormDTO formDTO) {
return new Result<List<OrgStaffListResultDTO>>().ok(govOrgService.staffList(formDTO));
public Result<OrgStaffListResultDTO> staffList(@LoginUser TokenDto tokenDto, @RequestBody OrgStaffListFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, OrgStaffListFormDTO.OrgStaff.class);
if(!"agency".equals(formDTO.getOrgType())&&!"dept".equals(formDTO.getOrgType())&&!"grid".equals(formDTO.getOrgType())){
throw new RenException("参数类型错误");
}
formDTO.setCustomerId(tokenDto.getCustomerId());
return new Result<OrgStaffListResultDTO>().ok(govOrgService.staffList(formDTO));
}
/**
@ -140,7 +145,8 @@ public class GovOrgController {
* @author sun
*/
@PostMapping("staffdetailv2")
public Result<StaffDetailV2FormDTO> staffDetailV2(@LoginUser StaffDetailV2ResultDTO formDTO) {
public Result<StaffDetailV2FormDTO> staffDetailV2(@RequestBody StaffDetailV2ResultDTO formDTO) {
//ValidatorUtils.validateEntity(formDTO, StaffDetailV2ResultDTO.listGridMemberDatas.class);
return new Result<StaffDetailV2FormDTO>().ok(govOrgService.staffDetailV2(formDTO));
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/CustomerStaffDao.java

@ -20,6 +20,7 @@ package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.epmetuser.CustomerStaffDTO;
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -51,4 +52,10 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
* @author sun
*/
List<ListStaffResultDTO> selectByRealName(@Param("customerId") String customerId, @Param("realName") String realName);
/**
* @Description 分页查询工作人员基础信息角色信息组织人员单位领导角色人员在前部门人员部门领导角色人员在前网格人员网格长角色人员在前
* @author sun
*/
List<ListStaffResultDTO> selectStaffList(OrgStaffListFormDTO formDTO);
}

6
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerStaffAgencyDao.java

@ -55,4 +55,10 @@ public interface CustomerStaffAgencyDao extends BaseDao<CustomerStaffAgencyEntit
*/
List<CustomerGridDTO> getStaffGridList(@Param("staffId") String staffId);
/**
* @Description 按类型查询组织部门网格下所有工作人员Id列表
* @author sun
*/
List<String> selectStaffList(String orgId, String orgType);
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java

@ -2,6 +2,7 @@ package com.epmet.dataaggre.service.epmetuser;
import com.epmet.dataaggre.dto.epmetuser.form.*;
import com.epmet.dataaggre.dto.epmetuser.result.*;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import java.util.List;
@ -125,4 +126,10 @@ public interface EpmetUserService {
* @return
*/
CustomerStaffResultDTO getStaffInfo(String staffId);
/**
* @Description 分页查询工作人员基础信息角色信息组织人员单位领导角色人员在前部门人员部门领导角色人员在前网格人员网格长角色人员在前
* @author sun
*/
List<ListStaffResultDTO> getStaffInfoList(OrgStaffListFormDTO formDTO);
}

14
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -17,6 +17,7 @@ import com.epmet.dataaggre.dto.epmetuser.result.*;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.dto.govorg.result.StaffOrgNameResultDTO;
import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity;
@ -563,5 +564,18 @@ public class EpmetUserServiceImpl implements EpmetUserService {
return result;
}
/**
* @Description 分页查询工作人员基础信息角色信息组织人员单位领导角色人员在前部门人员部门领导角色人员在前网格人员网格长角色人员在前
* @author sun
*/
@Override
public List<ListStaffResultDTO> getStaffInfoList(OrgStaffListFormDTO formDTO) {
//分别查询不能类型下人员信息、角色信息,按需求排序
int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize();
formDTO.setPageNo(pageIndex);
List<ListStaffResultDTO> resultList = customerStaffDao.selectStaffList(formDTO);
return resultList;
}
}

2
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java

@ -90,7 +90,7 @@ public interface GovOrgService {
* @Description 通讯录组织/部门/网格下人员列表
* @author sun
*/
List<OrgStaffListResultDTO> staffList(OrgStaffListFormDTO formDTO);
OrgStaffListResultDTO staffList(OrgStaffListFormDTO formDTO);
/**
* @Param formDTO

24
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -8,12 +8,16 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.govorg.*;
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO;
import com.epmet.dataaggre.dto.govorg.form.*;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO;
import com.epmet.dataaggre.dto.govorg.form.SubOrgFormDTO;
import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
@ -378,8 +382,22 @@ public class GovOrgServiceImpl implements GovOrgService {
* @author sun
*/
@Override
public List<OrgStaffListResultDTO> staffList(OrgStaffListFormDTO formDTO) {
return null;
public OrgStaffListResultDTO staffList(OrgStaffListFormDTO formDTO) {
OrgStaffListResultDTO resultDTO = new OrgStaffListResultDTO();
//1.按类型查询组织、部门、网格下所有工作人员Id列表[需要按角色排序 所以这里不能分页]
List<String> staffIds = customerStaffAgencyDao.selectStaffList(formDTO.getOrgId(), formDTO.getOrgType());
if (org.springframework.util.CollectionUtils.isEmpty(staffIds)) {
return resultDTO;
}
formDTO.setStaffIds(staffIds);
//2.分页查询工作人员基础信息、角色信息【组织人员单位领导角色人员在前;部门人员部门领导角色人员在前;网格人员网格长角色人员在前】
List<ListStaffResultDTO> staffList = epmetUserService.getStaffInfoList(formDTO);
//3.封装数据并返回
resultDTO.setStaffCount(staffIds.size());
resultDTO.setStaffList((null == staffList ? new ArrayList<>() : staffList));
return resultDTO;
}
/**

59
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml

@ -51,4 +51,63 @@
AND real_name LIKE CONCAT('%', #{realName}, '%')
</select>
<select id="selectStaffList" resultMap="staffList">
SELECT
*
FROM
customer_staff
WHERE
del_flag = '0'
AND user_id IN (
<!-- 按人员Id列表查询,先查询每个人有的角色,然后把有单位领导角色的人排在前边,其他的在按创建时间降序 -->
SELECT
t.staff_id
FROM (
<!-- 里边的sql,尽管有去重,一个人有多个角色时,在里边sql查询出来的是一个人两条数据,is_first一个是0一个是1,所以外层需要在按人分组 -->
SELECT DISTINCT<!-- 没有这个去重会改变最终的结果顺序,至于为什么还不清楚 -->
sr.staff_id,
case when gsr.role_key =
<choose>
<when test="orgType != null orgType == 'agency' ">
'agency_leader'
</when>
<when test="orgType != null orgType == 'dept' ">
'dept_leader'
</when>
<otherwise>
'grid_manager'
</otherwise>
</choose>
then 1 else 0 end is_first<!-- 有单位领导角色的人赋值为1,没有的赋值为0 -->
FROM staff_role sr
INNER JOIN gov_staff_role gsr ON sr.role_id = gsr.id AND gsr.customer_id = #{customerId}
WHERE
sr.del_flag = '0'
AND sr.staff_id IN
(
<foreach collection="staffIds" item="staffId" separator=",">
#{staffId}
</foreach>
)
ORDER BY
gsr.role_key <![CDATA[<>]]>
<choose>
<when test="orgType != null orgType == 'agency' ">
'agency_leader'
</when>
<when test="orgType != null orgType == 'dept' ">
'dept_leader'
</when>
<otherwise>
'grid_manager'
</otherwise>
</choose>
, sr.created_time DESC<!-- 标注有点位领导角色的人不参与排序也就是默认拍在前边 -->
) t
GROUP BY t.staff_id
ORDER BY t.is_first <![CDATA[<>]]> 1
LIMIT #{pageNo}, #{pageSize}
)
</select>
</mapper>

38
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml

@ -51,5 +51,43 @@
AND sg.USER_ID = #{staffId}
</select>
<select id="selectStaffList" resultType="java.lang.String">
<choose>
<when test="orgType != null orgType == 'dept' ">
SELECT
user_id
FROM
customer_staff_department
WHERE
del_flag = '0'
AND department_id = #{orgId}
ORDER BY
created_time ASC
</when>
<when test="orgType != null orgType == 'grid' ">
SELECT
user_id
FROM
customer_staff_grid
WHERE
del_flag = '0'
AND grid_id = #{orgId}
ORDER BY
created_time ASC
</when>
<otherwise>
SELECT
user_id
FROM
customer_staff_agency
WHERE
del_flag = '0'
AND agency_id = #{orgId}
ORDER BY
created_time ASC
</otherwise>
</choose>
</select>
</mapper>

Loading…
Cancel
Save