Jiance.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. namespace app\company\controller;
  3. use app\common\controller\Apic;
  4. use think\Db;
  5. /**
  6. * 检测下发
  7. */
  8. class Jiance extends Apic
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = [];
  12. protected $table = 'jiance';
  13. public function index(){
  14. $search = [];
  15. $bianhao = input('bianhao','');
  16. $uc_id = input('uc_id','');
  17. $worker_id = input('worker_id','');
  18. if(!empty($bianhao)){
  19. $search['jiance.bianhao'] = ['LIKE','%'.$bianhao.'%'];
  20. }
  21. if(!empty($uc_id)){
  22. $search['jiance.uc_id'] = $uc_id;
  23. }
  24. if(!empty($worker_id)){
  25. $search['jiance.worker_id'] = $worker_id;
  26. }
  27. $list = Db::name($this->table)
  28. ->field('jiance.*,uc.projectname,worker.truename as worker_truename,worker.mobile as worker_mobile')
  29. ->join('worker','jiance.worker_id = worker.id','LEFT')
  30. ->join('user_company uc','jiance.uc_id = uc.id','LEFT')
  31. ->where('jiance.company_id',$this->auth->company_id)
  32. ->where('jiance.deletetime',NULL)
  33. ->where($search)
  34. ->paginate();
  35. $total = $list->total();
  36. $list = $list->items();
  37. foreach($list as $key => $val){
  38. $list[$key]['pdfurl'] = 'https://kaoshi.huxiukeji.cn/admin.php/trainactive/showinfo/id/2';
  39. }
  40. $rs = [
  41. 'list' => $list,
  42. 'total'=> $total,
  43. ];
  44. $this->success(1,$rs);
  45. }
  46. public function add(){
  47. $project_ids = input('project_ids','');
  48. $jiance_number = 0;
  49. if(!empty($project_ids)){
  50. $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
  51. }
  52. $data = [
  53. 'company_id' => $this->auth->company_id,
  54. 'uc_id' => input('uc_id',''),
  55. 'worker_id' => input('worker_id',''),
  56. 'bianhao' => input('bianhao',''),
  57. 'status' => 0,
  58. 'jiance_number' => $jiance_number,
  59. 'project_ids' => $project_ids,
  60. ];
  61. Db::name($this->table)->insertGetId($data);
  62. $this->success();
  63. }
  64. public function info(){
  65. $id = input('id',0);
  66. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
  67. $this->success(1,$info);
  68. }
  69. public function edit(){
  70. $id = input('id',0);
  71. $info = Db::name($this->table)->where('id',$id)->where('company_id',$this->auth->company_id)->where('deletetime',NULL)->find();
  72. if(empty($info)){
  73. $this->error('没找到该信息,请刷新重试');
  74. }
  75. //
  76. $project_ids = input('project_ids','');
  77. $jiance_number = 0;
  78. if(!empty($project_ids)){
  79. $jiance_number = Db::name('jiance_project')->where('id','IN',$project_ids)->where('pid',0)->count();
  80. }
  81. $data = [
  82. 'uc_id' => input('uc_id',''),
  83. 'worker_id' => input('worker_id',''),
  84. 'bianhao' => input('bianhao',''),
  85. 'jiance_number' => $jiance_number,
  86. 'project_ids' => $project_ids,
  87. ];
  88. Db::name($this->table)->where('id',$id)->update($data);
  89. $this->success();
  90. }
  91. public function del(){
  92. $ids = input('ids','');
  93. $ids = explode(',',$ids);
  94. if (empty($ids)) {
  95. $this->error();
  96. }
  97. Db::name($this->table)->where('id','IN',$ids)->where('company_id',$this->auth->company_id)->update(['deletetime'=>time()]);
  98. $this->success();
  99. }
  100. //生成报告
  101. public function getpdf(){
  102. }
  103. }