public function importEmployeeAction($network_domain)
 {
     $request = $this->get("request");
     $user = $this->get('security.context')->getToken()->getUser();
     //判断当前导入人员是否是企业邮箱
     $userDomain = explode("@", $user->getUserName());
     $da = $this->get("we_data_access");
     $sql = "select 1 from we_public_domain where domain_name=?";
     $ds = $da->GetData("mt", $sql, array((string) $userDomain[1]));
     $mailType = count($ds["mt"]["rows"]) > 0 ? "0" : "1";
     //1表示是企业邮箱
     try {
         $upfile = $request->files->get("filedata");
         $tmpPath = $upfile->getPathname();
         $oldName = $upfile->getClientOriginalName();
         $fixs = explode(".", strtolower($oldName));
         if (count($fixs) < 2) {
             $re = array('s' => 0, 'message' => "文件类型不正确");
         } else {
             $fixedType = $fixs[count($fixs) - 1];
             if ($fixedType != "xlsx" && $fixedType != "xls") {
                 $re = array('s' => 0, 'message' => "文件类型不正确");
             } else {
                 $newFileName = $user->openid . date('y-m-d-H-m-s') . "." . $fixedType;
                 if (move_uploaded_file($tmpPath, 'upload/' . $newFileName)) {
                     $da = $this->container->get('we_data_access');
                     $objReader = \PHPExcel_IOFactory::createReader($fixedType == "xlsx" ? 'Excel2007' : "Excel5");
                     //use excel2007 for 2007 format
                     $objPHPExcel = $objReader->load($_SERVER['DOCUMENT_ROOT'] . '/upload/' . $newFileName);
                     $objWorksheet = $objPHPExcel->getActiveSheet();
                     $highestRow = $objWorksheet->getHighestRow();
                     $highestColumn = $objWorksheet->getHighestColumn();
                     $highestColumnIndex = \PHPExcel_Cell::columnIndexFromString($highestColumn);
                     //总列数
                     //获取标题行
                     $titleAry = array();
                     $account_index = 0;
                     $name_index = 0;
                     $mobile_index = 0;
                     $pwd_index = 0;
                     for ($row = 0; $row <= 1; $row++) {
                         for ($col = 0; $col < $highestColumnIndex; $col++) {
                             $titleAry[$col] = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
                             if (strpos($titleAry[$col], "邮箱") !== false) {
                                 $account_index = $col;
                             } else {
                                 if (strpos($titleAry[$col], "姓名") !== false) {
                                     $name_index = $col;
                                 } else {
                                     if (strpos($titleAry[$col], "手机") !== false) {
                                         $mobile_index = $col;
                                     } else {
                                         if (strpos($titleAry[$col], "密码") !== false) {
                                             $pwd_index = $col;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $titleAry[] = "eno";
                     $err_list = array();
                     $da = $this->get("we_data_access");
                     $dm = $this->get("we_data_access_im");
                     //获取数据行
                     for ($row = 2; $row <= $highestRow; $row++) {
                         $strs = array();
                         for ($col = 0; $col < $highestColumnIndex; $col++) {
                             $strs[$col] = trim((string) $objWorksheet->getCellByColumnAndRow($col, $row)->getValue());
                         }
                         $strs[] = $user->eno;
                         $name = $strs[$name_index];
                         if (empty($name)) {
                             $err_list[] = array("name" => "", "row" => $row, "msg" => "姓名不能为空");
                             continue;
                         }
                         if (strlen($name) == 1) {
                             $err_list[] = array("name" => "", "row" => $row, "msg" => "姓名不能少于2个字符");
                             continue;
                         }
                         //获取填写的帐号
                         $account = $strs[$account_index];
                         if (empty($account)) {
                             $err_list[] = array("name" => $name, "row" => $row, "msg" => "邮箱帐号不能为空");
                             continue;
                         }
                         if (!Utils::validateEmail($account)) {
                             $err_list[] = array("name" => $name, "row" => $row, "msg" => "邮箱帐号格式不正确");
                             continue;
                         }
                         $staffmgr = new Staff($da, $dm, $account);
                         if ($staffmgr->checkNickname($user->eno, $name) === true) {
                             $err_list[] = array("name" => "", "row" => $row, "msg" => "[" . $name . "]已经注册,请检查!");
                             continue;
                         }
                         //if($mailType=="1" && explode("@",$account)[1]!=$userDomain[1] )
                         //{
                         //	 $err_list[]=array("name"=>$name,"row"=>($row),"msg"=>"不允许导入公共邮箱$account");
                         //   continue;
                         //}
                         $mobile = $strs[$mobile_index];
                         if (!empty($mobile)) {
                             if (!Utils::validateMobile($mobile)) {
                                 $err_list[] = array("name" => $name, "row" => $row, "msg" => "手机号码格式不正确");
                                 continue;
                             }
                         }
                         //判断帐号是否已经注册
                         $isexist = $staffmgr->isExist($mobile);
                         if (!empty($isexist)) {
                             //已注册
                             $err_list[] = array("name" => $name, "msg" => "邮箱或手机号已被使用");
                             continue;
                         }
                         //判断是否已导入,已导入,则不再发邮件
                         $isImport = false;
                         try {
                             $isImport = $staffmgr->getImportInfo();
                         } catch (\Exception $err) {
                         }
                         try {
                             $staffmgr->importReg($titleAry, $strs);
                             //判断是否设置了密码
                             $pwd = $strs[$pwd_index];
                             if (!empty($pwd)) {
                                 $sql = "select ename from we_enterprise where eno=?";
                                 $ds = $da->GetData("t", $sql, array((string) $user->eno));
                                 //自动激活
                                 $active = new \Justsy\BaseBundle\Controller\ActiveController();
                                 $active->setContainer($this->container);
                                 $active->doSave(array('account' => $account, 'realName' => $name, 'passWord' => $pwd, 'eno' => $user->eno, 'ename' => $ds["t"]["rows"][0]["ename"], 'isNew' => '0', 'mailtype' => "1", 'isSendMessage' => "N", 'import' => '1'));
                                 $staffmgr = new Staff($da, $dm, $account);
                                 $importData = $staffmgr->getImportInfo();
                                 $staffmgr->updateByImport($importData);
                                 $staffmgr->deleteImportPhy();
                             } else {
                                 if ($isImport === false) {
                                     //发送邮件
                                     $activeurl = $this->generateUrl("JustsyBaseBundle_empimport_setpass", array('account' => DES::encrypt($account)), true);
                                     $txt = $this->renderView('JustsyBaseBundle:Register:mail.html.twig', array('realName' => $user->nick_name, 'account' => $account, 'activeurl' => $activeurl));
                                     Utils::saveMail($da, $this->container->getParameter('mailer_user'), $account, "欢迎加入Wefafa企业协作网络", $txt);
                                 }
                             }
                         } catch (\Exception $err) {
                             //写导入数据发生异常
                             $err_list[] = array("name" => $name, "msg" => "导入失败:" . $err->getMessage());
                             continue;
                         }
                     }
                     $re = array('s' => 1, 'error_list' => $err_list);
                 } else {
                     $re = array('s' => 0, 'message' => "文件上传失败");
                 }
                 try {
                     unlink($tmpPath);
                 } catch (\Exception $e) {
                 }
             }
         }
     } catch (\Exception $ex) {
         $re = array('s' => 0, 'message' => "导入失败");
     }
     $response = new Response("<script>parent.import_callback(" . json_encode($re) . ")</script>");
     $response->headers->set('Content-Type', 'text/html');
     return $response;
 }