Przeglądaj źródła

Merge branch 'master' of http://124.70.58.209:3000/ytrd-project-management/GeoHazardMonitor

gao.qiang 6 miesięcy temu
rodzic
commit
f0c1b02c55

+ 18 - 2
business-service/src/main/java/com/ozs/service/service/impl/CameraCaptureService.java

@@ -1,8 +1,11 @@
 package com.ozs.service.service.impl;
 
 import com.ozs.common.utils.MinioUtils;
+import com.ozs.common.utils.uuid.IdUtils;
+import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -63,9 +66,22 @@ public class CameraCaptureService {
                     byteArrayOutputStream.write(bytes,0,index);
                 }
                 ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-                log.info("getCapture======" + fileName);
+                String uploadUrl = "/data/test_picture/"+ IdUtils.fastSimpleUUID()+".jpeg";
+                if (log.isDebugEnabled()) {
+                    log.debug("生成至服务器本地开始,路径为======" + uploadUrl);
+                }
+                IOUtils.copy(byteArrayInputStream, new FileOutputStream(uploadUrl));
+                if (log.isDebugEnabled()) {
+                    log.debug("生成至服务器本地结束,路径为======");
+                }
+                byteArrayInputStream.reset();
+                if (log.isDebugEnabled()) {
+                    log.debug("getCapture======" + fileName);
+                }
                 minioUtils.minIoClientUpload(byteArrayInputStream, fileName);
-                System.out.println("fileName"+fileName+"图片结束截图时间"+new Date());
+                if (log.isDebugEnabled()) {
+                    log.debug("fileName:"+fileName+"图片结束截图时间:"+new Date());
+                }
             }
         } catch (Exception e) {
             //先关闭外层的缓冲流,再关闭内层的流,但是在关闭外层流的同时,