|
@@ -69,6 +69,8 @@ public class PersonService {
|
|
private IdenCommunityService idenCommunityService;
|
|
private IdenCommunityService idenCommunityService;
|
|
@Resource
|
|
@Resource
|
|
private IdenWarningPersonService idenWarningPersonService;
|
|
private IdenWarningPersonService idenWarningPersonService;
|
|
|
|
+ @Resource
|
|
|
|
+ private FaceIdenService faceIdenService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
@@ -299,7 +301,7 @@ public class PersonService {
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public List<Long> importWithExcel(MultipartFile file) throws BDException {
|
|
|
|
|
|
+ public List<Long> importWithExcel(MultipartFile file,boolean isCrowd) throws BDException {
|
|
List<Long> personIdList = new ArrayList<>();
|
|
List<Long> personIdList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
String excelFileName = file.getOriginalFilename();
|
|
String excelFileName = file.getOriginalFilename();
|
|
@@ -459,8 +461,11 @@ public class PersonService {
|
|
personVO.setType(type);
|
|
personVO.setType(type);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- msg.append("请填写类型(重点人员或小区人员,多个用英文逗号分隔)!\n");
|
|
|
|
|
|
+ if(!isCrowd){
|
|
|
|
+ msg.append("请填写类型(重点人员或小区人员,多个用英文逗号分隔)!\n");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
} else if (19 == j) {//人群类型
|
|
} else if (19 == j) {//人群类型
|
|
if (StringUtils.isNotBlank(value)){
|
|
if (StringUtils.isNotBlank(value)){
|
|
String[] crowdNames = value.split(",");
|
|
String[] crowdNames = value.split(",");
|
|
@@ -481,6 +486,10 @@ public class PersonService {
|
|
if(CollUtil.isNotEmpty(idenCrowdIds)){
|
|
if(CollUtil.isNotEmpty(idenCrowdIds)){
|
|
personVO.setCrowdIds(idenCrowdIds);
|
|
personVO.setCrowdIds(idenCrowdIds);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ if(isCrowd){
|
|
|
|
+ msg.append("填写人群类型错误(多个用英文逗号分隔)!\n");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if (20 == j) {//备注
|
|
} else if (20 == j) {//备注
|
|
if (StringUtils.isNotBlank(value)){
|
|
if (StringUtils.isNotBlank(value)){
|
|
@@ -569,12 +578,13 @@ public class PersonService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public void deleteById(Long id) throws BDException {
|
|
|
|
|
|
+ public void deleteById(Long id,String type) throws BDException {
|
|
String key = RedisKeyConstant.PERSON_DELETE;
|
|
String key = RedisKeyConstant.PERSON_DELETE;
|
|
String requestId = UUID.randomUUID().toString();
|
|
String requestId = UUID.randomUUID().toString();
|
|
boolean result = redisUtil.tryLock(key,requestId,10 * 60);
|
|
boolean result = redisUtil.tryLock(key,requestId,10 * 60);
|
|
try {
|
|
try {
|
|
if (result) {
|
|
if (result) {
|
|
|
|
+
|
|
QueryWrapper<IdenWarningPerson> queryWrapper0 = new QueryWrapper<>();
|
|
QueryWrapper<IdenWarningPerson> queryWrapper0 = new QueryWrapper<>();
|
|
queryWrapper0.lambda().eq(IdenWarningPerson::getPersonId,id);
|
|
queryWrapper0.lambda().eq(IdenWarningPerson::getPersonId,id);
|
|
int cnt = this.idenWarningPersonService.count(queryWrapper0);
|
|
int cnt = this.idenWarningPersonService.count(queryWrapper0);
|
|
@@ -582,22 +592,43 @@ public class PersonService {
|
|
throw new BDException("人员被引用,不能删除");
|
|
throw new BDException("人员被引用,不能删除");
|
|
}
|
|
}
|
|
|
|
|
|
- IdenPerson idenPerson = this.idenPersonService.getById(id);
|
|
|
|
-
|
|
|
|
- QueryWrapper<IdenPersonCrowdRef> queryWrapper = new QueryWrapper<>();
|
|
|
|
- queryWrapper.lambda().eq(IdenPersonCrowdRef::getPersonId,idenPerson.getId());
|
|
|
|
- idenPersonCrowdRefService.remove(queryWrapper);
|
|
|
|
|
|
+ IdenPerson idenPerson = this.idenPersonService.getById(id);
|
|
|
|
+ String types = idenPerson.getType();
|
|
|
|
+ String[] typeTmps = types.split(",");
|
|
|
|
|
|
- String image = idenPerson.getImage();
|
|
|
|
- IdenCommunity idenCommunity = this.idenCommunityService.getById(idenPerson.getCommunityId());
|
|
|
|
- if (StringUtils.isNotEmpty(image) && idenCommunity != null) {
|
|
|
|
- File imageFile = new File(idenRoot + "data/final/person/image/" + idenCommunity.getCode() + "/" + image.substring(image.lastIndexOf("/") + 1));
|
|
|
|
- if(imageFile.exists()){
|
|
|
|
- imageFile.delete();
|
|
|
|
|
|
+ if (typeTmps.length > 1) { //属于多个人员类型,只清除本类型的
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ for(String typeTmp : typeTmps){
|
|
|
|
+ if(!type.equals(typeTmp)) {
|
|
|
|
+ sb.append(typeTmp).append(",");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- this.idenPersonService.removeById(id);
|
|
|
|
- reloadFaceDataset();
|
|
|
|
|
|
+ types = sb.toString();
|
|
|
|
+
|
|
|
|
+ if(types.endsWith(",")) {
|
|
|
|
+ types = types.substring(0, types.length() -1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ UpdateWrapper<IdenPerson> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.lambda().set(IdenPerson::getType,types).eq(IdenPerson::getId,id);
|
|
|
|
+ idenPersonService.update(updateWrapper);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ QueryWrapper<IdenPersonCrowdRef> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.lambda().eq(IdenPersonCrowdRef::getPersonId,idenPerson.getId());
|
|
|
|
+ idenPersonCrowdRefService.remove(queryWrapper);
|
|
|
|
+
|
|
|
|
+ String image = idenPerson.getImage();
|
|
|
|
+ IdenCommunity idenCommunity = this.idenCommunityService.getById(idenPerson.getCommunityId());
|
|
|
|
+ if (StringUtils.isNotEmpty(image) && idenCommunity != null) {
|
|
|
|
+ File imageFile = new File(idenRoot + "data/final/person/image/" + idenCommunity.getCode() + "/" + image.substring(image.lastIndexOf("/") + 1));
|
|
|
|
+ if(imageFile.exists()){
|
|
|
|
+ imageFile.delete();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.idenPersonService.removeById(id);
|
|
|
|
+ faceIdenService.reloadFaceDataset();
|
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
} else {
|
|
throw new BDException("不能多人同时删除,稍后再试");
|
|
throw new BDException("不能多人同时删除,稍后再试");
|
|
@@ -743,26 +774,7 @@ public class PersonService {
|
|
faceMonitorPerson.appendFaceDataset(dataset);
|
|
faceMonitorPerson.appendFaceDataset(dataset);
|
|
}
|
|
}
|
|
|
|
|
|
- private void reloadFaceDataset(){
|
|
|
|
- //重新加载人脸库缓存
|
|
|
|
- FaceMonitor faceMonitorPerson = FaceMoniterCache.getFaceMonitor(Constants.FACE_CACHE_PERSON_KEY);
|
|
|
|
|
|
|
|
- QueryWrapper<IdenPerson> queryWrapper = new QueryWrapper();
|
|
|
|
- queryWrapper.select("id","name","feat_ptr");
|
|
|
|
- queryWrapper.lambda().isNotNull(IdenPerson::getFeatPtr);
|
|
|
|
- List<IdenPerson> idenPersonList = idenPersonService.list(queryWrapper);
|
|
|
|
- if (CollUtil.isNotEmpty(idenPersonList)) {
|
|
|
|
- FaceModel[] dataset = new FaceModel[idenPersonList.size()];
|
|
|
|
- for(int i = 0; i < idenPersonList.size(); i++){
|
|
|
|
- IdenPerson idenPerson = idenPersonList.get(i);
|
|
|
|
- dataset[i] = new FaceModel();
|
|
|
|
- dataset[i].setPersonId(idenPerson.getId().intValue());
|
|
|
|
- dataset[i].setName(String.valueOf(i));
|
|
|
|
- dataset[i].setFeatValue(ByteUtil.hex2Byte(idenPerson.getFeatPtr()));
|
|
|
|
- }
|
|
|
|
- faceMonitorPerson.loadFaceDataset(dataset);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改人员
|
|
* 修改人员
|
|
@@ -815,7 +827,7 @@ public class PersonService {
|
|
|
|
|
|
this.idenPersonService.updateById(idenPerson);
|
|
this.idenPersonService.updateById(idenPerson);
|
|
|
|
|
|
- reloadFaceDataset();
|
|
|
|
|
|
+ faceIdenService.reloadFaceDataset();
|
|
} else {
|
|
} else {
|
|
throw new BDException("不能多人同时修改,稍后再试");
|
|
throw new BDException("不能多人同时修改,稍后再试");
|
|
}
|
|
}
|