|
|
@@ -92,10 +92,16 @@ public class OrgUserFaceService extends SuperService {
|
|
|
if (StringUtils.isEmpty(projectOid)) {
|
|
|
return ResultContent.buildFail("oid不能为空");
|
|
|
}
|
|
|
- String userId = param.getUserId();
|
|
|
- if (StringUtils.isEmpty(userId)) {
|
|
|
+ String userId = "";
|
|
|
+ if (param.getIsManager() != null && param.getIsManager()) {
|
|
|
+ userId = param.getUserId();
|
|
|
+ } else {
|
|
|
userId = getCurrentUserId();
|
|
|
}
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
+ return ResultContent.buildFail("用户信息为空");
|
|
|
+ }
|
|
|
+
|
|
|
String img = param.getImg();
|
|
|
// 判断人脸可信度
|
|
|
ResultContent<ProjectCommonConfigModel> configContent = conformFace(img, projectOid);
|
|
|
@@ -108,15 +114,21 @@ public class OrgUserFaceService extends SuperService {
|
|
|
if (isAllowUpdateFace == null || !isAllowUpdateFace) {
|
|
|
return ResultContent.buildFail("系统不允许管理人脸信息");
|
|
|
}
|
|
|
-
|
|
|
// 人脸是否需要审核
|
|
|
Boolean isExamineFace = configModel.getIsExamineFace();
|
|
|
|
|
|
+ // 是否需要审核
|
|
|
+ boolean isMustAudit = false;
|
|
|
+ if ((param.getIsManager() == null || !param.getIsManager()) && isExamineFace != null && isExamineFace) {
|
|
|
+ isMustAudit = true;
|
|
|
+ }
|
|
|
+
|
|
|
int maxFaceNumber = configModel.getMaxFaceNumber();
|
|
|
int number = orgUserFaceDao.countByUserIdAndProjectOid(userId, projectOid);
|
|
|
if (number >= maxFaceNumber) {
|
|
|
- return ResultContent.buildFail("");
|
|
|
+ return ResultContent.buildFail(String.format("用户人脸数量已达上限:%d张", number));
|
|
|
}
|
|
|
+
|
|
|
// 所属用户userId
|
|
|
UserAccount userAccount = userCountDao.findTopByUserId(userId);
|
|
|
OrganizationUser organizationUser = organizationUserServiceImpl.getUserTopInProjectBindOrgUserInfo(projectOid, userAccount);
|
|
|
@@ -138,16 +150,13 @@ public class OrgUserFaceService extends SuperService {
|
|
|
initEntityNoCheckOid(orgUserFace);
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, orgUserFace, "id");
|
|
|
+
|
|
|
orgUserFace.setProjectOid(projectOid);
|
|
|
- orgUserFace.setOrganizationUser(organizationUser);
|
|
|
orgUserFace.setUpdateFaceFileId(updateFaceFileId);
|
|
|
orgUserFace.setUserId(userId);
|
|
|
- if (ObjectUtils.isNotEmpty(userAccount)) {
|
|
|
- orgUserFace.setUserAccount(userAccount);
|
|
|
- orgUserFace.setUserName(userAccount.getName());
|
|
|
- orgUserFace.setPhone(userAccount.getPhone());
|
|
|
- }
|
|
|
- if (isExamineFace != null && isExamineFace) {
|
|
|
+ fillEntityUserInfo(orgUserFace, organizationUser);
|
|
|
+
|
|
|
+ if (isMustAudit) {
|
|
|
// 需要审核
|
|
|
orgUserFace.setIsCanUsed(Boolean.FALSE);
|
|
|
orgUserFace.setAuditState(AuditState.WaitAudit);
|
|
|
@@ -165,6 +174,7 @@ public class OrgUserFaceService extends SuperService {
|
|
|
orgUserFace.setAuditRemark("自动通过");
|
|
|
orgUserFace.setAuditTime(System.currentTimeMillis());
|
|
|
}
|
|
|
+ orgUserFace.setConfidence(configModel.getConfidence());
|
|
|
orgUserFaceDao.save(orgUserFace);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
@@ -213,8 +223,22 @@ public class OrgUserFaceService extends SuperService {
|
|
|
return ResultContent.buildFail("数据已审核");
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, orgUserFace, "id");
|
|
|
+ if (orgUserFace.getAuditState() == AuditState.Audited) {
|
|
|
+ // 通过
|
|
|
+ ResultContent<String> content = syncFace(orgUserFace);
|
|
|
+ if (content.isFailed()) {
|
|
|
+ return ResultContent.buildFail(content.getMsg());
|
|
|
+ }
|
|
|
+ String updateFaceFileId = content.getContent();
|
|
|
+ orgUserFace.setUpdateFaceFileId(updateFaceFileId);
|
|
|
+ orgUserFace.setIsCanUsed(Boolean.TRUE);
|
|
|
+ } else {
|
|
|
+ orgUserFace.setIsCanUsed(Boolean.FALSE);
|
|
|
+ }
|
|
|
+ orgUserFace.setAuditUserId(getCurrentUserId());
|
|
|
orgUserFace.setAuditTime(System.currentTimeMillis());
|
|
|
orgUserFaceDao.save(orgUserFace);
|
|
|
+
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
@@ -331,12 +355,43 @@ public class OrgUserFaceService extends SuperService {
|
|
|
}
|
|
|
Double confidence = content.getContent() * 100;
|
|
|
if (BigDecimal.valueOf(confidence).compareTo(BigDecimal.valueOf(configModel.getSimilarity())) >= 0) {
|
|
|
+ configModel.setConfidence(BigDecimal.valueOf(confidence));
|
|
|
return ResultContent.buildSuccess(configModel);
|
|
|
} else {
|
|
|
return ResultContent.buildFail(String.format("未检测到人脸: %d", confidence.intValue()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 填充用户信息
|
|
|
+ *
|
|
|
+ * @param entity
|
|
|
+ * @param organizationUser
|
|
|
+ */
|
|
|
+ public void fillEntityUserInfo(OrgUserFace entity, OrganizationUser organizationUser) {
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ entity.setOrganizationUser(organizationUser);
|
|
|
+ if (ObjectUtils.isNotEmpty(organizationUser)) {
|
|
|
+ if (organizationUser.getOrganization() != null) {
|
|
|
+ entity.setUserOrgOid(organizationUser.getOrganization().getOid());
|
|
|
+ }
|
|
|
+ entity.setDepartment(organizationUser.getDepartment());
|
|
|
+ entity.setRoleIds(organizationUser.getRoleIds());
|
|
|
+ entity.setPosition(organizationUser.getPosition());
|
|
|
+ entity.setCode(organizationUser.getCode());
|
|
|
+ }
|
|
|
+ UserAccount userAccount = organizationUser.getUser();
|
|
|
+ if (ObjectUtils.isNotEmpty(userAccount)) {
|
|
|
+ if (ObjectUtils.isNotEmpty(userAccount)) {
|
|
|
+ entity.setUserAccount(userAccount);
|
|
|
+ entity.setUserName(userAccount.getName());
|
|
|
+ entity.setPhone(userAccount.getPhone());
|
|
|
+ entity.setSex(userAccount.getSex());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public OrgUserFaceModel toModel(OrgUserFace entity) {
|
|
|
OrgUserFaceModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|