success('请求成功'); } /** * 产品表qr_code_product同步 */ public function vo1() { $num1 = $this->request->param('num1'); $num2 = $this->request->param('num2'); if($num2<=$num1){ $this->error('同步num1到num2之间的数据, 要求num2大于num1'); } $qcodeProduct = new QcodeProduct(); // 连接到其他数据库 $config = [ 'type' => 'mysql', 'hostname' => '127.0.0.1', 'database' => 'dm_7in6_com', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8mb4', 'prefix' => 'qr_', ]; $db = Db::connect($config); //查询主表记录 $rows1 = $db->name('qcode_product') ->limit($num1,$num2-$num1) ->select(); foreach($rows1 as $v){ //1. 查询mongodb中是否存在该条记录 $bool = $qcodeProduct->where('oid_id',$v['id'])->find(); if ($bool) continue; //2. 获取设置主表数据 $row['oid_id'] = $v['id']; $row['product_name'] = $v['product_name']; $row['product_code'] = $v['product_code']; $row['temple'] = $v['temple']; // unset($row['id']); // $row = array_merge(['oid_id'=>$v['id']],$row); //查询unit表数据 $rows2 = $db->name('qcode_unit') ->where('code',$v['product_code']) ->find(); if($rows2){ if($rows2['main_unit']!=null){ $row['main_unit'] = $rows2['main_unit']; }else{ $row['main_unit'] = ''; } if($rows2['sec_unit']!=null){ $row['sec_unit'] = $rows2['sec_unit']; }else{ $row['sec_unit'] = ''; } if($rows2['proportion']!=null){ $row['proportion'] = $rows2['proportion']; }else{ $row['proportion'] = ''; } }else{ $row['main_unit'] = ''; $row['sec_unit'] = ''; $row['proportion'] = ''; } git add application/admin/controller/QcodeBach.php git add application/admin/lang/zh-cn/qcode_bach.php git add application/admin/view/qcode_bach/index.html git add application/api/controller/Index.php git add public/assets/js/backend/qcode_bach.js git add application/admin/model/QcodeGsmc.php git add application/admin/view/qcode_bach/reprint.html git add public/assets/js/LodopFuncs.js git add vendor/phpqrcode/ //3. 插入主表记录到mongodb中 $qcodeProduct = new QcodeProduct(); $qcodeProduct->save($row); } $this->success('成功'); } /** * 产品表qr_code_unit同步 */ public function vo2() { $num1 = $this->request->param('num1'); $num2 = $this->request->param('num2'); if($num2<=$num1){ $this->error('同步num1到num2之间的数据, 要求num2大于num1'); } $qcodeGsmc = new QcodeGsmc(); // 连接到其他数据库 $config = [ 'type' => 'mysql', 'hostname' => '127.0.0.1', 'database' => 'dm_7in6_com', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8mb4', 'prefix' => 'qr_', ]; $db = Db::connect($config); //查询主表记录 $rows1 = $db->name('qcode_gsmc') ->limit($num1,$num2-$num1) ->select(); foreach($rows1 as $v){ //1. 查询mongodb中是否存在该条记录 $bool = $qcodeGsmc->where('oid_id',$v['id'])->find(); if ($bool) continue; //2. 获取设置主表数据 $row = $v; unset($row['id']); $row = array_merge(['oid_id'=>$v['id']],$row); //3. 插入主表记录到mongodb中 $qcodeGsmc = new QcodeGsmc(); $qcodeGsmc->save($row); } $this->success('成功'); } }