Kaynağa Gözat

txt上传#优化

曹鹤洋 2 yıl önce
ebeveyn
işleme
40ebca900e
1 değiştirilmiş dosya ile 21 ekleme ve 4 silme
  1. 21 4
      application/api/controller/Index.php

+ 21 - 4
application/api/controller/Index.php

@@ -511,7 +511,15 @@ class Index extends Api
                         $row[$k]['quantitative_ion'] = $v[3];
                         $row[$k]['response_value'] = $v[4];
                         $row[$k]['potency'] = $v[5];
-                        $row[$k]['unit'] = $v[6];
+                        preg_match('/#/', $v[6], $matches);
+                        if(count($matches)){
+                            $unit = str_replace('#', '', $v[6]);
+                            $row[$k]['unit'] = $unit;
+                            $row[$k]['deviation'] = '#';
+                        }else{
+                            $row[$k]['unit'] = $v[6];
+                            $row[$k]['deviation'] = '';
+                        }
                         $row[$k]['quanlitative_ion'] = $v[7];
                         $row[$k]['create'] = $time;
                     }else{
@@ -522,6 +530,7 @@ class Index extends Api
                         $row[$k]['response_value'] = $v[3];
                         $row[$k]['potency'] = $v[3];
                         $row[$k]['unit'] = $v[3];
+                        $row[$k]['deviation'] = '';
                         $row[$k]['quanlitative_ion'] = $v[3];
                         $row[$k]['create'] = $time;
                     }
@@ -1027,7 +1036,15 @@ class Index extends Api
                                 $row[$k]['quantitative_ion'] = $v[3];
                                 $row[$k]['response_value'] = $v[4];
                                 $row[$k]['potency'] = $v[5];
-                                $row[$k]['unit'] = $v[6];
+                                preg_match('/#/', $v[6], $matches);
+                                if(count($matches)){
+                                    $unit = str_replace('#', '', $v[6]);
+                                    $row[$k]['unit'] = $unit;
+                                    $row[$k]['deviation'] = '#';
+                                }else{
+                                    $row[$k]['unit'] = $v[6];
+                                    $row[$k]['deviation'] = '';
+                                }
                                 $row[$k]['quanlitative_ion'] = $v[7];
                                 $row[$k]['create'] = $time;
                             }else{
@@ -1038,6 +1055,7 @@ class Index extends Api
                                 $row[$k]['response_value'] = $v[3];
                                 $row[$k]['potency'] = $v[3];
                                 $row[$k]['unit'] = $v[3];
+                                $row[$k]['deviation'] = '';
                                 $row[$k]['quanlitative_ion'] = $v[3];
                                 $row[$k]['create'] = $time;
                             }
@@ -1045,14 +1063,13 @@ 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]]);