Jelajahi Sumber

啥也没改

gbsong 3 tahun lalu
induk
melakukan
b8aa891258

+ 13 - 3
app/api/business/JcdBus.php

@@ -2,18 +2,28 @@
 
 namespace app\api\business;
 
+use app\api\model\Ccjc;
 use app\api\model\Cyd;
+use app\api\model\TestPesticides;
 
 class JcdBus
 {
 
     public function getJcdList($data)
     {
-
-
         $jcd_info = (new Cyd())->getCydListByUndertakeId($data['undertake_id'], $data['pageNum'], $data['pageSize']);
+        $jcd_info_count = (new Cyd())->countCydListByUndertakeId($data['undertake_id']);
 
-        return $jcd_info;
+        return ['rows'=>$jcd_info,'total'=>$jcd_info_count];
+    }
 
+    public function getModelItemBySampleID($sampel_id)
+    {
+        //根据模型,需要先获取到task_id才能获取到model_id,最后获取检测项
+        $task_id = (new Cyd())->getCydInfoBySampleId($sampel_id)['task_id'];
+        $test_model_id = (new Ccjc())->getTaskInfoByTaskID($task_id)['test_model_id'];
+        $model_item = (new TestPesticides())->getInfoByTestModelId($test_model_id);
+        return $model_item;
     }
+
 }

+ 3 - 4
app/api/business/SampleBus.php

@@ -40,9 +40,9 @@ class SampleBus
 
         $where=[
             ['cyd.task_id', '=', $data['task_id']],//这里绑定成cyd.task_id进行查询
-            ['uid', '=', $uid]
+            ['undertake_id','=',$data['undertake_id']],
+            //['uid', '=', $uid]
         ];
-
         //注释掉的是搜索功能
 //        if ($data['sample_name']!='') $where[]=['sample_name', 'LIKE', '%'.$data['sample_name'].'%'];//样品名称
 //        if ($data['sample_id']!='') $where[]=['sample_id', 'LIKE', '%'.$data['sample_id'].'%'];//样品编码
@@ -57,7 +57,6 @@ class SampleBus
 //
 //        if($data['sample_data']!='') $where[]=['sample_date','=',$data['sample_data']];//抽样日期
 
-
         $result = (new Cyd())->selectSampleListByTaskIdAndUid($where, $data['pageNum'], $data['pageSize']);
         $count = (new Cyd())->countSampleListByTaskIdAndUid($where);
         return ['rows'=>$result,'total'=>$count];
@@ -68,7 +67,7 @@ class SampleBus
         $model_id = (new Ccjc())->getTaskInfoByTaskID($task_id)['test_model_id'];
         $data = (new TestModel())->getProductInfo($model_id);
         $result=(new Arr())->Arr_columns($data, 'product_name,product_id');
-        return [$result];
+        return $result;
 
     }
 

+ 5 - 3
app/api/controller/v1/Jcd.php

@@ -14,7 +14,7 @@ class Jcd
         $data = [
             'pageNum' => request()->param('pageNum', 1, 'int'),
             'pageSize' => request()->param('pageSize', null, 'int'),
-            'undertake_id' => request()->param('undertake_id', '', 'int'),//当前的选中项的undertake_id,在数据库cyd中的undertake_id,undertake的id
+            'undertake_id' => request()->param('underTake_id',null, 'int'),//当前的选中项的undertake_id,在数据库cyd中的undertake_id,undertake的id
         ];
 
         $result = (new JcdBus())->getJcdList($data);
@@ -22,11 +22,13 @@ class Jcd
     }
 
     //填报检测单
-    public function saveJcdInfo()
+    public function getJcdObjectItem()
     {
         $data = [
-
+            'sample_id' => request()->param('sample_id', '', 'trim'),
         ];
+        $result = (new JcdBus())->getModelItemBySampleID($data['sample_id']);
+        return showSuccess($result);
 
     }
 }

+ 4 - 5
app/api/controller/v1/Sample.php

@@ -15,10 +15,10 @@ class Sample
     public function selectSampleList()
     {
         $data=[
-            'pageNum' => request()->param('pageNum',1,'trim'),//页码
-            'pageSize' => request()->param('pageSize',10,'trim'),//每页显示数量
-            'task_id' => request()->param('task_id','','trim'),//任务id
-            'undertake_id' => request()->param('undertake_id', '', 'trim'),//当前任务对应的承担信息,在undertake表中的id
+            'pageNum' => request()->param('pageNum',1,'int'),//页码
+            'pageSize' => request()->param('pageSize',10,'int'),//每页显示数量
+            'task_id' => request()->param('task_id',null,'int'),//任务id
+            'undertake_id' => request()->param('undertake_id', null, 'int'),//当前任务对应的承担信息,在undertake表中的id
 
 //注释掉的是原来的搜索功能
 //            'sample_name' => request()->param('sample_name','','trim'),//样品名称
@@ -30,7 +30,6 @@ class Sample
 //            'sample_ground' => request()->param('sample_ground','','trim'),//抽样场所
         ];
 
-
         $result = (new SampleBus())->selectSampleList($data);
         return showSuccess($result);
     }

+ 13 - 0
app/api/model/Cyd.php

@@ -40,6 +40,13 @@ class Cyd extends Model
             ->select();
         return $data;
     }
+    public function countCydListByUndertakeId($undertake_id)
+    {
+        $data = $this->with('undertake')
+            ->where('undertake_id', '=', $undertake_id)
+            ->count();
+        return $data;
+    }
 
     public function getCydDetailBySampleID($sample_id)
     {
@@ -68,6 +75,7 @@ class Cyd extends Model
 
     public function selectSampleListByTaskIdAndUid($where,$pageNum=1,$pageSize=null)
     {
+
         //这里保留两个task_id是为了以后可能会删除一个
         $result = $this
             ->alias('cyd')
@@ -121,4 +129,9 @@ class Cyd extends Model
     {
         return $this->whereDay('createtime','today')->count();
     }
+
+    public function getCydInfoBySampleId($sample_id)
+    {
+        return $this->where('sample_id', '=', $sample_id)->find();
+    }
 }

+ 4 - 0
app/api/model/TestPesticides.php

@@ -23,4 +23,8 @@ class TestPesticides extends Model
         return $this->insertAll($update_data);
     }
 
+    public function getInfoByTestModelId($test_model_id)
+    {
+        return $this->where('test_model_id', '=', $test_model_id)->select();
+    }
 }

+ 4 - 3
app/api/route/app.php

@@ -12,6 +12,10 @@ Route::group(function () {
 })->allowCrossDomain();
 
 Route::group(function () {
+    //检测单 相关路由
+    Route::post(":version.getJcdList",":version.Jcd/getJcdList");        //获取检测单列表
+    Route::post(":version.getJcdObjectItem",":version.Jcd/getJcdObjectItem");        //填报检测单
+
     //监管单位路由
     Route::post(":version.AddTask",":version.superviser/create");        //增 添加任务
     Route::post(":version.delTask",":version.superviser/delete");        //删 删除任务
@@ -28,9 +32,6 @@ Route::group(function () {
     Route::post(":version.getSampleId",":version.Sample/createSampleId");        //抽样单中生成样品编码
 
 
-    //检测单 相关路由
-    Route::post(":version.getJcdList",":version.Jcd/getJcdList");        //获取检测单列表
-    Route::post(":version.saveJcdList",":version.Jcd/saveJcdInfo");        //填报检测单列表