From f8ab3ffd814c6f12e698bcf903471f7d3b399559 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 8 Jun 2021 14:33:18 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=9B=91=E5=90=AC=E5=99=A8&=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/LogOperationListFormDTO.java | 15 ++ .../dto/region/LogOperationResultDTO.java | 49 +++++ .../com/epmet/enums/LogOperationTypeEnum.java | 39 ++++ epmet-admin/epmet-admin-server/pom.xml | 37 +++- .../main/java/com/epmet/AdminApplication.java | 4 + .../controller/LogOperationController.java | 45 +++++ .../java/com/epmet/dao/LogOperationDao.java | 33 ++++ .../com/epmet/entity/LogOperationEntity.java | 70 +++++++ .../mq/listener/RocketMQConsumerRegister.java | 66 +++++++ .../listener/OperationLogListener.java | 76 +++++++ .../epmet/service/LogOperationService.java | 28 +++ .../service/impl/LogOperationServiceImpl.java | 186 ++++++++++++++++++ .../src/main/resources/bootstrap.yml | 3 + .../migration/V0.0.3__add_log_ope_table.sql | 15 ++ .../main/resources/mapper/LogOperationDao.xml | 23 +++ .../constants/ConsomerGroupConstants.java | 5 + .../rocketmq/constants/TopicConstants.java | 5 + .../rocketmq/messages/OperationLogMQMsg.java | 16 ++ .../tools/feign/ResultDataResolver.java | 50 +++++ .../epmet/dto/form/CustomerStaffFormDTO.java | 19 +- .../epmet/feign/EpmetUserOpenFeignClient.java | 26 ++- .../EpmetUserOpenFeignClientFallback.java | 10 + .../controller/CustomerStaffController.java | 23 ++- .../java/com/epmet/dao/CustomerStaffDao.java | 8 + .../epmet/service/CustomerStaffService.java | 8 + .../impl/CustomerStaffServiceImpl.java | 6 + .../resources/mapper/CustomerStaffDao.xml | 42 ++++ 27 files changed, 898 insertions(+), 9 deletions(-) create mode 100644 epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java create mode 100644 epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java create mode 100644 epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/OperationLogListener.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java create mode 100644 epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql create mode 100644 epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml create mode 100644 epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java new file mode 100644 index 0000000000..05e4de0032 --- /dev/null +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.Data; + +@Data +public class LogOperationListFormDTO { + + private String operatorName; + + private String operatorMobile; + + private Integer pageNo = 1; + + private Integer pageSize = 10; +} diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java new file mode 100644 index 0000000000..a052b9dd2d --- /dev/null +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java @@ -0,0 +1,49 @@ +package com.epmet.dto.region; + +import lombok.Data; + +import java.util.Date; + +/** + * + */ +@Data +public class LogOperationResultDTO { + + /** + * 大类别。登录login,项目流转project + */ + private String category; + /** + * 类型枚举,小类别。登录login,logout退出,shift_project议题转项目等 + */ + private String type; + + /** + * 类型枚举名称 + */ + private String typeDisplay; + + /** + * 内容 + */ + private String content; + + /** + * 操作目标ID + */ + private String targetId; + + /** + * 操作人ID + */ + private String operatorId; + private String operatorName; + private String operatorMobile; + + /** + * 操作时间,该时间不是插入数据的时间,而是操作发生的真实时间 + */ + private Date operatingTime; + +} diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java new file mode 100644 index 0000000000..60baf21cc7 --- /dev/null +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java @@ -0,0 +1,39 @@ +package com.epmet.enums; + +/** + * 操作日志类型枚举 + */ +public enum LogOperationTypeEnum { + LOGIN("login", "登录"), + LOGOUT("logout", "退出登录"), + ISSUE_SHIFT_PROJECT("issue_shift_project", "议题转项目"), + CLOSE_PROJECT("close_project", "项目结案"), + PROJECT_TRANSFER("project_transfer", "项目流转"), + PROJECT_RESPONSE("project_response", "响应处理"), + PROJECT_APPROVAL("project_approval", "项目立项"); + + private String type; + private String typeDisplay; + + LogOperationTypeEnum(String type, String typeDisplay) { + this.type = type; + this.typeDisplay = typeDisplay; + } + + public static LogOperationTypeEnum get(String type) { + for (LogOperationTypeEnum t : LogOperationTypeEnum.values()) { + if (t.type.equals(type)) { + return t; + } + } + return null; + } + + public static String getDisplay(String type) { + LogOperationTypeEnum object = get(type); + if (object == null) { + return null; + } + return object.typeDisplay; + } +} diff --git a/epmet-admin/epmet-admin-server/pom.xml b/epmet-admin/epmet-admin-server/pom.xml index df371df8a9..15e142e3dd 100644 --- a/epmet-admin/epmet-admin-server/pom.xml +++ b/epmet-admin/epmet-admin-server/pom.xml @@ -54,6 +54,21 @@ feign-httpclient 10.3.0 + + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + + + + + com.epmet + epmet-user-client + 2.0.0 + compile + @@ -109,6 +124,10 @@ false + + + 192.168.1.130:9876;192.168.1.132:9876 + epmet_message @@ -122,14 +141,14 @@ - + epmet_admin_user EpmEt-db-UsEr 0 - 192.168.1.130 - 6379 + 118.190.150.119 + 47379 123456 false @@ -141,6 +160,10 @@ false + + + 192.168.1.130:9876;192.168.1.132:9876 + epmet_message @@ -170,6 +193,10 @@ true + + + 192.168.10.161:9876 + epmet_message @@ -199,6 +226,10 @@ true + + + 192.168.11.187:9876;192.168.11.184:9876 + epmet_message diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java index 89ac2c70d8..ea0ca31624 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/AdminApplication.java @@ -10,6 +10,8 @@ package com.epmet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; /** * 管理后台 @@ -18,6 +20,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @since 1.0.0 */ @SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients public class AdminApplication { public static void main(String[] args) { diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java new file mode 100644 index 0000000000..cc19f5dc36 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java @@ -0,0 +1,45 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.LogOperationListFormDTO; +import com.epmet.dto.region.LogOperationResultDTO; +import com.epmet.service.LogOperationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.CollectionUtils; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; + +@RequestMapping("log/operation") +@RestController +public class LogOperationController { + + @Autowired + private LogOperationService logOperationService; + + @Autowired + private LoginUserUtil loginUserUtil; + + @PostMapping("/list") + public Result> listLogOperations(@RequestBody LogOperationListFormDTO input) { + ValidatorUtils.validateEntity(input); + String operatorMobile = input.getOperatorMobile(); + String operatorName = input.getOperatorName(); + Integer pageNo = input.getPageNo(); + Integer pageSize = input.getPageSize(); + + String customerId = loginUserUtil.getLoginUserCustomerId(); + List resultList = logOperationService.listOperationLogs(operatorName, operatorMobile, customerId, pageNo, pageSize); + if (CollectionUtils.isEmpty(resultList)) { + resultList = new ArrayList<>(); + } + return new Result>().ok(resultList); + } + +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java new file mode 100644 index 0000000000..a63a5aa8e4 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/dao/LogOperationDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.LogOperationEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 操作日指标 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-06-07 + */ +@Mapper +public interface LogOperationDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java new file mode 100644 index 0000000000..54a141651a --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java @@ -0,0 +1,70 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 操作日指标 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-06-07 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("log_operation") +public class LogOperationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 大类别。登录login,项目流转project + */ + private String category; + /** + * 类型枚举,小类别。登录login,logout退出,shift_project议题转项目等 + */ + private String type; + + /** + * 内容 + */ + private String content; + + /** + * 操作目标ID + */ + private String targetId; + + /** + * 操作人ID + */ + private String operatorId; + + /** + * 操作时间,该时间不是插入数据的时间,而是操作发生的真实时间 + */ + private Date operatingTime; + +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java new file mode 100644 index 0000000000..f722f40a72 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java @@ -0,0 +1,66 @@ +package com.epmet.mq.listener; + +import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.mq.listener.listener.OperationLogListener; +import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.client.exception.MQClientException; +import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +@Component +public class RocketMQConsumerRegister { + @Value("${spring.profiles.active}") + private String env; + @Value("${rocketmq.name-server}") + private String nameServer; + + /** + * @return + * @Description 注册监听器 + * @author wxz + * @date 2021.03.03 16:09 + */ + @PostConstruct + public void registerAllListeners() { + try { + //if (!EnvEnum.LOCAL.getCode().equals(env)) { + register(nameServer, ConsomerGroupConstants.OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.OPERATION_LOG, "*", new OperationLogListener()); + //} + } catch (MQClientException e) { + e.printStackTrace(); + } + } + + public void register(String nameServer, String group, MessageModel messageModel, String topic, String subException, MessageListenerConcurrently listener) throws MQClientException { + // 实例化消费者 + DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(group); + + // 设置NameServer的地址 + consumer.setNamesrvAddr(nameServer); + consumer.setMessageModel(messageModel); + consumer.setInstanceName(buildInstanceName()); + // 订阅一个或者多个Topic,以及Tag来过滤需要消费的消息 + consumer.subscribe(topic, subException); + // 注册回调实现类来处理从broker拉取回来的消息 + consumer.registerMessageListener(listener); + // 启动消费者实例 + consumer.start(); + } + + private String buildInstanceName() { + String instanceName = ""; + for (int i = 0; i < 4; i++) { + int t = (int) (Math.random() * 10); + instanceName = instanceName.concat(t + ""); + } + + return instanceName; + } + +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/OperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/OperationLogListener.java new file mode 100644 index 0000000000..55bf16fd99 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/OperationLogListener.java @@ -0,0 +1,76 @@ +package com.epmet.mq.listener.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.messages.OperationLogMQMsg; +import com.epmet.commons.tools.distributedlock.DistributedLock; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.service.LogOperationService; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.common.message.MessageExt; +import org.redisson.api.RLock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @author wxz + * @Description 操作日志监听器 + + * @return + * @date 2021.06.07 16:12 + * + * + * { + * "type": "login", + * "content": "我登录了", + * "targetId": "11", + * "operatorId": "2", + * "operatingTime": "1623056525000" + * } + */ +public class OperationLogListener implements MessageListenerConcurrently { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public ConsumeConcurrentlyStatus consumeMessage(List msgs, ConsumeConcurrentlyContext context) { + try { + msgs.forEach(msg -> consumeMessage(msg)); + } catch (Exception e) { + logger.error(ExceptionUtils.getErrorStackTrace(e)); + return ConsumeConcurrentlyStatus.RECONSUME_LATER; + } + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + + private void consumeMessage(MessageExt messageExt) { + String tags = messageExt.getTags(); + String msg = new String(messageExt.getBody()); + logger.info("操作日志监听器-收到消息内容:{}", msg); + OperationLogMQMsg msgObj = JSON.parseObject(msg, OperationLogMQMsg.class); + + DistributedLock distributedLock = null; + RLock lock = null; + try { + distributedLock = SpringContextUtils.getBean(DistributedLock.class); + lock = distributedLock.getLock(String.format("lock:operation_log:%s:%s", msgObj.getType(), msgObj.getTargetId()), + 30L, 30L, TimeUnit.SECONDS); + SpringContextUtils.getBean(LogOperationService.class).log(msgObj, tags); + } catch (RenException e) { + // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 + logger.error("【RocketMQ】添加操作日志失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + } catch (Exception e) { + // 不是我们自己抛出的异常,可以让MQ重试 + logger.error("【RocketMQ】添加操作日志失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + throw e; + } finally { + distributedLock.unLock(lock); + } + } +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java new file mode 100644 index 0000000000..dec11275c8 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java @@ -0,0 +1,28 @@ +package com.epmet.service; + +import com.epmet.commons.rocketmq.messages.OperationLogMQMsg; +import com.epmet.dto.region.LogOperationResultDTO; + +import java.util.List; + +/** + * 操作日志 + */ +public interface LogOperationService { + + /** + * @Description 记录日志 + * @return + * @author wxz + * @date 2021.06.07 21:56 + */ + void log(OperationLogMQMsg msg, String category); + + /** + * @Description 查询操作日志 列表 + * @return + * @author wxz + * @date 2021.06.07 21:56 + */ + List listOperationLogs(String operatorName, String operatorMobile, String customerId, Integer pageNo, Integer pageSize); +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java new file mode 100644 index 0000000000..5d247e93a3 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -0,0 +1,186 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.epmet.commons.rocketmq.messages.OperationLogMQMsg; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.LogOperationDao; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; +import com.epmet.dto.form.ThirdCustomerStaffFormDTO; +import com.epmet.dto.region.LogOperationResultDTO; +import com.epmet.entity.LogOperationEntity; +import com.epmet.enums.LogOperationTypeEnum; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.service.LogOperationService; +import com.github.pagehelper.PageHelper; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +public class LogOperationServiceImpl implements LogOperationService, ResultDataResolver { + + @Autowired + private LogOperationDao logOperationDao; + + @Autowired + private EpmetUserOpenFeignClient userOpenFeignClient; + + @Override + public void log(OperationLogMQMsg msg, String category) { + LambdaQueryWrapper w = new LambdaQueryWrapper<>(); + w.eq(LogOperationEntity::getType, msg.getType()); + w.eq(LogOperationEntity::getTargetId, msg.getTargetId()); + w.eq(LogOperationEntity::getOperatorId, msg.getOperatorId()); + w.eq(LogOperationEntity::getOperatingTime, msg.getOperatingTime()); + + Integer existsCount = logOperationDao.selectCount(w); + if (existsCount > 0) { + // 该日志已存在,不做任何操作 + return; + } + + LogOperationEntity insert = new LogOperationEntity(); + insert.setContent(msg.getContent()); + insert.setOperatingTime(msg.getOperatingTime()); + insert.setOperatorId(msg.getOperatorId()); + insert.setTargetId(msg.getTargetId()); + insert.setType(msg.getType()); + insert.setCategory(category); + logOperationDao.insert(insert); + } + + @Override + public List listOperationLogs(String operatorName, String operatorMobile, String customerId, Integer pageNo, Integer pageSize) { + // 1.条件查询 + if (StringUtils.isNotBlank(operatorMobile)) { + return listByOperatorMobile(operatorMobile, customerId, pageNo, pageSize); + } else if (StringUtils.isNotBlank(operatorName)) { + return listByOperatorName(operatorName, pageNo, pageSize); + } + + // 2.直接分页查询 + // 条件查询,排序 + LambdaQueryWrapper w = new LambdaQueryWrapper<>(); + w.orderByDesc(LogOperationEntity::getOperatingTime); + IPage iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); + List logs = iPage.getRecords(); + List userIds = logs.stream().map(l -> l.getOperatorId()).collect(Collectors.toList()); + + return convertLogOperationEntity2DTO(logs, getStaffMapByUserIds(userIds)); + } + + private Map getStaffMapByUserIds(List userIds) { + CustomerStaffFormDTO form = new CustomerStaffFormDTO(); + form.setUserIds(userIds); + Result> result = userOpenFeignClient.list(form); + List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); + + HashMap staffMap = new HashMap<>(); + staffs.forEach(s -> { + staffMap.put(s.getUserId(), s); + }); + + return staffMap; + } + + /** + * 通过操作人手机号查询操作日志列表 + * + * @param operatorMobile + * @param customerId + */ + private List listByOperatorMobile(String operatorMobile, String customerId, Integer pageNo, Integer pageSize) { + CustomerStaffFormDTO form = new CustomerStaffFormDTO(); + form.setCustomerId(customerId); + form.setMobile(operatorMobile); + Result> result = userOpenFeignClient.list(form); + List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); + + if (staffs.size() == 0) { + return null; + } + CustomerStaffDTO staff = staffs.get(0); + + QueryWrapper w = new QueryWrapper<>(); + w.lambda() + .eq(LogOperationEntity::getOperatorId, staff.getUserId()) + .eq(LogOperationEntity::getDelFlag, 0) + .orderByDesc(LogOperationEntity::getOperatingTime); + + IPage iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); + + HashMap staffMap = new HashMap<>(); + staffMap.put(staff.getUserId(), staff); + + return convertLogOperationEntity2DTO(iPage.getRecords(), staffMap); + } + + /** + * @Description 通过操作人姓名查询操作日志列表 + * @return + * @author wxz + * @date 2021.06.08 11:12 + */ + private List listByOperatorName(String operatorName, Integer pageNo, Integer pageSize) { + CustomerStaffFormDTO form = new CustomerStaffFormDTO(); + form.setRealName(operatorName); + Result> result = userOpenFeignClient.list(form); + List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务查询工作人员信息发生异常"); + + List userIds = new ArrayList<>(); + HashMap staffMap = new HashMap(); + staffs.forEach(s -> { + staffMap.put(s.getUserId(), s); + userIds.add(s.getUserId()); + }); + + if (CollectionUtils.isEmpty(userIds)) { + return new ArrayList<>(); + } + LambdaQueryWrapper w = new LambdaQueryWrapper<>(); + w.in(LogOperationEntity::getOperatorId, userIds); + w.eq(LogOperationEntity::getDelFlag, 0); + w.orderByDesc(LogOperationEntity::getOperatingTime); + + IPage iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); + + return convertLogOperationEntity2DTO(iPage.getRecords(), staffMap); + } + + /** + * @Description 将操作日志entity转化为dto列表 + * @return + * @author wxz + * @date 2021.06.08 11:12 + */ + private List convertLogOperationEntity2DTO(List logOperationEntities, Map staffMap) { + return logOperationEntities.stream().map(l -> { + LogOperationResultDTO ldto = new LogOperationResultDTO(); + ldto.setCategory(l.getCategory()); + ldto.setContent(l.getContent()); + ldto.setOperatingTime(l.getOperatingTime()); + ldto.setOperatorId(l.getOperatorId()); + ldto.setTargetId(l.getTargetId()); + ldto.setType(l.getType()); + ldto.setTypeDisplay(LogOperationTypeEnum.getDisplay(l.getType())); + ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile()); + ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName()); + return ldto; + }).collect(Collectors.toList()); + } +} diff --git a/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml b/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml index 89f42ed404..0d9082cec3 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml +++ b/epmet-admin/epmet-admin-server/src/main/resources/bootstrap.yml @@ -134,3 +134,6 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +rocketmq: + name-server: @rocketmq.nameserver@ \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql new file mode 100644 index 0000000000..0613c1dd2c --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql @@ -0,0 +1,15 @@ +CREATE TABLE `log_operation` ( + `ID` varchar(64) NOT NULL COMMENT '主键ID', + `TYPE` varchar(64) NOT NULL COMMENT '类型枚举', + `CONTENT` varchar(512) NOT NULL COMMENT '内容', + `CATEGORY` varchar(64) NOT NULL COMMENT '类别', + `TARGET_ID` varchar(64) NOT NULL COMMENT '操作目标ID', + `OPERATOR_ID` varchar(64) NOT NULL COMMENT '操作人ID', + `OPERATING_TIME` datetime NOT NULL COMMENT '操作时间,该时间不是插入数据的时间,而是操作发生的真实时间', + `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='操作日指标' \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml new file mode 100644 index 0000000000..f63500d118 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java index 5acfebb90e..e6d4732409 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java @@ -31,4 +31,9 @@ public interface ConsomerGroupConstants { */ String GROUP_ACHIEVEMENT_COMPONENTS_GROUP = "group_achievement_components_group"; + /** + * 操作日志组 + */ + String OPERATION_LOG_GROUP = "operation_log_group"; + } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java index bd9fed05eb..99a9b839c9 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java @@ -13,4 +13,9 @@ public interface TopicConstants { * 小组成就 */ String GROUP_ACHIEVEMENT = "group_achievement"; + + /** + * 操作日志 + */ + String OPERATION_LOG = "operation_log"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java new file mode 100644 index 0000000000..95e3956114 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java @@ -0,0 +1,16 @@ +package com.epmet.commons.rocketmq.messages; + +import lombok.Data; + +import java.util.Date; + +@Data +public class OperationLogMQMsg { + + private String type; + private String content; + private String targetId; + private String operatorId; + private Date operatingTime; + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java new file mode 100644 index 0000000000..1e44b924c2 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java @@ -0,0 +1,50 @@ +package com.epmet.commons.tools.feign; + +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.Result; +import org.apache.commons.lang3.StringUtils; + +/** + * Feign请求结果解析器 + */ +public interface ResultDataResolver { + + /** + * @Description 获取Result种的data,如果失败(返回result为null或者result.success为false),那么返回null + * @return + * @author wxz + * @date 2021.06.07 22:45 + */ + //default R tryGetResultData(Result result, String targetServiceName) { + // Logger logger = LoggerFactory.getLogger(ResultDataResolver.class); + // if (result == null) { + // logger.error("调用{}服务发生错误,返回Result为null", targetServiceName); + // return null; + // } + // if (!result.success()) { + // logger.error("调用{}服务发生错误,错误信息:{}", targetServiceName, result.getInternalMsg()); + // return null; + // } + // return result.getData(); + //} + + /** + * @Description 获取Result种的data,如果失败(返回result为null或者result.success为false),那么抛出异常 + * @return + * @author wxz + * @date 2021.06.07 22:45 + */ + default R getResultDataOrThrowsException(Result result, String targetServiceName, Integer errorCode, String errorInternalMsg) { + if (result == null) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "调用{}服务发生错误,返回Result为null", targetServiceName); + } + if (!result.success()) { + Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode; + String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg; + throw new RenException(finalErrorCode, finalErrorInternalMsg); + } + return result.getData(); + } + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java index 43acb11d1c..f5317723e6 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CustomerStaffFormDTO.java @@ -4,6 +4,7 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.List; /** * @Description 根据手机号+客户id获取工作人员基本信息 @@ -13,9 +14,23 @@ import java.io.Serializable; @Data public class CustomerStaffFormDTO implements Serializable { private static final long serialVersionUID = 7619815083427853431L; - @NotBlank(message = "手机号不能为空") + + // 根据手机号+客户id获取工作人员基本信息 + public interface GetCustomerStaffInfo {} + + @NotBlank(message = "手机号不能为空", groups = { GetCustomerStaffInfo.class }) private String mobile; - @NotBlank(message = "客户id不能为空") + @NotBlank(message = "客户id不能为空", groups = { GetCustomerStaffInfo.class }) private String customerId; + + /** + * 姓名 + */ + private String realName; + + /** + * 用户id集合 + */ + private List userIds; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index f85ba6d782..ea092ea63a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -21,8 +21,8 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:09 */ -//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class, url = "localhost:8087") -@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class, url = "http://127.0.0.1:8087") +//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class) public interface EpmetUserOpenFeignClient { /** @@ -224,7 +224,7 @@ public interface EpmetUserOpenFeignClient { * @Author sun * @Description 根据客户ID、手机号查询政府端工作人员基本信息,校验用户是否存在 **/ - @GetMapping(value = "epmetuser/customerstaff/getCustsomerStaffByIdAndPhone") + @GetMapping(value = "/epmetuser/customerstaff/getCustsomerStaffByIdAndPhone") Result> getCustsomerStaffByIdAndPhone(@RequestBody ThirdCustomerStaffFormDTO formDTO); /** @@ -530,4 +530,24 @@ public interface EpmetUserOpenFeignClient { */ @PostMapping("/epmetuser/badge/userbadges") Result> userBadges(@RequestBody UserBadgesFormDTO formDTO); + + /** + * 根据用户ID获取工作人员基本信息 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/4/22 10:05 + **/ + @PostMapping(value = "/epmetuser/customerstaff/getstaffinfobyuserid") + Result getCustomerStaffInfoByUserId(@RequestBody CustomerStaffDTO formDTO); + + /** + * @Description 通用批量查询 + * @return + * @author wxz + * @date 2021.06.08 10:54 + */ + @PostMapping(value = "/epmetuser/customerstaff/list") + Result> list(CustomerStaffFormDTO input); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 518cca9cef..3e0ee743e1 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -373,4 +373,14 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> userBadges(UserBadgesFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "userBadges", formDTO); } + + @Override + public Result getCustomerStaffInfoByUserId(CustomerStaffDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getCustomerStaffInfoByUserId", formDTO); + } + + @Override + public Result> list(CustomerStaffFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "list", input); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index e1eefc0a94..d488ecff59 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -20,6 +20,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; @@ -32,10 +33,12 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.excel.CustomerStaffExcel; import com.epmet.service.CustomerStaffService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotBlank; import java.util.List; import java.util.Map; @@ -53,6 +56,9 @@ public class CustomerStaffController { @Autowired private CustomerStaffService customerStaffService; + @Autowired + private LoginUserUtil loginUserUtil; + @GetMapping("page") public Result> page(@RequestParam Map params) { PageData page = customerStaffService.page(params); @@ -116,7 +122,7 @@ public class CustomerStaffController { **/ @PostMapping(value = "getcustomerstaffinfo") public Result getCustomerStaffInfo(@RequestBody CustomerStaffFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); + ValidatorUtils.validateEntity(formDTO, CustomerStaffFormDTO.GetCustomerStaffInfo.class); return customerStaffService.getCustomerStaffInfo(formDTO); } @@ -410,4 +416,19 @@ public class CustomerStaffController { return new Result().ok(customerStaffService.getStaffBasicInfo(fromDTO)); } + /** + * @Description 通用列表查询。可以指定customerId,如果指定了,则使用指定的,如果未指定,则使用当前登录用户的customerId + * @return + * @author wxz + * @date 2021.06.08 10:54 + */ + @PostMapping("list") + public Result> list(@RequestBody CustomerStaffFormDTO input) { + String customerId = StringUtils.isBlank(input.getCustomerId()) ? loginUserUtil.getLoginUserCustomerId() : input.getCustomerId(); + + List staffs = customerStaffService.list(customerId, input.getRealName(), input.getMobile(), input.getUserIds()); + return new Result>().ok(staffs); + } + + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java index acffa2840e..fc8b35d778 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java @@ -197,4 +197,12 @@ public interface CustomerStaffDao extends BaseDao { * @return */ BasicInfoResultDTO getStaffBasicInfo(StaffBasicInfoFromDTO fromDTO); + + /** + * 通用列表查询 + * @param customerId + * @param realName + * @return + */ + List listDTOS(@Param("customerId") String customerId, @Param("realName") String realName, @Param("mobile") String mobile, @Param("userIds") List userIds); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java index 833791fc54..7f5b43161e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java @@ -321,4 +321,12 @@ public interface CustomerStaffService extends BaseService { * @return */ BasicInfoResultDTO getStaffBasicInfo(StaffBasicInfoFromDTO fromDTO); + + /** + * @Description 根据姓名查询工作人员 + * @return + * @author wxz + * @date 2021.06.08 10:52 + */ + List list(String customerId, String realName, String mobile, List ids); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index e52b9441ae..983ee63637 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -18,6 +18,7 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.entity.DataScope; @@ -56,6 +57,7 @@ import com.epmet.service.GovStaffRoleService; import com.epmet.service.StaffRoleService; import com.epmet.service.UserService; import com.epmet.util.ModuleConstant; +import kotlin.jvm.internal.Lambda; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; @@ -699,4 +701,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl list(String customerId, String realName, String mobile, List userIds) { + return baseDao.listDTOS(customerId, realName, mobile, userIds); + } } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index eab3a42191..725df08c21 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -357,4 +357,46 @@ AND user_id = #{staffId} LIMIT 1 + + From c7822de9c7938cdb41bb62aabb69861731b48063 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 8 Jun 2021 16:59:37 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=8F=91=E9=80=81=E4=BA=8B=E4=BB=B6=EF=BC=8C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/LogOperationListFormDTO.java | 4 +- .../com/epmet/enums/LogOperationTypeEnum.java | 10 +++++ epmet-admin/epmet-admin-server/pom.xml | 5 +++ .../controller/LogOperationController.java | 5 +-- .../mq/listener/RocketMQConsumerRegister.java | 5 +-- ...er.java => LoginOperationLogListener.java} | 31 +++++++------- .../epmet/service/LogOperationService.java | 6 +-- .../service/impl/LogOperationServiceImpl.java | 35 ++++++---------- .../controller/ThirdLoginController.java | 3 ++ .../service/impl/ThirdLoginServiceImpl.java | 40 ++++++++++++++++++- .../constants/ConsomerGroupConstants.java | 4 +- .../rocketmq/constants/TopicConstants.java | 4 +- .../commons/rocketmq/messages/LoginMQMsg.java | 20 ++++++++++ .../rocketmq/messages/OperationLogMQMsg.java | 16 -------- .../tools/security/user/LoginUserUtil.java | 1 + epmet-gateway/pom.xml | 7 ++-- .../com/epmet/constant/SystemMessageType.java | 7 +++- .../feign/EpmetMessageOpenFeignClient.java | 4 +- .../impl/SystemMessageServiceImpl.java | 4 +- .../resources/mapper/CustomerStaffDao.xml | 2 +- 20 files changed, 134 insertions(+), 79 deletions(-) rename epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/{OperationLogListener.java => LoginOperationLogListener.java} (76%) create mode 100644 epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java delete mode 100644 epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java index 05e4de0032..3fe203b482 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/form/LogOperationListFormDTO.java @@ -5,9 +5,7 @@ import lombok.Data; @Data public class LogOperationListFormDTO { - private String operatorName; - - private String operatorMobile; + private String condition; private Integer pageNo = 1; diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java index 60baf21cc7..e17078245b 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java @@ -1,5 +1,7 @@ package com.epmet.enums; +import lombok.Data; + /** * 操作日志类型枚举 */ @@ -15,6 +17,14 @@ public enum LogOperationTypeEnum { private String type; private String typeDisplay; + public String getType() { + return type; + } + + public String getTypeDisplay() { + return typeDisplay; + } + LogOperationTypeEnum(String type, String typeDisplay) { this.type = type; this.typeDisplay = typeDisplay; diff --git a/epmet-admin/epmet-admin-server/pom.xml b/epmet-admin/epmet-admin-server/pom.xml index 15e142e3dd..2e2afe5bc7 100644 --- a/epmet-admin/epmet-admin-server/pom.xml +++ b/epmet-admin/epmet-admin-server/pom.xml @@ -69,6 +69,11 @@ 2.0.0 compile + + com.epmet + epmet-message-client + 2.0.0 + diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java index cc19f5dc36..ddd86e8fac 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java @@ -29,13 +29,12 @@ public class LogOperationController { @PostMapping("/list") public Result> listLogOperations(@RequestBody LogOperationListFormDTO input) { ValidatorUtils.validateEntity(input); - String operatorMobile = input.getOperatorMobile(); - String operatorName = input.getOperatorName(); + String condition = input.getCondition(); Integer pageNo = input.getPageNo(); Integer pageSize = input.getPageSize(); String customerId = loginUserUtil.getLoginUserCustomerId(); - List resultList = logOperationService.listOperationLogs(operatorName, operatorMobile, customerId, pageNo, pageSize); + List resultList = logOperationService.listOperationLogs(condition, customerId, pageNo, pageSize); if (CollectionUtils.isEmpty(resultList)) { resultList = new ArrayList<>(); } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java index f722f40a72..b68c768f97 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java @@ -2,8 +2,7 @@ package com.epmet.mq.listener; import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; import com.epmet.commons.rocketmq.constants.TopicConstants; -import com.epmet.commons.tools.enums.EnvEnum; -import com.epmet.mq.listener.listener.OperationLogListener; +import com.epmet.mq.listener.listener.LoginOperationLogListener; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; import org.apache.rocketmq.client.exception.MQClientException; @@ -30,7 +29,7 @@ public class RocketMQConsumerRegister { public void registerAllListeners() { try { //if (!EnvEnum.LOCAL.getCode().equals(env)) { - register(nameServer, ConsomerGroupConstants.OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.OPERATION_LOG, "*", new OperationLogListener()); + register(nameServer, ConsomerGroupConstants.LOGIN_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.LOGIN, "*", new LoginOperationLogListener()); //} } catch (MQClientException e) { e.printStackTrace(); diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/OperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/LoginOperationLogListener.java similarity index 76% rename from epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/OperationLogListener.java rename to epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/LoginOperationLogListener.java index 55bf16fd99..53246a8364 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/OperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/LoginOperationLogListener.java @@ -1,11 +1,13 @@ package com.epmet.mq.listener.listener; import com.alibaba.fastjson.JSON; -import com.epmet.commons.rocketmq.messages.OperationLogMQMsg; +import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.entity.LogOperationEntity; +import com.epmet.enums.LogOperationTypeEnum; import com.epmet.service.LogOperationService; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; @@ -20,21 +22,12 @@ import java.util.concurrent.TimeUnit; /** * @author wxz - * @Description 操作日志监听器 + * @Description 登录操作日志监听器 * @return * @date 2021.06.07 16:12 - * - * - * { - * "type": "login", - * "content": "我登录了", - * "targetId": "11", - * "operatorId": "2", - * "operatingTime": "1623056525000" - * } */ -public class OperationLogListener implements MessageListenerConcurrently { +public class LoginOperationLogListener implements MessageListenerConcurrently { private Logger logger = LoggerFactory.getLogger(getClass()); @@ -53,15 +46,23 @@ public class OperationLogListener implements MessageListenerConcurrently { String tags = messageExt.getTags(); String msg = new String(messageExt.getBody()); logger.info("操作日志监听器-收到消息内容:{}", msg); - OperationLogMQMsg msgObj = JSON.parseObject(msg, OperationLogMQMsg.class); + LoginMQMsg msgObj = JSON.parseObject(msg, LoginMQMsg.class); + + LogOperationEntity logEntity = new LogOperationEntity(); + logEntity.setCategory(messageExt.getTopic()); + logEntity.setType(tags); + logEntity.setTargetId(""); + logEntity.setOperatorId(msgObj.getUserId()); + logEntity.setOperatingTime(msgObj.getLoginTime()); + logEntity.setContent("成功登录系统"); DistributedLock distributedLock = null; RLock lock = null; try { distributedLock = SpringContextUtils.getBean(DistributedLock.class); - lock = distributedLock.getLock(String.format("lock:operation_log:%s:%s", msgObj.getType(), msgObj.getTargetId()), + lock = distributedLock.getLock(String.format("lock:operation_log:%s:%s", logEntity.getType(), logEntity.getTargetId()), 30L, 30L, TimeUnit.SECONDS); - SpringContextUtils.getBean(LogOperationService.class).log(msgObj, tags); + SpringContextUtils.getBean(LogOperationService.class).log(logEntity); } catch (RenException e) { // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 logger.error("【RocketMQ】添加操作日志失败:".concat(ExceptionUtils.getErrorStackTrace(e))); diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java index dec11275c8..67b3736395 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/LogOperationService.java @@ -1,7 +1,7 @@ package com.epmet.service; -import com.epmet.commons.rocketmq.messages.OperationLogMQMsg; import com.epmet.dto.region.LogOperationResultDTO; +import com.epmet.entity.LogOperationEntity; import java.util.List; @@ -16,7 +16,7 @@ public interface LogOperationService { * @author wxz * @date 2021.06.07 21:56 */ - void log(OperationLogMQMsg msg, String category); + void log(LogOperationEntity msg); /** * @Description 查询操作日志 列表 @@ -24,5 +24,5 @@ public interface LogOperationService { * @author wxz * @date 2021.06.07 21:56 */ - List listOperationLogs(String operatorName, String operatorMobile, String customerId, Integer pageNo, Integer pageSize); + List listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize); } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java index 5d247e93a3..323ffae80e 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -4,22 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.epmet.commons.rocketmq.messages.OperationLogMQMsg; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.LogOperationDao; import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.form.CustomerStaffFormDTO; -import com.epmet.dto.form.ThirdCustomerStaffFormDTO; import com.epmet.dto.region.LogOperationResultDTO; import com.epmet.entity.LogOperationEntity; import com.epmet.enums.LogOperationTypeEnum; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.LogOperationService; -import com.github.pagehelper.PageHelper; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -41,7 +37,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR private EpmetUserOpenFeignClient userOpenFeignClient; @Override - public void log(OperationLogMQMsg msg, String category) { + public void log(LogOperationEntity msg) { LambdaQueryWrapper w = new LambdaQueryWrapper<>(); w.eq(LogOperationEntity::getType, msg.getType()); w.eq(LogOperationEntity::getTargetId, msg.getTargetId()); @@ -53,24 +49,19 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR // 该日志已存在,不做任何操作 return; } - - LogOperationEntity insert = new LogOperationEntity(); - insert.setContent(msg.getContent()); - insert.setOperatingTime(msg.getOperatingTime()); - insert.setOperatorId(msg.getOperatorId()); - insert.setTargetId(msg.getTargetId()); - insert.setType(msg.getType()); - insert.setCategory(category); - logOperationDao.insert(insert); + logOperationDao.insert(msg); } @Override - public List listOperationLogs(String operatorName, String operatorMobile, String customerId, Integer pageNo, Integer pageSize) { + public List listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize) { // 1.条件查询 - if (StringUtils.isNotBlank(operatorMobile)) { - return listByOperatorMobile(operatorMobile, customerId, pageNo, pageSize); - } else if (StringUtils.isNotBlank(operatorName)) { - return listByOperatorName(operatorName, pageNo, pageSize); + List logDtos = listByOperatorMobile(condition, customerId, pageNo, pageSize); + if (CollectionUtils.isEmpty(logDtos)) { + logDtos = listByOperatorName(condition, pageNo, pageSize); + } + + if (CollectionUtils.isEmpty(logDtos)) { + return new ArrayList<>(); } // 2.直接分页查询 @@ -78,10 +69,10 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR LambdaQueryWrapper w = new LambdaQueryWrapper<>(); w.orderByDesc(LogOperationEntity::getOperatingTime); IPage iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); - List logs = iPage.getRecords(); - List userIds = logs.stream().map(l -> l.getOperatorId()).collect(Collectors.toList()); + List logEntities = iPage.getRecords(); + List userIds = logEntities.stream().map(l -> l.getOperatorId()).collect(Collectors.toList()); - return convertLogOperationEntity2DTO(logs, getStaffMapByUserIds(userIds)); + return convertLogOperationEntity2DTO(logEntities, getStaffMapByUserIds(userIds)); } private Map getStaffMapByUserIds(List userIds) { diff --git a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java index 144e18d024..65e718aacf 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/ThirdLoginController.java @@ -1,7 +1,10 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.UserDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index 8dd958fe36..92295f9c7e 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -6,17 +6,21 @@ import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.tools.constant.ServiceConstant; 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.feign.ResultDataResolver; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.constant.AuthHttpUrlConstant; import com.epmet.constant.SmsTemplateConstant; +import com.epmet.constant.SystemMessageType; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -29,6 +33,7 @@ import com.epmet.redis.CaptchaRedis; import com.epmet.service.ThirdLoginService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -44,7 +49,7 @@ import java.util.stream.Collectors; */ @Slf4j @Service -public class ThirdLoginServiceImpl implements ThirdLoginService { +public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResolver { private static final Logger logger = LoggerFactory.getLogger(ThirdLoginServiceImpl.class); @Autowired @@ -61,6 +66,10 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { private GovOrgOpenFeignClient govOrgOpenFeignClient; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private EpmetMessageOpenFeignClient messageOpenFeignClient; + @Autowired + private LoginUserUtil loginUserUtil; /** * @param formDTO @@ -170,8 +179,11 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { this.saveLatestGovTokenDto(staffLatestAgencyResultDTO, userWechatDTO, token); UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); userTokenResultDTO.setToken(token); - return userTokenResultDTO; + //7.发送登录事件 + sendLoginEvent(staffLatestAgencyResultDTO.getStaffId(), formDTO.getAppId()); + + return userTokenResultDTO; } /** @@ -635,4 +647,28 @@ public class ThirdLoginServiceImpl implements ThirdLoginService { logger.info(String.format("发送短信验证码成功,手机号[%s]", formDTO.getMobile())); } + + /** + * @Description 发送登录事件 + * @return + * @author wxz + * @date 2021.06.08 15:27 + */ + private void sendLoginEvent(String userId, String appId) { + LoginMQMsg loginMQMsg = new LoginMQMsg(); + loginMQMsg.setUserId(userId); + loginMQMsg.setLoginTime(new Date()); + loginMQMsg.setAppId(appId); + + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(SystemMessageType.LOGIN); + form.setContent(loginMQMsg); + Result result = messageOpenFeignClient.sendSystemMsgByMQ(form); + try { + getResultDataOrThrowsException(result, ServiceConstant.EPMET_MESSAGE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用Message服务,发送登录事件到MQ失败"); + } catch (RenException e) { + log.error(e.getInternalMsg()); + } + } + } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java index e6d4732409..89e7f5a884 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java @@ -32,8 +32,8 @@ public interface ConsomerGroupConstants { String GROUP_ACHIEVEMENT_COMPONENTS_GROUP = "group_achievement_components_group"; /** - * 操作日志组 + * 登录操作日志消费组 */ - String OPERATION_LOG_GROUP = "operation_log_group"; + String LOGIN_OPERATION_LOG_GROUP = "login_operation_log_group"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java index 99a9b839c9..c50ff93dc3 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java @@ -15,7 +15,7 @@ public interface TopicConstants { String GROUP_ACHIEVEMENT = "group_achievement"; /** - * 操作日志 + * 登录 */ - String OPERATION_LOG = "operation_log"; + String LOGIN = "login"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java new file mode 100644 index 0000000000..643cd99f03 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java @@ -0,0 +1,20 @@ +package com.epmet.commons.rocketmq.messages; + +import lombok.Data; + +import java.util.Date; + +@Data +public class LoginMQMsg { + + /** + * 谁登录 + */ + private String userId; + private String appId; + /** + * 什么时间登录的 + */ + private Date loginTime; + +} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java deleted file mode 100644 index 95e3956114..0000000000 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/OperationLogMQMsg.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.epmet.commons.rocketmq.messages; - -import lombok.Data; - -import java.util.Date; - -@Data -public class OperationLogMQMsg { - - private String type; - private String content; - private String targetId; - private String operatorId; - private Date operatingTime; - -} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java index 410549aecb..bb5e6f7b5d 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/user/LoginUserUtil.java @@ -6,6 +6,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; import java.util.List; /** diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index af02a2054c..2a41a386b0 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -255,10 +255,11 @@ - - lb://epmet-auth-server + http://localhost:8081 + - lb://epmet-admin-server + http://localhost:8082 + lb://epmet-oss-server diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java index 282dc7b711..b29f2efaba 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java @@ -1,7 +1,7 @@ package com.epmet.constant; /** - * 系统消息类型 + * 系统消息类型(可以理解为动作,约等于rocket mq中的tag) */ public interface SystemMessageType { @@ -20,4 +20,9 @@ public interface SystemMessageType { */ String GROUP_ACHIEVEMENT = "group_achievement"; + /** + * 登录 + */ + String LOGIN = "login"; + } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java index ff085c7bc0..2a6f2428d2 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java @@ -26,8 +26,8 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:47 */ -//@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class,url = "http://127.0.0.1:8085") -@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class) +@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class,url = "http://127.0.0.1:8085") +//@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class) public interface EpmetMessageOpenFeignClient { /** * 发送短信 diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java index db9be4c1ba..82466bf528 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java @@ -43,7 +43,7 @@ public class SystemMessageServiceImpl implements SystemMessageService { //发送mq消息 try { - Message meMessage = new Message(getTopicByMsgType(messageType), contentStr.getBytes(RemotingHelper.DEFAULT_CHARSET)); + Message meMessage = new Message(getTopicByMsgType(messageType), messageType, contentStr.getBytes(RemotingHelper.DEFAULT_CHARSET)); rocketMQTemplate.getProducer().send(meMessage); } catch (Exception e) { String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); @@ -70,6 +70,8 @@ public class SystemMessageServiceImpl implements SystemMessageService { case SystemMessageType.GROUP_ACHIEVEMENT: topic = TopicConstants.GROUP_ACHIEVEMENT; break; + case SystemMessageType.LOGIN: + topic = TopicConstants.LOGIN; } return topic; } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index 725df08c21..ccb3dc0e41 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -389,7 +389,7 @@ and MOBILE = #{mobile} - + and userId in #{userId} From bd83b4ab6bbcf5da3f81370c8043930f1cf5be0c Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 8 Jun 2021 21:08:31 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ThirdLoginServiceImpl.java | 25 +++++++++++++------ .../epmet/service/impl/IssueServiceImpl.java | 3 +++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index 92295f9c7e..db26d3d75c 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -181,7 +181,13 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol userTokenResultDTO.setToken(token); //7.发送登录事件 - sendLoginEvent(staffLatestAgencyResultDTO.getStaffId(), formDTO.getAppId()); + try { + sendLoginEvent(staffLatestAgencyResultDTO.getStaffId(), formDTO.getAppId()); + } catch (RenException e) { + log.error(e.getInternalMsg()); + } catch (Exception e) { + log.error("【工作端workLogin登录】发送登录事件失败,程序继续执行。错误信息"); + } return userTokenResultDTO; } @@ -404,6 +410,15 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); userTokenResultDTO.setToken(token); + + //6.发送登录事件 + try { + sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId()); + } catch (RenException e) { + log.error(e.getInternalMsg()); + } catch (Exception e) { + log.error("【工作端enterOrg登录】发送登录事件失败,程序继续执行。错误信息"); + } return userTokenResultDTO; } @@ -663,12 +678,8 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(SystemMessageType.LOGIN); form.setContent(loginMQMsg); - Result result = messageOpenFeignClient.sendSystemMsgByMQ(form); - try { - getResultDataOrThrowsException(result, ServiceConstant.EPMET_MESSAGE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用Message服务,发送登录事件到MQ失败"); - } catch (RenException e) { - log.error(e.getInternalMsg()); - } + messageOpenFeignClient.sendSystemMsgByMQ(form); + //getResultDataOrThrowsException(result, ServiceConstant.EPMET_MESSAGE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用Message服务,发送登录事件到MQ失败"); } } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index 2c0cf4bb23..587b92c4a2 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -1041,6 +1041,9 @@ public class IssueServiceImpl extends BaseServiceImpl imp if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){ logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO)); } + + //8.记录日志 + //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient); } /** From 2176562b56443400aa15cca7d1b19a4111cdb536 Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 9 Jun 2021 13:48:48 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8F=98=E5=8A=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/enums/LogOperationTypeEnum.java | 93 ++++++++-------- epmet-admin/epmet-admin-server/pom.xml | 5 + .../com/epmet/entity/LogOperationEntity.java | 2 + .../mq/listener/RocketMQConsumerRegister.java | 11 +- ...ner.java => AuthOperationLogListener.java} | 9 +- .../listener/ProjectOperationLogListener.java | 100 ++++++++++++++++++ .../service/impl/LogOperationServiceImpl.java | 5 +- .../main/resources/mapper/LogOperationDao.xml | 1 + epmet-auth/epmet-auth-client/pom.xml | 14 +++ .../constants/AuthOperationConstants.java | 9 ++ .../auth/constants/AuthOperationEnum.java | 43 ++++++++ epmet-auth/pom.xml | 8 ++ .../service/impl/ThirdLoginServiceImpl.java | 3 +- .../constants/ConsomerGroupConstants.java | 9 +- .../rocketmq/constants/TopicConstants.java | 7 +- .../messages/ProjectChangedMQMsg.java | 11 ++ .../com/epmet/constant/SystemMessageType.java | 5 - .../java/com/epmet/send/SendMqMsgUtil.java | 2 +- .../epmet-message-server/pom.xml | 6 ++ .../impl/SystemMessageServiceImpl.java | 10 +- .../epmet/service/impl/IssueServiceImpl.java | 4 +- .../impl/ProjectProcessServiceImpl.java | 33 +++++- .../service/impl/ProjectServiceImpl.java | 68 ++++++++++-- .../service/impl/ProjectTraceServiceImpl.java | 7 +- 24 files changed, 379 insertions(+), 86 deletions(-) rename epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/{LoginOperationLogListener.java => AuthOperationLogListener.java} (87%) create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java create mode 100644 epmet-auth/epmet-auth-client/pom.xml create mode 100644 epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java create mode 100644 epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java index e17078245b..892d41ed34 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/enums/LogOperationTypeEnum.java @@ -1,49 +1,44 @@ -package com.epmet.enums; - -import lombok.Data; - -/** - * 操作日志类型枚举 - */ -public enum LogOperationTypeEnum { - LOGIN("login", "登录"), - LOGOUT("logout", "退出登录"), - ISSUE_SHIFT_PROJECT("issue_shift_project", "议题转项目"), - CLOSE_PROJECT("close_project", "项目结案"), - PROJECT_TRANSFER("project_transfer", "项目流转"), - PROJECT_RESPONSE("project_response", "响应处理"), - PROJECT_APPROVAL("project_approval", "项目立项"); - - private String type; - private String typeDisplay; - - public String getType() { - return type; - } - - public String getTypeDisplay() { - return typeDisplay; - } - - LogOperationTypeEnum(String type, String typeDisplay) { - this.type = type; - this.typeDisplay = typeDisplay; - } - - public static LogOperationTypeEnum get(String type) { - for (LogOperationTypeEnum t : LogOperationTypeEnum.values()) { - if (t.type.equals(type)) { - return t; - } - } - return null; - } - - public static String getDisplay(String type) { - LogOperationTypeEnum object = get(type); - if (object == null) { - return null; - } - return object.typeDisplay; - } -} +//package com.epmet.enums; +// +//import lombok.Data; +// +///** +// * 操作日志类型枚举 +// */ +//public enum LogOperationTypeEnum { +// LOGIN("login", "登录"), +// LOGOUT("logout", "退出登录"); +// +// private String type; +// private String typeDisplay; +// +// public String getType() { +// return type; +// } +// +// public String getTypeDisplay() { +// return typeDisplay; +// } +// +// LogOperationTypeEnum(String type, String typeDisplay) { +// this.type = type; +// this.typeDisplay = typeDisplay; +// } +// +// public static LogOperationTypeEnum get(String type) { +// for (LogOperationTypeEnum t : LogOperationTypeEnum.values()) { +// if (t.type.equals(type)) { +// return t; +// } +// } +// return null; +// } +// +// public static String getDisplay(String type) { +// LogOperationTypeEnum object = get(type); +// if (object == null) { +// return null; +// } +// return object.typeDisplay; +// } +//} diff --git a/epmet-admin/epmet-admin-server/pom.xml b/epmet-admin/epmet-admin-server/pom.xml index 2e2afe5bc7..5093acffb8 100644 --- a/epmet-admin/epmet-admin-server/pom.xml +++ b/epmet-admin/epmet-admin-server/pom.xml @@ -74,6 +74,11 @@ epmet-message-client 2.0.0 + + com.epmet + epmet-auth-client + 2.0.0 + diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java index 54a141651a..b6b0d4364e 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java @@ -47,6 +47,8 @@ public class LogOperationEntity extends BaseEpmetEntity { */ private String type; + private String typeDisplay; + /** * 内容 */ diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java index b68c768f97..ef71399b7d 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/RocketMQConsumerRegister.java @@ -2,7 +2,9 @@ package com.epmet.mq.listener; import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; import com.epmet.commons.rocketmq.constants.TopicConstants; -import com.epmet.mq.listener.listener.LoginOperationLogListener; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.mq.listener.listener.AuthOperationLogListener; +import com.epmet.mq.listener.listener.ProjectOperationLogListener; import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer; import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; import org.apache.rocketmq.client.exception.MQClientException; @@ -28,9 +30,10 @@ public class RocketMQConsumerRegister { @PostConstruct public void registerAllListeners() { try { - //if (!EnvEnum.LOCAL.getCode().equals(env)) { - register(nameServer, ConsomerGroupConstants.LOGIN_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.LOGIN, "*", new LoginOperationLogListener()); - //} + if (!EnvEnum.LOCAL.getCode().equals(env)) { + register(nameServer, ConsomerGroupConstants.AUTH_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.AUTH, "*", new AuthOperationLogListener()); + register(nameServer, ConsomerGroupConstants.PROJECT_OPERATION_LOG_GROUP, MessageModel.CLUSTERING, TopicConstants.PROJECT_CHANGED, "*", new ProjectOperationLogListener()); + } } catch (MQClientException e) { e.printStackTrace(); } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/LoginOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java similarity index 87% rename from epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/LoginOperationLogListener.java rename to epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java index 53246a8364..fe6cf5a03d 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/LoginOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java @@ -1,13 +1,13 @@ package com.epmet.mq.listener.listener; import com.alibaba.fastjson.JSON; +import com.epmet.auth.constants.AuthOperationEnum; import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.entity.LogOperationEntity; -import com.epmet.enums.LogOperationTypeEnum; import com.epmet.service.LogOperationService; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; @@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit; * @return * @date 2021.06.07 16:12 */ -public class LoginOperationLogListener implements MessageListenerConcurrently { +public class AuthOperationLogListener implements MessageListenerConcurrently { private Logger logger = LoggerFactory.getLogger(getClass()); @@ -45,12 +45,13 @@ public class LoginOperationLogListener implements MessageListenerConcurrently { private void consumeMessage(MessageExt messageExt) { String tags = messageExt.getTags(); String msg = new String(messageExt.getBody()); - logger.info("操作日志监听器-收到消息内容:{}", msg); + logger.info("认证操作日志监听器-收到消息内容:{}", msg); LoginMQMsg msgObj = JSON.parseObject(msg, LoginMQMsg.class); LogOperationEntity logEntity = new LogOperationEntity(); logEntity.setCategory(messageExt.getTopic()); logEntity.setType(tags); + logEntity.setTypeDisplay(AuthOperationEnum.getDisplay(tags)); logEntity.setTargetId(""); logEntity.setOperatorId(msgObj.getUserId()); logEntity.setOperatingTime(msgObj.getLoginTime()); @@ -60,7 +61,7 @@ public class LoginOperationLogListener implements MessageListenerConcurrently { RLock lock = null; try { distributedLock = SpringContextUtils.getBean(DistributedLock.class); - lock = distributedLock.getLock(String.format("lock:operation_log:%s:%s", logEntity.getType(), logEntity.getTargetId()), + lock = distributedLock.getLock(String.format("lock:auth_operation_log:%s:%s", logEntity.getType(), logEntity.getOperatorId()), 30L, 30L, TimeUnit.SECONDS); SpringContextUtils.getBean(LogOperationService.class).log(logEntity); } catch (RenException e) { diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java new file mode 100644 index 0000000000..181e7cd3fc --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java @@ -0,0 +1,100 @@ +package com.epmet.mq.listener.listener; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.messages.LoginMQMsg; +import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; +import com.epmet.commons.tools.distributedlock.DistributedLock; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.entity.LogOperationEntity; +import com.epmet.service.LogOperationService; +import org.apache.commons.lang3.StringUtils; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; +import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; +import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently; +import org.apache.rocketmq.common.message.MessageExt; +import org.redisson.api.RLock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @author wxz + * @Description 项目操作日志监听器 + + * @return + * @date 2021.06.08 22.21 + */ +public class ProjectOperationLogListener implements MessageListenerConcurrently { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Override + public ConsumeConcurrentlyStatus consumeMessage(List msgs, ConsumeConcurrentlyContext context) { + try { + msgs.forEach(msg -> consumeMessage(msg)); + } catch (Exception e) { + logger.error(ExceptionUtils.getErrorStackTrace(e)); + return ConsumeConcurrentlyStatus.RECONSUME_LATER; + } + return ConsumeConcurrentlyStatus.CONSUME_SUCCESS; + } + + private void consumeMessage(MessageExt messageExt) { + //String tags = messageExt.getTags(); + String msg = new String(messageExt.getBody()); + logger.info("项目变动操作日志监听器-收到消息内容:{}", msg); + ProjectChangedMQMsg msgObj = JSON.parseObject(msg, ProjectChangedMQMsg.class); + + String content = StringUtils.isBlank(msgObj.getOperationBrief()) ? "" : msgObj.getOperationBrief(); + + LogOperationEntity logEntity = new LogOperationEntity(); + logEntity.setCategory(messageExt.getTopic()); + logEntity.setType(msgObj.getOperation()); + logEntity.setTypeDisplay(getOperationTypeDisplay(msgObj.getOperation())); + logEntity.setTargetId(msgObj.getProjectId()); + logEntity.setOperatorId(msgObj.getOperatorId()); + logEntity.setOperatingTime(msgObj.getOperatingTime()); + logEntity.setContent(content); + + DistributedLock distributedLock = null; + RLock lock = null; + try { + distributedLock = SpringContextUtils.getBean(DistributedLock.class); + lock = distributedLock.getLock(String.format("lock:project_operation_log:%s:%s", logEntity.getType(), logEntity.getTargetId()), + 30L, 30L, TimeUnit.SECONDS); + SpringContextUtils.getBean(LogOperationService.class).log(logEntity); + } catch (RenException e) { + // 如果是我们手动抛出的异常,说明在业务可控范围内。目前不需要MQ重试 + logger.error("【RocketMQ】添加操作日志失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + } catch (Exception e) { + // 不是我们自己抛出的异常,可以让MQ重试 + logger.error("【RocketMQ】添加操作日志失败:".concat(ExceptionUtils.getErrorStackTrace(e))); + throw e; + } finally { + distributedLock.unLock(lock); + } + } + + private String getOperationTypeDisplay(String type) { + switch (type) { + case "response": + return "项目响应处理"; + case "issue_shift_project": + return "议题转项目"; + case "close": + return "项目结案"; + case "return": + return "项目退回"; + case "transfer": + return "项目吹哨"; + case "created": + return "项目立项"; + default: + return null; + } + } +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java index 323ffae80e..15c1d4e44b 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.epmet.auth.constants.AuthOperationEnum; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.feign.ResultDataResolver; @@ -13,10 +14,8 @@ import com.epmet.dto.CustomerStaffDTO; import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.dto.region.LogOperationResultDTO; import com.epmet.entity.LogOperationEntity; -import com.epmet.enums.LogOperationTypeEnum; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.LogOperationService; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -168,7 +167,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR ldto.setOperatorId(l.getOperatorId()); ldto.setTargetId(l.getTargetId()); ldto.setType(l.getType()); - ldto.setTypeDisplay(LogOperationTypeEnum.getDisplay(l.getType())); + ldto.setTypeDisplay(l.getTypeDisplay()); ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile()); ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName()); return ldto; diff --git a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml index f63500d118..1496892029 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml +++ b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml @@ -6,6 +6,7 @@ + diff --git a/epmet-auth/epmet-auth-client/pom.xml b/epmet-auth/epmet-auth-client/pom.xml new file mode 100644 index 0000000000..685407f474 --- /dev/null +++ b/epmet-auth/epmet-auth-client/pom.xml @@ -0,0 +1,14 @@ + + + + epmet-auth + com.epmet + 2.0.0 + + 4.0.0 + + epmet-auth-client + + \ No newline at end of file diff --git a/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java b/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java new file mode 100644 index 0000000000..2cffd341ee --- /dev/null +++ b/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java @@ -0,0 +1,9 @@ +package com.epmet.auth.constants; + +/** + * 认证操作常量 + */ +public interface AuthOperationConstants { + String LOGIN = "login"; + String LOGOUT = "logout"; +} diff --git a/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java b/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java new file mode 100644 index 0000000000..fb112e7c36 --- /dev/null +++ b/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java @@ -0,0 +1,43 @@ +package com.epmet.auth.constants; + +/** + * 认证操作枚举 + */ +public enum AuthOperationEnum { + + LOGIN(AuthOperationConstants.LOGIN, "登录"), + LOGOUT(AuthOperationConstants.LOGOUT, "退出"); + + private String operationType; + private String operationDisplay; + + AuthOperationEnum(String operationType, String operationDisplay) { + this.operationType = operationType; + this.operationDisplay = operationDisplay; + } + + public String getOperationType() { + return operationType; + } + + public String getOperationDisplay() { + return operationDisplay; + } + + public static AuthOperationEnum get(String operationType) { + for (AuthOperationEnum e : AuthOperationEnum.values()) { + if (e.getOperationType().equals(operationType)) { + return e; + } + } + return null; + } + + public static String getDisplay(String operationType) { + AuthOperationEnum obj = get(operationType); + if (obj == null) { + return null; + } + return obj.getOperationDisplay(); + } +} diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 87fe58c7a8..6970ec1dd8 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -3,6 +3,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 0.3.70 + + epmet-auth-client + com.epmet epmet-cloud @@ -133,6 +136,11 @@ 2.0.0 compile + + com.epmet + epmet-auth-client + 2.0.0 + diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index db26d3d75c..3926452c8d 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.epmet.auth.constants.AuthOperationConstants; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.rocketmq.messages.LoginMQMsg; import com.epmet.commons.tools.constant.ServiceConstant; @@ -676,7 +677,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol loginMQMsg.setAppId(appId); SystemMsgFormDTO form = new SystemMsgFormDTO(); - form.setMessageType(SystemMessageType.LOGIN); + form.setMessageType(AuthOperationConstants.LOGIN); form.setContent(loginMQMsg); messageOpenFeignClient.sendSystemMsgByMQ(form); //getResultDataOrThrowsException(result, ServiceConstant.EPMET_MESSAGE_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用Message服务,发送登录事件到MQ失败"); diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java index 89e7f5a884..ef5970dbb3 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java @@ -32,8 +32,13 @@ public interface ConsomerGroupConstants { String GROUP_ACHIEVEMENT_COMPONENTS_GROUP = "group_achievement_components_group"; /** - * 登录操作日志消费组 + * 认证操作日志消费组 */ - String LOGIN_OPERATION_LOG_GROUP = "login_operation_log_group"; + String AUTH_OPERATION_LOG_GROUP = "auth_operation_log_group"; + + /** + * 项目操作日志小肥猪 + */ + String PROJECT_OPERATION_LOG_GROUP = "project_operation_log_group"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java index c50ff93dc3..70d4e006f8 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java @@ -1,5 +1,8 @@ package com.epmet.commons.rocketmq.constants; +/** + * 话题列表常量,其他服务要想发送消息到mq,则应当引入epmet-commons-rocketmq模块,并且使用此常量 + */ public interface TopicConstants { /** * 初始化客户 @@ -15,7 +18,7 @@ public interface TopicConstants { String GROUP_ACHIEVEMENT = "group_achievement"; /** - * 登录 + * 认证 */ - String LOGIN = "login"; + String AUTH = "auth"; } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java index d93871bd55..9530f7a326 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java @@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import java.io.Serializable; +import java.util.Date; /** * desc:项目变动通知消息实体类 @@ -18,4 +19,14 @@ public class ProjectChangedMQMsg implements Serializable { * 操作类型 议题转项目issue_shift_project, 处理:response, 结案close,退回return,部门流转transfer,立项created */ private String operation; + +// ============> new + private String projectId; + private String operatorId; + private Date operatingTime; + /** + * 操作简介 + */ + private String operationBrief; + } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java index b29f2efaba..bc71d2817a 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java @@ -20,9 +20,4 @@ public interface SystemMessageType { */ String GROUP_ACHIEVEMENT = "group_achievement"; - /** - * 登录 - */ - String LOGIN = "login"; - } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java index 4e8e7c954a..a6204e07ac 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java @@ -37,7 +37,7 @@ public class SendMqMsgUtil { } /** - * desc: 发送小组成就消息,计算小组成就 + * desc: 发送项目变动事件消息 * * @param msgContent * @return boolean diff --git a/epmet-module/epmet-message/epmet-message-server/pom.xml b/epmet-module/epmet-message/epmet-message-server/pom.xml index 6af8aed5e8..f8de809d99 100644 --- a/epmet-module/epmet-message/epmet-message-server/pom.xml +++ b/epmet-module/epmet-message/epmet-message-server/pom.xml @@ -125,6 +125,12 @@ epmet-commons-rocketmq 2.0.0 + + + com.epmet + epmet-auth-client + 2.0.0 + diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java index 82466bf528..6813dcd362 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java @@ -1,6 +1,8 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; +import com.epmet.auth.constants.AuthOperationConstants; +import com.epmet.auth.constants.AuthOperationEnum; import com.epmet.commons.rocketmq.constants.TopicConstants; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -70,8 +72,12 @@ public class SystemMessageServiceImpl implements SystemMessageService { case SystemMessageType.GROUP_ACHIEVEMENT: topic = TopicConstants.GROUP_ACHIEVEMENT; break; - case SystemMessageType.LOGIN: - topic = TopicConstants.LOGIN; + case AuthOperationConstants.LOGIN: + topic = TopicConstants.AUTH; + break; + case AuthOperationConstants.LOGOUT: + topic = TopicConstants.AUTH; + break; } return topic; } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index 587b92c4a2..b1f1701e75 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -125,6 +125,8 @@ public class IssueServiceImpl extends BaseServiceImpl imp private IssueProjectTagDictService issueProjectTagDictService; @Autowired private IssueVoteDetailDao issueVoteDetailDao; + @Autowired + private EpmetMessageOpenFeignClient messageOpenFeignClient; @Value("${openapi.scan.server.url}") @@ -1043,7 +1045,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp } //8.记录日志 - //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient); + //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg(); } /** diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java index ff85abe02b..79e1903e7d 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java @@ -386,8 +386,15 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl processStaff = epmetUserFeignClient.getCustomerStaffInfoByUserId(form); + + ProjectEntity projectEntity = projectService.selectById(projectId); + return String.format("将项目\"%s\"吹哨给%s%s处理", projectEntity.getTitle(), departmentName, processStaff.getData().getRealName()); + } + /** * @Description 项目流转给流转工作人员推送消息 * @author sun @@ -741,7 +763,12 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl getProjectByIssue(ShiftProjectsFromDTO fromDTO) { List resultList = new ArrayList<>(); @@ -1165,8 +1205,15 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectTraceS } //项目实时统计消息 - ProjectChangedMQMsg mqMsg = new ProjectChangedMQMsg(projectEntity.getCustomerId(), ProjectConstant.OPERATION_CREATED); + String mqMsgBrief = String.format("创建了\"%s\"的项目", formDTO.getTitle()); + ProjectChangedMQMsg mqMsg = new ProjectChangedMQMsg(projectEntity.getCustomerId(), ProjectConstant.OPERATION_CREATED, + projectEntity.getId(), + formDTO.getUserId(), + new Date(), + mqMsgBrief); boolean msgResult = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendProjectChangedMqMsg(mqMsg); if (!msgResult) { log.error("项目实时统计消息发送失败"); From 3cb8dbc460b842625a5e0be0bd67990f94ed7ffd Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 9 Jun 2021 14:03:56 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8F=98=E5=8A=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=EF=BC=8C=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/region/LogOperationResultDTO.java | 5 ++++- .../java/com/epmet/service/impl/LogOperationServiceImpl.java | 2 +- .../java/com/epmet/feign/EpmetMessageOpenFeignClient.java | 4 ++-- .../main/java/com/epmet/feign/EpmetUserOpenFeignClient.java | 4 ++-- .../src/main/resources/mapper/CustomerStaffDao.xml | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java index a052b9dd2d..6033b176e6 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java @@ -1,5 +1,8 @@ package com.epmet.dto.region; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; import java.util.Date; @@ -44,6 +47,6 @@ public class LogOperationResultDTO { /** * 操作时间,该时间不是插入数据的时间,而是操作发生的真实时间 */ - private Date operatingTime; + private Long operatingTime; } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java index 15c1d4e44b..2e332fc171 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -163,7 +163,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR LogOperationResultDTO ldto = new LogOperationResultDTO(); ldto.setCategory(l.getCategory()); ldto.setContent(l.getContent()); - ldto.setOperatingTime(l.getOperatingTime()); + ldto.setOperatingTime(l.getOperatingTime().getTime()); ldto.setOperatorId(l.getOperatorId()); ldto.setTargetId(l.getTargetId()); ldto.setType(l.getType()); diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java index 2a6f2428d2..ff085c7bc0 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java @@ -26,8 +26,8 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:47 */ -@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class,url = "http://127.0.0.1:8085") -//@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class) +//@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class,url = "http://127.0.0.1:8085") +@FeignClient(name = ServiceConstant.EPMET_MESSAGE_SERVER, fallback = EpmetMessageOpenFeignClientFallback.class) public interface EpmetMessageOpenFeignClient { /** * 发送短信 diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index ea092ea63a..a9d3550fdf 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -21,8 +21,8 @@ import java.util.Map; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:09 */ -@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class, url = "http://127.0.0.1:8087") -//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class) +//@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class, url = "http://127.0.0.1:8087") +@FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallback = EpmetUserOpenFeignClientFallback.class) public interface EpmetUserOpenFeignClient { /** diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml index ccb3dc0e41..a05cf9f51f 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml @@ -390,7 +390,7 @@ and MOBILE = #{mobile} - and userId in + and user_id in #{userId} From 39d1645fe3c748ffc69ff575fda5f1f69a3c9f21 Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 9 Jun 2021 14:05:24 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8F=98=E5=8A=A8ddl?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V0.0.3__add_log_ope_table.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql index 0613c1dd2c..b55c87ecf8 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql +++ b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql @@ -1,8 +1,9 @@ CREATE TABLE `log_operation` ( `ID` varchar(64) NOT NULL COMMENT '主键ID', - `TYPE` varchar(64) NOT NULL COMMENT '类型枚举', + `TYPE` varchar(64) NOT NULL COMMENT '动作类型枚举', + `TYPE_DISPLAY` varchar(64) NOT NULL COMMENT '操作类型中文展示', `CONTENT` varchar(512) NOT NULL COMMENT '内容', - `CATEGORY` varchar(64) NOT NULL COMMENT '类别', + `CATEGORY` varchar(64) NOT NULL COMMENT '操作类型大类。例如login和logout都属于login大类。项目立项,项目流转,项目结案都属于项目大类', `TARGET_ID` varchar(64) NOT NULL COMMENT '操作目标ID', `OPERATOR_ID` varchar(64) NOT NULL COMMENT '操作人ID', `OPERATING_TIME` datetime NOT NULL COMMENT '操作时间,该时间不是插入数据的时间,而是操作发生的真实时间', From f9a344633ef195d11ce63c544a673c6ba3db7522 Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 9 Jun 2021 14:18:32 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E8=B0=83=E6=95=B4auth-client=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet-auth-client => epmet-auth-client}/pom.xml | 2 +- .../com/epmet/auth/constants/AuthOperationConstants.java | 0 .../java/com/epmet/auth/constants/AuthOperationEnum.java | 0 epmet-auth/pom.xml | 3 --- epmet-gateway/pom.xml | 8 ++++---- pom.xml | 1 + 6 files changed, 6 insertions(+), 8 deletions(-) rename {epmet-auth/epmet-auth-client => epmet-auth-client}/pom.xml (89%) rename {epmet-auth/epmet-auth-client => epmet-auth-client}/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java (100%) rename {epmet-auth/epmet-auth-client => epmet-auth-client}/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java (100%) diff --git a/epmet-auth/epmet-auth-client/pom.xml b/epmet-auth-client/pom.xml similarity index 89% rename from epmet-auth/epmet-auth-client/pom.xml rename to epmet-auth-client/pom.xml index 685407f474..1aee53c24e 100644 --- a/epmet-auth/epmet-auth-client/pom.xml +++ b/epmet-auth-client/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"> - epmet-auth + epmet-cloud com.epmet 2.0.0 diff --git a/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java b/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java similarity index 100% rename from epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java rename to epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationConstants.java diff --git a/epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java b/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java similarity index 100% rename from epmet-auth/epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java rename to epmet-auth-client/src/main/java/com/epmet/auth/constants/AuthOperationEnum.java diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 6970ec1dd8..87300fc380 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -3,9 +3,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 0.3.70 - - epmet-auth-client - com.epmet epmet-cloud diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 2a41a386b0..dc2dd76fda 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -255,11 +255,11 @@ - http://localhost:8081 - + + lb://epmet-auth-server - http://localhost:8082 - + + lb://epmet-admin-server lb://epmet-oss-server diff --git a/pom.xml b/pom.xml index 9b61cacf07..32fdd9b549 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ epmet-commons epmet-gateway epmet-auth + epmet-auth-client epmet-admin epmet-module epmet-user From 422f15f71e67ad9c9b7e95779b88df81e6c51c3c Mon Sep 17 00:00:00 2001 From: wxz Date: Wed, 9 Jun 2021 15:34:19 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E5=8D=95=E4=BD=8D=E4=B8=BA=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/impl/LogOperationServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java index 2e332fc171..ad8a3c1d6a 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -163,7 +163,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR LogOperationResultDTO ldto = new LogOperationResultDTO(); ldto.setCategory(l.getCategory()); ldto.setContent(l.getContent()); - ldto.setOperatingTime(l.getOperatingTime().getTime()); + ldto.setOperatingTime(l.getOperatingTime().getTime()/1000); ldto.setOperatorId(l.getOperatorId()); ldto.setTargetId(l.getTargetId()); ldto.setType(l.getType()); From 9e873d2595c4234810691c0f83fa25c66833e0b8 Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 10 Jun 2021 09:16:26 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0ip,app,client,operatorName,operatorM?= =?UTF-8?q?obile=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LogOperationController.java | 4 +- .../com/epmet/entity/LogOperationEntity.java | 15 +++++ .../listener/bean/log/LogOperationHelper.java | 63 +++++++++++++++++ .../mq/listener/bean/log/OperatorInfo.java | 11 +++ .../listener/AuthOperationLogListener.java | 16 +++++ .../listener/ProjectOperationLogListener.java | 9 +++ .../migration/V0.0.3__add_log_ope_table.sql | 5 ++ .../main/resources/mapper/LogOperationDao.xml | 5 ++ .../service/impl/ThirdLoginServiceImpl.java | 18 +++-- .../commons/rocketmq/messages/LoginMQMsg.java | 6 ++ .../messages/ProjectChangedMQMsg.java | 8 +++ .../impl/ProjectProcessServiceImpl.java | 20 +++++- .../service/impl/ProjectServiceImpl.java | 67 ++++++++++++++++--- .../service/impl/ProjectTraceServiceImpl.java | 13 +++- 14 files changed, 240 insertions(+), 20 deletions(-) create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java create mode 100644 epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java index ddd86e8fac..13ed1b9bd1 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/controller/LogOperationController.java @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.IpUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.LogOperationListFormDTO; @@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; @@ -27,7 +29,7 @@ public class LogOperationController { private LoginUserUtil loginUserUtil; @PostMapping("/list") - public Result> listLogOperations(@RequestBody LogOperationListFormDTO input) { + public Result> listLogOperations(@RequestBody LogOperationListFormDTO input, HttpServletRequest request) { ValidatorUtils.validateEntity(input); String condition = input.getCondition(); Integer pageNo = input.getPageNo(); diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java index b6b0d4364e..3bbbb75841 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java @@ -49,6 +49,12 @@ public class LogOperationEntity extends BaseEpmetEntity { private String typeDisplay; + private String ip; + + private String fromApp; + + private String fromClient; + /** * 内容 */ @@ -63,6 +69,15 @@ public class LogOperationEntity extends BaseEpmetEntity { * 操作人ID */ private String operatorId; + /** + * 操作人姓名 + */ + private String operatorName; + + /** + * 操作人手机号 + */ + private String operatorMobile; /** * 操作时间,该时间不是插入数据的时间,而是操作发生的真实时间 diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java new file mode 100644 index 0000000000..0d390709bd --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java @@ -0,0 +1,63 @@ +package com.epmet.mq.listener.bean.log; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.feign.EpmetUserOpenFeignClient; + +/** + * 操作日志帮助类 单例 + */ +public class LogOperationHelper implements ResultDataResolver { + + private EpmetUserOpenFeignClient userOpenFeignClient; + + private LogOperationHelper() { + } + + /** + * @Description 利用类只能加载一次的特性,保证类静态变量只能生成一份,实现单例 + * @return + * @author wxz + * @date 2021.06.09 16:55 + */ + private static class SingletonInnerClass { + public static LogOperationHelper instance = new LogOperationHelper(); + } + + /** + * @Description 获取实例 + * @return + * @author wxz + * @date 2021.06.09 16:54 + */ + public static LogOperationHelper getInstance() { + return SingletonInnerClass.instance; + } + + /** + * @Description 获取操作人信息 + * @return + * @author wxz + * @date 2021.06.09 16:57 + */ + public OperatorInfo getOperatorInfo(String userId) { + if (userOpenFeignClient == null) { + synchronized (this) { + if (userOpenFeignClient == null) { + userOpenFeignClient = SpringContextUtils.getBean(EpmetUserOpenFeignClient.class); + } + } + } + + CustomerStaffDTO form = new CustomerStaffDTO(); + form.setUserId(userId); + Result result = userOpenFeignClient.getCustomerStaffInfoByUserId(form); + CustomerStaffDTO staffInfo = getResultDataOrThrowsException(result, ServiceConstant.EPMET_ADMIN_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), + "调用epmet-user服务获取staff信息发生异常"); + return new OperatorInfo(staffInfo.getMobile(), staffInfo.getRealName()); + } +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java new file mode 100644 index 0000000000..fe1ce2fc09 --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java @@ -0,0 +1,11 @@ +package com.epmet.mq.listener.bean.log; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class OperatorInfo { + private String mobile; + private String name; +} diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java index fe6cf5a03d..85573d40f0 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java @@ -3,11 +3,20 @@ package com.epmet.mq.listener.listener; import com.alibaba.fastjson.JSON; import com.epmet.auth.constants.AuthOperationEnum; import com.epmet.commons.rocketmq.messages.LoginMQMsg; +import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; +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.feign.ResultDataResolver; +import com.epmet.commons.tools.utils.IpUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.dto.CustomerStaffDTO; import com.epmet.entity.LogOperationEntity; +import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.mq.listener.bean.log.LogOperationHelper; +import com.epmet.mq.listener.bean.log.OperatorInfo; import com.epmet.service.LogOperationService; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; @@ -48,12 +57,19 @@ public class AuthOperationLogListener implements MessageListenerConcurrently { logger.info("认证操作日志监听器-收到消息内容:{}", msg); LoginMQMsg msgObj = JSON.parseObject(msg, LoginMQMsg.class); + //获取操作人信息 + OperatorInfo operatorInfo = LogOperationHelper.getInstance().getOperatorInfo(msgObj.getUserId()); LogOperationEntity logEntity = new LogOperationEntity(); logEntity.setCategory(messageExt.getTopic()); logEntity.setType(tags); logEntity.setTypeDisplay(AuthOperationEnum.getDisplay(tags)); + logEntity.setIp(msgObj.getIp()); + logEntity.setFromApp(msgObj.getFromApp()); + logEntity.setFromClient(msgObj.getFromClient()); logEntity.setTargetId(""); logEntity.setOperatorId(msgObj.getUserId()); + logEntity.setOperatorName(operatorInfo.getName()); + logEntity.setOperatorMobile(operatorInfo.getMobile()); logEntity.setOperatingTime(msgObj.getLoginTime()); logEntity.setContent("成功登录系统"); diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java index 181e7cd3fc..5240444701 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java @@ -8,6 +8,8 @@ import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.entity.LogOperationEntity; +import com.epmet.mq.listener.bean.log.LogOperationHelper; +import com.epmet.mq.listener.bean.log.OperatorInfo; import com.epmet.service.LogOperationService; import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; @@ -51,12 +53,19 @@ public class ProjectOperationLogListener implements MessageListenerConcurrently String content = StringUtils.isBlank(msgObj.getOperationBrief()) ? "" : msgObj.getOperationBrief(); + OperatorInfo operatorInfo = LogOperationHelper.getInstance().getOperatorInfo(msgObj.getOperatorId()); + LogOperationEntity logEntity = new LogOperationEntity(); logEntity.setCategory(messageExt.getTopic()); logEntity.setType(msgObj.getOperation()); logEntity.setTypeDisplay(getOperationTypeDisplay(msgObj.getOperation())); logEntity.setTargetId(msgObj.getProjectId()); + logEntity.setIp(msgObj.getIp()); + logEntity.setFromApp(msgObj.getFromApp()); + logEntity.setFromClient(msgObj.getFromClient()); logEntity.setOperatorId(msgObj.getOperatorId()); + logEntity.setOperatorMobile(operatorInfo.getMobile()); + logEntity.setOperatorName(operatorInfo.getName()); logEntity.setOperatingTime(msgObj.getOperatingTime()); logEntity.setContent(content); diff --git a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql index b55c87ecf8..c6ccb2e1e9 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql +++ b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.3__add_log_ope_table.sql @@ -4,8 +4,13 @@ CREATE TABLE `log_operation` ( `TYPE_DISPLAY` varchar(64) NOT NULL COMMENT '操作类型中文展示', `CONTENT` varchar(512) NOT NULL COMMENT '内容', `CATEGORY` varchar(64) NOT NULL COMMENT '操作类型大类。例如login和logout都属于login大类。项目立项,项目流转,项目结案都属于项目大类', + `IP` varchar(15) NOT NULL COMMENT 'IP地址', + `FROM_APP` varchar(10) NOT NULL COMMENT '所用的APP', + `FROM_CLIENT` varchar(10) NOT NULL COMMENT '所用的client', `TARGET_ID` varchar(64) NOT NULL COMMENT '操作目标ID', `OPERATOR_ID` varchar(64) NOT NULL COMMENT '操作人ID', + `OPERATOR_NAME` varchar(15) NOT NULL COMMENT '操作者姓名', + `OPERATOR_MOBILE` varchar(11) NOT NULL COMMENT '操作者电话', `OPERATING_TIME` datetime NOT NULL COMMENT '操作时间,该时间不是插入数据的时间,而是操作发生的真实时间', `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', `REVISION` int(11) NOT NULL COMMENT '乐观锁', diff --git a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml index 1496892029..0e00d21c34 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml +++ b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml @@ -9,8 +9,13 @@ + + + + + diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index 3926452c8d..b6881aefdd 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; import com.epmet.auth.constants.AuthOperationConstants; import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.rocketmq.messages.LoginMQMsg; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; @@ -32,6 +33,7 @@ import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; import com.epmet.redis.CaptchaRedis; import com.epmet.service.ThirdLoginService; +import com.sun.deploy.association.utility.AppConstants; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.spring.core.RocketMQTemplate; @@ -40,7 +42,10 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletRequest; import java.util.*; import java.util.stream.Collectors; @@ -183,11 +188,11 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol //7.发送登录事件 try { - sendLoginEvent(staffLatestAgencyResultDTO.getStaffId(), formDTO.getAppId()); + sendLoginEvent(staffLatestAgencyResultDTO.getStaffId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP); } catch (RenException e) { log.error(e.getInternalMsg()); } catch (Exception e) { - log.error("【工作端workLogin登录】发送登录事件失败,程序继续执行。错误信息"); + log.error("【工作端workLogin登录】发送登录事件失败,程序继续执行。"); } return userTokenResultDTO; @@ -414,7 +419,7 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol //6.发送登录事件 try { - sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId()); + sendLoginEvent(customerStaff.getUserId(), formDTO.getAppId(), AppClientConstant.APP_GOV, AppClientConstant.CLIENT_WXMP); } catch (RenException e) { log.error(e.getInternalMsg()); } catch (Exception e) { @@ -670,11 +675,16 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol * @author wxz * @date 2021.06.08 15:27 */ - private void sendLoginEvent(String userId, String appId) { + private void sendLoginEvent(String userId, String appId, String fromApp, String fromClient) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + LoginMQMsg loginMQMsg = new LoginMQMsg(); loginMQMsg.setUserId(userId); loginMQMsg.setLoginTime(new Date()); loginMQMsg.setAppId(appId); + loginMQMsg.setIp(IpUtils.getIpAddr(request)); + loginMQMsg.setFromApp(fromApp); + loginMQMsg.setFromClient(fromClient); SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(AuthOperationConstants.LOGIN); diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java index 643cd99f03..646db43501 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/LoginMQMsg.java @@ -17,4 +17,10 @@ public class LoginMQMsg { */ private Date loginTime; + private String ip; + + private String fromApp; + + private String fromClient; + } diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java index 9530f7a326..5f33faae98 100644 --- a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/ProjectChangedMQMsg.java @@ -29,4 +29,12 @@ public class ProjectChangedMQMsg implements Serializable { */ private String operationBrief; + /** + * 操作者ip + */ + private String ip; + private String fromApp; + private String fromClient; + + } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java index 79e1903e7d..ad3fec6959 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectProcessServiceImpl.java @@ -31,7 +31,9 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.scan.param.TextScanParamDTO; import com.epmet.commons.tools.scan.param.TextTaskDTO; import com.epmet.commons.tools.scan.result.SyncScanResult; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.IpUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.ProjectConstant; @@ -71,7 +73,10 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletRequest; import java.util.*; import java.util.stream.Collectors; @@ -116,6 +121,8 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl page(Map params) { @@ -387,14 +394,17 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl implements ProjectTraceS private EpmetUserFeignClient epmetUserFeignClient; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private LoginUserUtil loginUserUtil; @Override public List getPendProjectList(TokenDto tokenDto, ProjectListFromDTO fromDTO) { @@ -506,12 +513,16 @@ public class ProjectTraceServiceImpl implements ProjectTraceS } //项目实时统计消息 + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String mqMsgBrief = String.format("创建了\"%s\"的项目", formDTO.getTitle()); ProjectChangedMQMsg mqMsg = new ProjectChangedMQMsg(projectEntity.getCustomerId(), ProjectConstant.OPERATION_CREATED, projectEntity.getId(), formDTO.getUserId(), new Date(), - mqMsgBrief); + mqMsgBrief, + IpUtils.getIpAddr(request), + loginUserUtil.getLoginUserApp(), + loginUserUtil.getLoginUserClient()); boolean msgResult = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendProjectChangedMqMsg(mqMsg); if (!msgResult) { log.error("项目实时统计消息发送失败"); From 4a5b12206156eaf5dd5ae4446f10b0841537c3cb Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 10 Jun 2021 09:29:23 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99impor?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/impl/ThirdLoginServiceImpl.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java index b6881aefdd..4d848f2dcf 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/ThirdLoginServiceImpl.java @@ -22,7 +22,6 @@ import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.constant.AuthHttpUrlConstant; import com.epmet.constant.SmsTemplateConstant; -import com.epmet.constant.SystemMessageType; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -33,10 +32,8 @@ import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; import com.epmet.redis.CaptchaRedis; import com.epmet.service.ThirdLoginService; -import com.sun.deploy.association.utility.AppConstants; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; From cf238e3ac2bb6526c1b4186fd0286911126d48b7 Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 11 Jun 2021 14:07:38 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=88=97=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0customer=5Fid=E5=88=97=20=E6=97=A5=E5=BF=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=94=B9=E4=B8=BA=E6=A8=A1?= =?UTF-8?q?=E7=B3=8A=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/region/LogOperationResultDTO.java | 1 + .../com/epmet/entity/LogOperationEntity.java | 2 ++ .../listener/bean/log/LogOperationHelper.java | 2 +- .../mq/listener/bean/log/OperatorInfo.java | 1 + .../listener/AuthOperationLogListener.java | 1 + .../listener/ProjectOperationLogListener.java | 1 + .../service/impl/LogOperationServiceImpl.java | 35 +++++++++++-------- .../db/migration/V0.0.4__addlog_ope_col.sql | 1 + .../src/main/resources/logback-spring.xml | 2 +- .../main/resources/mapper/LogOperationDao.xml | 1 + .../controller/CustomerStaffController.java | 4 +-- 11 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.4__addlog_ope_col.sql diff --git a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java index 6033b176e6..a9cca21013 100644 --- a/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java +++ b/epmet-admin/epmet-admin-client/src/main/java/com/epmet/dto/region/LogOperationResultDTO.java @@ -40,6 +40,7 @@ public class LogOperationResultDTO { /** * 操作人ID */ + private String customerId; private String operatorId; private String operatorName; private String operatorMobile; diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java index 3bbbb75841..d3f3f20402 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/entity/LogOperationEntity.java @@ -65,6 +65,8 @@ public class LogOperationEntity extends BaseEpmetEntity { */ private String targetId; + private String customerId; + /** * 操作人ID */ diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java index 0d390709bd..b8c82f6640 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/LogOperationHelper.java @@ -58,6 +58,6 @@ public class LogOperationHelper implements ResultDataResolver { Result result = userOpenFeignClient.getCustomerStaffInfoByUserId(form); CustomerStaffDTO staffInfo = getResultDataOrThrowsException(result, ServiceConstant.EPMET_ADMIN_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用epmet-user服务获取staff信息发生异常"); - return new OperatorInfo(staffInfo.getMobile(), staffInfo.getRealName()); + return new OperatorInfo(staffInfo.getCustomerId(), staffInfo.getMobile(), staffInfo.getRealName()); } } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java index fe1ce2fc09..6dfd9ba7d9 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/bean/log/OperatorInfo.java @@ -6,6 +6,7 @@ import lombok.Data; @Data @AllArgsConstructor public class OperatorInfo { + private String customerId; private String mobile; private String name; } diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java index 85573d40f0..4f9e361fc5 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/AuthOperationLogListener.java @@ -67,6 +67,7 @@ public class AuthOperationLogListener implements MessageListenerConcurrently { logEntity.setFromApp(msgObj.getFromApp()); logEntity.setFromClient(msgObj.getFromClient()); logEntity.setTargetId(""); + logEntity.setCustomerId(operatorInfo.getCustomerId()); logEntity.setOperatorId(msgObj.getUserId()); logEntity.setOperatorName(operatorInfo.getName()); logEntity.setOperatorMobile(operatorInfo.getMobile()); diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java index 5240444701..13384ea62e 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/mq/listener/listener/ProjectOperationLogListener.java @@ -63,6 +63,7 @@ public class ProjectOperationLogListener implements MessageListenerConcurrently logEntity.setIp(msgObj.getIp()); logEntity.setFromApp(msgObj.getFromApp()); logEntity.setFromClient(msgObj.getFromClient()); + logEntity.setCustomerId(operatorInfo.getCustomerId()); logEntity.setOperatorId(msgObj.getOperatorId()); logEntity.setOperatorMobile(operatorInfo.getMobile()); logEntity.setOperatorName(operatorInfo.getName()); diff --git a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java index ad8a3c1d6a..09b9269063 100644 --- a/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java +++ b/epmet-admin/epmet-admin-server/src/main/java/com/epmet/service/impl/LogOperationServiceImpl.java @@ -16,14 +16,12 @@ import com.epmet.dto.region.LogOperationResultDTO; import com.epmet.entity.LogOperationEntity; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.service.LogOperationService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @Service @@ -54,29 +52,35 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR @Override public List listOperationLogs(String condition, String customerId, Integer pageNo, Integer pageSize) { // 1.条件查询 - List logDtos = listByOperatorMobile(condition, customerId, pageNo, pageSize); - if (CollectionUtils.isEmpty(logDtos)) { - logDtos = listByOperatorName(condition, pageNo, pageSize); - } - - if (CollectionUtils.isEmpty(logDtos)) { - return new ArrayList<>(); - } + //List logDtos = listByOperatorMobile(condition, customerId, pageNo, pageSize); + //if (CollectionUtils.isEmpty(logDtos)) { + // logDtos = listByOperatorName(condition, pageNo, pageSize); + //} + // + //if (CollectionUtils.isEmpty(logDtos)) { + // return new ArrayList<>(); + //} // 2.直接分页查询 // 条件查询,排序 LambdaQueryWrapper w = new LambdaQueryWrapper<>(); + if (StringUtils.isNotBlank(condition)) { + w.like(LogOperationEntity::getOperatorName, condition) + .or() + .like(LogOperationEntity::getOperatorMobile, condition); + } + w.eq(LogOperationEntity::getCustomerId, customerId); w.orderByDesc(LogOperationEntity::getOperatingTime); IPage iPage = logOperationDao.selectPage(new Page<>(pageNo, pageSize), w); List logEntities = iPage.getRecords(); - List userIds = logEntities.stream().map(l -> l.getOperatorId()).collect(Collectors.toList()); + Set userIds = logEntities.stream().map(l -> l.getOperatorId()).collect(Collectors.toSet()); return convertLogOperationEntity2DTO(logEntities, getStaffMapByUserIds(userIds)); } - private Map getStaffMapByUserIds(List userIds) { + private Map getStaffMapByUserIds(Set userIds) { CustomerStaffFormDTO form = new CustomerStaffFormDTO(); - form.setUserIds(userIds); + form.setUserIds(new ArrayList<>(userIds)); Result> result = userOpenFeignClient.list(form); List staffs = getResultDataOrThrowsException(result, ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "调用user服务发生异常"); @@ -168,6 +172,7 @@ public class LogOperationServiceImpl implements LogOperationService, ResultDataR ldto.setTargetId(l.getTargetId()); ldto.setType(l.getType()); ldto.setTypeDisplay(l.getTypeDisplay()); + ldto.setCustomerId(l.getCustomerId()); ldto.setOperatorMobile(staffMap.get(l.getOperatorId()).getMobile()); ldto.setOperatorName(staffMap.get(l.getOperatorId()).getRealName()); return ldto; diff --git a/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.4__addlog_ope_col.sql b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.4__addlog_ope_col.sql new file mode 100644 index 0000000000..e2bcec3b6d --- /dev/null +++ b/epmet-admin/epmet-admin-server/src/main/resources/db/migration/V0.0.4__addlog_ope_col.sql @@ -0,0 +1 @@ +alter table log_operation add CUSTOMER_ID varchar(64) comment '客户id' not null after OPERATOR_ID; \ No newline at end of file diff --git a/epmet-admin/epmet-admin-server/src/main/resources/logback-spring.xml b/epmet-admin/epmet-admin-server/src/main/resources/logback-spring.xml index 215a9500e7..fc97e8f1c9 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/logback-spring.xml +++ b/epmet-admin/epmet-admin-server/src/main/resources/logback-spring.xml @@ -134,7 +134,7 @@ - + diff --git a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml index 0e00d21c34..5f34d339ad 100644 --- a/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml +++ b/epmet-admin/epmet-admin-server/src/main/resources/mapper/LogOperationDao.xml @@ -13,6 +13,7 @@ + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java index d488ecff59..cb9673ccf6 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java @@ -424,9 +424,7 @@ public class CustomerStaffController { */ @PostMapping("list") public Result> list(@RequestBody CustomerStaffFormDTO input) { - String customerId = StringUtils.isBlank(input.getCustomerId()) ? loginUserUtil.getLoginUserCustomerId() : input.getCustomerId(); - - List staffs = customerStaffService.list(customerId, input.getRealName(), input.getMobile(), input.getUserIds()); + List staffs = customerStaffService.list(input.getCustomerId(), input.getRealName(), input.getMobile(), input.getUserIds()); return new Result>().ok(staffs); }