|
|
@@ -39,21 +39,6 @@ class StaffSalary extends Api
|
|
|
if (Request::instance()->isPost() == false){
|
|
|
$this->error('非法请求');
|
|
|
}
|
|
|
- $options = [
|
|
|
- 'host' => '127.0.0.1',
|
|
|
- 'port' => 6379,
|
|
|
- 'password' => '',
|
|
|
- 'select' => 15,
|
|
|
- 'timeout' => 0,
|
|
|
- 'expire' => 0,
|
|
|
- 'persistent' => false,
|
|
|
- 'prefix' => '',
|
|
|
- ];
|
|
|
- $redis = new Redis($options);
|
|
|
- $queueKey = $redis->handler()->llen('queues:default');
|
|
|
- if ($queueKey){
|
|
|
- $this->success('数据正在处理中,请等待...');
|
|
|
- }
|
|
|
$params = Request::instance()->param();
|
|
|
if (!isset($params['start_date']) || !isset($params['end_date']) || empty($params['start_date']) || empty($params['end_date']) || !isset($params['date']) || empty($params['date']))
|
|
|
{
|
|
|
@@ -68,6 +53,22 @@ class StaffSalary extends Api
|
|
|
if (!$startDateInRange || !$endDateInRange) {
|
|
|
$this->error('日期参数错误');
|
|
|
}
|
|
|
+ $options = [
|
|
|
+ 'host' => '127.0.0.1',
|
|
|
+ 'port' => 6379,
|
|
|
+ 'password' => '',
|
|
|
+ 'select' => 15,
|
|
|
+ 'timeout' => 0,
|
|
|
+ 'expire' => 0,
|
|
|
+ 'persistent' => false,
|
|
|
+ 'prefix' => '',
|
|
|
+ ];
|
|
|
+ $redis = new Redis($options);
|
|
|
+ $taskIdentifier = md5(json_encode('date'));
|
|
|
+ $queueKey = $redis->get($taskIdentifier);
|
|
|
+ if ($queueKey){
|
|
|
+ $this->success('数据正在处理中,请等待...');
|
|
|
+ }
|
|
|
$vacationOneArr = [];
|
|
|
if (!empty($params['vacation_one_start']) && !empty($params['vacation_one_end'])){
|
|
|
$vacationOneStart = strtotime($params['vacation_one_start']);
|
|
|
@@ -495,10 +496,16 @@ class StaffSalary extends Api
|
|
|
$data[$key]['法定天数'] = $params['days'];
|
|
|
$data[$key]['sczl_type'] = trim($item['sczl_type']);
|
|
|
}
|
|
|
-
|
|
|
- $job = new InsertDataJob($data); // 创建任务实例
|
|
|
- Queue::push($job,'','default'); // 推送任务到队列
|
|
|
- $this->success('数据正在处理中,请等待...');
|
|
|
+ $taskIdentifier = md5(json_encode('date'));
|
|
|
+ // 检查任务是否已经存在于队列中,如果不存在则推送任务到队列
|
|
|
+ if (!$redis->has($taskIdentifier)) {
|
|
|
+ $job = new InsertDataJob($data); // 创建任务实例
|
|
|
+ // 推送任务到队列
|
|
|
+ Queue::push($job,'','default'); // 推送任务到队列
|
|
|
+ // 设置任务的标识符到缓存中,并设置有效期,有效期为队列执行时间的两倍
|
|
|
+ $redis->set($taskIdentifier, true,60*5);
|
|
|
+ $this->success('数据正在处理中,请等待...');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|