Browse Source

专题-组织网格数

dev_shibei_match
sunyuchao 4 years ago
parent
commit
fdff195cdb
  1. 40
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/StaffRoleListResultDTO.java
  2. 48
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/StaffAgencyGridListResultDTO.java
  3. 15
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java
  4. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StaffRoleDao.java
  5. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java
  6. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerGridDao.java
  7. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerStaffGridDao.java
  8. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  9. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  10. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java
  11. 83
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  12. 24
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffRoleDao.xml
  13. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml
  14. 16
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml
  15. 9
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml
  16. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffGridDao.xml

40
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/StaffRoleListResultDTO.java

@ -0,0 +1,40 @@
package com.epmet.dataaggre.dto.epmetuser.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 根据客户Id staffId查询人员在客户下的角色列表-接口返参
* @Author sun
*/
@Data
public class StaffRoleListResultDTO implements Serializable {
private static final long serialVersionUID = -2049883620062097446L;
/**
* 客户Id
* */
private String customerId;
/**
* 员工Id
* */
private String staffId;
/**
* 员工姓名
* */
private String staffName;
/**
* 角色Id
* */
private String roleId;
/**
* 角色Key
* */
private String roleKey;
/**
* 角色名称
* */
private String roleName;
}

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

@ -0,0 +1,48 @@
package com.epmet.dataaggre.dto.govorg.result;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 专题设置-组织网格切换树结构-接口返参
* @author sun
*/
@Data
public class StaffAgencyGridListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
//机关组织Id
private String agencyId = "";
//机关组织名称
private String agencyName = "";
//机关组织名称
private Boolean isOpt = true;
//网格:grid;社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province
private String orgLevel = "";
//当前组织id的上级id,如果当前是跟组织返回0
private String pid = "";
//当前组织id的所有上级id,如果当前是跟组织返回0
private String pids = "";
//当前机关的下属网格列表
private List<StaffAgencyGridListResultDTO.GridResultDTO> gridList = new ArrayList<>();
//当前组织的所有下级组织信息(递归)
private List<StaffAgencyGridListResultDTO> subAgencyGridList = new ArrayList<>();
@Data
public static class GridResultDTO{
//机关组织Id
private String gridId = "";
//机关组织名称
private String gridName = "";
//网格:grid;社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province
private String orgLevel = "";
//当前网格所属的组织id
private String pid = "";
//当前网格所有上级
private String pids = "";
}
}

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

@ -14,12 +14,11 @@ import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.result.AgencyGridListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO;
import com.epmet.dataaggre.dto.govorg.result.NextAreaCodeResultDTO;
import com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO;
import com.epmet.dataaggre.enums.GridMemberDataAnalysisEnums;
import com.epmet.dataaggre.service.AggreGridService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dto.result.PublicAndInternalFileResultDTO;
import org.apache.commons.lang3.StringUtils;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
@ -29,7 +28,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
/**
* @Author zxc
@ -119,4 +117,15 @@ public class GovOrgController {
List<GridMemberDataAnalysisResultDTO> resultList = aggreGridService.getGridMemberDataAnalysis(gridIds, searchedStaffName, loginUserId, month, sortType.getValue(), pageNo, pageSize);
return new Result().ok(resultList);
}
/**
* @Param tokenDto
* @Description 专题设置-组织网格切换树结构
* @author sun
*/
@PostMapping("staffagencygridlist")
public Result<StaffAgencyGridListResultDTO> staffAgencyGridList(@RequestBody TokenDto tokenDto) {
return new Result<StaffAgencyGridListResultDTO>().ok(govOrgService.staffAgencyGridList(tokenDto));
}
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/StaffRoleDao.java

