DirectlyIdentify.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. class DirectlyIdentify extends AdminController{
  6. public function index(){
  7. return view("", []);
  8. }
  9. public function list(){
  10. }
  11. public function enterprise_import(){
  12. if (!$this->request->file())
  13. return json(["msg" => "没有选择文件"]);
  14. $excel = $this->request->file("file");
  15. if (!isExcelFile($excel->getMime()))
  16. return json(["msg" => "不是正确的Excel文件"]);
  17. $mapping = [
  18. 0 => "type",
  19. 1 => "talentLevel",
  20. 2 => "name",
  21. 3 => "activeYear",
  22. 4 => "description"
  23. ];
  24. $path = $excel->getRealPath();
  25. $zhiren_data = [
  26. 'task_name' => date("Y-m-d",time()) , "-导入机构数据",
  27. 'task_file' => $path,
  28. 'task_status' => -1,
  29. 'createTime' => date("Y-m-d H:i:s",time()),
  30. 'updateTime' => date("Y-m-d H:i:s",time())
  31. ];
  32. $id = Db::table("new_talent_zhiren")->insert($zhiren_data);
  33. queue("app\job\Import", ["id" => $id]);
  34. $data = ["code" => 200, "msg" => "导入成功"];
  35. echo sprintf('<script>parent.DirectlyIdentify.callBack(%s);</script>', json_encode($data));
  36. }
  37. }