Explorar o código

2022-12-21 一体机物联控制权限相关功能代码。

chaiyunlong %!s(int64=3) %!d(string=hai) anos
pai
achega
dec665cf1d

+ 16 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/controller/OneMachineController.java

@@ -397,7 +397,7 @@ public class OneMachineController extends BaseController {
     }
 
 
-    @ApiOperation("物联签到验证")
+    @ApiOperation("物联签到验证:刷卡验证")
     @GetMapping("/{subId}/LotInCheck/{username}")
     public ResultData checkLot(@PathVariable("username") String username, @PathVariable("subId") Long subId, HttpServletRequest request) {
         //获取指定用户信息
@@ -414,4 +414,19 @@ public class OneMachineController extends BaseController {
         return ResultData.success();
     }
 
+
+
+    /**
+     * 物联控制,校验人脸识别
+     *
+     * @param code
+     * @param faceVO
+     * @return
+     */
+    @ApiOperation("物联控制,校验人脸识别")
+    @PostMapping("/{code}/lotSignIn")
+    public ResultData lotPostSignIn(@PathVariable @ApiParam("验证码") String code, @RequestBody @ApiParam("特征数据") FaceVO faceVO) {
+        return oneMachineService.lotPostSignIn(code, faceVO.getData());
+    }
+
 }

+ 45 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/service/OneMachineService.java

@@ -660,4 +660,49 @@ public class OneMachineService implements ValidationSignInPerInfo {
             }
         }
     }
+
+
+
+    /**
+     * 提交签到(人脸)/签出记录
+     *
+     * @param code     验证码
+     * @param face     人脸特征码
+     * @return
+     */
+    public ResultData lotPostSignIn(String code, byte[] face) {
+        try {
+            logger.info("&&&&&&&&&&&&&&&&&&&&&&" + code + ",");
+            if (StringUtils.isEmpty(code)) {
+                //            throw new CaptchaException("签到验证码错误,请重新刷卡重试!");
+                ResultData.fail(600, "签到验证码错误,请重新刷卡重试!");
+            }
+            String verifyKey = BaseConstants.SINGIN_CAPTCHA_CODE_KEY + code;
+            SingInUser user = redisService.getCacheObject(verifyKey);
+            if (user == null || user.getUserId() == null) {
+                ResultData.fail(600, "签到&签出人脸已超时,请重新刷卡重试!");
+            }
+            if (user != null) {
+                String s = StrUtil.subAfter(code, "_", true);
+
+                logger.info("1111111签到调用人脸服务");
+                //调用人脸验证
+                R r = faceCompare(user.getUserId(), face);
+                //验证失败刷新验证码时间
+                if (r.getCode() != 200) {
+                    return ResultData.fail(r.getMsg());
+                }
+                logger.info("2222222人脸服务调用完成!");
+
+
+                logger.info("333333用户签到完成!");
+                return ResultData.success();
+            }
+        } catch (Exception e) {
+            e.getStackTrace();
+        }
+        return ResultData.fail();
+    }
+
+
 }