|
|
@@ -7,10 +7,9 @@ import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
import com.google.common.collect.Lists;
|
|
|
-import com.zhongshu.card.client.model.projectAbout.orgFace.OrgUserFaceAuditParam;
|
|
|
-import com.zhongshu.card.client.model.projectAbout.orgFace.OrgUserFaceModel;
|
|
|
-import com.zhongshu.card.client.model.projectAbout.orgFace.OrgUserFaceParam;
|
|
|
-import com.zhongshu.card.client.model.projectAbout.orgFace.OrgUserFaceSearch;
|
|
|
+import com.zhongshu.card.client.model.base.IDsParam;
|
|
|
+import com.zhongshu.card.client.model.base.OutNumberModel;
|
|
|
+import com.zhongshu.card.client.model.projectAbout.orgFace.*;
|
|
|
import com.zhongshu.card.client.model.projectAbout.projectCommon.ProjectCommonConfigModel;
|
|
|
import com.zhongshu.card.client.type.common.AuditState;
|
|
|
import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
@@ -85,6 +84,15 @@ public class OrgUserFaceService extends SuperService {
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultContent saveFace(OrgUserFaceParam param) {
|
|
|
+ // 编辑 先删除
|
|
|
+ if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
+ ResultContent resultContent = deleteFace(param.getId(), false);
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return ResultContent.buildFail(resultContent.getMsg());
|
|
|
+ }
|
|
|
+ param.setId(null);
|
|
|
+ }
|
|
|
+
|
|
|
String projectOid = param.getProjectOid();
|
|
|
if (StringUtils.isEmpty(projectOid)) {
|
|
|
projectOid = getCurrentProjectOid();
|
|
|
@@ -125,6 +133,9 @@ public class OrgUserFaceService extends SuperService {
|
|
|
|
|
|
int maxFaceNumber = configModel.getMaxFaceNumber();
|
|
|
int number = orgUserFaceDao.countByUserIdAndProjectOid(userId, projectOid);
|
|
|
+ if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
+ number = number - 1;
|
|
|
+ }
|
|
|
if (number >= maxFaceNumber) {
|
|
|
return ResultContent.buildFail(String.format("用户人脸数量已达上限:%d张", number));
|
|
|
}
|
|
|
@@ -176,22 +187,47 @@ public class OrgUserFaceService extends SuperService {
|
|
|
}
|
|
|
orgUserFace.setConfidence(configModel.getConfidence());
|
|
|
orgUserFaceDao.save(orgUserFace);
|
|
|
+ return ResultContent.buildSuccess(toModel(orgUserFace));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除多个
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent deleteFace(IDsParam param) {
|
|
|
+ if (ObjectUtils.isEmpty(param.getIds())) {
|
|
|
+ return ResultContent.buildFail("ids 不能为空");
|
|
|
+ }
|
|
|
+ OutNumberModel model = new OutNumberModel();
|
|
|
+ for (String id : param.getIds()) {
|
|
|
+ ResultContent _temp = deleteFace(id, true);
|
|
|
+ if (_temp.isSuccess()) {
|
|
|
+ model.addSuccess(id);
|
|
|
+ } else {
|
|
|
+ model.addFail(id, _temp.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
- public ResultContent deleteFace(String id) {
|
|
|
+ public ResultContent deleteFace(String id, boolean isManager) {
|
|
|
OrgUserFace orgUserFace = orgUserFaceDao.findTopById(id);
|
|
|
if (orgUserFace == null) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
|
- ResultContent<ProjectCommonConfigModel> content = projectCommonConfigService.getConfigInfoAndCheck(orgUserFace.getProjectOid());
|
|
|
- if (content.isFailed()) {
|
|
|
- return ResultContent.buildFail(content.getMsg());
|
|
|
- }
|
|
|
- ProjectCommonConfigModel configModel = content.getContent();
|
|
|
- Boolean isAllowUpdateFace = configModel.getIsAllowUpdateFace();
|
|
|
- if (isAllowUpdateFace == null || !isAllowUpdateFace) {
|
|
|
- return ResultContent.buildFail("系统不允许删除人脸信息");
|
|
|
+ if (!isManager) {
|
|
|
+ // 不是管理员,需要验证是否可以删除
|
|
|
+ ResultContent<ProjectCommonConfigModel> content = projectCommonConfigService.getConfigInfoAndCheck(orgUserFace.getProjectOid());
|
|
|
+ if (content.isFailed()) {
|
|
|
+ return ResultContent.buildFail(content.getMsg());
|
|
|
+ }
|
|
|
+ ProjectCommonConfigModel configModel = content.getContent();
|
|
|
+ Boolean isAllowUpdateFace = configModel.getIsAllowUpdateFace();
|
|
|
+ if (isAllowUpdateFace == null || !isAllowUpdateFace) {
|
|
|
+ return ResultContent.buildFail("系统不允许删除人脸信息");
|
|
|
+ }
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(orgUserFace.getUpdateFaceFileId())) {
|
|
|
com.github.microservice.auth.client.content.ResultContent resultContent = userFaceService.delete(orgUserFace.getUserId(), orgUserFace.getUpdateFaceFileId());
|
|
|
@@ -208,6 +244,51 @@ public class OrgUserFaceService extends SuperService {
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
|
|
|
+ public ResultContent getDetail(String id) {
|
|
|
+ OrgUserFace orgUserFace = orgUserFaceDao.findTopById(id);
|
|
|
+ if (orgUserFace == null) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(toModel(orgUserFace));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核批量
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent auditsFace(OrgUserFaceAuditsParam param) {
|
|
|
+ List<String> ids = param.getIds();
|
|
|
+ if (ObjectUtils.isEmpty(ids)) {
|
|
|
+ return ResultContent.buildFail("ids不能为空");
|
|
|
+ }
|
|
|
+ String auditRemark = param.getAuditRemark();
|
|
|
+ AuditState auditState = param.getAuditState();
|
|
|
+ if (auditState == null) {
|
|
|
+ return ResultContent.buildFail("审核状态不能为空");
|
|
|
+ }
|
|
|
+ if (auditState == AuditState.Refuse && StringUtils.isEmpty(auditRemark)) {
|
|
|
+ return ResultContent.buildFail("原因不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 操作结果
|
|
|
+ OutNumberModel numberModel = new OutNumberModel();
|
|
|
+ for (String id : ids) {
|
|
|
+ OrgUserFaceAuditParam param1 = new OrgUserFaceAuditParam();
|
|
|
+ param1.setId(id);
|
|
|
+ param1.setAuditRemark(auditRemark);
|
|
|
+ param1.setAuditState(auditState);
|
|
|
+ ResultContent _temp = auditFace(param1);
|
|
|
+ if (_temp.isSuccess()) {
|
|
|
+ numberModel.addSuccess(id, "成功");
|
|
|
+ } else {
|
|
|
+ numberModel.addFail(id, _temp.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(numberModel);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 审核
|
|
|
*
|
|
|
@@ -219,10 +300,11 @@ public class OrgUserFaceService extends SuperService {
|
|
|
if (orgUserFace == null) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
}
|
|
|
- if (param.getAuditState() != AuditState.WaitAudit) {
|
|
|
+ if (orgUserFace.getAuditState() != AuditState.WaitAudit) {
|
|
|
return ResultContent.buildFail("数据已审核");
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, orgUserFace, "id");
|
|
|
+
|
|
|
if (orgUserFace.getAuditState() == AuditState.Audited) {
|
|
|
// 通过
|
|
|
ResultContent<String> content = syncFace(orgUserFace);
|
|
|
@@ -362,6 +444,24 @@ public class OrgUserFaceService extends SuperService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 项目用户信息发生变化,更新人脸信息冗余的用户信息
|
|
|
+ *
|
|
|
+ * @param organizationUser
|
|
|
+ */
|
|
|
+ public void updateAllUser(OrganizationUser organizationUser) {
|
|
|
+ if (ObjectUtils.isNotEmpty(organizationUser)) {
|
|
|
+ List<OrgUserFace> list = orgUserFaceDao.findByUserIdAndProjectOidOrderByCreateTimeDesc(organizationUser.getUserId(), organizationUser.getProjectOid());
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ for (OrgUserFace orgUserFace : list) {
|
|
|
+ fillEntityUserInfo(orgUserFace, organizationUser);
|
|
|
+ orgUserFaceDao.save(orgUserFace);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 填充用户信息
|
|
|
*
|
|
|
@@ -397,8 +497,9 @@ public class OrgUserFaceService extends SuperService {
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
model = new OrgUserFaceModel();
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
- model.setUserAccount(userAccountService.toSimpleModel(entity.getUserAccount()));
|
|
|
+ model.setUserAccount(userAccountService.toSimpleDesenModel(entity.getUserAccount()));
|
|
|
model.setOrganizationUser(organizationUserServiceImpl.toModel(entity.getOrganizationUser()));
|
|
|
+ model.setAuditUserAccount(userAccountService.toSimpleModel(entity.getAuditUserId()));
|
|
|
}
|
|
|
return model;
|
|
|
}
|