|
@@ -1,5 +1,7 @@
|
|
|
package com.zhongshu.card.server.core.service.visitor;
|
|
package com.zhongshu.card.server.core.service.visitor;
|
|
|
|
|
|
|
|
|
|
+import com.github.microservice.auth.client.model.UserFaceUploadModel;
|
|
|
|
|
+import com.github.microservice.auth.client.service.UserFaceService;
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
import com.github.microservice.net.ResultMessage;
|
|
@@ -7,14 +9,27 @@ import com.zhongshu.card.client.model.devices.DeviceInfoSimpleModel;
|
|
|
import com.zhongshu.card.client.model.visitor.VisitorMainModel;
|
|
import com.zhongshu.card.client.model.visitor.VisitorMainModel;
|
|
|
import com.zhongshu.card.client.model.visitor.VisitorMainParam;
|
|
import com.zhongshu.card.client.model.visitor.VisitorMainParam;
|
|
|
import com.zhongshu.card.client.model.visitor.VisitorMainSearch;
|
|
import com.zhongshu.card.client.model.visitor.VisitorMainSearch;
|
|
|
|
|
+import com.zhongshu.card.client.model.visitor.VisitorReViewParam;
|
|
|
|
|
+import com.zhongshu.card.client.type.visitor.VisitorState;
|
|
|
import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
|
|
import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
|
|
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationUserDao;
|
|
|
|
|
+import com.zhongshu.card.server.core.dao.org.UserCountDao;
|
|
|
import com.zhongshu.card.server.core.dao.scene.SceneComponentDao;
|
|
import com.zhongshu.card.server.core.dao.scene.SceneComponentDao;
|
|
|
import com.zhongshu.card.server.core.dao.visitor.VisitorMainDao;
|
|
import com.zhongshu.card.server.core.dao.visitor.VisitorMainDao;
|
|
|
|
|
+import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
|
|
|
|
|
+import com.zhongshu.card.server.core.domain.org.OrganizationUser;
|
|
|
|
|
+import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import com.zhongshu.card.server.core.domain.scene.SceneComponent;
|
|
import com.zhongshu.card.server.core.domain.scene.SceneComponent;
|
|
|
import com.zhongshu.card.server.core.domain.visitor.VisitorMain;
|
|
import com.zhongshu.card.server.core.domain.visitor.VisitorMain;
|
|
|
|
|
+import com.zhongshu.card.server.core.service.base.CommonService;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
|
|
import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
|
|
|
|
|
+import com.zhongshu.card.server.core.service.devices.permiss.Device2UseUsableService;
|
|
|
|
|
+import com.zhongshu.card.server.core.service.org.OrganizationUserServiceImpl;
|
|
|
|
|
+import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
|
|
import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
|
|
|
|
|
+import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
|
|
+import com.zhongshu.card.server.core.util.TempUserUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -51,20 +66,64 @@ public class VisitorMainService extends SuperService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private SceneComponentDao sceneComponentDao;
|
|
private SceneComponentDao sceneComponentDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private UserCountDao userCountDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OrganizationUserDao organizationUserDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OrganizationManagerServiceImpl organizationManagerService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OrganizationUserServiceImpl organizationUserService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private UserFaceService userFaceService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CommonService commonService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private Device2UseUsableService device2UseUsableService;
|
|
|
|
|
+
|
|
|
public ResultContent saveInfo(VisitorMainParam param) {
|
|
public ResultContent saveInfo(VisitorMainParam param) {
|
|
|
if (StringUtils.isEmpty(param.getSceneComponentId())) {
|
|
if (StringUtils.isEmpty(param.getSceneComponentId())) {
|
|
|
return ResultContent.buildFail("sceneComponentId 不能为空");
|
|
return ResultContent.buildFail("sceneComponentId 不能为空");
|
|
|
}
|
|
}
|
|
|
- if (StringUtils.isEmpty(param.getSceneComponentId())) {
|
|
|
|
|
- return ResultContent.buildFail("sceneComponentId 不能为空");
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(param.getVisitorUserId())) {
|
|
|
|
|
+ return ResultContent.buildFail("visitorUserId 不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(param.getFaceUrl())) {
|
|
|
|
|
+ return ResultContent.buildFail("faceUrl 不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long startTime = param.getStartTime();
|
|
|
|
|
+ if (CommonUtil.longIsEmpty(startTime)) {
|
|
|
|
|
+ return ResultContent.buildFail("到访时间不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (startTime <= System.currentTimeMillis()) {
|
|
|
|
|
+ return ResultContent.buildFail("到访时间不能小于当前时间");
|
|
|
}
|
|
}
|
|
|
|
|
+ Long minutes = param.getMinutes();
|
|
|
|
|
+ if (CommonUtil.longIsEmpty(minutes)) {
|
|
|
|
|
+ return ResultContent.buildFail("访问时长不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long endTime = startTime + minutes * 60 * 1000l;
|
|
|
|
|
|
|
|
|
|
+ // 所属组件信息
|
|
|
String sceneComponentId = param.getSceneComponentId();
|
|
String sceneComponentId = param.getSceneComponentId();
|
|
|
SceneComponent sceneComponent = sceneComponentDao.findTopById(sceneComponentId);
|
|
SceneComponent sceneComponent = sceneComponentDao.findTopById(sceneComponentId);
|
|
|
if (ObjectUtils.isEmpty(sceneComponent)) {
|
|
if (ObjectUtils.isEmpty(sceneComponent)) {
|
|
|
return ResultContent.buildFail("组件不存在");
|
|
return ResultContent.buildFail("组件不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ String projectOid = sceneComponent.getProjectOid();
|
|
|
|
|
+ UserAccount visitorUserAccount = userCountDao.findTopByUserId(param.getVisitorUserId());
|
|
|
|
|
+ if (ObjectUtils.isEmpty(visitorUserAccount)) {
|
|
|
|
|
+ return ResultContent.buildFail("被访人不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ OrganizationUser organizationUser = organizationUserService.getUserInProjectBindOrgUserInfo(projectOid, visitorUserAccount);
|
|
|
|
|
+
|
|
|
VisitorMain entity = null;
|
|
VisitorMain entity = null;
|
|
|
if (StringUtils.isNotEmpty(param.getId())) {
|
|
if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
entity = visitorMainDao.findTopById(param.getId());
|
|
entity = visitorMainDao.findTopById(param.getId());
|
|
@@ -73,12 +132,33 @@ public class VisitorMainService extends SuperService {
|
|
|
}
|
|
}
|
|
|
initUpdateEntity(entity);
|
|
initUpdateEntity(entity);
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ entity = new VisitorMain();
|
|
|
initEntityNoCheckOid(entity);
|
|
initEntityNoCheckOid(entity);
|
|
|
|
|
+ entity.setState(VisitorState.WaitReView);
|
|
|
}
|
|
}
|
|
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
|
|
|
|
|
|
|
+ entity.setVisitorUserAccount(visitorUserAccount);
|
|
|
|
|
+ entity.setOrganizationUser(organizationUser);
|
|
|
|
|
|
|
|
- BeanUtils.copyProperties(param, param);
|
|
|
|
|
|
|
+ // 申请用户
|
|
|
|
|
+ String applyUserId = getCurrentUserId();
|
|
|
|
|
+ UserAccount applyUserAccount = null;
|
|
|
|
|
+ if (StringUtils.isNotEmpty(applyUserId)) {
|
|
|
|
|
+ applyUserAccount = userCountDao.findTopByUserId(applyUserId);
|
|
|
|
|
+ OrganizationUser organizationUser1 = organizationUserService.getUserInProjectBindOrgUserInfo(projectOid, applyUserAccount);
|
|
|
|
|
+ entity.setApplyOrganizationUser(organizationUser1);
|
|
|
|
|
+ }
|
|
|
|
|
+ entity.setApplyUserId(applyUserId);
|
|
|
|
|
+ entity.setApplyUserAccount(applyUserAccount);
|
|
|
|
|
+ entity.setEndTime(endTime);
|
|
|
|
|
+ entity.setProjectOid(projectOid);
|
|
|
|
|
|
|
|
|
|
+ String tempUserId = applyUserId;
|
|
|
|
|
+ if (StringUtils.isEmpty(tempUserId)) {
|
|
|
|
|
+ tempUserId = TempUserUtil.getVisitorTempUserId();
|
|
|
|
|
+ }
|
|
|
|
|
+ entity.setTempUserId(tempUserId);
|
|
|
visitorMainDao.save(entity);
|
|
visitorMainDao.save(entity);
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
@@ -111,6 +191,109 @@ public class VisitorMainService extends SuperService {
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 拒绝
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResultContent refuseVisitApply(VisitorReViewParam param) {
|
|
|
|
|
+ VisitorMain visitorMain = visitorMainDao.findTopById(param.getId());
|
|
|
|
|
+ if (visitorMain == null) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ ResultContent resultContent = checkReViewInfo(visitorMain);
|
|
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
|
|
+ return resultContent;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 已拒绝状态
|
|
|
|
|
+ visitorMain.setState(VisitorState.Refuse);
|
|
|
|
|
+ visitorMain.setReviewRemark(param.getReviewRemark());
|
|
|
|
|
+ visitorMain.setReViewSuccess(Boolean.FALSE);
|
|
|
|
|
+ visitorMainDao.save(visitorMain);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 审核通过
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResultContent passVisitApply(VisitorReViewParam param) {
|
|
|
|
|
+ VisitorMain visitorMain = visitorMainDao.findTopById(param.getId());
|
|
|
|
|
+ if (visitorMain == null) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ ResultContent resultContent = checkReViewInfo(visitorMain);
|
|
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
|
|
+ return resultContent;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 通过状态
|
|
|
|
|
+ visitorMain.setState(VisitorState.WaitVisit);
|
|
|
|
|
+ visitorMain.setReviewRemark(param.getReviewRemark());
|
|
|
|
|
+ visitorMain.setReViewSuccess(Boolean.TRUE);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(param.getDeviceIds())) {
|
|
|
|
|
+ List<DeviceInfo> deviceInfos = deviceInfoService.getDevicesByDeviceIds(param.getDeviceIds());
|
|
|
|
|
+ visitorMain.setDeviceInfos(deviceInfos);
|
|
|
|
|
+ }
|
|
|
|
|
+ visitorMain.setDeviceIds(param.getDeviceIds());
|
|
|
|
|
+
|
|
|
|
|
+ String faceBase64 = commonService.getUrlFileBase64(visitorMain.getFaceUrl());
|
|
|
|
|
+ String updateFaceFileId = "";
|
|
|
|
|
+ // 维护管理权限中心用户的头像信息
|
|
|
|
|
+ UserFaceUploadModel userFaceUploadModel = new UserFaceUploadModel();
|
|
|
|
|
+ userFaceUploadModel.setUserId(visitorMain.getTempUserId());
|
|
|
|
|
+ userFaceUploadModel.setFile(faceBase64);
|
|
|
|
|
+ userFaceUploadModel.setUpdateFaceFileId(updateFaceFileId);
|
|
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String> content = userFaceService.upload(userFaceUploadModel);
|
|
|
|
|
+ if (content.isFailed()) {
|
|
|
|
|
+ return ResultContent.buildFail(content.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ updateFaceFileId = content.getContent();
|
|
|
|
|
+ visitorMain.setFaceFileId(updateFaceFileId);
|
|
|
|
|
+
|
|
|
|
|
+ // 把用户头像对应的设备权限写入 临时权限表
|
|
|
|
|
+ device2UseUsableService.addByVisitorData(visitorMain);
|
|
|
|
|
+
|
|
|
|
|
+ visitorMainDao.save(visitorMain);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 标记访客权限使用
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param fromDataId
|
|
|
|
|
+ */
|
|
|
|
|
+ public String markVisitor(String fromDataId) {
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fromDataId)) {
|
|
|
|
|
+ VisitorMain visitorMain = visitorMainDao.findTopById(fromDataId);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(visitorMain)) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (visitorMain.getState() == VisitorState.WaitVisit) {
|
|
|
|
|
+ visitorMain.setState(VisitorState.Visit);
|
|
|
|
|
+ visitorMain.setFirstVisitTime(System.currentTimeMillis());
|
|
|
|
|
+ visitorMainDao.save(visitorMain);
|
|
|
|
|
+ return visitorMain.getName();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent checkReViewInfo(VisitorMain visitorMain) {
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(visitorMain)) {
|
|
|
|
|
+ if (visitorMain.getState() == VisitorState.WaitReView && visitorMain.getEndTime() <= System.currentTimeMillis()) {
|
|
|
|
|
+ // 待审核 结束时间已过期
|
|
|
|
|
+ visitorMain.setState(VisitorState.Cancel);
|
|
|
|
|
+ visitorMain.setReviewRemark("申请数据过期");
|
|
|
|
|
+ visitorMainDao.save(visitorMain);
|
|
|
|
|
+ return ResultContent.buildFail("数据已过期");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public VisitorMainModel toModel(VisitorMain entity) {
|
|
public VisitorMainModel toModel(VisitorMain entity) {
|
|
|
VisitorMainModel model = null;
|
|
VisitorMainModel model = null;
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|