Browse Source

api接口

wuwenqiang 2 years ago
parent
commit
1203055fe1
1 changed files with 56 additions and 0 deletions
  1. 56 0
      application/api/controller/Data.php

+ 56 - 0
application/api/controller/Data.php

@@ -0,0 +1,56 @@
+<?php
+
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+
+/**
+ * 示例接口
+ */
+class Data extends Api
+{
+    protected $noNeedLogin = ['*'];
+
+    public function index(){
+        $params = $this->request->param();
+        if (empty($params['batch'])){
+            $this->error('参数错误','',401);
+        }
+        $where = [];
+        $where['bach'] = $params['batch'];
+        $where['delete_time'] = null;
+        $where['sample_no'] = array('like','%A%');
+        $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();
+        if ($res){
+            $check = Db::name('item_judge_detail')->where('pid',$res['standard_id'])->select();
+            foreach ($check as $key => $value){
+                if ($value['params'] == '溶剂残留总量'){
+                    $res['dis_max'] = $value['max'];
+                }
+                if ($value['params'] == '溶剂杂质总量'){
+                    $res['dis_impurity_max'] = $value['max'];
+                }
+                if ($value['params'] == '苯系物总量'){
+                    $res['ben_total_max'] = $value['max'];
+                }
+                if ($value['params'] == '苯含量'){
+                    $res['ben_max'] = $value['max'];
+                }
+            }
+            $res['create'] = date('Y',strtotime($res['create'])).'.'.date('m',strtotime($res['create'])).'.'.date('d',strtotime($res['create']));
+            if ($res['judge'] == 1){
+                $res['judge'] = '合格';
+            }else{
+                $res['judge'] = '不合格';
+            }
+            unset($res['standard_id']);
+            $this->success('请求成功',$res,200);
+        }else{
+            $this->error('请求失败,未查询到该批次号数据','',402);
+        }
+
+    }
+
+}