浏览代码

优化识别

suntianwu 3 年之前
父节点
当前提交
0488c29ef4

+ 33 - 20
src/main/java/com/iden/bms/service/WarningService.java

@@ -194,8 +194,8 @@ public class WarningService {
     public void handleDayWarning() throws BDException {
     public void handleDayWarning() throws BDException {
         int staBeforeDayNums = Integer.parseInt(staBeforeDays);
         int staBeforeDayNums = Integer.parseInt(staBeforeDays);
 
 
-        handleResident();//常住人员识别预警
         handleStranger();//陌生人员识别预警
         handleStranger();//陌生人员识别预警
+        handleResident();//常住人员识别预警
         handleEveningComming();//昼伏夜出人员识别预警
         handleEveningComming();//昼伏夜出人员识别预警
 
 
         staCommunity(staBeforeDayNums);//按小区统n天前的数据
         staCommunity(staBeforeDayNums);//按小区统n天前的数据
@@ -203,13 +203,6 @@ public class WarningService {
 
 
     //陌生人员识别预警
     //陌生人员识别预警
     private void handleStranger() {
     private void handleStranger() {
-        //先看今天是否运行过程序,若运行过,则返回
-        String strangerDate = (String)redisUtil.hget(RedisKeyConstant.HANDLE_WARNING_DATE,"stranger");
-        if(StringUtils.isNotEmpty(strangerDate) && strangerDate.equals(DateUtils.getCurrYyyyMMddDate())) {
-            return;
-        }
-        redisUtil.hset(RedisKeyConstant.HANDLE_WARNING_DATE,"stranger",DateUtils.getCurrYyyyMMddDate());
-
         List<IdenCommunity>  idenCommunityList = this.idenCommunityService.list();
         List<IdenCommunity>  idenCommunityList = this.idenCommunityService.list();
         if(CollUtil.isEmpty(idenCommunityList)){
         if(CollUtil.isEmpty(idenCommunityList)){
             return;
             return;
@@ -272,6 +265,13 @@ public class WarningService {
                     IdenWarningPerson idenWarningPerson = this.idenWarningPersonService.getOne(queryWrapper0);
                     IdenWarningPerson idenWarningPerson = this.idenWarningPersonService.getOne(queryWrapper0);
 
 
                     if (idenWarningPerson != null) {
                     if (idenWarningPerson != null) {
+                        //判断今天数据是不是处理过了
+                        String today = DateUtils.getCurrYyyyMMddDate();
+                        String modifyTime = DateUtils.formatToDateStr(idenWarningPerson.getModifyTime(),"yyyyMMdd");
+                        if(today.equals(modifyTime)) {
+                            continue;
+                        }
+
                         idenWarningPerson.setAppearFrequency(strangerDayFrequency);
                         idenWarningPerson.setAppearFrequency(strangerDayFrequency);
                         idenWarningPerson.setStrangerType(strangerType);
                         idenWarningPerson.setStrangerType(strangerType);
                         idenWarningPerson.setHandleStatus(HandleWarningStatusEnum.NO_HANDLE.getValue());
                         idenWarningPerson.setHandleStatus(HandleWarningStatusEnum.NO_HANDLE.getValue());
@@ -307,6 +307,7 @@ public class WarningService {
                         }
                         }
 
 
                         idenWarningPerson.setCreateTime(new Date());
                         idenWarningPerson.setCreateTime(new Date());
+                        idenWarningPerson.setModifyTime(new Date());
                         this.idenWarningPersonService.save(idenWarningPerson);
                         this.idenWarningPersonService.save(idenWarningPerson);
 
 
                     }
                     }
@@ -314,6 +315,7 @@ public class WarningService {
                     IdenWarningPersonHis idenWarningPersonHis = new IdenWarningPersonHis();
                     IdenWarningPersonHis idenWarningPersonHis = new IdenWarningPersonHis();
                     BeanUtil.copyProperties(idenWarningPerson,idenWarningPersonHis,"id");
                     BeanUtil.copyProperties(idenWarningPerson,idenWarningPersonHis,"id");
                     idenWarningPersonHis.setCreateTime(new Date());
                     idenWarningPersonHis.setCreateTime(new Date());
+                    idenWarningPersonHis.setModifyTime(new Date());
                     idenWarningPersonHisService.save(idenWarningPersonHis);
                     idenWarningPersonHisService.save(idenWarningPersonHis);
 
 
                     IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
                     IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
@@ -340,6 +342,7 @@ public class WarningService {
                     idenWarningEvent.setSubdistrict(idenWarningPerson.getSubdistrict());
                     idenWarningEvent.setSubdistrict(idenWarningPerson.getSubdistrict());
                     idenWarningEvent.setType(WarningTypeEnum.STRANGER.getValue());
                     idenWarningEvent.setType(WarningTypeEnum.STRANGER.getValue());
                     idenWarningEvent.setCreateTime(new Date());
                     idenWarningEvent.setCreateTime(new Date());
+                    idenWarningEvent.setModifyTime(new Date());
                     this.idenWarningEventService.save(idenWarningEvent);
                     this.idenWarningEventService.save(idenWarningEvent);
                 }
                 }
 
 
@@ -352,12 +355,6 @@ public class WarningService {
 
 
     //常住人员识别预警,小区人脸库内7天内未被命中人员或标记为独居老人或老人带小孩的7天内未被命中人员视为预警对象
     //常住人员识别预警,小区人脸库内7天内未被命中人员或标记为独居老人或老人带小孩的7天内未被命中人员视为预警对象
     private void handleResident() {
     private void handleResident() {
-        //先看今天是否运行过程序,若运行过,则返回
-        String residentDate = (String)redisUtil.hget(RedisKeyConstant.HANDLE_WARNING_DATE,"resident");
-        if(StringUtils.isNotEmpty(residentDate) && residentDate.equals(DateUtils.getCurrYyyyMMddDate())) {
-            return;
-        }
-        redisUtil.hset(RedisKeyConstant.HANDLE_WARNING_DATE,"resident",DateUtils.getCurrYyyyMMddDate());
 
 
         //查询全部小区人员
         //查询全部小区人员
         QueryWrapper<IdenPerson> queryWrapper = new QueryWrapper<>();
         QueryWrapper<IdenPerson> queryWrapper = new QueryWrapper<>();
@@ -397,7 +394,15 @@ public class WarningService {
                         .eq(IdenWarningPerson::getUid,idenPerson.getUid())
                         .eq(IdenWarningPerson::getUid,idenPerson.getUid())
                         .eq(IdenWarningPerson::getType,WarningTypeEnum.RESIDENT.getValue());
                         .eq(IdenWarningPerson::getType,WarningTypeEnum.RESIDENT.getValue());
                 IdenWarningPerson idenWarningPerson = this.idenWarningPersonService.getOne(queryWrapper0);
                 IdenWarningPerson idenWarningPerson = this.idenWarningPersonService.getOne(queryWrapper0);
+
                 if (idenWarningPerson != null) {
                 if (idenWarningPerson != null) {
+                    //判断今天数据是不是处理过了
+                    String today = DateUtils.getCurrYyyyMMddDate();
+                    String modifyTime = DateUtils.formatToDateStr(idenWarningPerson.getModifyTime(),"yyyyMMdd");
+                    if(today.equals(modifyTime)) {
+                        continue;
+                    }
+
                     idenWarningPerson.setContinueDisappearDays(continueDisappearDays);
                     idenWarningPerson.setContinueDisappearDays(continueDisappearDays);
                     idenWarningPerson.setModifyTime(new Date());
                     idenWarningPerson.setModifyTime(new Date());
                     idenWarningPerson.setHandleStatus(HandleWarningStatusEnum.NO_HANDLE.getValue());
                     idenWarningPerson.setHandleStatus(HandleWarningStatusEnum.NO_HANDLE.getValue());
@@ -427,12 +432,14 @@ public class WarningService {
 
 
                     idenWarningPerson.setType(WarningTypeEnum.RESIDENT.getValue());
                     idenWarningPerson.setType(WarningTypeEnum.RESIDENT.getValue());
                     idenWarningPerson.setCreateTime(new Date());
                     idenWarningPerson.setCreateTime(new Date());
+                    idenWarningPerson.setModifyTime(new Date());
                     this.idenWarningPersonService.save(idenWarningPerson);
                     this.idenWarningPersonService.save(idenWarningPerson);
                 }
                 }
 
 
                 IdenWarningPersonHis idenWarningPersonHis = new IdenWarningPersonHis();
                 IdenWarningPersonHis idenWarningPersonHis = new IdenWarningPersonHis();
                 BeanUtil.copyProperties(idenWarningPerson,idenWarningPersonHis,"id");
                 BeanUtil.copyProperties(idenWarningPerson,idenWarningPersonHis,"id");
                 idenWarningPersonHis.setCreateTime(new Date());
                 idenWarningPersonHis.setCreateTime(new Date());
+                idenWarningPersonHis.setModifyTime(new Date());
                 idenWarningPersonHisService.save(idenWarningPersonHis);
                 idenWarningPersonHisService.save(idenWarningPersonHis);
 
 
                 IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
                 IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
@@ -449,7 +456,9 @@ public class WarningService {
                 idenWarningEvent.setSubdistrict(idenWarningPerson.getSubdistrict());
                 idenWarningEvent.setSubdistrict(idenWarningPerson.getSubdistrict());
                 idenWarningEvent.setAppearTime(idenWarningPerson.getLatestAppearTime());
                 idenWarningEvent.setAppearTime(idenWarningPerson.getLatestAppearTime());
                 idenWarningEvent.setType(WarningTypeEnum.RESIDENT.getValue());
                 idenWarningEvent.setType(WarningTypeEnum.RESIDENT.getValue());
+
                 idenWarningEvent.setCreateTime(new Date());
                 idenWarningEvent.setCreateTime(new Date());
+                idenWarningEvent.setModifyTime(new Date());
                 this.idenWarningEventService.save(idenWarningEvent);
                 this.idenWarningEventService.save(idenWarningEvent);
             }
             }
         }
         }
@@ -458,12 +467,6 @@ public class WarningService {
 
 
     //昼伏夜出人员识别预警
     //昼伏夜出人员识别预警
     private void handleEveningComming() {
     private void handleEveningComming() {
-        //先看今天是否运行过程序,若运行过,则返回
-        String eveningCommingDate = (String)redisUtil.hget(RedisKeyConstant.HANDLE_WARNING_DATE,"eveningComming");
-        if(StringUtils.isNotEmpty(eveningCommingDate) && eveningCommingDate.equals(DateUtils.getCurrYyyyMMddDate())) {
-            return;
-        }
-        redisUtil.hset(RedisKeyConstant.HANDLE_WARNING_DATE,"eveningComming",DateUtils.getCurrYyyyMMddDate());
 
 
         List<IdenCommunity>  idenCommunityList = this.idenCommunityService.list();
         List<IdenCommunity>  idenCommunityList = this.idenCommunityService.list();
         if(CollUtil.isEmpty(idenCommunityList)){
         if(CollUtil.isEmpty(idenCommunityList)){
@@ -569,6 +572,13 @@ public class WarningService {
                     .eq(IdenWarningPerson::getType,WarningTypeEnum.EVENING_COMMING.getValue());
                     .eq(IdenWarningPerson::getType,WarningTypeEnum.EVENING_COMMING.getValue());
             IdenWarningPerson idenWarningPerson = this.idenWarningPersonService.getOne(queryWrapper0);
             IdenWarningPerson idenWarningPerson = this.idenWarningPersonService.getOne(queryWrapper0);
             if (idenWarningPerson != null) {
             if (idenWarningPerson != null) {
+                //判断今天数据是不是处理过了
+                String today = DateUtils.getCurrYyyyMMddDate();
+                String modifyTime = DateUtils.formatToDateStr(idenWarningPerson.getModifyTime(),"yyyyMMdd");
+                if(today.equals(modifyTime)) {
+                    return;
+                }
+
                 idenWarningPerson.setAppearFrequency(count);
                 idenWarningPerson.setAppearFrequency(count);
                 idenWarningPerson.setHandleStatus(HandleWarningStatusEnum.NO_HANDLE.getValue());
                 idenWarningPerson.setHandleStatus(HandleWarningStatusEnum.NO_HANDLE.getValue());
                 idenWarningPerson.setModifyTime(new Date());
                 idenWarningPerson.setModifyTime(new Date());
@@ -609,12 +619,14 @@ public class WarningService {
 
 
                 idenWarningPerson.setType(WarningTypeEnum.EVENING_COMMING.getValue());
                 idenWarningPerson.setType(WarningTypeEnum.EVENING_COMMING.getValue());
                 idenWarningPerson.setCreateTime(new Date());
                 idenWarningPerson.setCreateTime(new Date());
+                idenWarningPerson.setModifyTime(new Date());
                 this.idenWarningPersonService.save(idenWarningPerson);
                 this.idenWarningPersonService.save(idenWarningPerson);
 
 
             }
             }
             IdenWarningPersonHis idenWarningPersonHis = new IdenWarningPersonHis();
             IdenWarningPersonHis idenWarningPersonHis = new IdenWarningPersonHis();
             BeanUtil.copyProperties(idenWarningPerson,idenWarningPersonHis,"id");
             BeanUtil.copyProperties(idenWarningPerson,idenWarningPersonHis,"id");
             idenWarningPersonHis.setCreateTime(new Date());
             idenWarningPersonHis.setCreateTime(new Date());
+            idenWarningPersonHis.setModifyTime(new Date());
             idenWarningPersonHisService.save(idenWarningPersonHis);
             idenWarningPersonHisService.save(idenWarningPersonHis);
 
 
             IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
             IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
@@ -639,6 +651,7 @@ public class WarningService {
             idenWarningEvent.setAppearTime(idenFaceImage.getPhotographTime());
             idenWarningEvent.setAppearTime(idenFaceImage.getPhotographTime());
             idenWarningEvent.setType(WarningTypeEnum.EVENING_COMMING.getValue());
             idenWarningEvent.setType(WarningTypeEnum.EVENING_COMMING.getValue());
             idenWarningEvent.setCreateTime(new Date());
             idenWarningEvent.setCreateTime(new Date());
+            idenWarningEvent.setModifyTime(new Date());
             this.idenWarningEventService.save(idenWarningEvent);
             this.idenWarningEventService.save(idenWarningEvent);
         }
         }
     }
     }

+ 1 - 3
src/main/java/com/iden/common/cache/RedisKeyConstant.java

@@ -33,7 +33,5 @@ public class RedisKeyConstant {
 
 
     public static final String UID_KEY = "UID_KEY";
     public static final String UID_KEY = "UID_KEY";
 
 
-    //24小时
-    public static final String HANDLE_WARNING_DATE = "HANDLE:WARNING_DATE";
-    public static final int HANDLE_WARNING_DATE_TIME = 3600 * 24;
+
 }
 }

+ 1 - 1
src/main/resources/application-dev.properties

@@ -35,7 +35,7 @@ iden.root=/data/iden/
 file.url=http://124.70.58.209:17778/
 file.url=http://124.70.58.209:17778/
 
 
 ##是否初始化加载人脸识别库,是:1,不:0
 ##是否初始化加载人脸识别库,是:1,不:0
-init.face.dataset=0
+init.face.dataset=1
 
 
 #视频编辑程序所在路径
 #视频编辑程序所在路径
 ffmpeg.path=/data/iden/ffmpeg/ffmpeg-git-20211217-amd64-static/ffmpeg
 ffmpeg.path=/data/iden/ffmpeg/ffmpeg-git-20211217-amd64-static/ffmpeg