liumiao
2021-01-30 14ee79c4b8b656a428d78f421deb74ffe3609cf2
Merge remote-tracking branch 'origin/master'
2 files modified
93 ■■■■■ changed files
app/Http/Controllers/Api/v1/FaceController.php 71 ●●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/UsreController.php 22 ●●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/FaceController.php
@@ -25,9 +25,11 @@
class FaceController extends ApiController
{
    public function getFaceUrl($httpUrl) {
        return SHANGHAI_HTTPS . $httpUrl."?x-oss-process=style/thumb";
    public function getFaceUrl($httpUrl)
    {
        return SHANGHAI_HTTPS . $httpUrl . "?x-oss-process=style/thumb";
    }
    /**
     * 注册人脸
     * @param Request $request
@@ -48,7 +50,7 @@
        }
        $faceObj = new ALiYunFace();
        $path = $this->getFaceUrl( $request->httpUrl);
        $path = $this->getFaceUrl($request->httpUrl);
        $res = $this->checkFace($path);
        if($res != 'success')
@@ -57,39 +59,55 @@
        }
        $entityId = 'student_' . $request->studentId . '_' . $request->username;
        if(!isset($res['data']['Data']['MatchList']) || count($res['data']['Data']['MatchList']) == 0)
        // 样体人脸列表
        $faceList = $faceObj->GetFaceEntity($entityId);
        if($faceList['status'] != 1)
        {
            $res = $faceObj->SearchFace($path);
            return $this->_response([], ResponseCode::PARAM_ERROR, $faceList['data']);
        }
        //人脸搜索
        $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($res['data']['Data']['MatchList']) || count($res['data']['Data']['MatchList']) == 0)
            if(!isset($search['data']['Data']['MatchList']) || count($search['data']['Data']['MatchList']) == 0)
            {
                return $this->_response([], ResponseCode::PARAM_ERROR, '未检测到用户人脸');
            }
            if(isset($res['data']['Data']['MatchList'][0]['FaceItems'][0]['Score']))
            if(isset($search['data']['Data']['MatchList'][0]['FaceItems'][0]['Score']))
            {
                $score = $res['data']['Data']['MatchList'][0]['FaceItems'][0]['Score'];
                $score = $search['data']['Data']['MatchList'][0]['FaceItems'][0]['Score'];
                if($score > 0.65)
                {
                    return $this->_response([], ResponseCode::PARAM_ERROR, '人脸已存在,请更改');
                }
            }
            // 人脸列表
            $faceList = $faceObj->GetFaceEntity($entityId);
            if(!isset($faceList['data']['Data']))
        }
        else
        {
            if(isset($search['data']['Data']['MatchList'][0]['FaceItems'][0]['EntityId']))
            {
                $res = $faceObj->AddFaceEntity($entityId, '学生');
            }
            else
            {
                // 删除人脸
                if(count($faceList['data']['Data']['Faces']) != 0)
                $entityIdUp = $search['data']['Data']['MatchList'][0]['FaceItems'][0]['EntityId'];
                $score = $search['data']['Data']['MatchList'][0]['FaceItems'][0]['Score'];
                if($entityIdUp != $entityId && $score > 0.65)
                {
                    $id = $faceList['data']['Data']['Faces'][0]['FaceId'];
                    $faceObj->DeleteFace($id);
                    return $this->_response([], ResponseCode::PARAM_ERROR, '人脸已存在其他账号,请更改');
                }
            }
        }
            // 删除人脸
            if(count($faceList['data']['Data']['Faces']) != 0)
            {
                $id = $faceList['data']['Data']['Faces'][0]['FaceId'];
                $faceObj->DeleteFace($id);
            }
        }
        // 添加人脸
        $res = $faceObj->AddFace($entityId, $path);
@@ -135,8 +153,8 @@
            return $this->_response([], ResponseCode::SUCCESS, '未录入人脸无法比对');
        }
        $path = $this->getFaceUrl( $info->faceImg);
        $httpUrl = $this->getFaceUrl( $request->httpUrl);
        $path = $this->getFaceUrl($info->faceImg);
        $httpUrl = $this->getFaceUrl($request->httpUrl);
        $res = $this->checkFace($httpUrl);
        if($res != 'success')
        {
@@ -356,7 +374,7 @@
            return $this->_response([], ResponseCode::PARAM_ERROR, '签到失败,不在排课时间范围');
        }
        $faceObj = new ALiYunFace();
        $httpUrl = $this->getFaceUrl( $request->httpUrl);
        $httpUrl = $this->getFaceUrl($request->httpUrl);
        if($request->type == 1)
        {
@@ -410,9 +428,10 @@
        }
        if($request->type == 1)
        {
            $path = $this->getFaceUrl( $userInfo['faceImg']);
            $comStatus = $faceObj->CompareFace($path,$httpUrl);
            if(!$comStatus) {
            $path = $this->getFaceUrl($userInfo['faceImg']);
            $comStatus = $faceObj->CompareFace($path, $httpUrl);
            if(!$comStatus)
            {
                return $this->_response([], ResponseCode::SUCCESS, $userInfo['name'] . '人脸比对失败,请重新拍摄');
            }
        }
app/Http/Controllers/Api/v1/UsreController.php
@@ -192,7 +192,8 @@
        $username = $request->input('username');
        $where['a.username'] = $username;
        $List = DB::table('anni_classstudent as a')
            ->select('a.id','a.classCode','b.classMode','c.courseName','b.className','b.activationCode',
            ->select('a.id','a.classCode','a.courseStatus as classstudentStatus',
                'b.classMode','c.courseName','b.className','b.activationCode',
                'b.courseStatus','b.openclassTime','b.endTime','a.status')
            ->leftjoin('anni_class as b','b.classCode','=','a.classCode')
            ->leftjoin('anni_course as c','c.id','=','b.courseId')
@@ -205,12 +206,19 @@
                $List[$k]['openingstatus'] = 4; #已移除班级
            }else{
                if($v['courseStatus'] == 0){#1 课程状态 1.正常 2.停课 3.结课
                    if ($v['openclassTime'] > $date || $v['openclassTime'] == null){
                        $List[$k]['openingstatus'] = 1;#1 等课
                    }elseif ($v['openclassTime'] < $date && ($v['endTime'] > $date || $v['endTime'] == null )){
                        $List[$k]['openingstatus'] = 5;#5 开课
                    }elseif ($v['endTime'] < $date){
                        $List[$k]['openingstatus'] = 3;#3.结课
                    if ($v['classstudentStatus'] == 2){
                        $List[$k]['openingstatus'] = 2; # 2停课
                    }elseif ($v['classstudentStatus'] == 3){
                        $List[$k]['openingstatus'] = 3; # 3停课
                    }else{
                        if ($v['openclassTime'] > $date || $v['openclassTime'] == null){
                            $List[$k]['openingstatus'] = 1;#1 等课
                        }elseif ($v['openclassTime'] < $date && ($v['endTime'] > $date || $v['endTime'] == null )){
                            $List[$k]['openingstatus'] = 5;#5 开课
                        }elseif ($v['endTime'] < $date){
                            $List[$k]['openingstatus'] = 3;#3.结课
                        }
                    }
                }else{
                    $List[$k]['openingstatus'] = 6; # 转课中