authUsername, array()); $response = formatResponse($http); $data = $response['data']; if($response['status']){ $result['page'] = $data; $result['list'] = $data['list']; }else{ $result['page'] = array(); $result['list'] = array(); } $this->render('repairOrder', $result); } //新增维修工单 public function actionCreateRepairOrder() { $url = Yii::app()->params['ims']['url'].'api/upload/image'; $result['uploadUrl'] = $url; $result['basic'] = $this->setToken(); //todo 地址待修改 $http = http('storage-inventory/coach-item/0', 'GET', $this->authUsername, array()); $response = formatResponse($http); $result['itemList'] = $response['data']; $result['coachName'] = Yii::app()->session['coachInfo']['coach_name']; $result['schoolName'] = isset($this->schoolInfo->school_name)?$this->schoolInfo->school_name:''; $this->render('createRepairOrder', $result); } //关联资产 public function actionGetFixed() { $itemId = Req::get('itemId')?Req::get('itemId'):0; $http = http('equipment/coach/'. $itemId, 'GET', $this->authUsername, array()); $response = formatResponse($http); if($response['status']){ returnMsg(1,'ok', $response['data']); }else{ returnMsg(0,$response['data']); } } //保存提交工单 public function actionAjaxSaveOrder() { $id = Req::post('id')?Req::post('id'):''; $title = Req::post('title')?Req::post('title'):''; $reserveTime = Req::post('reserveTime')?Req::post('reserveTime'):''; $remarks = Req::post('remarks')?Req::post('remarks'):''; $priority = Req::post('priority')?Req::post('priority'):0; $itemId = Req::post('itemId')?Req::post('itemId'):0; $fixedCode = Req::post('fixedCode')?Req::post('fixedCode'):''; $imgArr = Req::post('imgArr')?Req::post('imgArr'):array(); if(isset(Yii::app()->session['coachInfo']['school_id'])){ $schoolId = Yii::app()->session['coachInfo']['school_id']; }else{ $schoolId = 0; } $submitArr = array( 'title'=>$title, 'reserveTime'=>date('Y-m-d H:i:s',strtotime($reserveTime)),'remarks'=>$remarks,'priority'=>$priority,'itemId'=>$itemId,'fixedCode'=>$fixedCode,'imgUrls'=>(array)$imgArr,'storageId'=>$schoolId ); $url = $id ? 'repair-order/coach-edit' :'repair-order/coach'; $method = $id ? 'PUT' : 'POST'; if($id){ $submitArr['id'] = $id; } $http = http($url, $method, $this->authUsername, $submitArr); $response = formatResponse($http); if($response['status']){ returnMsg(1,'ok', $response['data']); }else{ returnMsg(0,$response['data']); } } //编辑维修工单 public function actionEditRepairOrder() { $id = Req::get('id')?Req::get('id'):0; $http = http('repair-order/'.$id,'GET', $this->authUsername, array()); $response = formatResponse($http); $data = $response['data']; $url = Yii::app()->params['ims']['url'].'api/upload/image'; $data['uploadUrl'] = $url; $data['basic'] = $this->setToken(); //todo 地址待修改 $http_item = http('storage-inventory/coach-item/0', 'GET', $this->authUsername, array()); $response_item = formatResponse($http_item); $data['itemList'] = $response_item['data']; $data['coachName'] = Yii::app()->session['coachInfo']['coach_name']; $data['schoolName'] = isset($this->schoolInfo->school_name)?$this->schoolInfo->school_name:''; $this->render('editRepairOrder', $data); } //查看维修工单 public function actionViewRepairOrder() { $id = Req::get('id')?Req::get('id'):0; $http = http('repair-order/'.$id,'GET', $this->authUsername, array()); $response = formatResponse($http); $data = $response['data']; $data['coachName'] = Yii::app()->session['coachInfo']['coach_name']; $data['schoolName'] = isset($this->schoolInfo->school_name)?$this->schoolInfo->school_name:''; $this->render('viewRepairOrder', $data); } //确认提交 public function actionConfirmSubmit(){ $id = Req::get('id')?Req::get('id'):0; $http = http('repair-order/coach-commit/'.$id,'POST', $this->authUsername, array()); $response = formatResponse($http); if($response['status']){ returnMsg(1,'ok', $response['data']); }else{ returnMsg(0,$response['data']); } } //确认结果 public function actionConfirmResult() { $id = Req::get('id')?Req::get('id'):0; $http = http('repair-order/coach/commit-good/'.$id,'PUT', $this->authUsername, array()); $response = formatResponse($http); if($response['status']){ returnMsg(1,'ok', $response['data']); }else{ returnMsg(0,$response['data']); } } //维修记录列表 public function actionRepairRecord() { $params = array(); if(Req::get('rCode')){ $params['rCode'] = Req::get('rCode'); } $page = Req::get('page') ? Req::get('page') : 1; //TODO 参数名 if (Req::get('allocationType')!=-1) { $params['allocationType'] = Req::get('allocationType'); } if (Req::get('repairType')!=-1) { $params['repairType'] = Req::get('repairType'); } if(Req::get('repairResult')!=-1){ $params['repairResult'] = Req::get('repairResult'); } $res = http('repair-record/coach/page/' . $page, 'POST', $this->authUsername,$params); $res = formatResponse($res); $result['list'] = array(); if ($res['status'] == 1) { $result['list'] = $res['data']['list']; $result['page'] = $res['data']; } else { $result['list'] = array(); $result['page'] = array(); } $this->render('repairRecord', $result); } //查看维修记录 public function actionViewRecord() { $id = Req::get('id')?Req::get('id'):0; $http = http('repair-record/'.$id,'GET', $this->authUsername, array()); $response = formatResponse($http); $data = $response['data']; $this->render('viewRecord', $data); } public function setToken(){ $sign = $this->authUsername.Yii::app()->params['ims']['sign_url'].Yii::app()->params['ims']['sign']; $authPassword = md5($sign); $basic = "Basic ". base64_encode($this->authUsername.":".$authPassword); return $basic; } //打印量列表 public function actionPrintUploadList(){ $params = array(); if(Req::get('startDate')){ $params['beginDate'] = strtotime(Req::get('startDate'))*1000; $result['startDate']=Req::get('startDate'); } if(Req::get('endDate')){ $params['endDate'] = (strtotime(Req::get('endDate'))+86400)*1000; $result['endDate']=Req::get('endDate'); } if(Req::get('itemName')){ $params['itemName'] = Req::get('itemName'); $result['itemName']=Req::get('itemName'); } $page = Req::get('page') ? Req::get('page') : 1; $params['pageNum'] = $page; //读取品目列表 $printer=array(); $res = http('equip-print/coach/printer', 'GET', $this->authUsername); $res = formatResponse($res); if ($res['status'] == 1) { $printer=$res['data']; } //读取打印量列表 $res = http('equip-print/coach/page/', 'POST', $this->authUsername,$params); $res = formatResponse($res); $result['list'] = array(); if ($res['status'] == 1) { $result['list'] = $res['data']['list']; $result['page'] = $res['data']; } else { $result['list'] = array(); $result['page'] = array(); } $result['printer']=$printer; $this->render('printUploadList', $result); } //新增打印量 public function actionAddPrint(){ //读取品目列表 $printer=array(); $res = http('equip-print/coach/printer', 'GET', $this->authUsername); $res = formatResponse($res); if ($res['status'] == 1) { $printer=$res['data']; } if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $result['coachName']=Yii::app()->session['coachInfo']['real_name']; }else{ $result['coachName']=Yii::app()->session['coachInfo']['coach_name']; } $result['schoolName']=$this->schoolInfo['school_name']; $result['printer']=$printer; $url = Yii::app()->params['ims']['url'].'api/upload/image'; $result['uploadUrl'] = $url; $result['basic'] = $this->setToken(); $this->render('addPrint', $result); } //提交保存 public function actionSavePrintNumber(){ $params = array(); $params['print'] = Req::post('print'); $params['remark'] = Req::post('remark'); $params['status'] = Req::post('status'); $params['fcId'] = Req::post('fcId'); $params['imgUrls'] = Req::post('imgUrls'); $id=Req::post('id'); if($id){ $params['eprId']=$id; $http = http('equip-print/coach/','PUT', $this->authUsername, $params); }else{ $http = http('equip-print/coach/','POST', $this->authUsername, $params); } $response = formatResponse($http); if($response['status']){ returnMsg(1,'ok', $response['data']); }else{ returnMsg(0,$response['data']); } } //删除 public function actionDelPrint(){ $id = Req::post('id')?Req::post('id'):0; $http = http('equip-print/coach/'.$id,'DELETE', $this->authUsername, array()); $response = formatResponse($http); if($response['status']){ returnMsg(1,'ok', $response['data']); }else{ returnMsg(0,$response['data']); } } //上传 public function actionUpdatePrint(){ $id = Req::post('id')?Req::post('id'):0; $param['eprId']=$id; $param['status']=1; $http = http('equip-print/coach/upload/'.$id,'PUT', $this->authUsername, $param); $response = formatResponse($http); if($response['status']){ returnMsg(1,'ok', $response['data']); }else{ returnMsg(0,$response['data']); } } //查看 public function actionViewPrint(){ $id = Req::get('id')?Req::get('id'):0; $http = http('equip-print/coach/'.$id,'GET', $this->authUsername, array()); $response = formatResponse($http); $data = $response['data']; $printer=array(); $res = http('equip-print/coach/printer', 'GET', $this->authUsername); $res = formatResponse($res); if ($res['status'] == 1) { $printer=$res['data']; } if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $data['coachName']=Yii::app()->session['coachInfo']['real_name']; }else{ $data['coachName']=Yii::app()->session['coachInfo']['coach_name']; } $data['printer']=$printer; $data['schoolName']=$this->schoolInfo['school_name']; $this->render('viewPrint', $data); } //编辑 public function actionEditPrint(){ $id = Req::get('id')?Req::get('id'):0; $http = http('equip-print/coach/'.$id,'GET', $this->authUsername, array()); $response = formatResponse($http); $data = $response['data']; $printer=array(); $res = http('equip-print/coach/printer', 'GET', $this->authUsername); $res = formatResponse($res); if ($res['status'] == 1) { $printer=$res['data']; } if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){ $data['coachName']=Yii::app()->session['coachInfo']['real_name']; }else{ $data['coachName']=Yii::app()->session['coachInfo']['coach_name']; } $url = Yii::app()->params['ims']['url'].'api/upload/image'; $data['uploadUrl'] = $url; $data['basic'] = $this->setToken(); $data['printer']=$printer; $data['schoolName']=$this->schoolInfo['school_name']; $this->render('editPrint', $data); } /** * 清洁任务 */ public function actionTaskClean(){ $page = Req::get('page')?Req::get('page'):1; $epName = Req::get('epName')?Req::get('epName'):''; $beginTime = Req::get('beginTime')?Req::get('beginTime'):''; $endTime = Req::get('endTime')?Req::get('endTime'):''; if($epName) $result['epName'] = $epName; if($beginTime) $result['beginTime'] = $beginTime; if($endTime) $result['endTime'] = $endTime; $result['isGroup'] = 0; // 0计划列表 1组长审核 $result['pageNum'] = $page; $res = http('equip/plan/coach/page', 'POST', $this->authUsername,$result); $res = formatResponse($res); $data = $res['data']; //debug($data); if($res['status']){ $result['page'] = $data; $result['list'] = $data['list']; }else{ $result['page'] = array(); $result['list'] = array(); } $result['isGroup'] = 0; $this->render('taskClean', $result); } /** * 清洁任务审核 */ public function actionTaskVerify(){ $page = Req::get('page')?Req::get('page'):1; $epName = Req::get('epName')?Req::get('epName'):''; $storageId = Req::get('storageId')?Req::get('storageId'):0; //学校 $status = Req::get('taskStatus') ; //任务状态 $res = Req::get('checkResult') ; //任务状态 if($epName) $result['epName'] = $epName; if($storageId) $result['storageId'] = $storageId; if($status >= 0) $result['status'] = $status; if($res >= 0) $result['finalResult'] = $res; $result['isGroup'] = 1; // 0计划列表 1组长审核 $result['pageNum'] = $page; $res = http('equip/plan/coach/page', 'POST', $this->authUsername,$result); $res = formatResponse($res); $school_info = http('equip/plan/coach/school', 'GET', $this->authUsername,array()); $school_info = formatResponse($school_info); $schools = array(); if(isset($school_info['data']) && $school_info['data']){ foreach($school_info['data'] as $info){ $schools[$info['storageId']] = $info['storageName']; } } $task_status = array( 0 => '未发布', 1 => '学管清洁中', 2 => '组长审核中', 3 => '组长审核完成', 4 => '设备部抽查中', 5 => '完成', 6 => '学管超时', 7 => '组长超时', ); $result1 = array( 0 => '暂无', 1 => '合格', 2 => '不合格', ); $data = $res['data']; $data['school'] = $schools; $data['taskStatus'] = $task_status; $data['result'] = $result1; if($res['status']){ $result['page'] = $data; $result['list'] = $data['list']; }else{ $result['page'] = array(); $result['list'] = array(); } /*echo "
";
        print_r($result);exit;*/

        $this->render('taskVerify', $result);
    }

    /**
     * 提交审核
     */
    public function actionTaskSubmit(){
        if (Req::post('flag') && Req::post('flag') == 999) {
            $images = Req::post('images') ;
            $remark = Req::post('remark') ;
            $epsId = Req::post('epsId') ;
            $param['images']=$images;
            $param['remark']=$remark;
            $param['epsId']=$epsId;
            $http = http('equip/plan/coach/add','POST', $this->authUsername, $param);
            $response = formatResponse($http);
            if($response['status']){
                returnMsg(1,'ok', $response['data']);
            }else{
                returnMsg(0,$response['data']);
            }
            exit();
        }
        $epsId = Req::get('epsId')?Req::get('epsId'):1;
        $res = http('equip/plan/coach/task/'.$epsId, 'POST', $this->authUsername,array());
        $res = formatResponse($res);
        $data = $res['data'];
        $url = Yii::app()->params['ims']['url'].'api/upload/image';
        $data['uploadUrl'] = $url;
        $data['basic'] = $this->setToken();
        $this->render('taskSubmit', $data);
    }

    public function actionTaskView(){
        if (Req::post('currentTaskId') && Req::post('currentTaskId') != '') {
            $verify = Req::post('verify') ;
            $comment = Req::post('comment') ;
            $currentTaskId = Req::post('currentTaskId') ;
            $param['values']['approve'] = $verify;
            $param['values']['comment'] = $comment;
            $http = http('activiti/coach/tasks/'."$currentTaskId".'/action/complete','PUT', $this->authUsername, $param);
            $response = formatResponse($http);
            if($response['status']){
                returnMsg(1,'ok', $response['data']);
            }else{
                returnMsg(0,$response['data']);
            }
            exit();
        }

        $epsId = Req::get('epsId')?Req::get('epsId'):1;
        $res = http('equip/plan/coach/task/'.$epsId, 'POST', $this->authUsername,array());
        $res = formatResponse($res);
        $data = $res['data'];
        $data['isGroup'] = Req::get('isGroup')  ;
        $url = Yii::app()->params['ims']['url'].'api/upload/image';
        $data['uploadUrl'] = $url;
        $data['basic'] = $this->setToken();
        $data['page']=Req::get('page')?Req::get('page'):1;
        $this->render('taskView', $data);
    }

    /**
     * 清洁任务中止
     */
    public function actionSuspend(){
        $epsId = Req::get('epsId')?Req::get('epsId'):0;
        $http = http('equip/plan/coach/suspend/'.$epsId,'PUT', $this->authUsername, array());
        $response = formatResponse($http);
        if($response['status']){
            returnMsg(1,'ok', $response['data']);
        }else{
            returnMsg(0,$response['data']);
        }
    }
}