v10:特征库分组,根据小区id
This commit is contained in:
parent
88273e1a3d
commit
75cc8af2cb
|
@ -1,11 +1,17 @@
|
|||
package net.shapelight.modules.face;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.common.config.GlobalValue;
|
||||
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.ten.entity.TenCellEntity;
|
||||
import net.shapelight.modules.ten.entity.TenPersonEntity;
|
||||
import net.shapelight.modules.ten.service.TenCellService;
|
||||
import net.shapelight.modules.ten.service.TenPersonService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
|
@ -26,6 +32,10 @@ public class FaceEngineAutoRun implements ApplicationRunner {
|
|||
private FaceEngineService faceEngineService;
|
||||
@Autowired
|
||||
private TenPersonService tenPersonService;
|
||||
@Autowired
|
||||
private TenCellService tenCellService;
|
||||
@Autowired
|
||||
private GlobalValue globalValue;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
|
@ -52,28 +62,59 @@ public class FaceEngineAutoRun implements ApplicationRunner {
|
|||
// }
|
||||
// }
|
||||
|
||||
int count = tenPersonService.findCount();
|
||||
int pageSize = 1000;
|
||||
int page = count/pageSize;
|
||||
if(count%1000!=0){
|
||||
page = page+1;
|
||||
}
|
||||
int faceCount = 0;
|
||||
for (int i = 0; i < page; i++) {
|
||||
int start = i*1000;
|
||||
List<TenPersonEntity> listPage = tenPersonService.listPage(start,1000);
|
||||
for(TenPersonEntity personEntity: listPage){
|
||||
if(personEntity.getFeature()!=null && personEntity.getFeature().length()>0){
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
userInfo.setName(personEntity.getName());
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(personEntity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamCache.addUser(userInfo);
|
||||
faceCount++;
|
||||
// int count = tenPersonService.findCount();
|
||||
// int pageSize = 1000;
|
||||
// int page = count/pageSize;
|
||||
// if(count%1000!=0){
|
||||
// page = page+1;
|
||||
// }
|
||||
// int faceCount = 0;
|
||||
// for (int i = 0; i < page; i++) {
|
||||
// int start = i*1000;
|
||||
// List<TenPersonEntity> listPage = tenPersonService.listPage(start,1000);
|
||||
// for(TenPersonEntity personEntity: listPage){
|
||||
// if(personEntity.getFeature()!=null && personEntity.getFeature().length()>0){
|
||||
// UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
// userInfo.setName(personEntity.getName());
|
||||
// userInfo.setFaceFeature(Base64Util.base64ToBytes(personEntity.getFeature()));
|
||||
// //这边注册到内存缓存中
|
||||
// UserRamCache.addUser(userInfo);
|
||||
// faceCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
List<TenCellEntity> cellList = tenCellService.list(new QueryWrapper<TenCellEntity>()
|
||||
.eq("tenant_id",globalValue.getTenantId())
|
||||
.eq("delete_flag",0));
|
||||
for(TenCellEntity cellEntity: cellList){
|
||||
String cellId = cellEntity.getCellId()+"";
|
||||
UserRamGroup.addCell(cellId);
|
||||
int count = tenPersonService.findCount(cellId);
|
||||
int pageSize = 1000;
|
||||
int page = count/pageSize;
|
||||
if(count%1000!=0){
|
||||
page = page+1;
|
||||
}
|
||||
int faceCount = 0;
|
||||
for (int i = 0; i < page; i++) {
|
||||
int start = i*1000;
|
||||
List<TenPersonEntity> listPage = tenPersonService.listPage(start,1000, cellId);
|
||||
for(TenPersonEntity personEntity: listPage){
|
||||
if(personEntity.getFeature()!=null && personEntity.getFeature().length()>0){
|
||||
UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
userInfo.setName(personEntity.getName());
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(personEntity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamGroup.addUser(userInfo,cellId);
|
||||
faceCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug(cellEntity.getName()+":初始化人脸库完成,共 "+faceCount+" 人");
|
||||
}
|
||||
log.debug("初始化人脸库完成,共 "+faceCount+" 人");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,10 @@ package net.shapelight.modules.face.entity;
|
|||
|
||||
|
||||
import lombok.Data;
|
||||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamCache;
|
||||
|
||||
@Data
|
||||
public class UserCompareInfo extends UserRamCache.UserInfo {
|
||||
public class UserCompareInfo extends UserInfo {
|
||||
private Float similar;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.arcsoft.face.enums.ExtractType;
|
|||
import com.arcsoft.face.toolkit.ImageInfo;
|
||||
import net.shapelight.modules.face.entity.ProcessInfo;
|
||||
import net.shapelight.modules.face.entity.UserCompareInfo;
|
||||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamCache;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -19,12 +20,10 @@ public interface FaceEngineService {
|
|||
|
||||
byte[] extractFaceFeature(ImageInfo imageInfo, FaceInfo faceInfo, ExtractType extractType);
|
||||
|
||||
List<UserCompareInfo> faceRecognition(byte[] faceFeature, List<UserRamCache.UserInfo> userInfoList, float passRate) ;
|
||||
List<UserCompareInfo> faceRecognition(byte[] faceFeature, List<UserInfo> userInfoList, float passRate) ;
|
||||
|
||||
List<ProcessInfo> process(ImageInfo imageInfo, List<FaceInfo> faceInfoList);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.shapelight.modules.face.enums.ErrorCodeEnum;
|
|||
import net.shapelight.modules.face.factory.FaceEngineFactory;
|
||||
import net.shapelight.modules.face.rpc.BusinessException;
|
||||
import net.shapelight.modules.face.service.FaceEngineService;
|
||||
import net.shapelight.modules.face.util.UserInfo;
|
||||
import net.shapelight.modules.face.util.UserRamCache;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
|
@ -220,15 +221,15 @@ public class FaceEngineServiceImpl implements FaceEngineService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<UserCompareInfo> faceRecognition(byte[] faceFeature, List<UserRamCache.UserInfo> userInfoList, float passRate) {
|
||||
public List<UserCompareInfo> faceRecognition(byte[] faceFeature, List<UserInfo> userInfoList, float passRate) {
|
||||
List<UserCompareInfo> resultUserInfoList = Lists.newLinkedList();//识别到的人脸列表
|
||||
|
||||
FaceFeature targetFaceFeature = new FaceFeature();
|
||||
targetFaceFeature.setFeatureData(faceFeature);
|
||||
|
||||
List<List<UserRamCache.UserInfo>> faceUserInfoPartList = Lists.partition(userInfoList, 1000);//分成1000一组,多线程处理
|
||||
List<List<UserInfo>> faceUserInfoPartList = Lists.partition(userInfoList, 1000);//分成1000一组,多线程处理
|
||||
CompletionService<List<UserCompareInfo>> completionService = new ExecutorCompletionService(compareExecutorService);
|
||||
for (List<UserRamCache.UserInfo> part : faceUserInfoPartList) {
|
||||
for (List<UserInfo> part : faceUserInfoPartList) {
|
||||
completionService.submit(new CompareFaceTask(part, targetFaceFeature, passRate));
|
||||
}
|
||||
for (int i = 0; i < faceUserInfoPartList.size(); i++) {
|
||||
|
@ -248,6 +249,7 @@ public class FaceEngineServiceImpl implements FaceEngineService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ProcessInfo> process(ImageInfo imageInfo, List<FaceInfo> faceInfoList) {
|
||||
FaceEngine faceEngine = null;
|
||||
|
@ -303,12 +305,12 @@ public class FaceEngineServiceImpl implements FaceEngineService {
|
|||
|
||||
private class CompareFaceTask implements Callable<List<UserCompareInfo>> {
|
||||
|
||||
private List<UserRamCache.UserInfo> userInfoList;
|
||||
private List<UserInfo> userInfoList;
|
||||
private FaceFeature targetFaceFeature;
|
||||
private float passRate;
|
||||
|
||||
|
||||
public CompareFaceTask(List<UserRamCache.UserInfo> userInfoList, FaceFeature targetFaceFeature, float passRate) {
|
||||
public CompareFaceTask(List<UserInfo> userInfoList, FaceFeature targetFaceFeature, float passRate) {
|
||||
this.userInfoList = userInfoList;
|
||||
this.targetFaceFeature = targetFaceFeature;
|
||||
this.passRate = passRate;
|
||||
|
@ -320,7 +322,7 @@ public class FaceEngineServiceImpl implements FaceEngineService {
|
|||
List<UserCompareInfo> resultUserInfoList = Lists.newLinkedList();//识别到的人脸列表
|
||||
try {
|
||||
faceEngine = faceEngineComparePool.borrowObject();
|
||||
for (UserRamCache.UserInfo userInfo : userInfoList) {
|
||||
for (UserInfo userInfo : userInfoList) {
|
||||
FaceFeature sourceFaceFeature = new FaceFeature();
|
||||
sourceFaceFeature.setFeatureData(userInfo.getFaceFeature());
|
||||
FaceSimilar faceSimilar = new FaceSimilar();
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package net.shapelight.modules.face.util;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserInfo {
|
||||
private String faceId;
|
||||
private String name;
|
||||
private byte[] faceFeature;
|
||||
}
|
|
@ -10,51 +10,51 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
|
||||
public class UserRamCache {
|
||||
|
||||
private static final ConcurrentHashMap<String, UserInfo> USER_INFO_MAP = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, UserInfo> USER_INFO_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Set<Listener> REGISTER = new CopyOnWriteArraySet<>();
|
||||
private final Set<Listener> REGISTER = new CopyOnWriteArraySet<>();
|
||||
|
||||
public static void addUser(UserInfo userInfo) {
|
||||
public void addUser(UserInfo userInfo) {
|
||||
USER_INFO_MAP.put(userInfo.getFaceId(), userInfo);
|
||||
for (Listener listener : REGISTER) {
|
||||
listener.onAdd(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeUser(String faceId) {
|
||||
public void removeUser(String faceId) {
|
||||
UserInfo userInfo = USER_INFO_MAP.remove(faceId);
|
||||
for (Listener listener : REGISTER) {
|
||||
listener.onRemove(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<UserInfo> getUserList() {
|
||||
public List<UserInfo> getUserList() {
|
||||
List<UserInfo> userInfoList = Lists.newLinkedList();
|
||||
userInfoList.addAll(USER_INFO_MAP.values());
|
||||
return userInfoList;
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
public void clear(){
|
||||
USER_INFO_MAP.clear();
|
||||
REGISTER.clear();
|
||||
}
|
||||
|
||||
public static void addListener(Listener listener) {
|
||||
public void addListener(Listener listener) {
|
||||
REGISTER.add(listener);
|
||||
}
|
||||
|
||||
public static void removeListener(Listener listener) {
|
||||
public void removeListener(Listener listener) {
|
||||
REGISTER.remove(listener);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class UserInfo {
|
||||
|
||||
private String faceId;
|
||||
private String name;
|
||||
private byte[] faceFeature;
|
||||
|
||||
}
|
||||
// @Data
|
||||
// public class UserInfo {
|
||||
//
|
||||
// private String faceId;
|
||||
// private String name;
|
||||
// private byte[] faceFeature;
|
||||
//
|
||||
// }
|
||||
|
||||
public interface Listener {
|
||||
default void onAdd(UserInfo userInfo) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package net.shapelight.modules.face.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class UserRamGroup {
|
||||
|
||||
private static final ConcurrentHashMap<String, UserRamCache> USER_RAM_GROUP_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
public static void addCell(String cellId){
|
||||
UserRamCache cell = new UserRamCache();
|
||||
USER_RAM_GROUP_MAP.put(cellId,cell);
|
||||
}
|
||||
|
||||
public static void removeCell(String cellId){
|
||||
USER_RAM_GROUP_MAP.remove(cellId);
|
||||
}
|
||||
|
||||
public static void addUser(UserInfo userInfo, String cellId) {
|
||||
USER_RAM_GROUP_MAP.get(cellId).addUser(userInfo);
|
||||
}
|
||||
|
||||
public static void removeUser(String faceId, String cellId) {
|
||||
USER_RAM_GROUP_MAP.get(cellId).removeUser(faceId);
|
||||
}
|
||||
|
||||
public static List<UserInfo> getUserList(String cellId) {
|
||||
return USER_RAM_GROUP_MAP.get(cellId).getUserList();
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
USER_RAM_GROUP_MAP.clear();
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import net.shapelight.modules.face.entity.UserCompareInfo;
|
|||
import net.shapelight.modules.face.rpc.Response;
|
||||
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 org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -71,47 +72,47 @@ public class FaceController {
|
|||
/*
|
||||
人脸添加
|
||||
*/
|
||||
@RequestMapping(value = "/faceAdd", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Response faceAdd(@RequestBody FaceAddReqDTO faceAddReqDTO) {
|
||||
String image = faceAddReqDTO.getImage();
|
||||
|
||||
byte[] bytes = Base64Util.base64ToBytes(image);
|
||||
ImageInfo rgbData = ImageFactory.getRGBData(bytes);
|
||||
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(rgbData);
|
||||
if (CollectionUtil.isNotEmpty(faceInfoList)) {
|
||||
for (FaceInfo faceInfo : faceInfoList) {
|
||||
FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
|
||||
faceRecognitionResDTO.setRect(faceInfo.getRect());
|
||||
byte[] feature = faceEngineService.extractFaceFeature(rgbData, faceInfo,ExtractType.REGISTER);
|
||||
if (feature != null) {
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(faceAddReqDTO.getName());
|
||||
userInfo.setName(faceAddReqDTO.getName());
|
||||
userInfo.setFaceFeature(feature);
|
||||
//这边注册到内存缓存中,也可以根据业务,注册到数据库中
|
||||
UserRamCache.addUser(userInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Response.newSuccessResponse("");
|
||||
}
|
||||
// @RequestMapping(value = "/faceAdd", method = RequestMethod.POST)
|
||||
// @ResponseBody
|
||||
// public Response faceAdd(@RequestBody FaceAddReqDTO faceAddReqDTO) {
|
||||
// String image = faceAddReqDTO.getImage();
|
||||
//
|
||||
// byte[] bytes = Base64Util.base64ToBytes(image);
|
||||
// ImageInfo rgbData = ImageFactory.getRGBData(bytes);
|
||||
// List<FaceInfo> faceInfoList = faceEngineService.detectFaces(rgbData);
|
||||
// if (CollectionUtil.isNotEmpty(faceInfoList)) {
|
||||
// for (FaceInfo faceInfo : faceInfoList) {
|
||||
// FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
|
||||
// faceRecognitionResDTO.setRect(faceInfo.getRect());
|
||||
// byte[] feature = faceEngineService.extractFaceFeature(rgbData, faceInfo,ExtractType.REGISTER);
|
||||
// if (feature != null) {
|
||||
// UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(faceAddReqDTO.getName());
|
||||
// userInfo.setName(faceAddReqDTO.getName());
|
||||
// userInfo.setFaceFeature(feature);
|
||||
// //这边注册到内存缓存中,也可以根据业务,注册到数据库中
|
||||
// UserRamCache.addUser(userInfo);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return Response.newSuccessResponse("");
|
||||
// }
|
||||
|
||||
|
||||
@RequestMapping(value = "/getFaceList", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Response<List<GetFaceListResDTO>> getFaceList() {
|
||||
List<UserRamCache.UserInfo> userList = UserRamCache.getUserList();
|
||||
List<GetFaceListResDTO> resDTOS = new LinkedList<>();
|
||||
for (UserRamCache.UserInfo userInfo : userList) {
|
||||
GetFaceListResDTO face = new GetFaceListResDTO();
|
||||
face.setId(userInfo.getFaceId());
|
||||
face.setName(userInfo.getName());
|
||||
face.setUrl("/images/" + face.getId() + ".jpg");
|
||||
resDTOS.add(face);
|
||||
}
|
||||
return Response.newSuccessResponse(resDTOS);
|
||||
}
|
||||
// @RequestMapping(value = "/getFaceList", method = RequestMethod.POST)
|
||||
// @ResponseBody
|
||||
// public Response<List<GetFaceListResDTO>> getFaceList() {
|
||||
// List<UserInfo> userList = UserRamCache.getUserList();
|
||||
// List<GetFaceListResDTO> resDTOS = new LinkedList<>();
|
||||
// for (UserInfo userInfo : userList) {
|
||||
// GetFaceListResDTO face = new GetFaceListResDTO();
|
||||
// face.setId(userInfo.getFaceId());
|
||||
// face.setName(userInfo.getName());
|
||||
// face.setUrl("/images/" + face.getId() + ".jpg");
|
||||
// resDTOS.add(face);
|
||||
// }
|
||||
// return Response.newSuccessResponse(resDTOS);
|
||||
// }
|
||||
|
||||
|
||||
// @RequestMapping(value = "/recognition", method = RequestMethod.POST)
|
||||
|
@ -156,35 +157,35 @@ public class FaceController {
|
|||
/*
|
||||
人脸识别
|
||||
*/
|
||||
@RequestMapping(value = "/faceRecognition", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Response<List<FaceRecognitionResDTO>> faceRecognition(@RequestBody FaceRecognitionReqDTO faceRecognitionReqDTO) {
|
||||
String image = faceRecognitionReqDTO.getImage();
|
||||
|
||||
List<FaceRecognitionResDTO> faceRecognitionResDTOList = Lists.newLinkedList();
|
||||
byte[] bytes = Base64Util.base64ToBytes(image);
|
||||
ImageInfo rgbData = ImageFactory.getRGBData(bytes);
|
||||
List<FaceInfo> faceInfoList = faceEngineService.detectFaces(rgbData);
|
||||
if (CollectionUtil.isNotEmpty(faceInfoList)) {
|
||||
for (FaceInfo faceInfo : faceInfoList) {
|
||||
FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
|
||||
faceRecognitionResDTO.setRect(faceInfo.getRect());
|
||||
byte[] feature = faceEngineService.extractFaceFeature(rgbData, faceInfo,ExtractType.RECOGNIZE);
|
||||
if (feature != null) {
|
||||
List<UserCompareInfo> userCompareInfos = faceEngineService.faceRecognition(feature, UserRamCache.getUserList(), 0.8f);
|
||||
if (CollectionUtil.isNotEmpty(userCompareInfos)) {
|
||||
faceRecognitionResDTO.setName(userCompareInfos.get(0).getName());
|
||||
faceRecognitionResDTO.setSimilar(userCompareInfos.get(0).getSimilar());
|
||||
}
|
||||
}
|
||||
faceRecognitionResDTOList.add(faceRecognitionResDTO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Response.newSuccessResponse(faceRecognitionResDTOList);
|
||||
}
|
||||
// @RequestMapping(value = "/faceRecognition", method = RequestMethod.POST)
|
||||
// @ResponseBody
|
||||
// public Response<List<FaceRecognitionResDTO>> faceRecognition(@RequestBody FaceRecognitionReqDTO faceRecognitionReqDTO) {
|
||||
// String image = faceRecognitionReqDTO.getImage();
|
||||
//
|
||||
// List<FaceRecognitionResDTO> faceRecognitionResDTOList = Lists.newLinkedList();
|
||||
// byte[] bytes = Base64Util.base64ToBytes(image);
|
||||
// ImageInfo rgbData = ImageFactory.getRGBData(bytes);
|
||||
// List<FaceInfo> faceInfoList = faceEngineService.detectFaces(rgbData);
|
||||
// if (CollectionUtil.isNotEmpty(faceInfoList)) {
|
||||
// for (FaceInfo faceInfo : faceInfoList) {
|
||||
// FaceRecognitionResDTO faceRecognitionResDTO = new FaceRecognitionResDTO();
|
||||
// faceRecognitionResDTO.setRect(faceInfo.getRect());
|
||||
// byte[] feature = faceEngineService.extractFaceFeature(rgbData, faceInfo,ExtractType.RECOGNIZE);
|
||||
// if (feature != null) {
|
||||
// List<UserCompareInfo> userCompareInfos = faceEngineService.faceRecognition(feature, UserRamCache.getUserList(), 0.8f);
|
||||
// if (CollectionUtil.isNotEmpty(userCompareInfos)) {
|
||||
// faceRecognitionResDTO.setName(userCompareInfos.get(0).getName());
|
||||
// faceRecognitionResDTO.setSimilar(userCompareInfos.get(0).getSimilar());
|
||||
// }
|
||||
// }
|
||||
// faceRecognitionResDTOList.add(faceRecognitionResDTO);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return Response.newSuccessResponse(faceRecognitionResDTOList);
|
||||
// }
|
||||
|
||||
@RequestMapping(value = "/detectFaces", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
|
|
|
@ -26,7 +26,10 @@ import net.shapelight.modules.app.service.AppUserService;
|
|||
import net.shapelight.modules.face.dto.FaceRecognitionResDTO;
|
||||
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.httpapi.service.AuthService;
|
||||
import net.shapelight.modules.httpapi.service.RecordSaveSyncService;
|
||||
import net.shapelight.modules.nettyapi.config.CmdConstant;
|
||||
|
@ -1474,6 +1477,7 @@ public class HttpApiController {
|
|||
return res;
|
||||
}
|
||||
log.debug("设备端识别人员开始---------------------------------------------:"+sn);
|
||||
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
|
||||
// if (faceFile.isEmpty() || faceFile.getSize() == 0) {
|
||||
// return R.error("文件不能为空");
|
||||
// }
|
||||
|
@ -1496,7 +1500,8 @@ public class HttpApiController {
|
|||
// faceRecognitionResDTO.setRect(faceInfo.getRect());
|
||||
byte[] feature = faceEngineService.extractFaceFeature(rgbData, faceInfo, ExtractType.RECOGNIZE);
|
||||
if (feature != null) {
|
||||
List<UserCompareInfo> userCompareInfos = faceEngineService.faceRecognition(feature, UserRamCache.getUserList(), 0.8f);
|
||||
// List<UserCompareInfo> userCompareInfos = faceEngineService.faceRecognition(feature, UserRamCache.getUserList(), 0.8f);
|
||||
List<UserCompareInfo> userCompareInfos = faceEngineService.faceRecognition(feature, UserRamGroup.getUserList(deviceEntity.getCellId()+""), 0.8f);
|
||||
if (CollectionUtil.isNotEmpty(userCompareInfos)) {
|
||||
faceRecognitionResDTO = new FaceRecognitionResDTO();
|
||||
faceRecognitionResDTO.setPersonId(userCompareInfos.get(0).getFaceId());
|
||||
|
@ -1523,7 +1528,7 @@ public class HttpApiController {
|
|||
//身份证比对成功,访客
|
||||
//----------------------------------------以下业务-----------------------------------------------------
|
||||
log.debug("身份证人脸识别成功保存识别记录:"+sn);
|
||||
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
|
||||
// TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
|
||||
|
||||
TenRecordEntity record = new TenRecordEntity();
|
||||
record.setDeviceSn(sn);
|
||||
|
@ -1605,7 +1610,7 @@ public class HttpApiController {
|
|||
|
||||
//----------------------------------------以下业务-----------------------------------------------------
|
||||
log.debug("人脸识别成功:"+sn);
|
||||
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
|
||||
// TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
|
||||
boolean passFlag = false;
|
||||
if(tenPersonEntity.getPersonType() == Constant.PERSON_TYPE_GUEST){
|
||||
//访客,直接判断有效期
|
||||
|
@ -1706,7 +1711,7 @@ public class HttpApiController {
|
|||
}
|
||||
}else{
|
||||
if(icCard !=null && icCard.length()>0){
|
||||
TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
|
||||
// TenDeviceEntity deviceEntity = tenDeviceService.findBySn(sn);
|
||||
TenPersonEntity tenPersonEntity = tenPersonService.findByIcCardTop(icCard,deviceEntity.getTenantId()+"");
|
||||
if(tenPersonEntity!=null){
|
||||
|
||||
|
@ -1941,13 +1946,21 @@ public class HttpApiController {
|
|||
tenPersonService.updateByIdCard(personEntity);
|
||||
}
|
||||
//特征保存到内存
|
||||
UserRamCache.removeUser(personEntity.getPersonId()+"");
|
||||
log.debug("内存删除人员:"+personEntity.getPersonId()+" 姓名:"+personEntity.getName());
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// UserRamCache.removeUser(personEntity.getPersonId()+"");
|
||||
// log.debug("内存删除人员:"+personEntity.getPersonId()+" 姓名:"+personEntity.getName());
|
||||
// UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
// userInfo.setName(personEntity.getName());
|
||||
// userInfo.setFaceFeature(Base64.getDecoder().decode(personEntity.getFeature()));
|
||||
// UserRamCache.addUser(userInfo);
|
||||
UserRamGroup.removeUser(personEntity.getPersonId()+"",deviceEntity.getCellId()+"");
|
||||
|
||||
UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
userInfo.setName(personEntity.getName());
|
||||
userInfo.setFaceFeature(Base64.getDecoder().decode(personEntity.getFeature()));
|
||||
UserRamCache.addUser(userInfo);
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(personEntity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamGroup.addUser(userInfo,deviceEntity.getCellId()+"");
|
||||
log.debug("内存增加人员:"+personEntity.getPersonId()+" 姓名:"+personEntity.getName());
|
||||
//--------------------------------------------------------------------------
|
||||
JSONObject personRes = new JSONObject();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.shapelight.modules.job.task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.minio.MinioClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.shapelight.common.config.GlobalValue;
|
||||
|
@ -8,8 +9,11 @@ import net.shapelight.common.utils.RedisUtils;
|
|||
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.sys.service.SysUserService;
|
||||
import net.shapelight.modules.ten.entity.TenCellEntity;
|
||||
import net.shapelight.modules.ten.entity.TenPersonEntity;
|
||||
import net.shapelight.modules.ten.entity.TenRecordEntity;
|
||||
import net.shapelight.modules.ten.service.TenCellService;
|
||||
|
@ -28,37 +32,75 @@ public class FaceRestartTask implements ITask {
|
|||
private FaceEngineService faceEngineService;
|
||||
@Autowired
|
||||
private TenPersonService tenPersonService;
|
||||
@Autowired
|
||||
private TenCellService tenCellService;
|
||||
@Autowired
|
||||
private GlobalValue globalValue;
|
||||
|
||||
@Override
|
||||
public void run(String params){
|
||||
log.debug("faceEngin restart .............................................");
|
||||
|
||||
//clear all face
|
||||
UserRamCache.clear();
|
||||
// UserRamCache.clear();
|
||||
//
|
||||
// int count = tenPersonService.findCount();
|
||||
// int pageSize = 1000;
|
||||
// int page = count/pageSize;
|
||||
// if(count%1000!=0){
|
||||
// page = page+1;
|
||||
// }
|
||||
// int faceCount = 0;
|
||||
// for (int i = 0; i < page; i++) {
|
||||
// int start = i*1000;
|
||||
// List<TenPersonEntity> listPage = tenPersonService.listPage(start,1000);
|
||||
// for(TenPersonEntity personEntity: listPage){
|
||||
// if(personEntity.getFeature()!=null && personEntity.getFeature().length()>0){
|
||||
// UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
// userInfo.setName(personEntity.getName());
|
||||
// userInfo.setFaceFeature(Base64Util.base64ToBytes(personEntity.getFeature()));
|
||||
// //这边注册到内存缓存中
|
||||
// UserRamCache.addUser(userInfo);
|
||||
// faceCount++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// log.debug("初始化人脸库完成,共 "+faceCount+" 人");
|
||||
|
||||
int count = tenPersonService.findCount();
|
||||
int pageSize = 1000;
|
||||
int page = count/pageSize;
|
||||
if(count%1000!=0){
|
||||
page = page+1;
|
||||
}
|
||||
int faceCount = 0;
|
||||
for (int i = 0; i < page; i++) {
|
||||
int start = i*1000;
|
||||
List<TenPersonEntity> listPage = tenPersonService.listPage(start,1000);
|
||||
for(TenPersonEntity personEntity: listPage){
|
||||
if(personEntity.getFeature()!=null && personEntity.getFeature().length()>0){
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
userInfo.setName(personEntity.getName());
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(personEntity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamCache.addUser(userInfo);
|
||||
faceCount++;
|
||||
|
||||
//清除分组
|
||||
UserRamGroup.clear();
|
||||
List<TenCellEntity> cellList = tenCellService.list(new QueryWrapper<TenCellEntity>()
|
||||
.eq("tenant_id",globalValue.getTenantId())
|
||||
.eq("delete_flag",0));
|
||||
for(TenCellEntity cellEntity: cellList){
|
||||
String cellId = cellEntity.getCellId()+"";
|
||||
UserRamGroup.addCell(cellId);
|
||||
int count = tenPersonService.findCount(cellId);
|
||||
int pageSize = 1000;
|
||||
int page = count/pageSize;
|
||||
if(count%1000!=0){
|
||||
page = page+1;
|
||||
}
|
||||
int faceCount = 0;
|
||||
for (int i = 0; i < page; i++) {
|
||||
int start = i*1000;
|
||||
List<TenPersonEntity> listPage = tenPersonService.listPage(start,1000, cellId);
|
||||
for(TenPersonEntity personEntity: listPage){
|
||||
if(personEntity.getFeature()!=null && personEntity.getFeature().length()>0){
|
||||
UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(personEntity.getPersonId()+"");
|
||||
userInfo.setName(personEntity.getName());
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(personEntity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamGroup.addUser(userInfo,cellId);
|
||||
faceCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug(cellEntity.getName()+":初始化人脸库完成,共 "+faceCount+" 人");
|
||||
}
|
||||
log.debug("初始化人脸库完成,共 "+faceCount+" 人");
|
||||
log.debug("faceEngin restart end.............................................");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.shapelight.common.utils.Constant;
|
|||
import net.shapelight.common.utils.DateUtils;
|
||||
import net.shapelight.modules.face.entity.UserCompareInfo;
|
||||
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.SysDbBakEntity;
|
||||
import net.shapelight.modules.sys.service.SysDbBakService;
|
||||
|
@ -52,7 +53,8 @@ public class PersonProcessTask implements ITask {
|
|||
//修改人员表
|
||||
tenPersonService.updateStatusById(guest);
|
||||
//特征保存到内存
|
||||
UserRamCache.removeUser(guest.getPersonId()+"");
|
||||
UserRamGroup.removeUser(guest.getPersonId()+"",guest.getCellId()+"");
|
||||
// UserRamCache.removeUser(guest.getPersonId()+"");
|
||||
log.debug("内存删除人员:"+guest.getPersonId()+" 姓名:"+guest.getName());
|
||||
//修改同步表
|
||||
// List<TenPersonSyncEntity> syncEntityList = tenPersonSyncService.findByPersonId(guest.getPersonId(),guest.getTenantId());
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import net.shapelight.common.annotation.SysLog;
|
||||
import net.shapelight.common.utils.Constant;
|
||||
import net.shapelight.common.utils.SnowflakeIdWorker;
|
||||
import net.shapelight.modules.face.util.UserRamGroup;
|
||||
import net.shapelight.modules.sys.controller.AbstractController;
|
||||
import net.shapelight.modules.sys.entity.SysUserEntity;
|
||||
import net.shapelight.modules.sys.service.SysUserRoleService;
|
||||
|
@ -108,6 +109,8 @@ public class TenCellController extends AbstractController {
|
|||
tenCell.setCreateTime(new Date());
|
||||
tenCellService.save(tenCell);
|
||||
|
||||
UserRamGroup.addCell(id+"");
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
@ -144,6 +147,8 @@ public class TenCellController extends AbstractController {
|
|||
tenCellService.removeByIds(Arrays.asList(ids));
|
||||
//删除小区绑定的设备
|
||||
tenDeviceService.evictRemoveByCellIds(ids);
|
||||
|
||||
UserRamGroup.addCell(ids[0]+"");
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@ import net.shapelight.modules.app.entity.AppUserEntity;
|
|||
import net.shapelight.modules.app.service.AppUserService;
|
||||
import net.shapelight.modules.excel.model.PersonModel;
|
||||
import net.shapelight.modules.face.entity.UserCompareInfo;
|
||||
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.controller.AbstractController;
|
||||
import net.shapelight.modules.sys.entity.SysUserEntity;
|
||||
|
@ -168,6 +171,12 @@ public class TenPersonController extends AbstractController {
|
|||
}
|
||||
params.put("personType", Constant.PERSON_TYPE_GUEST);
|
||||
PageUtils page = tenPersonService.queryPage(params);
|
||||
// Date now = new Date();
|
||||
// for (TenPersonEntity guest : (List<TenPersonEntity>)page.getList()) {
|
||||
// if(guest.getLiveEnd().getTime()<now.getTime()){
|
||||
// guest.setStatus(Constant.PESON_SUATUS_GUEST_DATE_OUT);
|
||||
// }
|
||||
// }
|
||||
return R.ok().put("data", page);
|
||||
}
|
||||
|
||||
|
@ -539,17 +548,27 @@ public class TenPersonController extends AbstractController {
|
|||
tenPerson.setLastUpdateBy(getUser().getUsername());
|
||||
tenPerson.setLastUpdateTime(new Date());
|
||||
tenPersonService.updateStatusById(tenPerson);
|
||||
TenPersonEntity entity = tenPersonService.getByIdWithDelete(tenPerson.getPersonId());
|
||||
//特征保存到内存
|
||||
UserRamCache.removeUser(tenPerson.getPersonId()+"");
|
||||
// UserRamCache.removeUser(tenPerson.getPersonId()+"");
|
||||
UserRamGroup.removeUser(tenPerson.getPersonId()+"",entity.getCellId()+"");
|
||||
log.debug("内存删除人员:"+tenPerson.getPersonId()+" 姓名:"+tenPerson.getName());
|
||||
if(tenPerson.getStatus().intValue() == 0){
|
||||
TenPersonEntity entity = tenPersonService.getByIdWithDelete(tenPerson.getPersonId());
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
|
||||
// UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(entity.getPersonId()+"");
|
||||
// userInfo.setName(entity.getName());
|
||||
// userInfo.setFaceFeature(Base64.getDecoder().decode(entity.getFeature()));
|
||||
// UserRamCache.addUser(userInfo);
|
||||
// log.debug("内存增加人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
|
||||
|
||||
UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(entity.getPersonId()+"");
|
||||
userInfo.setName(entity.getName());
|
||||
userInfo.setFaceFeature(Base64.getDecoder().decode(entity.getFeature()));
|
||||
UserRamCache.addUser(userInfo);
|
||||
log.debug("内存增加人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(entity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamGroup.addUser(userInfo,entity.getCellId()+"");
|
||||
|
||||
}
|
||||
|
||||
//一下推送
|
||||
|
|
|
@ -119,9 +119,9 @@ public interface TenPersonDao {
|
|||
|
||||
List<TenPersonEntity> findByIdCardAndDept(@Param("idCard")String idCard, @Param("deptId")Long deptId);
|
||||
|
||||
List<TenPersonEntity> listPage(@Param("start")int start, @Param("count")int count);
|
||||
List<TenPersonEntity> listPage(@Param("start")int start, @Param("count")int count, @Param("cellId")String cellId);
|
||||
|
||||
int findCount();
|
||||
int findCount(@Param("cellId")String cellId);
|
||||
|
||||
int findByIdCardCount(@Param("idCard")String idCard, @Param("tenantId")String tenantId);
|
||||
|
||||
|
|
|
@ -145,9 +145,9 @@ public interface TenPersonService {
|
|||
List<TenPersonEntity> findByIdCardAndDept(String idCard,
|
||||
Long deptId);
|
||||
|
||||
List<TenPersonEntity> listPage(int start, int count);
|
||||
List<TenPersonEntity> listPage(int start, int count, String cellId);
|
||||
|
||||
int findCount();
|
||||
int findCount(String cellId);
|
||||
|
||||
TenLabelEntity findLabelByName(String name, String tenantId);
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ import net.shapelight.modules.face.dto.FaceRecognitionResDTO;
|
|||
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.ten.entity.*;
|
||||
import net.shapelight.modules.ten.service.*;
|
||||
|
@ -454,13 +456,22 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
// }
|
||||
int flag = tenPersonDao.insert(entity);
|
||||
//特征保存到内存
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(entity.getPersonId()+"");
|
||||
// userInfo.setName(entity.getName());
|
||||
// userInfo.setFaceFeature(Base64.getDecoder().decode(entity.getFeature()));
|
||||
// UserRamCache.addUser(userInfo);
|
||||
|
||||
UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(entity.getPersonId()+"");
|
||||
userInfo.setName(entity.getName());
|
||||
userInfo.setFaceFeature(Base64.getDecoder().decode(entity.getFeature()));
|
||||
UserRamCache.addUser(userInfo);
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(entity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamGroup.addUser(userInfo,entity.getCellId()+"");
|
||||
|
||||
log.debug("内存增加人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
|
||||
|
||||
|
||||
////访客添加失效redisKey
|
||||
// if(entity.getPersonType() == Constant.PERSON_TYPE_GUEST){
|
||||
//
|
||||
|
@ -893,7 +904,8 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
//删除人员
|
||||
tenPersonDao.logicDeleteById(personId, cellId);
|
||||
//基础人脸库
|
||||
UserRamCache.removeUser(personId+"");
|
||||
// UserRamCache.removeUser(personId+"");
|
||||
UserRamGroup.removeUser(personId+"",cellId+"");
|
||||
log.debug("内存移除人员:"+personId);
|
||||
|
||||
//记录所有人员id
|
||||
|
@ -1479,13 +1491,23 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
|
||||
//特征保存到内存
|
||||
if(entity.getFeature()!=null && entity.getFeature().length()>0){
|
||||
UserRamCache.removeUser(entity.getPersonId()+"");
|
||||
// UserRamCache.removeUser(entity.getPersonId()+"");
|
||||
// log.debug("内存删除人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
|
||||
// UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(entity.getPersonId()+"");
|
||||
// userInfo.setName(entity.getName());
|
||||
// userInfo.setFaceFeature(Base64.getDecoder().decode(entity.getFeature()));
|
||||
// UserRamCache.addUser(userInfo);
|
||||
|
||||
UserRamGroup.removeUser(entity.getPersonId()+"",entity.getCellId()+"");
|
||||
log.debug("内存删除人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(entity.getPersonId()+"");
|
||||
userInfo.setName(entity.getName());
|
||||
userInfo.setFaceFeature(Base64.getDecoder().decode(entity.getFeature()));
|
||||
UserRamCache.addUser(userInfo);
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(entity.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamGroup.addUser(userInfo,entity.getCellId()+"");
|
||||
|
||||
log.debug("内存增加人员:"+entity.getPersonId()+" 姓名:"+entity.getName());
|
||||
//配置同步数据
|
||||
List<TenPersonSyncEntity> syncEntitys = tenPersonSyncService.findByPersonId(entity.getPersonId(), entity.getTenantId());
|
||||
|
@ -2159,11 +2181,20 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
tenPersonDao.insert(tenPerson);
|
||||
//特征保存到内存
|
||||
if(tenPerson.getFeature()!=null && tenPerson.getFeature().length()>0){
|
||||
UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// UserRamCache.UserInfo userInfo = new UserCompareInfo();
|
||||
// userInfo.setFaceId(tenPerson.getPersonId()+"");
|
||||
// userInfo.setName(tenPerson.getName());
|
||||
// userInfo.setFaceFeature(Base64.getDecoder().decode(tenPerson.getFeature()));
|
||||
// UserRamCache.addUser(userInfo);
|
||||
// log.debug("内存增加人员:"+tenPerson.getPersonId()+" 姓名:"+tenPerson.getName());
|
||||
|
||||
UserInfo userInfo = new UserCompareInfo();
|
||||
userInfo.setFaceId(tenPerson.getPersonId()+"");
|
||||
userInfo.setName(tenPerson.getName());
|
||||
userInfo.setFaceFeature(Base64.getDecoder().decode(tenPerson.getFeature()));
|
||||
UserRamCache.addUser(userInfo);
|
||||
userInfo.setFaceFeature(Base64Util.base64ToBytes(tenPerson.getFeature()));
|
||||
//这边注册到内存缓存中
|
||||
UserRamGroup.addUser(userInfo,tenPerson.getCellId()+"");
|
||||
|
||||
log.debug("内存增加人员:"+tenPerson.getPersonId()+" 姓名:"+tenPerson.getName());
|
||||
}
|
||||
|
||||
|
@ -2487,13 +2518,13 @@ public class TenPersonServiceImpl implements TenPersonService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TenPersonEntity> listPage(int start, int count) {
|
||||
return tenPersonDao.listPage(start, count);
|
||||
public List<TenPersonEntity> listPage(int start, int count, String cellId) {
|
||||
return tenPersonDao.listPage(start, count, cellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int findCount() {
|
||||
return tenPersonDao.findCount();
|
||||
public int findCount(String cellId) {
|
||||
return tenPersonDao.findCount(cellId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1353,11 +1353,19 @@
|
|||
</select>
|
||||
|
||||
<select id="listPage" resultType="net.shapelight.modules.ten.entity.TenPersonEntity">
|
||||
select * from ten_person where delete_flag = 0 and status = 0 limit #{start},#{count}
|
||||
select * from ten_person where delete_flag = 0
|
||||
and status = 0
|
||||
<if test="cellId != null and cellId!=''">
|
||||
and cell_id = #{cellId}
|
||||
</if>
|
||||
limit #{start},#{count}
|
||||
</select>
|
||||
|
||||
<select id="findCount" resultType="int">
|
||||
select count(*) from ten_person where delete_flag = 0 and status = 0
|
||||
<if test="cellId != null and cellId!=''">
|
||||
and cell_id = #{cellId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findByIdCardList" resultType="net.shapelight.modules.ten.entity.TenPersonEntity">
|
||||
|
|
Loading…
Reference in New Issue