liumiao
2021-02-02 1e1263856fbdb14e4d943d6fc5e26c98946f9b87
Merge remote-tracking branch 'origin/master'
2 files modified
78 ■■■■■ changed files
app/Http/Controllers/Api/v1/FaceController.php 61 ●●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/PersonController.php 17 ●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/FaceController.php
@@ -69,24 +69,24 @@
        $search = $faceObj->SearchFace($path);
        if(!isset($faceList['data']['Data']))
        {
            $res = $faceObj->AddFaceEntity($entityId, '学生');
            if($res['status'] != 1)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, $res['data']);
            }
            if(!isset($search['data']['Data']['MatchList']) || count($search['data']['Data']['MatchList']) == 0)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, '未检测到用户人脸');
                return $this->_response([], ResponseCode::PARAM_ERROR, '采集失败,未检测到用户人脸');
            }
            if(isset($search['data']['Data']['MatchList'][0]['FaceItems'][0]['Score']))
            {
                $score = $search['data']['Data']['MatchList'][0]['FaceItems'][0]['Score'];
                if($score > 0.65)
                if($score > 0.68)
                {
                    return $this->_response([], ResponseCode::PARAM_ERROR, '人脸已存在,请更改');
                    return $this->_response([], ResponseCode::PARAM_ERROR, '采集失败,人脸已绑定其他账号,请更改');
                }
            }
            $res = $faceObj->AddFaceEntity($entityId, '学生');
            if($res['status'] != 1)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, $res['data']);
            }
        }
        else
@@ -95,12 +95,11 @@
            {
                $entityIdUp = $search['data']['Data']['MatchList'][0]['FaceItems'][0]['EntityId'];
                $score = $search['data']['Data']['MatchList'][0]['FaceItems'][0]['Score'];
                if($entityIdUp != $entityId && $score > 0.65)
                if($entityIdUp != $entityId && $score > 0.68)
                {
                    return $this->_response([], ResponseCode::PARAM_ERROR, '人脸已存在其他账号,请更改');
                    return $this->_response([], ResponseCode::PARAM_ERROR, '采集失败,人脸已绑定其他账号,请更改');
                }
            }
            // 删除人脸
            if(count($faceList['data']['Data']['Faces']) != 0)
            {
@@ -113,7 +112,7 @@
        if($res['status'] != 1)
        {
            return $this->_response([], ResponseCode::PARAM_ERROR, '人脸不符合');
            return $this->_response([], ResponseCode::PARAM_ERROR, '采集失败,人脸不符合规范');
        }
        $where = [
            'id' => $request->studentId
@@ -122,9 +121,9 @@
        $res = StudentsModel::where($where)->update(['faceImg' => $faceImg]);
        if($res)
        {
            return $this->_response([], ResponseCode::SUCCESS, '录入成功');
            return $this->_response([], ResponseCode::SUCCESS, '采集成功');
        }
        return $this->_response([], ResponseCode::SUCCESS, '录入失败');
        return $this->_response([], ResponseCode::SUCCESS, '采集失败');
    }
@@ -193,7 +192,7 @@
        {
            if(!isset($res['data']['Data']['FaceCount']) || $res['data']['Data']['FaceCount'] > 1)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, '区域范围内只能包含1张人脸,请重新录入');
                return $this->_response([], ResponseCode::PARAM_ERROR, '采集失败,区域范围内只能包含1张人脸,请重新录入');
            }
        }
        else
@@ -387,18 +386,24 @@
            $res = $faceObj->SearchFace($httpUrl);
            if($res['status'] != 1)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, '未检测到人脸');
                return $this->_response([], ResponseCode::PARAM_ERROR, '签到失败,未识别到人脸信息,请联系老师处理');
            }
            if(!isset($res['data']['Data']['MatchList']) || count($res['data']['Data']['MatchList']) == 0)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, '未检测到人脸信息');
                return $this->_response([], ResponseCode::PARAM_ERROR, '签到失败,未识别到人脸信息,请联系老师处理');
            }
            $entityId = $res['data']['Data']['MatchList'][0]['FaceItems'][0]['EntityId'];
            $score = $res['data']['Data']['MatchList'][0]['FaceItems'][0]['Score'];
            if($score < 0.65)
            if($score < 0.30)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, '人脸识别率太低或更换注册人脸后请重新拍摄');
                return $this->_response([], ResponseCode::PARAM_ERROR, '签到失败,未识别到人脸信息,请联系老师处理');
            }
            if($score < 0.68)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, '签到失败,未识别到人脸信息,请联系老师处理');
            }
            $entityIdArr = explode('_', $entityId);
            $studentId = $entityIdArr[1];
