同步长庆数据
This commit is contained in:
parent
b716a6f89f
commit
942d176283
|
@ -239,6 +239,12 @@
|
|||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bytedeco</groupId>
|
||||
<artifactId>javacv-platform</artifactId>
|
||||
<version>1.4.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.arcsoft.face</groupId>-->
|
||||
<!-- <artifactId>arcsoft-sdk-face</artifactId>-->
|
||||
|
|
|
@ -60,7 +60,7 @@ public class AdminApplication {
|
|||
// });
|
||||
}
|
||||
|
||||
/*@Bean
|
||||
/* @Bean
|
||||
@PostConstruct
|
||||
void init(){
|
||||
String res = cxFeignClient.getToken("5bb50ad0cc40e10565089c35aa61e7f3","k9?8bCqaQ*R1e2Wx0f65AzY4^]LDp@_Z");
|
||||
|
|
|
@ -30,9 +30,9 @@ public class Constant {
|
|||
public static final int ROLE_TEN_CELL = 3000; //小区主管 添加楼栋
|
||||
//public static final int ROLE_TEN_BUILD = 4000; //楼栋管理 只能管理某些楼栋
|
||||
|
||||
public static final int PERSON_TYPE_OWNER = 5000; //业主
|
||||
public static final int PERSON_TYPE_MEMBER = 5001; //家属住户
|
||||
public static final int PERSON_TYPE_TENANT = 5002; //租户
|
||||
public static final int PERSON_TYPE_OWNER = 5000; //内部员工
|
||||
public static final int PERSON_TYPE_MEMBER = 5001; //承包商
|
||||
public static final int PERSON_TYPE_TENANT = 5002; //长期供应商
|
||||
public static final int PERSON_TYPE_GUEST = 5005; //访客
|
||||
public static final int PERSON_TYPE_PROPERTY = 5006; //物业人员
|
||||
public static final int PERSON_TYPE_WHITE = 5007; //白名单
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.shapelight.common.utils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
public class MyBeanUtils {
|
||||
|
@ -42,4 +43,22 @@ public class MyBeanUtils {
|
|||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象指定属性的值
|
||||
* @param o 对象
|
||||
* @param fieldName 要获取值的属性
|
||||
* 返回值:对象指定属性的值
|
||||
*/
|
||||
public static Object getFieldValueByName(Object o, String fieldName) {
|
||||
try {
|
||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
||||
String getter = "get" + firstLetter + fieldName.substring(1);
|
||||
Method method = o.getClass().getMethod(getter, new Class[] {});
|
||||
return method.invoke(o, new Object[] {});
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,17 @@
|
|||
package net.shapelight.modules.changqing.controller;
|
||||
|
||||
import com.arcsoft.face.FaceEngine;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import net.shapelight.common.utils.PageUtils;
|
||||
import net.shapelight.common.utils.R;
|
||||
import net.shapelight.modules.changqing.entity.TenSafeVideoEntity;
|
||||
import net.shapelight.modules.changqing.service.TenSafeVideoService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import net.shapelight.modules.face.rtsp.RtspFrameGrabber;
|
||||
import net.shapelight.modules.ten.service.impl.TenPersonServiceImpl;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -22,6 +26,21 @@ import java.util.Map;
|
|||
public class TenSafeVideoController {
|
||||
@Autowired
|
||||
private TenSafeVideoService tenSafeVideoService;
|
||||
@Autowired
|
||||
private RtspFrameGrabber rtspFrameGrabber;
|
||||
|
||||
/**
|
||||
* 用于人脸识别的引擎池
|
||||
*/
|
||||
private GenericObjectPool<FaceEngine> frEnginePool;
|
||||
|
||||
/**
|
||||
* rtsp视频流url
|
||||
*/
|
||||
@Value("${global.file_path.static-locations}")
|
||||
private String rtspUrl;
|
||||
@Autowired
|
||||
private TenPersonServiceImpl tenPersonService;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
|
@ -77,4 +96,10 @@ public class TenSafeVideoController {
|
|||
tenSafeVideoService.removeByIds(Arrays.asList(ids));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/camara")
|
||||
public R watchStart(String cellId) {
|
||||
rtspFrameGrabber.startGrabber(cellId);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
|
@ -92,6 +92,7 @@ public class FaceEngineAutoRun implements ApplicationRunner {
|
|||
for(TenCellEntity cellEntity: cellList){
|
||||
String cellId = cellEntity.getCellId()+"";
|
||||
UserRamGroup.addCell(cellId);
|
||||
UserRamGroup.addOrgId(cellEntity.getOrgId(),cellId);
|
||||
int count = tenPersonService.findCount(cellId);
|
||||
int pageSize = 1000;
|
||||
int page = count/pageSize;
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package net.shapelight.modules.face.face;
|
||||
|
||||
import com.arcsoft.face.FaceInfo;
|
||||
|
||||
public class FacePreviewInfo {
|
||||
private FaceInfo faceInfo;
|
||||
private int trackId;
|
||||
private int gender = -1;
|
||||
|
||||
public FacePreviewInfo(FaceInfo faceInfo, int trackId) {
|
||||
this.faceInfo = faceInfo;
|
||||
this.trackId = trackId;
|
||||
}
|
||||
|
||||
public FacePreviewInfo(FaceInfo faceInfo, int trackId, int gender) {
|
||||
this.faceInfo = faceInfo;
|
||||
this.trackId = trackId;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public int getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(int gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public FaceInfo getFaceInfo() {
|
||||
return faceInfo;
|
||||
}
|
||||
|
||||
public void setFaceInfo(FaceInfo faceInfo) {
|
||||
this.faceInfo = faceInfo;
|
||||
}
|
||||
|
||||
|
||||
public int getTrackId() {
|
||||
return trackId;
|
||||
}
|
||||
|
||||
public void setTrackId(int trackId) {
|
||||
this.trackId = trackId;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,29 +21,29 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
|
||||
@Slf4j
|
||||
public class FaceRecognize {
|
||||
public final class FaceRecognize {
|
||||
|
||||
/**
|
||||
* VIDEO模式人脸检测引擎,用于预览帧人脸追踪
|
||||
*/
|
||||
private FaceEngine ftEngine;
|
||||
private static FaceEngine ftEngine;
|
||||
|
||||
/**
|
||||
* 人脸注册引擎
|
||||
*/
|
||||
private FaceEngine regEngine;
|
||||
private static FaceEngine regEngine;
|
||||
|
||||
/**
|
||||
* 用于人脸识别的引擎池
|
||||
*/
|
||||
private GenericObjectPool<FaceEngine> frEnginePool;
|
||||
private static GenericObjectPool<FaceEngine> frEnginePool;
|
||||
|
||||
|
||||
private volatile ConcurrentHashMap<Integer, FaceResult> faceResultRegistry = new ConcurrentHashMap<>();
|
||||
private static volatile ConcurrentHashMap<Integer, FaceResult> faceResultRegistry = new ConcurrentHashMap<>();
|
||||
|
||||
private ExecutorService frService = Executors.newFixedThreadPool(20);
|
||||
private static ExecutorService frService = Executors.newFixedThreadPool(20);
|
||||
|
||||
public ConcurrentHashMap<String, byte[]> faceFeatureRegistry = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, byte[]> faceFeatureRegistry = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 初始化引擎
|
||||
|
@ -100,7 +100,7 @@ public class FaceRecognize {
|
|||
}
|
||||
|
||||
|
||||
public void registerFace(String imagePath) {
|
||||
public static void registerFace(String imagePath) {
|
||||
|
||||
log.info("正在注册人脸");
|
||||
|
||||
|
@ -137,21 +137,21 @@ public class FaceRecognize {
|
|||
|
||||
}
|
||||
|
||||
public void registerFace(Map<String, byte[]> face) {
|
||||
public static void registerFace(Map<String, byte[]> face) {
|
||||
face.forEach((k, v) -> {
|
||||
faceFeatureRegistry.put(k, v.clone());
|
||||
});
|
||||
}
|
||||
|
||||
public void removeFace(String name) {
|
||||
public static void removeFace(String name) {
|
||||
faceFeatureRegistry.remove(name);
|
||||
}
|
||||
|
||||
public void clearFace() {
|
||||
public static void clearFace() {
|
||||
faceFeatureRegistry.clear();
|
||||
}
|
||||
|
||||
public FaceResult getFaceResult(FaceInfo faceInfo, ImageInfo imageInfo) {
|
||||
public static FaceResult getFaceResult(FaceInfo faceInfo, ImageInfo imageInfo) {
|
||||
FaceResult faceResult = faceResultRegistry.get(faceInfo.getFaceId());
|
||||
if (faceResult == null) {
|
||||
faceResult = new FaceResult();
|
||||
|
@ -211,7 +211,7 @@ public class FaceRecognize {
|
|||
|
||||
|
||||
@Data
|
||||
public class FaceResult {
|
||||
public static class FaceResult {
|
||||
private boolean flag = false;
|
||||
private String name;
|
||||
private float score;
|
||||
|
@ -229,7 +229,7 @@ public class FaceRecognize {
|
|||
}
|
||||
|
||||
|
||||
private class FaceInfoRunnable implements Runnable {
|
||||
private static class FaceInfoRunnable implements Runnable {
|
||||
private FaceInfo faceInfo;
|
||||
private ImageInfo imageInfo;
|
||||
private FaceResult faceResult;
|
||||
|
|
|
@ -0,0 +1,229 @@
|
|||
package net.shapelight.modules.face.rtsp;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.arcsoft.face.FaceEngine;
|
||||
import com.arcsoft.face.FaceFeature;
|
||||
import com.arcsoft.face.FaceInfo;
|
||||
import com.arcsoft.face.FaceSimilar;
|
||||
import com.arcsoft.face.enums.ExtractType;
|
||||
import com.arcsoft.face.toolkit.ImageFactory;
|
||||
import com.arcsoft.face.toolkit.ImageInfo;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.common.config.GlobalValue;
|
||||
import net.shapelight.modules.face.dto.FaceRecognitionResDTO;
|
||||
import net.shapelight.modules.face.entity.UserCompareInfo;
|
||||
import net.shapelight.modules.face.enums.ErrorCodeEnum;
|
||||
import net.shapelight.modules.face.face.FacePreviewInfo;
|
||||
import net.shapelight.modules.face.rpc.BusinessException;
|
||||
import net.shapelight.modules.face.service.FaceEngineService;
|
||||
import net.shapelight.modules.face.service.impl.FaceEngineServiceImpl;
|
||||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamGroup;
|
||||
import net.shapelight.modules.ten.entity.TenPersonEntity;
|
||||
import net.shapelight.modules.ten.service.TenPersonService;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import org.bytedeco.javacpp.avutil;
|
||||
import org.bytedeco.javacv.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.bytedeco.javacpp.avutil.AV_LOG_ERROR;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RtspFrameGrabber {
|
||||
|
||||
@Autowired
|
||||
private FaceEngineService faceEngineService;
|
||||
|
||||
@Autowired
|
||||
private TenPersonService personService;
|
||||
|
||||
@Autowired
|
||||
private GlobalValue globalValue;
|
||||
/**
|
||||
* 用于记录人脸识别相关状态
|
||||
*/
|
||||
public ConcurrentHashMap<Integer, Integer> requestFeatureStatusMap = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* rtsp视频流url
|
||||
*/
|
||||
private String rtspUrl;
|
||||
/**
|
||||
* 帧抓取器
|
||||
*/
|
||||
private FFmpegFrameGrabber grabber;
|
||||
/**
|
||||
* 视频帧率
|
||||
*/
|
||||
private int frameRate = 25;
|
||||
/**
|
||||
* 视频码率
|
||||
*/
|
||||
// private int bitRate = 2000000;
|
||||
private int bitRate = 128000;
|
||||
/**
|
||||
* 视频宽度
|
||||
*/
|
||||
private int frameWidth = 480;
|
||||
/**
|
||||
* 视频高度
|
||||
*/
|
||||
private int frameHeight = 270;
|
||||
|
||||
private void createGrabber() {
|
||||
try {
|
||||
|
||||
grabber = FFmpegFrameGrabber.createDefault("rtsp://192.168.100.102:554/main");
|
||||
grabber.setOption("rtsp_transport", "tcp");
|
||||
|
||||
// grabber.setOption("reconnect", "1");
|
||||
// grabber.setOption("reconnect_at_eof", "1");
|
||||
// grabber.setOption("reconnect_streamed", "1");
|
||||
// grabber.setOption("reconnect_delay_max", "2");
|
||||
// grabber.setOption("preset", "veryfast");
|
||||
// grabber.setOption("probesize", "192");
|
||||
// grabber.setOption("tune", "zerolatency");
|
||||
// grabber.setFrameRate(30.0);
|
||||
// grabber.setOption("buffer_size", "" + this.bufferSize);
|
||||
// grabber.setOption("max_delay", "500000");
|
||||
// grabber.setOption("stimeout", String.valueOf(20000));
|
||||
// grabber.setOption("loglevel", "quiet");
|
||||
|
||||
|
||||
// grabber.setOption("appkey", "****");//海康视频 appkey
|
||||
// grabber.setOption("secret", byte2Base64);//海康视频 secret
|
||||
// grabber.setOption("port", "446");//默认443
|
||||
// grabber.setOption("enableHTTPS", "1"); //是否启用HTTPS协议,这里总是填1
|
||||
// grabber.setOption("rtsp_flags", "prefer_tcp");
|
||||
grabber.setOption("stimeout", "5000000");//5秒
|
||||
|
||||
|
||||
//设置帧率
|
||||
grabber.setFrameRate(frameRate);
|
||||
//设置获取的视频宽度
|
||||
grabber.setImageWidth(frameWidth);
|
||||
//设置获取的视频高度
|
||||
grabber.setImageHeight(frameHeight);
|
||||
//设置视频bit率
|
||||
grabber.setVideoBitrate(bitRate);
|
||||
grabber.start();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
public void startGrabber(String cellId) {
|
||||
avutil.av_log_set_level(AV_LOG_ERROR);
|
||||
Java2DFrameConverter java2DFrameConverter = new Java2DFrameConverter();
|
||||
if (grabber == null) {
|
||||
//log.info("连接rtsp:" + rstp + ",开始创建grabber");
|
||||
createGrabber();
|
||||
}
|
||||
try {
|
||||
Frame frame = grabber.grabImage();
|
||||
if (frame != null) {
|
||||
// logger.info("处理帧.............................................");
|
||||
BufferedImage bi = java2DFrameConverter.getBufferedImage(frame);
|
||||
byte[] bytes = imageToBytes(bi, "jpg");
|
||||
// 读取图片
|
||||
BufferedImage image = ImageIO.read(new File("\"C:\\\\Users\\\\zhangbo\\\\OneDrive\\\\图片\\\\Camera Roll\\\\1寸相片.jpg\""));
|
||||
|
||||
// 创建字节输出流
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
// 使用ImageIO将BufferedImage编码为byte[]
|
||||
ImageIO.write(image, "jpg", baos);
|
||||
|
||||
// 转换为byte数组
|
||||
byte[] imageBytes = baos.toByteArray();
|
||||
if (imageBytes != null && imageBytes.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()));
|
||||
userCompareInfoList.forEach(userCompareInfo -> {
|
||||
personService.update(new LambdaUpdateWrapper<TenPersonEntity>().set(TenPersonEntity::getIsWatchSafeVideo,1).eq(TenPersonEntity::getPersonId,userCompareInfo.getFaceId()));
|
||||
});
|
||||
} else {
|
||||
log.error("图片不合格,未检测到人脸");
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
log.error("图片不合格,未检测到人脸");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
log.error("解码失败");
|
||||
if (grabber != null) {
|
||||
try {
|
||||
grabber.stop();
|
||||
} catch (FrameGrabber.Exception ex) {
|
||||
log.error("grabber stop exception: " + ex.getMessage());
|
||||
} finally {
|
||||
grabber = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
|
||||
if (grabber != null) {
|
||||
try {
|
||||
grabber.stop();
|
||||
} catch (FrameGrabber.Exception ex) {
|
||||
log.error("grabber stop exception: " + ex.getMessage());
|
||||
} finally {
|
||||
grabber = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// try {
|
||||
// Thread.sleep(100);
|
||||
// } catch (InterruptedException e) {
|
||||
// logger.error(e.getMessage());
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片转字节数组
|
||||
*
|
||||
* @param _bi 图片数据
|
||||
* @return 图片字节码
|
||||
*/
|
||||
private byte[] imageToBytes(BufferedImage _bi, String _format) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ImageIO.write(_bi, _format, baos);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public class UserRamGroup {
|
||||
|
||||
private static final ConcurrentHashMap<String, UserRamCache> USER_RAM_GROUP_MAP = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, String> ORG_CELL_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
public static void addCell(String cellId){
|
||||
UserRamCache cell = new UserRamCache();
|
||||
|
@ -28,6 +29,13 @@ public class UserRamGroup {
|
|||
return USER_RAM_GROUP_MAP.get(cellId).getUserList();
|
||||
}
|
||||
|
||||
public static void addOrgId(String orgId,String cellId){
|
||||
ORG_CELL_MAP.put(orgId,cellId);
|
||||
}
|
||||
public static String getOrgCellMap(String orgId) {
|
||||
return ORG_CELL_MAP.get(orgId);
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
USER_RAM_GROUP_MAP.clear();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name="cxFeignClient",url="${spring.global.qhseUrl}",configuration = CxFeignConfig.class)
|
||||
@FeignClient(name="cxFeignClient",url="${global.Url.qhseUrl}",configuration = CxFeignConfig.class)
|
||||
@Component
|
||||
public interface CxFeignClient {
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.shapelight.modules.face.util.Base64Util;
|
|||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamCache;
|
||||
import net.shapelight.modules.face.util.UserRamGroup;
|
||||
import net.shapelight.modules.feignClient.CxFeignClient;
|
||||
import net.shapelight.modules.httpapi.service.AuthService;
|
||||
import net.shapelight.modules.httpapi.service.RecordSaveSyncService;
|
||||
import net.shapelight.modules.nettyapi.config.CmdConstant;
|
||||
|
@ -111,6 +112,8 @@ public class HttpApiController {
|
|||
private FaceEngineService faceEngineService;
|
||||
@Autowired
|
||||
private RecordSaveSyncService recordSaveSyncService;
|
||||
@Autowired
|
||||
private CxFeignClient cxFeignClient;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -796,11 +799,42 @@ public class HttpApiController {
|
|||
|
||||
// 考勤记录,没有删除的人记录考勤
|
||||
TenPersonEntity memberEntity = tenPersonService.getById(personId,deviceEntity.getCellId());
|
||||
if(memberEntity!=null){
|
||||
/*if(memberEntity!=null){
|
||||
if(memberEntity.getDeleteFlag().intValue() == 0){
|
||||
tenCheckService.saveCheck(memberEntity,record);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*{
|
||||
"pmEntryExitRecordId": "", GUID,不需要赋值,空
|
||||
"orgId": "string", 单位id
|
||||
"orgName": "string", 单位名称
|
||||
"personnelName": "string", 人员姓名
|
||||
"personnelId": "string", 各类人员的id
|
||||
"personnelCardId": "string", 身份证号
|
||||
"personnelType": "string", 人员类型 字典项:1:承包商人员;2:内部人员;3:长期供应商人员;4:访客
|
||||
"entryOrExit": "string", 出入场类型 字典项:1:入场;2:出场
|
||||
"entryExitTime": "2024-09-12 03:51:39",出入场时间
|
||||
"accessControlName": "string",门禁名称
|
||||
"state": "string", 是否成功 字典项: 1:成功;0:失败
|
||||
"failureReason": "string" 失败原因,当出入场失败的时候赋值
|
||||
}*/
|
||||
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("pmEntryExitRecordId","");
|
||||
params.put("orgId",memberEntity.getOrgId());
|
||||
params.put("orgName",memberEntity.getCellName());
|
||||
params.put("personnelName",memberEntity.getName());
|
||||
params.put("personnelId",memberEntity.getOpenId());
|
||||
params.put("personnelType",personnelTypeMap.get(memberEntity.getPersonType()));
|
||||
params.put("entryOrExit",String.valueOf(deviceEntity.getGateFlag()+1));
|
||||
params.put("entryExitTime",new Date(unlockTime));
|
||||
params.put("accessControlName",memberEntity.getOpenId());
|
||||
params.put("state","");
|
||||
params.put("failureReason","");
|
||||
cxFeignClient.savePmEntryExitRecord(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -4,26 +4,37 @@ import cn.hutool.json.JSONArray;
|
|||
import cn.hutool.json.JSONObject;
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PutObjectOptions;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.common.config.GlobalValue;
|
||||
import net.shapelight.common.config.MinioConfig;
|
||||
import net.shapelight.common.utils.Constant;
|
||||
import net.shapelight.common.utils.SnowflakeIdWorker;
|
||||
import net.shapelight.common.utils.UUIDUtil;
|
||||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamGroup;
|
||||
import net.shapelight.modules.feignClient.CxFeignClient;
|
||||
import net.shapelight.modules.ten.entity.TenCellEntity;
|
||||
import net.shapelight.modules.ten.entity.TenPersonCert;
|
||||
import net.shapelight.modules.ten.entity.TenPersonEntity;
|
||||
import net.shapelight.modules.ten.entity.TenPersonTrain;
|
||||
import net.shapelight.modules.ten.service.TenCellService;
|
||||
import net.shapelight.modules.ten.service.TenPersonCertService;
|
||||
import net.shapelight.modules.ten.service.TenPersonService;
|
||||
import net.shapelight.modules.ten.service.TenPersonTrainService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
|
||||
@Component
|
||||
public class PersonSynchronousTask implements ITask{
|
||||
@Slf4j
|
||||
public class PersonSynchronousTask implements ITask {
|
||||
@Resource
|
||||
private CxFeignClient cxFeignClient;
|
||||
@Resource
|
||||
|
@ -36,6 +47,10 @@ public class PersonSynchronousTask implements ITask{
|
|||
private MinioConfig minioConfig;
|
||||
@Autowired
|
||||
private TenPersonService tenPersonService;
|
||||
@Autowired
|
||||
private TenPersonCertService certService;
|
||||
@Autowired
|
||||
private TenPersonTrainService trainService;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -43,41 +58,171 @@ public class PersonSynchronousTask implements ITask{
|
|||
|
||||
}
|
||||
|
||||
private void GetPmInternalPersonnelList(){
|
||||
private void getPmInternalPersonnelList(String type) {
|
||||
List<TenCellEntity> list = tenCellService.list();
|
||||
list.forEach(item -> {
|
||||
boolean flag = true;
|
||||
int pageIndex = 1;
|
||||
while (flag) {
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("pageIndex",pageIndex);
|
||||
params.put("pageSize",1000);
|
||||
params.put("orgName",item.getName());
|
||||
params.put("orgId",item.getCellId());
|
||||
JSONObject json = cxFeignClient.getPmInternalPersonnelList(params);
|
||||
if(json.getBool("success")) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("pageIndex", pageIndex);
|
||||
params.put("pageSize", 1000);
|
||||
params.put("orgName", item.getName());
|
||||
params.put("orgId", item.getCellId());
|
||||
JSONObject jsonOne = null;
|
||||
if(type.equals("Person")) {
|
||||
jsonOne = cxFeignClient.getPmInternalPersonnelList(params);
|
||||
} else if(type.equals("Contractor")) {
|
||||
jsonOne = cxFeignClient.getPmContractorDataList(params);
|
||||
} else {
|
||||
jsonOne = cxFeignClient.getPmSupplierDataList(params);
|
||||
}
|
||||
|
||||
int total = jsonOne.getInt("total");
|
||||
if(total>0){
|
||||
for(int i = 0;i<total/20;i++){
|
||||
Map<String, Object> params2 = new HashMap<>();
|
||||
params2.put("pageIndex", i);
|
||||
params2.put("pageSize", 20);
|
||||
params2.put("orgName", item.getName());
|
||||
params2.put("orgId", item.getCellId());
|
||||
JSONObject json = null;
|
||||
if(type.equals("Person")) {
|
||||
json = cxFeignClient.getPmInternalPersonnelList(params);
|
||||
} else if(type.equals("Contractor")) {
|
||||
json = cxFeignClient.getPmContractorDataList(params);
|
||||
} else {
|
||||
json = cxFeignClient.getPmSupplierDataList(params);
|
||||
}
|
||||
if (json.getBool("success")) {
|
||||
JSONObject data = json.getJSONObject("data");
|
||||
JSONArray dataList = data.getJSONArray("list");
|
||||
List<JSONObject> list1 = dataList.toList(JSONObject.class);
|
||||
list1.forEach(person -> {
|
||||
save(person,item);
|
||||
});
|
||||
}
|
||||
log.debug("同步inxex:"+(i+1));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void save(JSONObject person,TenCellEntity cellEntity) {
|
||||
TenPersonEntity tenPerson = new TenPersonEntity();
|
||||
Date now = new Date();
|
||||
long id = new SnowflakeIdWorker().nextId();
|
||||
tenPerson.setPersonId(id);
|
||||
tenPerson.setUuid(UUIDUtil.uuid());
|
||||
tenPerson.setTenantId(item.getTenantId());
|
||||
tenPerson.setTenantId(cellEntity.getTenantId());
|
||||
tenPerson.setCreateBy("sync");
|
||||
tenPerson.setRegisterType(Constant.RESGISTER_TYPE_FILE);
|
||||
tenPerson.setStatus(Constant.PESON_SUATUS_NOMOR);
|
||||
tenPerson.setCreateTime(now);
|
||||
tenPerson.setLastUpdateTime(now);
|
||||
tenPerson.setName(person.getStr("personnelName"));
|
||||
tenPerson.setGender(1);
|
||||
tenPerson.setNation(1);
|
||||
tenPerson.setCellId(item.getCellId());
|
||||
tenPerson.setPersonType(5000);
|
||||
tenPerson.setCellId(person.getStr("orgId")!=null?Long.parseLong(UserRamGroup.getOrgCellMap(person.getStr("orgId"))):null);
|
||||
tenPerson.setOrgId(person.getStr("orgId")!=null?person.getStr("orgId"):null);
|
||||
tenPerson.setName(person.getStr("personnelName")!=null?person.getStr("personnelName"):null);
|
||||
tenPerson.setGender(person.getInt("dictSex")!=null?person.getInt("dictSex"):0);
|
||||
tenPerson.setMobile(person.getStr("mobile")!=null?person.getStr("mobile"):null);
|
||||
tenPerson.setIdCard(person.getStr("personnelCardId")!=null?person.getStr("personnelCardId"):null);
|
||||
tenPerson.setNation(person.getStr("dictNation")!=null?Integer.parseInt(person.getStr("dictNation")):1);
|
||||
tenPerson.setCellId(cellEntity.getCellId());
|
||||
if(person.getStr("pmPersonnelId")!=null) {
|
||||
tenPerson.setOpenId(person.getStr("pmPersonnelId"));
|
||||
tenPerson.setOrgId(person.getStr("orgId"));
|
||||
}
|
||||
if(person.getStr("pmContractorId")!=null) {
|
||||
tenPerson.setOpenId(person.getStr("pmContractorId"));
|
||||
}
|
||||
if(person.getStr("pmSupplierId")!=null) {
|
||||
tenPerson.setOpenId(person.getStr("pmSupplierId"));
|
||||
}
|
||||
tenPerson.setOrgId(person.getStr("orgId")!=null?person.getStr("orgId"):null);
|
||||
SimpleDateFormat sfm = new SimpleDateFormat("yyyy-MM-dd hh-mm-ss");
|
||||
try {
|
||||
if(person.getStr("enterValidPeriod") != null) {
|
||||
tenPerson.setLiveStart(sfm.parse(person.getStr("enterValidPeriod")));
|
||||
} else if(person.getStr("validPeriodSta")!=null) {
|
||||
tenPerson.setLiveStart(sfm.parse(person.getStr("validPeriodSta")));
|
||||
}
|
||||
if(person.getStr("enterValidPeriodEnd") != null) {
|
||||
tenPerson.setLiveEnd(sfm.parse(person.getStr("enterValidPeriodEnd")));
|
||||
} else if(person.getStr("validPeriodEnd")!=null) {
|
||||
tenPerson.setLiveStart(sfm.parse(person.getStr("validPeriodEnd")));
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if(person.getStr("isEnterSulfurArea")!=null) {
|
||||
tenPerson.setIsEnterSulfurArea(person.getStr("isEnterSulfurArea").equals("是")?1:0);
|
||||
}
|
||||
if(person.getStr("isProtectDevice")!=null) {
|
||||
tenPerson.setIsProtectDevice(person.getStr("isProtectDevice").equals("是")?1:0);
|
||||
}
|
||||
if(person.getStr("isWatchSafeVideo")!=null) {
|
||||
tenPerson.setIsWatchSafeVideo(person.getStr("isWatchSafeVideo").equals("是")?1:0);
|
||||
}
|
||||
if(person.getStr("belongContractorName")!=null) {
|
||||
tenPerson.setBelongContractorName(person.getStr("belongContractorName"));
|
||||
}
|
||||
if(person.getStr("isBlacklistPersonnel")!=null && person.getStr("isBlacklistPersonnel").equals("是")) {
|
||||
tenPerson.setPersonType(Constant.PERSON_TYPE_BLACK);
|
||||
} else {
|
||||
tenPerson.setPersonType(Constant.PERSON_TYPE_BLACK);
|
||||
}
|
||||
if(person.getJSONArray("pmContractorCertDatas")!=null) {
|
||||
List<JSONObject> pmContractorCertDatas = person.getJSONArray("pmContractorCertDatas").toList(JSONObject.class);
|
||||
pmContractorCertDatas.forEach(contractorCert -> {
|
||||
TenPersonCert personCert = new TenPersonCert();
|
||||
personCert.setCertName(contractorCert.getStr("certName")!=null?contractorCert.getStr("certName"):null);
|
||||
personCert.setPmContractorCertId(contractorCert.getStr("pmContractorCertId")!=null?contractorCert.getStr("pmContractorCertId"):null);
|
||||
personCert.setPerson(id);
|
||||
personCert.setCertType(contractorCert.getStr("certType")!=null?contractorCert.getStr("certType"):null);
|
||||
if(contractorCert.getStr("certObtainDate")!=null) {
|
||||
try {
|
||||
personCert.setCertObtainDate(sfm.parse(contractorCert.getStr("certObtainDate")));
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if(contractorCert.getStr("effectiveDate")!=null) {
|
||||
try {
|
||||
personCert.setEffectiveDate(sfm.parse(contractorCert.getStr("effectiveDate")));
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
certService.saveOrUpdateByField(personCert,"pmContractorCertId");
|
||||
});
|
||||
}
|
||||
if(person.getJSONArray("pmContractorTrainDatas")!=null) {
|
||||
List<JSONObject> pmContractorTrainDatas = person.getJSONArray("pmContractorTrainDatas").toList(JSONObject.class);
|
||||
pmContractorTrainDatas.forEach(contractorTrain -> {
|
||||
TenPersonTrain personTrain = new TenPersonTrain();
|
||||
personTrain.setTrainContent(contractorTrain.getStr("trainContent")!=null?contractorTrain.getStr("trainContent"):null);
|
||||
personTrain.setPmContractorTrainId(contractorTrain.getStr("pmContractorTrainId")!=null?contractorTrain.getStr("pmContractorTrainId"):null);
|
||||
personTrain.setPersonId(id);
|
||||
if(contractorTrain.getStr("isQualified")!=null) {
|
||||
personTrain.setIsQualified(contractorTrain.getStr("isQualified").equals("是")?1:0);
|
||||
}
|
||||
|
||||
if(contractorTrain.getStr("trainStartDate")!=null) {
|
||||
try {
|
||||
personTrain.setTrainStartDate(sfm.parse(contractorTrain.getStr("trainStartDate")));
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if(contractorTrain.getStr("trainEndDate")!=null) {
|
||||
try {
|
||||
personTrain.setTrainEndDate(sfm.parse(contractorTrain.getStr("trainEndDate")));
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
trainService.saveOrUpdateByField(personTrain,"pmContractorTrainId");
|
||||
});
|
||||
}
|
||||
try {
|
||||
//保存原始图片
|
||||
String userFileUrl = globalValue.getImagesDir() + "/" +
|
||||
|
@ -85,7 +230,7 @@ public class PersonSynchronousTask implements ITask{
|
|||
tenPerson.getPersonId().toString() + "/";
|
||||
String orgImageFileName = userFileUrl + "o_" + UUIDUtil.uuid() + ".jpg";
|
||||
|
||||
byte[] b = Base64.getDecoder().decode(person.getStr("attachment").replace("\n",""));
|
||||
byte[] b = Base64.getDecoder().decode(person.getStr("attachment").replace("\n", ""));
|
||||
|
||||
InputStream inputStream = new ByteArrayInputStream(b);
|
||||
PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1);
|
||||
|
@ -97,17 +242,11 @@ public class PersonSynchronousTask implements ITask{
|
|||
tenPerson.setOrgImage(orgImageFileName);
|
||||
tenPerson.setFaceImage(orgImageFileName);
|
||||
|
||||
tenPersonService.save3d(tenPerson);
|
||||
|
||||
tenPersonService.saveOrUpdateByField(tenPerson,"idCard");
|
||||
UserInfo userInfo = new UserInfo();
|
||||
UserRamGroup.addUser(userInfo,tenPerson.getOrgId()!=null?UserRamGroup.getOrgCellMap(tenPerson.getOrgId()):null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
flag = false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.shapelight.modules.face.util.Base64Util;
|
|||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamCache;
|
||||
import net.shapelight.modules.face.util.UserRamGroup;
|
||||
import net.shapelight.modules.feignClient.CxFeignClient;
|
||||
import net.shapelight.modules.nettyapi.service.ServerApiService;
|
||||
import net.shapelight.modules.sys.controller.AbstractController;
|
||||
import net.shapelight.modules.sys.entity.SysUserEntity;
|
||||
|
@ -102,6 +103,8 @@ public class TenPersonController extends AbstractController {
|
|||
private TenLabelService tenLabelService;
|
||||
@Autowired
|
||||
private HttpServletResponse response;
|
||||
@Autowired
|
||||
private CxFeignClient cxFeignClient;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -324,7 +327,7 @@ public class TenPersonController extends AbstractController {
|
|||
TenUserScopeEntity scope = tenUserScopeService.getOne(new QueryWrapper<TenUserScopeEntity>().eq("user_id", user.getUserId()));
|
||||
params.put("cellId", scope.getCellId().toString());
|
||||
}
|
||||
params.put("personType", Constant.PERSON_TYPE_BLACK);
|
||||
params.put("isBlacklistPersonnel", 1);
|
||||
PageUtils page = tenPersonService.queryPage(params);
|
||||
return R.ok().put("data", page);
|
||||
}
|
||||
|
@ -468,11 +471,11 @@ public class TenPersonController extends AbstractController {
|
|||
}
|
||||
|
||||
|
||||
TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(),
|
||||
/*TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(),
|
||||
tenPerson.getRoomId(),tenPerson.getCellId());
|
||||
if(tenPersonEntity!=null){
|
||||
return R.error("姓名在此房间已存在");
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
if(tenPerson.getIdCard()!=null){
|
||||
|
@ -501,6 +504,25 @@ public class TenPersonController extends AbstractController {
|
|||
if (res==2) {
|
||||
return R.error("照片未检测到人脸");
|
||||
}
|
||||
if(tenPerson.getPersonType() == Constant.PERSON_TYPE_GUEST) {
|
||||
|
||||
Map<String,Object> params = new HashMap<>();
|
||||
params.put("pmVisitorPersonnelId","");
|
||||
params.put("orgId",tenPerson.getOrgId());
|
||||
params.put("orgName",tenPerson.getCellName());
|
||||
params.put("personnelName",tenPerson.getName());
|
||||
params.put("personnelId",tenPerson.getOpenId());
|
||||
params.put("personnelCardId",tenPerson.getIdCard());
|
||||
params.put("enterValidPeriod",tenPerson.getLiveStart().toString());
|
||||
params.put("enterValidPeriodEnd",tenPerson.getLiveEnd().toString());
|
||||
params.put("mobile",tenPerson.getMobile());
|
||||
params.put("isEnterSulfurArea",tenPerson.getIsEnterSulfurArea()==1?"是":"否");
|
||||
params.put("isProtectDevice",tenPerson.getIsProtectDevice()==1?"是":"否");
|
||||
params.put("isBlacklistPersonnel","否");
|
||||
params.put("isWatchSafeVideo",tenPerson.getIsWatchSafeVideo()==1?"是":"否");
|
||||
params.put("attachment",tenPerson.getIsWatchSafeVideo());
|
||||
cxFeignClient.savePmVisitorPersonnel(params);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -109,4 +109,6 @@ public class TenVideoController extends AbstractController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -163,5 +163,7 @@ public interface TenPersonService extends IService<TenPersonEntity> {
|
|||
|
||||
List<TenDeptPersonCount> findDeptCount(String tenantId);
|
||||
|
||||
void saveOrUpdateByField(TenPersonEntity entity,String fieldName);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import io.minio.MinioClient;
|
|||
import io.minio.PutObjectOptions;
|
||||
import io.minio.errors.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import net.shapelight.common.config.GlobalValue;
|
||||
import net.shapelight.common.config.MinioConfig;
|
||||
import net.shapelight.common.utils.*;
|
||||
|
@ -29,36 +28,29 @@ import net.shapelight.modules.face.entity.UserCompareInfo;
|
|||
import net.shapelight.modules.face.service.FaceEngineService;
|
||||
import net.shapelight.modules.face.util.Base64Util;
|
||||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamCache;
|
||||
import net.shapelight.modules.face.util.UserRamGroup;
|
||||
import net.shapelight.modules.nettyapi.service.ServerApiService;
|
||||
import net.shapelight.modules.sys.entity.SysUserEntity;
|
||||
import net.shapelight.modules.sys.service.SysUserService;
|
||||
import net.shapelight.modules.ten.controller.TenUserController;
|
||||
import net.shapelight.modules.ten.entity.*;
|
||||
import net.shapelight.modules.ten.service.*;
|
||||
import net.shapelight.modules.ten.vo.PersonExcelModel;
|
||||
import net.shapelight.modules.vo.*;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
@ -2720,4 +2712,23 @@ public class TenPersonServiceImpl extends ServiceImpl<TenPersonDao,TenPersonEnti
|
|||
public List<TenDeptPersonCount> findDeptCount(String tenantId) {
|
||||
return tenPersonDao.findDeptCount(tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可以根据其他字段批量更新或新增
|
||||
*
|
||||
* @param entity 对象
|
||||
* @param fieldName 字段名称
|
||||
* @return 操作结果
|
||||
*/
|
||||
public void saveOrUpdateByField(TenPersonEntity entity, String fieldName) {
|
||||
QueryWrapper<TenPersonEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(fieldName, MyBeanUtils.getFieldValueByName(entity,fieldName));
|
||||
TenPersonEntity existEntity = this.getOne(queryWrapper);
|
||||
|
||||
if (existEntity == null) {
|
||||
this.save(entity);
|
||||
} else {
|
||||
this.updateById(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ spring:
|
|||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.10.20:3306/cell_db_v10_pv_xianyang2?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://192.168.10.20:3306/cell_db_v12_changqing?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true
|
||||
username: user
|
||||
password: user@server001
|
||||
initial-size: 150
|
||||
|
@ -36,5 +36,7 @@ spring:
|
|||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
global:
|
||||
global:
|
||||
Url:
|
||||
qhseUrl: https://wstest.yunuat.cqyt.petrochina/ZLSTS/v1
|
||||
rtspUrl: rtsp://192.168.100.102:554/main
|
||||
|
|
|
@ -105,9 +105,9 @@ shapelight:
|
|||
config:
|
||||
arcface-sdk:
|
||||
version: 4.1
|
||||
app-id: DEnAZa1bWXcaAxyWUg33QZaKCmMkNmrQxuKZJQGmZsHJ
|
||||
sdk-key: vWbvUyStZeartSaM6QoTzPYWFpSaj4uhfDmRifSzCd6
|
||||
active-key: 82G1-11QA-713Y-8NB4
|
||||
app-id: SUQLGn78W5o7StEEbm6WTTfaMgAxSsN8HwJziApVyNN
|
||||
sdk-key: 7dJ9RqEhc3mPCatuUceKjgYwZXfX83n3QHz4xb6biPiG
|
||||
active-key: 86L1-11TK-313B-Y8KG
|
||||
active-file:
|
||||
detect-pool-size: 16
|
||||
compare-pool-size: 16
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<result property="openPassword" column="open_password"/>
|
||||
<result property="thirdId" column="third_id"/>
|
||||
<result property="tenantId" column="tenantId"/>
|
||||
<result property="orgId" column="org_id"/>
|
||||
<association property="areaName" javaType="String"
|
||||
select="net.shapelight.modules.ten.dao.TenAreaDao.getAreaName"
|
||||
column="areaId=area_id">
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.shapelight.modules.ten.dao.TenPersonCertDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="net.shapelight.modules.ten.entity.TenPersonCert">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="person" column="person" jdbcType="BIGINT"/>
|
||||
<result property="pmContractorCertId" column="pm_contractor_cert_id" jdbcType="VARCHAR"/>
|
||||
<result property="certName" column="cert_name" jdbcType="VARCHAR"/>
|
||||
<result property="certObtainDate" column="cert_obtain_date" jdbcType="TIMESTAMP"/>
|
||||
<result property="effectiveDate" column="effective_date" jdbcType="TIMESTAMP"/>
|
||||
<result property="certType" column="cert_type" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,person,pm_contractor_cert_id,
|
||||
cert_name,cert_obtain_date,effective_date,
|
||||
cert_type
|
||||
</sql>
|
||||
</mapper>
|
|
@ -0,0 +1,226 @@
|
|||
package gb;
|
||||
|
||||
import com.arcsoft.face.*;
|
||||
import com.arcsoft.face.enums.*;
|
||||
import com.arcsoft.face.toolkit.ImageFactory;
|
||||
import com.arcsoft.face.toolkit.ImageInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.arcsoft.face.toolkit.ImageInfoEx;
|
||||
|
||||
public class FaceEngineTest {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
//激活码,从官网获取
|
||||
String appId = "";
|
||||
String sdkKey = "";
|
||||
String activeKey = "";
|
||||
|
||||
System.err.println("注意,如果返回的errorCode不为0,可查看com.arcsoft.face.enums.ErrorInfo类获取相应的错误信息");
|
||||
|
||||
//人脸识别引擎库存放路径
|
||||
FaceEngine faceEngine = new FaceEngine("D:\\xituCode\\cell\\shapelight-admin\\src\\main\\resources\\libs\\4.1\\WIN64");
|
||||
//激活引擎
|
||||
int errorCode = faceEngine.activeOnline(appId, sdkKey, activeKey);
|
||||
System.out.println("引擎激活errorCode:" + errorCode);
|
||||
|
||||
ActiveDeviceInfo activeDeviceInfo = new ActiveDeviceInfo();
|
||||
//采集设备信息(可离线)
|
||||
errorCode = faceEngine.getActiveDeviceInfo(activeDeviceInfo);
|
||||
System.out.println("采集设备信息errorCode:" + errorCode);
|
||||
System.out.println("设备信息:" + activeDeviceInfo.getDeviceInfo());
|
||||
|
||||
// faceEngine.activeOffline("d:\\ArcFacePro64.dat.offline");
|
||||
|
||||
ActiveFileInfo activeFileInfo = new ActiveFileInfo();
|
||||
errorCode = faceEngine.getActiveFileInfo(activeFileInfo);
|
||||
System.out.println("获取激活文件errorCode:" + errorCode);
|
||||
System.out.println("激活文件信息:" + activeFileInfo.toString());
|
||||
|
||||
//引擎配置
|
||||
EngineConfiguration engineConfiguration = new EngineConfiguration();
|
||||
engineConfiguration.setDetectMode(DetectMode.ASF_DETECT_MODE_IMAGE);
|
||||
engineConfiguration.setDetectFaceOrientPriority(DetectOrient.ASF_OP_ALL_OUT);
|
||||
engineConfiguration.setDetectFaceMaxNum(10);
|
||||
//功能配置
|
||||
FunctionConfiguration functionConfiguration = new FunctionConfiguration();
|
||||
functionConfiguration.setSupportAge(true);
|
||||
functionConfiguration.setSupportFaceDetect(true);
|
||||
functionConfiguration.setSupportFaceRecognition(true);
|
||||
functionConfiguration.setSupportGender(true);
|
||||
functionConfiguration.setSupportLiveness(true);
|
||||
functionConfiguration.setSupportIRLiveness(true);
|
||||
functionConfiguration.setSupportImageQuality(true);
|
||||
functionConfiguration.setSupportMaskDetect(true);
|
||||
functionConfiguration.setSupportUpdateFaceData(true);
|
||||
engineConfiguration.setFunctionConfiguration(functionConfiguration);
|
||||
|
||||
//初始化引擎
|
||||
errorCode = faceEngine.init(engineConfiguration);
|
||||
System.out.println("初始化引擎errorCode:" + errorCode);
|
||||
VersionInfo version = faceEngine.getVersion();
|
||||
System.out.println(version);
|
||||
|
||||
//人脸检测
|
||||
ImageInfo imageInfo = ImageFactory.getRGBData(new File("C:\\Users\\zhangbo\\OneDrive\\图片\\Camera Roll\\1寸相片.jpg"));
|
||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||
errorCode = faceEngine.detectFaces(imageInfo, faceInfoList);
|
||||
System.out.println("人脸检测errorCode:" + errorCode);
|
||||
System.out.println("检测到人脸数:" + faceInfoList.size());
|
||||
|
||||
ImageQuality imageQuality = new ImageQuality();
|
||||
errorCode = faceEngine.imageQualityDetect(imageInfo, faceInfoList.get(0), 0, imageQuality);
|
||||
System.out.println("图像质量检测errorCode:" + errorCode);
|
||||
System.out.println("图像质量分数:" + imageQuality.getFaceQuality());
|
||||
|
||||
//特征提取
|
||||
FaceFeature faceFeature = new FaceFeature();
|
||||
errorCode = faceEngine.extractFaceFeature(imageInfo, faceInfoList.get(0), ExtractType.REGISTER, 0, faceFeature);
|
||||
System.out.println("特征提取errorCode:" + errorCode);
|
||||
|
||||
//人脸检测2
|
||||
ImageInfo imageInfo2 = ImageFactory.getRGBData(new File("d:\\2.jpg"));
|
||||
List<FaceInfo> faceInfoList2 = new ArrayList<FaceInfo>();
|
||||
errorCode = faceEngine.detectFaces(imageInfo2, faceInfoList2);
|
||||
System.out.println("人脸检测errorCode:" + errorCode);
|
||||
System.out.println("检测到人脸数:" + faceInfoList.size());
|
||||
|
||||
//特征提取2
|
||||
FaceFeature faceFeature2 = new FaceFeature();
|
||||
errorCode = faceEngine.extractFaceFeature(imageInfo2, faceInfoList2.get(0), ExtractType.RECOGNIZE, 0, faceFeature2);
|
||||
System.out.println("特征提取errorCode:" + errorCode);
|
||||
|
||||
//特征比对
|
||||
FaceFeature targetFaceFeature = new FaceFeature();
|
||||
targetFaceFeature.setFeatureData(faceFeature.getFeatureData());
|
||||
FaceFeature sourceFaceFeature = new FaceFeature();
|
||||
sourceFaceFeature.setFeatureData(faceFeature2.getFeatureData());
|
||||
FaceSimilar faceSimilar = new FaceSimilar();
|
||||
|
||||
errorCode = faceEngine.compareFaceFeature(targetFaceFeature, sourceFaceFeature, faceSimilar);
|
||||
System.out.println("特征比对errorCode:" + errorCode);
|
||||
System.out.println("人脸相似度:" + faceSimilar.getScore());
|
||||
|
||||
|
||||
//人脸属性检测
|
||||
FunctionConfiguration configuration = new FunctionConfiguration();
|
||||
configuration.setSupportAge(true);
|
||||
configuration.setSupportGender(true);
|
||||
configuration.setSupportLiveness(true);
|
||||
configuration.setSupportMaskDetect(true);
|
||||
errorCode = faceEngine.process(imageInfo, faceInfoList, configuration);
|
||||
System.out.println("图像属性处理errorCode:" + errorCode);
|
||||
|
||||
//性别检测
|
||||
List<GenderInfo> genderInfoList = new ArrayList<GenderInfo>();
|
||||
errorCode = faceEngine.getGender(genderInfoList);
|
||||
System.out.println("性别:" + genderInfoList.get(0).getGender());
|
||||
|
||||
//年龄检测
|
||||
List<AgeInfo> ageInfoList = new ArrayList<AgeInfo>();
|
||||
errorCode = faceEngine.getAge(ageInfoList);
|
||||
System.out.println("年龄:" + ageInfoList.get(0).getAge());
|
||||
|
||||
//活体检测
|
||||
List<LivenessInfo> livenessInfoList = new ArrayList<LivenessInfo>();
|
||||
errorCode = faceEngine.getLiveness(livenessInfoList);
|
||||
System.out.println("活体:" + livenessInfoList.get(0).getLiveness());
|
||||
|
||||
//口罩检测
|
||||
List<MaskInfo> maskInfoList = new ArrayList<MaskInfo>();
|
||||
errorCode = faceEngine.getMask(maskInfoList);
|
||||
System.out.println("口罩:" + maskInfoList.get(0).getMask());
|
||||
|
||||
|
||||
//IR属性处理
|
||||
ImageInfo imageInfoGray = ImageFactory.getGrayData(new File("d:\\IR_480p.jpg"));
|
||||
List<FaceInfo> faceInfoListGray = new ArrayList<FaceInfo>();
|
||||
errorCode = faceEngine.detectFaces(imageInfoGray, faceInfoListGray);
|
||||
|
||||
FunctionConfiguration configuration2 = new FunctionConfiguration();
|
||||
configuration2.setSupportIRLiveness(true);
|
||||
errorCode = faceEngine.processIr(imageInfoGray, faceInfoListGray, configuration2);
|
||||
//IR活体检测
|
||||
List<IrLivenessInfo> irLivenessInfo = new ArrayList<>();
|
||||
errorCode = faceEngine.getLivenessIr(irLivenessInfo);
|
||||
System.out.println("IR活体:" + irLivenessInfo.get(0).getLiveness());
|
||||
|
||||
//获取激活文件信息
|
||||
ActiveFileInfo activeFileInfo2 = new ActiveFileInfo();
|
||||
errorCode = faceEngine.getActiveFileInfo(activeFileInfo2);
|
||||
|
||||
//更新人脸数据
|
||||
errorCode = faceEngine.updateFaceData(imageInfo, faceInfoList);
|
||||
|
||||
//高级人脸图像处理接口
|
||||
ImageInfoEx imageInfoEx = new ImageInfoEx();
|
||||
imageInfoEx.setHeight(imageInfo.getHeight());
|
||||
imageInfoEx.setWidth(imageInfo.getWidth());
|
||||
imageInfoEx.setImageFormat(imageInfo.getImageFormat());
|
||||
imageInfoEx.setImageDataPlanes(new byte[][]{imageInfo.getImageData()});
|
||||
imageInfoEx.setImageStrides(new int[]{imageInfo.getWidth() * 3});
|
||||
List<FaceInfo> faceInfoList1 = new ArrayList<>();
|
||||
errorCode = faceEngine.detectFaces(imageInfoEx, DetectModel.ASF_DETECT_MODEL_RGB, faceInfoList1);
|
||||
ImageQuality imageQuality1 = new ImageQuality();
|
||||
errorCode = faceEngine.imageQualityDetect(imageInfoEx, faceInfoList1.get(0), 0, imageQuality1);
|
||||
FunctionConfiguration fun = new FunctionConfiguration();
|
||||
fun.setSupportAge(true);
|
||||
errorCode = faceEngine.process(imageInfoEx, faceInfoList1, fun);
|
||||
List<AgeInfo> ageInfoList1 = new ArrayList<>();
|
||||
int age = faceEngine.getAge(ageInfoList1);
|
||||
FaceFeature feature = new FaceFeature();
|
||||
errorCode = faceEngine.extractFaceFeature(imageInfoEx, faceInfoList1.get(0), ExtractType.REGISTER, 0, feature);
|
||||
errorCode = faceEngine.updateFaceData(imageInfoEx, faceInfoList1);
|
||||
|
||||
//设置活体测试
|
||||
errorCode = faceEngine.setLivenessParam(0.5f, 0.7f, 0.3f);
|
||||
System.out.println("设置活体活体阈值errorCode:" + errorCode);
|
||||
|
||||
LivenessParam livenessParam=new LivenessParam();
|
||||
errorCode = faceEngine.getLivenessParam(livenessParam);
|
||||
|
||||
//注册人脸信息1
|
||||
FaceFeatureInfo faceFeatureInfo = new FaceFeatureInfo();
|
||||
faceFeatureInfo.setSearchId(5);
|
||||
faceFeatureInfo.setFaceTag("FeatureData1");
|
||||
faceFeatureInfo.setFeatureData(faceFeature.getFeatureData());
|
||||
errorCode = faceEngine.registerFaceFeature(faceFeatureInfo);
|
||||
|
||||
//注册人脸信息2
|
||||
FaceFeatureInfo faceFeatureInfo2 = new FaceFeatureInfo();
|
||||
faceFeatureInfo2.setSearchId(6);
|
||||
faceFeatureInfo2.setFaceTag("FeatureData2");
|
||||
faceFeatureInfo2.setFeatureData(faceFeature2.getFeatureData());
|
||||
errorCode = faceEngine.registerFaceFeature(faceFeatureInfo2);
|
||||
|
||||
//获取注册人脸个数
|
||||
FaceSearchCount faceSearchCount = new FaceSearchCount();
|
||||
errorCode = faceEngine.getFaceCount(faceSearchCount);
|
||||
System.out.println("注册人脸个数:" + faceSearchCount.getCount());
|
||||
|
||||
//搜索最相似人脸
|
||||
SearchResult searchResult = new SearchResult();
|
||||
errorCode = faceEngine.searchFaceFeature(faceFeature, CompareModel.LIFE_PHOTO, searchResult);
|
||||
System.out.println("最相似人脸Id:" + searchResult.getFaceFeatureInfo().getSearchId());
|
||||
|
||||
//更新人脸信息
|
||||
FaceFeatureInfo faceFeatureInfo3 = new FaceFeatureInfo();
|
||||
faceFeatureInfo3.setSearchId(6);
|
||||
faceFeatureInfo3.setFaceTag("FeatureData2Update");
|
||||
faceFeatureInfo3.setFeatureData(faceFeature2.getFeatureData());
|
||||
errorCode = faceEngine.updateFaceFeature(faceFeatureInfo3);
|
||||
|
||||
//移除人脸信息
|
||||
errorCode = faceEngine.removeFaceFeature(6);
|
||||
|
||||
//引擎卸载
|
||||
errorCode = faceEngine.unInit();
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue