public function findBidKey($row) { $notinum_ex = $row['bidno']; $query = BidKey::find()->where(['whereis' => '08', 'notinum' => $row['notinum']]); if ($notinum_ex == 1) { $query->andWhere("notinum_ex='' or notinum_ex='1'"); } else { $query->andWhere(['notinum_ex' => $notinum_ex]); } $bidkey = $query->orderBy('bidid desc')->limit(1)->one(); return $bidkey; }
public function run($workload, $className) { try { $notinum_ex = $workload['bidno']; if (isset($workload['bidproc']) and ArrayHelper::isIn($workload['bidproc'], ['유찰', '재공고'])) { $query = BidKey::find()->where(['whereis' => '08', 'notinum' => $data['notinum']]); if ($notinum_ex == 1) { $query->andWhere("notinum_ex='' or notinum_ex='1'"); } else { $query->andWhere(['notinum_ex' => $notinum_ex]); } $bidkey = $query->orderBy('bidid desc')->limit(1)->one(); if ($bidkey !== null and $bidkey->bidproc !== 'F') { $this->gman_client->doBackground('i2_auto_suc_test', Json::encode(['bidid' => $bidkey->bidid, 'bidproc' => 'F'])); $this->stdout2(" >>> {$bidkey->bidid} ({$bidkey->bidproc}) %y유찰%n\n"); } return; } $worker = new $className(['notino' => $workload['notino'], 'bidno' => $workload['bidno'], 'bidseq' => $workload['bidseq'], 'state' => $workload['state']]); $worker->on('total_page', function ($event) { Console::startProgress(0, $event->sender->succom_total_page); }); $worker->on('page', function ($event) { if ($event->sender->succom_total_page == $event->sender->succom_page) { Console::updateProgress($event->sender->succom_page, $event->sender->succom_total_page); Console::endProgress(); } else { Console::updateProgress($event->sender->succom_page, $event->sender->succom_total_page); } }); $data = $worker->run(); $query = BidKey::find()->where(['whereis' => '08', 'notinum' => $data['notinum']]); if ($notinum_ex == 1) { $query->andWhere("notinum_ex='' or notinum_ex='1'"); } else { $query->andWhere(['notinum_ex' => $notinum_ex]); } $bidkey = $query->orderBy('bidid desc')->limit(1)->one(); if ($bidkey === null) { return; } $bidvalue = $bidkey->bidValue; $data['multispare'] = $bidvalue->multispare; if (is_array($data['selms'])) { $selms = []; $multispares = explode('|', $data['multispare']); foreach ($multispares as $i => $v) { if (ArrayHelper::isIn($v, $data['selms'])) { $selms[] = $i + 1; } } $data['selms'] = join('|', $selms); } $data['bidid'] = $bidkey->bidid; $data['bidproc'] = 'S'; $this->gman_client->doBackground('i2_auto_suc_test', Json::encode($data)); $this->stdout2(" >>> {$bidkey->bidid} ({$bidkey->bidproc}) 예가:{$data['yega']} 참여수:{$data['innum']} %g개찰%n\n"); } catch (\Exception $e) { $this->stdout("{$e}\n", Console::FG_RED); \Yii::error($e, 'ebidex'); } }
public function run($workload, $className) { try { $worker = new $className(['notino' => $workload['notino'], 'bidno' => $workload['bidno'], 'bidseq' => $workload['bidseq']]); $data = $worker->run(); $data['whereis'] = '08'; $data['orgcode_y'] = $workload['bidseq']; //차수 if (isset($workload['changeConstnm']) and isset($workload['constnm'])) { $data['constnm'] = $workload['constnm']; } if ($workload['bidproc'] == '취소공고') { $query = BidKey::find()->where(['whereis' => '08', 'notinum' => $data['notinum']]); if ($data['notinum_ex'] == 1) { $query->andWhere("notinum_ex='' or notinum_ex='1'"); } else { $query->andWhere(['notinum_ex' => $data['notinum_ex']]); } $bidkey = $query->orderBy('bidid desc')->limit(1)->one(); if ($bidkey !== null and $bidkey->bidproc != 'C' and $bidkey->orgcode_y <= $workload['bidseq']) { list($a, $b, $c, $d) = explode('-', $bidkey->bidid); $b = sprintf('%02s', intval($b) + 1); $data['bidid'] = "{$a}-{$b}-{$c}-{$d}"; $data['bidproc'] = 'C'; $this->gman_client->doNormal($this->i2_gman_func, Json::encode($data)); $this->stdout2(" %g>>> do {$this->i2_gman_func} {$data['bidid']} {$data['bidproc']}%n\n"); } } else { if ($workload['bidproc'] == '공고중' or $workload['bidproc'] == '정정공고중') { $query = BidKey::find()->where(['whereis' => '08', 'notinum' => $data['notinum']]); if ($data['notinum_ex'] == 1) { $query->andWhere("notinum_ex='' or notinum_ex='1'"); } else { $query->andWhere(['notinum_ex' => $data['notinum_ex']]); } $bidkey = $query->orderBy('bidid desc')->limit(1)->one(); if ($bidkey === null) { //new list(, $bno) = explode('-', $data['notinum']); $data['bidid'] = sprintf('%6sEX%5s%-02s-00-00-01', date('ymd'), $bno, $workload['bidno']); $data['bidproc'] = 'B'; $this->gman_client->doNormal($this->i2_gman_func, Json::encode($data)); $this->stdout2(" %g>>> do {$this->i2_gman_func} {$data['bidid']} {$data['bidproc']}%n\n"); } else { if ($workload['bidseq'] > 1 and $bidkey->orgcode_y != $workload['bidseq']) { //정정공고 list($a, $b, $c, $d) = explode('-', $bidkey->bidid); $b = sprintf('%02s', intval($b) + 1); $data['bidid'] = "{$a}-{$b}-{$c}-{$d}"; $data['bidproc'] = 'M'; $this->gman_client->doNormal($this->i2_gman_func, Json::encode($data)); $this->stdout2(" %g> do {$this->i2_gman_func} {$data['bidid']} {$data['bidproc']}%n\n"); } } } } \Yii::info(VarDumper::dumpAsString($data), 'ebidex'); //------------------------------- // 임의수정 check //------------------------------- if ($bidkey !== null) { $bidcheck = BidModifyCheck::findOne($bidkey->bidid); if ($bidcheck === null) { $bidcheck = new BidModifyCheck(['bidid' => $bidkey->bidid]); } $bid_hash = md5(join('', $data)); $noticeDoc = BidFile::findNoticeDoc($data['attchd_lnk']); if ($noticeDoc !== null and $noticeDoc->download()) { $file_hash = md5_file($noticeDoc->saveDir . '/' . $noticeDoc->savedName); $noticeDoc->remove(); } if (!empty($bidcheck->bid_hash) and $bidcheck->bid_hash != $bid_hash) { $this->stdout(" > check : bid_hash diff\n", Console::FG_YELLOW); $this->sendMessage("도로공사 공고정보 확인필요! [{$data['notinum']}]"); } else { if (!empty($bidcheck->file_hash) and $bidcheck->file_hash != $file_hash) { $this->stdout(" > check : file_hash diff\n", Console::FG_YELLOW); $this->sendMessage("도로공사 공고원문 확인필요! [{$data['notinum']}]"); } } $bidcheck->bid_hash = $bid_hash; $bidcheck->file_hash = $file_hash; $bidcheck->check_at = time(); $bidcheck->save(); $this->stdout2(" %b>>> bid modify check%n\n"); } //---------------------------- // 복수공고처리 //---------------------------- if (isset($data['multi_list'])) { $notinum = $data['notinum']; $bidtype = $data['bidtype']; foreach ($data['multi_list'] as $next) { if ($next['bidno'] > $worker->bidno) { $this->gman_client->doBackground('ebidex_work_bid_' . $bidtype, Json::encode(['notinum' => $notinum, 'notino' => $next['notino'], 'bidno' => $next['bidno'], 'bidseq' => $next['bidseq'], 'constnm' => $next['constnm'], 'changeConstnm' => '1', 'bidproc' => $workload['bidproc']])); break; } } } } catch (\Exception $e) { $this->stdout("{$e}\n", Console::FG_RED); \Yii::error($e, 'ebidex'); $this->sendMessage('ebidex:' . $e->getMessage()); } $this->stdout(sprintf("[%s] Peak memory usage: %sMb\n", date('Y-m-d H:i:s'), memory_get_peak_usage(true) / 1024 / 1024), Console::FG_GREY); $this->module->db->close(); sleep(mt_rand(3, 6)); }