增加证书实现类

This commit is contained in:
张博 2024-10-18 17:01:56 +08:00
parent 4df0355c0f
commit a9267ccd65
5 changed files with 87 additions and 60 deletions

View File

@ -96,10 +96,4 @@ public class TenSafeVideoController {
tenSafeVideoService.removeByIds(Arrays.asList(ids));
return R.ok();
}
@GetMapping("/camara")
public R watchStart(String cellId) {
rtspFrameGrabber.startGrabber(cellId);
return R.ok();
}
}

View File

@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@ -157,55 +158,8 @@ public class RtspFrameGrabber {
// 转换为byte数组
byte[] imageBytes = baos.toByteArray();*/
if (bytes != null && bytes.length > 0) {
ImageInfo imageInfo = ImageFactory.getRGBData(bytes);
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(imageInfo);
if (CollectionUtil.isNotEmpty(faceInfoList)) {
faceInfoList.forEach(faceInfo -> {
FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
faceRecognitionResDTO.setRect(faceInfo.getRect());
byte[] featureBytes = faceEngineService.extractFaceFeature(imageInfo, faceInfo, ExtractType.REGISTER);
if (featureBytes != null) {
List<UserInfo> userInfoList = UserRamGroup.getUserList(cellId);
List<UserCompareInfo> userCompareInfoList = faceEngineService.faceRecognition(featureBytes,userInfoList,Float.parseFloat(globalValue.getRecFaceThd()));
if(!userCompareInfoList.isEmpty()) {
UserCompareInfo userCompareInfo = userCompareInfoList.get(0);
TenPersonEntity tenPerson = personService.getOne(new LambdaQueryWrapper<TenPersonEntity>()
.eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId()));
Map<Integer,String> personnelTypeMap = new HashMap<>();
personnelTypeMap.put(Constant.PERSON_TYPE_OWNER,"2");//内部人员
personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商
personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商
Map<String,Object> params = new HashMap<>();
params.put("pmWatchVideoRecordId","");
params.put("orgId",tenPerson.getOrgId());
params.put("orgName","");
params.put("personnelName",tenPerson.getName());
params.put("personnelId",tenPerson.getOpenId());
params.put("personnelCardId",tenPerson.getIdCard());
params.put("personnelType",personnelTypeMap.get(tenPerson.getPersonType()));
params.put("dictSex",tenPerson.getGender()==0?"":"");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
params.put("watchVideoTime",sdf.format(System.currentTimeMillis()));
JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params);
if(jsonObject.getBool("success")!=null&&jsonObject.getBool("success")) {
personService.update(new LambdaUpdateWrapper<TenPersonEntity>()
.set(TenPersonEntity::getIsWatchSafeVideo,1)
.eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId()));
}
}
imageRecognition(bytes,cellId);
} else {
log.error("图片不合格,未检测到人脸");
}
});
} else {
log.error("图片不合格,未检测到人脸");
}
}
} else {
log.error("解码失败");
if (grabber != null) {
@ -241,6 +195,67 @@ public class RtspFrameGrabber {
}
public void recognition(MultipartFile file,String cellId) {
try {
byte[] bytes = file.getBytes();
imageRecognition(bytes,cellId);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void imageRecognition(byte[] bytes,String cellId) {
if (bytes != null && bytes.length > 0) {
ImageInfo imageInfo = ImageFactory.getRGBData(bytes);
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(imageInfo);
if (CollectionUtil.isNotEmpty(faceInfoList)) {
faceInfoList.forEach(faceInfo -> {
FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
faceRecognitionResDTO.setRect(faceInfo.getRect());
byte[] featureBytes = faceEngineService.extractFaceFeature(imageInfo, faceInfo, ExtractType.REGISTER);
if (featureBytes != null) {
List<UserInfo> userInfoList = UserRamGroup.getUserList(cellId);
List<UserCompareInfo> userCompareInfoList = faceEngineService.faceRecognition(featureBytes,userInfoList,Float.parseFloat(globalValue.getRecFaceThd()));
if(!userCompareInfoList.isEmpty()) {
UserCompareInfo userCompareInfo = userCompareInfoList.get(0);
TenPersonEntity tenPerson = personService.getOne(new LambdaQueryWrapper<TenPersonEntity>()
.eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId()));
Map<Integer,String> personnelTypeMap = new HashMap<>();
personnelTypeMap.put(Constant.PERSON_TYPE_OWNER,"2");//内部人员
personnelTypeMap.put(Constant.PERSON_TYPE_MEMBER,"1");//承包商
personnelTypeMap.put(Constant.PERSON_TYPE_TENANT,"3");//长期供应商
Map<String,Object> params = new HashMap<>();
params.put("pmWatchVideoRecordId","");
params.put("orgId",tenPerson.getOrgId());
params.put("orgName","");
params.put("personnelName",tenPerson.getName());
params.put("personnelId",tenPerson.getOpenId());
params.put("personnelCardId",tenPerson.getIdCard());
params.put("personnelType",personnelTypeMap.get(tenPerson.getPersonType()));
params.put("dictSex",tenPerson.getGender()==0?"":"");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
params.put("watchVideoTime",sdf.format(System.currentTimeMillis()));
/*JSONObject jsonObject = feignClient.savePmWatchVideoRecord(params);
if(jsonObject.getBool("success")!=null&&jsonObject.getBool("success")) {
personService.update(new LambdaUpdateWrapper<TenPersonEntity>()
.set(TenPersonEntity::getIsWatchSafeVideo,1)
.eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId()));
}*/
}
} else {
log.error("图片不合格,未检测到人脸");
}
});
} else {
log.error("图片不合格,未检测到人脸");
}
}
}
/**
* 图片转字节数组
*

View File

@ -6,6 +6,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
@ -24,19 +25,19 @@ public interface CxFeignClient {
同步安全视频观看记录
*/
@PostMapping("/ExternalService/SavePmWatchVideoRecord")
JSONObject savePmWatchVideoRecord(@RequestParam Map<String,Object> params);
JSONObject savePmWatchVideoRecord(@RequestBody Map<String,Object> params);
/*
同步进出场记录
*/
@PostMapping("/ExternalService/SavePmEntryExitRecord")
JSONObject savePmEntryExitRecord(@RequestParam Map<String,Object> params);
JSONObject savePmEntryExitRecord(@RequestBody Map<String,Object> params);
/*
同步访客记录
*/
@PostMapping("/ExternalService/SavePmVisitorPersonnel")
JSONObject savePmVisitorPersonnel(@RequestParam Map<String,Object> params);
JSONObject savePmVisitorPersonnel(@RequestBody Map<String,Object> params);
/*
获取内部人员信息

View File

@ -2,12 +2,12 @@ package net.shapelight.modules.iCq.controller.video;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.plugin.oss.service.OssTemplate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import net.shapelight.common.config.MinioConfig;
import net.shapelight.common.utils.R;
import net.shapelight.modules.face.rtsp.RtspFrameGrabber;
import net.shapelight.modules.iCq.controller.video.dto.UpdateVideoDto;
import net.shapelight.modules.iCq.controller.video.dto.UploadVideoDto;
import net.shapelight.modules.iCq.controller.video.vo.Unit;
@ -15,6 +15,7 @@ import net.shapelight.modules.iCq.dal.dataobject.video.File;
import net.shapelight.modules.iCq.dal.dataobject.video.TenSafeVideoEntity;
import net.shapelight.modules.iCq.dal.mysql.video.CqFileMapper;
import net.shapelight.modules.iCq.dal.mysql.video.CqSafeVideoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -34,14 +35,15 @@ public class CqSafeVideoController {
private static String BUCKET_NAME = "cqyt";
private final OssTemplate template;
private final MinioConfig minioConfig;
private final CqSafeVideoMapper cqSafeVideoMapper;
private final CqFileMapper cqFileMapper;
@Autowired
private RtspFrameGrabber rtspFrameGrabber;
@GetMapping("/getTopUnits")
@ApiOperation(value = "获取单位列表")
public R getTopUnits() {
@ -183,6 +185,19 @@ public class CqSafeVideoController {
return R.ok();
}
@GetMapping("/camara")
public R watchStart(String cellId) {
rtspFrameGrabber.startGrabber(cellId);
return R.ok();
}
@GetMapping("/face/recognition")
public R aWatchStart(@RequestParam("image") MultipartFile image,@RequestParam String cellId) {
rtspFrameGrabber.recognition(image,cellId);
return R.ok();
}

View File

@ -266,11 +266,13 @@ public class TenPersonEntity extends BaseEntity implements Serializable {
* 临时身份证正面照片
*/
@ApiModelProperty("临时身份证正面照片")
@TableField(exist = false)
private String idFrontImageTemp;
/**
* 临时身份证反面照片
*/
@ApiModelProperty("临时身份证反面照片")
@TableField(exist = false)
private String idBackImageTemp;