Index.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use Think\Exception;
  6. /**
  7. * 首页接口
  8. */
  9. class Index extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 首页
  15. *
  16. */
  17. public function index()
  18. {
  19. $this->success('请求111');
  20. }
  21. public function getOrder(){
  22. $where = [];
  23. $pagesize = 10;
  24. $page = 0;
  25. // $result = [
  26. // 'code' => '0',
  27. // 'message' => '请求成功',
  28. // 'data' => ''
  29. // ];
  30. $data = input('');
  31. // if($data['gd_gdbh'] !== '-1'){
  32. // $where['Gd_gdbh'] = $data['gd_gdbh'];
  33. // }
  34. // $where['行号'] = 1;
  35. $where['gd_statu'] = '2-生产中';
  36. //分页的页面显示数
  37. if($data['pagesize']){
  38. $pagesize = $data['pagesize'];
  39. }
  40. //当前分页的页数
  41. if($data['page']){
  42. $startpage = ($data['page']-1)*$pagesize;
  43. }
  44. //有分页
  45. if(isset($startpage) && $startpage >= 0){
  46. $res = Db::name('formula')->column('product_number');
  47. $res = array_values(array_unique($res));
  48. $list = array();
  49. foreach ($res as $key=>$value){
  50. $value = explode(',',$value);
  51. foreach($value as $k=>$v){
  52. array_push($list,$v);
  53. }
  54. }
  55. $list = array_filter($list);
  56. $where['Gd_cpdh'] = array('in',$list);
  57. $info = Db::connect('db2')->table('工单_基本资料')->where($where)->order('gd_gdbh desc')->limit($startpage,$pagesize)->select();
  58. $result['data'] = $info ;
  59. }else{
  60. $info = Db::connect('db2')->table('工单_基本资料')->where($where)->order('gd_gdbh desc')->limit($startpage,$pagesize)->select();
  61. $total = count($info);
  62. $result['data'] = $info ;
  63. }
  64. $this->success('请求成功',$info);
  65. }
  66. //获取工单详情
  67. public function getorderdetail(){
  68. $result = [
  69. 'code' => 0,
  70. 'message' => '请求成功',
  71. 'data' => '',
  72. ];
  73. $data = $_REQUEST?$_REQUEST:'';
  74. if(!isset($data['Gd_gdbh'])){
  75. $result = [
  76. 'code' => 1,
  77. 'message' => '工单编号不能为空',
  78. 'data' => '',
  79. ];
  80. $this->error('请求失败',$result);
  81. }
  82. $where['Gd_gdbh'] = $data['Gd_gdbh'];
  83. // $where['行号'] = 1;
  84. $field = "Gd_gdbh,订单数量,计量单位,成品名称,成品代号,Gd_cpdh";
  85. $info = Db::connect('db2')->table('工单_基本资料')->field($field)->where($where)->find();
  86. if($info){
  87. $result['data'] = $info;
  88. }else{
  89. $result = [
  90. 'code' => 2,
  91. 'message' => '该工单不存在',
  92. 'data' => '',
  93. ];
  94. }
  95. $this->success('请求成功',$result);
  96. }
  97. }