Bläddra i källkod

查询样品编号修改状态

曹鹤洋 2 år sedan
förälder
incheckning
f497c7384f
1 ändrade filer med 32 tillägg och 1 borttagningar
  1. 32 1
      application/api/controller/Index.php

+ 32 - 1
application/api/controller/Index.php

@@ -334,6 +334,13 @@ class Index extends Api
                 //将检测数据插入子表gather_txt_check_gc
                 db()->name('gather_txt_check_gc')->insertAll($row);
 
+                //去除数据文件名称后面的字母和.
+                $sample_no = preg_replace('/[a-zA-Z\.]+\s*$/', '', $res['data_txt_name']);
+                //查询entrust表中是否存在, 如果存在修改状态
+                if(db()->name('entrust')->where('sample_no',$sample_no)->find()){
+                    db()->name('entrust')->where('sample_no',$sample_no)->update(['data_status'=>1]);
+                }
+
                 //提交事务
                 db()->commit();
                 return json_encode(['code'=>'0','msg'=>'成功','time'=>$time,'data'=>[$res,$row]]);
@@ -521,7 +528,15 @@ class Index extends Api
                 }
 
                 //将检测数据插入子表gather_txt_check_gc
-                $id = db()->name('gather_txt_check_gcms')->insertAll($row);
+                db()->name('gather_txt_check_gcms')->insertAll($row);
+
+                //去除数据文件名称后面的字母和.
+                $sample_no = preg_replace('/[a-zA-Z\.]+\s*$/', '', $res['data_txt_name']);
+                //查询entrust表中是否存在, 如果存在修改状态
+                if(db()->name('entrust')->where('sample_no',$sample_no)->find()){
+                    db()->name('entrust')->where('sample_no',$sample_no)->update(['data_status'=>1]);
+                }
+
                 //提交事务
                 db()->commit();
 
@@ -829,6 +844,14 @@ class Index extends Api
 
                         //将检测数据插入子表gather_txt_check_gc
                         db()->name('gather_txt_check_gc')->insertAll($row);
+
+                        //去除数据文件名称后面的字母和.
+                        $sample_no = preg_replace('/[a-zA-Z\.]+\s*$/', '', $res['data_txt_name']);
+                        //查询entrust表中是否存在, 如果存在修改状态
+                        if(db()->name('entrust')->where('sample_no',$sample_no)->find()){
+                            db()->name('entrust')->where('sample_no',$sample_no)->update(['data_status'=>1]);
+                        }
+
                         //提交事务
                         db()->commit();
                         return json_encode(['code'=>'0','msg'=>'修改成功','time'=>$time,'data'=>[$res,$row]]);
@@ -1022,6 +1045,14 @@ class Index extends Api
 
                         //将检测数据插入子表gather_txt_check_gc
                         db()->name('gather_txt_check_gcms')->insertAll($row);
+
+                        //去除数据文件名称后面的字母和.
+                        $sample_no = preg_replace('/[a-zA-Z\.]+\s*$/', '', $res['data_txt_name']);
+                        //查询entrust表中是否存在, 如果存在修改状态
+                        if(db()->name('entrust')->where('sample_no',$sample_no)->find()){
+                            db()->name('entrust')->where('sample_no',$sample_no)->update(['data_status'=>1]);
+                        }
+                        
                         //提交事务
                         db()->commit();
                         return json_encode(['code'=>'0','msg'=>'修改成功','time'=>$time,'data'=>[$res,$row]]);