@@ -424,7 +429,7 @@
        $userInfo = StudentsModel::where(['id' => $studentId])->select("id", "name", "faceImg")->first();
        if(!$userInfo)
        {
            return $this->_response([], ResponseCode::SUCCESS, $userInfo['name'] . '未注册人脸无法打卡');
            return $this->_response([], ResponseCode::SUCCESS, '签到失败,'.$userInfo['name'] . '未注册人脸,请联系老师处理');
        }
        if($request->type == 1)
        {
@@ -432,7 +437,7 @@
            $comStatus = $faceObj->CompareFace($path, $httpUrl);
            if(!$comStatus)
            {
                return $this->_response([], ResponseCode::SUCCESS, $userInfo['name'] . '人脸比对失败,请重新拍摄');
                return $this->_response([], ResponseCode::SUCCESS, '签到失败,'.$userInfo['name'] . '人脸比对失败,请联系老师处理');
            }
        }
@@ -440,7 +445,7 @@
        $res = DB::table('anni_classstudent')->where($where)->first();
        if(!$res)
        {
            return $this->_response([], ResponseCode::SUCCESS, $userInfo['name'] . '不在此班级');
            return $this->_response([], ResponseCode::SUCCESS, '签到失败,'.$userInfo['name'] . '不在此班级,请联系老师处理');
        }
        $where = [
@@ -449,7 +454,7 @@
        $info = StudentsModel::where($where)->select('id', 'faceImg')->first();
        if(empty($info->faceImg))
        {
            return $this->_response([], ResponseCode::SUCCESS, $userInfo['name'] . '未录入人脸');
            return $this->_response([], ResponseCode::SUCCESS, '签到失败,'.$userInfo['name'] . '未录入人脸,请联系老师处理');
        }
        $where = [
@@ -464,7 +469,7 @@
        $res = FaceAttendanceModel::where($where)->first();
        if(!empty($res))
        {
            return $this->_response([], ResponseCode::PARAM_ERROR, $userInfo['name'] . '已签到,请勿重复签到');
            return $this->_response([], ResponseCode::PARAM_ERROR, '已签到,'.$userInfo['name'] . '已签到,请勿重复签到');
        }
        DB::beginTransaction(); //开启事务
        try
@@ -671,6 +676,12 @@
            ->select('s.id', 's.username', 's.phoneNumber', 's.name', 's.orgId', 's.englishName', 's.faceImg')
            ->leftJoin('anni_students as s', 's.username', '=', 'cs.username')
            ->where($where)
            /* ->where(function ($query) use ($request) {
                 $query->where('s.phoneNumber', '=', $request->phone)
                     ->orWhere('s.name', 'like', '%' . trim($request->phone) . '%')
                     ->orWhere('s.englishName', 'like', '%' . trim($request->phone) . '%')
                     ->orWhere('s.username', 'like', '%' . trim($request->phone) . '%');
             })*/
            ->groupBy('s.username')->get()->toArray();
        foreach($arr as $k => $v)
        {
app/Http/Controllers/Api/v1/PersonController.php
@@ -31,6 +31,12 @@
        $teacherId = $this->getAndCheckTeacherId();
        $orgId = $request->post("orgId");
        $roleInfo = UserRoleModel::findRecordOneCondition(["OrgId" => $orgId, "UserId" => $teacherId, "RoleId" => 2026]);
//        $this->redis->upPrefix("App");
//        $redisName = $deviceType . $version;
//        $_key = RedisKey::MY_PAGE_MENU . $redisName;
//        $myMenuList = $this->redis->get($_key);
//        if(empty($myMenuList))
//        {
        //顶级分组菜单
        $whereTop['m.status'] = 1;
        $whereTop['m.appType'] = 2;
@@ -64,16 +70,17 @@
        $myMenu = MyMenuModel::getDataJoinList($query, $where, $select, $order)->toArray();
        foreach($myMenu as $key => $value)
        {
            $value['imageUrl'] = $this->fun->stitchingPath($value['imageUrl']);
            if(empty($roleInfo) && $value["jumpModule"] == 5001)
            {
                continue;
            }
//            if(empty($roleInfo) && $value["jumpModule"] == 5001)
//            {
//                continue;
//            }
            $myMenuTop[$value['parentid']]['menuList'][] = $value;
        }
        $myMenuList = array_values($myMenuTop);
//            $this->redis->set($_key, json_encode($myMenuList, true));
//        }
        return $this->_response($myMenuList);
    }
}