Browse Source

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

# Conflicts:
#	epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java
#	epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml
dev_shibei_match
wangchao 5 years ago
parent
commit
055c7ca517
  1. 2
      epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml
  2. 2
      epmet-admin/epmet-admin-server/pom.xml
  3. 2
      epmet-auth/deploy/docker-compose-dev.yml
  4. 2
      epmet-auth/pom.xml
  5. 363
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java
  6. 28
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/GetSQLFilterFormDTO.java
  7. 15
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/MybatisGovAccessFeignClient.java
  8. 8
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/MybatisGovAccessFeignClientFallback.java
  9. 17
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
  10. 61
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/RequirePermissionAspect.java
  11. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ThreadLocalInitAspect.java
  12. 8
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java
  13. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/OpeScopeConstant.java
  14. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java
  15. 22
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasSpecifiedPermissionFormDTO.java
  16. 6
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  17. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonGovAccessFeignClient.java
  18. 6
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonGovAccessFeignClientFallback.java
  19. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  20. 7
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java
  21. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/TokenDto.java
  22. 2
      epmet-module/epmet-message/epmet-message-server/deploy/docker-compose-dev.yml
  23. 2
      epmet-module/epmet-message/epmet-message-server/pom.xml
  24. 2
      epmet-module/epmet-oss/epmet-oss-server/deploy/docker-compose-dev.yml
  25. 2
      epmet-module/epmet-oss/epmet-oss-server/pom.xml
  26. 2
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigOptionsFormDTO.java
  27. 2
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigSaveConfigDTO.java
  28. 28
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/GetSQLFilterFormDTO.java
  29. 22
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/HasSpecifiedPermissionFormDTO.java
  30. 14
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java
  31. 1
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/AccessConfigOptionsResultDTO.java
  32. 14
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/AccessConfigSettingResultDTO.java
  33. 3
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java
  34. 2
      epmet-module/gov-access/gov-access-server/deploy/docker-compose-dev.yml
  35. 14
      epmet-module/gov-access/gov-access-server/pom.xml
  36. 15
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/bean/OpeScopeFilterResultBean.java
  37. 48
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/constant/OperationScopeConstant.java
  38. 32
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessConfigController.java
  39. 42
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java
  40. 75
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/AccessSettingDao.java
  41. 1
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleScopeDao.java
  42. 4
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeEntity.java
  43. 64
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java
  44. 34
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  45. 42
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java
  46. 31
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java
  47. 52
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleAccessSettingRedis.java
  48. 4
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessConfigService.java
  49. 24
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java
  50. 69
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java
  51. 502
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java
  52. 80
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/AccessSettingDao.xml
  53. 20
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/AccessSettingOptionsDao.xml
  54. 5
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml
  55. 2
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleScopeDao.xml
  56. 38
      epmet-module/gov-access/gov-access-server/src/test/java/com/epmet/test/govaccess/AccessSettingTest.java
  57. 2
      epmet-module/gov-grid/gov-grid-server/deploy/docker-compose-dev.yml
  58. 2
      epmet-module/gov-grid/gov-grid-server/pom.xml
  59. 6
      epmet-module/gov-issue/gov-issue-client/pom.xml
  60. 2
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/PolyLineDTO.java
  61. 5
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java
  62. 2
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/TickStaffFormDTO.java
  63. 2
      epmet-module/gov-issue/gov-issue-server/deploy/docker-compose-dev.yml
  64. 2
      epmet-module/gov-issue/gov-issue-server/pom.xml
  65. 8
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/constant/UserMessageConstant.java
  66. 8
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java
  67. 89
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java
  68. 30
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java
  69. 11
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml
  70. 2
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDao.xml
  71. 2
      epmet-module/gov-mine/gov-mine-server/deploy/docker-compose-dev.yml
  72. 2
      epmet-module/gov-mine/gov-mine-server/pom.xml
  73. 8
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java
  74. 6
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java
  75. 257
      epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java
  76. 2
      epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml
  77. 2
      epmet-module/gov-org/gov-org-server/pom.xml
  78. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  79. 91
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectRelatedPersonnelDTO.java
  80. 2
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/TickStaffFormDTO.java
  81. 2
      epmet-module/gov-project/gov-project-server/deploy/docker-compose-dev.yml
  82. 8
      epmet-module/gov-project/gov-project-server/pom.xml
  83. 16
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/ProjectConstant.java
  84. 24
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/UserMessageConstant.java
  85. 94
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectRelatedPersonnelController.java
  86. 52
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectRelatedPersonnelDao.java
  87. 9
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectStaffDao.java
  88. 24
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectRelatedPersonnelEntity.java
  89. 68
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ProjectRelatedPersonnelExcel.java
  90. 29
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/feign/MessageFeignClient.java
  91. 23
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/feign/fallback/MessageFeignClientFallback.java
  92. 32
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/redis/ProjectRelatedPersonnelRedis.java
  93. 104
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectRelatedPersonnelService.java
  94. 9
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectStaffService.java
  95. 42
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java
  96. 109
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectRelatedPersonnelServiceImpl.java
  97. 81
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java
  98. 5
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectStaffServiceImpl.java
  99. 30
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectRelatedPersonnelDao.xml
  100. 3
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectStaffDao.xml

2
epmet-admin/epmet-admin-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-admin-server:
container_name: epmet-admin-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-admin-server:0.3.6
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-admin-server:0.3.8
ports:
- "8082:8082"
network_mode: host # 使用现有网络

2
epmet-admin/epmet-admin-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.6</version>
<version>0.3.8</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-admin</artifactId>

2
epmet-auth/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-auth-server:
container_name: epmet-auth-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.7
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.8
ports:
- "8081:8081"
network_mode: host # 使用现有网络

2
epmet-auth/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.7</version>
<version>0.3.8</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId>

363
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/aspect/DataFilterAspect.java

@ -1,22 +1,11 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.epmet.commons.mybatis.aspect;
import com.epmet.commons.mybatis.annotation.DataFilter;
import com.epmet.commons.mybatis.feign.MybatisGovAccessFeignClient;
import com.epmet.commons.tools.constant.AccessSettingConstant;
import com.epmet.commons.tools.constant.OpeScopeConstant;
import com.epmet.commons.mybatis.dto.form.*;
import com.epmet.commons.tools.constant.ThreadLocalConstant;
import com.epmet.commons.tools.dto.form.LoginUserInfoResultDTO;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.Result;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@ -28,9 +17,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* 数据过滤切面处理类
@ -44,13 +30,11 @@ public class DataFilterAspect {
private static final Logger log = LoggerFactory.getLogger(DataFilterAspect.class);
/**
* 线程变量记录是否已经添加了至少一个过滤条件
*/
private static final ThreadLocal<Boolean> hasConditions = new ThreadLocal();
@Autowired
private LoginUserUtil loginUserUtil;
@Autowired
private MybatisGovAccessFeignClient govAccessFeignClient;
private MybatisGovAccessFeignClient mybatisGovAccessFeignClient;
@Before("@annotation(com.epmet.commons.mybatis.annotation.DataFilter)")
public void dataFilter(JoinPoint point) {
@ -88,22 +72,17 @@ public class DataFilterAspect {
}
}
LoginUserInfoResultDTO loginUserInfo = ThreadLocalConstant.loginUserInfoTl.get();
hasConditions.set(false);
//LoginUserInfoResultDTO loginUserInfo = getLoginUserInfo();
// 生成过滤sql
String sqlFilterSegment = getSqlFilterSegment(
loginUserInfo.getUserId(),
loginUserInfo.getRoleIdList(),
requirePermission,
loginUserInfo.getOrgIdPath(),
loginUserInfo.getGridIdList(),
tableAlias,
loginUserInfo.getDeptIdList(),
gridId,
deptId,
requirePermission);
GetSQLFilterFormDTO form = new GetSQLFilterFormDTO();
form.setApp(loginUserUtil.getLoginUserApp());
form.setClient(loginUserUtil.getLoginUserClient());
form.setUserId(loginUserUtil.getLoginUserId());
form.setDepartmentId(deptId);
form.setGridId(gridId);
form.setOperationKey(requirePermission);
form.setTableAlias(tableAlias);
Result<String> sqlFilterSegmentRst = mybatisGovAccessFeignClient.getSqlFilterSegment(form);
// 方式1.填充到Service方法列表中的DataScope对象中。如果dao入参是用DTO的话,那么再加一个DataScope入参,sql中会报错提示#{}参数找不到,因此改用方法2
//Object[] methodArgs = point.getArgs();
@ -115,319 +94,13 @@ public class DataFilterAspect {
//}
// 方式2,采用ThreadLocal传参到DataFilterInterceptor中
if (StringUtils.isNotBlank(sqlFilterSegment)) {
ThreadLocalConstant.sqlFilter.set(sqlFilterSegment);
}
}
/**
* 生成过滤sql片段
*
* @return
*/
private String getSqlFilterSegment(String userId, Set<String> roleIds, String reqiurePermission, String orgIdPath,
Set<String> gridIdList, String tableAlias, Set<String> deptIds, String gridId, String deptId,
String operationKey) {
StringBuilder sb = new StringBuilder();
Map<String, String> accessSettings = listRoleAccessSettings(roleIds, operationKey);
// 1.生成sql:组织范围过滤
if (!genOrgScopeSql(sb, orgIdPath, roleIds, reqiurePermission, tableAlias)) {
// 返回false,说明已经开启了all所有范围,后续条件不在拼接入sql,结束执行
return sb.toString();
}
// 2.生成sql:我发起的
String iCreated = accessSettings.get(AccessSettingConstant.I_CREATED_KEY);
if (StringUtils.isNotBlank(iCreated) && AccessSettingConstant.I_CREATED_ON.equals(iCreated)) {
genICreatedSql(sb, userId, tableAlias);
}
// 3.生成sql:本网格的
String inGrid = accessSettings.get(AccessSettingConstant.IN_GRID_KEY);
if (StringUtils.isNotBlank(inGrid) && AccessSettingConstant.IN_GRID_ON.equals(inGrid)) {
if (StringUtils.isBlank(gridId)) {
log.error("DataFilter:拼接SQL语句出错:需要in grid权限,但是代码中没有获取到:{}", gridId);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
genInGrid(sb, gridId, tableAlias);
}
// 4.生成sql:根据部门列表
String inDept = accessSettings.get(AccessSettingConstant.IN_DEPARTMENT_KEY);
if (StringUtils.isNotBlank(inDept) && AccessSettingConstant.IN_DEPARTMENT_ON.equals(inDept)) {
if (StringUtils.isBlank(deptId)) {
log.error("DataFilter:拼接SQL语句出错:需要in department权限,但是代码中没有获取到:{}", deptId);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
genDepartmentFilterSql(sb, deptId, tableAlias);
if (!sqlFilterSegmentRst.success()) {
throw new RenException("DataFilterAspect调用Access服务生成SqlFilterSegment失败:" + sqlFilterSegmentRst.getMsg());
}
return sb.toString();
}
/**
* 列出角色对应的权限设置项
*
* @param roleIds
* @return
*/
private Map<String, String> listRoleAccessSettings(Set<String> roleIds, String operationKey) {
Map<String, String> settings = new HashMap<>();
roleIds.forEach(roleId -> {
settings.putAll(listRoleAccessSettings(roleId, operationKey));
});
return settings;
}
private Map<String, String> listRoleAccessSettings(String roleId, String operationKey) {
AccessSettingFormDTO accessSettingFormDTO = new AccessSettingFormDTO();
accessSettingFormDTO.setRoleId(roleId);
accessSettingFormDTO.setOperationKey(operationKey);
Result<Map<String, String>> result = govAccessFeignClient.listAccessSettings(accessSettingFormDTO);
if (result.success()) {
return result.getData();
} else {
log.error("角色[{}]查询权限配置AccessSettings失败:{}", roleId, result.getMsg());
}
return new HashMap<>();
}
/**
* 生成部门过滤sql
*
* @param sb
*/
private void genDepartmentFilterSql(StringBuilder sb, String deptId, String tableAlias) {
//Result<List<DepartmentListResultDTO>> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffId);
if (hasConditions.get()) {
// 之前没有条件
sb.append(" OR ");
}
if (StringUtils.isBlank(tableAlias)) {
sb.append(" DEPARTMENT_ID = '").append(deptId).append("' ");
} else {
sb.append(" ").append(tableAlias).append(".DEPARTMENT_ID ='").append(deptId).append("' ");
}
hasConditions.set(true);
}
//private void genDepartmentFilterSql(StringBuilder sb, Set<String> deptIdList) {
// //Result<List<DepartmentListResultDTO>> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffId);
// if (CollectionUtils.isEmpty(deptIdList)) {
// return;
// }
// deptIdList.forEach(deptId -> {
// sb.append(hasConditions.get() ? " OR " : "").append(" DEPARTMENT_ID = '").append(deptId).append("' ");
// });
// hasConditions.set(true);
//}
/**
* 网格sql
*
* @param sb
* @param tableAlias
*/
private void genInGrid(StringBuilder sb, String gridId, String tableAlias) {
if (hasConditions.get()) {
// 之前没有条件
sb.append(" OR ");
}
// OR GRID_ID = 'XXX' OR GRID_ID = 'QQQ'
if (StringUtils.isBlank(tableAlias)) {
sb.append(" GRID_ID = '").append(gridId).append("' ");
} else {
sb.append(" ").append(tableAlias).append(".GRID_ID ='").append(gridId).append("' ");
}
hasConditions.set(true);
}
/**
* sql我发起的
*
* @param userId
*/
private void genICreatedSql(StringBuilder sb, String userId, String tableAlias) {
if (StringUtils.isBlank(tableAlias)) {
sb.append(hasConditions.get() ? " OR " : " ").append(" CREATED_BY ='").append(userId).append("'");
} else {
sb.append(hasConditions.get() ? " OR " : " ").append(tableAlias).append(".CREATED_BY ='").append(userId).append("'");
}
hasConditions.set(true);
}
/**
* 计算组织范围过滤sql整体入口
* @param sb
* @param orgIdPath
* @param roleIds
* @param reqiurePermission
* @param tableAlias
* @return Boolean 是否继续往下执行true:继续执行false:不继续执行
*/
public boolean genOrgScopeSql(StringBuilder sb, String orgIdPath, Set<String> roleIds, String reqiurePermission, String tableAlias) {
// 根据角色列表查询操作范围列表
Set<RoleOpeScopeResultDTO> opeAndScopes = new HashSet<>();
roleIds.forEach(roleId -> {
Result<List<RoleOpeScopeResultDTO>> opeResult = govAccessFeignClient.listRoleAllOperationScopesByRoleId(roleId);
if (!opeResult.success()) {
log.error("DataFilter:根据角色查询角色所有的操作列表出错:{}", opeResult.getMsg());
} else {
List<RoleOpeScopeResultDTO> opes = opeResult.getData();
if (!CollectionUtils.isEmpty(opes)) {
opes.forEach(ope -> {
if (reqiurePermission.equals(ope.getOperationKey())) {
// 拿到当前操作对应的 RoleOpeScopeResultDTO
opeAndScopes.add(ope);
}
});
}
}
});
// 过滤出最大的范围
HashSet<String> scopes = filteScopes(opeAndScopes);
if (CollectionUtils.isEmpty(scopes)) {
// 没有范围限制
return true;
}
if (scopes.contains(OpeScopeConstant.ORG_ALL)) {
return false;
}
// 生成sql语句
genOrgScopeSql(sb, scopes, orgIdPath, tableAlias);
sb.replace(sb.lastIndexOf("OR"), sb.lastIndexOf("OR") + 3, "");
hasConditions.set(true);
return true;
}
/**
* 计算组织范围过滤sql
* PS:这个方法需要优化当前阶段因为逻辑不稳定暂时不做过度封装
* @param scopes
* @return
*/
private void genOrgScopeSql(StringBuilder sb, HashSet<String> scopes, String orgIdPath, String tableAlias) {
// 取出父组织ID path 和当前组织ID
//String parentOrgIDPath = orgIdPath.substring(0, orgIdPath.lastIndexOf(orgIdPathSpliter));
//String currOrgID = orgIdPath.substring(orgIdPath.lastIndexOf(orgIdPathSpliter) + 1);
for (String scope : scopes) {
switch (scope) {
// 当前单位(可以用ORG_ID_PATH,也可以用ORG_ID判断)
case OpeScopeConstant.ORG_CURR:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" ORG_ID_PATH = '").append(orgIdPath).append("' OR ");
//sb.append(" ORG_ID = '").append(currOrgID).append("' OR ");
} else {
sb.append(" ").append(tableAlias).append(".ORG_ID_PATH = '").append(orgIdPath).append("' OR ");
//sb.append(" ").append(tableAlias).append(".ORG_ID = '").append(currOrgID).append("' OR ");
}
break;
// 本单位及其子级单位
case OpeScopeConstant.ORG_CURR_AND_SUB:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append("%' OR ");
} else {
sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(orgIdPath).append("%' OR ");
}
break;
// 本单位的子级单位
case OpeScopeConstant.ORG_CURR_SUB:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append(":%' OR ");
} else {
sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(orgIdPath).append(":%' OR ");
}
break;
//当前单位的父级单位
case OpeScopeConstant.ORG_CURR_SUP:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,':%') OR ");
} else {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,':%') OR ");
}
break;
// 当前单位及其父级单位
case OpeScopeConstant.ORG_CURR_AND_SUP:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,'%') OR ");
} else {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,'%' ) OR ");
}
break;
case OpeScopeConstant.ORG_EQUAL:
// todo 同级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_AND_SUB:
// todo 同级及其子级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_SUB:
// todo 同级的子级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_AND_SUP:
// todo 同级及其上级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_SUP:
// todo 同级的上级
//sb.append(" OR ");
break;
}
}
}
/**
* 过滤有效范围
*
* @param scopeDTOS
* @return
*/
private HashSet<String> filteScopes(Set<RoleOpeScopeResultDTO> scopeDTOS) {
HashMap<String, RoleOpeScopeResultDTO> filtedScopes = new HashMap<>();
for (RoleOpeScopeResultDTO scope : scopeDTOS) {
String scopeIndex = scope.getScopeIndex();
if (StringUtils.isBlank(scopeIndex)) {
continue;
}
if (OpeScopeConstant.ORG_ALL.equals(scope.getScopeKey())) {
// 该操作具有all的权限,直接放入
filtedScopes.put(scopeIndex, scope);
break;
}
String[] currArr = scopeIndex.split("_");
if ("0".equals(currArr[1])) {
// 为0,说明没有包含关系,直接放入
filtedScopes.put(scopeIndex, scope);
continue;
}
RoleOpeScopeResultDTO tempScope = filtedScopes.get(currArr[0]);
if (tempScope != null) {
// 已经有ac开头的了
String tempScopeIndex = tempScope.getScopeIndex();
if (Integer.valueOf(currArr[1]) < Integer.valueOf(tempScopeIndex.split("_")[1])) {
filtedScopes.put(currArr[0], scope);
}
} else {
filtedScopes.put(currArr[0], scope);
}
}
HashSet<String> scopeStrs = new HashSet<>();
Set<Map.Entry<String, RoleOpeScopeResultDTO>> entries = filtedScopes.entrySet();
for (Map.Entry<String, RoleOpeScopeResultDTO> entry : entries) {
scopeStrs.add(entry.getValue().getScopeKey());
if (StringUtils.isNotBlank(sqlFilterSegmentRst.getData())) {
ThreadLocalConstant.sqlFilter.set(sqlFilterSegmentRst.getData());
}
return scopeStrs;
}
}

