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.
...@@ -23,7 +24,7 @@ class FollowUpTask ...@@ -23,7 +24,7 @@ class FollowUpTask
public function __construct() public function __construct()
{ {
$this->redis_ = RedisExt::getRedis(); $this->redis_ = RedisExt::getRedis();
$this->siteModel = new ASite(); $this->siteModel = new ASite();
} }
...@@ -36,11 +37,11 @@ class FollowUpTask ...@@ -36,11 +37,11 @@ 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();
$site_arr = $redis_service->getRedisCache(4, $siteId); $site_arr = $redis_service->getRedisCache(4, $siteId);
if (empty($site_arr)) { if (empty($site_arr)) {
$site_arr = $this->siteModel->findByOne('city', ["id" => $siteId]); $site_arr = $this->siteModel->findByOne('city', ["id" => $siteId]);
} }
...@@ -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
...@@ -121,12 +158,12 @@ class FollowUpTask ...@@ -121,12 +158,12 @@ class FollowUpTask
//todo 判断参数和时间 //todo 判断参数和时间
$checkDayStr = date('Y-m-d ', time()); $checkDayStr = date('Y-m-d ', time());
$timeBegin1 = strtotime($checkDayStr . "0:10" . ":00"); $timeBegin1 = strtotime($checkDayStr . "0:10" . ":00");
$timeEnd1 = strtotime($checkDayStr . "0:50" . ":00"); $timeEnd1 = strtotime($checkDayStr . "0:50" . ":00");
$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,18 +171,18 @@ class FollowUpTask ...@@ -134,18 +171,18 @@ 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"];
//判断此站点是否执行过 //判断此站点是否执行过
if ($this->redis_->get("is_run_" . $date . "_" . $site_id) > 0) { if ($this->redis_->get("is_run_" . $date . "_" . $site_id) > 0) {
continue; continue;
} }
$table_name = $this->table . $site_id . "_" . $date; $table_name = $this->table . $site_id . "_" . $date;
$phoneFollowUpModel = new UPhoneFollowUpTemporary($site_id); $phoneFollowUpModel = new UPhoneFollowUpTemporary($site_id);
$isTable = $phoneFollowUpModel->query('SHOW TABLES LIKE "' . $table_name . '"'); $isTable = $phoneFollowUpModel->query('SHOW TABLES LIKE "' . $table_name . '"');
if ($isTable) { if ($isTable) {
$sql = "INSERT into u_phone_follow_up_" . $site_id . " $sql = "INSERT into u_phone_follow_up_" . $site_id . "
(content,labels_id,user_id,agent_id,province,city,disc,type,create_time,update_time,user_status,img_str ) (content,labels_id,user_id,agent_id,province,city,disc,type,create_time,update_time,user_status,img_str )
select content,labels_id,user_id,agent_id,province,city,disc,type,create_time,update_time,user_status,img_str select content,labels_id,user_id,agent_id,province,city,disc,type,create_time,update_time,user_status,img_str
from `" . $table_name . "`"; from `" . $table_name . "`";
......
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