Browse Source

Merge remote-tracking branch 'remotes/origin/dev_bugfix_ljj' into develop

dev
jianjun 4 years ago
parent
commit
2532922f9e
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java
  2. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java
  4. 55
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java
  5. 1
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java
  6. 6
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java
  7. 13
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java
  8. 20
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java
  9. 2
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java

@ -66,6 +66,7 @@ public class LogMsgSendFilter extends LevelFilter {
} }
if (StringUtils.isNotBlank(activeEnv)) { if (StringUtils.isNotBlank(activeEnv)) {
stringBuilder.append("告警环境:").append(activeEnv);
stringBuilder.append("\n"); stringBuilder.append("\n");
} }
@ -112,7 +113,6 @@ public class LogMsgSendFilter extends LevelFilter {
if (!flag) { if (!flag) {
logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString()); logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString());
} }
stringBuilder.append("告警环境:").append(activeEnv);
} catch (Exception e) { } catch (Exception e) {
logger.warn("decide exception", e); logger.warn("decide exception", e);
} }

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

@ -733,4 +733,7 @@ public class RedisKeys {
return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId); return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId);
} }
public static String getCustomerMenuList(String customerId, Integer type) {
return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId).concat(":type:")+type;
}
} }

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.constants.MQUserPropertys;
import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg;
import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
@ -111,12 +112,19 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently
String customerId = msgObj.getCustomerId(); String customerId = msgObj.getCustomerId();
distributedLock = SpringContextUtils.getBean(DistributedLock.class); distributedLock = SpringContextUtils.getBean(DistributedLock.class);
lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId()) lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId())
,30L, 30L, TimeUnit.SECONDS); ,60L, 60L, TimeUnit.SECONDS);
if (StringUtils.isBlank(customerId)){ if (StringUtils.isBlank(customerId)){
logger.error("consumer project_changed fail,msg:{}",customerId); logger.error("consumer project_changed fail,msg:{}",customerId);
return; return;
} }
//睡一秒 要不然那边执行不完
try {
Thread.sleep(NumConstant.ONE_THOUSAND);
} catch (InterruptedException e) {
log.error("consumeMessage exception",e);
}
ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO(); ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO();
extractOriginFormDTO.setCustomerId(customerId); extractOriginFormDTO.setCustomerId(customerId);

55
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java

@ -17,31 +17,72 @@
package com.epmet.redis; package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.dto.GovMenuDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
/** /**
* 客户菜单配置表 * 客户菜单配置表
* *
* @author generator generator@elink-cn.com * @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-16 * @since v1.0.0 2021-03-16
*/ */
@Slf4j
@Component @Component
public class GovCustomerMenuRedis { public class GovCustomerMenuRedis {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
/**
public void delete(Object[] ids) { * desc:保存客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum
*/
public void setCustomerMenuList(String customerId, Integer type, List<GovMenuDTO> govMenuDTOS) {
if (checkParam(customerId, type)) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
redisUtils.set(key, govMenuDTOS, RedisUtils.DEFAULT_EXPIRE);
}
}
/**
* desc:获取客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum
*/
public List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
if (checkParam(customerId, type)) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
return (List<GovMenuDTO>) redisUtils.get(key);
}
return null;
} }
public void set(){ /**
* desc:删除客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum
*/
public void delCustomerMenu(String customerId, Integer type) {
if (checkParam(customerId, type)) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
redisUtils.delete(key);
}
} }
public String get(String id){ private boolean checkParam(String customerId, Integer type) {
return null; if (StringUtils.isBlank(customerId) || type == null){
log.warn("checkParam fail, param is null");
return false;
}
return true;
} }
} }

1
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java

@ -70,5 +70,4 @@ public class GovMenuRedis {
String key = RedisKeys.getUserPermissionsKey(userId, app, client); String key = RedisKeys.getUserPermissionsKey(userId, app, client);
return (Set<String>)redisUtils.get(key); return (Set<String>)redisUtils.get(key);
} }
} }

6
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java

@ -20,14 +20,15 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.GovCustomerMenuDao; import com.epmet.dao.GovCustomerMenuDao;
import com.epmet.dto.GovCustomerMenuDTO; import com.epmet.dto.GovCustomerMenuDTO;
import com.epmet.dto.form.MenuConfigFormDTO; import com.epmet.dto.form.MenuConfigFormDTO;
import com.epmet.entity.GovCustomerMenuEntity; import com.epmet.entity.GovCustomerMenuEntity;
import com.epmet.enums.MenuTypeEnum;
import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.service.GovCustomerMenuService; import com.epmet.service.GovCustomerMenuService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -105,6 +106,7 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void saveCustomerMenu(MenuConfigFormDTO formDTO) { public void saveCustomerMenu(MenuConfigFormDTO formDTO) {
baseDao.deleteBatchTableIds(formDTO.getTableId()); baseDao.deleteBatchTableIds(formDTO.getTableId());
if (NumConstant.ZERO < formDTO.getCustomerIds().size()) { if (NumConstant.ZERO < formDTO.getCustomerIds().size()) {
@ -117,6 +119,8 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
} }
insertBatch(entities); insertBatch(entities);
} }
//删除缓存
formDTO.getCustomerIds().forEach(customerId-> govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value()));
} }
@Override @Override

