This commit is contained in:
xman 2025-06-06 15:49:46 +08:00
parent 6045d93716
commit 696919950d
7 changed files with 170 additions and 101 deletions

View File

@ -25,7 +25,7 @@ class NoticeLogic
public function callIt($log)
{
try {
$dispatch = OrderDispatch::get($log->dispatch_id);
//1=派单2=提前通知3=超时通知
$ttsCode = null;
@ -69,12 +69,10 @@ class NoticeLogic
$log->save();
}
}else{
throw new Exception('语音通知服务未开启');
}
}catch (Exception $exception){
$log->status = -1;
$log->content = $exception->getMessage();
$log->content = 'TTSID为空';
$log->save();
//throw new Exception('语音通知服务未开启');
}
}

View File

@ -11,13 +11,16 @@ use app\common\Logic\NoticeLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Exception;
class CheckOrdeRecordCommand extends Command
{
protected $title = 'dispatch跟进记录通知,每天9点1分执行';
protected function configure()
{
$this->setName('check:dispatch-record-notice')
->setDescription('dispatch跟进记录通知,每天9点1分执行');
->setDescription($this->title);
}
protected function execute(Input $input, Output $output){
@ -29,6 +32,7 @@ class CheckOrdeRecordCommand extends Command
->chunk(100, function ($list) {
$ids = [];
$dispatchIds = [];
try {
foreach ($list as $item) {
$ids[] = $item->id;
$dispatchIds[] = $item->dispatch_id;
@ -53,8 +57,16 @@ class CheckOrdeRecordCommand extends Command
}
OrderDispatchRecord::whereIn('id',$ids)->where('status',0)->update(['status'=>1]);
$count = OrderDispatch::whereIn('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]);
echo 'count:'.$count.PHP_EOL;
}catch (Exception $exception){
Db::name('debug_log')->insert([
'title' => $this->title,
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
'create_time' => date('Y-m-d H:i:s', time())
]);
}
});
$output->info('OVER');

View File

@ -9,15 +9,17 @@ use app\common\Logic\OrderLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Exception;
use think\Hook;
class CheckOrderDispatchGotCommand extends Command
{
protected $title = '【自动派单未接单检测,五分钟未接单,重派派单】/【自动派单上门时间已到,未完成上门】,每分钟执行一次';
protected function configure()
{
$this->setName('check:dispatch-toget')
->setDescription('【自动派单未接单检测,五分钟未接单,重派派单】/【自动派单上门时间已到,未完成上门】,每分钟执行一次');
->setDescription($this->title);
}
protected function execute(Input $input, Output $output){
@ -72,6 +74,11 @@ class CheckOrderDispatchGotCommand extends Command
echo 'arrive_count:'. $count. PHP_EOL;
}catch (Exception $exception){
Db::name('debug_log')->insert([
'title' => $this->title,
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
'create_time' => date('Y-m-d H:i:s', time())
]);
echo $exception->getMessage(). PHP_EOL;
}
}

View File

@ -7,14 +7,16 @@ use app\admin\model\OrderDispatch;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Exception;
class CheckSmsPlantCommand extends Command
{
protected $title = 'dispatch预约任务短信提醒每5分钟执行一次';
protected function configure()
{
$this->setName('check:dispatch-sms-plant')
->setDescription('dispatch已预约任务短信提醒每5分钟执行一次');
->setDescription($this->title);
}
protected function execute(Input $input, Output $output){
@ -34,6 +36,12 @@ class CheckSmsPlantCommand extends Command
}catch (Exception $exception){
echo '短信发送失败:'.$exception->getMessage().PHP_EOL;
Db::name('debug_log')->insert([
'title' => $this->title,
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
'create_time' => date('Y-m-d H:i:s', time())
]);
}
echo '短信发送完成:'.$item->id.PHP_EOL;
}

View File

@ -11,13 +11,18 @@ use app\common\Logic\NoticeLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Exception;
class CheckTTSOverTimeCommand extends Command
{
protected $title = 'dispatch超时未完成任务语音通知每5分钟执行一次';
protected function configure()
{
$this->setName('check:dispatch-tts-overtime')
->setDescription('dispatch超时未完成任务语音通知每5分钟执行一次');
->setDescription($this->title);
}
protected function execute(Input $input, Output $output){
@ -31,6 +36,7 @@ class CheckTTSOverTimeCommand extends Command
->chunk(100, function ($list) {
$ids = [];
$logs = [];
try {
foreach ($list as $item) {
$ids[] = $item->id;
//修改状态
@ -49,6 +55,15 @@ class CheckTTSOverTimeCommand extends Command
$count = OrderDispatch::whereIn('id',$ids)->update(['follow'=>0,'tts_notice'=>3,'tts_check_time'=>date('Y-m-d H:i:s')]);
echo $count.PHP_EOL;
}
}catch (Exception $exception){
Db::name('debug_log')->insert([
'title' => $this->title,
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
'create_time' => date('Y-m-d H:i:s', time())
]);
}
});
$output->info('OVER');
}

View File

@ -11,13 +11,17 @@ use app\common\Logic\NoticeLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Exception;
class CheckTTSPlantCommand extends Command
{
protected $title = 'dispatch预约任务语音提醒每5分钟执行一次';
protected function configure()
{
$this->setName('check:dispatch-tts-plant')
->setDescription('dispatch已预约任务语音提醒每5分钟执行一次');
->setDescription($this->title);
}
protected function execute(Input $input, Output $output){
@ -33,6 +37,8 @@ class CheckTTSPlantCommand extends Command
$ids = [];
$logs = [];
foreach ($list as $item) {
try {
$ids[] = $item->id;
//修改状态
$logs[] = [
@ -45,6 +51,13 @@ class CheckTTSPlantCommand extends Command
'update_time' => date('Y-m-d H:i:s')
];
(new TtsLog())->insertAll($logs);
}catch (Exception $exception){
Db::name('debug_log')->insert([
'title' => $this->title,
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
'create_time' => date('Y-m-d H:i:s', time())
]);
}
}
if(!empty($ids)){
$count = OrderDispatch::whereIn('id',$ids)->update(['tts_notice'=>2,'tts_check_time'=>date('Y-m-d H:i:s')]);

View File

@ -11,13 +11,17 @@ use app\common\Logic\NoticeLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Exception;
class CheckTTSTaskCommand extends Command
{
protected $title = 'dispatch语音发送任务每1分钟执行一次';
protected function configure()
{
$this->setName('check:dispatch-tts-task')
->setDescription('语音发送任务每1分钟执行一次');
->setDescription($this->title);
}
protected function execute(Input $input, Output $output){
@ -26,7 +30,19 @@ class CheckTTSTaskCommand extends Command
$Model->where('status','=',0)
->chunk(100, function ($list)use($ttsService) {
foreach ($list as $item) {
try {
$ttsService->callIt($item);
}catch (Exception $exception){
$item->status = -1;
$item->content = $exception->getMessage();
$item->save();
Db::name('debug_log')->insert([
'title' => $this->title,
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
'create_time' => date('Y-m-d H:i:s', time())
]);
}
echo $item->id.PHP_EOL;
}
});