同步长庆数据

This commit is contained in:
张博 2024-10-18 10:44:41 +08:00
parent 87d31e4e6f
commit ae8d25d96e
5 changed files with 73 additions and 13 deletions

View File

@ -295,11 +295,11 @@
<!-- <classifier>${javacv.platform}</classifier>--> <!-- <classifier>${javacv.platform}</classifier>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency> <!--<dependency>
<groupId>com.pig4cloud.plugin</groupId> <groupId>com.pig4cloud.plugin</groupId>
<artifactId>oss-spring-boot-starter</artifactId> <artifactId>oss-spring-boot-starter</artifactId>
<version>1.0.5</version> <version>1.0.5</version>
</dependency> </dependency>-->
</dependencies> </dependencies>

View File

@ -1,6 +1,7 @@
package net.shapelight.modules.face.rtsp; package net.shapelight.modules.face.rtsp;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONObject;
import com.arcsoft.face.FaceEngine; import com.arcsoft.face.FaceEngine;
import com.arcsoft.face.FaceFeature; import com.arcsoft.face.FaceFeature;
import com.arcsoft.face.FaceInfo; import com.arcsoft.face.FaceInfo;
@ -12,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.shapelight.common.config.GlobalValue; import net.shapelight.common.config.GlobalValue;
import net.shapelight.common.utils.Constant;
import net.shapelight.modules.face.dto.FaceRecognitionResDTO; import net.shapelight.modules.face.dto.FaceRecognitionResDTO;
import net.shapelight.modules.face.entity.UserCompareInfo; import net.shapelight.modules.face.entity.UserCompareInfo;
import net.shapelight.modules.face.enums.ErrorCodeEnum; import net.shapelight.modules.face.enums.ErrorCodeEnum;
@ -21,6 +23,7 @@ import net.shapelight.modules.face.service.FaceEngineService;
import net.shapelight.modules.face.service.impl.FaceEngineServiceImpl; import net.shapelight.modules.face.service.impl.FaceEngineServiceImpl;
import net.shapelight.modules.face.util.UserInfo; import net.shapelight.modules.face.util.UserInfo;
import net.shapelight.modules.face.util.UserRamGroup; import net.shapelight.modules.face.util.UserRamGroup;
import net.shapelight.modules.feignClient.CxFeignClient;
import net.shapelight.modules.ten.entity.TenPersonEntity; import net.shapelight.modules.ten.entity.TenPersonEntity;
import net.shapelight.modules.ten.service.TenPersonService; import net.shapelight.modules.ten.service.TenPersonService;
import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.impl.GenericObjectPool;
@ -28,6 +31,7 @@ import org.bytedeco.javacpp.avutil;
import org.bytedeco.javacv.*; import org.bytedeco.javacv.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@ -36,9 +40,8 @@ import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Base64; import java.text.SimpleDateFormat;
import java.util.Enumeration; import java.util.*;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import static org.bytedeco.javacpp.avutil.AV_LOG_ERROR; import static org.bytedeco.javacpp.avutil.AV_LOG_ERROR;
@ -55,6 +58,9 @@ public class RtspFrameGrabber {
@Autowired @Autowired
private GlobalValue globalValue; private GlobalValue globalValue;
@Autowired
private CxFeignClient feignClient;
/** /**
* 用于记录人脸识别相关状态 * 用于记录人脸识别相关状态
*/ */
@ -139,7 +145,7 @@ public class RtspFrameGrabber {
// logger.info("处理帧............................................."); // logger.info("处理帧.............................................");
BufferedImage bi = java2DFrameConverter.getBufferedImage(frame); BufferedImage bi = java2DFrameConverter.getBufferedImage(frame);
byte[] bytes = imageToBytes(bi, "jpg"); byte[] bytes = imageToBytes(bi, "jpg");
// 读取图片 /* // 读取图片
BufferedImage image = ImageIO.read(new File("C:\\Users\\zhangbo\\OneDrive\\图片\\Camera Roll\\1寸相片.jpg")); BufferedImage image = ImageIO.read(new File("C:\\Users\\zhangbo\\OneDrive\\图片\\Camera Roll\\1寸相片.jpg"));
// 创建字节输出流 // 创建字节输出流
@ -149,9 +155,9 @@ public class RtspFrameGrabber {
ImageIO.write(image, "jpg", baos); ImageIO.write(image, "jpg", baos);
// 转换为byte数组 // 转换为byte数组
byte[] imageBytes = baos.toByteArray(); byte[] imageBytes = baos.toByteArray();*/
if (imageBytes != null && imageBytes.length > 0) { if (bytes != null && bytes.length > 0) {
ImageInfo imageInfo = ImageFactory.getRGBData(imageBytes); ImageInfo imageInfo = ImageFactory.getRGBData(bytes);
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(imageInfo); List<FaceInfo> faceInfoList = faceEngineService.detectFaces(imageInfo);
if (CollectionUtil.isNotEmpty(faceInfoList)) { if (CollectionUtil.isNotEmpty(faceInfoList)) {
faceInfoList.forEach(faceInfo -> { faceInfoList.forEach(faceInfo -> {
@ -161,8 +167,33 @@ public class RtspFrameGrabber {
if (featureBytes != null) { if (featureBytes != null) {
List<UserInfo> userInfoList = UserRamGroup.getUserList(cellId); List<UserInfo> userInfoList = UserRamGroup.getUserList(cellId);
List<UserCompareInfo> userCompareInfoList = faceEngineService.faceRecognition(featureBytes,userInfoList,Float.parseFloat(globalValue.getRecFaceThd())); List<UserCompareInfo> userCompareInfoList = faceEngineService.faceRecognition(featureBytes,userInfoList,Float.parseFloat(globalValue.getRecFaceThd()));
if(!userCompareInfoList.isEmpty()) {
UserCompareInfo userCompareInfo = userCompareInfoList.get(0); UserCompareInfo userCompareInfo = userCompareInfoList.get(0);
personService.update(new LambdaUpdateWrapper<TenPersonEntity>().set(TenPersonEntity::getIsWatchSafeVideo,1).eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId())); 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 { } else {
log.error("图片不合格,未检测到人脸"); log.error("图片不合格,未检测到人脸");

View File

@ -14,24 +14,45 @@ import java.util.Map;
@Component @Component
public interface CxFeignClient { public interface CxFeignClient {
/*
获取token
*/
@GetMapping("/Auth/getToken") @GetMapping("/Auth/getToken")
String getToken(@RequestParam String appid, @RequestParam String appsecret); String getToken(@RequestParam String appid, @RequestParam String appsecret);
/*
同步安全视频观看记录
*/
@PostMapping("/ExternalService/SavePmWatchVideoRecord") @PostMapping("/ExternalService/SavePmWatchVideoRecord")
JSONObject savePmWatchVideoRecord(@RequestParam Map<String,Object> params); JSONObject savePmWatchVideoRecord(@RequestParam Map<String,Object> params);
/*
同步进出场记录
*/
@PostMapping("/ExternalService/SavePmEntryExitRecord") @PostMapping("/ExternalService/SavePmEntryExitRecord")
JSONObject savePmEntryExitRecord(@RequestParam Map<String,Object> params); JSONObject savePmEntryExitRecord(@RequestParam Map<String,Object> params);
/*
同步访客记录
*/
@PostMapping("/ExternalService/SavePmVisitorPersonnel") @PostMapping("/ExternalService/SavePmVisitorPersonnel")
JSONObject savePmVisitorPersonnel(@RequestParam Map<String,Object> params); JSONObject savePmVisitorPersonnel(@RequestParam Map<String,Object> params);
/*
获取内部人员信息
*/
@GetMapping("/ExternalService/GetPmInternalPersonnelList") @GetMapping("/ExternalService/GetPmInternalPersonnelList")
JSONObject getPmInternalPersonnelList(@RequestParam Map<String,Object> params); JSONObject getPmInternalPersonnelList(@RequestParam Map<String,Object> params);
/*
获取承包商信息
*/
@GetMapping("/ExternalService/GetPmContractorDataList") @GetMapping("/ExternalService/GetPmContractorDataList")
JSONObject getPmContractorDataList(@RequestParam Map<String,Object> params); JSONObject getPmContractorDataList(@RequestParam Map<String,Object> params);
/*
获取长期供应商信息
*/
@GetMapping("/ExternalService/GetPmSupplierDataList") @GetMapping("/ExternalService/GetPmSupplierDataList")
JSONObject getPmSupplierDataList(@RequestParam Map<String,Object> params); JSONObject getPmSupplierDataList(@RequestParam Map<String,Object> params);
} }

View File

@ -834,7 +834,12 @@ public class HttpApiController {
params.put("accessControlName",memberEntity.getOpenId()); params.put("accessControlName",memberEntity.getOpenId());
params.put("state",""); params.put("state","");
params.put("failureReason",""); params.put("failureReason","");
cxFeignClient.savePmEntryExitRecord(params); cn.hutool.json.JSONObject jsonObject = cxFeignClient.savePmEntryExitRecord(params);
if(jsonObject.getBool("success")!=null && jsonObject.getBool("success")){
log.debug("同步进出场记录成功");
}else {
log.debug("同步进出场记录失败"+"姓名:"+memberEntity.getName()+",errorMessage"+jsonObject.getStr("message"));
}
return R.ok(); return R.ok();
} }

View File

@ -92,13 +92,16 @@ public class PersonSynchronousTask implements ITask {
} else { } else {
json = cxFeignClient.getPmSupplierDataList(params); json = cxFeignClient.getPmSupplierDataList(params);
} }
if (json.getBool("success")) { if (json.getBool("success")!=null&&json.getBool("success")) {
JSONObject data = json.getJSONObject("data"); JSONObject data = json.getJSONObject("data");
JSONArray dataList = data.getJSONArray("list"); JSONArray dataList = data.getJSONArray("list");
List<JSONObject> list1 = dataList.toList(JSONObject.class); List<JSONObject> list1 = dataList.toList(JSONObject.class);
list1.forEach(person -> { list1.forEach(person -> {
save(person,item); save(person,item);
}); });
log.debug("获取人员信息成功"+type);
} else {
log.debug("获取人员信息失败"+json.getStr("message"));
} }
log.debug("同步inxex"+(i+1)); log.debug("同步inxex"+(i+1));
} }