Commit fb3384cd authored by clone's avatar clone

1

parent 33daad04
...@@ -750,6 +750,7 @@ Route::group('task', [ ...@@ -750,6 +750,7 @@ Route::group('task', [
'test' => ['task/FollowUpTask/test', ['method' => 'get']], 'test' => ['task/FollowUpTask/test', ['method' => 'get']],
'isExistTable' => ['task/FollowUpTask/isExistTable', ['method' => 'get']], 'isExistTable' => ['task/FollowUpTask/isExistTable', ['method' => 'get']],
'moveFollowUpList' => ['task/FollowUpTask/moveFollowUpList', ['method' => 'get']], 'moveFollowUpList' => ['task/FollowUpTask/moveFollowUpList', ['method' => 'get']],
'delOldTable' => ['task/FollowUpTask/delOldTable', ['method' => 'get']],
'frostAgent' => ['task/FrostAgentTask/frostAgent', ['method' => 'get']], 'frostAgent' => ['task/FrostAgentTask/frostAgent', ['method' => 'get']],
'squareBackUp' => ['task/SquareTask/squareBackUp', ['method' => 'get']], //redis备份开盘排序 'squareBackUp' => ['task/SquareTask/squareBackUp', ['method' => 'get']], //redis备份开盘排序
......
...@@ -7,6 +7,7 @@ use app\extra\RedisExt; ...@@ -7,6 +7,7 @@ use app\extra\RedisExt;
use app\model\ASite; use app\model\ASite;
use app\model\UPhoneFollowUp; use app\model\UPhoneFollowUp;
use app\model\UPhoneFollowUpTemporary; use app\model\UPhoneFollowUpTemporary;
use Think\Exception;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
...@@ -36,7 +37,7 @@ class FollowUpTask ...@@ -36,7 +37,7 @@ class FollowUpTask
*/ */
public function isExistTable($time, $siteId) public function isExistTable($time, $siteId)
{ {
if(!$siteId){ if (!$siteId) {
return false; return false;
} }
$redis_service = new RedisCacheService(); $redis_service = new RedisCacheService();
...@@ -71,6 +72,42 @@ class FollowUpTask ...@@ -71,6 +72,42 @@ class FollowUpTask
return false; return false;
} }
public function delOldTable()
{
$redisCache = new RedisCacheService();
$siteIdArr = $redisCache->siteAllCityCache();
$date = date("Y-m-d", strtotime("-5 day")); //获取5天前的时间
foreach ($siteIdArr as $item) {
$this->delTable($date, $item["id"]);
}
}
/**
* @param $time
* @param $siteId
* @return bool|void
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
private function delTable($time, $siteId)
{
if (!$time || !$siteId || $time < '2019-05-27') {
return;
}
$phoneFollowUpModel = new UPhoneFollowUpTemporary($siteId);
$table_name = $this->table . $siteId . "_" . $time;
$isTable = $phoneFollowUpModel->query('SHOW TABLES LIKE "' . $table_name . '"');
if ($isTable) {//存在
//删除表
$sql = "DROP TABLE `" . $table_name . "`";
$phoneFollowUpModel->execute($sql);
}
$date = date('Y-m-d', strtotime("-1 day", strtotime($time)));
$this->delTable($date, $siteId);
}
/** /**
* @param $db * @param $db
* @param $tableName * @param $tableName
...@@ -126,7 +163,7 @@ class FollowUpTask ...@@ -126,7 +163,7 @@ class FollowUpTask
$curr_time = time(); $curr_time = time();
if (!$key || $key!= "zw" ||$curr_time < $timeBegin1 || $curr_time > $timeEnd1) { if (!$key || $key != "zw" || $curr_time < $timeBegin1 || $curr_time > $timeEnd1) {
echo "hello world"; echo "hello world";
return; return;
} }
...@@ -134,7 +171,7 @@ class FollowUpTask ...@@ -134,7 +171,7 @@ class FollowUpTask
if (count($site_arr) <= 0) { if (count($site_arr) <= 0) {
return; return;
} }
$date = date("Y-m-d",strtotime("-1 day")); $date = date("Y-m-d", strtotime("-1 day"));
foreach ($site_arr as $item) { foreach ($site_arr as $item) {
$site_id = $item["id"]; $site_id = $item["id"];
//判断此站点是否执行过 //判断此站点是否执行过
......
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