1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- use app\admin\model\MobileUpload;
- use app\common\service\MobileImport;
- use PhpOffice\PhpSpreadsheet\IOFactory;
- use Workerman\Lib\Timer;
- use Workerman\Worker as WO;
- class MobileImportWork extends Com{
- public static function run(){
- $work=self::newWorker();
- $work->onWorkerStart=function (WO $worker){
- Timer::add(3,function ()use ($worker){
- self::import();
- });
- };
- }
- public static function import(){
- $upload= MobileUpload::where('status',0)->find();
- if(!$upload){
- return;
- }
- $upload['status']=1;
- $upload->save();
- try {
- MobileImport::import($upload['file'],$upload['admin_id'],$upload['params']['type'],$upload['params']['status'],$upload);
- }catch (\Exception $e){
- $upload['remark']=$e->getMessage();
- $upload['status']=2;
- $upload->save();
- self::logError($e);
- }
- }
- }
- //MobileImportWork::run();
|