Browse Source

更新!

TRX 1 year ago
parent
commit
102c7ef6fd

+ 3 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceUseRecordModel.java

@@ -66,6 +66,9 @@ public class DeviceUseRecordModel extends SuperModel {
     @Schema(description = "卡片信息")
     private CardInfoStoreModel cardInfo;
 
+    @Schema(description = "人脸信息")
+    private String pic = "";
+
     //------------------用户信息 start-------------------
     @Schema(description = "用户userId")
     private String userId;

+ 8 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/gateDoor/GateDoorController.java

@@ -45,10 +45,16 @@ public class GateDoorController {
         return gateDoorService.offLine(param);
     }
 
-    @Operation(summary = "门闸 认证识别人员信息上传", description = "门闸 认证识别人员信息上传")
+    @Operation(summary = "门闸 认证识别人员信息上传消息", description = "门闸 认证识别人员信息上传消息")
     @RequestMapping(value = "recPush", method = {RequestMethod.POST})
     public ResultContent recPush(@RequestBody GateDoorIotParam param) {
-        return this.deviceUseRecordService.gateDoorUseRecord(param);
+        return this.gateDoorService.gateDoorUseRecord(param);
+    }
+
+    @Operation(summary = "门闸刷卡开门失败消息", description = "门闸刷卡开门失败消息")
+    @RequestMapping(value = "cardPush", method = {RequestMethod.POST})
+    public ResultContent cardPush(@RequestBody GateDoorIotParam param) {
+        return this.gateDoorService.gateDoorUseRecord(param);
     }
 
 }

+ 5 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/DeviceUseRecords.java

@@ -73,6 +73,9 @@ public class DeviceUseRecords extends SuperMain {
     @Schema(description = "卡片信息")
     private CardInfoStoreModel cardInfo;
 
+    @Schema(description = "人脸信息")
+    private String pic = "";
+
     //------------------用户信息 start-------------------
     @Schema(description = "用户userId")
     private String userId;
@@ -105,4 +108,6 @@ public class DeviceUseRecords extends SuperMain {
     @Schema(description = "关联的数据")
     private Object data;
 
+    @Schema(description = "操作类型")
+    private String operator;
 }

+ 3 - 63
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceUseRecordService.java

@@ -75,69 +75,6 @@ public class DeviceUseRecordService extends SuperService {
 
     private static Long ttlTime = 60 * 24 * 60 * 60 * 1000L;
 
-    /**
-     * 门闸的开门使用的 参数
-     *
-     * @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.Unknown);
-            }
-            // 使用操作方式
-            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);
-            }
-            useParam.setTime(info.getTime());
-            useParam.setUserId(info.getCustomId());
-            useParam.setIsOffLine(param.getIsOffLine());
-            useParam.setData(param);
-            ResultContent<DeviceUseRecords> resultContent = saveDeviceLogs(useParam);
-            if (resultContent.isSuccess()) {
-                result.setSuccess("成功");
-            } else {
-                result.setFailed(resultContent.getMsg());
-            }
-        } else {
-            result.setFailed("数据为空");
-        }
-        return ResultContent.buildSuccess(JSONUtil.toJsonStr(result));
-    }
-
     /**
      * 设备使用日志 (物联网来的数据)
      *
@@ -193,6 +130,9 @@ public class DeviceUseRecordService extends SuperService {
                 if (StringUtils.isNotEmpty(userId)) {
                     userAccount = userCountDao.findTopByUserId(userId);
                 }
+                if (ObjectUtils.isEmpty(userId)) {
+                    userId = "陌生人";
+                }
                 deviceUseRecord.setUserId(userId);
                 deviceUseRecord.setUserAccount(userAccountService.toSimpleModel(userAccount));
                 if (StringUtils.isNotEmpty(param.getTime())) {

+ 163 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/gateDoor/GateDoorService.java

@@ -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;
+//                }
+//            }
+//        }
+    }
+
 }