1
0

ExcelExport.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\command;
  3. use app\common\model\bank_account\BankAccount;
  4. use app\common\model\export\Export;
  5. use app\common\model\master_worker\MasterWorker;
  6. use app\common\model\master_worker\MasterWorkerInfo;
  7. use app\common\service\ExcelExportService;
  8. use think\console\Command;
  9. use think\console\Input;
  10. use think\console\Output;
  11. use think\facade\Log;
  12. /**
  13. * 表格导出
  14. * Class OpenObtainOrder
  15. * @package app\command
  16. */
  17. class ExcelExport extends Command
  18. {
  19. protected function configure()
  20. {
  21. $this->setName('excel_export')->setDescription('表格导出');
  22. }
  23. protected function execute(Input $input, Output $output)
  24. {
  25. set_time_limit(180);
  26. ini_set('memory_limit', '1024M');
  27. try {
  28. Export::where('generate_status',0)->where('createtime','<',(time()-86400*2))->delete();
  29. $result = Export::where('generate_status',0)->findOrEmpty();
  30. if(!$result->isEmpty()){
  31. (new ExcelExportService)->download($result->id,true);
  32. }
  33. return true;
  34. } catch (\Exception $e) {
  35. Log::write('ExcelExport:'.$e->getMessage());
  36. return $e->getMessage();
  37. }
  38. }
  39. }