@ -18,6 +18,7 @@
package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.entity.epmetuser.StaffRoleEntity;
import org.apache.ibatis.annotations.Mapper;
@ -40,4 +41,11 @@ public interface StaffRoleDao extends BaseDao<StaffRoleEntity> {
* @author sun
*/
List<GridStaffResultDTO> staffGridRole(@Param("forms") List<GridStaffResultDTO> forms, @Param("staffName") String staffName);
/**
* @Description 根据客户Id和staffId查询工作人员拥有的角色列表
* @Author sun
**/
List<StaffRoleListResultDTO> selectStaffRoleList(@Param("customerId") String customerId, @Param("staffId") String staffId);
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerAgencyDao.java

@ -19,6 +19,7 @@ package com.epmet.dataaggre.dao.govorg;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.govorg.result.AgencyGridResultDTO;
import com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO;
import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -52,4 +53,10 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
List<CustomerAgencyEntity> selectNextAgency(@Param("customerId")String customerId, @Param("pid")String pid);
/**
* @Author sun
* @Description 递归查询当前组织的直属下级组织列表
**/
List<StaffAgencyGridListResultDTO> selectSubAgencyList(@Param("subAgencyPids") String subAgencyPids);
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerGridDao.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.result.GridInfoResultDTO;
import com.epmet.dataaggre.dto.govorg.result.GridsInfoListResultDTO;
import com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO;
import com.epmet.dataaggre.entity.govorg.CustomerGridEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -68,4 +69,11 @@ public interface CustomerGridDao extends BaseDao<CustomerGridEntity> {
* @author sun
*/
List<CustomerGridDTO> getGridInfoList(@Param("gridIds") List<String> gridIds, @Param("staffId") String staffId);
/**
* @Author sun
* @Description 查询当前组织下网格列表
**/
List<StaffAgencyGridListResultDTO.GridResultDTO> getGridListByAgencyId(@Param("agencyId") String agencyId);
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govorg/CustomerStaffGridDao.java

@ -19,6 +19,7 @@ package com.epmet.dataaggre.dao.govorg;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO;
import com.epmet.dataaggre.entity.govorg.CustomerStaffGridEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -39,4 +40,10 @@ public interface CustomerStaffGridDao extends BaseDao<CustomerStaffGridEntity> {
* @author sun
*/
List<GridStaffResultDTO> selectGridStaffByGridIds(@Param("gridIds") List<String> gridIds);
/**
* @Description 查询工作人员参与的网格列表信息
* @author sun
*/
List<StaffAgencyGridListResultDTO.GridResultDTO> getStaffGridList(@Param("agencyId") String agencyId, @Param("staffId") String staffId);
}

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

@ -81,4 +81,9 @@ public interface EpmetUserService {
*/
OpenStaffDetailResultDTO openStaffDetail(OpenStaffDetailFormDTO formDTO);
/**
* @Description 根据客户Id和staffId查询工作人员拥有的角色列表
* @Author sun
**/
List<StaffRoleListResultDTO> getStaffRoleList(String customerId, String userId);
}

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

@ -365,5 +365,14 @@ public class EpmetUserServiceImpl implements EpmetUserService {
return resultDTO;
}
/**
* @Description 根据客户Id和staffId查询工作人员拥有的角色列表
* @Author sun
**/
@Override
public List<StaffRoleListResultDTO> getStaffRoleList(String customerId, String userId) {
return staffRoleDao.selectStaffRoleList(customerId, userId);
}
}

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

@ -1,5 +1,6 @@
package com.epmet.dataaggre.service.govorg;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
@ -72,4 +73,12 @@ public interface GovOrgService {
* @author sun
*/
CustomerAgencyDTO gridByAgencyId(String customerId, String staffId);
/**
* @Param tokenDto
* @Description 专题设置-组织网格切换树结构
* @author sun
*/
StaffAgencyGridListResultDTO staffAgencyGridList(TokenDto tokenDto);
}

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

@ -5,12 +5,13 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.govorg.CustomerAgencyDao;
import com.epmet.dataaggre.dao.govorg.CustomerGridDao;
import com.epmet.dataaggre.dao.govorg.CustomerStaffAgencyDao;
import com.epmet.dataaggre.dao.govorg.CustomerStaffGridDao;
import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO;
@ -285,4 +286,84 @@ public class GovOrgServiceImpl implements GovOrgService {
return customerStaffAgencyDao.selectAgencyByStaffId(customerId, staffId);
}
/**
* @Param tokenDto
* @Description 专题设置-组织网格切换树结构
* @author sun
*/
@Override
public StaffAgencyGridListResultDTO staffAgencyGridList(TokenDto tokenDto) {
StaffAgencyGridListResultDTO resultDTO = new StaffAgencyGridListResultDTO();
//1.查询当前人员所属组织信息
CustomerAgencyDTO agencyDTO = customerStaffAgencyDao.selectAgencyByStaffId(tokenDto.getCustomerId(), tokenDto.getUserId());
if (null == agencyDTO) {
throw new RenException("未查询到当前工作人员所属组织信息");
}
//2.获取当前人员工作端角色列表信息
List<StaffRoleListResultDTO> roleList = epmetUserService.getStaffRoleList(tokenDto.getCustomerId(), tokenDto.getUserId());
if (roleList.size() < NumConstant.ONE) {
return resultDTO;
}
//3.判断是否具有党建负责人或党建宣传员角色
//机关党建负责人角色
boolean party = false;
//党建宣传员角色
boolean gridParty = false;
for (StaffRoleListResultDTO role : roleList) {
if ("party_principals".equals(role.getRoleKey())) {
party = true;
}
if ("grid_party_director".equals(role.getRoleKey())) {
gridParty = true;
}
}
if (!party && !gridParty) {
return resultDTO;
}
//4.根据不同角色查询不同数据
if (party) {
//4.1:查询当前机关的网格列表以及所有下级机关的网格列表
//当前机关下网格列表
List<StaffAgencyGridListResultDTO.GridResultDTO> gridList = customerGridDao.getGridListByAgencyId(agencyDTO.getId());
resultDTO.setGridList(gridList);
//递归查询当前组织的下级组织以及每个下级组织对应的网格列表
//根组织pids为空
List<StaffAgencyGridListResultDTO> subAgencyGridList = getSubAgencyAndGridList(("".equals(agencyDTO.getPids()) ? "" : agencyDTO.getPids() + ":") + agencyDTO.getId());
resultDTO.setSubAgencyGridList(subAgencyGridList);
} else if (gridParty) {
resultDTO.setIsOpt(false);
//4.2:查询人员在当前机关下参与的网格列表
List<StaffAgencyGridListResultDTO.GridResultDTO> gridList = customerStaffGridDao.getStaffGridList(agencyDTO.getId(), tokenDto.getUserId());
resultDTO.setGridList(gridList);
}
//5.封装数据并返回
resultDTO.setAgencyId(agencyDTO.getId());
resultDTO.setAgencyName(agencyDTO.getOrganizationName());
resultDTO.setOrgLevel(agencyDTO.getLevel());
resultDTO.setPid(agencyDTO.getPid());
resultDTO.setPids(agencyDTO.getPids());
return resultDTO;
}
/**
* @Author sun
* @Description 递归查询当前组织的下一级组织网格列表
**/
private List<StaffAgencyGridListResultDTO> getSubAgencyAndGridList(String subAgencyPids) {
List<StaffAgencyGridListResultDTO> subAgencyList = customerAgencyDao.selectSubAgencyList(subAgencyPids);
if (subAgencyList.size() > NumConstant.ZERO) {
for (StaffAgencyGridListResultDTO sub : subAgencyList) {
List<StaffAgencyGridListResultDTO.GridResultDTO> gridList = customerGridDao.getGridListByAgencyId(sub.getAgencyId());
sub.setGridList(gridList);
List<StaffAgencyGridListResultDTO> subAgency = getSubAgencyAndGridList(sub.getPids() + ":" + sub.getAgencyId());
sub.setSubAgencyGridList(subAgency);
}
}
return subAgencyList;
}
}

24
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffRoleDao.xml

@ -22,4 +22,28 @@
</foreach>
</select>
<select id="selectStaffRoleList" resultType="com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO">
SELECT
staff.customer_id AS "customerId",
staff.user_id AS "staffId",
staff.real_name AS "staffName",
role.role_id AS "roleId",
rolename.role_key AS "roleKey",
rolename.role_name AS "roleName"
FROM
staff_role role
LEFT JOIN customer_staff staff ON ( role.staff_id = staff.user_id )
LEFT JOIN gov_staff_role rolename ON ( role.role_id = rolename.id )
WHERE
role.del_flag = '0'
AND staff.del_flag = '0'
AND rolename.del_flag = '0'
<if test='null != customerId and "" != customerId'>
AND staff.customer_id = #{customerId}
</if>
<if test='null != staffId and "" != staffId'>
AND staff.user_id = #{staffId}
</if>
</select>
</mapper>

17
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerAgencyDao.xml

@ -45,4 +45,21 @@
AND ca.PID = #{pid}
order by ca.CREATED_TIME asc
</select>
<select id="selectSubAgencyList" resultType="com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO">
SELECT
id AS "agencyId",
organization_name AS "agencyName",
level AS "orgLevel",
pid AS "pid",
pids AS "pids"
FROM
customer_agency
WHERE
del_flag = '0'
AND pids = #{subAgencyPids}
ORDER BY
created_time DESC
</select>
</mapper>

16
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml

@ -147,4 +147,20 @@
</choose>
</select>
<select id="getGridListByAgencyId" resultType="com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO$GridResultDTO">
SELECT
cg.id AS "gridId",
cg.grid_name AS "gridName",
'grid' AS "orgLevel",
ca.id AS "pid",
IF (ca.pids = '', ca.id, CONCAT(ca.pids, ':', ca.id)) AS "pids"
FROM
customer_grid cg
INNER JOIN customer_agency ca ON cg.pid = ca.id
WHERE
cg.del_flag = '0'
AND ca.del_flag = '0'
AND cg.pid = #{agencyId}
</select>
</mapper>

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

@ -19,7 +19,14 @@
<select id="selectAgencyByStaffId" resultType="com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO">
SELECT
ca.id,
ca.all_parent_name
ca.customer_id,
ca.pid,
ca.pids,
ca.all_parent_name,
ca.organization_name,
ca.level,
ca.area_code,
ca.parent_area_code
FROM
customer_staff_agency csa
INNER JOIN customer_agency ca ON csa.agency_id = ca.id

17
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffGridDao.xml

@ -18,4 +18,21 @@
)
</select>
<select id="getStaffGridList" resultType="com.epmet.dataaggre.dto.govorg.result.StaffAgencyGridListResultDTO$GridResultDTO">
SELECT
cg.id AS "gridId",
cg.grid_name AS "gridName",
'grid' AS "orgLevel",
ca.id AS "pid",
IF (ca.pids = '', ca.id, CONCAT(ca.pids, ':', ca.id)) AS "pids"
FROM
customer_staff_grid csg
INNER JOIN customer_grid cg ON csg.grid_id = cg.id
INNER JOIN customer_agency ca ON cg.pid = ca.id
WHERE
csg.del_flag = '0'
AND csg.user_id = #{staffId}
AND ca.id = #{agencyId}
</select>
</mapper>
Loading…
Cancel
Save