Index.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /** 首页接口*/
  6. class Index extends Api{
  7. protected $noNeedLogin = ['*'];
  8. protected $noNeedRight = ['*'];
  9. /** 首页 **/
  10. public function index(){$this->success('请求成功');}
  11. //甲类车间作业票列表
  12. public function jl_workshops(){
  13. $result = Db::table('mn_task')->alias('t')
  14. ->field('
  15. t.name,
  16. t.bach,
  17. t.machine,
  18. t.number,
  19. t.create,
  20. t.kuodan,
  21. CASE WHEN f.bach IS NULL THEN \'未投料\' ELSE \'已投料\' END AS fedding_status
  22. ')
  23. ->join('mn_feeding f','t.bach = f.bach','LEFT')
  24. ->where('t.machine', 'like', '%甲类%')
  25. ->where('t.create', '>=', date('Y-m-d', strtotime('-7 day')))
  26. ->where('t.create', '<=', date('Y-m-d'))
  27. ->order('t.create', 'desc')
  28. ->select();
  29. // echo "<pre>";print_r($result);echo "<pre>";die;
  30. // 获取数据列定义
  31. $list['columns'] = [
  32. ['name' => '配方名称', 'id' => 'name', 'width' => '30', 'autoWrap' => "true", 'textAlign' => 'left'],
  33. ['name' => '批次号', 'id' => 'bach', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  34. ['name' => '机台', 'id' => 'machine', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  35. ['name' => '生产量', 'id' => 'number', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  36. ['name' => '扩单重量', 'id' => 'kuodan', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  37. ['name' => '创建时间', 'id' => 'create', 'width' => '20', 'autoWrap' => "true", 'textAlign' => 'left'],
  38. ['name' => '是否投料', 'id' => 'fedding_status', 'width' => '14', 'autoWrap' => "true", 'textAlign' => 'left'],
  39. ];
  40. foreach ($result as $v) {
  41. $list['rows'][] = [
  42. 'name' => $v['name'],
  43. 'bach' => $v['bach'],
  44. 'machine' => $v['machine'],
  45. 'number' => $v['number'],
  46. 'kuodan' => $v['kuodan'],
  47. 'create' => $v['create'],
  48. 'fedding_status' => $v['fedding_status'],
  49. ];
  50. }
  51. $res['status'] = 0;
  52. $res['msg'] = '';
  53. $res['data'] = $list;
  54. return json($res);
  55. }
  56. //丙类车间作业票列表
  57. public function bl_workshops(){
  58. $result = Db::table('mn_task')->alias('t')
  59. ->field('
  60. t.name,
  61. t.bach,
  62. t.machine,
  63. t.number,
  64. t.create,
  65. t.kuodan,
  66. CASE WHEN f.bach IS NULL THEN \'未投料\' ELSE \'已投料\' END AS fedding_status
  67. ')
  68. ->join('mn_feeding f','t.bach = f.bach','LEFT')
  69. ->where('t.machine', 'like', '%丙类%')
  70. ->where('t.create', '>=', date('Y-m-d', strtotime('-7 day')))
  71. ->where('t.create', '<=', date('Y-m-d'))
  72. ->order('t.create', 'desc')
  73. ->select();
  74. // echo "<pre>";print_r($result);echo "<pre>";die;
  75. // 获取数据列定义
  76. $list['columns'] = [
  77. ['name' => '配方名称', 'id' => 'name', 'width' => '30', 'autoWrap' => "true", 'textAlign' => 'left'],
  78. ['name' => '批次号', 'id' => 'bach', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  79. ['name' => '机台', 'id' => 'machine', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  80. ['name' => '生产量', 'id' => 'number', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  81. ['name' => '扩单重量', 'id' => 'kuodan', 'width' => '15', 'autoWrap' => "true", 'textAlign' => 'left'],
  82. ['name' => '创建时间', 'id' => 'create', 'width' => '20', 'autoWrap' => "true", 'textAlign' => 'left'],
  83. ['name' => '是否投料', 'id' => 'fedding_status', 'width' => '14', 'autoWrap' => "true", 'textAlign' => 'left'],
  84. ];
  85. foreach ($result as $v) {
  86. $list['rows'][] = [
  87. 'name' => $v['name'],
  88. 'bach' => $v['bach'],
  89. 'machine' => $v['machine'],
  90. 'number' => $v['number'],
  91. 'kuodan' => $v['kuodan'],
  92. 'create' => $v['create'],
  93. 'fedding_status' => $v['fedding_status'],
  94. ];
  95. }
  96. $res['status'] = 0;
  97. $res['msg'] = '';
  98. $res['data'] = $list;
  99. return json($res);
  100. }
  101. }