Browse Source

定时删除非在读学生的人脸信息

dzx 3 tháng trước cách đây
mục cha
commit
7abbcb394c

+ 5 - 0
src/main/java/com/xjrsoft/module/job/StudentDropOutTask.java

@@ -8,6 +8,7 @@ import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
 import com.xjrsoft.module.personnel.entity.StundentFaceProcess;
+import com.xjrsoft.module.personnel.service.IFaceManagementService;
 import com.xjrsoft.module.personnel.service.IStundentFaceProcessService;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import lombok.extern.slf4j.Slf4j;
@@ -28,6 +29,9 @@ public class StudentDropOutTask {
     @Autowired
     private IStundentFaceProcessService stundentFaceProcessService;
 
+    @Autowired
+    private IFaceManagementService faceManagementService;
+
     @Scheduled(cron = "0 */30 * * * ?")
     public void execute() {
         String active = SpringUtil.getActiveProfile();
@@ -71,6 +75,7 @@ public class StudentDropOutTask {
                 JsonObject resultJson = parser.parse(doPost).getAsJsonObject();
                 if(resultJson.get("code").getAsInt() == 0){
                     stundentFaceProcessService.removeById(user);
+                    faceManagementService.clearRegisterBase64ByUserId(user.getUserId());
                 }
             }
 

+ 2 - 0
src/main/java/com/xjrsoft/module/personnel/service/IFaceManagementService.java

@@ -29,4 +29,6 @@ public interface IFaceManagementService extends MPJBaseService<FaceManagement> {
      * @return
      */
     Boolean delete(List<Long> ids);
+
+    Boolean clearRegisterBase64ByUserId(Long userId);
 }

+ 17 - 0
src/main/java/com/xjrsoft/module/personnel/service/impl/FaceManagementServiceImpl.java

@@ -3,6 +3,7 @@ package com.xjrsoft.module.personnel.service.impl;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.xjrsoft.common.exception.MyException;
@@ -102,4 +103,20 @@ public class FaceManagementServiceImpl extends MPJBaseServiceImpl<FaceManagement
 
         return true;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean clearRegisterBase64ByUserId(Long userId) {
+        LambdaQueryWrapper<FaceManagement> queryWrapper = new LambdaQueryWrapper<FaceManagement>().in(FaceManagement::getUserId, userId);
+        List<FaceManagement> oldCars = faceManagementMapper.selectList(queryWrapper);
+        for (FaceManagement item : oldCars) {
+            UpdateWrapper<FaceManagement> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.eq("id", item.getId());
+            updateWrapper.setSql("register_base64 = null");
+            updateWrapper.setSql("delete_mark = 1");
+            this.baseMapper.update(item, updateWrapper);
+        }
+
+        return true;
+    }
 }