13
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java

@ -33,7 +33,7 @@ import com.epmet.dao.GovMenuDao;
import com.epmet.dto.GovMenuDTO; import com.epmet.dto.GovMenuDTO;
import com.epmet.entity.GovMenuEntity; import com.epmet.entity.GovMenuEntity;
import com.epmet.enums.MenuTypeEnum; import com.epmet.enums.MenuTypeEnum;
import com.epmet.feign.EpmetUserFeignClient; import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.redis.GovMenuRedis; import com.epmet.redis.GovMenuRedis;
import com.epmet.service.*; import com.epmet.service.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
@ -57,7 +58,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
@Autowired @Autowired
private GovMenuRedis govMenuRedis; private GovMenuRedis govMenuRedis;
@Autowired @Autowired
private EpmetUserFeignClient epmetUserFeignClient; private GovCustomerMenuRedis govCustomerMenuRedis;
@Autowired @Autowired
private GovRoleMenuService govRoleMenuService; private GovRoleMenuService govRoleMenuService;
@Autowired @Autowired
@ -208,9 +209,15 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
* @Date 15:51 2021-03-16 * @Date 15:51 2021-03-16
**/ **/
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) { private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
List<GovMenuDTO> govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type);
if (!CollectionUtils.isEmpty(govMenuDTOS)){
return govMenuDTOS;
}
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage()); List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage());
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class);
return TreeUtils.buildTree(dtoList); govMenuDTOS = TreeUtils.buildTree(dtoList);
govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS);
return govMenuDTOS;
} }
@Override @Override

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

@ -453,10 +453,12 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION, Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current); ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current);
projectEntity.setStatus(ProjectConstant.CLOSED); ProjectEntity newProject = new ProjectEntity();
projectEntity.setClosedStatus(fromDTO.getClosedStatus()); newProject.setId(fromDTO.getProjectId());
projectEntity.setWorkMinutes(workMinutes); newProject.setStatus(ProjectConstant.CLOSED);
baseDao.updateById(projectEntity); newProject.setClosedStatus(fromDTO.getClosedStatus());
newProject.setWorkMinutes(workMinutes);
baseDao.updateById(newProject);
//更新项目关联表 //更新项目关联表
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity(); ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity();
projectStaffEntity.setId(fromDTO.getProjectStaffId()); projectStaffEntity.setId(fromDTO.getProjectStaffId());
@ -655,10 +657,12 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION, Integer workMinutes = calculateDelta_T(ProjectConstant.PRECISE_CALCULATION,
ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current); ProjectConstant.CALCULATION_TYPE_DEFAULT, fromDTO.getProjectId(), projectEntity.getCreatedTime(), current);
projectEntity.setStatus(ProjectConstant.CLOSED); ProjectEntity newProject = new ProjectEntity();
projectEntity.setClosedStatus(fromDTO.getClosedStatus()); newProject.setId(fromDTO.getProjectId());
projectEntity.setWorkMinutes(workMinutes); newProject.setStatus(ProjectConstant.CLOSED);
baseDao.updateById(projectEntity); newProject.setClosedStatus(fromDTO.getClosedStatus());
newProject.setWorkMinutes(workMinutes);
baseDao.updateById(newProject);
//更新项目关联表 //更新项目关联表
ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity(); ProjectStaffEntity projectStaffEntity = new ProjectStaffEntity();
projectStaffEntity.setId(fromDTO.getProjectStaffId()); projectStaffEntity.setId(fromDTO.getProjectStaffId());

2
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java

@ -33,7 +33,7 @@ public class ScanApiAuthInterceptor implements HandlerInterceptor {
String ip = IpUtils.getIpAddr(request); String ip = IpUtils.getIpAddr(request);
SetOperations setOperations = redisTemplate.opsForSet(); SetOperations setOperations = redisTemplate.opsForSet();
if (!setOperations.isMember(RedisKeys.getWhiteList(), ip)) { if (!setOperations.isMember(RedisKeys.getWhiteList(), ip)) {
log.warn("preHandle ip:{} is not in whitelist", ip); log.error("preHandle ip:{} 不在白名单内", ip);
String result = JSON.toJSONString(new Result<>().error(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg())); String result = JSON.toJSONString(new Result<>().error(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg()));
responseJson(response, result); responseJson(response, result);
return false; return false;

Loading…
Cancel
Save