123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/8/7 0007
- * Time: 15:44
- *
- * Ims 设备类
- */
- class ImsDeviceController extends Controller
- {
- public $layout = false;
- //维修工单列表 TODO 页面数据补齐
- public function actionRepairOrder()
- {
- $page = Req::get('page')?Req::get('page'):1;
- $http = http('repair-order/page/coach/'.$page,'POST', $this->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 "<pre>";
- 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']);
- }
- }
- }
|