ImsDeviceController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/8/7 0007
  6. * Time: 15:44
  7. *
  8. * Ims 设备类
  9. */
  10. class ImsDeviceController extends Controller
  11. {
  12. public $layout = false;
  13. //维修工单列表 TODO 页面数据补齐
  14. public function actionRepairOrder()
  15. {
  16. $page = Req::get('page')?Req::get('page'):1;
  17. $http = http('repair-order/page/coach/'.$page,'POST', $this->authUsername, array());
  18. $response = formatResponse($http);
  19. $data = $response['data'];
  20. if($response['status']){
  21. $result['page'] = $data;
  22. $result['list'] = $data['list'];
  23. }else{
  24. $result['page'] = array();
  25. $result['list'] = array();
  26. }
  27. $this->render('repairOrder', $result);
  28. }
  29. //新增维修工单
  30. public function actionCreateRepairOrder()
  31. {
  32. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  33. $result['uploadUrl'] = $url;
  34. $result['basic'] = $this->setToken();
  35. //todo 地址待修改
  36. $http = http('storage-inventory/coach-item/0', 'GET', $this->authUsername, array());
  37. $response = formatResponse($http);
  38. $result['itemList'] = $response['data'];
  39. $result['coachName'] = Yii::app()->session['coachInfo']['coach_name'];
  40. $result['schoolName'] = isset($this->schoolInfo->school_name)?$this->schoolInfo->school_name:'';
  41. $this->render('createRepairOrder', $result);
  42. }
  43. //关联资产
  44. public function actionGetFixed()
  45. {
  46. $itemId = Req::get('itemId')?Req::get('itemId'):0;
  47. $http = http('equipment/coach/'. $itemId, 'GET', $this->authUsername, array());
  48. $response = formatResponse($http);
  49. if($response['status']){
  50. returnMsg(1,'ok', $response['data']);
  51. }else{
  52. returnMsg(0,$response['data']);
  53. }
  54. }
  55. //保存提交工单
  56. public function actionAjaxSaveOrder()
  57. {
  58. $id = Req::post('id')?Req::post('id'):'';
  59. $title = Req::post('title')?Req::post('title'):'';
  60. $reserveTime = Req::post('reserveTime')?Req::post('reserveTime'):'';
  61. $remarks = Req::post('remarks')?Req::post('remarks'):'';
  62. $priority = Req::post('priority')?Req::post('priority'):0;
  63. $itemId = Req::post('itemId')?Req::post('itemId'):0;
  64. $fixedCode = Req::post('fixedCode')?Req::post('fixedCode'):'';
  65. $imgArr = Req::post('imgArr')?Req::post('imgArr'):array();
  66. if(isset(Yii::app()->session['coachInfo']['school_id'])){
  67. $schoolId = Yii::app()->session['coachInfo']['school_id'];
  68. }else{
  69. $schoolId = 0;
  70. }
  71. $submitArr = array(
  72. '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
  73. );
  74. $url = $id ? 'repair-order/coach-edit' :'repair-order/coach';
  75. $method = $id ? 'PUT' : 'POST';
  76. if($id){
  77. $submitArr['id'] = $id;
  78. }
  79. $http = http($url, $method, $this->authUsername, $submitArr);
  80. $response = formatResponse($http);
  81. if($response['status']){
  82. returnMsg(1,'ok', $response['data']);
  83. }else{
  84. returnMsg(0,$response['data']);
  85. }
  86. }
  87. //编辑维修工单
  88. public function actionEditRepairOrder()
  89. {
  90. $id = Req::get('id')?Req::get('id'):0;
  91. $http = http('repair-order/'.$id,'GET', $this->authUsername, array());
  92. $response = formatResponse($http);
  93. $data = $response['data'];
  94. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  95. $data['uploadUrl'] = $url;
  96. $data['basic'] = $this->setToken();
  97. //todo 地址待修改
  98. $http_item = http('storage-inventory/coach-item/0', 'GET', $this->authUsername, array());
  99. $response_item = formatResponse($http_item);
  100. $data['itemList'] = $response_item['data'];
  101. $data['coachName'] = Yii::app()->session['coachInfo']['coach_name'];
  102. $data['schoolName'] = isset($this->schoolInfo->school_name)?$this->schoolInfo->school_name:'';
  103. $this->render('editRepairOrder', $data);
  104. }
  105. //查看维修工单
  106. public function actionViewRepairOrder()
  107. {
  108. $id = Req::get('id')?Req::get('id'):0;
  109. $http = http('repair-order/'.$id,'GET', $this->authUsername, array());
  110. $response = formatResponse($http);
  111. $data = $response['data'];
  112. $data['coachName'] = Yii::app()->session['coachInfo']['coach_name'];
  113. $data['schoolName'] = isset($this->schoolInfo->school_name)?$this->schoolInfo->school_name:'';
  114. $this->render('viewRepairOrder', $data);
  115. }
  116. //确认提交
  117. public function actionConfirmSubmit(){
  118. $id = Req::get('id')?Req::get('id'):0;
  119. $http = http('repair-order/coach-commit/'.$id,'POST', $this->authUsername, array());
  120. $response = formatResponse($http);
  121. if($response['status']){
  122. returnMsg(1,'ok', $response['data']);
  123. }else{
  124. returnMsg(0,$response['data']);
  125. }
  126. }
  127. //确认结果
  128. public function actionConfirmResult()
  129. {
  130. $id = Req::get('id')?Req::get('id'):0;
  131. $http = http('repair-order/coach/commit-good/'.$id,'PUT', $this->authUsername, array());
  132. $response = formatResponse($http);
  133. if($response['status']){
  134. returnMsg(1,'ok', $response['data']);
  135. }else{
  136. returnMsg(0,$response['data']);
  137. }
  138. }
  139. //维修记录列表
  140. public function actionRepairRecord()
  141. {
  142. $params = array();
  143. if(Req::get('rCode')){
  144. $params['rCode'] = Req::get('rCode');
  145. }
  146. $page = Req::get('page') ? Req::get('page') : 1;
  147. //TODO 参数名
  148. if (Req::get('allocationType')!=-1) {
  149. $params['allocationType'] = Req::get('allocationType');
  150. }
  151. if (Req::get('repairType')!=-1) {
  152. $params['repairType'] = Req::get('repairType');
  153. }
  154. if(Req::get('repairResult')!=-1){
  155. $params['repairResult'] = Req::get('repairResult');
  156. }
  157. $res = http('repair-record/coach/page/' . $page, 'POST', $this->authUsername,$params);
  158. $res = formatResponse($res);
  159. $result['list'] = array();
  160. if ($res['status'] == 1) {
  161. $result['list'] = $res['data']['list'];
  162. $result['page'] = $res['data'];
  163. } else {
  164. $result['list'] = array();
  165. $result['page'] = array();
  166. }
  167. $this->render('repairRecord', $result);
  168. }
  169. //查看维修记录
  170. public function actionViewRecord()
  171. {
  172. $id = Req::get('id')?Req::get('id'):0;
  173. $http = http('repair-record/'.$id,'GET', $this->authUsername, array());
  174. $response = formatResponse($http);
  175. $data = $response['data'];
  176. $this->render('viewRecord', $data);
  177. }
  178. public function setToken(){
  179. $sign = $this->authUsername.Yii::app()->params['ims']['sign_url'].Yii::app()->params['ims']['sign'];
  180. $authPassword = md5($sign);
  181. $basic = "Basic ". base64_encode($this->authUsername.":".$authPassword);
  182. return $basic;
  183. }
  184. //打印量列表
  185. public function actionPrintUploadList(){
  186. $params = array();
  187. if(Req::get('startDate')){
  188. $params['beginDate'] = strtotime(Req::get('startDate'))*1000;
  189. $result['startDate']=Req::get('startDate');
  190. }
  191. if(Req::get('endDate')){
  192. $params['endDate'] = (strtotime(Req::get('endDate'))+86400)*1000;
  193. $result['endDate']=Req::get('endDate');
  194. }
  195. if(Req::get('itemName')){
  196. $params['itemName'] = Req::get('itemName');
  197. $result['itemName']=Req::get('itemName');
  198. }
  199. $page = Req::get('page') ? Req::get('page') : 1;
  200. $params['pageNum'] = $page;
  201. //读取品目列表
  202. $printer=array();
  203. $res = http('equip-print/coach/printer', 'GET', $this->authUsername);
  204. $res = formatResponse($res);
  205. if ($res['status'] == 1) {
  206. $printer=$res['data'];
  207. }
  208. //读取打印量列表
  209. $res = http('equip-print/coach/page/', 'POST', $this->authUsername,$params);
  210. $res = formatResponse($res);
  211. $result['list'] = array();
  212. if ($res['status'] == 1) {
  213. $result['list'] = $res['data']['list'];
  214. $result['page'] = $res['data'];
  215. } else {
  216. $result['list'] = array();
  217. $result['page'] = array();
  218. }
  219. $result['printer']=$printer;
  220. $this->render('printUploadList', $result);
  221. }
  222. //新增打印量
  223. public function actionAddPrint(){
  224. //读取品目列表
  225. $printer=array();
  226. $res = http('equip-print/coach/printer', 'GET', $this->authUsername);
  227. $res = formatResponse($res);
  228. if ($res['status'] == 1) {
  229. $printer=$res['data'];
  230. }
  231. if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
  232. $result['coachName']=Yii::app()->session['coachInfo']['real_name'];
  233. }else{
  234. $result['coachName']=Yii::app()->session['coachInfo']['coach_name'];
  235. }
  236. $result['schoolName']=$this->schoolInfo['school_name'];
  237. $result['printer']=$printer;
  238. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  239. $result['uploadUrl'] = $url;
  240. $result['basic'] = $this->setToken();
  241. $this->render('addPrint', $result);
  242. }
  243. //提交保存
  244. public function actionSavePrintNumber(){
  245. $params = array();
  246. $params['print'] = Req::post('print');
  247. $params['remark'] = Req::post('remark');
  248. $params['status'] = Req::post('status');
  249. $params['fcId'] = Req::post('fcId');
  250. $params['imgUrls'] = Req::post('imgUrls');
  251. $id=Req::post('id');
  252. if($id){
  253. $params['eprId']=$id;
  254. $http = http('equip-print/coach/','PUT', $this->authUsername, $params);
  255. }else{
  256. $http = http('equip-print/coach/','POST', $this->authUsername, $params);
  257. }
  258. $response = formatResponse($http);
  259. if($response['status']){
  260. returnMsg(1,'ok', $response['data']);
  261. }else{
  262. returnMsg(0,$response['data']);
  263. }
  264. }
  265. //删除
  266. public function actionDelPrint(){
  267. $id = Req::post('id')?Req::post('id'):0;
  268. $http = http('equip-print/coach/'.$id,'DELETE', $this->authUsername, array());
  269. $response = formatResponse($http);
  270. if($response['status']){
  271. returnMsg(1,'ok', $response['data']);
  272. }else{
  273. returnMsg(0,$response['data']);
  274. }
  275. }
  276. //上传
  277. public function actionUpdatePrint(){
  278. $id = Req::post('id')?Req::post('id'):0;
  279. $param['eprId']=$id;
  280. $param['status']=1;
  281. $http = http('equip-print/coach/upload/'.$id,'PUT', $this->authUsername, $param);
  282. $response = formatResponse($http);
  283. if($response['status']){
  284. returnMsg(1,'ok', $response['data']);
  285. }else{
  286. returnMsg(0,$response['data']);
  287. }
  288. }
  289. //查看
  290. public function actionViewPrint(){
  291. $id = Req::get('id')?Req::get('id'):0;
  292. $http = http('equip-print/coach/'.$id,'GET', $this->authUsername, array());
  293. $response = formatResponse($http);
  294. $data = $response['data'];
  295. $printer=array();
  296. $res = http('equip-print/coach/printer', 'GET', $this->authUsername);
  297. $res = formatResponse($res);
  298. if ($res['status'] == 1) {
  299. $printer=$res['data'];
  300. }
  301. if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
  302. $data['coachName']=Yii::app()->session['coachInfo']['real_name'];
  303. }else{
  304. $data['coachName']=Yii::app()->session['coachInfo']['coach_name'];
  305. }
  306. $data['printer']=$printer;
  307. $data['schoolName']=$this->schoolInfo['school_name'];
  308. $this->render('viewPrint', $data);
  309. }
  310. //编辑
  311. public function actionEditPrint(){
  312. $id = Req::get('id')?Req::get('id'):0;
  313. $http = http('equip-print/coach/'.$id,'GET', $this->authUsername, array());
  314. $response = formatResponse($http);
  315. $data = $response['data'];
  316. $printer=array();
  317. $res = http('equip-print/coach/printer', 'GET', $this->authUsername);
  318. $res = formatResponse($res);
  319. if ($res['status'] == 1) {
  320. $printer=$res['data'];
  321. }
  322. if(isset(Yii::app()->session['coachInfo']['real_name']) && Yii::app()->session['coachInfo']['real_name']){
  323. $data['coachName']=Yii::app()->session['coachInfo']['real_name'];
  324. }else{
  325. $data['coachName']=Yii::app()->session['coachInfo']['coach_name'];
  326. }
  327. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  328. $data['uploadUrl'] = $url;
  329. $data['basic'] = $this->setToken();
  330. $data['printer']=$printer;
  331. $data['schoolName']=$this->schoolInfo['school_name'];
  332. $this->render('editPrint', $data);
  333. }
  334. /**
  335. * 清洁任务
  336. */
  337. public function actionTaskClean(){
  338. $page = Req::get('page')?Req::get('page'):1;
  339. $epName = Req::get('epName')?Req::get('epName'):'';
  340. $beginTime = Req::get('beginTime')?Req::get('beginTime'):'';
  341. $endTime = Req::get('endTime')?Req::get('endTime'):'';
  342. if($epName) $result['epName'] = $epName;
  343. if($beginTime) $result['beginTime'] = $beginTime;
  344. if($endTime) $result['endTime'] = $endTime;
  345. $result['isGroup'] = 0; // 0计划列表 1组长审核
  346. $result['pageNum'] = $page;
  347. $res = http('equip/plan/coach/page', 'POST', $this->authUsername,$result);
  348. $res = formatResponse($res);
  349. $data = $res['data'];
  350. //debug($data);
  351. if($res['status']){
  352. $result['page'] = $data;
  353. $result['list'] = $data['list'];
  354. }else{
  355. $result['page'] = array();
  356. $result['list'] = array();
  357. }
  358. $result['isGroup'] = 0;
  359. $this->render('taskClean', $result);
  360. }
  361. /**
  362. * 清洁任务审核
  363. */
  364. public function actionTaskVerify(){
  365. $page = Req::get('page')?Req::get('page'):1;
  366. $epName = Req::get('epName')?Req::get('epName'):'';
  367. $storageId = Req::get('storageId')?Req::get('storageId'):0; //学校
  368. $status = Req::get('taskStatus') ; //任务状态
  369. $res = Req::get('checkResult') ; //任务状态
  370. if($epName) $result['epName'] = $epName;
  371. if($storageId) $result['storageId'] = $storageId;
  372. if($status >= 0) $result['status'] = $status;
  373. if($res >= 0) $result['finalResult'] = $res;
  374. $result['isGroup'] = 1; // 0计划列表 1组长审核
  375. $result['pageNum'] = $page;
  376. $res = http('equip/plan/coach/page', 'POST', $this->authUsername,$result);
  377. $res = formatResponse($res);
  378. $school_info = http('equip/plan/coach/school', 'GET', $this->authUsername,array());
  379. $school_info = formatResponse($school_info);
  380. $schools = array();
  381. if(isset($school_info['data']) && $school_info['data']){
  382. foreach($school_info['data'] as $info){
  383. $schools[$info['storageId']] = $info['storageName'];
  384. }
  385. }
  386. $task_status = array(
  387. 0 => '未发布',
  388. 1 => '学管清洁中',
  389. 2 => '组长审核中',
  390. 3 => '组长审核完成',
  391. 4 => '设备部抽查中',
  392. 5 => '完成',
  393. 6 => '学管超时',
  394. 7 => '组长超时',
  395. );
  396. $result1 = array(
  397. 0 => '暂无',
  398. 1 => '合格',
  399. 2 => '不合格',
  400. );
  401. $data = $res['data'];
  402. $data['school'] = $schools;
  403. $data['taskStatus'] = $task_status;
  404. $data['result'] = $result1;
  405. if($res['status']){
  406. $result['page'] = $data;
  407. $result['list'] = $data['list'];
  408. }else{
  409. $result['page'] = array();
  410. $result['list'] = array();
  411. }
  412. /*echo "<pre>";
  413. print_r($result);exit;*/
  414. $this->render('taskVerify', $result);
  415. }
  416. /**
  417. * 提交审核
  418. */
  419. public function actionTaskSubmit(){
  420. if (Req::post('flag') && Req::post('flag') == 999) {
  421. $images = Req::post('images') ;
  422. $remark = Req::post('remark') ;
  423. $epsId = Req::post('epsId') ;
  424. $param['images']=$images;
  425. $param['remark']=$remark;
  426. $param['epsId']=$epsId;
  427. $http = http('equip/plan/coach/add','POST', $this->authUsername, $param);
  428. $response = formatResponse($http);
  429. if($response['status']){
  430. returnMsg(1,'ok', $response['data']);
  431. }else{
  432. returnMsg(0,$response['data']);
  433. }
  434. exit();
  435. }
  436. $epsId = Req::get('epsId')?Req::get('epsId'):1;
  437. $res = http('equip/plan/coach/task/'.$epsId, 'POST', $this->authUsername,array());
  438. $res = formatResponse($res);
  439. $data = $res['data'];
  440. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  441. $data['uploadUrl'] = $url;
  442. $data['basic'] = $this->setToken();
  443. $this->render('taskSubmit', $data);
  444. }
  445. public function actionTaskView(){
  446. if (Req::post('currentTaskId') && Req::post('currentTaskId') != '') {
  447. $verify = Req::post('verify') ;
  448. $comment = Req::post('comment') ;
  449. $currentTaskId = Req::post('currentTaskId') ;
  450. $param['values']['approve'] = $verify;
  451. $param['values']['comment'] = $comment;
  452. $http = http('activiti/coach/tasks/'."$currentTaskId".'/action/complete','PUT', $this->authUsername, $param);
  453. $response = formatResponse($http);
  454. if($response['status']){
  455. returnMsg(1,'ok', $response['data']);
  456. }else{
  457. returnMsg(0,$response['data']);
  458. }
  459. exit();
  460. }
  461. $epsId = Req::get('epsId')?Req::get('epsId'):1;
  462. $res = http('equip/plan/coach/task/'.$epsId, 'POST', $this->authUsername,array());
  463. $res = formatResponse($res);
  464. $data = $res['data'];
  465. $data['isGroup'] = Req::get('isGroup') ;
  466. $url = Yii::app()->params['ims']['url'].'api/upload/image';
  467. $data['uploadUrl'] = $url;
  468. $data['basic'] = $this->setToken();
  469. $data['page']=Req::get('page')?Req::get('page'):1;
  470. $this->render('taskView', $data);
  471. }
  472. /**
  473. * 清洁任务中止
  474. */
  475. public function actionSuspend(){
  476. $epsId = Req::get('epsId')?Req::get('epsId'):0;
  477. $http = http('equip/plan/coach/suspend/'.$epsId,'PUT', $this->authUsername, array());
  478. $response = formatResponse($http);
  479. if($response['status']){
  480. returnMsg(1,'ok', $response['data']);
  481. }else{
  482. returnMsg(0,$response['data']);
  483. }
  484. }
  485. }