更新自动任务
This commit is contained in:
parent
3f7a8fb95f
commit
4880420620
@ -6,9 +6,11 @@
|
||||
*/
|
||||
declare (strict_types = 1);
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\project\model\ProjectTask as TaskList;
|
||||
use app\api\BaseController;
|
||||
use think\facade\Db;
|
||||
use app\project\validate\TaskCheck;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
class Index extends BaseController
|
||||
{
|
||||
@ -681,4 +683,82 @@ class Index extends BaseController
|
||||
$cate = get_work_cate();
|
||||
return to_assign(0, '', $cate);
|
||||
}
|
||||
|
||||
//添加
|
||||
public function task_add()
|
||||
{
|
||||
$param = get_params();
|
||||
if (request()->isPost()) {
|
||||
if (isset($param['end_time'])) {
|
||||
$param['end_time'] = strtotime(urldecode($param['end_time']));
|
||||
}
|
||||
if (!empty($param['id']) && $param['id'] > 0) {
|
||||
$task = (new TaskList())->detail($param['id']);
|
||||
try {
|
||||
validate(TaskCheck::class)->scene('edit')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
if (isset($param['flow_status'])) {
|
||||
if ($param['flow_status'] == 3) {
|
||||
$param['over_time'] = time();
|
||||
$param['done_ratio'] = 100;
|
||||
if($task['before_task']>0){
|
||||
$flow_status = Db::name('ProjectTask')->where(['id' => $task['before_task']])->value('flow_status');
|
||||
if($flow_status !=3){
|
||||
return to_assign(1, '前置任务未完成,不能设置已完成');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$param['over_time'] = 0;
|
||||
$param['done_ratio'] = 0;
|
||||
}
|
||||
}
|
||||
if(isset($param['before_task'])){
|
||||
$after_task_array = admin_after_task_son($param['id']);
|
||||
//包括自己在内
|
||||
$after_task_array[] = $param['id'];
|
||||
if (in_array($param['before_task'], $after_task_array)) {
|
||||
return to_assign(1, '前置任务不能是该任务本身或其后置任务');
|
||||
}
|
||||
}
|
||||
$param['update_time'] = time();
|
||||
$res = TaskList::where('id', $param['id'])->strict(false)->save($param);
|
||||
if ($res) {
|
||||
add_log('edit', $param['id'], $param);
|
||||
add_project_log(1,'task',$param, $task);
|
||||
}
|
||||
return to_assign();
|
||||
} else {
|
||||
try {
|
||||
validate(TaskCheck::class)->scene('add')->check($param);
|
||||
} catch (ValidateException $e) {
|
||||
// 验证失败 输出错误信息
|
||||
return to_assign(1, $e->getError());
|
||||
}
|
||||
$param['create_time'] = time();
|
||||
$param['admin_id'] = 1;
|
||||
$sid = TaskList::strict(false)->field(true)->insertGetId($param);
|
||||
if ($sid) {
|
||||
add_log('add', $sid, $param);
|
||||
$log_data = array(
|
||||
'module' => 'task',
|
||||
'task_id' => $sid,
|
||||
'new_content' => $param['title'],
|
||||
'field' => 'new',
|
||||
'action' => 'add',
|
||||
'admin_id' => 1,
|
||||
'create_time' => time(),
|
||||
);
|
||||
Db::name('ProjectLog')->strict(false)->field(true)->insert($log_data);
|
||||
//发消息
|
||||
//$users = $param['director_uid'];
|
||||
//sendMessage($users, 21, ['title' => $param['title'],'from_uid' => $this->uid, 'create_time'=>date('Y-m-d H:i:s',time()), 'action_id' => $sid]);
|
||||
}
|
||||
return to_assign();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user