Commit 464e7732 authored by yinxiaoling's avatar yinxiaoling

表新建添加备注

parent eefbd83d
......@@ -9,6 +9,18 @@ trait Tool
public function getAllowLoginUser(){
return ['user_name'=>'yxl001','user_sn'=>'SYSUSER|9da548a2e392a679eb274a0b2abeb627','parent_sn'=>'ljs'];
}
public function getAllowProjects($style=0){
$projectInfo = [['sn'=>'projects|a3a4259352c8e964ad6ea6c5ee8a7208','name'=>'liuy-转人工测试'],['sn'=>'projects|a3a4259352c8e964ad6ea6c5ee8a7208','name'=>'liuy-转人工测试']];
if ($style == 1){
$projectArr = [];
foreach ($projectInfo as $k=>$v){
$projectArr[$v['sn']] = $v['name'];
}
return $projectArr;
}else{
return $projectInfo;
}
}
public function success()
{
......
......@@ -18,7 +18,21 @@ class StrategySetController extends Controller
use Tool;
public function index(){
dd('策略列表');
$projectArr = $this->getAllowProjects(1);
$strategyInfo = StrategySet::all()->toArray();
$listInfo = [];
foreach ($strategyInfo as $k=>$v){
$projectSnTemp = explode("#", $v['project_sn']);
$v['project_name'] = isset($projectArr[$projectSnTemp[0]]) ? $projectArr[$projectSnTemp[0]] : '';
if (isset($projectSnTemp[1]) && isset($projectArr[$projectSnTemp[1]])){
$v['project_name'] .= $projectArr[$projectSnTemp[1]];
}
$v['disabled_name'] = $v['disabled'] == 0 ? '启用' : '停用';
$v['day_type_name'] = $v['day_type'] == 0 ? '每天' : '日期前一天和当天';
$v['frequency_type_name'] = $v['frequency_type'] == 1 ? '一天一次' : '一天两次';
$listInfo[] = $v;
}
return $this->successWithInfo(['data'=>$listInfo]);
}
public function store(Request $request,StrategyService $StrategyService){
......@@ -77,10 +91,13 @@ class StrategySetController extends Controller
$returnArr = compact('total','successTotal','failTotal','failDataFile');
return $this->successWithInfo(['data'=>$returnArr]);
}
//删除策略
public function destroy($id){
dd($id);
}
//项目列表
public function getProjectsList(){
$projectInfo = [['sn'=>'projects|a3a4259352c8e964ad6ea6c5ee8a7208','name'=>'liuy-转人工测试'],['sn'=>'projects|a3a4259352c8e964ad6ea6c5ee8a7208','name'=>'liuy-转人工测试']];
$projectInfo = $this->getAllowProjects(0);
return $this->successWithInfo(['data'=>$projectInfo]);
}
......@@ -115,7 +132,7 @@ class StrategySetController extends Controller
return $fcontent;
}catch(\Exception $e){
Log::channel('api')->error($e->getFile().'-'.$e->getLine().'-'.$e->getMessage());
return $this->errorWithInfo('下载异常', 401);
return $this->errorWithInfo('下载异常', 500);
}
}
......@@ -132,17 +149,33 @@ class StrategySetController extends Controller
}
$strategySn = $request->strategy_sn;
$strategyInfo = StrategySet::where('strategy_sn',$strategySn)->first();
if (empty($strategyInfo)){
return $this->errorWithInfo('策略不存在', 401);
}
$day_type = $strategyInfo->day_type;
if (isset($request->upload) && !empty($request->upload)){ //excel文件上传
$total = $successTotal = $failTotal = 0;
$failDataFile = '';
$excelData = $StrategyService->validUploadExcel($request,'upload',8388608); //限制最大上传文件8M
if (isset($excelData['code'])){
return $this->errorWithInfo($excelData['msg'], 401);
}
//验证excel数据格式及不合格数据原因
$excelDataValid = $StrategyService->validExcelData($excelData, $params['day_type']);
$excelDataValid = $StrategyService->validExcelData($excelData, $day_type);
extract($excelDataValid);
unset($params['upload']);
if (isset($successTotal) && $successTotal > 0){
$insertExcelReturn = $StrategyService->insertStrategyExcel($strategySn, $successData);
//添加最新导入数及总数
$updateArr['latest_total'] = $successTotal;
$updateArr['total'] = $strategyInfo->total + $successTotal;
StrategySet::where('strategy_sn',$strategySn)->update($updateArr);
}
//返回成功数、失败数、失败导出文件
$returnArr = compact('total','successTotal','failTotal','failDataFile');
return $this->successWithInfo(['data'=>$returnArr]);
}else{
return $this->errorWithInfo('请选择导入文件', 401);
}
......
......@@ -24,9 +24,9 @@ class CheckApiKey
try {
//$url=$request->url;
//$api_key=$request->api_key;
$user_sn=$request->user_sn;
$user_sn=$request->header('user_sn');
//$user_sn=$request->header('user-sn');
$api_key = $request->header('api-key');//header头里面不能用下划线的参数
if (empty($api_key) || empty($user_sn)){
return $this->errorWithInfo('参数验证不通过', 401);
}
......
......@@ -235,6 +235,7 @@ class StrategyService
foreach ($data as $k=>$v){
$tempi ++;
$taskData[] = [
'strategy_sn'=>$strategySn,
'name'=>$v->name,
'phone'=>$v->phone,
'duty_date'=>$v->duty_date,
......@@ -261,6 +262,7 @@ class StrategyService
$tempi = $tempi+2;
$yesterday = date('Y-m-d',strtotime("-1 day",strtotime($v->duty_date)));
$taskData[] = [
'strategy_sn'=>$strategySn,
'name'=>$v->name,
'phone'=>$v->phone,
'duty_date'=>$v->duty_date,
......@@ -273,6 +275,7 @@ class StrategyService
];
$taskData[] = [
'strategy_sn'=>$strategySn,
'name'=>$v->name,
'phone'=>$v->phone,
'duty_date'=>$v->duty_date,
......@@ -291,9 +294,10 @@ class StrategyService
}
}
}
}
//将处理的策略月份修改为最新
StrategyExcel::where([['strategy_sn',$strategySn],['last_handle_month','<>',$cmonth]])->update(['last_handle_month'=>$cmonth]);
}
......
......@@ -18,31 +18,28 @@ class DatabaseSeeder extends Seeder
if(!Schema::hasTable($tableName)){
Schema::create($tableName, function (Blueprint $table){
$table->increments('id');
$table->uuid('strategy_sn'); //sn编号
$table->char('strategy_name',50); //策略名称
$table->char('user_sn',100); //用户sn
$table->char('user_name',50); //用户名
$table->char('call_number',50); //主叫号码
$table->char('parent_sn',50); //主账号名
$table->char('project_sn',100); //项目sn
$table->uuid('strategy_sn')->comment('sn编号'); //sn编号
$table->char('strategy_name',50)->comment('策略名称');
$table->char('user_sn',100)->comment('用户sn');
$table->char('user_name',50)->comment('用户名');
$table->char('call_number',50)->comment('主叫号码');
$table->char('parent_sn',50)->comment('主账号名');
$table->char('project_sn',100)->comment('项目sn');
$table->unsignedSmallInteger('day_type')->default(0); //外呼日期类型 0每天 1日期前一天和当天
$table->unsignedSmallInteger('frequency_type')->default(1);//外呼频率类型 (1 一天一次 2 一天两次)
$table->char('call_time_set',50); //呼叫设置时间点,两个用#号分割
$table->unsignedSmallInteger('disabled')->default(1);//是否不可用 0启用 1停用
$table->integer('total')->default(0);//excel导入号码总数量
$table->integer('latest_total')->default(0);//最新一次导入excel号码数量
$table->timestamp('updated_at')->nullable();
$table->timestamp('created_at')->nullable();
$table->unsignedSmallInteger('day_type')->default(0)->comment('外呼日期类型 0每天 1日期前一天和当天');
$table->unsignedSmallInteger('frequency_type')->default(1)->comment('外呼频率类型 (1 一天一次 2 一天两次)');
$table->char('call_time_set',50)->comment('呼叫设置时间点,两个用#号分割');
$table->unsignedSmallInteger('disabled')->default(1)->comment('是否不可用 0启用 1停用');
$table->integer('total')->default(0)->comment('excel导入号码总数量');
$table->integer('latest_total')->default(0)->comment('最新一次导入excel号码数量');
$table->timestamp('updated_at')->nullable()->comment('更新时间');
$table->timestamp('created_at')->nullable()->comment('创建时间');
});
//加索引
Schema::table($tableName, function ($table){
$table->index('strategy_sn');
$table->index('disabled');
});
//加注释
//$sql = "COMMENT ON COLUMN \"public\".\"seating_assistance_project_set\".\"is_seating_sensitive_word\" IS '是否坐席敏感词 0否 1是'";
//DB::statement($sql);
}
......@@ -50,13 +47,13 @@ class DatabaseSeeder extends Seeder
if(!Schema::hasTable($tableName)){
Schema::create($tableName, function (Blueprint $table){
$table->increments('id');
$table->char('strategy_sn',100); //sn编号
$table->char('name',50)->nullable(); //姓名
$table->date('duty_date')->nullable(); //值班日期
$table->unsignedBigInteger('phone'); //手机号
$table->unsignedSmallInteger('last_handle_month')->default(0);//最后处理月份,当月处理后不再处理
$table->timestamp('updated_at')->nullable();
$table->timestamp('created_at')->nullable();
$table->char('strategy_sn',100)->comment('sn编号');
$table->char('name',50)->nullable()->comment('姓名');
$table->date('duty_date')->nullable()->comment('值班日期');
$table->unsignedBigInteger('phone')->comment('手机号');
$table->unsignedSmallInteger('last_handle_month')->default(0)->comment('最后处理月份,当月处理后不再处理');
$table->timestamp('updated_at')->nullable()->comment('更新时间');
$table->timestamp('created_at')->nullable()->comment('创建时间');
});
//加索引
Schema::table($tableName, function ($table){
......@@ -68,17 +65,18 @@ class DatabaseSeeder extends Seeder
if(!Schema::hasTable($tableName)){
Schema::create($tableName, function (Blueprint $table){
$table->increments('id');
$table->char('name',50)->nullable(); //sn编号
$table->date('duty_date')->nullable(); //值班日期(年月日)
$table->unsignedBigInteger('phone'); //手机号
$table->char('call_number',50); //主叫号码
$table->date('call_date'); //外呼时间(年月日)
$table->time('call_time'); //外呼时间(时分秒)
$table->char('parent_sn',50); //主账号名
$table->char('project_sn',100); //项目sn
$table->uuid('strategy_sn')->comment('策略sn编号'); //sn编号
$table->char('name',50)->nullable()->comment('姓名');
$table->date('duty_date')->nullable()->comment('值班日期(年月日)');
$table->unsignedBigInteger('phone')->comment('手机号');
$table->char('call_number',50)->comment('主叫号码');
$table->date('call_date')->comment('外呼时间(年月日)');
$table->time('call_time')->comment('外呼时间(时分秒)');
$table->char('parent_sn',50)->comment('主账号名');
$table->char('project_sn',100)->comment('项目sn');
$table->unsignedSmallInteger('is_created')->default(0);//是否新建任务(0未建 1已建)
$table->unsignedSmallInteger('created_fail_number')->default(0);//任务创建失败尝试次数
$table->unsignedSmallInteger('is_created')->default(0)->comment('是否新建任务(0未建 1已建)');
$table->unsignedSmallInteger('created_fail_number')->default(0)->comment('任务创建失败尝试次数');
$table->timestamp('created_at')->nullable();
});
......
......@@ -28,6 +28,8 @@ Route::group(['middleware' => 'check.apikey','namespace'=>'strategy'], function
Route::get('strategy/downloadFailExcel', 'StrategySetController@downloadFailExcel')->name('strategy.downloadFailExcel');//下载失败导入excel数据
Route::post('strategy/importExcelData', 'StrategySetController@importExcelData')->name('strategy.importExcelData');//导入excel数据
Route::apiResource('strategySet', StrategySetController::class);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment