ReportController.php
28.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
<?php
namespace api\home\controller;
use app\portal\model\DiscussModel;
use cmf\controller\RestBaseController;
use FFMpeg\FFProbe;
use think\Validate;
use think\Db;
use FFMpeg\FFMpeg;
/**
* @title 查看报表
*/
class ReportController extends RestBaseController
{
/**
* @title 获取项目状态
* @description 接口说明
* @author 开发者
* @url /api/home/report/getProjectStatus
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @return data:列表@
* @data id:状态id status:状态名称
*/
public function getProjectStatus(){
if($this->request->isGet()){
$common = new CommonController();
$res = $common->getProjectStatus();
$this->success('成功',['data'=>$res]);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 日检巡检报表列表
* @description 接口说明
* @author 开发者
* @url /api/home/report/inspectReportList
* @method GET
*
* @header name:token require:1 default: desc:header
* @param name:page type:inter require:1 default: other desc:分页页码
*
* @param name:company_id type:inter require:0 default: other desc:企业id(总领导传此字段)
* @param name:project_id type:inter require:0 default: other desc:项目id(检索)
* @param name:start_time type:inter require:0 default: other desc:开始日期(检索开始日期)
* @param name:end_time type:inter require:0 default: other desc:开始日期(检索结束日期)
*
* @return data:列表@
* @data id:列表id project_id:项目id project_name:项目名称 create_time:巡检时间 user_group:项目组人员
* @return page:当前页数
* @return total_page:总页数
*/
public function inspectReportList(){
if($this->request->isGet()){
$data = $this->request->get();
$company_id = $this->request->get('company_id');
$rule = config('site.pages');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$common = new CommonController();
$user = $common->getUserIdentity();
//根据企业id查询项目id
$pIds = $common->getCheckStatus($user,$company_id);
$result = $common->getInspectReportList('inspect',$user['party'],$pIds,$data);
//查找项目组人员名称
foreach($result as &$value){
if($user['party'] == 0){
//甲方项目组
$user_group = $common->getUserByProject($value['project_id'],'id,a_sid');
$value['user_group'] = trim(implode(array_column($user_group,'user_login'),'/'),'/');
}else{
//乙方项目组
$value['user_group'] = $common->getUserByProjectId($value['project_id'],'id,b_sid');
}
}
$total_page = $common->getInspectReportCount('inspect',$user['party'],$pIds,$data);
$res['data'] = $result;
$res['page'] = intval($data['page']);
$res['total_page'] = $total_page;
$this->success('成功',$res);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 年检报表列表
* @description 接口说明
* @author 开发者
* @url /api/home/report/yearsReportList
* @method GET
*
* @header name:token require:1 default: desc:header
* @param name:page type:inter require:1 default: other desc:分页页码
*
* @param name:company_id type:inter require:0 default: other desc:企业id(总领导传此字段)
* @param name:project_id type:inter require:0 default: other desc:项目id(检索)
* @param name:start_time type:inter require:0 default: other desc:开始日期(检索开始日期)
* @param name:end_time type:inter require:0 default: other desc:开始日期(检索结束日期)
*
* @return data:列表@
* @data id:列表id project_id:项目id project_name:项目名称 test_time:检测时间 user_group:项目组人员
* @return page:当前页数
* @return total_page:总页数
*/
public function yearsReportList(){
if($this->request->isGet()){
$data = $this->request->get();
$company_id = $this->request->get('company_id');
$rule = config('site.pages');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$common = new CommonController();
$user = $common->getUserIdentity();
//根据企业id查询项目id
$pIds = $common->getCheckStatus($user,$company_id);
$result = $common->getTestReportList('test',$pIds,$data);
//查找项目组乙方人员名称
foreach($result as &$value){
//乙方项目组
$value['user_group'] = $common->getUserByProjectId($value['project_id'],'id,b_sid');
}
$total_page = $common->getTestReportCount('test',$pIds,$data);
$res['data'] = $result;
$res['page'] = intval($data['page']);
$res['total_page'] = $total_page;
$this->success('成功',$res);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 服务报表列表(2:月检,3:改造,4:报修跟进,5:培训,6:演习)
* @description 接口说明
* @author 开发者
* @url /api/home/report/serviceReportList
* @method GET
*
* @header name:token require:1 default: desc:header
* @param name:page type:inter require:1 default: other desc:分页页码
* @param name:service_id type:inter require:1 default: other desc:服务id(2:月检,3:改造,4:报修跟进,5:培训,6:演习)
*
* @param name:company_id type:inter require:0 default: other desc:企业id(总领导传此字段)
* @param name:project_id type:inter require:0 default: other desc:项目id(检索)
* @param name:status type:inter require:0 default: other desc:状态(检索状态:-1:全部,1:待确认,2:进行中,3:已完成)
* @param name:start_time type:inter require:0 default: other desc:开始日期(检索开始日期)
* @param name:end_time type:inter require:0 default: other desc:开始日期(检索结束日期)
*
* @return data:列表@
* @data id:列表id project_id:项目id project_name:项目名称 ins_m_time:(ins_m_time:月检时间,create_time:报修改造时间,train_time:培训时间,exercise:演习时间) user_group:项目组人员 status:状态(月检[0:待甲方领导确认,1:甲方领导驳回,2待乙方员工完成,3:已完成],改造:[0:待确认,1:维修中,2:已完成],报修跟进:[0:待确认,1:维修中,2:已完成],培训:[0:甲方提交申请,1:乙方领导驳回,2:乙方领导确认,3:完成],演习:[0:甲方提交申请,1:乙方领导驳回,2:乙方领导确认,3:完成 ])
* @return page:当前页数
* @return total_page:总页数
*/
public function serviceReportList(){
if($this->request->isGet()){
$data = $this->request->get();
$company_id = $this->request->get('company_id');
$rule = config('site.pages_service');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$common = new CommonController();
$user = $common->getUserIdentity();
//根据企业id查询项目id
$pIds = $common->getCheckStatus($user,$company_id);
$service_id = $data['service_id'];
$result = [];
$total_page = 0;
if($service_id == 2){
//月检
$result = $common->getCheckReportList($pIds,$data);
$total_page = $common->checkReportCount($pIds,$data);
}else if($service_id == 3){
//改造
$result = $common->getReformReportList($pIds,$data,'reform');
$total_page = $common->reformReportCount($pIds,$data,'reform');
}else if($service_id == 4){
//报修跟进
$result = $common->getReformReportList($pIds,$data,'repair');
$total_page = $common->reformReportCount($pIds,$data,'repair');
}else if($service_id == 5){
//培训
$result = $common->getTrainReportList($pIds,$data,'train');
$total_page = $common->trainReportCount($pIds,$data,'train');
}else if($service_id == 6){
//演习
$result = $common->getTrainReportList($pIds,$data,'exercise');
$total_page = $common->trainReportCount($pIds,$data,'exercise');
}
foreach($result as &$value){
//查找项目组人员
if($user['party'] == 0){
//甲方项目组
$user_group = $common->getUserByProject($value['project_id'],'id,a_sid');
$value['user_group'] = trim(implode(array_column($user_group,'user_login'),'/'),'/');
}else{
//乙方项目组
$value['user_group'] = $common->getUserByProjectId($value['project_id'],'id,b_sid');
}
}
$res['data'] = $result;
$res['page'] = intval($data['page']);
$res['total_page'] = $total_page;
$this->success('成功',$res);
}else{
$this->error('请求方式错误!');
}
}
//截取视频第一帧
public function getVideoCover() {
var_dump(1111);
$ffm_peg = FFMpeg::create([
'ffmpeg.binaries' => '/urs/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe'
]);
$video = $ffm_peg->open(ROOT_PATH.'public/uploads/1.mp4');
$video->filters()->resize(new \FFMpeg\Coordinate\Dimension(320, 240))->synchronize();
$video->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(10))->save(ROOT_PATH.'public/upload/image.jpg');
var_dump(2222);exit;
}
/**
* @title 日检巡检报表详情
* @description 接口说明
* @author 开发者
* @url /api/home/report/inspectReportDetail
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
*
* @return a_company:甲方公司@!
* @a_company company_name:甲方公司 logo:公司logo
*
* @return b_company:乙方公司@!
* @b_company company_name:乙方公司 logo:公司logo
* @return title:报表名称
* @return inspect_name:项目组(甲方或者乙方)
*
* @return inspect_time:日检巡检时间
*
* @return inspect:日检@
* @inspect id:日检点id status:日检点状态(0:正常,1:故障,2:未检查) user_login:检查人姓名 point_name:日检点名称 images:日检图片@
* @images image_url:图片路径
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
*
*/
public function inspectReportDetail(){
if($this->request->isGet()){
$data = $this->request->get();
$rule = config('site.data');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('inspect')
->where(['id'=>$data['id']])
->find();
if($res){
//根据项目id获取项目名称,甲方公司名称,logo,乙方公司名称,logo
$common = new CommonController();
$arr = $common->getInspectReportDetail($res,$data,'inspect');
}
$this->success('成功',$arr);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 月检报表详情
* @description 接口说明
* @author 开发者
* @url /api/home/report/checkReportDetail
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
*
* @return a_company:甲方公司@!
* @a_company company_name:甲方公司 logo:公司logo
*
* @return b_company:乙方公司@!
* @b_company company_name:乙方公司 logo:公司logo
*
* @return title:报表名称
* @return ins_m_time:月检时间
* @return user_login:乙方发起人
* @return number:月检单号
* @return a_leader_user:甲方领导确认人
* @return confirm_user:乙方验收人姓名
* @return finish_time:完成时间
* @return check_period:工期
* @return check_name:乙方项目组人员(乙方月检人员)
* @return images:月检图片@!
* @images title:图片标题 i_images:月检图片@
* @i_images day:图片日期 image:图片路径@
* @image image_url:图片路径
*
* @return confirm_images:确认完成图片@!
* @confirm_images title:图片标题 c_images:完成图片@
* @c_images day:图片日期 image:图片路径@
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
*
* @return address:演习地点
* @return remark:演习备注
*/
public function checkReportDetail(){
if($this->request->isGet()){
$data = $this->request->get();
$rule = config('site.data');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('check')
->where(['id'=>$data['id']])
->find();
if($res){
//根据项目id获取项目名称,甲方公司名称,logo,乙方公司名称,logo
$common = new CommonController();
$arr = $common->getCheckReportDetail($res,$data);
}
$this->success('成功',$arr);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 年检报表详情
* @description 接口说明
* @author 开发者
* @url /api/home/report/yearsReportDetail
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
*
* @return a_company:甲方公司@!
* @a_company company_name:甲方公司 logo:公司logo
*
* @return b_company:乙方公司@!
* @b_company company_name:乙方公司 logo:公司logo
* @return title:报表名称
* @return inspect_name:项目组(甲方或者乙方)
*
* @return test_time:检测时间
* @return number:检测单号
* @return years:年检@
* @years spot_id:年检点id status:日检点状态(0:正常,1:故障,2:未检查) user_login:检查人姓名 spot_name:年检点名称 images:年检图片@
* @images day:图片日期 image:图片路径@
* @image image_url:图片路径
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
*
*/
public function yearsReportDetail(){
if($this->request->isGet()){
$data = $this->request->get();
$rule = config('site.data');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('test')
->where(['id'=>$data['id']])
->find();
if($res){
//根据项目id获取项目名称,甲方公司名称,logo,乙方公司名称,logo
$common = new CommonController();
$arr = $common->getInspectReportDetail($res,$data,'years');
}
$this->success('成功',$arr);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 报修报表详情
* @description 接口说明
* @author 开发者
* @url /api/home/report/repairReportDetail
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
*
* @return a_company:甲方公司@!
* @a_company company_name:甲方公司 logo:公司logo
*
* @return b_company:乙方公司@!
* @b_company company_name:乙方公司 logo:公司logo
*
* @return title:报表名称
* @return number:报修单号
* @return create_time:报修时间
*
* @return user_login:发起人@!
* @user_login user:发起人姓名 party:发起人身份(0:甲方,1:乙方)
*
* @return h_user_login:确认人@!
* @h_user_login user:确认人姓名 party:确认人身份(0:甲方,乙方)
*
* @return confirm_user:验收人姓名
* @return finish_time:完成时间
* @return repair_period:工期
* @return repair_name:乙方项目组人员(乙方维修人员)
* @return images:报修图片@!
* @images title:图片标题 i_images:报修图片@
* @i_images day:图片日期 image:图片路径@
* @image image_url:图片路径
*
* @return repair_images:完善图片@!
* @repair_images title:图片标题 r_images:完善图片@
* @r_images day:图片日期 image:图片路径@
*
* @return confirm_images:确认完成图片@!
* @confirm_images title:图片标题 c_images:完成图片@
* @c_images day:图片日期 image:图片路径@
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
*/
public function repairReportDetail(){
if($this->request->isGet()){
//列表id
$data = $this->request->get();
$rule = config('site.data');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('repair')
->where(['id'=>$data['id']])
->find();
if($res){
//根据项目id获取项目名称,甲方公司名称,logo,乙方公司名称,logo
$common = new CommonController();
$arr = $common->getRepairReportDetail($res,$data,'repair');
}
$this->success('成功',$arr);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 改造报表详情
* @description 接口说明
* @author 开发者
* @url /api/home/report/reformReportDetail
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
*
* @return a_company:甲方公司@!
* @a_company company_name:甲方公司 logo:公司logo
*
* @return b_company:乙方公司@!
* @b_company company_name:乙方公司 logo:公司logo
*
* @return title:报表名称
* @return number:改造单号
* @return create_time:改造时间
*
* @return user_login:发起人@!
* @user_login user:发起人姓名 party:发起人身份(0:甲方,1:乙方)
*
* @return h_user_login:确认人@!
* @h_user_login user:确认人姓名 party:确认人身份(0:甲方,乙方)
*
* @return confirm_user:验收人姓名
* @return finish_time:完成时间
* @return reform_period:工期
* @return reform_name:乙方项目组人员(乙方改造人员)
* @return images:改造图片@!
* @images title:图片标题 i_images:改造图片@
* @i_images day:图片日期 image:图片路径@
* @image image_url:图片路径
*
* @return reform_images:完善图片@!
* @reform_images title:图片标题 r_images:完善图片@
* @r_images day:图片日期 image:图片路径@
*
* @return confirm_images:确认完成图片@!
* @confirm_images title:图片标题 c_images:完成图片@
* @c_images day:图片日期 image:图片路径@
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
*/
public function reformReportDetail(){
if($this->request->isGet()){
//列表id
$data = $this->request->get();
$rule = config('site.data');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('reform')
->where(['id'=>$data['id']])
->find();
if($res){
//根据项目id获取项目名称,甲方公司名称,logo,乙方公司名称,logo
$common = new CommonController();
$arr = $common->getRepairReportDetail($res,$data,'reform');
}
$this->success('成功',$arr);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 培训报表详情
* @description 接口说明
* @author 开发者
* @url /api/home/report/trainReportDetail
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
*
* @return a_company:甲方公司@!
* @a_company company_name:甲方公司 logo:公司logo
*
* @return b_company:乙方公司@!
* @b_company company_name:乙方公司 logo:公司logo
*
* @return title:报表名称
* @return number:培训单号
* @return train_time:培训时间
* @return user_login:甲方发起人
* @return b_leader_user:乙方领导确认人
* @return confirm_user:甲方验收人姓名
* @return finish_time:完成时间
* @return train_period:工期
* @return train_name:乙方项目组人员(乙方培训人员)
* @return images:培训图片@!
* @images title:图片标题 i_images:培训图片@
* @i_images day:图片日期 image:图片路径@
* @image image_url:图片路径
*
* @return confirm_images:完成图片@!
* @confirm_images title:图片标题 c_images:完成图片@
* @c_images day:图片日期 image:图片路径@
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
*
* @return address:培训地点
* @return remark:培训备注
*/
public function trainReportDetail(){
if($this->request->isGet()){
$data = $this->request->get();
$rule = config('site.data');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('train')
->where(['id'=>$data['id']])
->find();
if($res){
//根据项目id获取项目名称,甲方公司名称,logo,乙方公司名称,logo
$common = new CommonController();
$arr = $common->getTrainReportDetail($res,$data,'train');
}
$this->success('成功',$arr);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 演习报表详情
* @description 接口说明
* @author 开发者
* @url /api/home/report/exerciseReportDetail
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
*
* @return a_company:甲方公司@!
* @a_company company_name:甲方公司 logo:公司logo
*
* @return b_company:乙方公司@!
* @b_company company_name:乙方公司 logo:公司logo
*
* @return title:报表名称
* @return number:演习单号
* @return exercise_time:演习时间
* @return user_login:甲方发起人
* @return b_leader_user:乙方领导确认人
* @return confirm_user:甲方验收人姓名
* @return finish_time:完成时间
* @return exercise_period:工期
* @return exercise_name:乙方项目组人员(乙方演习人员)
* @return images:演习图片@!
* @images title:图片标题 i_images:演习图片@
* @i_images day:图片日期 image:图片路径@
* @image image_url:图片路径
*
* @return confirm_images:完成图片@!
* @confirm_images title:图片标题 c_images:完成图片@
* @c_images day:图片日期 image:图片路径@
*
* @return is_comment:是否已评论(0:未评论,1:已评论)
* @return comment:评论内容
*
* @return address:演习地点
* @return remark:演习备注
*/
public function exerciseReportDetail(){
if($this->request->isGet()){
$data = $this->request->get();
$rule = config('site.data');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('exercise')
->where(['id'=>$data['id']])
->find();
if($res){
//根据项目id获取项目名称,甲方公司名称,logo,乙方公司名称,logo
$common = new CommonController();
$arr = $common->getTrainReportDetail($res,$data,'train');
}
$this->success('成功',$arr);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 报表评价
* @description 接口说明
* @author 开发者
* @url /api/home/report/comment
* @method POST
*
* @header name:token require:1 default: desc:header
*
* @param name:id type:inter require:1 default: other desc:列表id
* @param name:service_id type:inter require:1 default: other desc:服务id(1:日检,2:月检,3:改造,4:报修跟进,5:培训,6:演习,7:年检)
* @param name:comment type:string require:1 default: other desc:评论内容
*/
public function comment(){
if($this->request->isPost()){
$data = $this->request->post();
$common = new CommonController();
$user = $common->getIdentity();
//如果是员工,则没有权限操作
if($user['identity'] == config('site.a_staff') || $user['identity'] == config('site.b_staff')){
$this->error('无权操作');
}
$rule = config('site.comment');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
$commentModel = new DiscussModel();
$arr = [];
$arr['type_id'] = $data['id'];
$arr['type'] = $data['service_id'];
$arr['discuss'] = $data['comment'];
$arr['uid'] = $this->userId;
$arr['create_time'] = time();
$res = $commentModel->create($arr);
if($res){
$this->success('成功');
}else{
$this->error('失败');
}
}else{
$this->error('请求方式错误!');
}
}
}