28
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/dto/form/GetSQLFilterFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.commons.mybatis.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetSQLFilterFormDTO {
@NotBlank
private String operationKey;
@NotBlank
private String userId;
@NotBlank
private String app;
@NotBlank
private String client;
private String tableAlias;
private String gridId;
private String departmentId;
}

15
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/MybatisGovAccessFeignClient.java

@ -7,9 +7,9 @@ import com.epmet.commons.tools.utils.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@ -29,16 +29,17 @@ public interface MybatisGovAccessFeignClient {
Result<Set<OperationScopeDTO>> getOperationScopesByRoleId(OperationScopeFormDTO operationScopeFormDTO);
/**
* 查询角色的权限相关配置
* 查询角色所有operation及其范围(缓存)
* @return
*/
@PostMapping("/gov/access/access/accesssettings")
Result<Map<String, String>> listAccessSettings(AccessSettingFormDTO accessSettingFormDTO);
@PostMapping("/gov/access/access/roleallopesandscopes/{roleId}")
Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId);
/**
* 查询角色所有operation及其范围(缓存)
* 查询sql过滤片段
* @param form
* @return
*/
@PostMapping("/gov/access/access/roleallopesandscopes/{roleId}")
Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId);
@PostMapping("/gov/access/access/getSqlFilterSegment")
Result<String> getSqlFilterSegment(@RequestBody GetSQLFilterFormDTO form);
}

8
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/feign/fallback/MybatisGovAccessFeignClientFallback.java

@ -27,12 +27,12 @@ public class MybatisGovAccessFeignClientFallback implements MybatisGovAccessFeig
}
@Override
public Result<Map<String, String>> listAccessSettings(AccessSettingFormDTO accessSettingFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listAccessSettings", accessSettingFormDTO);
public Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId){
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listRoleAllOperationScopesByRoleId", roleId);
}
@Override
public Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId){
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listRoleAllOperationScopesByRoleId", roleId);
public Result<String> getSqlFilterSegment(GetSQLFilterFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "getSqlFilterSegment", form);
}
}

17
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java

