Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aic_duty_strategy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yinxiaoling
aic_duty_strategy
Commits
45321bf2
Commit
45321bf2
authored
May 18, 2020
by
yinxiaoling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
任务定时批量创建
parent
2ea72dd3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
6 deletions
+94
-6
CreatedTaskCommand.php
app/Console/Commands/CreatedTaskCommand.php
+10
-6
StrategyTaskController.php
app/Http/Controllers/strategy/StrategyTaskController.php
+3
-0
StrategyService.php
app/Service/StrategyService.php
+81
-0
No files found.
app/Console/Commands/CreatedTaskCommand.php
View file @
45321bf2
...
...
@@ -4,6 +4,7 @@ namespace App\Console\Commands;
use
Illuminate\Console\Command
;
use
App\Models\StrategyTask
;
use
App\Service\StrategyService
;
//use App\Http\Controllers\Tool;
class
CreatedTaskCommand
extends
Command
...
...
@@ -40,18 +41,21 @@ class CreatedTaskCommand extends Command
*/
public
function
handle
()
{
$StrategyService
=
new
StrategyService
();
$StrategyService
->
createdTask
();
//新建任务、失败原任务重呼3次,接口调用失败重试3次
//$userInfo = $this->getAllowLoginUser();
/
* /
/$userInfo = $this->getAllowLoginUser();
$userInfo = ['user_name'=>'yxl001','user_sn'=>'SYSUSER|9da548a2e392a679eb274a0b2abeb627','parent_sn'=>'ljs'];
$taskInfo
=
StrategyTask
::
where
(
'is_created'
,
0
)
->
get
()
->
toArray
();
//获取
需要新建任务的数据
$today = date('Y-m-d');
$taskInfo = StrategyTask::where(
[['is_created',0],['call_date',$today],['created_fail_number','<=','3']])->get()->toArray(); //获取当天
需要新建任务的数据
$url = "https://test117.ciopaas.com/api/addJsonNoLogin";
//dd($taskInfo);
foreach ($taskInfo as $k=>$v){//批量调用接口新建任务
$failLabTemp = 0;
$failReason = '';
//处理参数
dump
(
$v
[
'project_sn'
]);
if (empty($v['project_sn'])){
break;
}
...
...
@@ -91,7 +95,7 @@ class CreatedTaskCommand extends Command
$params['url'] = substr(md5(json_encode($params)),1,8);
$requestReturn = $this->requestPost($url,$params);
dd
(
$requestReturn
);
$requestReturnArr = json_decode($requestReturn,true);
if (isset($requestReturnArr['code'])){
if ($requestReturnArr['code'] == 0){//接口请求返回成功
...
...
@@ -114,7 +118,7 @@ class CreatedTaskCommand extends Command
StrategyTask::where('id',$v['id'])->update(['created_fail_number'=>($v['created_fail_number'] + 1),'create_fail_reason'=>$failReason]); //设为已创建
}
}
*/
}
...
...
app/Http/Controllers/strategy/StrategyTaskController.php
View file @
45321bf2
...
...
@@ -79,6 +79,9 @@ class StrategyTaskController extends Controller
}
$taskInfo
=
StrategyTask
::
find
(
$id
);
if
(
empty
(
$taskInfo
)){
return
$this
->
errorWithInfo
(
'任务数据不存在'
,
401
);
}
if
(
$taskInfo
->
is_created
==
1
){
return
$this
->
errorWithInfo
(
'任务已经创建不能编辑'
,
401
);
}
...
...
app/Service/StrategyService.php
View file @
45321bf2
...
...
@@ -7,9 +7,11 @@ use App\Models\StrategyExcel;
use
App\Models\StrategySet
;
use
App\Models\StrategyTask
;
use
App\Jobs\StrategyTaskJob
;
use
App\Http\Controllers\Tool
;
class
StrategyService
{
use
Tool
;
//验证上传的excel
public
function
validUploadExcel
(
$request
,
$inputName
,
$maxUploadSize
=
''
){
$path
=
storage_path
()
.
"/import/"
;
...
...
@@ -322,6 +324,85 @@ class StrategyService
}
//创建任务
public
function
createdTask
(
$strategySn
=
''
){
$userInfo
=
$this
->
getAllowLoginUser
();
$today
=
date
(
'Y-m-d'
);
$whereArr
=
[[
'is_created'
,
0
],[
'call_date'
,
$today
],[
'created_fail_number'
,
'<='
,
'3'
]];
if
(
empty
(
$strategySn
)){
array_push
(
$whereArr
,
[
'strategy_sn'
,
$strategySn
]);
}
$taskInfo
=
StrategyTask
::
where
()
->
get
(
$whereArr
)
->
toArray
();
//获取当天需要新建任务的数据
$url
=
"https://test117.ciopaas.com/api/addJsonNoLogin"
;
//dd($taskInfo);
foreach
(
$taskInfo
as
$k
=>
$v
){
//批量调用接口新建任务
$failLabTemp
=
0
;
$failReason
=
''
;
//处理参数
if
(
empty
(
$v
[
'project_sn'
])){
break
;
}
$client_info_json
=
[
[
'姓名'
=>
$v
[
'name'
],
'电话'
=>
$v
[
'phone'
],
'地址'
=>
''
,
'公司名称'
=>
''
,
'备注'
=>
''
,
'手机号码'
=>
$v
[
'phone'
],
'值班日期'
=>
$v
[
'duty_date'
]
]
];
$params
=
[
'user_sn'
=>
$v
[
'user_sn'
],
'project_sn'
=>
trim
(
$v
[
'project_sn'
]),
'source'
=>
date
(
'YmdHis'
)
.
$k
,
//任务名称,年月日时分秒,加上循环键值避免重复任务名
'ai_user_sn'
=>
$v
[
'user_sn'
],
//$v['user_sn'],
'is_zidong'
=>
'off'
,
//是否自动启动,否,任务定时启动
'is_open_remove_duplication'
=>
'0'
,
'is_auto_fail_recall'
=>
'1'
,
//是否自动重呼,是
'total_fail_recall_times'
=>
'3'
,
//重呼次数
'fail_recall_interval'
=>
'3'
,
//重呼间隔时间
'recall_auto'
=>
1
,
//重呼方式; 0新建任务1原任务重呼
'mark'
=>
'值班策略创建任务'
,
'fail_recall_of_reason'
=>
'关机,来电提醒,稍后再拨,停机,无法接通,正在通话中,用户正忙,用户拒接,欠费,无人应答,其他,对方示忙'
,
'is_auto_stop'
=>
2
,
//0非自动暂停,1自动暂停 2 定时启动任务
'timed_started_at'
=>
$v
[
'call_date'
]
.
' '
.
$v
[
'call_time'
],
//定时启动
'yd_display_phone'
=>
$v
[
'user_sn'
]
.
'@vos:'
.
$v
[
'call_number'
]
//主叫号码传输格式
//'ai_distribution_type'=>'0'//0公用ai 1按主账号分配ai(6.2人工外呼分配方式 0平均,1抢拨)
];
$params
[
'client_info_json'
]
=
json_encode
([
'data'
=>
$client_info_json
]);
$params
[
'url'
]
=
substr
(
md5
(
json_encode
(
$params
)),
1
,
8
);
$requestReturn
=
$this
->
requestPost
(
$url
,
$params
);
$requestReturnArr
=
json_decode
(
$requestReturn
,
true
);
if
(
isset
(
$requestReturnArr
[
'code'
])){
if
(
$requestReturnArr
[
'code'
]
==
0
){
//接口请求返回成功
if
(
$requestReturnArr
[
'data'
][
'total'
]
==
$requestReturnArr
[
'data'
][
'success'
]){
//全部成功
StrategyTask
::
where
(
'id'
,
$v
[
'id'
])
->
update
([
'is_created'
=>
1
]);
//设为已创建
}
else
{
//存在失败数据
$failLabTemp
=
1
;
$failReason
=
substr
(
$requestReturnArr
[
'msg'
],
0
,
490
);
}
}
else
{
//接口请求返回异常
$failLabTemp
=
1
;
$failReason
=
substr
(
$requestReturnArr
[
'msg'
],
0
,
490
);
}
}
else
{
$failLabTemp
=
1
;
$failReason
=
substr
(
$requestReturn
,
0
,
490
);
}
if
(
$failLabTemp
==
1
){
StrategyTask
::
where
(
'id'
,
$v
[
'id'
])
->
update
([
'created_fail_number'
=>
(
$v
[
'created_fail_number'
]
+
1
),
'create_fail_reason'
=>
$failReason
]);
//设为已创建
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment