Forráskód Böngészése

优化提交到检测

liuhairui 2 éve
szülő
commit
c885564e1f
1 módosított fájl, 29 hozzáadás és 8 törlés
  1. 29 8
      application/admin/controller/Entrust.php

+ 29 - 8
application/admin/controller/Entrust.php

@@ -335,19 +335,40 @@ class Entrust extends Backend
          * 2、gc或gcms中有一个有数据,判定这个数据为检测数据
          * 3、gc和gcms都有数据,将创建时间转换为时间戳,判断大小,时间戳大的检测数据此委托单的检测数据
         */
+        $data_txt_gc = $entrust['sample_no'] . '.D';
+        $gather_gc = Db::name('gather_txt_gc')->where('data_txt_name', ['=',$data_txt_gc],['=',$entrust['sample_no'].'R.D'],'or')->order('id desc')->find();
 
         if (empty($gather_gcms)) {
-            $data_txt_gc = $entrust['sample_no'] . '.D';
-            $gather_gc = Db::name('gather_txt_gc')->where('data_txt_name', ['=',$data_txt_gc],['=',$entrust['sample_no'].'R.D'],'or')->order('id desc')->find();
-            if (empty($gather_gc)) {
-                $this->error('序号为'.$id.'的样品未获取到检测数据,请取消选中');
-            }
             $gather = $gather_gc;
             $gather_tab = 'gather_txt_check_gc';
-        } else {
-            $gather = $gather_gcms;
-            $gather_tab = 'gather_txt_check_gcms';
+            if (empty($gather_gc)) {
+                $this->error('没获取到检测数据');
+            }
+        }else{
+            $gcms_time = strtotime($gather_gcms['create']);//gcms创建时间转换为时间戳
+            $gc_time = strtotime($gather_gc['create']);    //gc创建时间转换为时间戳
+            if($gcms_time > $gc_time){
+                //gcms时间最新
+                $gather = $gather_gcms;
+                $gather_tab = 'gather_txt_check_gcms';
+            }else{
+                //gc时间最新
+                $gather = $gather_gc;
+                $gather_tab = 'gather_txt_check_gc';
+            }
         }
+//        if (empty($gather_gcms)) {
+//            $data_txt_gc = $entrust['sample_no'] . '.D';
+//            $gather_gc = Db::name('gather_txt_gc')->where('data_txt_name', ['=',$data_txt_gc],['=',$entrust['sample_no'].'R.D'],'or')->order('id desc')->find();
+//            if (empty($gather_gc)) {
+//                $this->error('序号为'.$id.'的样品未获取到检测数据,请取消选中');
+//            }
+//            $gather = $gather_gc;
+//            $gather_tab = 'gather_txt_check_gc';
+//        } else {
+//            $gather = $gather_gcms;
+//            $gather_tab = 'gather_txt_check_gcms';
+//        }
         $detail_data = Db::name($gather_tab)->where('pid', $gather['id'])->field('chemical_compound,potency')->select();
         $is_qualified = [];//默认合格,当有一项不合格时,判定此次检测不合格
         $dis = 0;//溶剂残留总量