@ -11,6 +11,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.dao.DuplicateKeyException;
import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
import java.time.LocalDateTime;
/**
* 日志切面
@ -40,13 +42,14 @@ public abstract class BaseRequestLogAspect {
String requestURI = request.getRequestURI();
long id = Thread.currentThread().getId();
Result result;
Object result = null;
Exception exception = null;
LocalDateTime startTime = LocalDateTime.now();
try {
Object[] args = point.getArgs();
log.info(">>>>>>>>请求信息>>>>>>>>:线程ID:{},url:{},请求参数:{}", id, requestURI, objectsToString(args));
result = (Result)point.proceed();
log.info("<<<<<<<<正常响应<<<<<<<<:线程ID:{},响应数据:{}", id, result.toString());
result = point.proceed();
} catch (RenException e) {
exception = e;
result = handleRenException(e);
@ -63,8 +66,13 @@ public abstract class BaseRequestLogAspect {
exception = e;
result = handlerException(e);
} finally {
LocalDateTime endTime = LocalDateTime.now();
long execTimeMillis = Duration.between(startTime, endTime).toMillis();
if (exception != null) {
log.info("<<<<<<<<异常响应<<<<<<<<:线程ID:{},异常信息:{}", id, ExceptionUtils.getErrorStackTrace(exception));
log.info("<<<<<<<<异常响应<<<<<<<<:线程ID:{},执行时长:{}ms, 异常信息:{}", id, execTimeMillis, ExceptionUtils.getErrorStackTrace(exception));
} else {
log.info("<<<<<<<<正常响应<<<<<<<<:线程ID:{},执行时长:{}ms, 响应数据:{}", id, execTimeMillis, result == null ? result : result.toString());
}
}
return result;
@ -124,6 +132,7 @@ public abstract class BaseRequestLogAspect {
}
Result result=new Result().error();
result.setData(e.getMsg());
//result.setMsg(e.getMsg());
return result;
}

61
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/RequirePermissionAspect.java

@ -10,6 +10,7 @@ package com.epmet.commons.tools.aspect;
import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.constant.ThreadLocalConstant;
import com.epmet.commons.tools.dto.form.HasSpecifiedPermissionFormDTO;
import com.epmet.commons.tools.dto.form.LoginUserInfoFormDTO;
import com.epmet.commons.tools.dto.form.LoginUserInfoResultDTO;
import com.epmet.commons.tools.dto.form.RoleOpeScopeResultDTO;
@ -65,68 +66,32 @@ public class RequirePermissionAspect {
String requirePermission = requirePermissionEnum.getKey();
LoginUserInfoResultDTO loginUserInfo = getLoginUserInfo();
Set<String> ownPermissions = getPermissions(loginUserInfo.getRoleIdList());
// 校验操作权限
validateOpePermission(ownPermissions, requirePermission);
validPermission(requirePermission);
// 操作权限校验通过。将该操作key放入ThreadLocal,供DataFilterAspect中数据权限过滤器进一步使用
ThreadLocalConstant.requirePermissionTl.set(requirePermission);
ThreadLocalConstant.loginUserInfoTl.set(loginUserInfo);
}
/**
* 获取登陆用户信息
* @return
* 校验权限
* @param requirePermission
*/
private LoginUserInfoResultDTO getLoginUserInfo() {
LoginUserInfoFormDTO loginUserinfoFormDTO = new LoginUserInfoFormDTO();
loginUserinfoFormDTO.setApp(loginUserUtil.getLoginUserApp());
loginUserinfoFormDTO.setClient(loginUserUtil.getLoginUserClient());
loginUserinfoFormDTO.setStaffId(loginUserUtil.getLoginUserId());
Result<LoginUserInfoResultDTO> result = govAccessFeignClient.getLoginUserInfo(loginUserinfoFormDTO);
private void validPermission(String requirePermission) {
HasSpecifiedPermissionFormDTO form = new HasSpecifiedPermissionFormDTO();
form.setApp(loginUserUtil.getLoginUserApp());
form.setClient(loginUserUtil.getLoginUserClient());
form.setUserId(loginUserUtil.getLoginUserId());
form.setOperationKey(requirePermission);
Result<Boolean> result = govAccessFeignClient.hasSpecifiedPermission(form);
if (result.getCode() != 0) {
// 查询不到权限,记录日志,抛出8000异常
log.error("调用Access查询权限失败:{}", result.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
LoginUserInfoResultDTO loginUserInfo = result.getData();
if (loginUserInfo == null) {
log.error("操作权限不足,查询不到登录用户信息");
throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode());
}
return loginUserInfo;
}
/**
* 校验操作权限
*/
private void validateOpePermission(Set<String> permissions, String reqiurePermission) {
if (!permissions.contains(reqiurePermission)) {
// 权限不足
Boolean data = result.getData();
if (data == null || !data) {
log.error("操作权限不足");
throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode());
}
}
private Set<String> getPermissions(Set<String> roleIdList) {
Set<String> permissions = new HashSet<>();
roleIdList.forEach(role -> {
// 找出该角色的所有功能操作列表
Result<List<RoleOpeScopeResultDTO>> result = govAccessFeignClient.listRoleAllOperationScopesByRoleId(role);
if (!result.success()) {
// 获取operation异常
log.error("调用GovAccess,根据RoleId查询Operation列表失败:{}", result.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
List<RoleOpeScopeResultDTO> roleOperations = result.getData();
permissions.addAll(roleOperations.stream().map(ope -> ope.getOperationKey()).collect(Collectors.toSet()));
});
return permissions;
}
}

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ThreadLocalInitAspect.java

@ -38,7 +38,6 @@ public class ThreadLocalInitAspect {
try {
ThreadLocalConstant.sqlFilter.remove();
ThreadLocalConstant.requirePermissionTl.remove();
ThreadLocalConstant.loginUserInfoTl.remove();
} catch (Exception e) {
log.error("清理sqlFilter缓存失败:{}", ExceptionUtils.getErrorStackTrace(e));
}

8
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java

@ -118,5 +118,13 @@ public interface Constant {
*
*/
String NO="no";
/**
* 已读
*/
String READ = "read";
/**
* 未读
*/
String UNREAD = "unread";
}

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/OpeScopeConstant.java

@ -5,7 +5,10 @@ package com.epmet.commons.tools.constant;
*/
public class OpeScopeConstant {
// 权限覆盖所有范围
// 无任何范围限制
public static final String ALL = "all";
// 覆盖机构下的所有范围
public static final String ORG_ALL = "org_all";
//"同级组织的下级"

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java

@ -12,11 +12,6 @@ public class ThreadLocalConstant {
*/
public static final ThreadLocal<String> requirePermissionTl = new ThreadLocal<>();
/**
* 登陆用户信息的 ThreadLocal
*/
public static final ThreadLocal<LoginUserInfoResultDTO> loginUserInfoTl = new ThreadLocal<>();
/**
* 用于向DataFilterInterceptor传递权限过滤的sql片段(需要在Controller相关的AOP中进行清理防止变量残留)
*/

22
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/form/HasSpecifiedPermissionFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.commons.tools.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class HasSpecifiedPermissionFormDTO {
@NotBlank
private String operationKey;
@NotBlank
private String userId;
@NotBlank
private String app;
@NotBlank
private String client;
}

6
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -45,8 +45,10 @@ public enum EpmetErrorCode {
ALREADY_EVALUATE(8501,"您已评价"),
ALREADY_VOTE(8502,"您已表态"),
PROJECT_IS_CLOSED(8601,"项目已结案")
;
PROJECT_IS_CLOSED(8601,"项目已结案"),
// 该错误不会提示给前端,只是后端传输错误信息用。
ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数");
private int code;
private String msg;

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/CommonGovAccessFeignClient.java

@ -1,6 +1,7 @@
package com.epmet.commons.tools.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.dto.form.HasSpecifiedPermissionFormDTO;
import com.epmet.commons.tools.dto.form.LoginUserInfoFormDTO;
import com.epmet.commons.tools.dto.form.LoginUserInfoResultDTO;
import com.epmet.commons.tools.dto.form.RoleOpeScopeResultDTO;
@ -34,4 +35,12 @@ public interface CommonGovAccessFeignClient {
*/
@PostMapping("/gov/access/access/roleallopesandscopes/{roleId}")
Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId);
/**
* 用户是否具有指定权限
* @param form
* @return
*/
@PostMapping("/gov/access/access/hasspecifiedpermission")
Result<Boolean> hasSpecifiedPermission(@RequestBody HasSpecifiedPermissionFormDTO form);
}

6
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonGovAccessFeignClientFallback.java

@ -1,6 +1,7 @@
package com.epmet.commons.tools.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.dto.form.HasSpecifiedPermissionFormDTO;
import com.epmet.commons.tools.dto.form.LoginUserInfoFormDTO;
import com.epmet.commons.tools.dto.form.LoginUserInfoResultDTO;
import com.epmet.commons.tools.dto.form.RoleOpeScopeResultDTO;
@ -30,4 +31,9 @@ public class CommonGovAccessFeignClientFallback implements CommonGovAccessFeignC
public Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId){
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listRoleAllOperationScopesByRoleId", roleId);
}
@Override
public Result<Boolean> hasSpecifiedPermission(HasSpecifiedPermissionFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "hasSpecifiedPermission", form);
}
}

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -204,13 +204,4 @@ public class RedisKeys {
public static String getRoleAllOpeScopesKey(String roleId) {
return rootPrefix.concat("gov:access:role:allopescopes:").concat(roleId);
}
/**
* 角色ID对应的权限配置
* @param roleId
* @return
*/
public static String getRoleAccessSettingKey(String roleId, String operationKey) {
return rootPrefix.concat(String.format("gov:access:role:accesssettings:%s:%s", roleId, operationKey));
}
}

7
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java

@ -1,9 +1,9 @@
package com.epmet.commons.tools.security.dto;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
/**
@ -78,5 +78,10 @@ public class GovTokenDto extends BaseTokenDto implements Serializable {
* 角色ID列表
*/
private Set<String> roleIdList;
@Override
public String toString() {
return JSON.toJSONString(this);
}
}

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/TokenDto.java

@ -1,5 +1,6 @@
package com.epmet.commons.tools.security.dto;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import java.io.Serializable;
@ -39,4 +40,8 @@ public class TokenDto extends BaseTokenDto implements Serializable {
*/
private long updateTime;
@Override
public String toString() {
return JSON.toJSONString(this);
}
}

2
epmet-module/epmet-message/epmet-message-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-message-server:
container_name: epmet-message-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-message-server:0.3.6
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-message-server:0.3.7
ports:
- "8085:8085"
network_mode: host # 使用现有网络

2
epmet-module/epmet-message/epmet-message-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.6</version>
<version>0.3.7</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-message</artifactId>

2
epmet-module/epmet-oss/epmet-oss-server/deploy/docker-compose-dev.yml

@ -3,7 +3,7 @@ services:
epmet-oss-server:
container_name: epmet-oss-server-dev
# image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-dev/epmet-oss-server:0.3.2
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-oss-server:0.3.7
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-oss-server:0.3.8
ports:
- "8083:8083"
network_mode: host # 使用现有网络

2
epmet-module/epmet-oss/epmet-oss-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.7</version>
<version>0.3.8</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss</artifactId>

2
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigSettingFormDTO.java → epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigOptionsFormDTO.java

@ -5,7 +5,7 @@ import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AccessConfigSettingFormDTO {
public class AccessConfigOptionsFormDTO {
@NotBlank(message = "角色ID不能为空")
private String roleId;

2
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigSaveSettingDTO.java → epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigSaveConfigDTO.java

@ -6,7 +6,7 @@ import javax.validation.constraints.NotBlank;
import java.util.Set;
@Data
public class AccessConfigSaveSettingDTO {
public class AccessConfigSaveConfigDTO {
@NotBlank(message = "角色ID不能为空")
private String roleId;

28
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/GetSQLFilterFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetSQLFilterFormDTO {
@NotBlank
private String operationKey;
@NotBlank
private String userId;
@NotBlank
private String app;
@NotBlank
private String client;
private String tableAlias;
private String gridId;
private String departmentId;
}

22
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/HasSpecifiedPermissionFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class HasSpecifiedPermissionFormDTO {
@NotBlank
private String operationKey;
@NotBlank
private String userId;
@NotBlank
private String app;
@NotBlank
private String client;
}

14
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/ListOpePermsFormDTO.java

@ -0,0 +1,14 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class ListOpePermsFormDTO {
@NotBlank(message = "用户ID不能为空")
private String staffId;
@NotBlank(message = "当前单位不能为空")
private String currAgencyId;
}

1
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/AccessConfigOptionsResultDTO.java

@ -7,5 +7,4 @@ import java.util.List;
@Data
public class AccessConfigOptionsResultDTO {
private List<AccessConfigScopeResultDTO> scopeOptions;
private List<AccessConfigSettingResultDTO> settingOptions;
}

14
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/AccessConfigSettingResultDTO.java

@ -1,14 +0,0 @@
package com.epmet.dto.result;
import lombok.Data;
@Data
public class AccessConfigSettingResultDTO {
private String settingKey;
private String settingName;
private String roleId;
private Boolean assigned;
private String operationKey;
}

3
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/RoleOpeScopeResultDTO.java

@ -30,4 +30,7 @@ public class RoleOpeScopeResultDTO {
*/
private String scopeIndex;
private String series;
private Integer sort;
}

2
epmet-module/gov-access/gov-access-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-access-server:
container_name: gov-access-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-access-server:0.3.10
image: 192.168.1.130:10080/epmet-cloud-dev/gov-access-server:0.3.11
ports:
- "8099:8099"
network_mode: host # 使用现有网络

14
epmet-module/gov-access/gov-access-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.10</version>
<version>0.3.11</version>
<parent>
<artifactId>gov-access</artifactId>
<groupId>com.epmet</groupId>
@ -19,6 +19,18 @@
<artifactId>gov-access-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>gov-org-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>

15
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/bean/OpeScopeFilterResultBean.java

@ -0,0 +1,15 @@
package com.epmet.bean;
import lombok.Data;
import java.util.HashSet;
import java.util.Set;
@Data
public class OpeScopeFilterResultBean {
private HashSet<String> orgLevelScopes;
private Set<String> switchScopes;
private boolean allScopes;
}

48
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/constant/OperationScopeConstant.java

@ -0,0 +1,48 @@
package com.epmet.constant;
/**
* 操作范围系列常量
*/
public class OperationScopeConstant {
/**
* ===================系列===================
*/
public static final String SERIES_ORG_LEVEL = "org_level";
public static final String SERIES_SWITCH = "switch";
public static final String SERIES_ALL = "all";
/**
* ===================范围===================
*/
// 无任何范围限制
public static final String SCOPE_ALL = "all";
// 覆盖机构下的所有范围
public static final String SCOPE_ORG_ALL = "org_all";
//"同级组织的下级"
public static final String SCOPE_ORG_EQUAL_SUB = "org_equal_sub";
//"同级组织及下级"
public static final String SCOPE_ORG_EQUAL_AND_SUB = "org_equal_and_sub";
// 同级组织的上级
public static final String SCOPE_ORG_EQUAL_SUP = "org_equal_sup";
// 同级组织及上级
public static final String SCOPE_ORG_EQUAL_AND_SUP = "org_equal_and_sup";
//"同级组织"
public static final String SCOPE_ORG_EQUAL = "org_equal";
//"本组织的下级"
public static final String SCOPE_ORG_CURR_SUB = "org_curr_sub";
//"本组织及下级"
public static final String SCOPE_ORG_CURR_AND_SUB = "org_curr_and_sub";
//"本组织"
public static final String SCOPE_ORG_CURR = "org_curr";
//我创建的
public static final String SCOPE_I_CREATED = "i_created";
//网格内
public static final String SCOPE_IN_GRID = "in_grid";
// 部门内
public static final String SCOPE_IN_DEPARTMENT = "in_department";
}

32
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessConfigController.java

@ -3,15 +3,14 @@ package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.AccessConfigOpesFormDTO;
import com.epmet.dto.form.AccessConfigSaveSettingDTO;
import com.epmet.dto.form.AccessConfigSettingFormDTO;
import com.epmet.dto.form.AccessConfigOptionsFormDTO;
import com.epmet.dto.form.AccessConfigSaveConfigDTO;
import com.epmet.dto.result.AccessConfigOpesResultDTO;
import com.epmet.dto.result.AccessConfigOptionsResultDTO;
import com.epmet.service.AccessConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Set;
@ -34,7 +33,7 @@ public class AccessConfigController {
}
/**
* 保存角色的操作功能列表
* 保存角色的操作权限列表
* @return
*/
@PostMapping("saveroleopes")
@ -47,26 +46,25 @@ public class AccessConfigController {
* 查询可配置项列表
* @return
*/
@PostMapping("settingoptions")
public Result listSettingoptions(@RequestBody AccessConfigSettingFormDTO settingFormDTO) {
ValidatorUtils.validateEntity(settingFormDTO);
AccessConfigOptionsResultDTO options = accessConfigService.listScopeItemsForAccessConfig(settingFormDTO.getRoleId(), settingFormDTO.getOperationKey());
@PostMapping("configoptions")
public Result listConfigOptions(@RequestBody AccessConfigOptionsFormDTO accessConfigFormDTO) {
ValidatorUtils.validateEntity(accessConfigFormDTO);
AccessConfigOptionsResultDTO options = accessConfigService.listScopeOptionsForAccessConfig(accessConfigFormDTO.getRoleId(), accessConfigFormDTO.getOperationKey());
return new Result().ok(options);
}
/**
* 保存设置
* @param settings
* @param config
* @return
*/
@PostMapping("savesettings")
public Result saveSettings(@RequestBody AccessConfigSaveSettingDTO settings) {
ValidatorUtils.validateEntity(settings);
String roleId = settings.getRoleId();
String operationKey = settings.getOperationKey();
Set<String> scopeKeys = settings.getScopeKeys();
Set<String> settingKeys = settings.getSettingKeys();
accessConfigService.saveSettings(roleId, operationKey, scopeKeys, settingKeys);
@PostMapping("saveconfig")
public Result saveSettings(@RequestBody AccessConfigSaveConfigDTO config) {
ValidatorUtils.validateEntity(config);
String roleId = config.getRoleId();
String operationKey = config.getOperationKey();
Set<String> scopeKeys = config.getScopeKeys();
accessConfigService.saveConfig(roleId, operationKey, scopeKeys);
return new Result();
}

42
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessController.java

@ -3,17 +3,15 @@ package com.epmet.controller;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.AccessSettingFormDTO;
import com.epmet.dto.form.OperationScopeFormDTO;
import com.epmet.dto.form.StaffPermCacheFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.LoginUserInfoResultDTO;
import com.epmet.dto.result.RoleOpeScopeResultDTO;
import com.epmet.service.AccessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@ -91,12 +89,38 @@ public class AccessController {
}
/**
* 查询角色的权限相关配置(缓存)
* 用户是否具有指定功能权限
* @return
*/
@PostMapping("/accesssettings")
public Result<Map<String, String>> listAccessSettings(@RequestBody AccessSettingFormDTO accessSettingFormDTO) {
Map<String, String> settings = accessService.listAccessSettings(accessSettingFormDTO.getRoleId(), accessSettingFormDTO.getOperationKey());
return new Result<Map<String, String>>().ok(settings);
@PostMapping("hasspecifiedpermission")
public Result<Boolean> hasSpecifiedPermission(@RequestBody HasSpecifiedPermissionFormDTO form) {
ValidatorUtils.validateEntity(form);
Boolean hasPermission = accessService.hasPermission(form.getOperationKey(), form.getUserId(), form.getApp(), form.getClient());
return new Result<Boolean>().ok(hasPermission);
}
/**
* 列出功能权限列表
* @return
*/
@PostMapping("listoperationpermissions")
public Result<Set<String>> listOperationPermissions(@RequestBody ListOpePermsFormDTO listOpePermsFormDTO) {
ValidatorUtils.validateEntity(listOpePermsFormDTO);
String currAgencyId = listOpePermsFormDTO.getCurrAgencyId();
String staffId = listOpePermsFormDTO.getStaffId();
Set<String> operationPermissions = accessService.listOperationPermissions(staffId, currAgencyId);
return new Result<Set<String>>().ok(operationPermissions);
}
/**
* 查询sql过滤片段
* @param form
* @return
*/
@PostMapping("getSqlFilterSegment")
public Result getSqlFilterSegment(@RequestBody GetSQLFilterFormDTO form) {
ValidatorUtils.validateEntity(form);
String sqlFilterSegment = accessService.getSqlFilterSegment(form);
return new Result().ok(sqlFilterSegment);
}
}

75
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/AccessSettingDao.java

@ -1,75 +0,0 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.AccessConfigSettingResultDTO;
import com.epmet.dto.result.AccessSettingResultDTO;
import com.epmet.entity.AccessSettingEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* 权限配置
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-29
*/
@Mapper
public interface AccessSettingDao extends BaseDao<AccessSettingEntity> {
/**
* 根据角色查询配置列表
* @param roleId
* @return
*/
List<AccessSettingResultDTO> listAccessSettingsByRoleId(@Param("roleId") String roleId,
@Param("operationKey") String operationKey);
List<AccessConfigSettingResultDTO> listSettingOptionsForAccessConfig(@Param("roleId") String roleId,
@Param("operationKey") String operationKey);
/**
* 删除
* @param roleId
* @param operationKey
* @param settingKeys2Delete
* @return
*/
int delete(@Param("roleId") String roleId,
@Param("operationKey") String operationKey,
@Param("settingKeys2Delete") Set<String> settingKeys2Delete);
AccessSettingEntity get(@Param("roleId") String roleId,
@Param("operationKey") String operationKey,
@Param("settingKey") String settingKey);
/**
* 启用
* @param roleId
* @param operationKey
* @param settingKey
* @return
*/
int enable(@Param("roleId") String roleId,
@Param("operationKey") String operationKey,
@Param("settingKey") String settingKey);
}

1
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/RoleScopeDao.java

@ -19,7 +19,6 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.AccessConfigScopeResultDTO;
import com.epmet.dto.result.AccessConfigSettingResultDTO;
import com.epmet.entity.RoleScopeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

4
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/OperationScopeEntity.java

@ -48,4 +48,8 @@ public class OperationScopeEntity extends BaseEpmetEntity {
*/
private String scopeName;
private String scopeIndex;
private String series;
private Integer sort;
}

64
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java

@ -0,0 +1,64 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.form.StaffGridVisitedFormDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.feign.fallback.EpmetUserFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @Description
* @Author sun
*/
//, url = "localhost:8087"
@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserFeignClientFallback.class)
public interface EpmetUserFeignClient {
/**
* 获取最近一次登录的客户信息
*
* @param userId
* @return
*/
@GetMapping("/epmetuser/staffagencyvisited/getlatestcustomer/{userId}")
Result<LatestCustomerResultDTO> getLatestCustomer(@PathVariable("userId") String userId);
/**
* @Description 查询工作人员上次登录的网格
* @Param customerId ; staffId
* @return Result<CustomerGridByUserIdResultDTO>
* @Author wangc
* @Date 2020.04.23 10:44
**/
@PostMapping(value = "/epmetuser/staffgridvisited/getstafflatestgrid")
Result<CustomerGridByUserIdResultDTO> getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO);
/**
* @param staffGridVisitedFormDTO
* @return com.epmet.commons.tools.utils.Result
* @Author yinzuomei
* @Description 保存网格访问记录
* @Date 2020/4/23 13:27
**/
@PostMapping(value = "/epmetuser/staffgridvisited/savestaffgridvisitedrecord", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result saveStaffGridVisitedRecord(@RequestBody StaffGridVisitedFormDTO staffGridVisitedFormDTO);
/**
* 查询工作人员的角色
* @return
*/
@PostMapping("/epmetuser/staffrole/staffroles")
Result<List<GovStaffRoleDTO>> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO);
}

34
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java

@ -0,0 +1,34 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.feign.fallback.GovOrgFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @Description
* @Author sun
*/
//, url = "localhost:8092"
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class)
public interface GovOrgFeignClient {
/**
* 根据Id查询agency
* @param agencyId
* @return
*/
@PostMapping("/gov/org/agency/agencybyid/{agencyId}")
Result<CustomerAgencyDTO> getAgencyById(@PathVariable("agencyId") String agencyId);
/**
* 根据staffId查询所属的组织机构
* @param staffId
* @return
*/
@PostMapping("/gov/org/agency/agencybystaff/{staffId}")
Result<CustomerAgencyDTO> getAgencyByStaff(@PathVariable("staffId") String staffId);
}

42
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallback.java

@ -0,0 +1,42 @@
package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.form.StaffGridVisitedFormDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.feign.EpmetUserFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Description
* @Author sun
*/
@Component
public class EpmetUserFeignClientFallback implements EpmetUserFeignClient {
@Override
public Result<LatestCustomerResultDTO> getLatestCustomer(String userId) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getLatestCustomer", userId);
}
@Override
public Result<List<GovStaffRoleDTO>> getRolesOfStaff(StaffRoleFormDTO staffRoleFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getRolesOfStaff");
}
@Override
public Result<CustomerGridByUserIdResultDTO> getStaffLatestGrid(LatestGridFormDTO latestGridFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getStaffLatestGrid",latestGridFormDTO);
}
@Override
public Result saveStaffGridVisitedRecord(StaffGridVisitedFormDTO staffGridVisitedFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveStaffGridVisitedRecord", staffGridVisitedFormDTO);
}
}

31
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java

@ -0,0 +1,31 @@
package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.LatestGridFormDTO;
import com.epmet.dto.result.CustomerGridByUserIdResultDTO;
import com.epmet.dto.result.LatestCustomerResultDTO;
import com.epmet.feign.GovOrgFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Description
* @Author sun
*/
@Component
public class GovOrgFeignClientFallBack implements GovOrgFeignClient {
@Override
public Result<CustomerAgencyDTO> getAgencyById(String agencyId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyById", agencyId);
}
@Override
public Result<CustomerAgencyDTO> getAgencyByStaff(String staffId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyByStaff", staffId);
}
}

52
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/RoleAccessSettingRedis.java

@ -1,52 +0,0 @@
package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@Component
public class RoleAccessSettingRedis {
@Autowired
private RedisUtils redisUtils;
public void set(Map<String, String> settings, String roleId, String operationKey) {
// 转化Map
HashMap<String, Object> newSettings = new HashMap<>();
Set<Map.Entry<String, String>> entries = settings.entrySet();
entries.forEach(entry -> {
newSettings.put(entry.getKey(), entry.getValue());
});
String roleAccessSettingKey = RedisKeys.getRoleAccessSettingKey(roleId, operationKey);
redisUtils.hMSet(roleAccessSettingKey, newSettings);
}
public Map<String, String> get(String roleId, String operationKey) {
String roleAccessSettingKey = RedisKeys.getRoleAccessSettingKey(roleId, operationKey);
Map<String, Object> s = redisUtils.hGetAll(roleAccessSettingKey);
// 转化Map
if (!CollectionUtils.isEmpty(s)) {
Map<String, String> settings = new HashMap<>();
s.forEach((s1, o) -> {
if (o != null) {
settings.put(s1, String.valueOf(o));
}
});
return settings;
}
return null;
}
public void delete(String roleId, String operationKey) {
redisUtils.delete(RedisKeys.getRoleAccessSettingKey(roleId, operationKey));
}
}

4
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessConfigService.java

@ -11,7 +11,7 @@ public interface AccessConfigService {
void saveRoleOpes(String roleId, List<AccessConfigOpesResultDTO> opes);
AccessConfigOptionsResultDTO listScopeItemsForAccessConfig(String roleId, String operationKey);
AccessConfigOptionsResultDTO listScopeOptionsForAccessConfig(String roleId, String operationKey);
void saveSettings(String roleId, String operationKey, Set<String> scopeKeys, Set<String> settingKeys);
void saveConfig(String roleId, String operationKey, Set<String> scopeKeys);
}

24
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessService.java

@ -1,6 +1,7 @@
package com.epmet.service;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.dto.form.GetSQLFilterFormDTO;
import com.epmet.dto.result.RoleOpeScopeResultDTO;
import java.util.List;
@ -30,16 +31,29 @@ public interface AccessService {
Set<RoleOpeScopeResultDTO> listOperationScopesByRoleId(String roleId, String operationKey);
/**
* 查询角色的权限相关配置
* 查询角色所有operation及其范围(缓存)
* @param roleId
* @return
*/
Map<String, String> listAccessSettings(String roleId, String operationKey);
List<RoleOpeScopeResultDTO> listAllRoleOperationScopesByRoleId(String roleId);
/**
* 查询角色所有operation及其范围(缓存)
* @param roleId
* 角色
* @param operationKey
* @param userId
* @return
*/
List<RoleOpeScopeResultDTO> listAllRoleOperationScopesByRoleId(String roleId);
Boolean hasPermission(String operationKey, String userId, String app, String client);
/**
* 生成sql过滤脚本
* @param form
*/
String getSqlFilterSegment(GetSQLFilterFormDTO form);
/**
* 列出角色的功能权限
* @return
*/
Set<String> listOperationPermissions(String staffId, String currAgencyId);
}

69
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java

@ -1,14 +1,11 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.AccessSettingConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.dao.*;
import com.epmet.dto.result.*;
import com.epmet.entity.AccessSettingEntity;
import com.epmet.entity.RoleOperationEntity;
import com.epmet.entity.RoleScopeEntity;
import com.epmet.redis.RoleAccessSettingRedis;
import com.epmet.redis.RoleOpeScopeRedis;
import com.epmet.service.AccessConfigService;
import org.slf4j.Logger;
@ -36,12 +33,6 @@ public class AccessConfigServiceImpl implements AccessConfigService {
@Autowired
private RoleScopeDao roleScopeDao;
@Autowired
private AccessSettingDao accessSettingDao;
@Autowired
private RoleAccessSettingRedis roleAccessSettingRedis;
@Override
public List<AccessConfigOpesResultDTO> listOpesByRole(String roleId) {
return roleOperationDao.listOpesForAccessConfig(roleId);
@ -84,70 +75,18 @@ public class AccessConfigServiceImpl implements AccessConfigService {
}
@Override
public AccessConfigOptionsResultDTO listScopeItemsForAccessConfig(String roleId, String operationKey) {
public AccessConfigOptionsResultDTO listScopeOptionsForAccessConfig(String roleId, String operationKey) {
List<AccessConfigScopeResultDTO> scopeOptions = roleScopeDao.listScopeOptionsForAccessConfig(roleId, operationKey);
List<AccessConfigSettingResultDTO > settingOptions = accessSettingDao.listSettingOptionsForAccessConfig(roleId, operationKey);
//List<AccessConfigSettingResultDTO > settingOptions = accessSettingDao.listSettingOptionsForAccessConfig(roleId, operationKey);
AccessConfigOptionsResultDTO options = new AccessConfigOptionsResultDTO();
options.setScopeOptions(scopeOptions);
options.setSettingOptions(settingOptions);
//options.setSettingOptions(settingOptions);
return options;
}
@Override
@Transactional
public void saveSettings(String roleId, String operationKey, Set<String> scopeKeys, Set<String> settingKeys) {
saveScopeSettings(roleId, operationKey, scopeKeys);
saveAccessSettingSettings(roleId, operationKey, settingKeys);
}
/**
* 保存设置
* 可以优化为遍历时候直接删除或者新增而不用新建settingKeys2Delete, settingKeys2Add变量
* @param roleId
* @param operationKey
*/
private void saveAccessSettingSettings(String roleId, String operationKey, Set<String> newSettingKeys) {
Set<String> settingKeysDB = accessSettingDao.listAccessSettingsByRoleId(roleId, operationKey)
.stream()
.map(setting -> setting.getSettingKey())
.collect(Collectors.toSet());
Set<String> settingKeys2Delete = settingKeysDB.stream().filter(settingKeyDB -> !newSettingKeys.contains(settingKeyDB)).collect(Collectors.toSet());
Set<String> settingKeys2Add = newSettingKeys.stream().filter(newSetting -> !settingKeysDB.contains(newSetting)).collect(Collectors.toSet());
// 删除
if (!CollectionUtils.isEmpty(settingKeys2Delete)) {
accessSettingDao.delete(roleId, operationKey, settingKeys2Delete);
}
// 新增
if (!CollectionUtils.isEmpty(settingKeys2Add)) {
settingKeys2Add.forEach(settingKey -> {
if (accessSettingDao.get(roleId, operationKey, settingKey) != null) {
// 数据库中已有
accessSettingDao.enable(roleId, operationKey, settingKey);
} else {
AccessSettingEntity newSetting = new AccessSettingEntity();
newSetting.setRoleId(roleId);
newSetting.setOperationKey(operationKey);
newSetting.setSettingKey(settingKey);
newSetting.setSettingValue(AccessSettingConstant.ON);
accessSettingDao.insert(newSetting);
}
});
}
// 清空redis缓存
roleAccessSettingRedis.delete(roleId, operationKey);
}
/**
* 保存Scope设置
* @param roleId
* @param operationKey
* @param scopeKeys
*/
private void saveScopeSettings(String roleId, String operationKey, Set<String> scopeKeys) {
public void saveConfig(String roleId, String operationKey, Set<String> scopeKeys) {
List<RoleScopeEntity> scopesDB = roleScopeDao.listScopeEntities(roleId, operationKey);
// 数据库中已有的scopeKey列表
Set<String> scopeKeysDB = scopesDB.stream().map(scope -> scope.getScopeKey()).collect(Collectors.toSet());

502
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java

@ -1,15 +1,26 @@
package com.epmet.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.epmet.bean.OpeScopeFilterResultBean;
import com.epmet.commons.tools.constant.OpeScopeConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.dao.AccessSettingDao;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.OperationScopeConstant;
import com.epmet.dao.OperationScopeDao;
import com.epmet.dto.result.AccessSettingResultDTO;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.GetSQLFilterFormDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.RoleOpeScopeResultDTO;
import com.epmet.redis.RoleAccessSettingRedis;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.redis.RoleOpeScopeRedis;
import com.epmet.service.AccessService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -17,12 +28,18 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class AccessServiceImpl implements AccessService {
private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class);
/**
* 线程变量记录是否已经添加了至少一个过滤条件
*/
private static final ThreadLocal<Boolean> hasConditions = new ThreadLocal();
@Autowired
private CpUserDetailRedis cpUserDetailRedis;
@ -30,14 +47,17 @@ public class AccessServiceImpl implements AccessService {
private OperationScopeDao operationScopeDao;
@Autowired
private AccessSettingDao accessSettingDao;
private RoleOpeScopeRedis roleOpeScopeRedis;
@Autowired
private RoleOpeScopeRedis roleOpeScopeRedis;
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private RoleAccessSettingRedis roleAccessSettingRedis;
private EpmetUserFeignClient userFeignClient;
public static final String ORG_RELATION_SAME = "same";
public static final String ORG_RELATION_SUB = "sub";
public static final String ORG_RELATION_SUP = "sup";
/**
* 更新权限缓存
@ -90,38 +110,464 @@ public class AccessServiceImpl implements AccessService {
return scopes;
}
@Override
public List<RoleOpeScopeResultDTO> listAllRoleOperationScopesByRoleId(String roleId) {
List<RoleOpeScopeResultDTO> roleAllOpeScopes = roleOpeScopeRedis.getRoleAllOpeScopes(roleId);
if (roleAllOpeScopes == null) {
roleAllOpeScopes = operationScopeDao.listAllRoleOperationScopesByRoleId(roleId);
roleOpeScopeRedis.setRoleAllOpeScopes(roleId, roleAllOpeScopes);
}
return roleAllOpeScopes;
}
@Override
public Boolean hasPermission(String operationKey, String userId, String app, String client) {
GovTokenDto userDetails = getUserDetails(app, client, userId);
if (userDetails == null) {
return false;
}
Set<String> roleIdList = userDetails.getRoleIdList();
if (CollectionUtils.isEmpty(roleIdList)) {
return false;
}
final Set<String> operationKeys = new HashSet<>();
roleIdList.stream().forEach(roleId -> {
List<RoleOpeScopeResultDTO> opeAndScopes = listAllRoleOperationScopesByRoleId(roleId);
operationKeys.addAll(opeAndScopes.stream().map(opeAndScope -> opeAndScope.getOperationKey()).collect(Collectors.toSet()));
});
if (operationKeys.contains(operationKey)) {
return true;
}
return false;
}
@Override
public String getSqlFilterSegment(GetSQLFilterFormDTO form) {
hasConditions.set(false);
GovTokenDto userDetails = getUserDetails(form.getApp(), form.getClient(), form.getUserId());
if (userDetails == null) {
logger.error("查询SQL过滤脚本:没有找到用户的登陆信息:app: {}, client: {}, userId:{}", form.getApp(), form.getClient(), form.getUserId());
throw new RenException(EpmetErrorCode.ERR10006.getCode());
}
StringBuilder sb = new StringBuilder();
if (CollectionUtils.isEmpty(userDetails.getRoleIdList())) {
//logger.warn("用户{}没有配置任何角色,无法执行{}操作", form.getUserId(), form.getOperationKey());
throw new RenException(String.format("用户%s没有配置任何角色,无法执行%s操作", form.getUserId(), form.getOperationKey()));
}
OpeScopeFilterResultBean effectiveOpeScopes = getEffectiveOpeScopes(userDetails.getRoleIdList(), form.getOperationKey());
if (effectiveOpeScopes.isAllScopes()) {
return sb.toString();
}
HashSet<String> orgLevelScopes = effectiveOpeScopes.getOrgLevelScopes();
Set<String> switchScopes = effectiveOpeScopes.getSwitchScopes();
// 生成组织上下级关系系列的sql过滤片段
if (!CollectionUtil.isEmpty(orgLevelScopes) && !orgLevelScopes.contains(OpeScopeConstant.ORG_ALL)) {
genOrgLevelScopeSqlFilter(sb, orgLevelScopes, userDetails.getOrgIdPath(), form.getTableAlias());
}
// 生成开关范围的sql过滤器
if (!CollectionUtil.isEmpty(switchScopes)) {
genSwitchScopeSqlFilter(switchScopes, sb, form.getTableAlias(), userDetails.getUserId(), form.getGridId(), form.getDepartmentId());
}
return sb.toString();
}
/**
* 查询角色的权限相关配置
* @param roleId
* 生成开关系列范围sql过滤片段
* @param switchScopes
*/
private void genSwitchScopeSqlFilter(Set<String> switchScopes,
StringBuilder sb,
String tableAlias,
String userId,
String gridId,
String departmentId) {
if (switchScopes.contains(OperationScopeConstant.SCOPE_I_CREATED)) {
genICreatedSql(sb, userId, tableAlias);
}
if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_GRID)) {
if (StringUtils.isBlank(gridId)) {
String error = String.format("DataFilter:拼接SQL语句出错:需要in grid权限,但是代码中没有获取到,GridId:%s", gridId);
logger.error(error);
throw new RenException(error);
}
genInGrid(sb, gridId, tableAlias);
}
if (switchScopes.contains(OperationScopeConstant.SCOPE_IN_DEPARTMENT)) {
if (StringUtils.isBlank(departmentId)) {
String error = String.format("DataFilter:拼接SQL语句出错:需要in department权限,但是代码中没有获取到, departmentId:%s", departmentId);
logger.error(error);
throw new RenException(error);
}
genDepartmentFilterSql(sb, departmentId, tableAlias);
}
}
/**
* sql我发起的
*
* @param userId
*/
private void genICreatedSql(StringBuilder sb, String userId, String tableAlias) {
if (StringUtils.isBlank(tableAlias)) {
sb.append(hasConditions.get() ? " OR " : " ").append(" CREATED_BY ='").append(userId).append("'");
} else {
sb.append(hasConditions.get() ? " OR " : " ").append(tableAlias).append(".CREATED_BY ='").append(userId).append("'");
}
hasConditions.set(true);
}
/**
* 网格sql
*
* @param sb
* @param tableAlias
*/
private void genInGrid(StringBuilder sb, String gridId, String tableAlias) {
if (hasConditions.get()) {
// 之前没有条件
sb.append(" OR ");
}
// OR GRID_ID = 'XXX' OR GRID_ID = 'QQQ'
if (StringUtils.isBlank(tableAlias)) {
sb.append(" GRID_ID = '").append(gridId).append("' ");
} else {
sb.append(" ").append(tableAlias).append(".GRID_ID ='").append(gridId).append("' ");
}
hasConditions.set(true);
}
/**
* 生成部门过滤sql
*
* @param sb
*/
private void genDepartmentFilterSql(StringBuilder sb, String deptId, String tableAlias) {
//Result<List<DepartmentListResultDTO>> deptListResult = govOrgFeignClient.getDepartmentListByStaffId(staffId);
if (hasConditions.get()) {
// 之前没有条件
sb.append(" OR ");
}
if (StringUtils.isBlank(tableAlias)) {
sb.append(" DEPARTMENT_ID = '").append(deptId).append("' ");
} else {
sb.append(" ").append(tableAlias).append(".DEPARTMENT_ID ='").append(deptId).append("' ");
}
hasConditions.set(true);
}
/**
* 计算有效操作范围
*/
public OpeScopeFilterResultBean getEffectiveOpeScopes(Set<String> roleIds, String reqiurePermission) {
// 根据角色列表查询操作范围列表
Set<RoleOpeScopeResultDTO> opeAndScopesOfThisOperation = new HashSet<>();
roleIds.forEach(roleId -> {
List<RoleOpeScopeResultDTO> opes = listAllRoleOperationScopesByRoleId(roleId);
if (!CollectionUtils.isEmpty(opes)) {
opes.forEach(ope -> {
if (reqiurePermission.equals(ope.getOperationKey())) {
// 拿到当前操作对应的 RoleOpeScopeResultDTO
opeAndScopesOfThisOperation.add(ope);
}
});
}
});
// 过滤范围
return filteAndGroupScopes(opeAndScopesOfThisOperation);
}
/**
* 对范围进行过滤和分组
*
* @param scopeDTOS
* @return
*/
@Override
public Map<String, String> listAccessSettings(String roleId, String operationKey) {
Map<String, String> settings = roleAccessSettingRedis.get(roleId, operationKey);
if (settings == null) {
settings = new HashMap<>();
// 数据库查出来,放入redis一份。此处为权限过滤器用到
List<AccessSettingResultDTO> accessSettingDtos = accessSettingDao.listAccessSettingsByRoleId(roleId, operationKey);
if (!CollectionUtils.isEmpty(accessSettingDtos)) {
for (AccessSettingResultDTO setting : accessSettingDtos) {
settings.put(setting.getSettingKey(), setting.getSettingValue());
private OpeScopeFilterResultBean filteAndGroupScopes(Set<RoleOpeScopeResultDTO> scopeDTOS) {
// 存储上下级关系系列范围。先放到Map是为了去重和中途判断
HashMap<String, RoleOpeScopeResultDTO> orgLevelScopes = new HashMap<>();
// 存储开关系列范围
Set<String> switchScopes = new HashSet<>();
// 所有范围
Boolean all = false;
for (RoleOpeScopeResultDTO scope : scopeDTOS) {
if (OpeScopeConstant.ALL.equals(scope.getScopeKey())) {
all = true;
break;
}
if (OperationScopeConstant.SERIES_SWITCH.equals(scope.getSeries())) {
switchScopes.add(scope.getScopeKey());
continue;
}
String scopeIndex = scope.getScopeIndex();
if (OpeScopeConstant.ORG_ALL.equals(scope.getScopeKey())) {
// 该操作具有org_all的权限,直接放入
orgLevelScopes.put(scopeIndex, scope);
continue;
}
String[] currArr = scopeIndex.split("_");
if ("0".equals(currArr[1])) {
// 为0,说明没有包含关系,直接放入
orgLevelScopes.put(scopeIndex, scope);
continue;
}
RoleOpeScopeResultDTO tempScope = orgLevelScopes.get(currArr[0]);
if (tempScope != null) {
// 已经有ac开头的了
String tempScopeIndex = tempScope.getScopeIndex();
if (Integer.valueOf(currArr[1]) < Integer.valueOf(tempScopeIndex.split("_")[1])) {
orgLevelScopes.put(currArr[0], scope);
}
} else {
// 占位,否则空map存不到redis中
settings.put("-", "-");
orgLevelScopes.put(currArr[0], scope);
}
roleAccessSettingRedis.set(settings, roleId, operationKey);
}
return settings;
HashSet<String> scopeStrs = new HashSet<>();
Set<Map.Entry<String, RoleOpeScopeResultDTO>> entries = orgLevelScopes.entrySet();
for (Map.Entry<String, RoleOpeScopeResultDTO> entry : entries) {
scopeStrs.add(entry.getValue().getScopeKey());
}
OpeScopeFilterResultBean resultBean = new OpeScopeFilterResultBean();
resultBean.setOrgLevelScopes(scopeStrs);
resultBean.setSwitchScopes(switchScopes);
resultBean.setAllScopes(all);
return resultBean;
}
/**
* 生成组织上下级关系系列的sql过滤片段
* @param sb
* @param orgIdPath
* @param tableAlias
* @return
*/
private void genOrgLevelScopeSqlFilter(StringBuilder sb, HashSet<String> scopes, String orgIdPath, String tableAlias) {
// 取出父组织ID path 和当前组织ID
//String parentOrgIDPath = orgIdPath.substring(0, orgIdPath.lastIndexOf(orgIdPathSpliter));
//String currOrgID = orgIdPath.substring(orgIdPath.lastIndexOf(orgIdPathSpliter) + 1);
for (String scope : scopes) {
switch (scope) {
// 当前单位(可以用ORG_ID_PATH,也可以用ORG_ID判断)
case OpeScopeConstant.ORG_CURR:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" ORG_ID_PATH = '").append(orgIdPath).append("' OR ");
//sb.append(" ORG_ID = '").append(currOrgID).append("' OR ");
} else {
sb.append(" ").append(tableAlias).append(".ORG_ID_PATH = '").append(orgIdPath).append("' OR ");
//sb.append(" ").append(tableAlias).append(".ORG_ID = '").append(currOrgID).append("' OR ");
}
break;
// 本单位及其子级单位
case OpeScopeConstant.ORG_CURR_AND_SUB:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append("%' OR ");
} else {
sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(orgIdPath).append("%' OR ");
}
break;
// 本单位的子级单位
case OpeScopeConstant.ORG_CURR_SUB:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" ORG_ID_PATH like '").append(orgIdPath).append(":%' OR ");
} else {
sb.append(" ").append(tableAlias).append(".ORG_ID_PATH like '").append(orgIdPath).append(":%' OR ");
}
break;
//当前单位的父级单位
case OpeScopeConstant.ORG_CURR_SUP:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,':%') OR ");
} else {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,':%') OR ");
}
break;
// 当前单位及其父级单位
case OpeScopeConstant.ORG_CURR_AND_SUP:
if (StringUtils.isBlank(tableAlias)) {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append("ORG_ID_PATH,'%') OR ");
} else {
sb.append(" '").append(orgIdPath).append("' like CONCAT(").append(tableAlias).append(".ORG_ID_PATH,'%' ) OR ");
}
break;
case OpeScopeConstant.ORG_EQUAL:
// todo 同级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_AND_SUB:
// todo 同级及其子级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_SUB:
// todo 同级的子级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_AND_SUP:
// todo 同级及其上级
//sb.append(" OR ");
break;
case OpeScopeConstant.ORG_EQUAL_SUP:
// todo 同级的上级
//sb.append(" OR ");
break;
}
}
sb.replace(sb.lastIndexOf("OR"), sb.lastIndexOf("OR") + 3, "");
hasConditions.set(true);
}
@Override
public List<RoleOpeScopeResultDTO> listAllRoleOperationScopesByRoleId(String roleId) {
List<RoleOpeScopeResultDTO> roleAllOpeScopes = roleOpeScopeRedis.getRoleAllOpeScopes(roleId);
if (roleAllOpeScopes == null) {
roleAllOpeScopes = operationScopeDao.listAllRoleOperationScopesByRoleId(roleId);
roleOpeScopeRedis.setRoleAllOpeScopes(roleId, roleAllOpeScopes);
public Set<String> listOperationPermissions(String staffId, String currAgencyId) {
// 1.拿到所属组织机构信息
Result<CustomerAgencyDTO> agencyByStaffRst = govOrgFeignClient.getAgencyByStaff(staffId);
if (!agencyByStaffRst.success()) {
logger.error("根据StaffId查询所属单位出错,StaffId:{}, 错误信息:{}", staffId, agencyByStaffRst.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
return roleAllOpeScopes;
CustomerAgencyDTO belongAgency = agencyByStaffRst.getData();
if (belongAgency == null) {
logger.error("根据StaffId查询所属单位结果为空,StaffId:{}", staffId);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
// 2.拿到当前所处机关单位信息
Result<CustomerAgencyDTO> currAgencyRst = govOrgFeignClient.getAgencyById(currAgencyId);
CustomerAgencyDTO currAgencyDto = currAgencyRst.getData();
if (!currAgencyRst.success() || currAgencyDto == null) {
logger.error("根据当前机构id[{}]查询pids失败:{}", currAgencyId, currAgencyRst.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
// 查询机关单位中的角色
List<GovStaffRoleDTO> roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId());
// 当前组织和所属组织的orgId路径,以及他们的上下级关系
String belongOrgIdPath = getOrgIdPath(belongAgency);
String currOrgIdPath = getOrgIdPath(currAgencyDto);
String currOrgRelation = getCurrOrgRelation(belongOrgIdPath, currOrgIdPath);
Set<String> filtedOps = new HashSet<>();
roleDTOS.forEach(roleDTO -> {
List<RoleOpeScopeResultDTO> opeAndScopeDTO = listAllRoleOperationScopesByRoleId(roleDTO.getId());
filtedOps.addAll(filterOpesByScope(currOrgRelation, opeAndScopeDTO));
});
return filtedOps;
}
/**
* 获取当前所处机关与所属机关的关系
*/
private String getCurrOrgRelation(String belongOrgPath, String currAgencyPath) {
if (belongOrgPath.equals(currAgencyPath)) {
// 当前机关即该人员所属机关
return ORG_RELATION_SAME;
} else if (currAgencyPath.indexOf(belongOrgPath.concat(":")) > -1) {
// 说明当前所在机关是人员所属机关子级,只取出scope为sub的
return ORG_RELATION_SUB;
} else if (belongOrgPath.indexOf(currAgencyPath.concat(":")) > -1) {
// 说明当前所在机关是人员所属机关的上级
return ORG_RELATION_SUP;
}
return belongOrgPath;
}
/**
* 获取组织的orgId路径
*/
public String getOrgIdPath(CustomerAgencyDTO agency) {
// 拼接单位ID全路径
if ("0".equals(agency.getPid())) {
// 顶级组织
return agency.getId();
} else {
return agency.getPids().concat(":").concat(agency.getId());
}
}
public List<GovStaffRoleDTO> queryGovStaffRoles(String staffId, String orgId) {
List<GovStaffRoleDTO> roleDTOS = new ArrayList<>();
StaffRoleFormDTO formDTO = new StaffRoleFormDTO();
formDTO.setStaffId(staffId);
formDTO.setOrgId(orgId);
Result<List<GovStaffRoleDTO>> gridResult = userFeignClient.getRolesOfStaff(formDTO);
if (!CollectionUtils.isEmpty(gridResult.getData())) {
roleDTOS.addAll(gridResult.getData());
}
return roleDTOS;
}
/**
* 根据上下级关系过滤出要返回的权限列表
*
* @param currOrgRelation
* @param roleOperations
* @return
*/
private HashSet<String> filterOpesByScope(String currOrgRelation, List<RoleOpeScopeResultDTO> roleOperations) {
HashSet<String> opeKeys = new HashSet<>();
for (RoleOpeScopeResultDTO opeScope : roleOperations) {
String scopeKey = opeScope.getScopeKey();
if (OpeScopeConstant.ORG_ALL.equals(scopeKey) || OpeScopeConstant.ALL.equals(scopeKey)) {
// 如果该操作的范围是org_all或者all,不需要根据上下级关系判断,直接返回即可。
opeKeys.add(opeScope.getOperationKey());
continue;
}
if (!opeScope.getSeries().equals(OperationScopeConstant.SERIES_ORG_LEVEL)) {
// 如果不是org_level系列权限,跳过。(如果一个操作没有分配org_level系列权限,那么无法根据所在机构判断是否具有该功能权限)
// 此时不会给前台返回此功能权限。即要求所有操作必须分配至少一个org_level系列权限(如果实在不需要,可以分配成org_all)。
continue;
}
switch (currOrgRelation) {
case ORG_RELATION_SAME:// 就在所在机构下
if (OpeScopeConstant.ORG_CURR.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) {
opeKeys.add(opeScope.getOperationKey());
}
break;
case ORG_RELATION_SUB:// 所在机构的子级
if (OpeScopeConstant.ORG_CURR_SUB.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey)) {
opeKeys.add(opeScope.getOperationKey());
}
break;
case ORG_RELATION_SUP:// 所在机构的上级
if (OpeScopeConstant.ORG_CURR_SUP.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) {
opeKeys.add(opeScope.getOperationKey());
}
break;
}
}
return opeKeys;
}
}

80
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/AccessSettingDao.xml

@ -1,80 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.AccessSettingDao">
<resultMap type="com.epmet.entity.AccessSettingEntity" id="accessSettingMap">
<result property="id" column="ID"/>
<result property="roleId" column="ROLE_ID"/>
<result property="operationKey" column="OPERATION_KEY"/>
<result property="settingKey" column="SETTING_KEY"/>
<result property="settingValue" column="SETTING_VALUE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!--根据角色查询配置列表-->
<select id="listAccessSettingsByRoleId" resultType="com.epmet.dto.result.AccessSettingResultDTO">
SELECT
s.*,
opt.SETTING_NAME
FROM
access_setting s
INNER JOIN access_setting_options opt ON ( s.SETTING_KEY = opt.SETTING_KEY AND opt.DEL_FLAG = 0)
WHERE
s.ROLE_ID = #{roleId}
AND s.DEL_FLAG = 0
AND s.OPERATION_KEY = #{operationKey}
AND s.DEL_FLAG = 0
</select>
<!--权限配置:列出配置项-->
<select id="listSettingOptionsForAccessConfig"
resultType="com.epmet.dto.result.AccessConfigSettingResultDTO">
SELECT opt.SETTING_KEY,
opt.SETTING_NAME,
s.ROLE_ID,
CASE
WHEN s.ROLE_ID IS NULL THEN FALSE
ELSE TRUE END AS assigned,
s.OPERATION_KEY
FROM access_setting_options opt
LEFT JOIN access_setting s ON (s.DEL_FLAG = 0 AND opt.SETTING_KEY = s.SETTING_KEY AND s.ROLE_ID = #{roleId}
AND s.OPERATION_KEY = #{operationKey})
WHERE opt.DEL_FLAG = 0
ORDER BY opt.SETTING_KEY ASC
</select>
<!--删除-->
<delete id="delete">
DELETE
FROM access_setting
WHERE ROLE_ID = #{roleId}
AND OPERATION_KEY = #{operationKey}
AND SETTING_KEY IN
<foreach collection="settingKeys2Delete" item="settingKey" open="(" separator="," close=")">
#{settingKey}
</foreach>
</delete>
<select id="get" resultType="com.epmet.entity.AccessSettingEntity">
SELECT s.*
FROM access_setting s
WHERE s.ROLE_ID = #{roleId}
AND s.OPERATION_KEY = #{operationKey}
AND s.SETTING_KEY = #{settingKey}
</select>
<!--启用-->
<update id="enable">
UPDATE access_setting s
SET DEL_FLAG = 0
WHERE s.ROLE_ID = #{roleId}
AND s.OPERATION_KEY = #{operationKey}
AND s.SETTING_KEY = #{settingKey}
</update>
</mapper>

20
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/AccessSettingOptionsDao.xml

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.AccessSettingOptionsDao">
<resultMap type="com.epmet.entity.AccessSettingOptionsEntity" id="accessSettingOptionsMap">
<result property="id" column="ID"/>
<result property="settingKey" column="SETTING_KEY"/>
<result property="settingName" column="SETTING_NAME"/>
<result property="brief" column="BRIEF"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

5
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/OperationScopeDao.xml

@ -7,6 +7,9 @@
<result property="id" column="ID"/>
<result property="scopeKey" column="SCOPE_KEY"/>
<result property="scopeName" column="SCOPE_NAME"/>
<result property="scopeIndex" column="SCOPE_INDEX"/>
<result property="series" column="SERIES"/>
<result property="sort" column="SORT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
@ -29,7 +32,7 @@
<!--查询角色所有operation及其范围-->
<select id="listAllRoleOperationScopesByRoleId" resultType="com.epmet.dto.result.RoleOpeScopeResultDTO">
SELECT t.*, os.SCOPE_INDEX
SELECT t.*, os.SCOPE_INDEX, os.SERIES, os.SORT
FROM (
SELECT ope.ROLE_ID,
ope.OPERATION_KEY,

2
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/RoleScopeDao.xml

@ -33,7 +33,7 @@
ON (os.SCOPE_KEY = rs.SCOPE_KEY AND rs.DEL_FLAG = 0 AND rs.ROLE_ID = #{roleId} AND
OPERATION_KEY = #{operationKey})
WHERE os.DEL_FLAG = 0
ORDER BY SCOPE_KEY ASC
ORDER BY os.SORT ASC
</select>
<!--根据角色ID和操作key删除-->

38
epmet-module/gov-access/gov-access-server/src/test/java/com/epmet/test/govaccess/AccessSettingTest.java

@ -1,38 +0,0 @@
package com.epmet.test.govaccess;
import com.epmet.dao.AccessSettingDao;
import com.epmet.dto.result.AccessSettingResultDTO;
import com.epmet.redis.RoleAccessSettingRedis;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest
public class AccessSettingTest {
@Autowired
private AccessSettingDao roleAccessSettingDao;
@Autowired
private RoleAccessSettingRedis roleAccessSettingRedis;
@Test
public void addAccessSettings2Redis() {
List<AccessSettingResultDTO> settings = roleAccessSettingDao.listAccessSettingsByRoleId("1", "org_staff_list");
HashMap<String, String> objectObjectHashMap = new HashMap<>();
settings.forEach(setting -> {
objectObjectHashMap.put(setting.getSettingKey(), setting.getSettingValue());
});
roleAccessSettingRedis.set(objectObjectHashMap, "1", "org_staff_list");
Map<String, String> map = roleAccessSettingRedis.get("1", "org_staff_list");
System.out.println(map);
}
}

2
epmet-module/gov-grid/gov-grid-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-grid-server:
container_name: gov-grid-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-grid-server:0.3.18
image: 192.168.1.130:10080/epmet-cloud-dev/gov-grid-server:0.3.19
ports:
- "8097:8097"
network_mode: host # 使用现有网络

2
epmet-module/gov-grid/gov-grid-server/pom.xml

@ -3,7 +3,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.18</version>
<version>0.3.19</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>gov-grid</artifactId>

6
epmet-module/gov-issue/gov-issue-client/pom.xml

@ -17,5 +17,11 @@
<artifactId>epmet-commons-tools</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>resi-group-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

2
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/PolyLineDTO.java

@ -17,7 +17,7 @@ public class PolyLineDTO implements Serializable {
/**
* 投票日期
*/
private Long voteDtae;
private Long voteDate;
/**
* 当日赞成票数量

5
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java

@ -1,6 +1,7 @@
package com.epmet.dto.form;
import com.epmet.dto.IssueDTO;
import com.epmet.resi.group.dto.topic.ResiTopicDTO;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@ -38,6 +39,10 @@ public class ShiftProjectFormDTO implements Serializable {
* token中工作人员Id
*/
private String staffId;
/**
* 话题对象信息
*/
private ResiTopicDTO topicDTO ;
}

2
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/TickStaffFormDTO.java

@ -26,7 +26,7 @@ public class TickStaffFormDTO implements Serializable {
*/
private String gridId="";
@NotBlank(message = "内部备注不能为空")
@NotBlank(message = "工作人员Id不能为空")
private String staffId;
}

2
epmet-module/gov-issue/gov-issue-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-issue-server:
container_name: gov-issue-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-issue-server:0.3.8
image: 192.168.1.130:10080/epmet-cloud-dev/gov-issue-server:0.3.14
ports:
- "8101:8101"
network_mode: host # 使用现有网络

2
epmet-module/gov-issue/gov-issue-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.8</version>
<version>0.3.14</version>
<parent>
<artifactId>gov-issue</artifactId>
<groupId>com.epmet</groupId>

8
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/constant/UserMessageConstant.java

@ -10,6 +10,10 @@ public interface UserMessageConstant {
* 消息标题
*/
String ISSUE_TITLE = "您有一条议题消息";
/**
* 项目跟踪-消息标题
*/
String PROJECT_TITLE = "您有一条项目消息";
/**
* 议题关闭时选择已解决
@ -26,5 +30,9 @@ public interface UserMessageConstant {
*/
String ISSUE_SHIFT_PROJECT_MSG = "您好,您发表的话题\"%s\"的问题,已由%s部门处理,请查看。";
/**
* 议题转项目消息模板
*/
String PROJECT_RESLOVED_MSG = "您好。您收到一条【%s】的新信息,请您尽快处理。";
}

8
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java

@ -30,6 +30,7 @@ import com.epmet.dto.result.VotingIssueListResultDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.IssueEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -101,6 +102,13 @@ public interface IssueDao extends BaseDao<IssueEntity> {
*/
Integer checkIssuePublisher(VoteFormDTO formDTO);
/**
* @Description 获取转项目或者议题关闭时间
* @param issueId
* @author zxc
*/
String operateTime(@Param("issueId")String issueId);
/**
* @Description 生成昨日的议题日统计信息
* @param

89
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java

@ -402,7 +402,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
}
/**
* @Description 关闭议题议题转项目时给话题创建人和议题发起人发送消息
* @Description 关闭议题时给话题创建人和议题发起人发送消息
* @author sun
*/
private Result saveUserMessageList(ResiTopicDTO topicDTO, String messageContent, IssueEntity entity) {
@ -415,11 +415,14 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
msgDTO.setTitle(UserMessageConstant.ISSUE_TITLE);
msgDTO.setMessageContent(messageContent);
msgDTO.setReadFlag(ReadFlagConstant.UN_READ);
UserMessageFormDTO msgIssue = ConvertUtils.sourceToTarget(msgDTO,UserMessageFormDTO.class);
msgDTO.setUserId(topicDTO.getCreatedBy());
msgList.add(msgDTO);
msgIssue.setUserId(entity.getCreatedBy());
msgList.add(msgIssue);
//话题人和议题人是同一个人时则只发送一条居民消息
if (!topicDTO.getCreatedBy().equals(entity.getCreatedBy())) {
UserMessageFormDTO msgIssue = ConvertUtils.sourceToTarget(msgDTO,UserMessageFormDTO.class);
msgIssue.setUserId(entity.getCreatedBy());
msgList.add(msgIssue);
}
return messageFeignClient.saveUserMessageList(msgList);
}
@ -480,20 +483,28 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
}
formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class));
//2:调用gov-project服务,新增项目各业务表初始数据
//2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId());
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) {
throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION);
}
ResiTopicDTO topicDTO = resultTopicDTO.getData();
formDTO.setTopicDTO(topicDTO);
//3:调用gov-project服务,新增项目各业务表初始数据
Result<IssueProjectResultDTO> resultDTO = govProjectFeignClient.issueShiftProject(formDTO);
if (!resultDTO.success() || null == resultDTO.getData()) {
throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION);
}
IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData();
//3:更新议题相关业务表数据
//3.1:更新议题表数据
//4:更新议题相关业务表数据
//4.1:更新议题表数据
entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
entity.setShiftedTime(issueProjectResultDTO.getShiftedTime());
baseDao.updateById(entity);
//3.2:议题处理进展表新增数据
//4.2:议题处理进展表新增数据
IssueProcessEntity processEntity = new IssueProcessEntity();
processEntity.setIssueId(entity.getId());
processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
@ -502,30 +513,66 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
processEntity.setOrgName(issueProjectResultDTO.getOrgName());
issueProcessDao.insert(processEntity);
//3.3:议题项目关系表新增数据
//4.3:议题项目关系表新增数据
IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity();
relationEntity.setIssueId(entity.getId());
relationEntity.setProjectId(issueProjectResultDTO.getProjectId());
issueProjectRelationDao.insert(relationEntity);
//4:调用epmet-message服务,给居民端话题创建人和议题发起人发送消息
//4.1:调用resi-group查询话题创建人数据(目前议题来源只有来自话题)
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId());
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) {
throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION);
}
ResiTopicDTO topicDTO = resultTopicDTO.getData();
//4.2:创建消息模板
String messageContent = String.format(UserMessageConstant.ISSUE_SHIFT_PROJECT_MSG, topicDTO.getTopicContent(), issueProjectResultDTO.getOrgName());
//4.3:调用服务,发送消息
if (!saveUserMessageList(topicDTO, messageContent, entity).success()) {
//5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息
if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) {
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION);
}
//5:缓存中网格下表决中的议题总数减1
//6:缓存中网格下表决中的议题总数减1
govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId());
}
/**
* @Description 议题转项目时给话题创建人议题发起人勾选的工作人员分别推送消息
* @author sun
*/
private Result shiftProjectMessage(IssueProjectResultDTO issueProjectResultDTO, ShiftProjectFormDTO formDTO, IssueEntity entity) {
List<UserMessageFormDTO> msgList = new ArrayList<>();
//1:创建话题发起人、议题发表人消息对象
UserMessageFormDTO msgDTO = new UserMessageFormDTO();
msgDTO.setCustomerId(entity.getCustomerId());
msgDTO.setGridId(entity.getGridId());
msgDTO.setApp(AppClientConstant.APP_RESI);
msgDTO.setTitle(UserMessageConstant.ISSUE_TITLE);
String topicIssueMessage = String.format(UserMessageConstant.ISSUE_SHIFT_PROJECT_MSG, formDTO.getTopicDTO().getTopicContent(), issueProjectResultDTO.getOrgName());
msgDTO.setMessageContent(topicIssueMessage);
msgDTO.setReadFlag(ReadFlagConstant.UN_READ);
msgDTO.setUserId(formDTO.getTopicDTO().getCreatedBy());
msgList.add(msgDTO);
//话题人和议题人是同一个人时则只发送一条居民消息
if (!formDTO.getTopicDTO().getCreatedBy().equals(entity.getCreatedBy())) {
UserMessageFormDTO msgIssue = ConvertUtils.sourceToTarget(msgDTO, UserMessageFormDTO.class);
msgIssue.setUserId(entity.getCreatedBy());
msgList.add(msgIssue);
}
//2:创建项目工作人员消息对象
String projectStaffMessage = String.format(UserMessageConstant.PROJECT_RESLOVED_MSG, entity.getIssueTitle());
//所选人员如果即在部门下又在网格下则只发一条消息
Map<String,String> map = new HashMap<>();
formDTO.getStaffList().forEach(staff->{
if(!map.containsKey(staff.getStaffId())){
UserMessageFormDTO msg = new UserMessageFormDTO();
msg.setCustomerId(entity.getCustomerId());
msg.setGridId("*");
msg.setApp(AppClientConstant.APP_GOV);
msg.setTitle(UserMessageConstant.PROJECT_TITLE);
msg.setMessageContent(projectStaffMessage);
msg.setReadFlag(ReadFlagConstant.UN_READ);
msg.setUserId(staff.getStaffId());
msgList.add(msg);
map.put(staff.getStaffId(),staff.getStaffId());
}
});
return messageFeignClient.saveUserMessageList(msgList);
}
/**
* @Description
* @param issueListForm

30
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java

@ -27,6 +27,7 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.constant.IssueConstant;
import com.epmet.dao.IssueDao;
import com.epmet.dao.IssueSatisfactionDetailDao;
import com.epmet.dao.IssueVoteStatisticalDao;
import com.epmet.dto.IssueVoteStatisticalDTO;
@ -50,6 +51,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -75,6 +79,8 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
private EpmetUserFeignClient userFeignClient;
@Autowired
private IssueVoteDetailRedis issueVoteDetailRedis;
@Autowired
private IssueDao issueDao;
@Override
public PageData<IssueVoteStatisticalDTO> page(Map<String, Object> params) {
@ -160,13 +166,33 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
*/
@Override
public VotingTrendResultDTO votingTrend(IssueIdFormDTO issueId) {
//应表决数暂时从issue_vote_statistical查询
// VotingTrendResultDTO votingTrendResultDTO = issueVoteStatisticalDao.votingTrend(issueId);
VoteRedisFormDTO voteRedisFormDTO = issueVoteDetailRedis.get(issueId.getIssueId());
VotingTrendResultDTO votingTrendResultDTO = new VotingTrendResultDTO();
BeanUtils.copyProperties(voteRedisFormDTO,votingTrendResultDTO);
votingTrendResultDTO.setRealityVoteCount(voteRedisFormDTO.getSupportAmount()+voteRedisFormDTO.getOppositionAmount());
List<PolyLineDTO> polyLineDTOS = issueVoteStatisticalDao.polyLineData(issueId);
PolyLineDTO polyLineDTO = new PolyLineDTO();
polyLineDTO.setVoteDate(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
//今天刚转项目或刚刚关闭,当天数据DB没有,直接从缓存拿
if (polyLineDTOS.size()==NumConstant.ZERO){
polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount());
polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount());
polyLineDTOS.add(polyLineDTO);
}else {
//折线数据=DB
String date = issueDao.operateTime(issueId.getIssueId());
if (date.equals(LocalDate.now().toString())) {
Integer yesterdaySupport = 0;
Integer yesterdayOppose = 0;
for (PolyLineDTO lineDTO : polyLineDTOS) {
yesterdaySupport += lineDTO.getSupportIncrement();
yesterdayOppose += lineDTO.getOppositionIncrement();
}
polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount() - yesterdaySupport);
polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount() - yesterdayOppose);
polyLineDTOS.add(polyLineDTO);
}
}
votingTrendResultDTO.setPolyLine(polyLineDTOS);
return votingTrendResultDTO;
}

