Machine.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use \think\Request;
  5. use \think\Db;
  6. /**
  7. * 工种定额及比例管理接口
  8. */
  9. class Machine extends Api
  10. {
  11. protected $noNeedLogin = ['*'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 首页-已核查成品编号
  15. *
  16. */
  17. public function index()
  18. {
  19. $this->success('请求成功');
  20. }
  21. /**
  22. *工种定额及比例管理接口
  23. *
  24. * @ApiMethod GET
  25. *@params string department
  26. */
  27. public function getMachineInfo(){
  28. if (Request::instance()->isGet() == false){
  29. $this->error('非法请求');
  30. }
  31. $params = Request::instance()->param();
  32. $department = $params['department'];
  33. if (!isset($department)){
  34. $this->error('参数不能为空');
  35. }
  36. $limit = $params['limit'];
  37. if (empty($limit)){
  38. $limit = 15;
  39. }
  40. $pages = $params['page'];
  41. if (empty($pages)){
  42. $pages = 1;
  43. }
  44. $where['使用部门'] = $department;
  45. $field = '设备编号,rtrim(设备名称) as 设备名称,rtrim(生产工序) as 生产工序,日定额,千件工价,机长,副机,调墨,二手,飞达,辅助,放卷,分切1,分切2,检验,rtrim(使用部门) as 使用部门,sys_id,sys_rq,mod_rq,UniqId';
  46. $list = db('设备_基本资料')->where($where)->field($field)->limit($limit)->page($pages)->order('设备编号 asc')->select();
  47. $count = db('设备_基本资料')->where($where)->field($field)->count();
  48. $data['data'] = $list;
  49. $data['total'] = $count;
  50. $this->success('请求成功',$data);
  51. }
  52. /**
  53. * 获取车间部门列表
  54. *
  55. * @ApiMethod GET
  56. */
  57. public function getDepartment(){
  58. if (Request::instance()->isGet() == false){
  59. $this->error('非法请求');
  60. }
  61. $list = [
  62. 0 => '印刷车间',
  63. 1 => '印后车间'
  64. ];
  65. $this->success('请求成功',$list);
  66. }
  67. }