MS-PDRLKVHCADMG\Administrator 5 år sedan
förälder
incheckning
8e4985df98

+ 9 - 0
api/application/controllers/Common.php

@@ -214,6 +214,15 @@ class Common extends CI_Controller {
 
         exit(json_result('0000',$this->response['0000'],array('path'=>base_url($url))));
     }
+
+    public function model_nav(){
+        $supId = intval($this->input->post('supId',true));
+        if (empty($supId)) exit(json_result('0007',$this->response['0007']));
+
+        $list = $this->db->query('select id,name from model_info where supId = '.$supId)->result_array();
+        exit(json_result('0000',$this->response['0000'],['list'=>$list]));
+    }
+
     public function workmode() {
         $version = $this->session->userdata('version');
         if (empty($version)) {

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

@@ -880,6 +880,10 @@ class Lampcontrol extends Base_Controller {
         $protocoltype = $this->input->post('protocoltype',true);
         $data['protocoltype'] = $protocoltype;
 
+        $data['model'] = intval($this->input->post('model',true));
+        $data['power'] = intval($this->input->post('power',true));
+
+
         $loadtype = $this->input->post('loadtype',true);
         if ($loadtype !== null) {
             $data["loadtype"] = intval($loadtype);
@@ -915,6 +919,13 @@ class Lampcontrol extends Base_Controller {
             if ($this->Lamp_model->getDataCount(array('number'=>$data['number'], 'projectid'=>$data['projectid'])) > 0) {
                 exit(json_result('0401', $this->response['0401'], array()));
             }   
+            $fascal_year = $this->input->post('fascal_year',true);
+            if (empty($fascal_year)) $fascal_year = date('Y-m-d');
+            $data['fascal_year'] = $fascal_year;
+
+            $fascal_year_phase = $this->input->post('fascal_year_phase',true);
+            if (empty($fascal_year_phase)) $fascal_year_phase = date('Y');
+            $data['fascal_year_phase'] = $fascal_year_phase.'-'.date('Y',strtotime($fascal_year_phase.' +1 year'));
 
             $lamp = $this->Lamp_model->get_one(array('address'=>$data['address']),'projectid,number');
             if (!empty($lamp)) {
@@ -933,8 +944,8 @@ class Lampcontrol extends Base_Controller {
                 $data['longitude'] = $globalData['longitude'];
                 $data['latitude'] = $globalData['latitude'];
             }
-
-            $data['createtime'] = date('Y-m-d H:i:s',time());
+            $createtime = $this->input->post('createtime',true);
+            $data['createtime'] = empty($createtime) ? date('Y-m-d H:i:s',time()) : $createtime;
 
             $lampid = $this->Lamp_model->add($data);
 
@@ -949,6 +960,12 @@ class Lampcontrol extends Base_Controller {
                 exit(json_result('0401', $this->response['0401'], array()));
             }
 
+            $fascal_year = $this->input->post('fascal_year',true);
+            if (!empty($fascal_year)) $data['fascal_year'] = $fascal_year;
+
+            $fascal_year_phase = $this->input->post('fascal_year_phase',true);
+            if (!empty($fascal_year_phase)) $data['fascal_year_phase'] = $fascal_year_phase;
+
             $lamp = $this->Lamp_model->get_one(array('address'=>$data['address'], 'id !='=>$where['id']),'projectid,number');
             if (!empty($lamp)) {
                 $projectid = $lamp['projectid'];

+ 75 - 0
api/application/controllers/Test.php

@@ -0,0 +1,75 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+
+class Test extends CI_Controller {
+    
+    var $response;
+    var $userinfo;
+    var $version;
+
+    public function __construct() {
+        parent::__construct();
+        $this->load->model('User_model');
+        $this->response = $this->config->config['response_en'];
+
+        $version = 1;
+        $this->session->set_userdata('version', $version);
+        $this->version = $version;
+    }
+
+    // 批量导入
+    public function haha(){
+        $indexArr = ['B'=>'b','C'=>'c'];
+        // 文件上传成功
+        // $data = $this->upload->data();
+
+        $filePath = '../upload/test.xlsx';
+        $this->load->library('phpExcel/PHPExcel');
+
+        $extension = strtolower( pathinfo($filePath, PATHINFO_EXTENSION) );
+         if($extension =='xls' ){
+            $reader = PHPExcel_IOFactory::createReader('Excel5');
+        }elseif($extension =='xlsx'){
+            $reader = PHPExcel_IOFactory::createReader('Excel2007');
+        }else if ($extension=='csv' || strtolower($extension)=='hcl') {
+            $reader = new PHPExcel_Reader_CSV();               
+        }
+
+        // $reader = PHPExcel_IOFactory::createReader('Excel5'); //设置以Excel5格式(Excel97-2003工作簿)
+
+        $PHPExcel = $reader->load($filePath); // 载入excel文件  
+        $sheet = $PHPExcel->getSheet(0); // 读取第一個工作表  
+        $highestRow = $sheet->getHighestRow(); // 取得总行数  
+        // $highestColumm = $sheet->getHighestColumn(); // 取得总列数  
+          
+        /** 循环读取每个单元格的数据 */  
+        $k = 0;
+        $data = array();
+        for ($row = 1; $row <= $highestRow; $row++)    //行号从1开始  
+        {  
+            if ($row < 4) continue; // 跳过标题行
+            foreach ($indexArr as $key => $value) {
+                $res = $sheet->getCell($key.$row)->getValue();
+
+                if (is_object($res)) {
+                    $res= $res->__toString();
+                }
+                $data[$k][$value] = $res;  
+            }
+
+            $k ++;
+        }
+        $supId = 0;
+        foreach ($data as $key => $value) {
+            if (isset($value['b']) && !empty($value['b'])) {
+                $res = $this->db->query('select * from company where name = "'.$value['b'].'"')->row_array();
+                // if (empty($res)) var_dump($value['b']);
+                $supId = $res['id'];
+                // var_dump($res);
+            }
+            if (!empty($value['c'])) $this->db->query('insert into model_info (supId,name) values('.$supId.',"'.$value['c'].'")');
+        }
+        var_dump($data);die;
+        // 批量写入数据
+        return $data;
+    }
+}

sendCmd/sumData.php → sendCmd/idcol_sumData.php