diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d2dce30..27c80b8 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -59,8 +59,7 @@
update ter_device_monitoring_data_realtime set del_flag = 0;
update ter_device_monitoring_data set del_flag = 0;
---未更新 0603
-
+--已更新 0603
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `software` varchar(255) DEFAULT NULL COMMENT '软件版本' AFTER `first_warn_datetime`,
ADD COLUMN `hardware` varchar(255) DEFAULT NULL COMMENT '硬件版本' AFTER `software`,
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d2dce30..27c80b8 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -59,8 +59,7 @@
update ter_device_monitoring_data_realtime set del_flag = 0;
update ter_device_monitoring_data set del_flag = 0;
---未更新 0603
-
+--已更新 0603
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `software` varchar(255) DEFAULT NULL COMMENT '软件版本' AFTER `first_warn_datetime`,
ADD COLUMN `hardware` varchar(255) DEFAULT NULL COMMENT '硬件版本' AFTER `software`,
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index 71b64a0..f2722fb 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -28,6 +28,12 @@
spring-integration-mqtt
+
+ com.qcloud
+ cos_api
+ 5.6.213
+
+
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d2dce30..27c80b8 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -59,8 +59,7 @@
update ter_device_monitoring_data_realtime set del_flag = 0;
update ter_device_monitoring_data set del_flag = 0;
---未更新 0603
-
+--已更新 0603
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `software` varchar(255) DEFAULT NULL COMMENT '软件版本' AFTER `first_warn_datetime`,
ADD COLUMN `hardware` varchar(255) DEFAULT NULL COMMENT '硬件版本' AFTER `software`,
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index 71b64a0..f2722fb 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -28,6 +28,12 @@
spring-integration-mqtt
+
+ com.qcloud
+ cos_api
+ 5.6.213
+
+
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
index 0dadc84..638a9ac 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
@@ -31,4 +31,10 @@
@ApiModelProperty(value = "摄像头")
private String camera;
+ /**
+ *
+ */
+ @ApiModelProperty(value = "", hidden = true)
+ private Date lastPicTime;
+
}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d2dce30..27c80b8 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -59,8 +59,7 @@
update ter_device_monitoring_data_realtime set del_flag = 0;
update ter_device_monitoring_data set del_flag = 0;
---未更新 0603
-
+--已更新 0603
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `software` varchar(255) DEFAULT NULL COMMENT '软件版本' AFTER `first_warn_datetime`,
ADD COLUMN `hardware` varchar(255) DEFAULT NULL COMMENT '硬件版本' AFTER `software`,
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index 71b64a0..f2722fb 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -28,6 +28,12 @@
spring-integration-mqtt
+
+ com.qcloud
+ cos_api
+ 5.6.213
+
+
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
index 0dadc84..638a9ac 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
@@ -31,4 +31,10 @@
@ApiModelProperty(value = "摄像头")
private String camera;
+ /**
+ *
+ */
+ @ApiModelProperty(value = "", hidden = true)
+ private Date lastPicTime;
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
index 3a50b96..2891a87 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
@@ -59,6 +59,8 @@
set(StringUtils.isNotBlank(termiteDateUpRequest.getRssi()), "rssi", termiteDateUpRequest.getRssi()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getAP()), "ap", termiteDateUpRequest.getAP()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getCamera()), "camera", termiteDateUpRequest.getCamera()).
+ set(null != termiteDateUpRequest.getLastPicTime(), "last_pic_time", termiteDateUpRequest.getLastPicTime()).
+ set("sync_state", EDeviceSyncState.success.getCode()).
eq("sn", termiteDateUpRequest.getSn());
update(updateWrapper);
return true;
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d2dce30..27c80b8 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -59,8 +59,7 @@
update ter_device_monitoring_data_realtime set del_flag = 0;
update ter_device_monitoring_data set del_flag = 0;
---未更新 0603
-
+--已更新 0603
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `software` varchar(255) DEFAULT NULL COMMENT '软件版本' AFTER `first_warn_datetime`,
ADD COLUMN `hardware` varchar(255) DEFAULT NULL COMMENT '硬件版本' AFTER `software`,
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index 71b64a0..f2722fb 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -28,6 +28,12 @@
spring-integration-mqtt
+
+ com.qcloud
+ cos_api
+ 5.6.213
+
+
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
index 0dadc84..638a9ac 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
@@ -31,4 +31,10 @@
@ApiModelProperty(value = "摄像头")
private String camera;
+ /**
+ *
+ */
+ @ApiModelProperty(value = "", hidden = true)
+ private Date lastPicTime;
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
index 3a50b96..2891a87 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
@@ -59,6 +59,8 @@
set(StringUtils.isNotBlank(termiteDateUpRequest.getRssi()), "rssi", termiteDateUpRequest.getRssi()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getAP()), "ap", termiteDateUpRequest.getAP()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getCamera()), "camera", termiteDateUpRequest.getCamera()).
+ set(null != termiteDateUpRequest.getLastPicTime(), "last_pic_time", termiteDateUpRequest.getLastPicTime()).
+ set("sync_state", EDeviceSyncState.success.getCode()).
eq("sn", termiteDateUpRequest.getSn());
update(updateWrapper);
return true;
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
index 6d1bcff..ab25c36 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
@@ -10,8 +10,17 @@
import com.newfiber.termite.domain.DeviceMonitoringDataRealtime;
import com.newfiber.termite.domain.OneByOneNow;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
+import com.newfiber.termite.domain.dto.AlarmDataDto;
+import com.newfiber.termite.domain.dto.DeviceInfoDto;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
@@ -24,6 +33,7 @@
import com.newfiber.termite.enums.EIdentColle;
import com.newfiber.termite.mapper.TermiteMapper;
import com.newfiber.termite.service.ITermiteService;
+import com.newfiber.termite.util.CosUtil;
import com.newfiber.termite.util.FileUploadUtils;
import com.newfiber.termite.util.MinioConfig;
import io.minio.MinioClient;
@@ -37,6 +47,11 @@
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
@@ -47,12 +62,6 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
@Slf4j
@Service
public class TermiteServiceImpl extends BaseServiceImpl implements ITermiteService {
@@ -83,7 +92,7 @@
public DataUpResponse termiteDataup(TermiteDataUpRequest termiteDateUpRequest, MultipartFile image) throws Exception{
String date = DateUtil.formatDateTime(new Date());
log.info("站点{}在{}时刻上传数据", termiteDateUpRequest.getSn(), date);
- String url = uploadFile(image);
+ String url = CosUtil.putFile(image);
// 保存历史数据
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
@@ -106,6 +115,7 @@
DeviceMonitoringData lastHeatingDeviceMonitoringData = deviceMonitoringDataService.lastHeating(termiteDateUpRequest.getSn());
// 更新设备状态
+ termiteDateUpRequest.setLastPicTime(new Date());
deviceInfoService.update(termiteDateUpRequest);
return new DataUpResponse(url, lastDrugingDeviceMonitoringData, lastHeatingDeviceMonitoringData);
@@ -116,7 +126,7 @@
DeviceMonitoringData existedDeviceMonitoringData = deviceMonitoringDataService.getById(dataDto.getId());
log.info("站点{}在{}时刻更新识别结果", existedDeviceMonitoringData.getSn(), DateUtil.formatDateTime(new Date()));
- String url = uploadFile(image);
+ String url = CosUtil.putFile(image);
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
deviceMonitoringData.setId(Long.parseLong(dataDto.getId()));
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d2dce30..27c80b8 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -59,8 +59,7 @@
update ter_device_monitoring_data_realtime set del_flag = 0;
update ter_device_monitoring_data set del_flag = 0;
---未更新 0603
-
+--已更新 0603
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `software` varchar(255) DEFAULT NULL COMMENT '软件版本' AFTER `first_warn_datetime`,
ADD COLUMN `hardware` varchar(255) DEFAULT NULL COMMENT '硬件版本' AFTER `software`,
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index 71b64a0..f2722fb 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -28,6 +28,12 @@
spring-integration-mqtt
+
+ com.qcloud
+ cos_api
+ 5.6.213
+
+
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
index 0dadc84..638a9ac 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
@@ -31,4 +31,10 @@
@ApiModelProperty(value = "摄像头")
private String camera;
+ /**
+ *
+ */
+ @ApiModelProperty(value = "", hidden = true)
+ private Date lastPicTime;
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
index 3a50b96..2891a87 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
@@ -59,6 +59,8 @@
set(StringUtils.isNotBlank(termiteDateUpRequest.getRssi()), "rssi", termiteDateUpRequest.getRssi()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getAP()), "ap", termiteDateUpRequest.getAP()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getCamera()), "camera", termiteDateUpRequest.getCamera()).
+ set(null != termiteDateUpRequest.getLastPicTime(), "last_pic_time", termiteDateUpRequest.getLastPicTime()).
+ set("sync_state", EDeviceSyncState.success.getCode()).
eq("sn", termiteDateUpRequest.getSn());
update(updateWrapper);
return true;
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
index 6d1bcff..ab25c36 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
@@ -10,8 +10,17 @@
import com.newfiber.termite.domain.DeviceMonitoringDataRealtime;
import com.newfiber.termite.domain.OneByOneNow;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
+import com.newfiber.termite.domain.dto.AlarmDataDto;
+import com.newfiber.termite.domain.dto.DeviceInfoDto;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
@@ -24,6 +33,7 @@
import com.newfiber.termite.enums.EIdentColle;
import com.newfiber.termite.mapper.TermiteMapper;
import com.newfiber.termite.service.ITermiteService;
+import com.newfiber.termite.util.CosUtil;
import com.newfiber.termite.util.FileUploadUtils;
import com.newfiber.termite.util.MinioConfig;
import io.minio.MinioClient;
@@ -37,6 +47,11 @@
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
@@ -47,12 +62,6 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
@Slf4j
@Service
public class TermiteServiceImpl extends BaseServiceImpl implements ITermiteService {
@@ -83,7 +92,7 @@
public DataUpResponse termiteDataup(TermiteDataUpRequest termiteDateUpRequest, MultipartFile image) throws Exception{
String date = DateUtil.formatDateTime(new Date());
log.info("站点{}在{}时刻上传数据", termiteDateUpRequest.getSn(), date);
- String url = uploadFile(image);
+ String url = CosUtil.putFile(image);
// 保存历史数据
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
@@ -106,6 +115,7 @@
DeviceMonitoringData lastHeatingDeviceMonitoringData = deviceMonitoringDataService.lastHeating(termiteDateUpRequest.getSn());
// 更新设备状态
+ termiteDateUpRequest.setLastPicTime(new Date());
deviceInfoService.update(termiteDateUpRequest);
return new DataUpResponse(url, lastDrugingDeviceMonitoringData, lastHeatingDeviceMonitoringData);
@@ -116,7 +126,7 @@
DeviceMonitoringData existedDeviceMonitoringData = deviceMonitoringDataService.getById(dataDto.getId());
log.info("站点{}在{}时刻更新识别结果", existedDeviceMonitoringData.getSn(), DateUtil.formatDateTime(new Date()));
- String url = uploadFile(image);
+ String url = CosUtil.putFile(image);
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
deviceMonitoringData.setId(Long.parseLong(dataDto.getId()));
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/util/CosUtil.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/util/CosUtil.java
new file mode 100644
index 0000000..122241a
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/util/CosUtil.java
@@ -0,0 +1,104 @@
+package com.newfiber.termite.util;
+
+import cn.hutool.core.date.DateUtil;
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosClientException;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.PutObjectResult;
+import com.qcloud.cos.region.Region;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+public class CosUtil {
+ private static String secretId = "AKIDoOp3B8JLacTElCnM5bbxHOGuHsGOd5NB";
+ private static String secretKey = "lK8xY6MAkm8F6kQr1xkHYJp9EgtpVv87";
+ private static String bucketName = "termite-1255570142";
+ private static String region = "ap-nanjing";
+ private static COSClient cosClient = createCli();;
+ private static String url = "https://termite-1255570142.cos.ap-nanjing.myqcloud.com/";
+
+ private static COSClient createCli() {
+ // 初始化用户身份信息(secretId, secretKey)
+ COSCredentials cred = new BasicCOSCredentials(secretId,secretKey);
+ // 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
+ ClientConfig clientConfig = new ClientConfig(new Region(region));
+ // 生成cos客户端
+ return new COSClient(cred, clientConfig);
+ }
+
+ public static String putFile(MultipartFile file){
+
+ try {
+ Date date = new Date();
+ String fileName = file.getOriginalFilename();
+ fileName = DateUtil.year(date) + "/" + (DateUtil.month(date) + 1) + "/" + DateUtil.dayOfMonth(date) + "/" + fileName;
+ InputStream inputStream = file.getInputStream();
+ ObjectMetadata objectMetadata = new ObjectMetadata();
+
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileName, inputStream, objectMetadata);
+ // 设置单链接限速(如有需要),不需要可忽略
+ putObjectRequest.setTrafficLimit(8*1024*1024);
+ PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
+// System.out.println(putObjectResult.getRequestId());
+ return url + fileName;
+ } catch (CosServiceException e) {
+ e.printStackTrace();
+ } catch (CosClientException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return "";
+ }
+
+ private static void putLocalFileDemo() {
+ String key = "abc/abc.txt";
+ String localPath = "abc.txt";
+
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, new File(localPath));
+ try {
+ PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
+ System.out.println(putObjectResult.getRequestId());
+ } catch (CosServiceException cse) {
+ cse.printStackTrace();
+ } catch (CosClientException cce) {
+ cce.printStackTrace();
+ }
+ }
+
+ private static void putInputStreamDemo() {
+ String key = "abc/def.txt";
+ // 这里创建一个 ByteArrayInputStream 来作为示例,实际中这里应该是您要上传的 InputStream 类型的流
+ int inputStreamLength = 1024 * 1024;
+ byte data[] = new byte[inputStreamLength];
+ InputStream inputStream = new ByteArrayInputStream(data);
+
+ ObjectMetadata objectMetadata = new ObjectMetadata();
+ // 上传的流如果能够获取准确的流长度,则推荐一定填写 content-length
+ // 如果确实没办法获取到,则下面这行可以省略,但同时高级接口也没办法使用分块上传了
+ objectMetadata.setContentLength(inputStreamLength);
+
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, inputStream, objectMetadata);
+ // 设置单链接限速(如有需要),不需要可忽略
+ putObjectRequest.setTrafficLimit(8*1024*1024);
+ try {
+ PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
+ System.out.println(putObjectResult.getRequestId());
+ } catch (CosServiceException e) {
+ e.printStackTrace();
+ } catch (CosClientException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/doc/upgrade.sql b/doc/upgrade.sql
index d2dce30..27c80b8 100644
--- a/doc/upgrade.sql
+++ b/doc/upgrade.sql
@@ -59,8 +59,7 @@
update ter_device_monitoring_data_realtime set del_flag = 0;
update ter_device_monitoring_data set del_flag = 0;
---未更新 0603
-
+--已更新 0603
ALTER TABLE `newfiber_standard_termite`.`ter_device_info`
ADD COLUMN `software` varchar(255) DEFAULT NULL COMMENT '软件版本' AFTER `first_warn_datetime`,
ADD COLUMN `hardware` varchar(255) DEFAULT NULL COMMENT '硬件版本' AFTER `software`,
diff --git a/newfiber-termites/newfiber-termites-dataup/pom.xml b/newfiber-termites/newfiber-termites-dataup/pom.xml
index 71b64a0..f2722fb 100644
--- a/newfiber-termites/newfiber-termites-dataup/pom.xml
+++ b/newfiber-termites/newfiber-termites-dataup/pom.xml
@@ -28,6 +28,12 @@
spring-integration-mqtt
+
+ com.qcloud
+ cos_api
+ 5.6.213
+
+
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
index 0dadc84..638a9ac 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java
@@ -31,4 +31,10 @@
@ApiModelProperty(value = "摄像头")
private String camera;
+ /**
+ *
+ */
+ @ApiModelProperty(value = "", hidden = true)
+ private Date lastPicTime;
+
}
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
index 3a50b96..2891a87 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java
@@ -59,6 +59,8 @@
set(StringUtils.isNotBlank(termiteDateUpRequest.getRssi()), "rssi", termiteDateUpRequest.getRssi()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getAP()), "ap", termiteDateUpRequest.getAP()).
set(StringUtils.isNotBlank(termiteDateUpRequest.getCamera()), "camera", termiteDateUpRequest.getCamera()).
+ set(null != termiteDateUpRequest.getLastPicTime(), "last_pic_time", termiteDateUpRequest.getLastPicTime()).
+ set("sync_state", EDeviceSyncState.success.getCode()).
eq("sn", termiteDateUpRequest.getSn());
update(updateWrapper);
return true;
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
index 6d1bcff..ab25c36 100644
--- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java
@@ -10,8 +10,17 @@
import com.newfiber.termite.domain.DeviceMonitoringDataRealtime;
import com.newfiber.termite.domain.OneByOneNow;
import com.newfiber.termite.domain.Termite;
-import com.newfiber.termite.domain.dto.*;
-import com.newfiber.termite.domain.request.*;
+import com.newfiber.termite.domain.dto.AlarmDataDto;
+import com.newfiber.termite.domain.dto.DeviceInfoDto;
+import com.newfiber.termite.domain.dto.PhotoIdentifyDto;
+import com.newfiber.termite.domain.dto.SnAlarmStatisticDto;
+import com.newfiber.termite.domain.dto.TermiteDataUpRequest;
+import com.newfiber.termite.domain.dto.UnitInfoDto;
+import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest;
+import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoQueryRequest;
+import com.newfiber.termite.domain.request.TermiteInfoSaveRequest;
+import com.newfiber.termite.domain.request.TermiteInfoUpdateyRequest;
import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest;
import com.newfiber.termite.domain.request.deviceMonitoringData.DeviceMonitoringDataQueryRequest;
import com.newfiber.termite.domain.response.DataUpResponse;
@@ -24,6 +33,7 @@
import com.newfiber.termite.enums.EIdentColle;
import com.newfiber.termite.mapper.TermiteMapper;
import com.newfiber.termite.service.ITermiteService;
+import com.newfiber.termite.util.CosUtil;
import com.newfiber.termite.util.FileUploadUtils;
import com.newfiber.termite.util.MinioConfig;
import io.minio.MinioClient;
@@ -37,6 +47,11 @@
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
@@ -47,12 +62,6 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
@Slf4j
@Service
public class TermiteServiceImpl extends BaseServiceImpl implements ITermiteService {
@@ -83,7 +92,7 @@
public DataUpResponse termiteDataup(TermiteDataUpRequest termiteDateUpRequest, MultipartFile image) throws Exception{
String date = DateUtil.formatDateTime(new Date());
log.info("站点{}在{}时刻上传数据", termiteDateUpRequest.getSn(), date);
- String url = uploadFile(image);
+ String url = CosUtil.putFile(image);
// 保存历史数据
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
@@ -106,6 +115,7 @@
DeviceMonitoringData lastHeatingDeviceMonitoringData = deviceMonitoringDataService.lastHeating(termiteDateUpRequest.getSn());
// 更新设备状态
+ termiteDateUpRequest.setLastPicTime(new Date());
deviceInfoService.update(termiteDateUpRequest);
return new DataUpResponse(url, lastDrugingDeviceMonitoringData, lastHeatingDeviceMonitoringData);
@@ -116,7 +126,7 @@
DeviceMonitoringData existedDeviceMonitoringData = deviceMonitoringDataService.getById(dataDto.getId());
log.info("站点{}在{}时刻更新识别结果", existedDeviceMonitoringData.getSn(), DateUtil.formatDateTime(new Date()));
- String url = uploadFile(image);
+ String url = CosUtil.putFile(image);
DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData();
deviceMonitoringData.setId(Long.parseLong(dataDto.getId()));
diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/util/CosUtil.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/util/CosUtil.java
new file mode 100644
index 0000000..122241a
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/util/CosUtil.java
@@ -0,0 +1,104 @@
+package com.newfiber.termite.util;
+
+import cn.hutool.core.date.DateUtil;
+import com.qcloud.cos.COSClient;
+import com.qcloud.cos.ClientConfig;
+import com.qcloud.cos.auth.BasicCOSCredentials;
+import com.qcloud.cos.auth.COSCredentials;
+import com.qcloud.cos.exception.CosClientException;
+import com.qcloud.cos.exception.CosServiceException;
+import com.qcloud.cos.model.ObjectMetadata;
+import com.qcloud.cos.model.PutObjectRequest;
+import com.qcloud.cos.model.PutObjectResult;
+import com.qcloud.cos.region.Region;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+public class CosUtil {
+ private static String secretId = "AKIDoOp3B8JLacTElCnM5bbxHOGuHsGOd5NB";
+ private static String secretKey = "lK8xY6MAkm8F6kQr1xkHYJp9EgtpVv87";
+ private static String bucketName = "termite-1255570142";
+ private static String region = "ap-nanjing";
+ private static COSClient cosClient = createCli();;
+ private static String url = "https://termite-1255570142.cos.ap-nanjing.myqcloud.com/";
+
+ private static COSClient createCli() {
+ // 初始化用户身份信息(secretId, secretKey)
+ COSCredentials cred = new BasicCOSCredentials(secretId,secretKey);
+ // 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
+ ClientConfig clientConfig = new ClientConfig(new Region(region));
+ // 生成cos客户端
+ return new COSClient(cred, clientConfig);
+ }
+
+ public static String putFile(MultipartFile file){
+
+ try {
+ Date date = new Date();
+ String fileName = file.getOriginalFilename();
+ fileName = DateUtil.year(date) + "/" + (DateUtil.month(date) + 1) + "/" + DateUtil.dayOfMonth(date) + "/" + fileName;
+ InputStream inputStream = file.getInputStream();
+ ObjectMetadata objectMetadata = new ObjectMetadata();
+
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, fileName, inputStream, objectMetadata);
+ // 设置单链接限速(如有需要),不需要可忽略
+ putObjectRequest.setTrafficLimit(8*1024*1024);
+ PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
+// System.out.println(putObjectResult.getRequestId());
+ return url + fileName;
+ } catch (CosServiceException e) {
+ e.printStackTrace();
+ } catch (CosClientException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return "";
+ }
+
+ private static void putLocalFileDemo() {
+ String key = "abc/abc.txt";
+ String localPath = "abc.txt";
+
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, new File(localPath));
+ try {
+ PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
+ System.out.println(putObjectResult.getRequestId());
+ } catch (CosServiceException cse) {
+ cse.printStackTrace();
+ } catch (CosClientException cce) {
+ cce.printStackTrace();
+ }
+ }
+
+ private static void putInputStreamDemo() {
+ String key = "abc/def.txt";
+ // 这里创建一个 ByteArrayInputStream 来作为示例,实际中这里应该是您要上传的 InputStream 类型的流
+ int inputStreamLength = 1024 * 1024;
+ byte data[] = new byte[inputStreamLength];
+ InputStream inputStream = new ByteArrayInputStream(data);
+
+ ObjectMetadata objectMetadata = new ObjectMetadata();
+ // 上传的流如果能够获取准确的流长度,则推荐一定填写 content-length
+ // 如果确实没办法获取到,则下面这行可以省略,但同时高级接口也没办法使用分块上传了
+ objectMetadata.setContentLength(inputStreamLength);
+
+ PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, inputStream, objectMetadata);
+ // 设置单链接限速(如有需要),不需要可忽略
+ putObjectRequest.setTrafficLimit(8*1024*1024);
+ try {
+ PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
+ System.out.println(putObjectResult.getRequestId());
+ } catch (CosServiceException e) {
+ e.printStackTrace();
+ } catch (CosClientException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/newfiber-termites/newfiber-termites-package/src/test/java/CommonTest.java b/newfiber-termites/newfiber-termites-package/src/test/java/CommonTest.java
new file mode 100644
index 0000000..5791e51
--- /dev/null
+++ b/newfiber-termites/newfiber-termites-package/src/test/java/CommonTest.java
@@ -0,0 +1,14 @@
+import com.newfiber.common.core.utils.file.FileUtils;
+import com.newfiber.termite.util.CosUtil;
+import java.io.File;
+import org.junit.Test;
+import org.springframework.web.multipart.MultipartFile;
+
+public class CommonTest {
+
+ @Test
+ public void fileUploadTest(){
+ MultipartFile file = FileUtils.getMultipartFile(new File("C:\\Users\\Administrator\\Pictures\\201210133348076.jpg"));
+ System.out.println(CosUtil.putFile(file));
+ }
+}