Bläddra i källkod

删除人脸数据逻辑修改

M墨鱼—_mo 5 år sedan
förälder
incheckning
6e9c370c9d

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonInfoDAO.java

@@ -19,4 +19,6 @@ public interface PersonInfoDAO {
 	PersonInfo findByOpenId(String openId);
     List<PersonInfo> findByCompanyId(String companyId);
     long countByCompanyCode(String code,Long personId);
+
+	PersonInfo getIgnoreDelFlag(Long id);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonInfoService.java

@@ -21,4 +21,6 @@ public interface PersonInfoService {
     List<PersonInfo> findByCompanyId(String companyId);
 
     long countByCompanyCode(String code,Long personId);
+
+	PersonInfo getIgnoreDelFlag(Long id);
 }

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

@@ -29,14 +29,14 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	public int insert(PersonInfo model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return personInfoDAO.insert(model);
 	}
 
 	@Override
 	public int update(PersonInfo model) {
 		// TODO Auto-generated method stub
-		return personInfoDAO.update(model);		
+		return personInfoDAO.update(model);
 	}
 
 	@Override
@@ -49,22 +49,22 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	public boolean exist(Long id) {
 		// TODO Auto-generated method stub
 		int count = personInfoDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<PersonInfo> list() {
 		// TODO Auto-generated method stub
 		return personInfoDAO.list();
 	}
-		
+
 	@Override
 	public Page<PersonInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<PersonInfo> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             personInfoDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
 
@@ -87,4 +87,9 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	public long countByCompanyCode(String code,Long personId) {
 		return personInfoDAO.countByCompanyCode(code,personId);
 	}
+
+	@Override
+	public PersonInfo getIgnoreDelFlag(Long id) {
+		return personInfoDAO.getIgnoreDelFlag(id);
+	}
 }

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

@@ -120,7 +120,9 @@ public class LapiServiceImpl implements ILapiService {
             map3.put("FaceID", personInfo.getId());
             map3.put("Name", personInfo.getId() + ".jpg");
 
-            map3.put("Size", base64Data.length());
+            //照片base64长度
+            Integer imageSize = base64Data.length();
+            map3.put("Size", imageSize);
             map3.put("Data", base64Data);
             List listMap3 = new ArrayList();
             listMap3.add(map3);
@@ -130,7 +132,9 @@ public class LapiServiceImpl implements ILapiService {
             map.put("PersonInfoList", listMap1);
 
             try {
-                if (base64Data.length() > 512 * 1024 || base64Data.length() < 10 * 1024) {
+                //照片字节大小
+                Integer fileSize = imageSize - (imageSize/8)*2;
+                if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
                     throw new Exception("人员照片大小限定为10k~512k");
                 }
                 //获取人员人脸库id
@@ -207,7 +211,9 @@ public class LapiServiceImpl implements ILapiService {
                     map3.put("FaceID", personInfo.getId());
                     map3.put("Name", personInfo.getId() + ".jpg");
 
-                    map3.put("Size", base64Data.length());
+                    //照片base64长度
+                    Integer imageSize = base64Data.length();
+                    map3.put("Size", imageSize);
                     map3.put("Data", base64Data);
                     List listMap3 = new ArrayList();
                     listMap3.add(map3);
@@ -216,7 +222,10 @@ public class LapiServiceImpl implements ILapiService {
                     listMap1.add(map1);
                     map.put("PersonInfoList", listMap1);
 
-                    if (base64Data.length() > 512 * 1024 || base64Data.length() < 10 * 1024) {
+                    //照片字节大小
+                    Integer fileSize = imageSize - (imageSize/8)*2;
+
+                    if (fileSize > 512 * 1024 || fileSize < 10 * 1024) {
                         throw new Exception("人员照片大小限定为10k~512k");
                     }
                     //获取人员人脸库id
@@ -324,7 +333,7 @@ public class LapiServiceImpl implements ILapiService {
     @Override
     public List<LapiMsgResult> deletePerson(Long id) throws Exception {
 
-        PersonInfo personInfo = personInfoService.get(id);
+        PersonInfo personInfo = personInfoService.getIgnoreDelFlag(id);
         if (personInfo == null) {
             throw new Exception("人员不存在");
         }
@@ -384,7 +393,7 @@ public class LapiServiceImpl implements ILapiService {
         if (StringUtils.isBlank(deviceIds)) {
             throw new Exception("相关设备不能为空");
         }
-        PersonInfo personInfo = personInfoService.get(id);
+        PersonInfo personInfo = personInfoService.getIgnoreDelFlag(id);
         if (personInfo == null) {
             throw new Exception("人员信息不存在");
         }

+ 8 - 0
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -270,4 +270,12 @@
             )
         </if>
     </select>
+
+    <select id="getIgnoreDelFlag" parameterType="long" resultMap="PersonInfoMap">
+        select
+        a.*,b.name_ as company_name
+        from base_person_info a
+        left join base_company_info b on a.company_id = b.id_
+        where a.id_=#{0}  limit 1
+    </select>
 </mapper>

+ 10 - 0
web/src/main/java/com/jpsoft/smart/schduled/HeartbeatDetectionTask.java

@@ -2,12 +2,14 @@ package com.jpsoft.smart.schduled;
 
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.base.service.DeviceInfoService;
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.math.BigInteger;
 import java.util.Date;
 import java.util.List;
 
@@ -56,4 +58,12 @@ public class HeartbeatDetectionTask {
 
         }
 
+    public static void main(String[] args) {
+
+    /*    String base64Data = OSSUtil.downloadToBase64("C:\\Users\\Administrator\\Desktop\\异常照片\\3.jpg");*/
+
+
+    //    System.out.println(base64Data.length());
+    }
+
 }

+ 1 - 0
web/src/test/java/com/jpsoft/smart/LApiTest.java

@@ -175,6 +175,7 @@ public class LApiTest {
             List<String> idList = Arrays.asList(ids.split(","));
 
             List<WarningPusher> list = warningPusherDAO.findByIdList(idList);
+
             System.out.println(list);
         } catch (Exception e) {
             e.printStackTrace();