public function getHotlinkTo(Model $model, $action = null, $options = []) { if (!ArrayHelper::isIn($this->className(), ArrayHelper::getColumn($model->behaviors(), 'class'))) { throw new InvalidRouteException('The "LinkableBehavior" is not attached to the specified model'); } return $this->getHotlink(strtr('{route}/{action}', ['{route}' => $model->route, '{action}' => $action ?? $model->defaultAction]), $model->linkableParams, $options); }
public function __construct($config = array()) { self::$plugins = array_diff(scandir(__DIR__ . '/plugins/'), array('..', '.')); $provider = ArrayHelper::getValue($config, 'config.provider'); if (isset($provider)) { if (ArrayHelper::isIn($provider . '.php', self::$plugins)) { require __DIR__ . '/plugins/' . $provider . '.php'; $format = ArrayHelper::getValue($config, 'config.return_formats'); if (isset($format)) { if (ArrayHelper::isIn($format, ArrayHelper::getValue($plugin, 'accepted_formats'))) { self::$return_formats = $format; } else { self::$return_formats = ArrayHelper::getValue($plugin, 'default_accepted_format'); } } self::$provider = $plugin; self::$api_key = ArrayHelper::getValue($config, 'config.api_key', NULL); } else { throw new HttpException(404, 'The requested Item could not be found.'); } } else { require __DIR__ . '/plugins/geoplugin.php'; self::$provider = $plugin; self::$return_formats = $plugin['default_accepted_format']; } return parent::__construct($config); }
/** * @inheritdoc */ protected function validateValue($value) { $in = false; if ($this->allowArray && ($value instanceof \Traversable || is_array($value)) && ArrayHelper::isSubset($value, $this->range, $this->strict)) { $in = true; } if (!$in && ArrayHelper::isIn($value, $this->range, $this->strict)) { $in = true; } return $this->not !== $in ? null : [$this->message, []]; }
/** * Return not default languages * @return array * */ public function getLanguagesList() { $languages = $this->languages; if (ArrayHelper::getValue($languages, $this->defaultLanguage)) { unset($languages[$this->defaultLanguage]); } else { if ($key = ArrayHelper::isIn($this->defaultLanguage, $languages)) { unset($languages[$key]); } } return $languages; }
public function onSucRow($event) { $row = $event->row; if (ArrayHelper::isIn($row['status'], ['공개', '유찰'])) { $bidkey = BidKey::findOne(['whereis' => '05', 'notinum' => $row['notinum'] . '-' . $row['subno']]); if ($bidkey !== null) { if ($row['status'] === '유찰' && $bidkey->bidproc === 'F') { return; } if ($row['status'] === '공개' && $bidkey->bidproc === 'S') { return; } $this->gman_client->doBackground('ebidlh_suc_work', Json::encode($row)); } } }
/** * Renders the option tags that can be used by [[dropDownList()]] and [[listBox()]]. * @param string|array|null $selection the selected value(s). String for single or array for multiple selection(s). * @param array $items the option data items. The array keys are option values, and the array values * are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). * For each sub-array, an option group will be generated whose label is the key associated with the sub-array. * If you have a list of data models, you may convert them into the format described above using * [[\yii\helpers\ArrayHelper::map()]]. * * Note, the values and labels will be automatically HTML-encoded by this method, and the blank spaces in * the labels will also be HTML-encoded. * @param array $tagOptions the $options parameter that is passed to the [[dropDownList()]] or [[listBox()]] call. * This method will take out these elements, if any: "prompt", "options" and "groups". See more details * in [[dropDownList()]] for the explanation of these elements. * * @return string the generated list options */ public static function renderSelectOptions($selection, $items, &$tagOptions = []) { $lines = []; $encodeSpaces = ArrayHelper::remove($tagOptions, 'encodeSpaces', false); $encode = ArrayHelper::remove($tagOptions, 'encode', true); if (isset($tagOptions['prompt'])) { $prompt = $encode ? static::encode($tagOptions['prompt']) : $tagOptions['prompt']; if ($encodeSpaces) { $prompt = str_replace(' ', ' ', $prompt); } $lines[] = static::tag('option', $prompt, ['value' => '']); } $options = isset($tagOptions['options']) ? $tagOptions['options'] : []; $groups = isset($tagOptions['groups']) ? $tagOptions['groups'] : []; unset($tagOptions['prompt'], $tagOptions['options'], $tagOptions['groups']); $options['encodeSpaces'] = ArrayHelper::getValue($options, 'encodeSpaces', $encodeSpaces); $options['encode'] = ArrayHelper::getValue($options, 'encode', $encode); foreach ($items as $key => $value) { if (is_array($value)) { $groupAttrs = isset($groups[$key]) ? $groups[$key] : []; if (!isset($groupAttrs['label'])) { $groupAttrs['label'] = $key; } $attrs = ['options' => $options, 'groups' => $groups, 'encodeSpaces' => $encodeSpaces, 'encode' => $encode]; $content = static::renderSelectOptions($selection, $value, $attrs); $lines[] = static::tag('optgroup', "\n" . $content . "\n", $groupAttrs); } else { $attrs = isset($options[$key]) ? $options[$key] : []; $attrs['value'] = (string) $key; if (!array_key_exists('selected', $attrs)) { $attrs['selected'] = $selection !== null && (!ArrayHelper::isTraversable($selection) && !strcmp($key, $selection) || ArrayHelper::isTraversable($selection) && ArrayHelper::isIn($key, $selection)); } $text = $encode ? static::encode($value) : $value; if ($encodeSpaces) { $text = str_replace(' ', ' ', $text); } $lines[] = static::tag('option', $text, $attrs); } } return implode("\n", $lines); }
public function i2conv_run($job) { $workload = $job->workload(); $workload = Json::decode($workload); try { $this->module->i2db->close(); $this->module->infodb->close(); $bidKey = BidKey::findOne($workload['bidid']); if ($bidKey === null) { return; } $bidvalue = $bidKey->bidValue; if ($bidvalue === null) { return; } if (!ArrayHelper::isIn($bidKey->state, ['Y', 'N', 'D'])) { return; } if ($bidKey->bidproc === 'J') { return; } if (empty($bidKey->location)) { return; } switch ($bidKey->bidtype) { case 'con': echo Console::renderColoredString('%y[공사]%n'); break; case 'ser': echo Console::renderColoredString('%g[용역]%n'); break; case 'pur': echo Console::renderColoredString('%b[구매]%n'); break; default: return; } echo $bidKey->constnm; echo '[' . $bidKey->notinum . ']'; echo '(' . $bidKey->state . ',' . $bidKey->bidproc . ')'; //------------------------------------------------------ // v3_bid_key //------------------------------------------------------ $v3bidkey = V3BidKey::findNew($bidKey->bidid); $this->stdout($v3bidkey->isNewRecord ? "[NEW]\n" : "\n", Console::FG_RED); $v3bidkey->attributes = ['whereis' => $bidKey->whereis, 'bidtype' => $bidKey->bidtype, 'con' => strpos($bidKey->bidview, 'con') === false ? 'N' : 'Y', 'ser' => strpos($bidKey->bidview, 'ser') === false ? 'N' : 'Y', 'pur' => strpos($bidKey->bidview, 'pur') === false ? 'N' : 'Y', 'notinum' => $bidKey->notinum, 'orgcode' => $bidKey->orgcode_i, 'constnm' => $bidKey->constnm, 'org' => $bidKey->org_i, 'bidproc' => $bidKey->bidproc, 'contract' => $bidKey->contract, 'bidcls' => $bidKey->bidcls, 'succls' => $bidKey->succls, 'conlevel' => $bidKey->toV3BidKey_conlevel(), 'ulevel' => $bidKey->opt, 'concode' => $bidKey->toV3BidKey_concode(), 'sercode' => $bidKey->toV3BidKey_sercode(), 'purcode' => $bidKey->toV3BidKey_purcode(), 'location' => $bidKey->location ? $bidKey->location : 0, 'convention' => $bidKey->convention == '3' ? '2' : $bidKey->convention, 'presum' => $bidKey->presum ? $bidKey->presum : 0, 'basic' => $bidKey->basic ? $bidKey->basic : 0, 'pct' => $bidKey->pct ? $bidKey->pct : '', 'registdate' => strtotime($bidKey->registdt) > 0 ? date('Y-m-d', strtotime($bidKey->registdt)) : '', 'explaindate' => strtotime($bidKey->explaindt) > 0 ? date('Y-m-d', strtotime($bidKey->explaindt)) : '', 'agreedate' => strtotime($bidKey->agreedt) > 0 ? date('Y-m-d', strtotime($bidKey->agreedt)) : '', 'opendate' => strtotime($bidKey->opendt) > 0 ? date('Y-m-d', strtotime($bidKey->opendt)) : '', 'closedate' => strtotime($bidKey->closedt) > 0 ? date('Y-m-d', strtotime($bidKey->closedt)) : '', 'constdate' => strtotime($bidKey->constdt) > 0 ? date('Y-m-d', strtotime($bidKey->constdt)) : '', 'writedate' => strtotime($bidKey->writedt) > 0 ? date('Y-m-d', strtotime($bidKey->writedt)) : '', 'reswdate' => strtotime($bidKey->resdt) > 0 ? date('Y-m-d', strtotime($bidKey->resdt)) : '', 'state' => $bidKey->state, 'in_id' => 91]; //------------------------------------------------------ // v3_bid_value //------------------------------------------------------ $v3BidValue = V3BidValue::findNew($v3bidkey->bidid); $v3BidValue->attributes = ['scrcls' => $bidvalue->scrcls, 'scrid' => $bidvalue->scrid, 'constno' => $bidvalue->constno, 'refno' => $bidvalue->refno, 'realorg' => $bidvalue->realorg, 'yegatype' => $bidvalue->yegatype, 'yegarng' => str_replace('|', '/', $bidvalue->yegarng), 'prevamt' => $bidvalue->prevamt, 'parbasic' => $bidvalue->parbasic, 'lvcnt' => $bidvalue->lvcnt, 'charger' => str_replace('|', '/', $bidvalue->charger), 'multispare' => str_replace('|', '/', str_replace(',', '', $bidvalue->multispare)), 'contper' => $bidvalue->contper, 'noticedt' => strtotime($bidKey->noticedt) > 0 ? strtotime($bidKey->noticedt) : 0, 'registdt' => strtotime($bidKey->registdt) > 0 ? strtotime($bidKey->registdt) : 0, 'explaindt' => strtotime($bidKey->explaindt) > 0 ? strtotime($bidKey->explaindt) : 0, 'agreedt' => strtotime($bidKey->agreedt) > 0 ? strtotime($bidKey->agreedt) : 0, 'opendt' => strtotime($bidKey->opendt) > 0 ? strtotime($bidKey->opendt) : 0, 'closedt' => strtotime($bidKey->closedt) > 0 ? strtotime($bidKey->closedt) : 0, 'constdt' => strtotime($bidKey->constdt) > 0 ? strtotime($bidKey->constdt) : 0, 'writedt' => strtotime($bidKey->writedt) > 0 ? strtotime($bidKey->writedt) : 0, 'editdt' => strtotime($bidKey->editdt) > 0 ? strtotime($bidKey->editdt) : 0]; //공동도급지역코드 (사용하나??) $arr = explode('|', $bidvalue->contloc); foreach ($arr as $val) { if (empty($val)) { continue; } $m = BidLocal::findOne(['bidid' => $v3bidkey->bidid, 'name' => iconv('utf-8', 'euckr', $val)]); if ($m !== null) { $v3BidValue->contloc = $m->code; break; //v3_bid_key.contloc char(4) 때문 1개 지역만 처리... } } //------------------------------------------------------ // v3_bid_itemcode //------------------------------------------------------ V3BidItemcode::deleteAll(['bidid' => $v3bidkey->bidid]); $bidItemcodes = $bidKey->toV3BidItemcodes_attributes(); foreach ($bidItemcodes as $row) { $v3BidItemcode = V3BidItemcode::findNew($v3bidkey->bidid, $row['bidtype'], $row['code']); $v3BidItemcode->name = $row['name']; $v3BidItemcode->save(); } //------------------------------------------------------ // v3_bid_local //------------------------------------------------------ V3BidLocal::deleteAll(['bidid' => $v3bidkey->bidid]); $bidlocals = $bidKey->bidLocals; foreach ($bidlocals as $bidlocal) { $v3BidLocal = new V3BidLocal(['bidid' => $v3bidkey->bidid, 'code' => $bidLocal->code, 'name' => $bidLocal->name]); $v3BidLocal->save(); } //------------------------------------------------------ // v3_bid_subcode //------------------------------------------------------ V3BidSubcode::deleteAll(['bidid' => $v3bidkey->bidid]); $subcodes = $bidKey->bidSubcodes; foreach ($subcodes as $subcode) { $v3BidSubcode = new V3BidSubcode(['bidid' => $v3bidkey->bidid, 'g2b_code' => $subcode->g2b_code, 'g2b_code_nm' => $subcode->g2b_code_nm, 'i2_code' => $subcode->i2_code, 'itemcode' => $subcode->itemcode, 'pri_cont' => $subcode->pri_cont, 'share' => $subcode->share]); $v3BidSubcode->save(); } //------------------------------------------------------- // v3_bid_content //------------------------------------------------------- $bidcontent = $bidKey->bidContent; if ($bidcontent !== null) { $v3content = V3BidContent::findNew($v3bidkey->bidid); $v3content->attributes = ['content_bid' => $bidcontent->bid_html, 'important_suc' => $bidcontent->nbidcomment, 'content_suc' => $bidcontent->nbid_html, 'upfile_bid' => $bidcontent->bid_file, 'upfile_suc' => $bidcontent->nbid_file, 'important_bid' => !empty($bidcontent->bidcomment_mod) ? $bidcontent->bidcomment_mod . '\\n<hr/>\\n' . $bidcontent->bidcomment : $bidcontent->bidcomment]; $v3content->save(); $v3BidValue->origin_lnk = $bidcontent->orign_lnk; $v3BidValue->attchd_lnk = $bidcontent->attchd_lnk; } //----------------------------------------------------- // v3_bid_goods //----------------------------------------------------- $bidGoods = $bidKey->bidGoods; V3BidGoods::deleteAll(['bidid' => $v3bidkey->bidid]); foreach ($bidGoods as $g) { $v3BidGood = new V3BidGoods(); $v3BidGood->attributes = $g->attributes; $v3BidGood->save(); } //------------------------------------------------------- // v3_bid_res,v3_bid_succom //------------------------------------------------------- $bidRes = $bidKey->bidRes; if (ArrayHelper::isIn($bidKey->bidproc, ['S', 'F']) && $bidRes !== null) { $v3BidResult = V3BidResult::findNew($v3bidkey->bidid); $v3BidResult->attributes = ['yega' => $bidRes->yega, 'innum' => $bidRes->innum, 'officenm1' => $bidRes->officenm1, 'prenm1' => $bidRes->prenm1, 'officeno1' => $bidRes->officeno1, 'success1' => $bidRes->success1, 'resdt' => strtotime($bidKey->resdt) > 0 ? strtotime($bidKey->resdt) : 0, 'reswdt' => strtotime($bidRes->reswdt) > 0 ? strtotime($bidRes->reswdt) : 0]; $arr = explode('|', $bidRes->selms); $selms = []; foreach ($arr as $v) { if ($v == '') { continue; } $selms[] = intval($v) - 1; } $v3BidResult->selms = implode('-', $selms); $v3BidResult->save(); if ($bidKey->whereis != '08' && $bidKey->bidproc != 'F') { $v3BidValue->multispare = str_replace('|', '/', str_replace(',', '', $bidRes->multispare)); } $v3BidValue->save(); if ($bidRes->innum > 0) { $succoms = $bidKey->succoms; if (count($succoms) == $bidRes->innum) { V3BidSuccom::deleteAll(['constdate' => $v3bidkey->constdate, 'bidid' => $v3bidkey->bidid]); Console::startProgress(0, $bidRes->innum); $n = 1; foreach ($succoms as $s) { $v3succom = V3BidSuccom::findNew($v3bidkey->constdate, $v3bidkey->bidid, $s->seq); $v3succom = new V3BidSuccom(['constdate' => $v3bidkey->constdate, 'bidid' => $v3bidkey->bidid, 'seq' => $s->seq, 'regdt' => strtotime($s->regdt) > 0 ? strtotime($s->regdt) : 0, 'pct' => $s->pct, 'prenm' => $s->prenm == null ? '' : $s->prenm, 'officenm' => $s->officenm, 'officeno' => $s->officeno, 'success' => $s->success, 'etc' => $s->etc, 'rank' => $s->rank]); $v3succom->save(); Console::updateProgress($n, $bidRes->innum); $n++; } Console::endProgress(); } } } $v3BidValue->save(); $v3bidkey->save(); $gman_client = new GearmanClient(); $gman_client->addServers($this->module->gman_server); $gman_client->doBackground('i2conv_legacy', Json::encode($workload)); } catch (\Exception $e) { echo Console::ansiFormat($e, [Console::FG_RED]), PHP_EOL; Yii::error($e, 'i2conv'); $gman_client = new GearmanClient(); $gman_client->addServers('192.168.1.242'); $gman_client->doBackground('send_chat_message_from_admin', Json::encode(['recv_id' => 149, 'message' => iconv('cp949', 'utf-8', $e) . "\n[i2conv]"])); } $this->stdout(sprintf("[%s] Peak memory usage: %s MB\n", date('Y-m-d H:i:s'), memory_get_peak_usage(true) / 1024 / 1024), Console::FG_GREY); }
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 work($job) { \Yii::info('[' . __METHOD__ . '] $workload' . PHP_EOL . VarDumper::dumpAsString($job->workload()), 'kwater'); $workload = Json::decode($job->workload()); $http = new \kwater\Http(); $data = []; try { if (empty($workload['notinum'])) { throw new \Exception('notinum is empty'); } if (empty($workload['bidtype'])) { throw new \Exception('bidtype is empty'); } $data['org_i'] = '한국수자원공사'; if ($workload['realorg']) { $data['org_i'] .= ' ' . str_replace('관리처', '지역본부', $workload['realorg']); } $data['notinum'] = $workload['notinum']; switch ($workload['bidtype']) { case '공사': $data['bidtype'] = 'con'; $data['bidview'] = 'con'; break; case '용역': $data['bidtype'] = 'ser'; $data['bidview'] = 'ser'; break; default: $data['bidtype'] = 'pur'; $data['bidview'] = 'pur'; } $html = $http->request('GET', static::URL, ['query' => ['BidNo' => $workload['notinum']]]); $thml = strip_tags($html, '<tr><td><a>'); $html = preg_replace('/<tr[^>]*>/', '<tr>', $html); $html = preg_replace('/<td[^>]*>/', '<td>', $html); $html = str_replace(' ', '', $html); $data['attchd_lnk'] = $this->attchd_lnk($html); $html = strip_tags($html, '<tr><td>'); //echo $html,PHP_EOL; $data['constnm'] = $this->constnm($html); $contract = $this->contract($html); if ($contract == '소액전자') { $data['contract'] = '40'; } $succls = $this->succls($html); switch ($succls) { case '적격심사': $data['succls'] = '01'; break; case '최저가': $data['succls'] = '02'; break; default: $data['succls'] = '00'; } $data['registdt'] = $this->registdt($html); $data['multispare'] = $this->multispare($html); $data['constdt'] = $this->constdt($html); //$data['bidcomment']=$this->bidcomment($thml); $data['charger'] = $this->charger($html); $data = ArrayHelper::merge($data, $this->closedt($html)); $convention = $this->convention($html); $data['convention'] = '0'; if (ArrayHelper::isIn($convention['convention1'], ['가능', '공동'])) { $data['convention'] = '2'; } if (ArrayHelper::isIn($convention['convention2'], ['가능', '공동'])) { $data['convention'] = '2'; } $data['orign_lnk'] = 'http://ebid.kwater.or.kr/fz?bidno=' . $workload['notinum']; $data['noticedt'] = $this->noticedt($html); $data['basic'] = $this->basic($html); $data['pqdt'] = $this->pqdt($html); //현장설명회 if ($data['pqdt']) { $data['bidcomment'] = 'PQ심사신청서 신청기한 : ' . $data['pqdt'] . '<hr>'; $data['succls'] = '05'; } $event = new \kwater\WatchEvent(); $event->row = $data; $this->trigger(\kwater\WatchEvent::EVENT_ROW, $event); } catch (\Exception $e) { echo Console::renderColoredString("%r{$e}%n"), PHP_EOL; \Yii::error($e, 'kwater'); } $this->module->db->close(); echo sprintf("[%s] Peak memory usage: %sMb\n", date('Y-m-d H:i:s'), memory_get_peak_usage(true) / 1024 / 1024); sleep(1); }
protected function _action_params() { $action_params = Yii::$app->request->queryParams; if ($this->_view() && isset($this->actions[$this->_view()])) { $action_param = $this->actions[$this->_view()]; foreach ($action_params as $key => $value) { if (is_null($value) || $value == '' || !ArrayHelper::isIn($key, $action_param)) { unset($action_params[$key]); } } } $action_params = Json::encode($action_params); return $action_params; }
public function actionSuc() { $con = new SucWatcherCon(); $ser = new SucWatcherSer(); $pur = new SucWatcherPur(); while (true) { $start = date('Ymd', strtotime('-1 month')); $end = date('Ymd'); try { $con->watch($start, $end, function ($row) { $this->stdout2("도로> %y[공사낙찰]%n {$row['notinum']} {$row['constnm']} ({$row['local']},{$row['multi']},{$row['bidproc']})"); $bidkey = $this->findBidKey($row); if ($bidkey === null) { $this->stdout2(" %rERROR%n\n"); return; } $this->stdout2(" [{$bidkey->bidproc}]"); if (ArrayHelper::isIn($row['bidproc'], ['유찰', '재공고']) and $bidkey->bidproc == 'F') { $this->stdout("\n"); return; } else { if ($bidkey->bidproc == 'S') { $this->stdout("\n"); return; } } $this->stdout2(" %yNEW%n\n"); sleep(1); $this->gman_client->doNormal('ebidex_work_suc_con', Json::encode($row)); }); $ser->watch($start, $end, function ($row) { $this->stdout2("도로> %g[용역낙찰]%n {$row['notinum']} {$row['constnm']} ({$row['local']},{$row['multi']},{$row['bidproc']})"); $bidkey = $this->findBidKey($row); if ($bidkey === null) { $this->stdout2(" %rERROR%n\n"); return; } $this->stdout2(" [{$bidkey->bidproc}]"); if (ArrayHelper::isIn($row['bidproc'], ['유찰', '재공고']) and $bidkey->bidproc == 'F') { $this->stdout("\n"); return; } else { if ($bidkey->bidproc == 'S') { $this->stdout("\n"); return; } } $this->stdout2(" %yNEW%n\n"); sleep(1); $this->gman_client->doNormal('ebidex_work_suc_ser', Json::encode($row)); }); $pur->watch($start, $end, function ($row) { $this->stdout2("도로> %b[구매낙찰]%n {$row['notinum']} {$row['constnm']} ({$row['local']},{$row['multi']},{$row['bidproc']})"); $bidkey = $this->findBidKey($row); if ($bidkey === null) { $this->stdout2(" %rERROR%n\n"); return; } $this->stdout2(" [{$bidkey->bidproc}]"); if (ArrayHelper::isIn($row['bidproc'], ['유찰', '재공고']) and $bidkey->bidproc == 'F') { $this->stdout("\n"); return; } else { if ($bidkey->bidproc == 'S') { $this->stdout("\n"); return; } } $this->stdout2(" %yNEW%n\n"); $this->gman_client->doNormal('ebidex_work_suc_pur', Json::encode($row)); sleep(1); }); } catch (\Exception $e) { $this->stdout("{$e}\n", Console::FG_RED); \Yii::error($e, 'ebidex'); } $this->stdout(sprintf("[%s] Peak memory usage: %s MB\n", date('Y-m-d H:i:s'), memory_get_peak_usage(true) / 1024 / 1024), Console::FG_GREY); sleep(mt_rand(5, 10)); } }
public function actionAction() { if (User::hasRole('admin')) { //\Yii::trace('### ### ### Тест лога'); //Проверяем был ли выбрана комманда $ids = Yii::$app->request->post('ActionForm'); //\Yii::trace(Yii::$app->request->post('ActionForm')); //Проверяем, выбран ли пустой id, если да, то как будто только открыли if ($ids and ArrayHelper::isIn('', $ids)) { $ids = null; } //Для проверки отправки запроса получаем значение $page = Yii::$app->request->post('adr'); if ($ids) { //Если выбран ID $model = $this->findModel($ids); return $this->render('action', ['model' => $model, 'ghide' => 1, 'gadr' => '10.24.2.188', 'guser' => '', 'gpass' => '', 'gid' => $model->id, 'gcommand' => $model->actionstring, 'gparams' => $model->params, 'pagein' => '', 'pageout' => '']); } elseif ($page) { //Если отправлен запрос $ids = Yii::$app->request->post('id'); $model = $this->findModel($ids); $vagon = new Vagon(); $pagein = 'http://' . Yii::$app->request->post('adr') . '/crq?req=' . Yii::$app->request->post('string') . '&' . Yii::$app->request->post('params'); $user = Yii::$app->request->post('user'); $pass = Yii::$app->request->post('pass'); return $this->render('action', ['model' => $model, 'ghide' => 2, 'gadr' => Yii::$app->request->post('adr'), 'guser' => $user, 'gpass' => $pass, 'gid' => $model->id, 'gcommand' => Yii::$app->request->post('string'), 'gparams' => Yii::$app->request->post('params'), 'pagein' => $pagein, 'pageout' => $vagon->getCurlOut($pagein, $user, $pass)]); } else { //Если форму только открыли return $this->render('action', ['model' => new ActionForm(), 'ghide' => 0, 'gadr' => '', 'guser' => '', 'gpass' => '', 'gid' => '', 'gcommand' => '', 'gparams' => '', 'pagein' => '', 'pageout' => '']); } } else { throw new NotFoundHttpException('Страница не найдена.'); } }
$objectProperty = $model_object_property->theObjectProperty; $property = $model_object_property->property; if (!ArrayHelper::isIn($objectProperty->id, $parentData)) { if ($property->formTypePresentation($service->object_ownership) != null) { echo $this->render('objectProperty/' . $property->formTypePresentation($service->object_ownership) . '.php', ['form' => $form, 'index' => $index, 'model_object_property' => $model_object_property, 'objectProperty' => $objectProperty, 'property' => $property, 'service' => $service]); echo Html::activeHiddenInput($model_object_property, 'checkUserObject', ['id' => 'checkUserObject_model_spec' . $property->id]); //echo Html::activeHiddenInput($model_object_property, '['.$index.']spec_id', ['value'=>$objectProperty->id]); } } } echo '<h5 class="col-sm-offset-3 gray-color"><hr>' . c($parent->tName) . '</h5>'; echo '<p class="col-sm-offset-3 hint margin-bottom-20">Opišite i detalje ' . $parent->tNameGen . ', kao celine.</p>'; foreach ($model_object_properties as $index => $model_object_property) { $objectProperty = $model_object_property->theObjectProperty; $property = $model_object_property->property; if (ArrayHelper::isIn($objectProperty->id, $parentData)) { if ($property->formTypePresentation($service->object_ownership) != null) { echo $this->render('objectProperty/' . $property->formTypePresentation($service->object_ownership) . '.php', ['form' => $form, 'index' => $index, 'model_object_property' => $model_object_property, 'objectProperty' => $objectProperty, 'property' => $property, 'service' => $service]); echo Html::activeHiddenInput($model_object_property, 'checkUserObject', ['id' => 'checkUserObject_model_spec' . $property->id]); //echo Html::activeHiddenInput($model_object_property, '['.$index.']spec_id', ['value'=>$objectProperty->id]); } } } } else { // ako objekat nije part foreach ($model_object_properties as $index => $model_object_property) { $objectProperty = $model_object_property->theObjectProperty; $property = $model_object_property->property; if ($property->formTypePresentation($service->object_ownership) != null) { echo $this->render('objectProperty/' . $property->formTypePresentation($service->object_ownership) . '.php', ['form' => $form, 'index' => $index, 'model_object_property' => $model_object_property, 'objectProperty' => $objectProperty, 'property' => $property, 'service' => $service]); echo Html::activeHiddenInput($model_object_property, 'checkUserObject', ['id' => 'checkUserObject_model_spec' . $property->id]);
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); } }
foreach ($model_specs as $index => $model_spec) { $specification = $model_spec->specification; $property = $model_spec->property; if (!ArrayHelper::isIn($specification->id, $parentData)) { if ($property->formTypePresentation($service->service_object) != null) { echo $this->render('specification/' . $property->formTypePresentation($service->service_object) . '.php', ['form' => $form, 'index' => $index, 'model_spec' => $model_spec, 'specification' => $specification, 'property' => $property, 'service' => $service, 'input' => Yii::$app->request->get('PresentationSpecs')]); echo Html::activeHiddenInput($model_spec, '[' . $index . ']spec_id', ['value' => $specification->id]); } } } echo '<h5 class="col-sm-offset-3 gray-color"><hr>' . c($parent->tName) . '</h5>'; echo '<p class="col-sm-offset-3 hint margin-bottom-20">Opišite i detalje ' . $parent->tNameGen . ', kao celine.</p>'; foreach ($model_specs as $index => $model_spec) { $specification = $model_spec->specification; $property = $model_spec->property; if (ArrayHelper::isIn($specification->id, $parentData)) { if ($property->formTypePresentation($service->service_object) != null) { echo $this->render('specification/' . $property->formTypePresentation($service->service_object) . '.php', ['form' => $form, 'index' => $index, 'model_spec' => $model_spec, 'specification' => $specification, 'property' => $property, 'service' => $service, 'input' => Yii::$app->request->get('PresentationSpecs')]); echo Html::activeHiddenInput($model_spec, '[' . $index . ']spec_id', ['value' => $specification->id]); } } } } else { // ako objekat nije part foreach ($model_specs as $index => $model_spec) { $specification = $model_spec->specification; $property = $model_spec->property; if ($property->formTypePresentation($service->service_object) != null) { echo $this->render('specification/' . $property->formTypePresentation($service->service_object) . '.php', ['form' => $form, 'index' => $index, 'model_spec' => $model_spec, 'specification' => $specification, 'property' => $property, 'service' => $service, 'input' => Yii::$app->request->get('PresentationSpecs')]); echo Html::activeHiddenInput($model_spec, '[' . $index . ']spec_id', ['value' => $specification->id]); }
/** * @param $event * @return array */ public function getFields($event) { $class = $this->getEventClassValue($event); if ($class == null) { return []; } /** @var Model $model */ $model = new $class(); $class = $this->replaceNamespace($class); $fields = []; if (!$model instanceof Model) { return []; } $this->getFieldsByAttributes($fields, $class, $model); // check in related model if (ArrayHelper::isIn($event, array_keys($this->_eventsWithRelatedModels))) { foreach ($this->_eventsWithRelatedModels[$event] as $relatedModel) { $method = 'get' . ucfirst($relatedModel); $query = $model->{$method}(); if ($query instanceof ActiveQuery) { $model = new $query->modelClass(); $this->getFieldsByAttributes($fields, $this->replaceNamespace($query->modelClass), $model); } } } // check in closure if (ArrayHelper::isIn($event, array_keys($this->_eventsWithClosure))) { foreach ($this->_eventsWithClosure[$event] as $attributes) { foreach (array_keys($attributes) as $attribute) { $fields[] = '\\Closure' . $this->classNameKeySeparator . $attribute; } } } return array_unique($fields); }
private function update_pur($v3key) { $workload = $this->_workload; if (empty($v3key->writedate) or $v3key->writedate == '0000-00-00') { return; } $v3val = $v3key->v3BidValue; $keyid = $v3val->keyid; list($bidno, $bidseq, $rebidno, $divno) = explode('-', $v3key->bidid); $subseq = intval($bidseq); $pm = PurMaster::findOne(['id' => $keyid, 'subseq' => $subseq]); if ($pm === null or $keyid == 0) { $pm = new PurMaster(); $idstart = str_replace('-', '', $v3key->writedate); $idstart . '0000'; $id = (new Query())->from('pur_master')->where("id > :idstart", [':idstart' => $idstart])->max('id', PurMaster::getDb()); if (empty($id)) { $id = $idstart; } $pm->id = $id + 1; $pm->subseq = $subseq; } $pm->attributes = ['notinum' => $v3key->notinum, 'constname' => $v3key->constnm, 'org' => $v3key->org, 'gesi_dt' => $v3val->noticedt, 'explain_dt' => $v3val->explaindt, 'ibchalgesi_dt' => $v3val->opendt, 'ibchalmagam_dt' => $v3val->closedt, 'ibchal_dt' => $v3val->constdt, 'chamgamagam_dt' => $v3val->registdt, 'write_dt' => $v3val->writedt, 'presum' => $v3key->presum, 'basic' => $v3key->basic, 'pct' => $v3key->pct, 'itemcode' => $v3key->purcode, 'location' => $v3key->location, 'state' => $v3key->state, 'register' => 'i2conv', 'islast' => 'Y', 'org_code' => $v3key->orgcode]; if (empty($pm->chamgamagam_dt) or $v3key->whereis === '01') { $pm->chamgamagam_dt = $pm->ibchalmagam_dt; } switch ($v3key->contract) { case '10': $pm->constract = '일반'; break; case '20': $pm->constract = '제한'; break; case '40': $pm->constract = '수의'; break; case '70': $pm->constract = '역경매'; break; case '80': $pm->constract = '실적'; break; default: $pm->constract = ''; } switch ($v3key->bidcls) { case '00': $pm->ibchalbangsik = '직찰'; break; case '01': $pm->ibchalbangsik = '전자입찰'; break; default: $pm->ibchalbangsik = ''; } $cmtopts = []; if (($v3key->ulevel & pow(2, 2)) > 0) { $cmtopts[] = '긴급'; } if (($v3key->ulevel & pow(2, 11)) > 0) { $cmtopts[] = '관내'; } $pm->commentoption = implode(',', $cmtopts); switch ($v3key->bidproc) { case 'B': $pm->dataprocess = 'GEN'; break; case 'C': $pm->dataprocess = 'CANCEL'; break; default: $pm->dataprocess = 'MOD'; } if (!ArrayHelper::isIn($v3key->bidproc, ['S', 'F']) && intval($rebidno) > 0) { $pm->isjeibchal = 'Y'; } switch ($v3key->whereis) { case '01': $pm->whereis = 'G2B'; break; case '08': $pm->whereis = 'EX'; break; case '03': $pm->whereis = 'KEPCO'; break; case '10': $pm->whereis = 'DPA'; break; case '96': $pm->whereis = 'KHNP'; break; case '52': $pm->whereis = 'KR'; break; default: $pm->whereis = 'ETC'; } $v3bidgoods = V3BidGoods::findAll(['bidid' => $v3key->bidid]); $pm->goods_cnt = count($v3bidgoods); $v3bidlocals = $v3key->v3BidLocals; $lockeywords = []; foreach ($v3bidlocals as $v3bidlocal) { $a = explode(' ', $v3bidlocal->name); $lockeywords[] = array_pop($a); } $pm->lockeyword = implode(',', $lockeywords); $pm->save(); $v3ctn = $v3key->v3BidContent; //---------------------------------------------- // pur_file_data //---------------------------------------------- $pfd = $pm->purFileData; if ($pfd === null) { $pfd = new PurFileData(['id' => $pm->id, 'subseq' => $pm->subseq]); } if ($v3ctn !== null) { $pfd->attributes = ['filedata1' => $v3ctn->upfile_bid, 'jungjungdata' => $v3ctn->important_bid, 'maincontents' => $v3ctn->content_bid, 'openbid_contents' => $v3ctn->content_suc]; } $pfd->urlinfo1 = $v3val->origin_lnk; $pfd->linkdata = $v3val->attchd_lnk; $pfd->save(); //---------------------------------------------- // pur_g2b_goods //---------------------------------------------- $v3goods = $v3key->v3BidGoods; foreach ($v3goods as $g) { $pgg = PurG2bGoods::findOne(['notinum' => $v3key->notinum, 'bunryu_no' => 1, 'sunbun_no' => $g->seq]); if ($pgg === null) { $pgg = new PurG2bGoods(['notinum' => $v3key->notinum, 'bunryu_no' => 1, 'sunbun_no' => $g->seq]); } $pgg->attributes = ['info_code' => 0, 'info_name' => '', 'g2b_code' => $g->gcode, 'g2b_myung' => $g->gname]; $pgg->save(); } //--------------------------------------------- // pur_res //--------------------------------------------- $v3res = $v3key->v3BidResult; if ($v3res !== null and ArrayHelper::isIn($v3key->bidproc, ['R', 'S', 'F'])) { $pres = PurRes::findOne(['id' => $pm->id, 'notinum' => $pm->notinum, 'bunryuno' => 1]); if ($pres === null) { $pres = new PurRes(['id' => $pm->id, 'notinum' => $pm->notinum, 'bunryuno' => 1]); } $pres->attributes = ['jeibchal_bunho' => intval($rebidno), 'rs_selected_num' => $v3res->selms, 'rs_gechal_ilsi' => $v3res->resdt, 'yega' => $v3res->yega, 'gichoamt' => $v3key->basic]; switch ($v3key->bidproc) { case 'R': $pres->process = 'REBID'; break; case 'F': $pres->process = 'YUCHAL'; break; default: $pres->process = 'DONE'; } $ms = explode('/', $v3val->multispare); if (isset($ms[0])) { $pres->rs_yega1 = $ms[0]; } if (isset($ms[1])) { $pres->rs_yega2 = $ms[1]; } if (isset($ms[2])) { $pres->rs_yega3 = $ms[2]; } if (isset($ms[3])) { $pres->rs_yega4 = $ms[3]; } if (isset($ms[4])) { $pres->rs_yega5 = $ms[4]; } if (isset($ms[5])) { $pres->rs_yega6 = $ms[5]; } if (isset($ms[6])) { $pres->rs_yega7 = $ms[6]; } if (isset($ms[7])) { $pres->rs_yega8 = $ms[7]; } if (isset($ms[8])) { $pres->rs_yega9 = $ms[8]; } if (isset($ms[9])) { $pres->rs_yega10 = $ms[9]; } if (isset($ms[10])) { $pres->rs_yega11 = $ms[10]; } if (isset($ms[11])) { $pres->rs_yega12 = $ms[11]; } if (isset($ms[12])) { $pres->rs_yega13 = $ms[12]; } if (isset($ms[13])) { $pres->rs_yega14 = $ms[13]; } if (isset($ms[14])) { $pres->rs_yega15 = $ms[14]; } switch ($v3key->bidproc) { case 'F': case 'S': $pm->sucprocess = 'Y'; break; case 'R': $pm->isjeibchal = 'Y'; break; } $pm->successamt = $v3res->success1; $pm->successname = $v3res->officenm1; $pres->save(); if ($v3key->bidproc === 'S') { $v3succoms = V3BidSuccom::findAll(['constdate' => $v3key->constdate, 'bidid' => $v3key->bidid]); PurResEnterprise::deleteAll(['id' => $pm->id]); $innum = count($v3succoms); $n = 1; Console::startProgress(0, $innum); foreach ($v3succoms as $s) { $pen = new PurResEnterprise(['id' => $pm->id, 'saupja_bunho' => $s->officeno, 'notinum' => $pm->notinum, 'sunwi' => $s->rank, 'upche_myung' => $s->officenm, 'depyoja' => $s->prenm, 'tuchal_gumek' => $s->success, 'tuchal_ryul' => $s->pct, 'bigo' => $s->etc, 'bunryuno' => 1]); $pen->save(); Console::updateProgress($n, $innum); $n++; } Console::endProgress(); } } if ($v3val->keyid != $pm->id) { $v3val->keyid = $pm->id; $v3val->save(); } }