mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-14 12:42:51 +00:00
feat: 添加功能 - 每天发出本项目未领取任务
This commit is contained in:
parent
38befc94ca
commit
a52e9e152d
@ -75,6 +75,8 @@ class SystemController extends AbstractController
|
|||||||
'image_save_local',
|
'image_save_local',
|
||||||
'start_home',
|
'start_home',
|
||||||
'file_upload_limit',
|
'file_upload_limit',
|
||||||
|
'unclaimed_task_reminder',
|
||||||
|
'unclaimed_task_reminder_time',
|
||||||
])) {
|
])) {
|
||||||
unset($all[$key]);
|
unset($all[$key]);
|
||||||
}
|
}
|
||||||
@ -116,6 +118,8 @@ class SystemController extends AbstractController
|
|||||||
$setting['image_save_local'] = $setting['image_save_local'] ?: 'open';
|
$setting['image_save_local'] = $setting['image_save_local'] ?: 'open';
|
||||||
$setting['start_home'] = $setting['start_home'] ?: 'close';
|
$setting['start_home'] = $setting['start_home'] ?: 'close';
|
||||||
$setting['file_upload_limit'] = $setting['file_upload_limit'] ?: '';
|
$setting['file_upload_limit'] = $setting['file_upload_limit'] ?: '';
|
||||||
|
$setting['unclaimed_task_reminder'] = $setting['unclaimed_task_reminder'] ?: 'close';
|
||||||
|
$setting['unclaimed_task_reminder_time'] = $setting['unclaimed_task_reminder_time'] ?: '';
|
||||||
//
|
//
|
||||||
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
return Base::retSuccess('success', $setting ?: json_decode('{}'));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,25 +2,26 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\File;
|
|
||||||
use App\Module\Base;
|
|
||||||
use App\Module\Extranet;
|
|
||||||
use App\Module\RandomColor;
|
|
||||||
use App\Tasks\AppPushTask;
|
|
||||||
use App\Tasks\AutoArchivedTask;
|
|
||||||
use App\Tasks\CheckinRemindTask;
|
|
||||||
use App\Tasks\DeleteBotMsgTask;
|
|
||||||
use App\Tasks\DeleteTmpTask;
|
|
||||||
use App\Tasks\EmailNoticeTask;
|
|
||||||
use App\Tasks\JokeSoupTask;
|
|
||||||
use App\Tasks\LoopTask;
|
|
||||||
use Arr;
|
use Arr;
|
||||||
use Cache;
|
use Cache;
|
||||||
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
|
||||||
use LasseRafn\InitialAvatarGenerator\InitialAvatar;
|
|
||||||
use Redirect;
|
|
||||||
use Request;
|
use Request;
|
||||||
|
use Redirect;
|
||||||
use Response;
|
use Response;
|
||||||
|
use App\Models\File;
|
||||||
|
use App\Module\Base;
|
||||||
|
use App\Tasks\LoopTask;
|
||||||
|
use App\Module\Extranet;
|
||||||
|
use App\Tasks\AppPushTask;
|
||||||
|
use App\Module\RandomColor;
|
||||||
|
use App\Tasks\JokeSoupTask;
|
||||||
|
use App\Tasks\DeleteTmpTask;
|
||||||
|
use App\Tasks\EmailNoticeTask;
|
||||||
|
use App\Tasks\AutoArchivedTask;
|
||||||
|
use App\Tasks\DeleteBotMsgTask;
|
||||||
|
use App\Tasks\CheckinRemindTask;
|
||||||
|
use Hhxsv5\LaravelS\Swoole\Task\Task;
|
||||||
|
use App\Tasks\UnclaimedTaskRemindTask;
|
||||||
|
use LasseRafn\InitialAvatarGenerator\InitialAvatar;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,6 +204,8 @@ class IndexController extends InvokeController
|
|||||||
Task::deliver(new CheckinRemindTask());
|
Task::deliver(new CheckinRemindTask());
|
||||||
// 获取笑话/心灵鸡汤
|
// 获取笑话/心灵鸡汤
|
||||||
Task::deliver(new JokeSoupTask());
|
Task::deliver(new JokeSoupTask());
|
||||||
|
// 未领取任务通知
|
||||||
|
Task::deliver(new UnclaimedTaskRemindTask());
|
||||||
|
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|||||||
82
app/Tasks/UnclaimedTaskRemindTask.php
Normal file
82
app/Tasks/UnclaimedTaskRemindTask.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Tasks;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Module\Base;
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\ProjectTask;
|
||||||
|
use App\Models\ProjectUser;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Models\WebSocketDialogMsg;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
|
@error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
||||||
|
|
||||||
|
class UnclaimedTaskRemindTask extends AbstractTask
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function start()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
$setting = Base::setting('system');
|
||||||
|
if ($setting['unclaimed_task_reminder'] !== 'open') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!$setting['unclaimed_task_reminder_time']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
$times = explode(':',date('H:i'));
|
||||||
|
$reminderTimes = explode(':',$setting['unclaimed_task_reminder_time']);
|
||||||
|
if( !isset($times[1]) || !isset($reminderTimes[1]) || $times[0] != $reminderTimes[0]){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 执行一次
|
||||||
|
if (Cache::get("UnclaimedTaskRemindTask:His",0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( $times[1] >= $reminderTimes[1] - 1 && $times[1] <= $reminderTimes[1] + 1){
|
||||||
|
//
|
||||||
|
Cache::put("UnclaimedTaskRemindTask:His", date('H:i:s'), Carbon::now()->addMinutes(5));
|
||||||
|
//
|
||||||
|
Project::whereNull('deleted_at')->whereNull('archived_at')->chunk(100,function($projects) {
|
||||||
|
foreach ($projects as $project) {
|
||||||
|
//
|
||||||
|
$count = ProjectTask::query()
|
||||||
|
->leftJoin('project_task_users', function ($query) {
|
||||||
|
$query->on('project_tasks.id', '=', 'project_task_users.task_id');
|
||||||
|
})
|
||||||
|
->where('project_tasks.project_id',$project->id)
|
||||||
|
->whereNull('project_tasks.deleted_at')
|
||||||
|
->whereNull('project_tasks.archived_at')
|
||||||
|
->whereNull('project_task_users.id')
|
||||||
|
->count();
|
||||||
|
if($count > 0){
|
||||||
|
$botUser = User::botGetOrCreate('task-alert');
|
||||||
|
if (empty($botUser)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!ProjectUser::whereUserid($botUser->userid)->whereProjectId($project->id)->exists()) {
|
||||||
|
$project->joinProject($botUser->userid);
|
||||||
|
$project->syncDialogUser();
|
||||||
|
}
|
||||||
|
WebSocketDialogMsg::sendMsg(null, $project->dialog_id , 'text', [
|
||||||
|
'text' => "当前存在{$count}个未领取任务"
|
||||||
|
], $botUser->userid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function end()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1393,3 +1393,5 @@ APP推送
|
|||||||
使用独立的发送按钮
|
使用独立的发送按钮
|
||||||
开启后,键盘上的发送按钮会被替换成换行
|
开启后,键盘上的发送按钮会被替换成换行
|
||||||
仅我的
|
仅我的
|
||||||
|
未领任务提醒
|
||||||
|
开启后每天按设定的提醒时间在项目群聊中发送未领取任务通知。
|
||||||
@ -100,6 +100,18 @@
|
|||||||
transfer/>
|
transfer/>
|
||||||
<div class="form-tip">{{$L('添加任务计划时间默认时分。')}}</div>
|
<div class="form-tip">{{$L('添加任务计划时间默认时分。')}}</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
<FormItem :label="$L('未领任务提醒')" prop="autoArchived">
|
||||||
|
<RadioGroup :value="formDatum.unclaimed_task_reminder" @on-change="formTaskReminder">
|
||||||
|
<Radio label="open">{{$L('开启')}}</Radio>
|
||||||
|
<Radio label="close">{{$L('关闭')}}</Radio>
|
||||||
|
</RadioGroup>
|
||||||
|
<div class="form-tip">{{$L('开启后每天按设定的提醒时间在项目群聊中发送未领取任务通知。')}}</div>
|
||||||
|
<TimePicker v-if="formDatum.unclaimed_task_reminder=='open'"
|
||||||
|
v-model="formDatum.unclaimed_task_reminder_time"
|
||||||
|
format="HH:mm"
|
||||||
|
:placeholder="$L('请选择提醒时间')"
|
||||||
|
transfer/>
|
||||||
|
</FormItem>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="block-setting-box">
|
<div class="block-setting-box">
|
||||||
@ -223,6 +235,10 @@ export default {
|
|||||||
this.formDatum = { ...this.formDatum, auto_archived: value };
|
this.formDatum = { ...this.formDatum, auto_archived: value };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
formTaskReminder(value) {
|
||||||
|
this.formDatum = { ...this.formDatum, unclaimed_task_reminder: value };
|
||||||
|
},
|
||||||
|
|
||||||
systemSetting(save) {
|
systemSetting(save) {
|
||||||
this.loadIng++;
|
this.loadIng++;
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
|
|||||||
1
resources/assets/sass/pages/common.scss
vendored
1
resources/assets/sass/pages/common.scss
vendored
@ -17,6 +17,7 @@ body {
|
|||||||
color: $primary-desc-color;
|
color: $primary-desc-color;
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
|
word-break:break-all;
|
||||||
&.red {
|
&.red {
|
||||||
color: #ED4014;
|
color: #ED4014;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -429,6 +429,11 @@ body.window-portrait {
|
|||||||
line-height: 38px;
|
line-height: 38px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.submit {
|
||||||
|
.ivu-tabs{
|
||||||
|
padding: 0 16px 16px 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user