|
|
@@ -1,20 +1,27 @@
|
|
|
package com.zhongshu.card.server.core.service.gateDoor;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.github.microservice.core.util.random.RandomUtil;
|
|
|
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.net.ResultContent;
|
|
|
+import com.github.microservice.types.deviceUse.OperateState;
|
|
|
+import com.github.microservice.types.deviceUse.OperateType;
|
|
|
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.payment.RequestInfoService;
|
|
|
import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -29,6 +36,9 @@ public class GateDoorService extends SuperService {
|
|
|
@Autowired
|
|
|
RequestInfoService requestInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DeviceUseRecordService deviceUseRecordService;
|
|
|
+
|
|
|
/**
|
|
|
* 闸机方法 onLine
|
|
|
*
|
|
|
@@ -65,4 +75,156 @@ public class GateDoorService extends SuperService {
|
|
|
return ResultContent.buildSuccess(JSONUtil.toJsonStr(resultModel));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 门闸的开门使用的 参数
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ResultContent gateDoorUseRecord(GateDoorIotParam param) {
|
|
|
+ GateDoorUseResult result = new GateDoorUseResult();
|
|
|
+ GateDoorInfoParam info = param.getInfo();
|
|
|
+ log.info("闸机使用记录 gateDoorUseRecord...");
|
|
|
+ if (ObjectUtils.isNotEmpty(info)) {
|
|
|
+ // 封装记录日志参数
|
|
|
+ GateDoorUseParam useParam = new GateDoorUseParam();
|
|
|
+ useParam.setMqttDataId(param.getMqttDataId());
|
|
|
+ useParam.setDeviceId(param.getDeviceId());
|
|
|
+ useParam.setGateWayId(param.getGateWayId());
|
|
|
+
|
|
|
+ String VerifyStatus = info.getVerifyStatus();
|
|
|
+ if (StringUtils.isNotEmpty(VerifyStatus)) {
|
|
|
+ if ("1".equals(VerifyStatus)) {
|
|
|
+ // 成功
|
|
|
+ useParam.setOperateState(OperateState.Success);
|
|
|
+ } else if ("2".equals(VerifyStatus)) {
|
|
|
+ // 失败
|
|
|
+ useParam.setOperateState(OperateState.Failed);
|
|
|
+ } else {
|
|
|
+ // 未知
|
|
|
+ useParam.setOperateState(OperateState.Unknown);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 未知
|
|
|
+ useParam.setOperateState(OperateState.Failed);
|
|
|
+ }
|
|
|
+ // 使用操作方式
|
|
|
+ if (StringUtils.isNotEmpty(info.getPic())) {
|
|
|
+ // 人脸形式
|
|
|
+ useParam.setOperateType(OperateType.Face);
|
|
|
+ } else {
|
|
|
+ String cardNum2 = info.getCardNum2();
|
|
|
+ if (StringUtils.isNotEmpty(cardNum2)) {
|
|
|
+ useParam.setOperateType(OperateType.Card);
|
|
|
+ useParam.setCardNo(cardNum2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (useParam.getOperateType() == null) {
|
|
|
+ useParam.setOperateType(OperateType.Unknown);
|
|
|
+ }
|
|
|
+ GateDoorFailCardInfo cardInfo = info.getCardInfo();
|
|
|
+ if (StringUtils.isEmpty(useParam.getCardNo()) && ObjectUtils.isNotEmpty(cardInfo)) {
|
|
|
+ useParam.setCardNo(cardInfo.getCardNum());
|
|
|
+ useParam.setOperateType(OperateType.Card);
|
|
|
+ }
|
|
|
+ useParam.setTime(info.getTime());
|
|
|
+ useParam.setUserId(info.getCustomId());
|
|
|
+ useParam.setIsOffLine(param.getIsOffLine());
|
|
|
+ useParam.setData(param);
|
|
|
+ useParam.setOperator(param.getOperator());
|
|
|
+ useParam.setPic(info.getPic());
|
|
|
+ info.setPic("");
|
|
|
+ ResultContent<DeviceUseRecords> resultContent = deviceUseRecordService.saveDeviceLogs(useParam);
|
|
|
+ if (resultContent.isSuccess()) {
|
|
|
+ DeviceUseRecords records = resultContent.getContent();
|
|
|
+ if (records.getOperateState() == OperateState.Success) {
|
|
|
+ result.setSuccess("成功");
|
|
|
+ } else {
|
|
|
+ result.setFailed(records.getMsg());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.setFailed(resultContent.getMsg());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.setFailed("数据为空");
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(JSONUtil.toJsonStr(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检查设备使用的 参数验证
|
|
|
+ *
|
|
|
+ * @param entity
|
|
|
+ */
|
|
|
+ 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;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
}
|