diff --git a/log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java b/log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java index c5afda663eae461493252da54662c9289fc0753d..0c2a100b6053e322c6bf9df11778e3a40b0ee792 100644 --- a/log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java +++ b/log-manager/src/main/java/com/mortals/xhx/base/framework/listener/AccessMessageConsumerListener.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.mortals.xhx.common.key.Constant; import com.mortals.xhx.common.key.QueueKey; import com.mortals.xhx.common.pdu.access.AccessLogPdu; import com.mortals.xhx.module.access.model.AccessLogEntity; @@ -23,6 +24,7 @@ import org.springframework.boot.autoconfigure.amqp.RabbitProperties; import org.springframework.messaging.handler.annotation.Headers; import org.springframework.messaging.handler.annotation.Payload; import org.springframework.stereotype.Component; +import org.springframework.util.ObjectUtils; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -69,15 +71,19 @@ public class AccessMessageConsumerListener { @RabbitHandler public void onMessage(List<AccessLogEntity> messages) { - log.info("[Access onMessage][娑堟伅鏁伴噺锛歿}]", messages.size()); + log.info("[Access onMessage][娑堟伅鏁伴噺锛歿}]", messages.size()); List<AccessLogEntity> collect = messages.stream().map(entity -> { try { - // AccessLogEntity entity =null; + // AccessLogEntity entity =null; //entity = JSON.parseObject(message, AccessLogEntity.class); - entity.setLogTime(entity.getLogTime()==null?new Date():entity.getLogTime()); + entity.setLogTime(entity.getLogTime() == null ? new Date() : entity.getLogTime()); entity.setId(IdUtil.getSnowflake(0, 1).nextId()); entity.setCreateUserId(1L); entity.setCreateTime(new Date()); + //鍒ゆ柇 瓒呰繃涓€瀹氭椂闂寸殑璇锋眰 鎵嶈褰� + if (!ObjectUtils.isEmpty(entity.getDuration()) && entity.getDuration() < Constant.ACCESS_EXPIRE_TIME) { + return null; + } return entity; } catch (Exception e) { log.info("鍙嶅簭鍒楀寲寮傚父", e); diff --git a/log-manager/src/main/java/com/mortals/xhx/common/key/Constant.java b/log-manager/src/main/java/com/mortals/xhx/common/key/Constant.java index 1e94db916924e7217b315b6ef356cbc0db59db9b..ff6d7076e1b9f6996511f61f70d120608926b614 100644 --- a/log-manager/src/main/java/com/mortals/xhx/common/key/Constant.java +++ b/log-manager/src/main/java/com/mortals/xhx/common/key/Constant.java @@ -114,4 +114,9 @@ public final class Constant { public static final String DISTRIBUTE_PATH = "distribute_path"; + /** + * 璁块棶瓒呮椂鏃堕棿,榛樿2绉� + */ + public static final Long ACCESS_EXPIRE_TIME = 2000L; + }