public function onRow($event) { $row = $event->row; $out[] = "[KWATER] [{$row['bidtype']}] %g{$row['notinum']}%n {$row['constnm']} ({$row['contract']},{$row['status']})"; $bidkey = BidKey::find()->where(['whereis' => \kwater\Module::WHEREIS, 'notinum' => $row['notinum']])->orderBy('bidid desc')->limit(1)->one(); if ($bidkey === null) { if (!ArrayHelper::isIn($row['status'], ['입찰완료', '적격신청', '결과발표']) and !ArrayHelper::isIn($row['contract'], ['지명경쟁', '수의계약(시담)'])) { $out[] = "%rNEW%n"; $this->gman_client->doBackground('kwater_work_bid', Json::encode($row)); $sleep = 1; } } else { $out[] = "({$bidkey->bidproc})"; if ($bidkey->bidproc === 'B' and $bidkey->state === 'Y') { $bidcheck = BidModifyCheck::findOne($bidkey->bidid); if ($bidcheck === null) { $out[] = "%yCHECK%n"; $this->gman_client->doBackground('kwater_work_bid', Json::encode($row)); } else { $diff = time() - $bidcheck->check_at; if ($diff >= 60 * 60 * 1) { $out[] = "%yCHECK%n"; $this->gman_client->doBackground('kwater_work_bid', Json::encode($row)); $bidcheck->check_at = time(); $bidcheck->save(); $sleep = 1; } } } } $this->stdout(Console::renderColoredString(join(' ', $out)) . PHP_EOL); if (isset($sleep)) { sleep(3); } }
public function onSucData($event) { $row = $event->row; \Yii::info('[' . __METHOD__ . '] $row ' . VarDumper::dumpAsString($row), 'kwater'); $this->stdout(Console::renderColoredString("[KWATER] %g{$row['notinum']}%n {$row['constnm']} ({$row['status']})\n")); try { $bidkey = BidKey::find()->where(['whereis' => '07', 'notinum' => $row['notinum']])->orderBy('bidid desc')->limit(1)->one(); if ($bidkey === null) { $this->stdout(" > 입찰공고가 없습니다.\n", Console::FG_RED); return; } $bidvalue = BidValue::findOne($bidkey->bidid); if ($bidvalue === null) { throw new \Exception('bid_value is empty'); } $bidres = BidRes::findOne($bidkey->bidid); if ($bidres === null) { $bidres = new BidRes(['bidid' => $bidkey->bidid]); } BidSuccom::deleteAll(['bidid' => $bidkey->bidid]); if ($row['bidproc'] == 'F') { $bidres->yega = 0; $bidres->selms = ''; $bidres->multispare = ''; $bidres->officenm1 = '유찰'; $bidres->reswdt = date('Y-m-d H:i:s'); $bidres->save(); $bidkey->bidproc = 'F'; $bidkey->resdt = date('Y-m-d H:i:s'); $bidkey->editdt = date('Y-m-d H:i:s'); $bidkey->save(); return; } $bidres->yega = $row['yega']; $bidres->innum = $row['innum']; $bidres->selms = $row['selms']; $bidres->multispare = $bidvalue->multispare; $bidres->save(); Console::startProgress(0, $row['innum']); foreach ($row['succoms'] as $succom) { $bidsuccom = new BidSuccom(['bidid' => $bidkey->bidid, 'seq' => $succom['seq'], 'officeno' => '', 'officenm' => $succom['officenm'], 'prenm' => '', 'success' => $succom['success'], 'pct' => $succom['pct'], 'rank' => $succom['rank'], 'selms' => '', 'etc' => $succom['etc']]); $bidsuccom->save(); Console::updateProgress($succom['seq'], $row['innum']); } Console::endProgress(); $bidkey->bidproc = 'S'; $bidkey->resdt = date('Y-m-d H:i:s'); $bidkey->editdt = date('Y-m-d H:i:s'); $bidkey->save(); } catch (\Exception $e) { $this->stdout("{$e}\n", Console::FG_RED); \Yii::error($e, 'kwater'); } }