Explorar el Código

流程单打印优化

qiuenguang hace 1 año
padre
commit
71bf49f079
Se han modificado 1 ficheros con 6 adiciones y 4 borrados
  1. 6 4
      application/api/controller/ProcessDocument.php

+ 6 - 4
application/api/controller/ProcessDocument.php

@@ -83,7 +83,8 @@ class ProcessDocument extends Api
         $where = array();
         //印件代号
         $where['product_number'] = $params['yjdh'];
-        $res = Db::connect('db2')->name('qr_history')->where($where)->order('id desc')->field('data,update')->find();
+        $db2 = \db()->connect(config('database.db2'));
+        $res = $db2->name('qr_history')->where($where)->order('id desc')->field('data,update')->find();
         $result = array();
         $result['update'] = '暂无';
         $result['data'] = '';
@@ -112,6 +113,7 @@ class ProcessDocument extends Api
         if (empty($params['order'])){
             $this->error('参数不能为空');
         }
+        $db2 = \db()->connect(config('database.db2'));
         $ip = request()->ip();
         //定义各部门ip地址
         $JYarray=array('20.0.3.253','60.190.242.28','127.0.0.1');
@@ -134,11 +136,11 @@ class ProcessDocument extends Api
         $map['product_number'] = $data['product_number'];
         $data['update'] = date('Y-m-d H:i:s');
         $data['ip'] =$ip;
-        $isNull = Db::connect('db2')->name('qr_history')->where($map)->find();
+        $isNull = $db2->name('qr_history')->where($map)->find();
         if ($isNull){//去更新工艺及时间
-            $res = Db::connect('db2')->name('qr_history')->where('id',$isNull['id'])->update($data);
+            $res = $db2->name('qr_history')->where('id',$isNull['id'])->update($data);
         }else{//新增
-            $res = Db::connect('db2')->name('qr_history')->insert($data);
+            $res = $db2->name('qr_history')->insert($data);
         }
         if ($res){
             $this->success('更新成功');