人脸删除
This commit is contained in:
parent
d131a953da
commit
83bb3f0d38
|
|
@ -37,7 +37,7 @@ public class UserFace implements Serializable {
|
||||||
|
|
||||||
/** 照片地址 */
|
/** 照片地址 */
|
||||||
@ApiModelProperty(value = "照片地址")
|
@ApiModelProperty(value = "照片地址")
|
||||||
@NotBlank(message = "照片地址必填")
|
//@NotBlank(message = "照片地址必填")
|
||||||
private String photoUrl;
|
private String photoUrl;
|
||||||
|
|
||||||
/** 特征码 */
|
/** 特征码 */
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,6 @@ import com.bonus.canteen.core.user.domain.UserFace;
|
||||||
*/
|
*/
|
||||||
public interface UserFaceMapper {
|
public interface UserFaceMapper {
|
||||||
int insertUserFace(UserFace userFace);
|
int insertUserFace(UserFace userFace);
|
||||||
|
|
||||||
|
int deleteUserFace(UserFace userFace);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,12 @@ import com.bonus.canteen.core.user.utils.ArcFaceHelper;
|
||||||
import com.bonus.canteen.core.user.utils.FaceResult;
|
import com.bonus.canteen.core.user.utils.FaceResult;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.houqin.mq.constant.LeMqConstant;
|
import com.bonus.common.houqin.mq.constant.LeMqConstant;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.bonus.canteen.core.user.mapper.UserFaceMapper;
|
import com.bonus.canteen.core.user.mapper.UserFaceMapper;
|
||||||
|
|
@ -30,8 +33,10 @@ import com.bonus.canteen.core.user.service.IUserFaceService;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UserFaceServiceImpl implements IUserFaceService {
|
public class UserFaceServiceImpl implements IUserFaceService {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(UserFaceServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserFaceMapper UserFaceMapper;
|
private UserFaceMapper userFaceMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询人员生物识别特征
|
* 查询人员生物识别特征
|
||||||
|
|
@ -47,15 +52,14 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
||||||
if (ObjectUtil.isNull(dto.getUserId())) {
|
if (ObjectUtil.isNull(dto.getUserId())) {
|
||||||
throw new ServiceException("用户ID为空!");
|
throw new ServiceException("用户ID为空!");
|
||||||
}
|
}
|
||||||
if (ObjectUtil.isNull(dto.getPhotoUrl())) {
|
if (StringUtils.isEmpty(dto.getPhotoUrl())) {
|
||||||
throw new ServiceException("图片地址为空!");
|
userFaceMapper.deleteUserFace(dto);
|
||||||
}
|
} else {
|
||||||
|
log.info("开始采集虹软人脸");
|
||||||
System.out.println("开始采集虹软人脸");
|
|
||||||
ArcFaceHelper arcFaceHelper = new ArcFaceHelper();
|
ArcFaceHelper arcFaceHelper = new ArcFaceHelper();
|
||||||
String url = FileUrlUtil.getFileUrl(dto.getPhotoUrl());
|
String url = FileUrlUtil.getFileUrl(dto.getPhotoUrl());
|
||||||
FaceResult faceResult = arcFaceHelper.getFaceFeatures(url);
|
FaceResult faceResult = arcFaceHelper.getFaceFeatures(url);
|
||||||
System.err.println("采集结束");
|
log.info("采集结束");
|
||||||
List<UserFace> list = new ArrayList<>();
|
List<UserFace> list = new ArrayList<>();
|
||||||
if (faceResult != null) {
|
if (faceResult != null) {
|
||||||
UserFace faceVO = new UserFace();
|
UserFace faceVO = new UserFace();
|
||||||
|
|
@ -69,18 +73,18 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
||||||
faceVO.setCreateTime(DateUtils.getTime());
|
faceVO.setCreateTime(DateUtils.getTime());
|
||||||
faceVO.setUpdateTime(DateUtils.getTime());
|
faceVO.setUpdateTime(DateUtils.getTime());
|
||||||
list.add(faceVO);
|
list.add(faceVO);
|
||||||
System.out.println("faceResult.getFeatures():" + Base64.getEncoder().encodeToString(faceResult.getFeatures()));
|
log.info("faceResult.getFeatures():" + Base64.getEncoder().encodeToString(faceResult.getFeatures()));
|
||||||
System.out.println("人脸采集成功");
|
log.info("人脸采集成功");
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException("[虹软算法]:特征值提取失败");
|
throw new ServiceException("[虹软算法]:特征值提取失败");
|
||||||
}
|
}
|
||||||
int code = UserFaceMapper.insertUserFace(list.get(0));
|
int code = userFaceMapper.insertUserFace(list.get(0));
|
||||||
if (code == 0){
|
if (code == 0){
|
||||||
throw new ServiceException("[虹软算法]:保存失败");
|
throw new ServiceException("[虹软算法]:保存失败");
|
||||||
}
|
}
|
||||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(1);
|
}
|
||||||
System.out.println(bean.toString());
|
|
||||||
//发送mq
|
//发送mq
|
||||||
|
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(1);
|
||||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
update_by = #{updateBy},
|
update_by = #{updateBy},
|
||||||
update_time = #{updateTime}
|
update_time = #{updateTime}
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteUserFace" parameterType="com.bonus.canteen.core.user.domain.UserFace">
|
||||||
|
delete from user_face
|
||||||
|
where user_id = #{userId}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue