Merge branch 'master' of http://192.168.0.75:3000/bonus/Bonus-Cloud-JYY-Smart-Canteen
This commit is contained in:
commit
7f584f958c
|
|
@ -76,9 +76,10 @@ public class DeviceMqPersonalUpdateMessageDTO {
|
|||
this.updatePerson = updatePerson;
|
||||
return this;
|
||||
}
|
||||
public DeviceMqPersonalUpdateMessageDTO setUpdatePersonPhoto(final Integer updatePersonPhoto) {
|
||||
public DeviceMqPersonalUpdateMessageDTO setUpdatePersonPhoto(final Integer updatePersonPhoto,String type) {
|
||||
this.currentTime = DateUtils.getTime();
|
||||
this.updatePersonPhoto = updatePersonPhoto;
|
||||
this.type = type;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class UserFace implements Serializable {
|
|||
|
||||
/** 照片地址 */
|
||||
@ApiModelProperty(value = "照片地址")
|
||||
@NotBlank(message = "照片地址必填")
|
||||
//@NotBlank(message = "照片地址必填")
|
||||
private String photoUrl;
|
||||
|
||||
/** 特征码 */
|
||||
|
|
|
|||
|
|
@ -11,4 +11,6 @@ import com.bonus.canteen.core.user.domain.UserFace;
|
|||
*/
|
||||
public interface UserFaceMapper {
|
||||
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.common.core.exception.ServiceException;
|
||||
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.houqin.mq.constant.LeMqConstant;
|
||||
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.stereotype.Service;
|
||||
import com.bonus.canteen.core.user.mapper.UserFaceMapper;
|
||||
|
|
@ -30,8 +33,10 @@ import com.bonus.canteen.core.user.service.IUserFaceService;
|
|||
*/
|
||||
@Service
|
||||
public class UserFaceServiceImpl implements IUserFaceService {
|
||||
private static final Logger log = LoggerFactory.getLogger(UserFaceServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private UserFaceMapper UserFaceMapper;
|
||||
private UserFaceMapper userFaceMapper;
|
||||
|
||||
/**
|
||||
* 查询人员生物识别特征
|
||||
|
|
@ -47,15 +52,17 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
|||
if (ObjectUtil.isNull(dto.getUserId())) {
|
||||
throw new ServiceException("用户ID为空!");
|
||||
}
|
||||
if (ObjectUtil.isNull(dto.getPhotoUrl())) {
|
||||
throw new ServiceException("图片地址为空!");
|
||||
}
|
||||
|
||||
System.out.println("开始采集虹软人脸");
|
||||
if (StringUtils.isEmpty(dto.getPhotoUrl())) {
|
||||
userFaceMapper.deleteUserFace(dto);
|
||||
//发送mq
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(dto.getUserId().intValue(),"del");
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
} else {
|
||||
log.info("开始采集虹软人脸");
|
||||
ArcFaceHelper arcFaceHelper = new ArcFaceHelper();
|
||||
String url = FileUrlUtil.getFileUrl(dto.getPhotoUrl());
|
||||
FaceResult faceResult = arcFaceHelper.getFaceFeatures(url);
|
||||
System.err.println("采集结束");
|
||||
log.info("采集结束");
|
||||
List<UserFace> list = new ArrayList<>();
|
||||
if (faceResult != null) {
|
||||
UserFace faceVO = new UserFace();
|
||||
|
|
@ -69,19 +76,19 @@ public class UserFaceServiceImpl implements IUserFaceService {
|
|||
faceVO.setCreateTime(DateUtils.getTime());
|
||||
faceVO.setUpdateTime(DateUtils.getTime());
|
||||
list.add(faceVO);
|
||||
System.out.println("faceResult.getFeatures():" + Base64.getEncoder().encodeToString(faceResult.getFeatures()));
|
||||
System.out.println("人脸采集成功");
|
||||
log.info("faceResult.getFeatures():" + Base64.getEncoder().encodeToString(faceResult.getFeatures()));
|
||||
log.info("人脸采集成功");
|
||||
} else {
|
||||
throw new ServiceException("[虹软算法]:特征值提取失败");
|
||||
}
|
||||
int code = UserFaceMapper.insertUserFace(list.get(0));
|
||||
int code = userFaceMapper.insertUserFace(list.get(0));
|
||||
if (code == 0){
|
||||
throw new ServiceException("[虹软算法]:保存失败");
|
||||
}
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(1);
|
||||
System.out.println(bean.toString());
|
||||
//发送mq
|
||||
DeviceMqPersonalUpdateMessageDTO bean = new DeviceMqPersonalUpdateMessageDTO().setUpdatePersonPhoto(dto.getUserId().intValue(),"update");
|
||||
MqUtil.pushToTenantAllDevice(bean, LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.user.mapper.UserFaceMapper">
|
||||
<insert id="insertUserFace" parameterType="com.bonus.canteen.core.user.domain.UserFace" useGeneratedKeys="true" keyProperty="faceId">
|
||||
<insert id="insertUserFace" parameterType="com.bonus.canteen.core.user.domain.UserFace">
|
||||
insert into user_face(user_id,photo_url,features,create_by,error_msg,create_time,update_by,update_time)
|
||||
values(#{userId},#{photoUrl},#{features},#{createBy},#{errorMsg},#{createTime},#{updateBy},#{updateTime})
|
||||
on duplicate key update features = #{features},
|
||||
|
|
@ -12,4 +12,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
</insert>
|
||||
|
||||
<delete id="deleteUserFace" parameterType="com.bonus.canteen.core.user.domain.UserFace">
|
||||
delete from user_face
|
||||
where user_id = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue