瀏覽代碼

no message

wzh 5 年之前
父節點
當前提交
0ee724366d
共有 2 個文件被更改,包括 14 次插入2 次删除
  1. 10 0
      api/application/controllers/Base_Controller.php
  2. 4 2
      api/application/controllers/Lampcontrol.php

+ 10 - 0
api/application/controllers/Base_Controller.php

@@ -245,4 +245,14 @@ class Base_Controller extends CI_Controller {
         // var_dump($sendData);die;
         return lampMqttCmd('/IDCOL/CmdInput/'.$address,'/IDCOL/CmdOutput/'.$address,pack('H*',$sendData),$timeout);
     }
+
+    // 根据设备地址获取制造商
+    protected function get_manu_by_address($address){
+        $id = substr($address, 0,2);
+        $res = $this->db->query('select id from company where companyId like "'.$id.'%" order by id desc')->row_array();
+        if (empty($res) || empty($res['id'])) {
+            return 0;
+        }
+        return $res['id'];
+    }
 }

+ 4 - 2
api/application/controllers/Lampcontrol.php

@@ -875,8 +875,8 @@ class Lampcontrol extends Base_Controller {
         $data["supplier"] = !empty($supplier) ? $supplier : 0;
         $po = $this->input->post('po',true);
         $data["po"] = !empty($po) ? $po : 0;
-        $manu = $this->input->post('manu',true);
-        $data["manu"] = !empty($manu) ? $manu : 0;
+        // $manu = $this->input->post('manu',true);
+        // $data["manu"] = !empty($manu) ? $manu : 0;
         $protocoltype = $this->input->post('protocoltype',true);
         $data['protocoltype'] = $protocoltype;
 
@@ -896,6 +896,8 @@ class Lampcontrol extends Base_Controller {
                 exit(json_result('0013',$this->response['0013']));
             }
         }
+
+        if (!isset($data["manu"])) $data["manu"] = $this->get_manu_by_address($data["address"]);
         
         // 控制器协议类型
         $version = $this->session->userdata('version');