Data.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 示例接口
  7. */
  8. class Data extends Api
  9. {
  10. protected $noNeedLogin = ['*'];
  11. public function index(){
  12. $params = $this->request->param();
  13. if (empty($params['batch'])){
  14. $this->error('参数错误','',401);
  15. }
  16. $where = [];
  17. $where['bach'] = $params['batch'];
  18. $where['delete_time'] = null;
  19. $where['sample_no'] = array('like','%A%');
  20. $res = Db::name('res')->where($where)->field('entrust_no,name,bach,sell_bach,sample_no,dis,dis_impurity,ben_total,ben,judge,standard_id,create')->find();
  21. if ($res){
  22. $check = Db::name('item_judge_detail')->where('pid',$res['standard_id'])->select();
  23. foreach ($check as $key => $value){
  24. if ($value['params'] == '溶剂残留总量'){
  25. $res['dis_max'] = $value['max'];
  26. }
  27. if ($value['params'] == '溶剂杂质总量'){
  28. $res['dis_impurity_max'] = $value['max'];
  29. }
  30. if ($value['params'] == '苯系物总量'){
  31. $res['ben_total_max'] = $value['max'];
  32. }
  33. if ($value['params'] == '苯含量'){
  34. $res['ben_max'] = $value['max'];
  35. }
  36. }
  37. $res['create'] = date('Y',strtotime($res['create'])).'.'.date('m',strtotime($res['create'])).'.'.date('d',strtotime($res['create']));
  38. if ($res['judge'] == 1){
  39. $res['judge'] = '合格';
  40. }else{
  41. $res['judge'] = '不合格';
  42. }
  43. unset($res['standard_id']);
  44. $this->success('请求成功',$res,200);
  45. }else{
  46. $this->error('请求失败,未查询到该批次号数据','',402);
  47. }
  48. }
  49. }