|
|
@@ -99,11 +99,13 @@ if (empty($period)){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public static function autoPrePerf(){
|
|
|
+ public static function autoPrePerf(){ // 自动预结算
|
|
|
$nowTs = time();
|
|
|
$currentPeriod = Period::find()->where('START_TIME< :NOW_TIME',['NOW_TIME'=>$nowTs])->where('END_TIME>= :NOW_TIME',['NOW_TIME'=>$nowTs-6])->asArray()->one();
|
|
|
$periodNum = $currentPeriod['PERIOD_NUM'];
|
|
|
-
|
|
|
+ if (Period::isProcessing($periodNum)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if($nowTs+86400>$currentPeriod['END_TIME'] ){
|
|
|
$nowMin = date("i", $nowTs);
|
|
|
$nowSec = date("s", $nowTs);
|
|
|
@@ -133,7 +135,7 @@ if (empty($period)){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static function listenAutoPerfPeriod()
|
|
|
+ public static function listenAutoPerfPeriod() // 拉取预结算的结果
|
|
|
{
|
|
|
$db = self::CALC_DB_NAME;
|
|
|
$allPeriod = \Yii::$app->$db->createCommand("SELECT * FROM AR_PERIOD ")->queryAll();
|
|
|
@@ -152,11 +154,16 @@ if (empty($period)){
|
|
|
|
|
|
$businessPeriod = Period::find()->where(['PERIOD_NUM' => $period['PERIOD_NUM']])->asArray()->one();
|
|
|
|
|
|
+ if (
|
|
|
+ $businessPeriod['IS_SENT'] // 已挂网
|
|
|
+ || 1 != $businessPeriod['IS_PREPARING'] // 未在预计算中
|
|
|
+ || $period['PERFED_AT'] < $businessPeriod['START_EXEC_TIME'] // 计算服务中的计算时间,早于业务系统开始计算时间,说明是旧的,不拉取
|
|
|
+ ){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
if (
|
|
|
2 == $period['IS_PREPARE']
|
|
|
- && 1 == $businessPeriod['IS_PROCESSING']
|
|
|
&& 3 == $period['IS_PERFED']
|
|
|
- && $period['PERFED_AT']>$businessPeriod['START_EXEC_TIME']
|
|
|
) {
|
|
|
//拉取期业绩
|
|
|
CalcRecord::record($period['PERIOD_NUM'], '第' . $period['PERIOD_NUM'] . '期的预计算业绩数据已生成');
|
|
|
@@ -166,11 +173,15 @@ if (empty($period)){
|
|
|
$res = (new PullPerfDataFromCalc($period['PERIOD_NUM']))->start();
|
|
|
if (200 == $res['code']) {
|
|
|
Period::updatePeriodIsProcessing($period['PERIOD_NUM'], Period::NOT_PROCESSING);
|
|
|
+ //设置预计算标识
|
|
|
+ Period::updatePeriodIsPreparing($period['PERIOD_NUM'], Period::NOT_PREPARING);
|
|
|
CalcRecord::record($period['PERIOD_NUM'], '第' . $period['PERIOD_NUM'] . '期的预计算期业绩数据已获取');
|
|
|
return $res;
|
|
|
} else {
|
|
|
//结束计算状态
|
|
|
Period::updatePeriodIsProcessing($period['PERIOD_NUM'], Period::NOT_PROCESSING);
|
|
|
+ //设置预计算标识
|
|
|
+ Period::updatePeriodIsPreparing($period['PERIOD_NUM'], Period::NOT_PREPARING);
|
|
|
CalcRecord::record($period['PERIOD_NUM'], '第' . $period['PERIOD_NUM'] . '期的预计算期业绩数据获取失败,原因:' . $res['msg']);
|
|
|
return $res;
|
|
|
}
|