11
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml

@ -258,6 +258,17 @@
AND id = #{issueId}
</select>
<!-- 获取转项目或者议题关闭时间 -->
<select id="operateTime" resultType="java.lang.String">
SELECT
DATE_FORMAT(updated_time,'%Y-%m-%d') AS updateTime
FROM
issue
WHERE
del_flag = 0
AND id = #{issueId}
</select>
<!-- 生成昨日的话题统计信息 -->
<select id="getIssueVotingStatistical" resultType="com.epmet.dto.result.IssuesToBeCountedResultDTO">

2
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDao.xml

@ -58,7 +58,7 @@
<!-- 获取折线每天的支持、反对数量 (按时间正序) -->
<select id="polyLineData" parameterType="com.epmet.dto.form.IssueIdFormDTO" resultType="com.epmet.dto.PolyLineDTO">
SELECT
UNIX_TIMESTAMP(statistical_date) AS voteDtae,
UNIX_TIMESTAMP(statistical_date) AS voteDate,
support_increment AS supportIncrement,
opposition_increment AS oppositionIncrement
FROM

2
epmet-module/gov-mine/gov-mine-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-mine-server:
container_name: gov-mine-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-mine-server:0.3.15
image: 192.168.1.130:10080/epmet-cloud-dev/gov-mine-server:0.3.18
ports:
- "8098:8098"
network_mode: host # 使用现有网络

