|
@@ -33,7 +33,7 @@ class Import {
|
|
|
* @return bool
|
|
|
*/
|
|
|
public function deal($data): bool {
|
|
|
- if ($data['type'] == 1) {
|
|
|
+ if ($data['type'] == 1) {//企业导入
|
|
|
$id = $data['id'];
|
|
|
$res = Db::table("new_talent_zhiren")->where('id', $id)->findOrEmpty();
|
|
|
if ($res) {
|
|
@@ -155,7 +155,7 @@ class Import {
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
- } else {
|
|
|
+ } elseif ($data['type'] == 2) {//省级人才导入
|
|
|
$id = $data['id'];
|
|
|
$res = Db::table("new_talent_zhiren")->where('id', $id)->findOrEmpty();
|
|
|
if ($res) {
|
|
@@ -198,14 +198,14 @@ class Import {
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case 2:
|
|
|
+ case 5:
|
|
|
if (empty($row[$i])) {
|
|
|
array_push($msg, "人才姓名不能为空");
|
|
|
} else {
|
|
|
$item['name'] = $row[$i];
|
|
|
}
|
|
|
break;
|
|
|
- case 3:
|
|
|
+ case 6:
|
|
|
if (in_array($row[$i], ['身份证', '通行证', '护照'])) {
|
|
|
$key = array_search($row[$i], ['身份证', '通行证', '护照']);
|
|
|
$item['card_type'] = $key + 1;
|
|
@@ -214,7 +214,7 @@ class Import {
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
- case 4:
|
|
|
+ case 7:
|
|
|
if (empty($row[$i])) {
|
|
|
array_push($msg, "证件号码不能为空");
|
|
|
} else {
|
|
@@ -228,10 +228,135 @@ class Import {
|
|
|
$item['card_number'] = $row[$i];
|
|
|
}
|
|
|
break;
|
|
|
- case 5:
|
|
|
+ case 8:
|
|
|
$item['nationality'] = array_key_exists($row[$i], $country) ? $country[$row[$i]] : 'other';
|
|
|
break;
|
|
|
+ case 19:
|
|
|
+ $item['talent_condition_text'] = $row[$i];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $item["checkState"] = \app\common\api\TalentState::REVERIFY_PASS; //复审通过
|
|
|
+ $item["highProcess"] = 5; //最高进度
|
|
|
+ $item["isImport"] = 1;//导入人才的标志
|
|
|
+ if (count($msg) >= 1) {
|
|
|
+ $sheet->setCellValue('AL' . ($index + 2), '导入失败,失败原因:' . implode(";", $msg));
|
|
|
+ } else {
|
|
|
+ if ($action == 'update') {
|
|
|
+ $item['updateTime'] = date("Y-m-d H:i:s", time());
|
|
|
+ Db::table("new_talent_info")->where('id', $talent_info['id'])->update($item);
|
|
|
+ $sheet->setCellValue('AL' . ($index + 2), '更新成功');
|
|
|
+ } else {
|
|
|
+ $item['createTime'] = date("Y-m-d H:i:s", time());
|
|
|
+ Db::table("new_talent_info")->insert($item);
|
|
|
+ $sheet->setCellValue('AL' . ($index + 2), '导入成功');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
|
|
+ $writer->save($path . "/public/storage/" . $res['task_file']);
|
|
|
+ Db::table("new_talent_zhiren")->where('id', $id)->update(['task_result' => $res['task_file'], 'task_status' => 1, 'updateTime' => date("Y-m-d H:i:s", time())]);
|
|
|
+ return true;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::table("new_talent_zhiren")->where('id', $id)->update(['task_result' => $e->getMessage(), 'task_status' => 0, 'updateTime' => date("Y-m-d H:i:s", time())]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } elseif ($data['type'] == 3){//泉州人才导入
|
|
|
+ $id = $data['id'];
|
|
|
+ $res = Db::table("new_talent_zhiren")->where('id', $id)->findOrEmpty();
|
|
|
+ if ($res) {
|
|
|
+ if ($res['task_status'] != -1) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ $path = dirname(dirname(dirname(__FILE__)));
|
|
|
+ $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($path ."/public/storage/" . $res['task_file']);
|
|
|
+ $sheet = $spreadsheet->getSheet(0);
|
|
|
+ $datas = $sheet->toArray();
|
|
|
+ $datas = array_slice($datas, 1); //去标题
|
|
|
+ $country = Db::table("sys_dict")->where("pid", 35)->column("code", "name");
|
|
|
+
|
|
|
+ for ($index = 0; $index < count($datas); $index++) {
|
|
|
+ $row = $datas[$index];
|
|
|
+ $msg = [];
|
|
|
+ $item = [];
|
|
|
+ $enterprise_name = '';
|
|
|
+ $enterprise_id = '';
|
|
|
+ $action = 'insert';
|
|
|
+ for ($i = 0; $i < 28; $i++) {
|
|
|
+ switch ($i) {
|
|
|
+ case 0:
|
|
|
+ if (empty($row[$i])) {
|
|
|
+ array_push($msg, "机构名称不能为空");
|
|
|
+ } else {
|
|
|
+ $enterprise_name = $row[$i];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ $info = Db::table("un_enterprise")->where('idCard', $row[$i])->findOrEmpty();
|
|
|
+ if (!$info) {
|
|
|
+ array_push($msg, "机构代码不存在,请检查");
|
|
|
+ } else {
|
|
|
+ if ($info['name'] != $enterprise_name) {
|
|
|
+ array_push($msg, "机构代码与企业名称无法对应,请检查");
|
|
|
+ } else {
|
|
|
+ $item['enterprise_id'] = $enterprise_id = $info['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (empty($row[$i])) {
|
|
|
+ array_push($msg, "人才姓名不能为空");
|
|
|
+ } else {
|
|
|
+ $item['name'] = $row[$i];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ if($row[$i] == '女'){
|
|
|
+ $item['sex'] = 2;
|
|
|
+ }else{
|
|
|
+ $item['sex'] = 1;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ $item['nationality'] = array_key_exists($row[$i], $country) ? $country[$row[$i]] : 'other';
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ if (in_array($row[$i], ['身份证', '通行证', '护照'])) {
|
|
|
+ $key = array_search($row[$i], ['身份证', '通行证', '护照']);
|
|
|
+ $item['card_type'] = $key + 1;
|
|
|
+ } else {
|
|
|
+ array_push($msg, "人才的证件类型不正确");
|
|
|
+ }
|
|
|
+ break;
|
|
|
case 6:
|
|
|
+ if (empty($row[$i])) {
|
|
|
+ array_push($msg, "证件号码不能为空");
|
|
|
+ } else {
|
|
|
+ if (!isCreditNo($row[$i]) && $item['card_type'] == 1) {
|
|
|
+ array_push($msg, "证件号码不正确");
|
|
|
+ }
|
|
|
+ $talent_info = Db::table("new_talent_info")->where("card_number", $row[$i])->where('enterprise_id', $enterprise_id)->findOrEmpty();
|
|
|
+ if ($talent_info) {
|
|
|
+ $action = 'update';
|
|
|
+ }
|
|
|
+ $item['card_number'] = $row[$i];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ $item['birthday'] = $row[$i];
|
|
|
+ break;
|
|
|
+ case 16:
|
|
|
+ $item['phone'] = $row[$i];
|
|
|
+ break;
|
|
|
+ case 17:
|
|
|
+ $item['email'] = $row[$i];
|
|
|
+ break;
|
|
|
+ case 18:
|
|
|
if (!in_array($row[$i], ['第一层次', '第二层次', '第三层次', '第四层次', '第五层次'])) {
|
|
|
array_push($msg, "人才层次不正确");
|
|
|
} else {
|
|
@@ -239,50 +364,25 @@ class Import {
|
|
|
$item['talent_arrange'] = $key + 1;
|
|
|
}
|
|
|
break;
|
|
|
- case 7:
|
|
|
- switch ($row[$i]) {
|
|
|
- case '福建省人才':
|
|
|
- $item['source'] = 1;
|
|
|
- break;
|
|
|
- case '泉州市人才':
|
|
|
- $item['source'] = 2;
|
|
|
- break;
|
|
|
- default:
|
|
|
- array_push($msg, "人才来源不正确");
|
|
|
- break;
|
|
|
- }
|
|
|
- break;
|
|
|
- case 8:
|
|
|
- switch ($item['source']) {
|
|
|
- case '1':
|
|
|
- $item['fujian_highcert_exptime'] = $row[$i];
|
|
|
- break;
|
|
|
- case '2':
|
|
|
- $item['quanzhou_highcert_exptime'] = $row[$i];
|
|
|
- break;
|
|
|
- default:
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
+ case 19:
|
|
|
+ $item['talent_condition_text'] = $row[$i];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
$item["checkState"] = \app\common\api\TalentState::REVERIFY_PASS; //复审通过
|
|
|
$item["highProcess"] = 5; //最高进度
|
|
|
- $item["isImport"] = 1;//导入人才的标志
|
|
|
- $item["importCheckState"] = 1;//导入人才的状态,待提交补充
|
|
|
- var_dump($item);
|
|
|
+ $item["isImport"] = 2;//导入人才的标志
|
|
|
if (count($msg) >= 1) {
|
|
|
- $sheet->setCellValue('J' . ($index + 2), '导入失败,失败原因:' . implode(";", $msg));
|
|
|
+ $sheet->setCellValue('AC' . ($index + 2), '导入失败,失败原因:' . implode(";", $msg));
|
|
|
} else {
|
|
|
if ($action == 'update') {
|
|
|
$item['updateTime'] = date("Y-m-d H:i:s", time());
|
|
|
Db::table("new_talent_info")->where('id', $talent_info['id'])->update($item);
|
|
|
- $sheet->setCellValue('J' . ($index + 2), '更新成功');
|
|
|
+ $sheet->setCellValue('AC' . ($index + 2), '更新成功');
|
|
|
} else {
|
|
|
$item['createTime'] = date("Y-m-d H:i:s", time());
|
|
|
Db::table("new_talent_info")->insert($item);
|
|
|
- $sheet->setCellValue('J' . ($index + 2), '导入成功');
|
|
|
+ $sheet->setCellValue('AC' . ($index + 2), '导入成功');
|
|
|
}
|
|
|
}
|
|
|
}
|