作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !3152
... ... @@ -82,9 +82,10 @@ class RemainDay extends Command
$list = $projectModel->list(['extend_type'=>Project::TYPE_ZERO,'type'=>['in',[Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR,Project::TYPE_SIX]]],'id',['id','type','level','uptime','remain_day','version','is_remain_today','pause_days','finish_remain_day','bm_finish_remain_day','geo_qualify_num']);
foreach ($list as $item){
$deploy_build = $deployBuildModel->read(['project_id'=>$item['id']],['service_duration','seo_service_duration','plan','seo_plan']);
echo 'start->项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
$this->output('start->项目id:' . $item['id']);
//todo::暂停的项目停止计时
if(in_array($item['id'],$this->ceaseProjectId)){//暂停的项目
$this->output('暂停的项目id:' . $item['id']);
if(($item['type'] == Project::TYPE_TWO) && ($item['is_remain_today'] == 1)){
$pause_days = $item['pause_days'] + 1;
}
... ... @@ -96,6 +97,8 @@ class RemainDay extends Command
}
//todo::优化项目中途达标计时切换为按天计时
if(in_array($item['id'],$this->projectSwitchId)){
$this->output('中途切换计时的项目id:' . $item['id'].',旧达标天数:'.$item['finish_remain_day'].',新达标天数:'.($item['finish_remain_day'] + 1));
$this->output('中途切换计时的项目id:' . $item['id'].',当前剩余服务时常:'.$item['remain_day'].',剩余时常:'.($item['remain_day'] - 1));
$this->project->edit(['remain_day'=>($item['remain_day'] - 1),'finish_remain_day'=>($item['finish_remain_day'] + 1)],['id'=>$item['id']]);
continue;
}
... ... @@ -103,7 +106,7 @@ class RemainDay extends Command
$this->seoRemainDay($deploy_build,$item);
//默认版本统计
$this->remainDay($item,$deploy_build);
echo 'end->项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL;
$this->output('end->项目id:' . $item['id']);
}
return true;
}
... ... @@ -121,14 +124,17 @@ class RemainDay extends Command
//白帽版本的系统
if($deploy_build['seo_plan'] != 0){
if($deploy_build['seo_service_duration'] != 0){
$this->output('白帽计算剩余服务时常:'.$item['id']);
if(in_array($item['id'],$this->bm_projectId) || (in_array( 19,$item['level']))){
$compliance_day = (int)$item['bm_finish_remain_day'];
$seo_remain_day = $deploy_build['seo_service_duration'] - (int)$item['bm_finish_remain_day'];
$this->output('按白帽达标天数统计:'.$item['id'].',bm达标天数:'.$item['bm_finish_remain_day'].',bm剩余白帽天数:'.$seo_remain_day);
}else{
//按自然日统计
$diff = time() - strtotime($item['uptime']);
$compliance_day = floor($diff / (60 * 60 * 24));
$seo_remain_day = $deploy_build['seo_service_duration'] - $compliance_day;
$this->output('按白帽自然日天数统计:'.$item['id'].',bm达标天数:'.$compliance_day.',bm剩余白帽天数:'.$seo_remain_day);
}
$this->project->edit(['seo_remain_day'=>$seo_remain_day,'bm_finish_remain_day'=>$compliance_day ?? 0],['id'=>$item['id']]);
}
... ... @@ -144,8 +150,10 @@ class RemainDay extends Command
* @time :2025/4/25 14:31
*/
public function remainDay($item,$deploy_build){
$this->output('普通项目计算剩余服务时常:'.$item['id']);
//默认版本统计
if($deploy_build['service_duration'] == 0 || $deploy_build['plan'] == 0){
$this->output('当前项目跳过:'.$item['id']);
return false;
}
//默认版本计算剩余服务时常
... ... @@ -159,6 +167,7 @@ class RemainDay extends Command
$diff = time() - strtotime($opInfo['start_date'] ?? $item['uptime']);
$compliance_day = floor($diff / (60 * 60 * 24));
$remain_day = $deploy_build['service_duration'] - $compliance_day;
$this->output('已开始优化的时间结算:'.$item['id'].',剩余服务时常:'.$remain_day);
}else{
$compliance_day = ($item['finish_remain_day'] ?? 0);
//todo::7.5版本单独计算
... ... @@ -168,8 +177,10 @@ class RemainDay extends Command
if($item['is_remain_today'] > 0 && $is_qualify > 0){
$remain_day = $item['remain_day'] - 1;
}
$this->output('7.5版本单独计算:'.$item['id'].',剩余服务时常:'.$remain_day);
}else{
$remain_day = $deploy_build['service_duration'] - $compliance_day;
$this->output('优化项目:'.$item['id'].',剩余服务时常:'.$remain_day.',已达标天数:'.$compliance_day);
}
}
}else{
... ... @@ -183,11 +194,20 @@ class RemainDay extends Command
}
}
$extend_type = 0;
// if($remain_day < 0 && $deploy_build['service_duration'] != 0){
// $remain_day = 0;
// $extend_type = Project::TYPE_FIVE;
// }
$this->project->edit(['remain_day'=>$remain_day,'extend_type'=>$extend_type,'finish_remain_day'=>$compliance_day ?? 0],['id'=>$item['id']]);
return true;
}
/**
* 输入日志
* @param $message
* @return bool
*/
public function output($message)
{
$message = date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL;
echo $message;
file_put_contents(storage_path('logs/remain_day/') . date('Ymd') . '.log', $message, FILE_APPEND);
return true;
}
}
... ...
... ... @@ -36,7 +36,9 @@ class GeoConf extends Base
if (empty($optimize)) {
$optimize = ManageHr::where(['status' => ManageHr::STATUS_ONE, 'entry_position' => 46])->pluck('name', 'id')->toArray();
$optimize[11] = '陶婵';
$optimize[207] = '吴雨静';
$optimize[875] = '艾媛媛';
$optimize[893] = '杨汀';
ksort($optimize);
Cache::put($key, $optimize, 3600);
}
... ...