2
epmet-module/gov-mine/gov-mine-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.15</version>
<version>0.3.18</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>gov-mine</artifactId>

8
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/GovAccessFeignClient.java

@ -3,6 +3,7 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.OperationScopeDTO;
import com.epmet.dto.form.ListOpePermsFormDTO;
import com.epmet.dto.form.OperationScopeFormDTO;
import com.epmet.dto.form.StaffPermCacheFormDTO;
import com.epmet.dto.result.RoleOpeScopeResultDTO;
@ -55,4 +56,11 @@ public interface GovAccessFeignClient {
@PostMapping("/gov/access/access/roleallopesandscopes/{roleId}")
Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(@PathVariable("roleId") String roleId);
/**
* 列出觉得的功能权限列表
* @return
*/
@PostMapping("/gov/access/access/listoperationpermissions")
Result<Set<String>> listOperationPermissions(@RequestBody ListOpePermsFormDTO listOpePermsFormDTO);
}

6
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallback.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.OperationScopeDTO;
import com.epmet.dto.form.ListOpePermsFormDTO;
import com.epmet.dto.form.OperationScopeFormDTO;
import com.epmet.dto.form.StaffPermCacheFormDTO;
import com.epmet.dto.result.RoleOpeScopeResultDTO;
@ -46,4 +47,9 @@ public class GovAccessFeignClientFallback implements GovAccessFeignClient {
public Result<List<RoleOpeScopeResultDTO>> listRoleAllOperationScopesByRoleId(String roleId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listRoleAllOperationScopesByRoleId", roleId);
}
@Override
public Result<Set<String>> listOperationPermissions(ListOpePermsFormDTO listOpePermsFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ACCESS_SERVER, "listOperationPermissions", listOpePermsFormDTO);
}
}

