DataCheck.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. class DataCheck extends AdminController{
  6. public function index(){
  7. return view("", []);
  8. }
  9. /**
  10. * 数据核验列表
  11. * @return array
  12. * @throws \think\db\exception\DataNotFoundException
  13. * @throws \think\db\exception\DbException
  14. * @throws \think\db\exception\ModelNotFoundException
  15. */
  16. public function list(){
  17. $list = Db::table("new_data_check")->order('createTime','desc')->select();
  18. return ["total" => count($list), "rows" => $list];
  19. }
  20. public function import_wuxian(){
  21. $response_obj = new \StdClass();
  22. if (!$this->request->file()){
  23. $response_obj->code = 500;
  24. $response_obj->msg = '没有选择文件';
  25. return \StrUtil::back($response_obj, "DataCheck.callBack");
  26. }
  27. $excel = $this->request->file("file");
  28. $year = $this->request->post('year');
  29. $savename = \think\facade\Filesystem::disk("public")->putFile("uploadexcel", $excel);
  30. $check_data = [
  31. 'task_name' => date("Y-m-d",time()) . "-导入五险({$year}年度)查询数据",
  32. 'task_file' => $savename,
  33. 'task_status' => -1,
  34. 'createTime' => date("Y-m-d H:i:s",time()),
  35. 'updateTime' => date("Y-m-d H:i:s",time())
  36. ];
  37. $id = Db::table("new_data_check")->insertGetId($check_data);
  38. queue("app\job\Import", ["id" => $id,"type" => 1, 'year' => $year]);
  39. $response_obj = new \StdClass();
  40. $response_obj->code = 200;
  41. $response_obj->msg = '导入成功';
  42. return \StrUtil::back($response_obj, "DataCheck.callBack");
  43. }
  44. }