Index.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\web\controller;
  3. use think\facade\Session;
  4. use app\web\BaseController;
  5. class Index extends BaseController
  6. {
  7. public function index()
  8. {
  9. return redirect('/web.php/home/home');
  10. }
  11. public function t1()
  12. {
  13. halt(1);
  14. set_time_limit(0);
  15. ini_set("memory_limit","10000M");
  16. $dir = scandir(public_path().'public/其他');
  17. $res = [];
  18. $data= [];
  19. for ($i = 0,$i<=50;$i++;) {
  20. $data[] = $i;
  21. }
  22. foreach ($dir as $key => $file) {
  23. if ($file == '.' || $file == '..') {
  24. continue;
  25. }
  26. $list = importExecl('其他/'.$file, $data, 0);
  27. $name_key = array_search('姓名',$list[2]);
  28. $idcard_key = array_search('身份证号码',$list[2]) !== false ? array_search('身份证号码',$list[2]) : array_search('证件号码',$list[2]);
  29. $wuxian_key = 0;
  30. $yingfa_key = 0;
  31. foreach ($list[2] as $k => $v) {
  32. if (mb_strpos($v,'个人') !== false) {
  33. $wuxian_key = $k;
  34. }
  35. if (mb_strpos($v,'应发') !== false) {
  36. $yingfa_key = $k;
  37. }
  38. }
  39. $yanglan_key = 0;
  40. $shiye_key = 0;
  41. $yiliao_key = 0;
  42. $gongjijin_key = 0;
  43. foreach ($list[3] as $k => $v) {
  44. if ($k >= $wuxian_key) {
  45. if (mb_strpos($v,'养老') !== false) {
  46. $yanglan_key = $k;
  47. } elseif (mb_strpos($v,'失业') !== false) {
  48. $shiye_key = $k;
  49. } elseif (mb_strpos($v,'医疗') !== false) {
  50. $yiliao_key = $k;
  51. } elseif (mb_strpos($v,'公积金') !== false) {
  52. $gongjijin_key = $k;
  53. }
  54. }
  55. }
  56. $list = array_slice($list,4);
  57. foreach ($list as $v) {
  58. if (!is_numeric($v[0])) {
  59. break;
  60. }
  61. $res[] = [
  62. 'title' => $file,
  63. 'name' => $name_key ? $v[$name_key] : "",
  64. 'idcard' => $idcard_key ? $v[$idcard_key] : "",
  65. 'yingfa' => $yingfa_key ? $v[$yingfa_key] : 0,
  66. 'yanglan' => $yanglan_key ? $v[$yanglan_key] : 0,
  67. 'shiye' => $shiye_key ? $v[$shiye_key] : 0,
  68. 'yiliao' => $yiliao_key ? $v[$yiliao_key] : 0,
  69. 'gongjijin' => $gongjijin_key ? $v[$gongjijin_key] : 0,
  70. ];
  71. }
  72. }
  73. $xlsCell = [['title','表名'],['name','姓名'],['idcard','身份证'],['yingfa','应发'],['yanglan','养老'],['shiye','失业'],['yiliao','医疗'],['gongjijin','公积金']];
  74. export_excel('结果',$xlsCell,$res);
  75. }
  76. }