257
epmet-module/gov-mine/gov-mine-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java

@ -1,24 +1,15 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.OpeScopeConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.OperationScopeDTO;
import com.epmet.dto.form.StaffRoleFormDTO;
import com.epmet.dto.result.RoleOpeScopeResultDTO;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.dto.form.ListOpePermsFormDTO;
import com.epmet.feign.GovAccessFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.service.AccessService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
@ -27,253 +18,21 @@ public class AccessServiceImpl implements AccessService {
private static Logger logger = LoggerFactory.getLogger(AccessServiceImpl.class);
@Autowired
private EpmetUserFeignClient userFeignClient;
@Autowired
private GovAccessFeignClient govAccessFeignClient;
@Autowired
private GovOrgFeignClient govOrgFeignClient;
public static final String ORG_RELATION_SAME = "same";
public static final String ORG_RELATION_SUB = "sub";
public static final String ORG_RELATION_SUP = "sup";
public List<GovStaffRoleDTO> queryGovStaffRoles(String staffId, String orgId) {
List<GovStaffRoleDTO> roleDTOS = new ArrayList<>();
StaffRoleFormDTO formDTO = new StaffRoleFormDTO();
formDTO.setStaffId(staffId);
formDTO.setOrgId(orgId);
Result<List<GovStaffRoleDTO>> gridResult = userFeignClient.getRolesOfStaff(formDTO);
if (!CollectionUtils.isEmpty(gridResult.getData())) {
roleDTOS.addAll(gridResult.getData());
}
return roleDTOS;
}
@Override
public Set<String> listOpeKeysByStaffId(String app, String client, String staffId, String currAgencyId, String currGridId) {
// 1.拿到所属组织机构信息
Result<CustomerAgencyDTO> agencyByStaffRst = govOrgFeignClient.getAgencyByStaff(staffId);
if (!agencyByStaffRst.success()) {
logger.error("根据StaffId查询所属单位出错,StaffId:{}, 错误信息:{}", staffId, agencyByStaffRst.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
CustomerAgencyDTO belongAgency = agencyByStaffRst.getData();
if (belongAgency == null) {
logger.error("根据StaffId查询所属单位结果为空,StaffId:{}", staffId);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
// 2.拿到当前所处机关单位信息
Result<CustomerAgencyDTO> currAgencyRst = govOrgFeignClient.getAgencyById(currAgencyId);
CustomerAgencyDTO currAgencyDto = currAgencyRst.getData();
if (!currAgencyRst.success() || currAgencyDto == null) {
logger.error("根据当前机构id[{}]查询pids失败:{}", currAgencyId, currAgencyRst.getMsg());
ListOpePermsFormDTO listOpePermsFormDTO = new ListOpePermsFormDTO();
listOpePermsFormDTO.setStaffId(staffId);
listOpePermsFormDTO.setCurrAgencyId(currAgencyId);
Result<Set<String>> result = govAccessFeignClient.listOperationPermissions(listOpePermsFormDTO);
if (!result.success()) {
logger.error("调用GovAccess服务查询功能权限列表失败,StaffId:{},错误信息:{}", staffId, result.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
// 拿到该用户所属的组织机构的orgIdPath,拿到当前组织机构的orgIdPath,看当前组织机构的orgIdPath是否在用户所属的组织机构的orgIdPath下
// 查询机关单位中的角色
List<GovStaffRoleDTO> roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId());
// 拼装操作key列表
//Set<String> opeKeys = new HashSet<>();
// 角色ID列表
//Set<String> roleIds = new HashSet<>();
// 当前组织和所属组织的orgId路径,以及他们的上下级关系
String belongOrgIdPath = getOrgIdPath(belongAgency);
String currOrgIdPath = getOrgIdPath(currAgencyDto);
String currOrgRelation = getCurrOrgRelation(belongOrgIdPath, currOrgIdPath);
HashSet<String> filtedOps = new HashSet<>();
roleDTOS.forEach(roleDto -> {
String roleId = roleDto.getId();
// 找出该角色的所有功能操作列表
Result<List<RoleOpeScopeResultDTO>> result = govAccessFeignClient.listRoleAllOperationScopesByRoleId(roleId);
if (!result.success()) {
// 获取operation异常
logger.error("调用GovAccess,根据RoleId查询Operation列表失败:{}", result.getMsg());
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode());
}
List<RoleOpeScopeResultDTO> roleOperations = result.getData();
filtedOps.addAll(filterOpesByScope(currOrgRelation, roleOperations));
});
return filtedOps;
}
/**
* 根据上下级关系过滤出要返回的权限列表
*
* @param currOrgRelation
* @param roleOperations
* @return
*/
private HashSet<String> filterOpesByScope(String currOrgRelation, List<RoleOpeScopeResultDTO> roleOperations) {
HashSet<String> opeKeys = new HashSet<>();
for (RoleOpeScopeResultDTO opeScope : roleOperations) {
String scopeKey = opeScope.getScopeKey();
if (OpeScopeConstant.ORG_ALL.equals(scopeKey)) {
// 如果该操作的范围是org_all,那就具有所有范围的该操作权限,不需要根据上下级关系判断
opeKeys.add(opeScope.getOperationKey());
continue;
}
switch (currOrgRelation) {
case ORG_RELATION_SAME:// 就在所在机构下
if (OpeScopeConstant.ORG_CURR.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) {
opeKeys.add(opeScope.getOperationKey());
}
break;
case ORG_RELATION_SUB:// 所在机构的子级
if (OpeScopeConstant.ORG_CURR_SUB.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUB.equals(scopeKey)) {
opeKeys.add(opeScope.getOperationKey());
}
break;
case ORG_RELATION_SUP:// 所在机构的上级
if (OpeScopeConstant.ORG_CURR_SUP.equals(scopeKey)
|| OpeScopeConstant.ORG_CURR_AND_SUP.equals(scopeKey)) {
opeKeys.add(opeScope.getOperationKey());
}
break;
}
}
return opeKeys;
}
/**
* 获取当前所处机关与所属机关的关系
*/
private String getCurrOrgRelation(String belongOrgPath, String currAgencyPath) {
if (belongOrgPath.equals(currAgencyPath)) {
// 当前机关即该人员所属机关
return ORG_RELATION_SAME;
} else if (currAgencyPath.indexOf(belongOrgPath.concat(":")) > -1) {
// 说明当前所在机关是人员所属机关子级,只取出scope为sub的
return ORG_RELATION_SUB;
} else if (belongOrgPath.indexOf(currAgencyPath.concat(":")) > -1) {
// 说明当前所在机关是人员所属机关的上级
return ORG_RELATION_SUP;
}
return belongOrgPath;
}
/**
* 获取组织的orgId路径
*/
public String getOrgIdPath(CustomerAgencyDTO agency) {
// 拼接单位ID全路径
if ("0".equals(agency.getPid())) {
// 顶级组织
return agency.getId();
} else {
return agency.getPids().concat(":").concat(agency.getId());
}
}
//private boolean filterCurrOrgKeysByScope(Set<String> roleIds, String opeKey) {
// for (String roleId : roleIds) {
// Result<Set<RoleOpeScopeResultDTO>> result = govAccessFeignClient.listRoleAllOperationScopesByRoleId(roleId);
// if (!result.success()) {
// continue;
// }
// Set<RoleOpeScopeResultDTO> scopeDTOS = result.getData();
// Set<String> scopeKeys = scopeDTOS.stream()
// .filter(scope -> scope.getScopeKey().equals(opeKey))
// .map(scope -> scope.getScopeKey())
// .collect(Collectors.toSet());
// if (scopeKeys.contains(OpeScopeConstant.ORG_CURR)
// || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUB)
// || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUP)) {
// return true;
// }
// }
// return false;
//}
//private boolean filterSubOrgKeysByScope(Set<String> roleIds, String opeKey) {
// for (String roleId : roleIds) {
// OperationScopeFormDTO opeScopeFormDTO = new OperationScopeFormDTO();
// opeScopeFormDTO.setRoleId(roleId);
// opeScopeFormDTO.setOperationKey(opeKey);
// Result<Set<OperationScopeDTO>> result = govAccessFeignClient.getOperationScopesByRoleId(opeScopeFormDTO);
// if (!result.success()) {
// continue;
// }
//
// Set<OperationScopeDTO> scopeDTOS = result.getData();
// Set<String> scopeKeys = scopeDTOS.stream().map(scope -> scope.getScopeKey()).collect(Collectors.toSet());
// if (scopeKeys.contains(OpeScopeConstant.ORG_CURR_SUB)
// || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUB)) {
// return true;
// }
// }
// return false;
//}
//private boolean filterSupOrgKeysByScope(Set<String> roleIds, String opeKey) {
// for (String roleId : roleIds) {
// OperationScopeFormDTO opeScopeFormDTO = new OperationScopeFormDTO();
// opeScopeFormDTO.setRoleId(roleId);
// opeScopeFormDTO.setOperationKey(opeKey);
// Result<Set<OperationScopeDTO>> result = govAccessFeignClient.getOperationScopesByRoleId(opeScopeFormDTO);
// if (!result.success()) {
// continue;
// }
//
// Set<OperationScopeDTO> scopeDTOS = result.getData();
// Set<String> scopeKeys = scopeDTOS.stream().map(scope -> scope.getScopeKey()).collect(Collectors.toSet());
// if (scopeKeys.contains(OpeScopeConstant.ORG_CURR_SUP)
// || scopeKeys.contains(OpeScopeConstant.ORG_CURR_AND_SUP)) {
// return true;
// }
// }
// return false;
//}
/**
* 过滤有效范围
*
* @param scopeDTOS
* @return
*/
private HashSet<String> filteScopes(Set<OperationScopeDTO> scopeDTOS) {
HashMap<String, OperationScopeDTO> filtedScopes = new HashMap<>();
for (OperationScopeDTO scope : scopeDTOS) {
String scopeIndex = scope.getScopeIndex();
if (StringUtils.isBlank(scopeIndex)) {
continue;
}
String[] currArr = scopeIndex.split("_");
if ("0".equals(currArr[1])) {
// 为0,说明没有包含关系,直接放入
filtedScopes.put(scopeIndex, scope);
continue;
}
OperationScopeDTO tempScope = filtedScopes.get(currArr[0]);
if (tempScope != null) {
// 已经有ac开头的了
String tempScopeIndex = tempScope.getScopeIndex();
if (Integer.valueOf(currArr[1]) < Integer.valueOf(tempScopeIndex.split("_")[1])) {
filtedScopes.put(currArr[0], scope);
}
} else {
filtedScopes.put(currArr[0], scope);
}
}
HashSet<String> scopeStrs = new HashSet<>();
Set<Map.Entry<String, OperationScopeDTO>> entries = filtedScopes.entrySet();
for (Map.Entry<String, OperationScopeDTO> entry : entries) {
scopeStrs.add(entry.getValue().getScopeKey());
}
return scopeStrs;
return result.getData();
}
}

2
epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-org-server:
container_name: gov-org-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.38
image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.43
ports:
- "8092:8092"
network_mode: host # 使用现有网络

2
epmet-module/gov-org/gov-org-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.3.38</version>
<version>0.3.43</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>gov-org</artifactId>

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

@ -265,6 +265,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
for (CustomerStaffDepartmentDTO dept : deptStaffs) {
if (dept.getUserId().equals(stf.getStaffId())) {
itDept.remove();
break;
}
}
}
@ -275,6 +276,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
for (CustomerStaffGridDTO grid : gridStaffs) {
if (grid.getUserId().equals(stf.getStaffId())) {
itGrid.remove();
break;
}
}
}

91
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ProjectRelatedPersonnelDTO.java

@ -0,0 +1,91 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 项目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-20
*/
@Data
public class ProjectRelatedPersonnelDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键 唯一标识
*/
private String id;
/**
* 项目ID
*/
private String projectId;
/**
* 所属端 居民端用户resi政府端工作人员gov运营端工作人员oper
*/
private String app;
/**
* 网格ID app=resi时此列为gridId,其他情况暂定 *
*/
private String gridId;
/**
* 用户ID
*/
private String userId;
/**
* 删除标识
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

2
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/TickStaffFormDTO.java

@ -29,7 +29,7 @@ public class TickStaffFormDTO implements Serializable {
*/
private String gridId;
@NotBlank(message = "内部备注不能为空")
@NotBlank(message = "工作人员Id不能为空")
private String staffId;
}

2
epmet-module/gov-project/gov-project-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-project-server:
container_name: gov-project-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-project-server:0.3.6
image: 192.168.1.130:10080/epmet-cloud-dev/gov-project-server:0.3.11
ports:
- "8102:8102"
network_mode: host # 使用现有网络

8
epmet-module/gov-project/gov-project-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.6</version>
<version>0.3.11</version>
<parent>
<artifactId>gov-project</artifactId>
<groupId>com.epmet</groupId>
@ -84,6 +84,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-message-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

16
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -93,4 +93,20 @@ public interface ProjectConstant {
* 调用gov-org服务查询数据失败
*/
String UNHANDLED_EXCEPTION = "已转过其他部门,不能再次操作";
/**
* 调用user-message服务失败
*/
String SAVE_MSG_EXCEPTION = "发送消息失败";
/**
* 查询项目表数据失败
*/
String SELECT_PROJECT_EXCEPTION = "获取项目数据失败";
/**
* 居民端
*/
String RESI = "resi";
/**
* 政府端
*/
String GOV = "gov";
}

24
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/UserMessageConstant.java

@ -0,0 +1,24 @@
package com.epmet.constant;
/**
* @Description 项目跟踪模块消息通知
* @Author sun
*/
public interface UserMessageConstant {
/**
* 消息标题
*/
String PROJECT_TITLE = "您有一条项目消息";
/**
* 议题转项目项目流转项目退回消息模板
*/
String PROJECT_RESOLVED_MSG = "您好。您收到一条【%s】的新信息,请您尽快处理。";
/**
* 项目结案消息模板
*/
String PROJECT_CLOSED_MSG = "您好,您参与的【%s】项目已结案,原因:%s";
}

94
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ProjectRelatedPersonnelController.java

@ -0,0 +1,94 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.ProjectRelatedPersonnelDTO;
import com.epmet.excel.ProjectRelatedPersonnelExcel;
import com.epmet.service.ProjectRelatedPersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 项目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-20
*/
@RestController
@RequestMapping("projectrelatedpersonnel")
public class ProjectRelatedPersonnelController {
@Autowired
private ProjectRelatedPersonnelService projectRelatedPersonnelService;
@GetMapping("page")
public Result<PageData<ProjectRelatedPersonnelDTO>> page(@RequestParam Map<String, Object> params){
PageData<ProjectRelatedPersonnelDTO> page = projectRelatedPersonnelService.page(params);
return new Result<PageData<ProjectRelatedPersonnelDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<ProjectRelatedPersonnelDTO> get(@PathVariable("id") String id){
ProjectRelatedPersonnelDTO data = projectRelatedPersonnelService.get(id);
return new Result<ProjectRelatedPersonnelDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody ProjectRelatedPersonnelDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
projectRelatedPersonnelService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody ProjectRelatedPersonnelDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
projectRelatedPersonnelService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
projectRelatedPersonnelService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ProjectRelatedPersonnelDTO> list = projectRelatedPersonnelService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, ProjectRelatedPersonnelExcel.class);
}
}

52
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/AccessSettingOptionsEntity.java → epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectRelatedPersonnelDao.java

@ -15,42 +15,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
package com.epmet.dao;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ProjectRelatedPersonnelDTO;
import com.epmet.entity.ProjectRelatedPersonnelEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 权限配置选
* 项目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-29
* @since v1.0.0 2020-05-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("access_setting_options")
public class AccessSettingOptionsEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 配置KEY
*/
private String settingKey;
/**
* 配置name
*/
private String settingName;
/**
* 简介
*/
private String brief;
}
@Mapper
public interface ProjectRelatedPersonnelDao extends BaseDao<ProjectRelatedPersonnelEntity> {
/**
* 查找项目关联人员
* @author zhaoqifeng
* @date 2020/5/20 13:45
* @param projectId
* @return java.util.List<com.epmet.dto.ProjectRelatedPersonnelDTO>
*/
List<ProjectRelatedPersonnelDTO> selectPersonnelListByProjectId(@Param("projectId") String projectId);
}

