Sfoglia il codice sorgente

设备没有图片传递时不保存图片

Administrator 5 anni fa
parent
commit
13997afefd

+ 11 - 8
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -75,20 +75,23 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         String retFileUrl = "";
         try {
 
-            BASE64Decoder decoder = new BASE64Decoder();
+            if (StringUtils.isNotBlank(faceImageJson.getStr("Data"))){
+                BASE64Decoder decoder = new BASE64Decoder();
 
-            byte[] imgData = decoder.decodeBuffer(faceImageJson.getStr("Data"));
+                byte[] imgData = decoder.decodeBuffer(faceImageJson.getStr("Data"));
 
-            for (int i = 0; i < imgData.length; ++i) {
-                if (imgData[i] < 0) {// 调整异常数据
-                    imgData[i] += 256;
+                for (int i = 0; i < imgData.length; ++i) {
+                    if (imgData[i] < 0) {// 调整异常数据
+                        imgData[i] += 256;
+                    }
                 }
-            }
 
-            ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
+                ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
 
 
-            retFileUrl = OSSUtil.upload(ossConfig, "/devicePersonLog", faceImageJson.getStr("Name"), inputStream);
+                retFileUrl = OSSUtil.upload(ossConfig, "/devicePersonLog", faceImageJson.getStr("Name"), inputStream);
+            }
+
         } catch (Exception e) {
             log.error("保存图片路径错误" + e.getMessage());
         }