Quellcode durchsuchen

人员无照片上传

M墨鱼—_mo vor 5 Jahren
Ursprung
Commit
4d26352cb9

+ 17 - 9
common/src/main/java/com/jpsoft/smart/modules/lapi/service/impl/LapiServiceImpl.java

@@ -230,10 +230,23 @@ public class LapiServiceImpl implements ILapiService {
                 map3.put("FaceID", personInfo.getId());
                 map3.put("Name", personInfo.getId() + ".jpg");
 
-                //照片base64长度
-                Integer imageSize = base64Data.length();
-                map3.put("Size", imageSize);
-                map3.put("Data", base64Data);
+                if (StringUtils.isNotBlank(base64Data)){
+                    //照片base64长度
+                    Integer imageSize = base64Data.length();
+                    map3.put("Size", imageSize);
+                    map3.put("Data", base64Data);
+                    //照片字节大小
+                    Integer fileSize = imageSize - (imageSize / 8) * 2;
+
+                    if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
+                        throw new Exception("人员照片大小限定为10k~512k");
+                    }
+                }
+                else {
+                    map3.put("Size", "");
+                    map3.put("Data", "");
+                }
+
                 List listMap3 = new ArrayList();
                 listMap3.add(map3);
                 map1.put("ImageList", listMap3);
@@ -241,12 +254,7 @@ public class LapiServiceImpl implements ILapiService {
                 listMap1.add(map1);
                 map.put("PersonInfoList", listMap1);
 
-                //照片字节大小
-                Integer fileSize = imageSize - (imageSize / 8) * 2;
 
-                if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
-                    throw new Exception("人员照片大小限定为10k~512k");
-                }
                 //获取人员人脸库id
                 String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());