9
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectStaffDao.java

@ -54,4 +54,13 @@ public interface ProjectStaffDao extends BaseDao<ProjectStaffEntity> {
*/
ProjectStaffDTO selectProjectStaffInfo(@Param("processId") String processId);
/**
* 获取项目关联的工作人员ID
* @author zhaoqifeng
* @date 2020/5/20 14:32
* @param projectId
* @return java.util.List<java.lang.String>
*/
List<String> selectStaffsByProjectId(@Param("projectId") String projectId);
}

24
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/entity/AccessSettingEntity.java → epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ProjectRelatedPersonnelEntity.java

@ -26,36 +26,36 @@ import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 权限配置
* 项目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-29
* @since v1.0.0 2020-05-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("access_setting")
public class AccessSettingEntity extends BaseEpmetEntity {
@TableName("project_related_personnel")
public class ProjectRelatedPersonnelEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 角色ID
* 项目ID
*/
private String roleId;
private String projectId;
/**
* 操作key
* 所属端 居民端用户resi政府端工作人员gov运营端工作人员oper
*/
private String operationKey;
private String app;
/**
* 配置KEY
* 网格ID app=resi时此列为gridId,其他情况暂定 *
*/
private String settingKey;
private String gridId;
/**
* 配置值
* 用户ID
*/
private String settingValue;
private String userId;
}

68
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/excel/ProjectRelatedPersonnelExcel.java

@ -0,0 +1,68 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 项目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-20
*/
@Data
public class ProjectRelatedPersonnelExcel {
@Excel(name = "主键 唯一标识")
private String id;
@Excel(name = "项目ID")
private String projectId;
@Excel(name = "所属端 居民端用户resi、政府端工作人员gov、运营端工作人员oper")
private String app;
@Excel(name = "网格ID app=resi时,此列为gridId,其他情况暂定 *")
private String gridId;
@Excel(name = "用户ID")
private String userId;
@Excel(name = "删除标识")
private String delFlag;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
}

