Browse Source

first commit

liuhairui 6 months ago
parent
commit
b34e252e80
3 changed files with 28 additions and 51 deletions
  1. 8 21
      application/admin/controller/QcodeAdd.php
  2. 12 22
      application/config.php
  3. 8 8
      application/database.php

+ 8 - 21
application/admin/controller/QcodeAdd.php

@@ -19,11 +19,6 @@ class QcodeAdd extends Backend
 {
     /**
      * 首页展示
-     * @return string|\think\response\Json
-     * @throws \think\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
      */
     public function index()
     {
@@ -64,6 +59,8 @@ class QcodeAdd extends Backend
                 echo "创建集合 {$tableName} 失败:" . $e->getMessage();
             }
         }
+
+
 //        $product_id = $company->name((int)$userinfo['company'].'_'.'qcode_company')->where('delete_time','')->column('product_id');
 //        echo "<pre>";
 //        print_r($product_id);
@@ -73,9 +70,6 @@ class QcodeAdd extends Backend
 //            $list = $product->where('_id',$v)->where('delete_time','')->find();
 //            $product_name[$list['product_code']] =  $list['product_name'];
 //        }
-//        echo "<pre>";
-//        print_r($product_name);
-//        echo "<pre>";
 //        $this->view->assign('product', $product_name);
 
         // 1. 获取所有产品的 ID
@@ -94,8 +88,8 @@ class QcodeAdd extends Backend
             if ($list) {
                 // 记录完整产品信息
                 $product_info[$list['product_code']] = [
-                    'jjcp_cpmc' => $list['product_name'], // 产品名称
-                    'jjcp_cpdh' => $list['product_code'], // 产品代码
+                    'jjcp_cpmc' => $list['product_name'],
+                    'jjcp_cpdh' => $list['product_code'],
                 ];
             }
         }
@@ -115,25 +109,22 @@ class QcodeAdd extends Backend
                     $matched_products[] = [
                         'jjcp_cpmc' => $item['jjcp_cpmc'],
                         'jjcp_cpdh' => $item['jjcp_cpdh'],
-                        'order_ddbh' => $mp['order_ddbh'], // 从 MongoDB 查找
-                        'jjcp_gdbh' => $mp['jjcp_gdbh'],   // 从 MongoDB 查找
-                        'jjcp_sl' => $mp['jjcp_sl'],       // 从 MongoDB 查找
+                        'order_ddbh' => $mp['order_ddbh'],
+                        'jjcp_gdbh' => $mp['jjcp_gdbh'],
+                        'jjcp_sl' => $mp['jjcp_sl'],
                         'product_code' => $code,
                     ];
                 }
             }
         }
         $this->view->assign('product', $matched_products);
+
         $this->view->assign('row',$data);
         return $this->view->fetch();
     }
 
     /**
      * 获取产品信息
-     * @return \think\response\Json
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
      */
     public function product(){
         $QcodeProduct = new QcodeProduct();
@@ -169,10 +160,6 @@ class QcodeAdd extends Backend
 
     /**
      * 增加新批次
-     * @return void
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
      */
     public function add()
     {

+ 12 - 22
application/config.php

@@ -316,30 +316,20 @@ return [
         'api_url'               => 'https://api.fastadmin.net',
     ],
     'mongodb' => [
-        // 数据库类型
         'type'        => '\think\mongo\Connection',
-        // Query类
-        'query'           => '\think\mongo\Query',
-        // 数据库连接DSN配置
-        'dsn'         => '',
-        // 服务器地址
-        'hostname' =>Env::get('mongodb.hostname', "10.10.4.58"),
-        // 验证数据库
-        'database'    => Env::get('mongodb.database', "dm_v3_7in6_com"),
-
-        // 数据库用户名
-        'username'    => Env::get('mongodb.username', "dm_v3_7in6_com"),
-        // 数据库密码
-        'password'    => Env::get('mongodb.password', "RC6Y2mhZKGKr247W"),
-        // 数据库连接端口
-        'hostport'    => Env::get('mongodb.hostport', "27017"),
-        // 数据库连接参数x
-        'params'      => [],
-        // 数据库编码默认采用utf8
+        'query'       => '\think\mongo\Query',
+        'hostname'    => '10.10.4.58',
+        'hostport'    => 27017,
+        'database'    => 'ymnydm',
+        'username'    => 'ymnydm',
+        'password'    => 'D4zKiM4rLjXH35c7',
+        'params'      => [
+            'authSource' => 'ymnydm'   // 重点是这里
+        ],
         'charset'     => 'utf8mb4',
-        // 数据库表前缀
         'prefix'      => '',
         'pk_convert_id' => false,
-        'debug'     =>  false,
-    ],
+        'debug'       => false,
+    ]
+
 ];

+ 8 - 8
application/database.php

@@ -16,13 +16,13 @@ return [
     // 数据库类型
     'type'            => Env::get('database.type', 'mysql'),
     // 服务器地址
-    'hostname'        => Env::get('database.hostname', '10.10.4.58'),
+    'hostname'        => Env::get('database.hostname', 'rm-bp17w41t6c09dl10ayo.mysql.rds.aliyuncs.com'),
     // 数据库名
-    'database'        => Env::get('database.database', 'zsfastadmin'),
+    'database'        => Env::get('database.database', 'ymnydm'),
     // 用户名
-    'username'        => Env::get('database.username', 'zsfastadmin'),
+    'username'        => Env::get('database.username', 'ymnydm'),
     // 密码
-    'password'        => Env::get('database.password', 'fDkGB8NYm2yKR3eD'),
+    'password'        => Env::get('database.password', '!QAZ2wsx#EDC'),
     // 端口
     'hostport'        => Env::get('database.hostport', ''),
     // 连接dsn
@@ -60,11 +60,11 @@ return [
         // 服务器地址
         'hostname'        => Env::get('database.mongodb.hostname', '10.10.4.58'),
         // 数据库名
-        'database'        => Env::get('database.mongodb.database', 'zsdm_v3_7in6_com'),
+        'database'        => Env::get('database.mongodb.database', 'ymnydm'),
         // 用户名
-        'username'        => Env::get('database.mongodb.username', 'zsdm_v3_7in6_com'),
+        'username'        => Env::get('database.mongodb.username', 'ymnydm'),
         // 密码
-        'password'        => Env::get('database.mongodb.password', 'GaMwsGWheaB3MH5r'),
+        'password'        => Env::get('database.mongodb.password', 'D4zKiM4rLjXH35c7'),
     ],
     /**
      * 配置中间表数据库
@@ -110,5 +110,5 @@ return [
         'datetime_format' => false,
         // 是否需要进行SQL性能分析
         'sql_explain'     => false,
-    ]
+    ],
 ];