Collection.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <?php
  2. namespace app\admin\controller\student;
  3. use app\common\controller\Backend;
  4. use app\common\model\Config as ConfigModel;
  5. use app\admin\model\Report;
  6. use app\admin\model\Fault;
  7. use think\exception\DbException;
  8. use think\exception\PDOException;
  9. use think\exception\ValidateException;
  10. use think\response\Json;
  11. use think\Db;
  12. use think\Env;
  13. /**
  14. *
  15. * @icon fa fa-circle-o
  16. */
  17. class Collection extends Backend
  18. {
  19. /**
  20. * Collection模型对象
  21. * @var \app\admin\model\teacher\Collection
  22. */
  23. protected $model = null;
  24. protected $exam_model = null;
  25. protected $whereExtend = null;
  26. protected $noNeedLogin = ['addreport','editreport','delreport'];
  27. public function _initialize()
  28. {
  29. parent::_initialize();
  30. $this->model = new \app\admin\model\teacher\Collection;
  31. $this->exam_model = new \app\admin\model\teacher\Exams;
  32. $this->assignConfig('sim_sim_type', ConfigModel::getSimTypeList());
  33. $this->assignConfig('sim_question_setting_method', ConfigModel::getSimQuestionList());
  34. $this->whereExtend['exam_collection_type'] = 3;
  35. $this->whereExtend['exam_collection_state'] = 2;
  36. $this->assignConfig('sim_sim_type', ConfigModel::getSimTypeList());
  37. $groupIds = $this->auth->getGroupIds();
  38. //学员查看自己区队的考试集合
  39. if(in_array(8, $groupIds)){
  40. $departid = $this->auth->depart_id;
  41. $this->whereExtend[] = ['exp',Db::raw("FIND_IN_SET($departid,depart_ids)")];
  42. }
  43. }
  44. /**
  45. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  46. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  47. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  48. */
  49. /**
  50. * 查看
  51. *
  52. * @return string|Json
  53. * @throws \think\Exception
  54. * @throws DbException
  55. */
  56. public function index()
  57. {
  58. $isset = $this->model->alias('z')
  59. ->join('real_exam r','z.exam_collection_id=r.exam_collection_id','left')
  60. ->where('z.exam_collection_type=3 and z.exam_collection_state=2 and r.endtime=0 and r.user_id='.$this->auth->id)->find();
  61. if(empty($isset)){
  62. //提示页面,没有开始的考试
  63. return $this->view->fetch('tishi');
  64. }else{
  65. //// $this->redirect('/ZQOtIMLKud.php/student/collection/examing/ids/'.$isset['exam_id'].'?ref=addtabs');
  66. // echo "<script>location.href='/ZQOtIMLKud.php/student/collection/examing/ids/".$isset['exam_id']."';</script>";
  67. // //$this->redirect('/hotelmanage/room/displayindex/ids/1');
  68. // exit();
  69. echo "<script>location.href='/ZQOtIMLKud.php/student/collection/into/ids/".$isset['exam_collection_id']."'</script>";
  70. }
  71. die();
  72. //设置过滤方法
  73. $this->request->filter(['strip_tags', 'trim']);
  74. if (false === $this->request->isAjax()) {
  75. return $this->view->fetch();
  76. }
  77. //如果发送的来源是 Selectpage,则转发到 Selectpage
  78. if ($this->request->request('keyField')) {
  79. return $this->selectpage();
  80. }
  81. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  82. $list = $this->model
  83. ->where($where)->where($this->whereExtend)
  84. ->order($sort, $order)
  85. ->paginate($limit);
  86. foreach ($list as $k => $v){
  87. $exam_isset = $this->exam_model->where(['user_id'=>$this->auth->id,'exam_collection_id'=>$v['exam_collection_id'],'exam_collection_type'=>3,'endtime'=>['>',0]])->find();
  88. if(isset($exam_isset)){
  89. $v->is_user_examed = 1;
  90. }else{
  91. $v->is_user_examed = 0;
  92. }
  93. }
  94. unset($v);
  95. $result = ['total' => $list->total(), 'rows' => $list->items()];
  96. return json($result);
  97. }
  98. //进入考试
  99. public function into($ids = null)
  100. {
  101. $row = $this->model->get($ids);
  102. if(!$row){
  103. $this->error('未找到记录');
  104. }
  105. $info = $this->exam_model->where(['user_id'=>$this->auth->id,'exam_collection_id'=>$ids,'exam_collection_type'=>3,'endtime'=>0])->find();
  106. if(!empty($info)){
  107. if($info['seat_id']>0 && $this->auth->seat_id!=$info['seat_id']){
  108. $this->error('已在其他座号有开始的考试,不允许换座号');
  109. }
  110. $this->exam_model->where('exam_id',$info['exam_id'])->update(['seat_id'=>$this->auth->seat_id]);
  111. $info['seat_id'] = $this->auth->seat_id;
  112. // $sim = Db::name('sim')->where('seat_id',$this->auth->seat_id)->find();
  113. $sim = Db::name('sim')->where('sim_type',$info['sim_type'])->find();
  114. $sim_text = '';
  115. if(!empty($sim)){
  116. if($sim['sim_state']==1){
  117. $sim_text = '在线';
  118. }else if($sim['sim_state']==2){
  119. $sim_text = '模拟器离线';
  120. }else if($sim['sim_state']==3){
  121. $sim_text = '网关离线';
  122. }else if($sim['sim_state']==4){
  123. $sim_text = '硬件故障异常';
  124. }else if($sim['sim_state']==5){
  125. $sim_text = '手动禁用';
  126. }
  127. }
  128. // 模拟器状态 0:可用初始化 1:在线 2:模拟器离线 3:网关离线 4:硬件故障异常 5:手动禁用
  129. $info['sim_text'] = $sim_text;
  130. }
  131. if(!empty($info['starttime']))
  132. {
  133. echo "<script>location.href='/ZQOtIMLKud.php/student/collection/examing/ids/".$info['exam_id']."'</script>";
  134. die();
  135. }
  136. $this->view->assign('info', $info);
  137. $this->view->assign('row', $row);
  138. $this->assignConfig('exam_id', $info['exam_id']);
  139. $this->assignConfig('url_type', config('site.url_type'));
  140. $this->assignConfig('is_fault', Env::get('app.is_fault'));
  141. return $this->view->fetch();
  142. }
  143. public function examing($ids = null)
  144. {
  145. $row = $this->exam_model->get($ids);
  146. if(!$row){
  147. $this->error('未找到记录');
  148. }
  149. if ($this->request->isPost()) {
  150. //先请求接口判断,再进行处理
  151. if(Env::get('app.is_fault')){
  152. $url = config('site.url_type').'/sim/real-exam/student/exam/submit/'.$ids;
  153. // /dev-api/sim/real-exam/student/exam/submit/{examId}
  154. $ret = json_decode(send_get($url),true);
  155. // halt($ret);
  156. if($ret['code']!=200){
  157. $this->error($ret['msg']);
  158. }
  159. }
  160. //计算分数,保存记录
  161. $params = $this->request->post('row/a');
  162. $result = false;
  163. $score = 100;
  164. $fault_one_score = 25;
  165. $fault_two_score = 25;
  166. $fault_three_score = 25;
  167. $xianxian_score = 0;
  168. $yuanyin_socre= 0;
  169. $buwei_score= 0;
  170. $fangfa_score= 0;
  171. $xianxian_arr = [];
  172. $yuanyin_arr = [];
  173. $buwei_arr = [];
  174. $fangfa_arr = [];
  175. $jielun_score = 0;
  176. Db::startTrans();
  177. try {
  178. //更新考试结束时间
  179. $row->end_time = date('Y-m-d H:i:s');
  180. $row->endtime = time();
  181. $row->exam_status = 5;
  182. $row->other_report = $params['other_report'];
  183. $result = $row->save();
  184. $info = $this->exam_model->where(['exam_id'=>$ids])->find();
  185. //更新故障是否正确
  186. $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
  187. if(!empty($fault_list)){
  188. foreach ($fault_list as $k =>$t){
  189. $answer_right = 2;
  190. if(!empty($t['sim_fault_question_value']) && !empty($t['sim_fault_answer_value'])){
  191. if($t['sim_fault_question_value']!=$t['sim_fault_answer_value'] ){
  192. //真实故障id 000200010001
  193. if($t['sim_fault_answer_value']=='00000000' && $t['fault_id'] !='000200010001'){
  194. $answer_right=2;
  195. }
  196. $answer_right=1;
  197. }
  198. }
  199. Db::name('real_exam_fault')->where(['ref_id'=>$t['ref_id']])->update(['answer_right'=>$answer_right]);
  200. }
  201. }
  202. //计算得分,故障是否有扣分 扣分制
  203. $fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1,'answer_right'=>['>',0]])->select();
  204. if(!empty($fault_right_list)){
  205. if($fault_right_list[0]['answer_right']==1){
  206. $fault_one_score = 0;
  207. }
  208. if($fault_right_list[1]['answer_right']==1){
  209. $fault_two_score = 0;
  210. }
  211. if($fault_right_list[2]['answer_right']==1){
  212. $fault_three_score = 0;
  213. }
  214. //根据故障部位,查找故障现象
  215. $fault_arr = [$fault_right_list[0]['fault_id'],$fault_right_list[1]['fault_id'],$fault_right_list[2]['fault_id']];
  216. $partent_fault_id = Fault::where(['fault_id'=>['in',$fault_arr]])->column('parent_fault_id');
  217. //故障保存的是部位,需要查找故障现象
  218. $other_report = json_decode($params['other_report'],true);
  219. if(count($other_report)<3){
  220. $xianxian_score = 15-5*count($other_report)+$xianxian_score;
  221. $buwei_score = 3-1*count($other_report)+$buwei_score;
  222. $yuanyin_socre = 3-1*count($other_report)+$yuanyin_socre;
  223. $fangfa_score = 3-1*count($other_report)+$fangfa_score;
  224. }
  225. foreach ($other_report as $key => $em){
  226. //故障现象
  227. if(!in_array($em['xx_id'],$partent_fault_id)){
  228. $xianxian_score = 5+$xianxian_score;
  229. $xianxian_arr[] = $em['xx_id'];
  230. }
  231. //故障部位
  232. if(!empty($em['bw_id'])){
  233. $report_xx_id = Report::where(['bw_id'=>['in',$em['bw_id']]])->column('xx_id');
  234. if(!in_array($em['xx_id'],$report_xx_id)){ //现象不对,直接扣分
  235. $buwei_score = 1+$buwei_score;
  236. $buwei_arr[] = $em['bw_id'];
  237. }else{
  238. //现象正确,判断是不是正确的选项
  239. foreach (explode(',',$em['bw_id']) as $s => $bs){
  240. if(!in_array($bs,$fault_arr)){
  241. $buwei_score = 1+$buwei_score;
  242. $buwei_arr[] = $bs;
  243. }
  244. }
  245. }
  246. }else{
  247. //部位为空 +1
  248. $buwei_score = 1+ $buwei_score;
  249. }
  250. //可能原因
  251. if(!empty($em['yy_id'])){
  252. $report_bw_id = Report::where(['yy_id'=>['in',$em['yy_id']]])->column('bw_id');
  253. if(!in_array($em['bw_id'],$report_bw_id)){ //现象不对,直接扣分
  254. $yuanyin_socre = 1+$yuanyin_socre;
  255. $yuanyin_arr[] = $em['yy_id'];
  256. }else{
  257. }
  258. }else{
  259. //部位为空 +1
  260. $yuanyin_socre = 1+$yuanyin_socre;
  261. }
  262. //排除方法
  263. if(!empty($em['pc_id'])){
  264. $report_pc_id = Report::where(['pc_id'=>['in',$em['pc_id']]])->column('bw_id');
  265. if(!in_array($em['bw_id'],$report_pc_id)){ //现象不对,直接扣分
  266. $fangfa_score = 1+$fangfa_score;
  267. $fangfa_arr[] = $em['pc_id'];
  268. }else{
  269. }
  270. }else{
  271. $fangfa_score = 1+$fangfa_score;
  272. }
  273. }
  274. }
  275. // echo "<pre>";
  276. // print_r($buwei_arr);
  277. // echo '原因:'.$yuanyin_socre.'<br/>';
  278. // echo '部位:'.$buwei_score.'<br/>';
  279. // echo '现象:'.$xianxian_score;
  280. // die();
  281. $weixiu_score = $xianxian_score+$yuanyin_socre+$buwei_score+$fangfa_score;
  282. if($weixiu_score>15){
  283. $weixiu_score = 15;
  284. }
  285. // $xianxian_score = rand(1,3);
  286. // $yuanyin_socre= rand(1,3);
  287. // $buwei_score= rand(1,3);
  288. // $fangfa_score= rand(1,3);
  289. // if(empty($params['other_jielun'])){
  290. // $jielun_score = rand(1,3);
  291. // }
  292. //是否超时
  293. $overtime_fen = intval((time()-$info['endtime']) / 60);
  294. if($overtime_fen>=10){
  295. $overtime_score = 10;
  296. }else if($overtime_fen>0 && $overtime_fen<10){
  297. $overtime_score = $overtime_fen ;
  298. }else{
  299. $overtime_score =0;
  300. }
  301. $fault_score = $score-$fault_one_score-$fault_two_score-$fault_three_score-$weixiu_score-$overtime_score;
  302. //更新考试结果表
  303. $params['exam_id'] = $ids;
  304. $params['total'] = $fault_score;//得分;
  305. $params['fault_one_score'] = $fault_one_score;//得分;
  306. $params['fault_two_score'] = $fault_two_score;//得分;
  307. $params['fault_three_score'] = $fault_three_score;//得分;
  308. $params['xianxian_score'] = $xianxian_score;//得分;
  309. $params['xianxian_content'] = !empty($xianxian_arr) ? json_encode($xianxian_arr):'';//错题;
  310. $params['yuanyin_socre'] = $yuanyin_socre;//得分;
  311. $params['yuanyin_content'] = !empty($yuanyin_arr) ? json_encode($yuanyin_arr) : '';//错题;
  312. $params['buwei_score'] = $buwei_score;//得分;
  313. $params['buwei_content'] = !empty($buwei_arr) ? json_encode($buwei_arr) :'';//错题;
  314. $params['fangfa_score'] = $fangfa_score;//得分;
  315. $params['fangfa_content'] = !empty($fangfa_arr) ? json_encode($fangfa_arr):'';//错题;
  316. // $params['jielun_score'] = $jielun_score;//得分;
  317. $params['overtime_score'] = $overtime_score;//得分;
  318. Db::name('real_exam_score')->insert($params);
  319. $this->exam_model->where(['exam_id'=>$ids])->update(['total_score'=>$fault_score]);
  320. Db::commit();
  321. } catch (ValidateException|PDOException|Exception $e) {
  322. Db::rollback();
  323. $this->error($e->getMessage());
  324. }
  325. if ($result === false) {
  326. $this->error(__('No rows were inserted'));
  327. }
  328. $this->success('交卷成功,待老师确认成绩','/ZQOtIMLKud.php/student/exam/index');
  329. }
  330. if(empty($row->starttime)){
  331. $row->start_time = date('Y-m-d H:i:s');
  332. $row->starttime = time();
  333. $row->exam_status = 4;
  334. $row->save();
  335. }
  336. $isloading =1;
  337. if(empty($row->other_replace)){
  338. $isloading = 0;
  339. $row->other_replace = '[{"fault_id":"","request_status":"0"}]';
  340. }
  341. $row->other_report_text = !empty($row->other_report) ? json_decode($row->other_report,true) : [];
  342. //还未开始考试
  343. $row->limit_duration = $this->model->where(['exam_collection_id'=>$row['exam_collection_id']])->value('limit_duration');
  344. if(empty($row->starttime)){
  345. $timer = 60*$row->limit_duration;
  346. }else{
  347. $timer = $row->limit_duration*60 - abs(time() - $row->starttime);
  348. }
  349. $row->replace_list =Db::name('real_exam_comp_request')->where(['exam_id'=>$ids])->select();
  350. $this->assignConfig('ids',$ids);
  351. $this->assignConfig('timer',$timer);
  352. $this->assignConfig('isloading',$isloading);
  353. $this->view->assign('row', $row);
  354. $departmentdata = [];
  355. $departmentdata = Fault::where(['replace_part'=>1,'sim_type'=>$row->sim_type])->order('fault_id asc')->select();
  356. //更换件数据
  357. $this->view->assign('departmentdata', $departmentdata);
  358. //故障现象
  359. $xianxiang = Fault::where(['fault_type'=>1,'sim_type'=>$row->sim_type])->select();
  360. $this->view->assign('xianxiang', $xianxiang);
  361. //可能原因
  362. $yuanyin = Fault::where(['fault_type'=>2,'sim_type'=>$row->sim_type])->select();
  363. $this->view->assign('yuanyin', $yuanyin);
  364. //故障部位
  365. $buwei = Fault::where(['fault_type'=>3,'sim_type'=>$row->sim_type])->select();
  366. $this->view->assign('buwei', $buwei);
  367. //排除方法
  368. $paichu = Fault::where(['fault_type'=>4,'sim_type'=>$row->sim_type])->select();
  369. $this->view->assign('paichu', $paichu);
  370. return $this->view->fetch();
  371. }
  372. public function replace($ids = null)
  373. {
  374. if ($this->request->isPost()) {
  375. $params = $this->request->post('other_replace','');
  376. $other_report = $this->request->post('other_report','');
  377. $param = json_decode($params,true);
  378. if(!empty($param)){
  379. $faultid_arr = [];
  380. foreach ($param as $key=>$item){
  381. if(!empty($item['fault_id'])){
  382. $isreplace = Db::name('real_exam_comp_request')->where(['exam_id'=>$ids,'fault_id'=>$item['fault_id']])->find();
  383. if(empty($isreplace)){
  384. $add = [
  385. 'exam_id'=>$ids,
  386. 'fault_id'=>$item['fault_id'],
  387. 'request_status'=>1,
  388. 'fault_name'=>Db::name('fault')->where('fault_id',$item['fault_id'])->value('replace_name'),
  389. 'create_by_user_id'=>$this->auth->id,
  390. 'create_by'=>$this->auth->nickname,
  391. 'createtime'=>time(),
  392. 'updatetime'=>time(),
  393. 'create_time'=>date('Y-m-d H:i:s'),
  394. 'update_time'=>date('Y-m-d H:i:s'),
  395. ];
  396. Db::name('real_exam_comp_request')->insert($add);
  397. $status = 1;
  398. }else{
  399. $status = $isreplace['request_status'];
  400. }
  401. $faultid_arr[] = [
  402. 'fault_id'=>$item['fault_id'],
  403. 'request_status'=>$status,
  404. ];
  405. }
  406. }
  407. unset($item);
  408. $row = $this->exam_model->get($ids);
  409. $row-> other_replace = $faultid_arr ? json_encode($faultid_arr):'';
  410. $row-> other_report = $other_report;
  411. $result = $row->save();
  412. }
  413. $this->success('申请成功,待老师审批');
  414. }
  415. }
  416. /**
  417. * @Notes:添加维修报告
  418. * @Author: jxb
  419. * @Date: 2025/1/21
  420. * @Time: 10:29
  421. */
  422. public function addreport($ids = null){
  423. $row = $this->exam_model->get($ids);
  424. if(!$row){
  425. $this->error('未找到记录');
  426. }
  427. if ($this->request->isPost()) {
  428. $unwin = $this->request->post('unwin/a');
  429. $arr = [];
  430. if(!empty($unwin)){
  431. $xx_name = Fault::where('fault_id',$unwin['xx_id'])->value('name');
  432. $yy_name = Fault::where('fault_id','in',$unwin['yy_id'])->column('name');
  433. $bw_name = Fault::where('fault_id','in',$unwin['bw_id'])->column('name');
  434. $pc_name = Fault::where('fault_id','in',$unwin['pc_id'])->column('name');
  435. $arr = [
  436. 'xh_id' => $unwin['xh_id'],
  437. 'xx_id' => $unwin['xx_id'],
  438. 'xx_name'=>$xx_name,
  439. 'yy_id' => implode(',',$unwin['yy_id']),
  440. 'yy_name' => implode(',',$yy_name),
  441. 'bw_id' => implode(',',$unwin['bw_id']),
  442. 'bw_name' => implode(',',$bw_name),
  443. 'pc_id' => implode(',',$unwin['pc_id']),
  444. 'pc_name' => implode(',',$pc_name),
  445. ];
  446. }
  447. $other_report = !empty($row->other_report) ? json_decode($row->other_report,true) : [];
  448. array_push($other_report,$arr);
  449. $row->other_report = json_encode($other_report);
  450. $row->save();
  451. $this->success();
  452. }
  453. //故障现象
  454. $xianxiang = Fault::where(['fault_type'=>1,'sim_type'=>$row->sim_type])->select();
  455. $this->view->assign('xianxiang', $xianxiang);
  456. //可能原因
  457. $yuanyin = Fault::where(['fault_type'=>2,'sim_type'=>$row->sim_type])->column('fault_id,name');
  458. $this->view->assign('yuanyin', $yuanyin);
  459. //故障部位
  460. $buwei = Fault::where(['fault_type'=>3,'sim_type'=>$row->sim_type])->column('fault_id,name');
  461. $this->view->assign('buwei', $buwei);
  462. //排除方法
  463. $paichu = Fault::where(['fault_type'=>4,'sim_type'=>$row->sim_type])->column('fault_id,name');
  464. $this->view->assign('paichu', $paichu);
  465. $row->other_report_count = 0;
  466. if(!empty($row->other_report)){
  467. $row->other_report_count = count(json_decode($row->other_report,true));
  468. }
  469. $this->view->assign('row', $row);
  470. return $this->view->fetch();
  471. }
  472. /**
  473. * @Notes:编辑报告
  474. * @Author: jxb
  475. * @Date: 2025/1/21
  476. * @Time: 15:04
  477. */
  478. public function editreport($ids = null,$xh_id = null){
  479. $row = $this->exam_model->get($ids);
  480. if(!$row){
  481. $this->error('未找到记录');
  482. }
  483. if ($this->request->isPost()) {
  484. $unwin = $this->request->post('unwin/a');
  485. if(!empty($unwin)){
  486. $xx_name = Fault::where('fault_id',$unwin['xx_id'])->value('name');
  487. $yy_name = Fault::where('fault_id','in',$unwin['yy_id'])->column('name');
  488. $bw_name = Fault::where('fault_id','in',$unwin['bw_id'])->column('name');
  489. $pc_name = Fault::where('fault_id','in',$unwin['pc_id'])->column('name');
  490. $other_report = !empty($row->other_report) ? json_decode($row->other_report,true) : [];
  491. foreach ($other_report as $k =>$item){
  492. if($k==$xh_id){
  493. $other_report[$k]['xx_id'] =$unwin['xx_id'];
  494. $other_report[$k]['xx_name'] =$xx_name;
  495. $other_report[$k]['yy_id'] = implode(',',$unwin['yy_id']);
  496. $other_report[$k]['yy_name'] =implode(',',$yy_name);
  497. $other_report[$k]['bw_id'] = implode(',',$unwin['bw_id']);
  498. $other_report[$k]['bw_name'] =implode(',',$bw_name);
  499. $other_report[$k]['pc_id'] =implode(',',$unwin['pc_id']);
  500. $other_report[$k]['pc_name'] =implode(',',$pc_name);
  501. }
  502. }
  503. $row->other_report = json_encode($other_report);
  504. $row->save();
  505. }
  506. $this->success();
  507. }
  508. //故障现象
  509. $xianxiang = Fault::where(['fault_type'=>1,'sim_type'=>$row->sim_type])->select();
  510. $this->view->assign('xianxiang', $xianxiang);
  511. //可能原因
  512. $yuanyin = Fault::where(['fault_type'=>2,'sim_type'=>$row->sim_type])->column('fault_id,name');
  513. $this->view->assign('yuanyin', $yuanyin);
  514. //故障部位
  515. $buwei = Fault::where(['fault_type'=>3,'sim_type'=>$row->sim_type])->column('fault_id,name');
  516. $this->view->assign('buwei', $buwei);
  517. //排除方法
  518. $paichu = Fault::where(['fault_type'=>4,'sim_type'=>$row->sim_type])->column('fault_id,name');
  519. $this->view->assign('paichu', $paichu);
  520. $row->other_report_text = [];
  521. if(!empty($row->other_report)){
  522. $other_report = json_decode($row->other_report,true);
  523. foreach ($other_report as $k =>$item){
  524. if($k==$xh_id){
  525. $row->other_report_text = [
  526. 'xx_id'=>$item['xx_id'],
  527. 'yy_id'=>explode(',',$item['yy_id']),
  528. 'bw_id'=>explode(',',$item['bw_id']),
  529. 'pc_id'=>explode(',',$item['pc_id']),
  530. 'xh_id'=>$item['xh_id']
  531. ];
  532. }
  533. }
  534. }
  535. $this->view->assign('row', $row);
  536. return $this->view->fetch();
  537. }
  538. /**
  539. * @Notes:移除 维修报告
  540. * @Author: jxb
  541. * @Date: 2025/1/21
  542. * @Time: 14:45
  543. */
  544. public function delreport($ids = null){
  545. $row = $this->exam_model->get($ids);
  546. if(!$row){
  547. $this->error('未找到记录');
  548. }
  549. if ($this->request->isPost()) {
  550. $xh_id = $this->request->post('xh_id');
  551. if(!empty($row->other_report)){
  552. $other_report = json_decode($row->other_report,true);
  553. unset($other_report[$xh_id]);
  554. $row->other_report = json_encode($other_report);
  555. $row->save();
  556. }
  557. $this->success();
  558. }
  559. }
  560. public function analysis($ids = null)
  561. {
  562. $row = $this->exam_model->get($ids);
  563. if(!$row){
  564. $this->error('未找到记录');
  565. }
  566. if ($this->request->isPost()) {
  567. $params = $this->request->post('row/a');
  568. //计算总分到学员考试表
  569. $this->success('操作成功','/ZQOtIMLKud.php/student/collection/index');
  570. }
  571. return $this->view->fetch();
  572. }
  573. }