29
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/feign/MessageFeignClient.java

@ -0,0 +1,29 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.feign.fallback.MessageFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @Description 调用epmet-message服务
* @Author sun
* , url = "localhost:8085"
*/
@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = MessageFeignClientFallback.class)
public interface MessageFeignClient {
/**
* @param msgList
* @return com.epmet.commons.tools.utils.Result
* @Author sun
* @Description 批量推送消息
**/
@PostMapping(value = "message/usermessage/saveusermessagelist", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result saveUserMessageList(List<UserMessageFormDTO> msgList);
}

23
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/feign/fallback/MessageFeignClientFallback.java

@ -0,0 +1,23 @@
package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.feign.MessageFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Description 调用epmet-message服务
* @Author sun
*/
@Component
public class MessageFeignClientFallback implements MessageFeignClient {
@Override
public Result saveUserMessageList(List<UserMessageFormDTO> msgList) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "saveUserMessageList", msgList);
}
}

32
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/AccessSettingOptionsDao.java → epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/redis/ProjectRelatedPersonnelRedis.java

@ -15,19 +15,33 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
package com.epmet.redis;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.AccessSettingOptionsEntity;
import org.apache.ibatis.annotations.Mapper;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 权限配置选
* 目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-04-29
* @since v1.0.0 2020-05-20
*/
@Mapper
public interface AccessSettingOptionsDao extends BaseDao<AccessSettingOptionsEntity> {
@Component
public class ProjectRelatedPersonnelRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

104
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectRelatedPersonnelService.java

@ -0,0 +1,104 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.ProjectRelatedPersonnelDTO;
import com.epmet.entity.ProjectRelatedPersonnelEntity;
import java.util.List;
import java.util.Map;
/**
* 项目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-20
*/
public interface ProjectRelatedPersonnelService extends BaseService<ProjectRelatedPersonnelEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<ProjectRelatedPersonnelDTO>
* @author generator
* @date 2020-05-20
*/
PageData<ProjectRelatedPersonnelDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<ProjectRelatedPersonnelDTO>
* @author generator
* @date 2020-05-20
*/
List<ProjectRelatedPersonnelDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return ProjectRelatedPersonnelDTO
* @author generator
* @date 2020-05-20
*/
ProjectRelatedPersonnelDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2020-05-20
*/
void save(ProjectRelatedPersonnelDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2020-05-20
*/
void update(ProjectRelatedPersonnelDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2020-05-20
*/
void delete(String[] ids);
/**
* 查找项目关联人员
* @author zhaoqifeng
* @date 2020/5/20 13:52
* @param projectId
* @return java.util.List<com.epmet.dto.ProjectRelatedPersonnelDTO>
*/
List<ProjectRelatedPersonnelDTO> getPersonnelListByProjectId(String projectId);
}

9
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ProjectStaffService.java

@ -122,4 +122,13 @@ public interface ProjectStaffService extends BaseService<ProjectStaffEntity> {
* @Description 项目跟踪-部门人员选择
**/
DepartmentStaffListResultDTO departmentStaffList(DepartmentStaffListFormDTO formDTO);
/**
* 获取项目关联的工作人员ID
* @author zhaoqifeng
* @date 2020/5/20 14:36
* @param projectId
* @return java.util.List<java.lang.String>
*/
List<String> getStaffsByProjectId(String projectId);
}

42
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java

@ -20,6 +20,7 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
@ -27,6 +28,8 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ProjectConstant;
import com.epmet.constant.ReadFlagConstant;
import com.epmet.constant.UserMessageConstant;
import com.epmet.dao.ProjectProcessDao;
import com.epmet.dao.ProjectStaffDao;
import com.epmet.dto.CustomerAgencyDTO;
@ -38,6 +41,7 @@ import com.epmet.entity.ProjectProcessEntity;
import com.epmet.entity.ProjectStaffEntity;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.MessageFeignClient;
import com.epmet.redis.ProjectProcessRedis;
import com.epmet.service.ProjectProcessService;
import com.epmet.service.ProjectService;
@ -74,6 +78,8 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
private ProjectProcessDao projectProcessDao;
@Autowired
private ProjectStaffService projectStaffService;
@Autowired
private com.epmet.feign.MessageFeignClient messageFeignClient;
@Override
public PageData<ProjectProcessDTO> page(Map<String, Object> params) {
@ -245,6 +251,42 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
entityList.add(entity);
});
projectStaffService.insertBatch(entityList);
//4:调用epmet-message服务,给项目流转过程中的工作人员发送消息
if (!transferMessage(formDTO).success()) {
throw new RenException(ProjectConstant.SAVE_MSG_EXCEPTION);
}
}
/**
* @Description 项目流转给流转工作人员推送消息
* @author sun
*/
private Result transferMessage(TransferFormDTO formDTO) {
List<UserMessageFormDTO> msgList = new ArrayList<>();
ProjectEntity projectEntity = projectService.selectById(formDTO.getProjectId());
if (null == projectEntity) {
throw new RenException(ProjectConstant.SELECT_PROJECT_EXCEPTION);
}
//3:创建项目工作人员消息对象
//所选人员如果即在部门下又在网格下则只发一条消息
Map<String,String> map = new HashMap<>();
String projectStaffMessage = String.format(UserMessageConstant.PROJECT_RESOLVED_MSG, projectEntity.getTitle());
formDTO.getStaffList().forEach(staff->{
if(!map.containsKey(staff.getStaffId())){
UserMessageFormDTO msg = new UserMessageFormDTO();
msg.setCustomerId(projectEntity.getCustomerId());
msg.setGridId("*");
msg.setApp(AppClientConstant.APP_GOV);
msg.setTitle(UserMessageConstant.PROJECT_TITLE);
msg.setMessageContent(projectStaffMessage);
msg.setReadFlag(ReadFlagConstant.UN_READ);
msg.setUserId(staff.getStaffId());
msgList.add(msg);
map.put(staff.getStaffId(),staff.getStaffId());
}
});
return messageFeignClient.saveUserMessageList(msgList);
}
/**

109
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectRelatedPersonnelServiceImpl.java

@ -0,0 +1,109 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.ProjectRelatedPersonnelDao;
import com.epmet.dto.ProjectRelatedPersonnelDTO;
import com.epmet.entity.ProjectRelatedPersonnelEntity;
import com.epmet.redis.ProjectRelatedPersonnelRedis;
import com.epmet.service.ProjectRelatedPersonnelService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 项目相关人员表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-05-20
*/
@Service
public class ProjectRelatedPersonnelServiceImpl extends BaseServiceImpl<ProjectRelatedPersonnelDao, ProjectRelatedPersonnelEntity> implements ProjectRelatedPersonnelService {
@Autowired
private ProjectRelatedPersonnelRedis projectRelatedPersonnelRedis;
@Override
public PageData<ProjectRelatedPersonnelDTO> page(Map<String, Object> params) {
IPage<ProjectRelatedPersonnelEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ProjectRelatedPersonnelDTO.class);
}
@Override
public List<ProjectRelatedPersonnelDTO> list(Map<String, Object> params) {
List<ProjectRelatedPersonnelEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ProjectRelatedPersonnelDTO.class);
}
private QueryWrapper<ProjectRelatedPersonnelEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<ProjectRelatedPersonnelEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public ProjectRelatedPersonnelDTO get(String id) {
ProjectRelatedPersonnelEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, ProjectRelatedPersonnelDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(ProjectRelatedPersonnelDTO dto) {
ProjectRelatedPersonnelEntity entity = ConvertUtils.sourceToTarget(dto, ProjectRelatedPersonnelEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ProjectRelatedPersonnelDTO dto) {
ProjectRelatedPersonnelEntity entity = ConvertUtils.sourceToTarget(dto, ProjectRelatedPersonnelEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
public List<ProjectRelatedPersonnelDTO> getPersonnelListByProjectId(String projectId) {
return baseDao.selectPersonnelListByProjectId(projectId);
}
}

81
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

@ -20,6 +20,8 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
@ -29,21 +31,21 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ParameterKeyConstant;
import com.epmet.constant.ProjectConstant;
import com.epmet.constant.UserMessageConstant;
import com.epmet.dao.ProjectDao;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.ProjectEntity;
import com.epmet.entity.ProjectProcessEntity;
import com.epmet.entity.ProjectRelatedPersonnelEntity;
import com.epmet.entity.ProjectStaffEntity;
import com.epmet.feign.CommonFeignClient;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.feign.MessageFeignClient;
import com.epmet.redis.ProjectRedis;
import com.epmet.service.CustomerProjectParameterService;
import com.epmet.service.ProjectProcessService;
import com.epmet.service.ProjectService;
import com.epmet.service.ProjectStaffService;
import com.epmet.service.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -76,6 +78,10 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
private EpmetUserFeignClient epmetUserFeignClient;
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private MessageFeignClient messageFeignClient;
@Autowired
private ProjectRelatedPersonnelService projectRelatedPersonnelService;
private final static String ONE_DAY = "<1";
@ -186,7 +192,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
if (ProjectConstant.CLOSED.equals(p.getStatus())) {
created.setDepartmentNameList(departmentNameList);
created.setWarningFlag(false);
created.setDetentionDays("0");
created.setDetentionDays(NumConstant.ZERO_STR);
} else {
String detentionDays = getDetentionDays(p);
if (!ONE_DAY.equals(detentionDays) && Integer.parseInt(detentionDays) > finalDays) {
@ -229,7 +235,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
if (ProjectConstant.CLOSED.equals(p.getStatus())) {
involved.setDepartmentNameList(departmentNameList);
involved.setWarningFlag(false);
involved.setDetentionDays("0");
involved.setDetentionDays(NumConstant.ZERO_STR);
} else {
String detentionDays = getDetentionDays(p);
if (!ONE_DAY.equals(detentionDays) && Integer.parseInt(detentionDays) > finalDays) {
@ -258,7 +264,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
projectStaffDTO.setProjectId(fromDTO.getProjectId());
projectStaffDTO.setStaffId(fromDTO.getUserId());
List<DepartmentResultDTO> departmentList = projectStaffService.getDepartmentNameList(projectStaffDTO);
if (null != departmentList && departmentList.size() > 0) {
if (null != departmentList && departmentList.size() > NumConstant.ZERO) {
resultDTO.setProcessable(true);
} else {
resultDTO.setProcessable(false);
@ -311,6 +317,37 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
projectProcessEntity.setStaffId(fromDTO.getUserId());
projectProcessEntity.setCostWorkdays(getDetentionDays(ConvertUtils.sourceToTarget(projectEntity, ProjectDTO.class)));
projectProcessService.insert(projectProcessEntity);
//通知
List<UserMessageFormDTO> msgList = new ArrayList<>();
//通知项目相关人员
List<ProjectRelatedPersonnelDTO> personnelList = projectRelatedPersonnelService.getPersonnelListByProjectId(fromDTO.getProjectId());
personnelList.forEach(p -> {
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO();
messageFormDTO.setCustomerId(projectEntity.getCustomerId());
messageFormDTO.setApp(p.getApp());
messageFormDTO.setGridId(p.getGridId());
messageFormDTO.setUserId(p.getUserId());
messageFormDTO.setTitle(UserMessageConstant.PROJECT_TITLE);
messageFormDTO.setMessageContent(String.format(UserMessageConstant.PROJECT_CLOSED_MSG, projectEntity.getTitle(), fromDTO.getPublicReply()));
messageFormDTO.setReadFlag(Constant.UNREAD);
msgList.add(messageFormDTO);
});
//通知项目关联的部门人员
List<String> staffList = projectStaffService.getStaffsByProjectId(fromDTO.getProjectId());
staffList.add(projectEntity.getCreatedBy());
staffList.stream().distinct().forEach(s -> {
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO();
messageFormDTO.setCustomerId(projectEntity.getCustomerId());
messageFormDTO.setApp(ProjectConstant.GOV);
messageFormDTO.setGridId("*");
messageFormDTO.setUserId(s);
messageFormDTO.setTitle(UserMessageConstant.PROJECT_TITLE);
messageFormDTO.setMessageContent(String.format(UserMessageConstant.PROJECT_CLOSED_MSG, projectEntity.getTitle(), fromDTO.getPublicReply()));
messageFormDTO.setReadFlag(Constant.UNREAD);
msgList.add(messageFormDTO);
});
messageFeignClient.saveUserMessageList(msgList);
}
@Override
@ -346,7 +383,18 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
projectStaff.setIsHandle(ProjectConstant.UNHANDLED);
projectStaffService.insert(projectStaff);
//TODO 通知
//通知
List<UserMessageFormDTO> msgList = new ArrayList<>();
UserMessageFormDTO messageFormDTO = new UserMessageFormDTO();
messageFormDTO.setCustomerId(projectEntity.getCustomerId());
messageFormDTO.setApp(ProjectConstant.GOV);
messageFormDTO.setGridId("*");
messageFormDTO.setUserId(projectStaffDTO.getStaffId());
messageFormDTO.setTitle(UserMessageConstant.PROJECT_TITLE);
messageFormDTO.setMessageContent(String.format(UserMessageConstant.PROJECT_RESOLVED_MSG, projectEntity.getTitle()));
messageFormDTO.setReadFlag(Constant.UNREAD);
msgList.add(messageFormDTO);
messageFeignClient.saveUserMessageList(msgList);
}
@Override
@ -404,7 +452,7 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
workDayFormDTO.setEndDate(format.format(new Date()));
list.add(workDayFormDTO);
Result<List<WorkDayResultDTO>> detentionDays = commonFeignClient.detentionDays(list);
return detentionDays.getData().get(0).getDetentionDays();
return detentionDays.getData().get(NumConstant.ZERO).getDetentionDays();
}
/**
@ -502,7 +550,20 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
});
projectStaffService.insertBatch(entityList);
//5:返回接口参数
//5:项目相关人员表初始数据
List<ProjectRelatedPersonnelEntity> list = new ArrayList<>();
ProjectRelatedPersonnelEntity entity1 = new ProjectRelatedPersonnelEntity();
entity1.setProjectId(projectEntity.getId());
entity1.setApp(AppClientConstant.APP_RESI);
entity1.setGridId(issueDTO.getGridId());
entity1.setUserId(formDTO.getTopicDTO().getCreatedBy());
ProjectRelatedPersonnelEntity entity2 = ConvertUtils.sourceToTarget(entity1,ProjectRelatedPersonnelEntity.class);
entity2.setUserId(issueDTO.getCreatedBy());
list.add(entity1);
list.add(entity2);
projectRelatedPersonnelService.insertBatch(list);
//6:返回接口参数
issueProjectResultDTO.setProjectId(projectEntity.getId());
issueProjectResultDTO.setOrgName(processEntity.getDepartmentName());
issueProjectResultDTO.setShiftedTime(projectEntity.getCreatedTime());

5
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectStaffServiceImpl.java

@ -146,4 +146,9 @@ public class ProjectStaffServiceImpl extends BaseServiceImpl<ProjectStaffDao, Pr
return resultDTOResult.getData();
}
@Override
public List<String> getStaffsByProjectId(String projectId) {
return baseDao.selectStaffsByProjectId(projectId);
}
}

30
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectRelatedPersonnelDao.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ProjectRelatedPersonnelDao">
<resultMap type="com.epmet.entity.ProjectRelatedPersonnelEntity" id="projectRelatedPersonnelMap">
<result property="id" column="ID"/>
<result property="projectId" column="PROJECT_ID"/>
<result property="app" column="APP"/>
<result property="gridId" column="GRID_ID"/>
<result property="userId" column="USER_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="selectPersonnelListByProjectId" resultType="com.epmet.dto.ProjectRelatedPersonnelDTO">
SELECT
*
FROM
project_related_personnel
WHERE
DEL_FLAG = '0'
AND PROJECT_ID = #{projectId}
</select>
</mapper>

3
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectStaffDao.xml

@ -40,6 +40,9 @@
AND pp.ID = #{processId}
LIMIT 1
</select>
<select id="selectStaffsByProjectId" resultType="java.lang.String">
SELECT DISTINCT STAFF_ID FROM project_staff WHERE PROJECT_ID = #{projectId}
</select>
</mapper>

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save