|
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.iden.common.entity.*;
|
|
import com.iden.common.entity.*;
|
|
import com.iden.common.enums.HandleWarningStatusEnum;
|
|
import com.iden.common.enums.HandleWarningStatusEnum;
|
|
|
|
+import com.iden.common.enums.StrangerTypeEnum;
|
|
import com.iden.common.enums.WarningTypeEnum;
|
|
import com.iden.common.enums.WarningTypeEnum;
|
|
import com.iden.common.exception.BDException;
|
|
import com.iden.common.exception.BDException;
|
|
|
|
|
|
@@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -43,11 +45,14 @@ public class WarningService {
|
|
private IdenWarningPersonTraceService idenWarningPersonTraceService;
|
|
private IdenWarningPersonTraceService idenWarningPersonTraceService;
|
|
@Resource
|
|
@Resource
|
|
private IdenWarningStaService idenWarningStaService;
|
|
private IdenWarningStaService idenWarningStaService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IdenWarningRuleStrangerService idenWarningRuleStrangerService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 处理预警
|
|
* 处理预警
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
|
|
+
|
|
public void handleWarning() throws BDException {
|
|
public void handleWarning() throws BDException {
|
|
//查询没有处理过的人脸图像数据
|
|
//查询没有处理过的人脸图像数据
|
|
QueryWrapper<IdenFaceImage> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<IdenFaceImage> queryWrapper = new QueryWrapper<>();
|
|
@@ -61,54 +66,11 @@ public class WarningService {
|
|
for (IdenFaceImage idenFaceImage : idenFaceImageList) {
|
|
for (IdenFaceImage idenFaceImage : idenFaceImageList) {
|
|
|
|
|
|
String type = idenFaceImage.getType();
|
|
String type = idenFaceImage.getType();
|
|
- if (StringUtils.isNotEmpty(type) && type.contains("0")) { //陌生人员
|
|
|
|
-
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(type) && type.contains("0")) {
|
|
|
|
+ handleStranger(idenFaceImage);
|
|
}
|
|
}
|
|
- else if (StringUtils.isNotEmpty(type) && type.contains("1")) { //重点人员
|
|
|
|
- IdenWarningPerson idenWarningPerson = new IdenWarningPerson();
|
|
|
|
- idenWarningPerson.setImage(idenFaceImage.getImage());
|
|
|
|
- idenWarningPerson.setDataDate(DateUtils.strToDate(DateUtils.formatToDateStr(idenFaceImage.getPhotographTime(),"yyyy-MM-dd"),"yyyy-MM-dd"));
|
|
|
|
- Long cameraId = idenFaceImage.getCameraId();
|
|
|
|
- if(cameraId != null) {
|
|
|
|
- IdenCamera idenCamera = this.idenCameraService.getById(cameraId);
|
|
|
|
- idenWarningPerson.setCommunityName(idenCamera.getDistrict());
|
|
|
|
- idenWarningPerson.setSubdistrict(idenCamera.getSubdistrict());
|
|
|
|
- }
|
|
|
|
- Long communityId = idenFaceImage.getCommunityId();
|
|
|
|
- if(communityId != null) {
|
|
|
|
- IdenCommunity idenCommunity = this.idenCommunityService.getById(communityId);
|
|
|
|
- if (idenCommunity != null) {
|
|
|
|
- idenWarningPerson.setCommunityId(communityId);
|
|
|
|
- idenWarningPerson.setCommunityCode(idenCommunity.getCode());
|
|
|
|
- idenWarningPerson.setCommunityName(idenCommunity.getName());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- idenWarningPerson.setAppearFrequency(1);
|
|
|
|
- idenWarningPerson.setEarliestAppearTime(idenFaceImage.getPhotographTime());
|
|
|
|
- idenWarningPerson.setType(WarningTypeEnum.KEYNOTE.getValue());
|
|
|
|
- idenWarningPerson.setPersonId(idenFaceImage.getPersonId());
|
|
|
|
- idenWarningPerson.setCreateTime(idenFaceImage.getCreateTime());
|
|
|
|
- this.idenWarningPersonService.save(idenWarningPerson);
|
|
|
|
-
|
|
|
|
- IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
|
|
|
|
- idenWarningEvent.setWarningPersonId(idenWarningPerson.getId());
|
|
|
|
- idenWarningEvent.setDataTime(idenFaceImage.getPhotographTime());
|
|
|
|
- idenWarningEvent.setImage(idenFaceImage.getImage());
|
|
|
|
- idenWarningEvent.setCommunityId(idenWarningPerson.getCommunityId());
|
|
|
|
- idenWarningEvent.setCommunityCode(idenWarningPerson.getCommunityCode());
|
|
|
|
- idenWarningEvent.setCommunityName(idenWarningPerson.getCommunityName());
|
|
|
|
- idenWarningEvent.setCommunityName(idenWarningPerson.getDistrict());
|
|
|
|
- idenWarningEvent.setSubdistrict(idenWarningPerson.getSubdistrict());
|
|
|
|
- idenWarningEvent.setAppearTime(idenFaceImage.getPhotographTime());
|
|
|
|
- idenWarningEvent.setType(WarningTypeEnum.KEYNOTE.getValue());
|
|
|
|
- idenWarningEvent.setPersonId(idenFaceImage.getPersonId());
|
|
|
|
- idenWarningEvent.setCreateTime(idenFaceImage.getCreateTime());
|
|
|
|
- this.idenWarningEventService.save(idenWarningEvent);
|
|
|
|
-
|
|
|
|
- IdenWarningPersonTrace idenWarningPersonTrace = new IdenWarningPersonTrace();
|
|
|
|
- BeanUtil.copyProperties(idenFaceImage,idenWarningPersonTrace,"id");
|
|
|
|
- idenWarningPersonTrace.setWarningPersonId(idenWarningPerson.getId());
|
|
|
|
- this.idenWarningPersonTraceService.save(idenWarningPersonTrace);
|
|
|
|
|
|
+ else if (StringUtils.isNotEmpty(type) && type.contains("1")) {
|
|
|
|
+ handleKeynote(idenFaceImage);
|
|
}
|
|
}
|
|
else if (StringUtils.isNotEmpty(type) && type.contains("2")) { //小区人员
|
|
else if (StringUtils.isNotEmpty(type) && type.contains("2")) { //小区人员
|
|
|
|
|
|
@@ -116,9 +78,171 @@ public class WarningService {
|
|
else if (StringUtils.isNotEmpty(type) && type.contains("3")) { //昼伏夜出人员
|
|
else if (StringUtils.isNotEmpty(type) && type.contains("3")) { //昼伏夜出人员
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ IdenFaceImage idenFaceImageUpdate = new IdenFaceImage();
|
|
|
|
+ idenFaceImageUpdate.setId(idenFaceImage.getId());
|
|
|
|
+ idenFaceImageUpdate.setHandleWarningStatus(HandleWarningStatusEnum.HANDLED.getValue());
|
|
|
|
+ this.idenFaceImageService.updateById(idenFaceImageUpdate);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //陌生人员
|
|
|
|
+ private void handleStranger(IdenFaceImage idenFaceImage){
|
|
|
|
+
|
|
|
|
+ //查询此人1月出现天次
|
|
|
|
+ QueryWrapper<IdenFaceImage> queryWrapper1 = new QueryWrapper<>();
|
|
|
|
+ queryWrapper1.select("select distinct data_date dataDate ") ;
|
|
|
|
+ queryWrapper1.lambda().eq(IdenFaceImage::getUid,idenFaceImage.getUid())
|
|
|
|
+ .orderByAsc(IdenFaceImage::getDataDate);
|
|
|
|
+ queryWrapper1.apply(" data_date > date_format(DATE_SUB(CURDATE(), INTERVAL 30 DAY),'%Y%m%d')");
|
|
|
|
+ int strangerDayFrequency = this.idenFaceImageService.count(queryWrapper1);
|
|
|
|
+
|
|
|
|
+ //1月内-7天出现情况
|
|
|
|
+ List<IdenFaceImage> listDataDate = this.idenFaceImageService.list(queryWrapper1);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<IdenWarningRuleStranger> queryWrapper3 = new QueryWrapper<>();
|
|
|
|
+ IdenWarningRuleStranger idenWarningRuleStranger = idenWarningRuleStrangerService.getOne(queryWrapper3);
|
|
|
|
+ int strangerFrequency = 15;
|
|
|
|
+ int strangerDays = 7;
|
|
|
|
+ if (idenWarningRuleStranger != null){
|
|
|
|
+ strangerFrequency = idenWarningRuleStranger.getStrangerFrequency();
|
|
|
|
+ strangerDays = idenWarningRuleStranger.getStrangerDays();
|
|
|
|
+ }
|
|
|
|
+ boolean isContinue = getIsContinue(listDataDate,strangerDays);
|
|
|
|
+
|
|
|
|
+ IdenWarningPerson idenWarningPerson = new IdenWarningPerson();
|
|
|
|
+
|
|
|
|
+ //此人1月出现频次少于15次及7内天每天未连续出现,视为陌生人
|
|
|
|
+ if(strangerDayFrequency < strangerFrequency && !isContinue) {
|
|
|
|
+ idenWarningPerson.setStrangerType(StrangerTypeEnum.STRANGER.getValue());
|
|
|
|
+ } else if(strangerDayFrequency >= strangerFrequency || isContinue) {
|
|
|
|
+ idenWarningPerson.setStrangerType(StrangerTypeEnum.NO_REGISTER.getValue());
|
|
|
|
+ } else {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ idenWarningPerson.setDataDate(DateUtils.strToDate(DateUtils.formatToDateStr(idenFaceImage.getPhotographTime(),"yyyy-MM-dd"),"yyyy-MM-dd"));
|
|
|
|
+ idenWarningPerson.setImage(idenFaceImage.getImage());
|
|
|
|
+
|
|
|
|
+ Long cameraId = idenFaceImage.getCameraId();
|
|
|
|
+ if(cameraId != null) {
|
|
|
|
+ IdenCamera idenCamera = this.idenCameraService.getById(cameraId);
|
|
|
|
+ idenWarningPerson.setDistrict(idenCamera.getDistrict());
|
|
|
|
+ idenWarningPerson.setSubdistrict(idenCamera.getSubdistrict());
|
|
|
|
+ }
|
|
|
|
+ Long communityId = idenFaceImage.getCommunityId();
|
|
|
|
+ if(communityId != null) {
|
|
|
|
+ IdenCommunity idenCommunity = this.idenCommunityService.getById(communityId);
|
|
|
|
+ if (idenCommunity != null) {
|
|
|
|
+ idenWarningPerson.setCommunityId(communityId);
|
|
|
|
+ idenWarningPerson.setCommunityCode(idenCommunity.getCode());
|
|
|
|
+ idenWarningPerson.setCommunityName(idenCommunity.getName());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ idenWarningPerson.setAppearFrequency(strangerDayFrequency);
|
|
|
|
+ idenWarningPerson.setEarliestAppearTime(idenFaceImage.getPhotographTime());
|
|
|
|
+ idenWarningPerson.setType(WarningTypeEnum.KEYNOTE.getValue());
|
|
|
|
+ idenWarningPerson.setPersonId(idenFaceImage.getPersonId());
|
|
|
|
+ idenWarningPerson.setCreateTime(idenFaceImage.getCreateTime());
|
|
|
|
+ this.idenWarningPersonService.save(idenWarningPerson);
|
|
|
|
+
|
|
|
|
+ IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
|
|
|
|
+ idenWarningEvent.setWarningPersonId(idenWarningPerson.getId());
|
|
|
|
+ idenWarningEvent.setDataTime(idenFaceImage.getPhotographTime());
|
|
|
|
+ idenWarningEvent.setImage(idenFaceImage.getImage());
|
|
|
|
+ idenWarningEvent.setCommunityId(idenWarningPerson.getCommunityId());
|
|
|
|
+ idenWarningEvent.setCommunityCode(idenWarningPerson.getCommunityCode());
|
|
|
|
+ idenWarningEvent.setCommunityName(idenWarningPerson.getCommunityName());
|
|
|
|
+ idenWarningEvent.setCommunityName(idenWarningPerson.getDistrict());
|
|
|
|
+ idenWarningEvent.setSubdistrict(idenWarningPerson.getSubdistrict());
|
|
|
|
+ idenWarningEvent.setAppearTime(idenFaceImage.getPhotographTime());
|
|
|
|
+ idenWarningEvent.setType(WarningTypeEnum.KEYNOTE.getValue());
|
|
|
|
+ idenWarningEvent.setPersonId(idenFaceImage.getPersonId());
|
|
|
|
+ idenWarningEvent.setCreateTime(idenFaceImage.getCreateTime());
|
|
|
|
+ this.idenWarningEventService.save(idenWarningEvent);
|
|
|
|
+
|
|
|
|
+ IdenWarningPersonTrace idenWarningPersonTrace = new IdenWarningPersonTrace();
|
|
|
|
+ BeanUtil.copyProperties(idenFaceImage,idenWarningPersonTrace,"id");
|
|
|
|
+ idenWarningPersonTrace.setWarningPersonId(idenWarningPerson.getId());
|
|
|
|
+ this.idenWarningPersonTraceService.save(idenWarningPersonTrace);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ //重点人员
|
|
|
|
+ private void handleKeynote(IdenFaceImage idenFaceImage){
|
|
|
|
+
|
|
|
|
+ IdenWarningPerson idenWarningPerson = new IdenWarningPerson();
|
|
|
|
+ idenWarningPerson.setImage(idenFaceImage.getImage());
|
|
|
|
+ idenWarningPerson.setDataDate(DateUtils.strToDate(DateUtils.formatToDateStr(idenFaceImage.getPhotographTime(),"yyyy-MM-dd"),"yyyy-MM-dd"));
|
|
|
|
+ Long cameraId = idenFaceImage.getCameraId();
|
|
|
|
+ if(cameraId != null) {
|
|
|
|
+ IdenCamera idenCamera = this.idenCameraService.getById(cameraId);
|
|
|
|
+ idenWarningPerson.setDistrict(idenCamera.getDistrict());
|
|
|
|
+ idenWarningPerson.setSubdistrict(idenCamera.getSubdistrict());
|
|
|
|
+ }
|
|
|
|
+ Long communityId = idenFaceImage.getCommunityId();
|
|
|
|
+ if(communityId != null) {
|
|
|
|
+ IdenCommunity idenCommunity = this.idenCommunityService.getById(communityId);
|
|
|
|
+ if (idenCommunity != null) {
|
|
|
|
+ idenWarningPerson.setCommunityId(communityId);
|
|
|
|
+ idenWarningPerson.setCommunityCode(idenCommunity.getCode());
|
|
|
|
+ idenWarningPerson.setCommunityName(idenCommunity.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ idenWarningPerson.setAppearFrequency(1);
|
|
|
|
+ idenWarningPerson.setEarliestAppearTime(idenFaceImage.getPhotographTime());
|
|
|
|
+ idenWarningPerson.setType(WarningTypeEnum.KEYNOTE.getValue());
|
|
|
|
+ idenWarningPerson.setPersonId(idenFaceImage.getPersonId());
|
|
|
|
+ idenWarningPerson.setCreateTime(idenFaceImage.getCreateTime());
|
|
|
|
+ this.idenWarningPersonService.save(idenWarningPerson);
|
|
|
|
+
|
|
|
|
+ IdenWarningEvent idenWarningEvent = new IdenWarningEvent();
|
|
|
|
+ idenWarningEvent.setWarningPersonId(idenWarningPerson.getId());
|
|
|
|
+ idenWarningEvent.setDataTime(idenFaceImage.getPhotographTime());
|
|
|
|
+ idenWarningEvent.setImage(idenFaceImage.getImage());
|
|
|
|
+ idenWarningEvent.setCommunityId(idenWarningPerson.getCommunityId());
|
|
|
|
+ idenWarningEvent.setCommunityCode(idenWarningPerson.getCommunityCode());
|
|
|
|
+ idenWarningEvent.setCommunityName(idenWarningPerson.getCommunityName());
|
|
|
|
+ idenWarningEvent.setCommunityName(idenWarningPerson.getDistrict());
|
|
|
|
+ idenWarningEvent.setSubdistrict(idenWarningPerson.getSubdistrict());
|
|
|
|
+ idenWarningEvent.setAppearTime(idenFaceImage.getPhotographTime());
|
|
|
|
+ idenWarningEvent.setType(WarningTypeEnum.KEYNOTE.getValue());
|
|
|
|
+ idenWarningEvent.setPersonId(idenFaceImage.getPersonId());
|
|
|
|
+ idenWarningEvent.setCreateTime(idenFaceImage.getCreateTime());
|
|
|
|
+ this.idenWarningEventService.save(idenWarningEvent);
|
|
|
|
+
|
|
|
|
+ IdenWarningPersonTrace idenWarningPersonTrace = new IdenWarningPersonTrace();
|
|
|
|
+ BeanUtil.copyProperties(idenFaceImage,idenWarningPersonTrace,"id");
|
|
|
|
+ idenWarningPersonTrace.setWarningPersonId(idenWarningPerson.getId());
|
|
|
|
+ this.idenWarningPersonTraceService.save(idenWarningPersonTrace);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private boolean getIsContinue(List<IdenFaceImage> listDataDate,int strangerDays) {
|
|
|
|
+ if(CollUtil.isEmpty(listDataDate)){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ List<String> dataDateList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for(IdenFaceImage idenFaceImage : listDataDate) {
|
|
|
|
+ dataDateList.add(idenFaceImage.getDataDate());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String minDataDate = listDataDate.get(0).getDataDate();
|
|
|
|
+ String maxDataDate = listDataDate.get(listDataDate.size() - 1).getDataDate();
|
|
|
|
+
|
|
|
|
+ List<String> list = DateUtils.getBetweenDates(minDataDate,maxDataDate);
|
|
|
|
+ int cnt = 0;
|
|
|
|
+ for (String date : list) {
|
|
|
|
+ if(dataDateList.contains(date)){
|
|
|
|
+ cnt++;
|
|
|
|
+ } else {
|
|
|
|
+ cnt = 0;
|
|
|
|
+ }
|
|
|
|
+ if(cnt >= strangerDays) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|