From f22a5485cbe6563447ace9cf7939405f7e06c6a6 Mon Sep 17 00:00:00 2001 From: aijinhui <aijinhui> Date: 星期一, 13 十一月 2023 10:25:27 +0800 Subject: [PATCH] 车辆RTU --- ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java | 61 +++++++++++++++++------------- 1 files changed, 35 insertions(+), 26 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java b/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java index ce70fdf..d5f2c06 100644 --- a/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/storage/minio/service/impl/StorageMinioEventServiceImpl.java @@ -1,26 +1,30 @@ package com.ruoyi.storage.minio.service.impl; +import java.io.File; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.storage.minio.domain.jsonbean.*; +import com.ruoyi.utils.process.CmdUtils; +import com.sun.jna.Platform; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import com.ruoyi.storage.minio.mapper.StorageMinioEventMapper; import com.ruoyi.storage.minio.domain.StorageMinioEvent; import com.ruoyi.storage.minio.service.IStorageMinioEventService; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import javax.annotation.Resource; /** @@ -32,6 +36,7 @@ @Service @Slf4j(topic = "minio") public class StorageMinioEventServiceImpl implements IStorageMinioEventService { + @Resource private StorageMinioEventMapper storageMinioEventMapper; @@ -106,31 +111,35 @@ @Async @Override public void parseStorageMinioEvent(String message) { - JsonsRootBean jsonsRootBean = JSONObject.parseObject(message, JsonsRootBean.class); - if (jsonsRootBean != null) { - Records records = jsonsRootBean.getRecords().get(0); - StorageMinioEvent storageMinioEvent = new StorageMinioEvent(); - storageMinioEvent.setEventTime(records.getEventTime()); - storageMinioEvent.setEventType(records.getEventName()); - storageMinioEvent.setBucketName(records.getS3().getBucket().getName()); - String encode = null; - try { - encode = URLDecoder.decode(records.getS3().getMObject().getKey(), "UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - storageMinioEvent.setObjectName(encode); - storageMinioEvent.setObjectSize(records.getS3().getMObject().getSize()); - storageMinioEvent.setObjectType(records.getS3().getMObject().getContentType()); - storageMinioEvent.setHost(records.getSource().getHost()); - storageMinioEvent.setEndpoint(records.getResponseElements().getXMinioOriginEndpoint()); - storageMinioEvent.setUserName(records.getRequestParameters().getPrincipalid()); + try { + JsonsRootBean jsonsRootBean = JSONObject.parseObject(message, JsonsRootBean.class); + if (jsonsRootBean != null) { + Records records = jsonsRootBean.getRecords().get(0); + StorageMinioEvent storageMinioEvent = new StorageMinioEvent(); + storageMinioEvent.setEventTime(records.getEventTime()); + String eventType = records.getEventName().substring(0, records.getEventName().indexOf(":", records.getEventName().indexOf(":") + 1));//涓嶅寘鍚湰韬綅缃� + storageMinioEvent.setEventType(eventType); + storageMinioEvent.setBucketName(records.getS3().getBucket().getName()); + String encode = null; + try { + encode = URLDecoder.decode(records.getS3().getMObject().getKey(), "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + storageMinioEvent.setObjectName(encode); + storageMinioEvent.setObjectSize(records.getS3().getMObject().getSize()); + storageMinioEvent.setObjectType(records.getS3().getMObject().getContentType()); + storageMinioEvent.setHost(records.getSource().getHost()); + storageMinioEvent.setEndpoint(records.getResponseElements().getXMinioOriginEndpoint()); + storageMinioEvent.setUserName(records.getRequestParameters().getPrincipalid()); - int i = insertStorageMinioEvent(storageMinioEvent); - if(i>0) - { - log.debug("minio鎿嶄綔鏃ュ織鍏ュ簱鎴愬姛!銆�"+storageMinioEvent.getEventType()+"銆�"); + int i = insertStorageMinioEvent(storageMinioEvent); + if (i > 0) { + log.debug("minio鎿嶄綔鏃ュ織鍏ュ簱鎴愬姛!銆�" + storageMinioEvent.getEventType() + "銆�"); + } } + } catch (Exception ex) { + log.error("minio浜嬩欢鏍煎紡鍖栧紓甯�:" + ex.getMessage()); } } } -- Gitblit v1.9.3