|
|
@@ -1,15 +1,13 @@
|
|
|
package com.zhongshu.card.server.core.service.gateDoor;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.github.microservice.auth.client.service.UserFaceService;
|
|
|
import com.github.microservice.models.gateDoor.OnLineAckInfoModel;
|
|
|
import com.github.microservice.models.gateDoor.OnLineInfoParam;
|
|
|
import com.github.microservice.models.gateDoor.OnLineModel;
|
|
|
import com.github.microservice.models.gateDoor.OnLineParam;
|
|
|
import com.github.microservice.models.gateDoor.gateDoor.GateDoorIotParam;
|
|
|
-import com.github.microservice.models.gateDoor.use.GateDoorFailCardInfo;
|
|
|
-import com.github.microservice.models.gateDoor.use.GateDoorInfoParam;
|
|
|
-import com.github.microservice.models.gateDoor.use.GateDoorUseParam;
|
|
|
-import com.github.microservice.models.gateDoor.use.GateDoorUseResult;
|
|
|
+import com.github.microservice.models.gateDoor.use.*;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.types.deviceUse.OperateState;
|
|
|
import com.github.microservice.types.deviceUse.OperateType;
|
|
|
@@ -17,6 +15,7 @@ import com.zhongshu.card.client.type.payment.RequestType;
|
|
|
import com.zhongshu.card.server.core.domain.devices.DeviceUseRecords;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.devices.DeviceUseRecordService;
|
|
|
+import com.zhongshu.card.server.core.service.devices.permiss.DevicePermissVerifyService;
|
|
|
import com.zhongshu.card.server.core.service.payment.RequestInfoService;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -39,6 +38,12 @@ public class GateDoorService extends SuperService {
|
|
|
@Autowired
|
|
|
private DeviceUseRecordService deviceUseRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DevicePermissVerifyService devicePermissVerifyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserFaceService userFaceService;
|
|
|
+
|
|
|
/**
|
|
|
* 闸机方法 onLine
|
|
|
*
|
|
|
@@ -153,79 +158,46 @@ public class GateDoorService extends SuperService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 检查设备使用的 参数验证
|
|
|
+ * 门闸人脸在线验证
|
|
|
*
|
|
|
- * @param entity
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
*/
|
|
|
- public void checkUseDeviceData(DeviceUseRecords entity) {
|
|
|
-// // 主要是从设备、卡片等的基础信息验证
|
|
|
-// if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
-// // 1. 检查设备
|
|
|
-// if (ObjectUtils.isEmpty(entity.getDeviceInfo())) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("设备信息未找到");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// DeviceInfoStoreModel deviceInfo = entity.getDeviceInfo();
|
|
|
-// if (deviceInfo.getState() == null || deviceInfo.getState() != DataState.Enable) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("设备未启用");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// //2. 验证用户信息
|
|
|
-// UserCountSimpleModel userAccount = entity.getUserAccount();
|
|
|
-// if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("用户信息未确定");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// if (userAccount.getState() == null || userAccount.getState() != UserState.Normal) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg(String.format("用户已禁用"));
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// // 验证用户是否有设备申请权限
|
|
|
-// if (deviceInfo.getIsOpenUse() == null || !deviceInfo.getIsOpenUse()) {
|
|
|
-// DevicePermiss devicePermiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOid(entity.getUserId(), entity.getDeviceId(), entity.getProjectOid());
|
|
|
-// if (ObjectUtils.isEmpty(devicePermiss)) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("用户没有设备权限");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// if (devicePermiss.getDataState() == null || devicePermiss.getDataState() != DataState.Enable) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("用户权限未启用");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// Integer mode = entity.getMode();
|
|
|
-// if (mode == null) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("使用模式未确定");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// if (mode == 0) {
|
|
|
-// // 刷卡
|
|
|
-// if (ObjectUtils.isEmpty(entity.getCardInfo())) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("卡片未找到");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// CardInfoStoreModel cardInfo = entity.getCardInfo();
|
|
|
-// if (cardInfo.getIsCanceled() != null && cardInfo.getIsCanceled()) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg("卡片已作废");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-//
|
|
|
-// if (cardInfo.getCardState() == null || cardInfo.getCardState() != CardState.Enable) {
|
|
|
-// entity.setIsPassed(Boolean.FALSE);
|
|
|
-// entity.setMsg(String.format("卡片%s", cardInfo.getCardState().getRemark()));
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
- }
|
|
|
+ public ResultContent gateDoorOnLineVerify(GateDoorIotParam param) {
|
|
|
+ GateDoorOnLineUseResult result = new GateDoorOnLineUseResult();
|
|
|
+ GateDoorInfoParam info = param.getInfo();
|
|
|
+ log.info("闸机使用记录 gateDoorOnLineVerify...");
|
|
|
+ if (ObjectUtils.isNotEmpty(info)) {
|
|
|
+ String deviceId = param.getDeviceId();
|
|
|
+ String gateWayId = param.getGateWayId();
|
|
|
+ String mqttDataId = param.getMqttDataId();
|
|
|
+ result.setMqttDataId(mqttDataId);
|
|
|
+
|
|
|
+ GateDoorUseParam useParam = new GateDoorUseParam();
|
|
|
+ useParam.setMqttDataId(param.getMqttDataId());
|
|
|
+ useParam.setDeviceId(param.getDeviceId());
|
|
|
+ useParam.setGateWayId(param.getGateWayId());
|
|
|
+ String faceBase64Str = info.getPic();
|
|
|
+ // 根据人脸查找用户
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String> faceContent = userFaceService.matches(faceBase64Str);
|
|
|
+ String userId = "";
|
|
|
+ if (faceContent.isSuccess()) {
|
|
|
+ userId = faceContent.getContent();
|
|
|
+ } else {
|
|
|
+ result.setFailed(faceContent.getMsg());
|
|
|
+ }
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(userId)) {
|
|
|
+ // 验证用户对设备有误权限
|
|
|
+ ResultContent<String> resultContent = devicePermissVerifyService.verifyDevice(userId, deviceId);
|
|
|
+ if (resultContent.isSuccess()) {
|
|
|
+ result.setSuccess();
|
|
|
+ result.setMsg(resultContent.getContent());
|
|
|
+ } else {
|
|
|
+ result.setFailed(resultContent.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(JSONUtil.toJsonStr(result));
|
|
|
+ }
|
|
|
}
|