Browse Source

Merge branches 'dev' and 'dev_0707bugfix' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_0707bugfix

dev_shibei_match
yinzuomei 4 years ago
parent
commit
90ff95a3dc
  1. 14
      epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java
  2. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RequirePermissionEnum.java
  3. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  4. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml
  5. 2
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenDifficultyDataDao.xml
  6. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactGridGovernDailyServiceImpl.java
  7. 55
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java
  8. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java
  9. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java
  10. 7
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigAdd4RoletFormDTO.java
  11. 16
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/AccessConfigController.java
  12. 2
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/AccessConfigService.java
  13. 44
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java
  14. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

14
epmet-commons/epmet-commons-mybatis/src/main/java/com/epmet/commons/mybatis/handler/FieldMetaObjectHandler.java

@ -97,12 +97,20 @@ public class FieldMetaObjectHandler implements MetaObjectHandler {
}
public Object getCustomerIdByFieldValue(MetaObject metaObject) {
if (metaObject.hasSetter(FieldConstant.CUSTOMER_ID_HUMP)) {
return loginUserUtil.getLoginUserCustomerId();
}
if (!metaObject.hasSetter(FieldConstant.CUSTOMER_ID_HUMP)) {
// 如果该entity对象,没有customerId属性,那么返回null;
return null;
}
Object customerId;
customerId = getFieldValByName(FieldConstant.CUSTOMER_ID_HUMP, metaObject);
if (customerId != null && !customerId.equals("")) {
// 看entity是否手动设置了,设置了就用设置的
return customerId;
}
return loginUserUtil.getLoginUserCustomerId();
}
public Object getCreatedTimeByFieldValue(MetaObject metaObject) {
Object createdTime = null;
if (metaObject.hasGetter(FieldConstant.CREATED_TIME_HUMP)) {

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/RequirePermissionEnum.java

@ -170,7 +170,7 @@ public enum RequirePermissionEnum {
* 更多-日志记录
*/
MORE_PATROL_RECORD_LIST("more_patrol_record_list","更多:日志记录:巡查记录:列表","巡查记录列表"),
MORE_SYSTEM_LOG_LIST("MORE_SYSTEM_LOG_LIST","更多:日志记录:系统日志:列表","系统日志列表"),
MORE_SYSTEM_LOG_LIST("more_system_log_list","更多:日志记录:系统日志:列表","系统日志列表"),
MORE_GRID_MEMBER_STATS_ANALYSIS("more_grid_member_stats_analysis", "更多:网格员数据分析", "更多:网格员数据分析"),

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

@ -129,6 +129,7 @@ public enum EpmetErrorCode {
OPER_UPLOAD_IMG_TYPE_ERROR(8716, "请上传PNG格式的图片"),
OPER_UPLOAD_IMG_SIZE_ERROR(8717, "请上传200*200的图片"),
OPER_CORS_CONFIG_ERROR(8718, "跨域配置错误"),
ACCESS_CONFIG_ERROR(8719, "权限配置错误"),
// 党建声音 前端提示 88段
DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"),

10
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/StaffPatrolRecordDao.xml

@ -52,6 +52,10 @@
</select>
<select id="selectStaffPatrolList" resultType="com.epmet.dataaggre.dto.epmetuser.result.StaffListResultDTO">
SELECT
d.latest_patrol_status AS status,
t.*
FROM(
SELECT
ssp.grid_id AS gridId,
ssp.staff_id AS staffId,
@ -59,7 +63,7 @@
cs.gender AS gender,
IFNULL(MAX(ssp.latest_patrol_time), '') AS patrolStartTime,
IFNULL(SUM(ssp.patrol_total), 0) AS patrolTotal,
ssp.latest_patrol_status AS STATUS,
MAX(DATE_ID) dateId,
IFNULL(SUM(ssp.report_project_count), 0) AS reportProjectCount,
IFNULL(SUM(ssp.total_time), 0) AS timeNum
FROM
@ -95,6 +99,10 @@
</if>
LIMIT
#{pageNo}, #{pageSize}
) t
INNER JOIN stats_staff_patrol_record_daily d ON t.dateId = d.date_id
AND t.gridId = d.grid_id
AND t.staffId = d.staff_id
</select>
<select id="selectPersonalPatrolList" resultType="com.epmet.dataaggre.dto.epmetuser.result.StaffListResultDTO">

2
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenDifficultyDataDao.xml

@ -70,7 +70,7 @@
on(diff.ORG_ID=scg.GRID_ID and scg.DEL_FLAG='0')
WHERE
diff.DEL_FLAG = '0'
and diff.orgType='grid'
and diff.ORG_TYPE='grid'
and diff.EVENT_STATUS_CODE in('pending','0')
AND scg.AREA_CODE like concat(#{areaCode},'%')
ORDER BY

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactGridGovernDailyServiceImpl.java

@ -278,7 +278,7 @@ public class FactGridGovernDailyServiceImpl extends BaseServiceImpl<FactGridGove
boolean inGridClosed = checkIsInGridClosed(governProjectInfoDTO.getGridId(),
governProjectInfoDTO.getProjectLogDTOList());
if (inGridClosed) {
log.info("projectId=【"+governProjectInfoDTO.getId()+"】属于网格自治");
log.debug("projectId=【"+governProjectInfoDTO.getId()+"】属于网格自治");
// 2、在网格内流转结案的,计算以下下值
if (ProjectConstant.PROJECT_ORIGIN_ISSUE.equals(governProjectInfoDTO.getOrigin())) {
if (ProjectConstant.RESOLVED.equals(governProjectInfoDTO.getIsResolved())) {

55
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java

@ -17,6 +17,7 @@ import com.epmet.service.evaluationindex.extract.toscreen.*;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.service.evaluationindex.screen.*;
import com.epmet.service.stats.DimCustomerService;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,8 +27,7 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.*;
/**
* @Author zxc
@ -36,6 +36,11 @@ import java.util.concurrent.Executors;
@Service
@Slf4j
public class ScreenExtractServiceImpl implements ScreenExtractService {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("ScreenExtractServiceImpl-pool-%d").build();
ExecutorService threadPool = new ThreadPoolExecutor(3, 6,
10L, TimeUnit.MINUTES,
new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
@Autowired
private DimCustomerService dimCustomerService;
@ -101,13 +106,17 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
if (StringUtils.isNotBlank(extractOriginFormDTO.getStartDate()) && StringUtils.isNotBlank(extractOriginFormDTO.getEndDate())) {
List<String> daysBetween = DateUtils.getDaysBetween(extractOriginFormDTO.getStartDate(), extractOriginFormDTO.getEndDate());
daysBetween.forEach(dateId -> {
extractDaily(customerId, dateId);
boolean isLastDay = false;
if (dateId.equals(daysBetween.get(daysBetween.size() - 1))) {
isLastDay = true;
}
extractDaily(customerId, dateId, isLastDay);
});
} else if (StringUtils.isNotBlank(extractOriginFormDTO.getDateId())) {
extractDaily(customerId, extractOriginFormDTO.getDateId());
extractDaily(customerId, extractOriginFormDTO.getDateId(), true);
} else {
String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", "");
extractDaily(customerId, dateId);
extractDaily(customerId, dateId, true);
}
});
}
@ -146,11 +155,15 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
/**
* @param customerId
* @param dateId
* @param isLast 是否是最后一天
* @Description 按天计算
* @author zxc
* @date 2020/9/24 10:16 上午
*/
public void extractDaily(String customerId, String dateId) {
public void extractDaily(String customerId, String dateId, boolean isLast) {
//等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁
final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR);
threadPool.submit(() -> {
//党员基本情况screen_cpc_base_data
try {
partyBaseInfoService.statsPartyMemberBaseInfoToScreen(customerId, dateId);
@ -158,6 +171,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
log.error("党员基本情况抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
//先锋模范screen_pioneer_data
if (isLast) {
try {
pioneerDataExtractService.extractGridPioneerData(customerId, dateId);
} catch (Exception e) {
@ -173,13 +187,19 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("先锋模范【extractExceptCommunityPioneerData】抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
}
latch.countDown();
log.info("extractDaily 1 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
});
threadPool.submit(() -> {
//公众参与排行(注册人数、参与人数、话题数、议题数、项目数)screen_public_party_total_data
try {
publicPartiTotalDataExtractService.extractPublicPartiTotalData(customerId, dateId);
} catch (Exception e) {
log.error("公众参与排行抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
if (isLast) {
//基层治理- 难点赌点 screen_difficulty_data | screen_difficulty_img_data
try {
ScreenCentralZoneDataFormDTO param2 = new ScreenCentralZoneDataFormDTO();
@ -193,7 +213,11 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("基层治理-难点赌点抽取到大屏失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
}
latch.countDown();
log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
});
threadPool.submit(() -> {
ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO();
param.setCustomerId(customerId);
param.setDateId(dateId);
@ -230,7 +254,10 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
} catch (Exception e) {
log.error("按天统计:组织内各个分类下的项目总数,customerId为:" + customerId + "dateId为:" + dateId, e);
}
latch.countDown();
log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
});
threadPool.submit(() -> {
//治理能力排行screen_govern_rank_data
try {
governRankDataExtractService.extractGridDataDaily(customerId, dateId);
@ -274,7 +301,15 @@ public class ScreenExtractServiceImpl implements ScreenExtractService {
log.error("网格员数据统计fact_grid_member_statistics_daily抽取失败,customerId为:" + customerId + "dateId为:" + dateId, e);
}
extractPartData(customerId, dateId);
log.info("===== extractDaily method end ======");
latch.countDown();
log.info("extractDaily 4 thread run end ========= dateId:{},customerId:{}", dateId, customerId);
});
try {
latch.await();
} catch (InterruptedException e) {
log.error("extractDaily run exception", e);
}
log.info("===== extractDaily method end customerId:{}======",customerId);
}
@Override

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java

@ -387,8 +387,8 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
name.deleteCharAt(name.length() - NumConstant.ONE);
diffEntity.setEventCategoryCode(code.toString());
diffEntity.setEventCategoryName(name.toString());
log.info("code:{}",code.toString());
log.info("name:{}",name.toString());
log.debug("code:{}",code.toString());
log.debug("name:{}",name.toString());
});
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/ScreenCentralZoneDataExtractServiceImpl.java

@ -15,6 +15,7 @@ import com.epmet.service.org.CustomerAgencyService;
import com.epmet.service.stats.ScreenCentralZoneDataExtractService;
import com.epmet.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -184,6 +185,7 @@ public class ScreenCentralZoneDataExtractServiceImpl implements ScreenCentralZon
//For:06.01新增:orgType=agency或者grid的时候,此列赋值:当前组织或者当前网格内的网格员人数
o.setGridMemberTotal(gridManagerMap.getOrDefault(orgId, NumConstant.ZERO));
});
return result;
List<ScreenUserTotalDataEntity> newResult = result.stream().filter(o -> StringUtils.isNotBlank(o.getParentId())).collect(Collectors.toList());
return newResult;
}
}

7
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/form/AccessConfigAdd4RoletFormDTO.java

@ -18,10 +18,13 @@ public class AccessConfigAdd4RoletFormDTO {
// 为角色添加多个操作
public interface AddMultiOperations4RoleGroup {}
@NotBlank(message = "角色Key不能为空", groups = { AddSingleOperation4RoleGroup.class })
//为角色添加单个操作,从默认配置里面查询,而不从前端传
public interface AddSingleOperations4RoleByDefault {}
@NotBlank(message = "角色Key不能为空", groups = { AddSingleOperation4RoleGroup.class, AddSingleOperations4RoleByDefault.class })
private String roleKey;
@NotBlank(message = "操作Key不能为空", groups = { AddSingleOperation4RoleGroup.class })
@NotBlank(message = "操作Key不能为空", groups = { AddSingleOperation4RoleGroup.class, AddSingleOperations4RoleByDefault.class })
private String operationKey;
private List<String> scopeKeys;

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

@ -135,6 +135,22 @@ public class AccessConfigController {
return new Result();
}
/**
* @Description 根据默认配置为所有客户的某角色配置某操作及其范围
* @return
* @author wxz
* @date 2021.07.01 16:07
*/
@PostMapping("add-ope-and-scopes-4role/by-default-conf")
public Result addOpeAndScopes4RoleByDefaultConf(@RequestBody AccessConfigAdd4RoletFormDTO form) {
ValidatorUtils.validateEntity(form, AccessConfigAdd4RoletFormDTO.AddSingleOperations4RoleByDefault.class);
String roleKey = form.getRoleKey();
String operationKey = form.getOperationKey();
accessConfigService.addOpeAndScopes4RoleByDefaultConf(roleKey, operationKey);
return new Result();
}
/**
* @Description 给角色添加单个操作权限和操作范围
* @return

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

@ -29,4 +29,6 @@ public interface AccessConfigService {
void addOpeAndScopes4Role(String roleKey, String operationKey, List<String> scopeKeys);
void addOpesAndScopes4Role(String roleKey, List<AccessConfigAdd4RoletFormDTO.OperationsAndScopes> operations);
void addOpeAndScopes4RoleByDefaultConf(String roleKey, String operationKey);
}

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

@ -1,5 +1,6 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
@ -213,6 +214,7 @@ public class AccessConfigServiceImpl implements AccessConfigService {
*/
@Override
public void addOpeAndScopes4Role(String roleKey, String operationKey, List<String> scopeKeys) {
// 所有客户下该角色的列表
Result<List<GovStaffRoleResultDTO>> rolesResult = epmetUserOpenFeignClient.listRolesByRoleKey(roleKey);
if (!rolesResult.success()) {
String msg = "调用user服务,根据key查询角色列表失败";
@ -220,39 +222,41 @@ public class AccessConfigServiceImpl implements AccessConfigService {
RenException.MessageMode.CODE_INTERNAL_EXTERNAL.CODE_INTERNAL_EXTERNAL);
}
List<GovStaffRoleResultDTO> roles = rolesResult.getData();
List<String> roleIds2Add = roles.stream().map(GovStaffRoleResultDTO::getRoleId).collect(Collectors.toList());
addOpeAndScopes4Role(roleIds2Add, operationKey, scopeKeys);
List<GovStaffRoleResultDTO> rolesOfAllCustomer = rolesResult.getData();
addOpeAndScopes4Role(rolesOfAllCustomer, operationKey, scopeKeys);
}
/**
* @Description 将默认的角色操作和范围同步给具体的角色
* @param rolesOfAllCustomer 所有客户的该角色的列表
* @return
* @author wxz
* @date 2020.11.17 17:38
*/
@Transactional(rollbackFor = Exception.class)
public void addOpeAndScopes4Role(List<String> roleIds, String operationKey, List<String> scopeKeys) {
for (String roleId : roleIds) {
public void addOpeAndScopes4Role(List<GovStaffRoleResultDTO> rolesOfAllCustomer, String operationKey, List<String> scopeKeys) {
for (GovStaffRoleResultDTO role : rolesOfAllCustomer) {
// 只给没有添加该权限的用户赋予该权限,已经添加了和添加了又取消的不操作
RoleOperationEntity roleOpe = roleOperationDao.getRoleOpe(roleId, operationKey);
RoleOperationEntity roleOpe = roleOperationDao.getRoleOpe(role.getRoleId(), operationKey);
boolean needRefreshCache = false;
if (roleOpe == null) {
// 没有该操作,则添加
RoleOperationEntity roleOperation = new RoleOperationEntity();
roleOperation.setOperationKey(operationKey);
roleOperation.setRoleId(roleId);
roleOperation.setRoleId(role.getRoleId());
roleOperation.setCustomerId(role.getCustomerId());
roleOperationDao.insert(roleOperation);
needRefreshCache = true;
}
for (String scopeKey : scopeKeys) {
// 没有的话则添加
RoleScopeEntity roleScopeInDb = roleScopeDao.getByRoleIdAndOpeKey(roleId, operationKey, scopeKey);
RoleScopeEntity roleScopeInDb = roleScopeDao.getByRoleIdAndOpeKey(role.getRoleId(), operationKey, scopeKey);
if (roleScopeInDb == null) {
RoleScopeEntity roleScopeEntity = new RoleScopeEntity();
roleScopeEntity.setOperationKey(operationKey);
roleScopeEntity.setRoleId(roleId);
roleScopeEntity.setRoleId(role.getRoleId());
roleScopeEntity.setScopeKey(scopeKey);
roleScopeEntity.setCustomerId(role.getCustomerId());
roleScopeDao.insert(roleScopeEntity);
needRefreshCache = true;
}
@ -260,7 +264,7 @@ public class AccessConfigServiceImpl implements AccessConfigService {
// 清空角色的权限缓存
if (needRefreshCache) {
roleOpeScopeRedis.delRoleAllOpeScopes(roleId);
roleOpeScopeRedis.delRoleAllOpeScopes(role.getRoleId());
}
}
}
@ -273,4 +277,24 @@ public class AccessConfigServiceImpl implements AccessConfigService {
addOpeAndScopes4Role(roleKey, operationKey, scopeKeys);
}
}
@Override
public void addOpeAndScopes4RoleByDefaultConf(String roleKey, String operationKey) {
// 1.先判断该角色是否已经为该操作配做了默认配置
LambdaQueryWrapper<RoleOperationDefaultEntity> rodw = new LambdaQueryWrapper<>();
rodw.eq(RoleOperationDefaultEntity::getRoleKey, roleKey);
rodw.eq(RoleOperationDefaultEntity::getOperationKey, operationKey);
rodw.eq(RoleOperationDefaultEntity::getDelFlag, 0);
Integer roleOperationCount = roleOperationDefaultDao.selectCount(rodw);
List<OperationScopeDefaultEntity> scopes = operationScopeDefaultDao.listOpeDefaultScopesByRoleAndOpeKey(roleKey, operationKey);
if (roleOperationCount == 0 || CollectionUtils.isEmpty(scopes)) {
throw new RenException(EpmetErrorCode.ACCESS_CONFIG_ERROR.getCode(), String.format("为所有客户同步%s的%s配置权限默认失败,请先保存默认权限配置再重试", roleKey, operationKey));
}
// 2.开始执行同步
List<String> scopeKeys = scopes.stream().map(s -> s.getScopeKey()).collect(Collectors.toList());
logger.info(String.format("为所有客户同步%s的%s配置权限,范围列表:" + scopeKeys, roleKey, operationKey));
addOpeAndScopes4Role(roleKey, operationKey, scopeKeys);
logger.info("同步完成");
}
}

2
epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml

@ -104,7 +104,7 @@
)
</select>
<!--根据角色key查询具有该key的所有角色列表-->
<!--根据角色key查询具有该key的所有角色列表(所有客户下该角色列表)-->
<select id="listRolesByRoleKey" resultType="com.epmet.dto.result.GovStaffRoleResultDTO">
select gsr.ID roleId, gsr.ROLE_KEY roleKey, gsr.ROLE_NAME, gsr.CUSTOMER_ID customerId
from gov_staff_role gsr

Loading…
Cancel
Save