提交 9547a645 authored 作者: yangqi's avatar yangqi

1

上级 b20eb8b3
......@@ -62,4 +62,11 @@ public class LisaController {
Pagination<EntityListVO> entityListVOPageInfo = equipmentService.getEntityList(apartmentId, page, pageSize);
return new ApiResponse<>(entityListVOPageInfo);
}
@NoAuth
@GetMapping("/searchFace")
public ApiResponse<Object> searchFace(int apartmentId, String url) throws Exception {
equipmentService.searchFace(apartmentId, url);
return new ApiResponse<>();
}
}
......@@ -183,6 +183,7 @@ public class Face {
Map<String, String> map = new HashMap<>();
map.put("entityId" , item.getEntityId());
map.put("faceId", item.getFaceId());
map.put("ossUrl", url);
return map;
}
......
......@@ -46,7 +46,7 @@ public interface FaceService {
/**
* 搜索人脸
*/
boolean searchFace(String dbName, String url) throws Exception;
Map<String, String> searchFace(String dbName, String url) throws Exception;
/**
* 搜索人脸
......
......@@ -152,36 +152,12 @@ public class FaceServiceImpl implements FaceService{
}
@Override
public boolean searchFace(String dbName, String url) throws Exception {
public Map<String, String> searchFace(String dbName, String url) throws Exception {
Utils.checkParamsNotEmpty(dbName, "dbName");
Utils.checkParamsNotEmpty(url, "url");
AliFaceDb db = dbMapper.getDbByName(dbName);
if(db == null){
return false;
}
String ossUrl = sdk.uploadImageUrl(url);
Map<String, String> map = sdk.searchFace(dbName, ossUrl);
if(map == null){
return false;
}
int dbId = db.getAliFaceDbId();
String entityId = map.get("entityId");
String faceId = map.get("faceId");
AliFaceEntity entityDb = new AliFaceEntity();
entityDb.setAliFaceDbId(dbId);
entityDb.setEntityId(entityId);
AliFaceEntity entity = entityMapper.getEntityByEntityId(entityDb);
if(entity == null){
return false;
}
AliFaceLog log = new AliFaceLog();
log.setAliFaceDbId(dbId);
log.setAliFaceEntityId(entity.getAliFaceEntityId());
log.setFaceId(faceId);
log.setImageUrl(url);
log.setOssUrl(ossUrl);
logMapper.addLog(log);
return true;
return sdk.searchFace(dbName, ossUrl);
}
@Override
......
......@@ -25,4 +25,6 @@ public interface EquipmentService {
void updateEntity(int entityId, String userName, Byte sex, String roomNumber, Byte identity, String mobile, String idCard, String imgUrl, int employeeId) throws Exception;
Pagination<EntityListVO> getEntityList(int apartmentId, int page, int pageSize) throws Exception;
boolean searchFace(int apartmentId, String url) throws Exception;
}
......@@ -11,10 +11,7 @@ import cn.lefull.repository.mapper.face.AliFaceDbMapper;
import cn.lefull.repository.mapper.face.CameraApartmentDbMapper;
import cn.lefull.repository.mapper.face.CameraEntityMapper;
import cn.lefull.repository.mapper.face.CameraEquipmentMapper;
import cn.lefull.repository.model.face.AliFaceDb;
import cn.lefull.repository.model.face.CameraApartmentDb;
import cn.lefull.repository.model.face.CameraEntity;
import cn.lefull.repository.model.face.CameraEquipment;
import cn.lefull.repository.model.face.*;
import cn.lefull.service.ali.FaceService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
......@@ -257,4 +254,31 @@ public class EquipmentServiceImpl implements EquipmentService {
}
return PageBuilder.buildPageResult(objects, entityListVOS);
}
@Override
public boolean searchFace(int apartmentId, String url) throws Exception {
Utils.checkParamsNotEmpty(apartmentId, "apartmentId");
Utils.checkParamsNotEmpty(url, "url");
String dbName = this.getFaceDbName(apartmentId);
int dbId = this.getFaceDbId(apartmentId);
Map<String, String> map = faceService.searchFace(dbName, url);
if(map == null){
//校验失败
return false;
}
String entityId = map.get("entityId");
String faceId = map.get("faceId");
String ossUrl = map.get("ossUrl");
AliFaceLog log = new AliFaceLog();
log.setAliFaceDbId(dbId);
log.setAliFaceEntityId(entityId);
log.setFaceId(faceId);
log.setImageUrl(url);
log.setOssUrl(ossUrl);
logMapper.addLog(log);
return true;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论