|
@@ -2,6 +2,7 @@
|
|
|
namespace app\index\controller;
|
|
|
|
|
|
use app\common\util\AppMsg;
|
|
|
+use app\common\util\ExcelUtil;
|
|
|
use app\hander\HelpHander;
|
|
|
use EasyWeChat\Factory;
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
@@ -17,6 +18,47 @@ class Index extends Controller
|
|
|
// $this->model = new \app\common\model\Daily();
|
|
|
}
|
|
|
|
|
|
+ public function device(){
|
|
|
+ set_time_limit(0);
|
|
|
+ ini_set("memory_limit","512M");
|
|
|
+
|
|
|
+ $file = "./1.xls";
|
|
|
+ $orgId = 100;
|
|
|
+ $cate1 = 22; //灭火器
|
|
|
+ $cate2 = 23; // 消火栓
|
|
|
+ $form1 = "20,21,22,23";
|
|
|
+ $form2 = "24,25,26,27";
|
|
|
+
|
|
|
+ $userId = 3139;
|
|
|
+
|
|
|
+ $data = ExcelUtil::read($file,['title','sn','area','cate_id','content']);
|
|
|
+ $i = 0;
|
|
|
+ foreach ($data as $k=>$v){
|
|
|
+ if($i >= 906){
|
|
|
+ $data[$k]['org_id'] = $orgId;
|
|
|
+ $data[$k]['enable'] = 1;
|
|
|
+ if($v['cate_id'] == "灭火器"){
|
|
|
+ $data[$k]['cate_id'] = $cate1;
|
|
|
+ $data[$k]['device_form'] = $form1;
|
|
|
+ }else{
|
|
|
+ $data[$k]['cate_id'] = $cate2;
|
|
|
+ $data[$k]['device_form'] = $form2;
|
|
|
+ }
|
|
|
+
|
|
|
+ $deivceId = Db::name('device')->insertGetId($data[$k]);
|
|
|
+ if($deivceId){
|
|
|
+ Db::name('device_user')->insert([
|
|
|
+ "device_id" => $deivceId,
|
|
|
+ "user_id" => $userId,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ halt($data);
|
|
|
+ }
|
|
|
+
|
|
|
public function tt(){
|
|
|
$orgId = 28;
|
|
|
$mode = 3;
|