Commit 259b3c43 authored by 蔡闯's avatar 蔡闯

20201-1-7

parent 719da6bc
...@@ -359,8 +359,6 @@ class Common extends BaseController ...@@ -359,8 +359,6 @@ class Common extends BaseController
//用户导入 //用户导入
public static function importTenant($filePath,$village_id) { public static function importTenant($filePath,$village_id) {
$where['village_id'] = $village_id; $where['village_id'] = $village_id;
$objReader = \PHPExcel_IOFactory::createReader('Excel5');//配置成2003版本,因为office版本可以向下兼容 $objReader = \PHPExcel_IOFactory::createReader('Excel5');//配置成2003版本,因为office版本可以向下兼容
$objPHPExcel = $objReader->load($filePath,$encode='utf-8');//$file 为解读的excel文件 $objPHPExcel = $objReader->load($filePath,$encode='utf-8');//$file 为解读的excel文件
...@@ -370,11 +368,12 @@ class Common extends BaseController ...@@ -370,11 +368,12 @@ class Common extends BaseController
$errorData =[]; //存放导入失败的数据; $errorData =[]; //存放导入失败的数据;
$insertData = []; $insertData = [];
$layout_list = Db::name('layout_list')->where($where)->column('layout_id','code'); $layout_list = Db::name('layout_list')->where($where)->column('layout_id','code');
$layoutList = Db::name('layout_list');
for($i=1;$i<$highestRow;$i++) { for($i=1;$i<$highestRow;$i++) {
$msg=""; $msg="";
$name = $dataAll[$i][0]; $name = $dataAll[$i][0];
if(is_null($name)){
continue;
}
$phone = $dataAll[$i][1]; $phone = $dataAll[$i][1];
if(!isPhoneNo($phone)){ if(!isPhoneNo($phone)){
$msg.="手机号不正确!"; $msg.="手机号不正确!";
...@@ -387,13 +386,13 @@ class Common extends BaseController ...@@ -387,13 +386,13 @@ class Common extends BaseController
if($layout_list_code) { if($layout_list_code) {
$layout_id = $layout_list[$layout_list_code]; $layout_id = $layout_list[$layout_list_code];
} else { } else {
$msg .="社区布局未选择!"; $msg.="社区布局未选择!";
} }
$vacancyCode = $dataAll[$i][3]; $vacancyCode = $dataAll[$i][3];
//验证房间编号是否存在,是否合理 //验证房间编号是否存在,是否合理
$res_vacancy_code = self::getVacancyCode($vacancyCode,$layout_id); $res_vacancy_code = self::getVacancyCode($vacancyCode,$layout_id);
if($res_vacancy_code['code'] !=200) { if($res_vacancy_code['code'] !=200) {
$msg .= "房间编号不正确!"; $msg.= "房间编号不正确!";
} }
$where['vacancy_code'] = $res_vacancy_code['msg']; $where['vacancy_code'] = $res_vacancy_code['msg'];
$vacancy_id = Db::name('house_vacancy')->where($where)->value('vacancy_id'); $vacancy_id = Db::name('house_vacancy')->where($where)->value('vacancy_id');
...@@ -418,16 +417,13 @@ class Common extends BaseController ...@@ -418,16 +417,13 @@ class Common extends BaseController
$msg.='该房间已绑定业主,请在解绑!'; $msg.='该房间已绑定业主,请在解绑!';
} }
} }
$data['vacancy_id'] = $vacancy_id; $data['vacancy_id'] = $vacancy_id;
$data['village_id'] = $village_id; $data['village_id'] = $village_id;
$data['id_card'] = $id_card; $data['id_card'] = $id_card;
$data['name'] = $name; $data['name'] = $name;
$data['phone'] = $phone; $data['phone'] = $phone;
$data['type'] = $type; $data['type'] = $type;
if($type==1) {
$data['relatives_type'] =1; //默认 $data['relatives_type'] =1; //默认
}
$data['create_time'] = $data['pass_time'] = time(); $data['create_time'] = $data['pass_time'] = time();
$data['status'] =1; $data['status'] =1;
if(empty($msg)){ if(empty($msg)){
...@@ -437,16 +433,18 @@ class Common extends BaseController ...@@ -437,16 +433,18 @@ class Common extends BaseController
$errorData[] = $dataAll[$i]; $errorData[] = $dataAll[$i];
} }
} }
//导入对的数据
if(!empty($insertData)){ if(!empty($insertData)){
Db::name('house_user_bind')->insertAll($insertData); Db::name('house_user_bind')->insertAll($insertData);
}
//如果有错误的数据,导出
if($errorData){ if($errorData){
//导出错误的数据 //导出错误的数据
$file = "./formwork/importTenant.xls"; $file = "./formwork/importTenant.xls";
$phpExcel = \PHPExcel_IOFactory::load($file); $phpExcel = \PHPExcel_IOFactory::load($file);
$title = ['A','B','C','D','E','F','G']; $title = ['A','B','C','D','E','F','G'];
$i = 2; $i = 2;
$optionsArr = $layoutList->where(['village_id'=>$village_id])->column('code'); $optionsArr = Db::name('layout_list')->where(['village_id'=>$village_id])->column('code');
$optionsString = implode(',',$optionsArr);//这个是选择布局 $optionsString = implode(',',$optionsArr);//这个是选择布局
foreach ($errorData as $k =>$v) { foreach ($errorData as $k =>$v) {
foreach ($title as $key=>$value) { foreach ($title as $key=>$value) {
...@@ -481,15 +479,9 @@ class Common extends BaseController ...@@ -481,15 +479,9 @@ class Common extends BaseController
header('Content-Disposition: attachment;filename="用户导入失败数据.xls"'); header('Content-Disposition: attachment;filename="用户导入失败数据.xls"');
header('Cache-Control: max-age=0'); header('Cache-Control: max-age=0');
$objWriter->save("php://output"); $objWriter->save("php://output");
} else { } else {
return ['code'=>200,'data'=>[]]; return ['code'=>200,'data'=>[]];
} }
} else {
return ['code'=>200,'data'=>[]];
}
} }
//车辆导入 //车辆导入
...@@ -514,6 +506,7 @@ class Common extends BaseController ...@@ -514,6 +506,7 @@ class Common extends BaseController
$license_plate = $dataAll[$i][2]; $license_plate = $dataAll[$i][2];
$car_color = $dataAll[$i][3]; $car_color = $dataAll[$i][3];
$brand = $dataAll[$i][4]; $brand = $dataAll[$i][4];
$car_type = $dataAll[$i][5];
$data['name'] = $name; $data['name'] = $name;
$data['phone'] = $phone; $data['phone'] = $phone;
$data['license_plate'] = $license_plate; $data['license_plate'] = $license_plate;
...@@ -521,6 +514,7 @@ class Common extends BaseController ...@@ -521,6 +514,7 @@ class Common extends BaseController
$data['create_time'] = time(); $data['create_time'] = time();
$data['village_id'] = $village_id; $data['village_id'] = $village_id;
$data['brand'] = $brand; $data['brand'] = $brand;
$data['car_type'] = $car_type;
if(empty($msg)){ if(empty($msg)){
$insertData[] = $data; $insertData[] = $data;
} else { } else {
...@@ -535,7 +529,7 @@ class Common extends BaseController ...@@ -535,7 +529,7 @@ class Common extends BaseController
//导出错误的数据 //导出错误的数据
$file = "./formwork/importCar.xls"; $file = "./formwork/importCar.xls";
$phpExcel = \PHPExcel_IOFactory::load($file); $phpExcel = \PHPExcel_IOFactory::load($file);
$title = ['A','B','C','D','E','F']; $title = ['A','B','C','D','E','F','G'];
$i = 2; $i = 2;
$optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name'); $optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name');
$optionsString = implode(',',$optionsArr);//这个是的车库 $optionsString = implode(',',$optionsArr);//这个是的车库
......
...@@ -33,8 +33,6 @@ class Base extends BaseController ...@@ -33,8 +33,6 @@ class Base extends BaseController
} }
......
...@@ -220,6 +220,7 @@ class Parking extends Base ...@@ -220,6 +220,7 @@ class Parking extends Base
$data['brand'] = Request::param('brand'); $data['brand'] = Request::param('brand');
$data['car_color'] = Request::param('car_color'); $data['car_color'] = Request::param('car_color');
$data['brand'] = Request::param('brand'); $data['brand'] = Request::param('brand');
$data['car_type'] = Request::param('car_type');
$data['license_plate'] = Request::param('license_plate'); $data['license_plate'] = Request::param('license_plate');
$data['sort_id'] = Request::param('sort_id',1); $data['sort_id'] = Request::param('sort_id',1);
if($car_id) { if($car_id) {
......
...@@ -233,7 +233,6 @@ class Userbind extends Base ...@@ -233,7 +233,6 @@ class Userbind extends Base
//用户批量导入数据 //用户批量导入数据
public function importTenant() { public function importTenant() {
$filePath = Request::param('filePath'); $filePath = Request::param('filePath');
if(!file_exists($filePath)){ if(!file_exists($filePath)){
return $this->returnJson([],'文件不存在!',400); return $this->returnJson([],'文件不存在!',400);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment