|
@@ -1,50 +0,0 @@
|
|
-package com.iden.bms.schedule;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-import com.iden.bms.service.FaceIdenService;
|
|
|
|
-import com.iden.common.cache.RedisKeyConstant;
|
|
|
|
-import com.iden.common.cache.RedisUtil;
|
|
|
|
-import org.springframework.context.annotation.Configuration;
|
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
-import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
|
-import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
-
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-import java.util.UUID;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 定时读取目录下图片,调用人脸识别引擎,把特征码入库
|
|
|
|
- */
|
|
|
|
-@Configuration
|
|
|
|
-@EnableScheduling
|
|
|
|
-@EnableAsync
|
|
|
|
-public class FaceIdenSchedule {
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private FaceIdenService faceIdenService;
|
|
|
|
- @Resource
|
|
|
|
- private RedisUtil redisUtil;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 处理摄像头上传的图像
|
|
|
|
- */
|
|
|
|
- @Async
|
|
|
|
- @Scheduled(cron = "0 0/5 * * * ?")
|
|
|
|
- public void handleCameraImage() {
|
|
|
|
- String key = RedisKeyConstant.HANDLE_CAMERA_IMAGE;
|
|
|
|
- String requestId = UUID.randomUUID().toString();
|
|
|
|
- boolean result = redisUtil.tryLock(key,requestId,10 * 60);
|
|
|
|
- try {
|
|
|
|
- if (result) {
|
|
|
|
- faceIdenService.handleCameraImage();
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.getMessage();
|
|
|
|
- } finally {
|
|
|
|
- redisUtil.releaseLock(key,requestId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-}
|
|
|