/** * set date type */ public function _setFlashType($type) { $aTmpField = array(); $aDate = $this->aInput['date']; if (count($aDate) > 1) { $this->aInput['input'][$type]['type'] = 'multDate'; } else { if ($type == 'flash') { $aTables = $this->aInput['input']['flash']['table']; if (is_array($aTables)) { foreach ($aTables as $aTable) { foreach ($aTable['metric'] as $aMetric) { if ($aMetric['show']) { $aTmpField[] = $aMetric['key']; } } break; } } if (count($aTmpField) > 1) { $this->aInput['input'][$type]['type'] = 'multMetric'; } } } \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); }
public function preStart() { $aInput = $this->aInput['input'][$this->_type]['table']; //检查 横向维度 并初始化:将xdimen加入到dimen $i = 1; foreach ($aInput as $table => $aTable) { if ($i == 1) { if (empty($aTable['xdimen']) || count($aTable['xdimen']) != 1) { throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'need xdimen,and just one xdimen'); } $aInput[$table]['dimen'] = array_merge($aTable['dimen'], $aTable['xdimen']); foreach ($aTable['xdimen'] as $v) { $aInput[$table]['xdimen_key'][] = $v['key']; } foreach ($aTable['dimen'] as $v) { if (!(isset($v['group']) && false == $v['group'])) { //去重 if (empty($aInput[$table]['ydimen_key']) || !in_array($v['key'], $aInput[$table]['ydimen_key'])) { $aInput[$table]['ydimen_key'][] = $v['key']; } $aInput[$table]['ydimen_key_select'][$v['key']] = $v['selected'] ? $v['selected'] : $v['key']; } } } $i++; //$aInput[$table]['xdimen'][] = $aTable['xdimen'][] } $this->aInput['input'][$this->_type]['table'] = $aInput; \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); }
function go() { $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput(); $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput(); $trendType = $aInput['input']['flash']['type'] = isset($aInput['input']['flash']['type']) ? $aInput['input']['flash']['type'] : "trend"; $xmlDataEntity = ""; if ('bubble' == $trendType) { $xmlDataEntity .= "\n\r<bubble>"; foreach ($aOutput['flash'] as $i => $aTmp) { $xmlDataEntity .= "\n\r<entity>\n"; $xmlDataEntity .= "<column>" . $i . "</column>\n"; foreach ($aTmp as $date => $aTmp2) { $xmlDataEntity .= "<column>" . $aTmp2 . "</column>"; } $xmlDataEntity .= "\n</entity>"; } $xmlDataEntity .= "\n\r</bubble>"; } else { foreach ($aOutput['flash'] as $i => $aTmp) { $xmlDataEntity .= "\n\r<trend>"; foreach ($aTmp as $date => $aTmp2) { $xmlDataEntity .= "\n\r<entity>\n"; $xmlDataEntity .= "<column>" . $date . "</column>\n"; $xmlDataEntity .= "<column>" . current(array_values($aTmp2)) . "</column>"; $xmlDataEntity .= "\n</entity>"; } $xmlDataEntity .= "\n\r</trend>"; } } $aOutput['flash.output'] = "<flash>\n\n" . $xmlDataEntity . "</flash>\n\n"; \YcheukfReport\Lib\ALYS\Report\Start::setInput($aInput); \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput); }
/** *扩展父类中的输入参数 */ public function fmtInput() { parent::fmtInput(); $type = 'flash'; $aDefaultIndex = array(); for ($i = 0; $i < $this->aInput['input']['detail']['page']['total']; $i++) { $aDefaultIndex[] = $i; } if (isset($this->aInput['input'][$type]['sort_indexs'])) { //用户传递了列表的参数 $this->aInput['input'][$type]['sort_indexs'] = count($this->aInput['input'][$type]['sort_indexs']) < $this->aInput['input']['detail']['page']['total'] ? $this->aInput['input'][$type]['sort_indexs'] : $aDefaultIndex; } else { //默认 $this->aInput['input'][$type]['sort_indexs'] = $this->aInput['input']['detail']['page']['total'] > 4 ? array(0, 1, 2, 3, 4) : $aDefaultIndex; } //初始化 sort模式下的几个默认选中排列项目 $this->aInput['input'][$type]['sort_totalflag'] = isset($this->aInput['input'][$type]['sort_totalflag']) ? $this->aInput['input'][$type]['sort_totalflag'] : 0; \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); // var_export($this->aInput['input']['detail']['page']['total']); }
/** * 格式小数位数等 */ public function _formatMetric($type) { $aMainTable = $this->aInput['input'][$type]['mainTable']; $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric'); $this->aInput['internal'][$type]['datas'] = $aOrgData = $this->aOutput[$type]; if (isset($this->aInput['input']['flash']['type']) && $this->aInput['input']['flash']['type'] == 'geography' and $type == 'flash') { if (count($aOrgData)) { foreach ($aOrgData as $date_i => $aData) { if (count($aData) < 1) { continue; } foreach ($aData as $field => $data) { if (count($data) < 1) { continue; } foreach ($data as $k => $v) { $this->aOutput[$type][$date_i][$field][$k] = $oDict->ALYSmetricFormat($field, $v, $data); } } } } } else { if (count($aOrgData)) { foreach ($aOrgData as $date_i => $aData) { if (count($aData) < 1) { continue; } foreach ($aData as $date => $data) { if (count($aMainTable['showField']) < 1) { continue; } foreach ($aMainTable['showField'] as $metric) { $this->aOutput[$type][$date_i][$date][$metric] = $oDict->ALYSmetricFormat($metric, $data[$metric], $data); } } } } } \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput); }
protected function _init() { $aInput = $this->aInput['input'][$this->_type]; $mainTable = $aInput['mainTable']['table']; //查询条件 $dataCondition = $this->getDateNew($this->_type); //日期条件 $aCondition = $this->getCondition($this->_type, $mainTable); //其它过滤条件 $aCondition = array_merge(array($dataCondition[0][$mainTable]), $aCondition); $aConftionAry = $this->getCondition($type, $table, 'array'); $aConftionAry = array_merge(array($dataCondition[0][$mainTable]), $aConftionAry); //维度 $aDimenField = $aInput['tables'][$mainTable]['dimen']['field']; //$aDimenKey = $aInput['tables'][$mainTable]['dimen']['key']; $aDimenKey2Field = $aInput['tables'][$mainTable]['dimen']['dimenkey2field']; //var_dump($aInput['tables'][$mainTable]['dimen']);exit; //将dimen字段的最后一个作为横向维度 横向维度只有一个 $xDimenKey = @$aInput['table'][$mainTable]['xdimen_key'][0]; $xDimen = $aDimenKey2Field[$xDimenKey]; //$xDimenKey = array_pop($aDimenKey); if (empty($xDimen)) { throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'need xdimen'); } //其余为纵向维度 $yDimensKey = $aInput['table'][$mainTable]['ydimen_key']; $yDimens = array(); //var_dump($yDimensKey,$aDimenKey2Field);exit; foreach ($yDimensKey as $v) { $yDimens[] = $aDimenKey2Field[$v] . " as " . $v; } //$yDimensKey = $aDimenKey; $this->aInput['input'][$this->_type]['dimenpage']['yDimens'] = $yDimens; //存入 列表展示用 $distinctYDimen = implode(',', $yDimens); //查询纵向显示列 $start = (int) ($aInput['page']['current_page'] * $aInput['page']['items_per_page']); $Conf = array('noRecord' => 0, 'limit' => 1, 'start' => $start, 'length' => (int) $aInput['page']['items_per_page'], 'orderby' => $aInput['orderby'], 'field_array' => array('distinct ' . $distinctYDimen), 'table' => $mainTable, 'condition' => $aCondition, 'condition_array' => $aConftionAry); list($aYData, $iYTotal) = $this->list->getAlldata($Conf); //var_dump($aYData);exit; $yfieldData = $this->_fmtArray($aYData, $yDimensKey); unset($aData); //查询横向显示列 //$items_per_page = 5;//固定显示项数量 //$this->aInput['input'][$this->_type]['dimenpage']['items_per_page']=$items_per_page; $Conf['start'] = (int) ($aInput['dimenpage']['current_page'] * $aInput['dimenpage']['items_per_page']); //设置起始值 $Conf['length'] = $aInput['dimenpage']['items_per_page']; //设置显示项 if (!empty($aInput['dimenpage']['orderby'])) { $Conf['orderby'] = $aInput['dimenpage']['orderby']; } else { unset($Conf['orderby']); //清除排序 } // $Conf['field'] = 'distinct '.$xDimen." as ".$xDimenKey; $Conf['field_array'] = array('distinct ' . $xDimen . " as " . $xDimenKey); list($aXData, $iXTotal) = $this->list->getAlldata($Conf); $xfieldData = $this->_fmtArray($aXData, $xDimenKey); //var_dump($aYData,$aXData);exit; //var_dump($xfieldData,$yfieldData);exit; //设置主查询的条件 $aFilter = array_merge($this->_getInSQL($yfieldData, $aDimenKey2Field), $this->_getInSQL($xfieldData, $aDimenKey2Field)); if (empty($this->aInput['input'][$this->_type]['tables'][$mainTable]['filter'])) { $this->aInput['input'][$this->_type]['tables'][$mainTable]['filter'] = $aFilter; } else { $this->aInput['input'][$this->_type]['tables'][$mainTable]['filter'] = array_merge($this->aInput['input'][$this->_type]['tables'][$mainTable]['filter'], $aFilter); } //总数设置 用于分页 $this->aInput['input'][$this->_type]['page']['is_limit'] = 0; $this->aInput['input'][$this->_type]['page']['total'] = $iYTotal; $this->aInput['input'][$this->_type]['dimenpage']['total'] = $iXTotal; //将纵向显示字段存入input 的 dimenpage数组 $this->aInput['input'][$this->_type]['dimenpage']['yfield'] = $aYData; $this->aInput['input'][$this->_type]['dimenpage']['xfield'] = $xfieldData[$xDimenKey]; \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); }
/** * 将输入的参数格式化为跨纬度指标的形式 */ public function _fmtGroup($type) { $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput(); $mainTable = $this->aInput['input'][$type]['mainTable']['table']; $aGroup = array(); $orderByKey = null; $orderbyAsc = 'asc'; if (isset($aInput['input'][$type]['orderby']) && !preg_match("/\\(/i", $aInput['input'][$type]['orderby'])) { list($orderByKey, $orderbyAsc) = @explode(' ', $aInput['input'][$type]['orderby']); $orderbyAsc = empty($orderbyAsc) ? 'asc' : $orderbyAsc; } // var_export($orderByKey); // var_export($orderbyAsc); foreach ($aInput['input'][$type]['table'] as $table => $aTmp) { if (isset($aTmp['dimen']) and $table == $mainTable) { foreach ($aTmp['dimen'] as $i => $aTmp2) { if (!isset($aTmp2['group']) || !empty($aTmp2['group'])) { $aTmp3 = $aTmp2; // $aTmp3 = array(); // foreach($aTmp2 as $k=>$v){ // if($k == 'key'){ // }else{ // $aTmp3[$k] = $v; // } // } $aTmp2['selected'] = empty($aTmp2['selected']) ? $aTmp2['key'] : $aTmp2['selected']; $aTmp3['key'] = $aTmp2['selected']; $aTmp3['sortAble'] = isset($aTmp2['sortAble']) ? $aTmp2['sortAble'] : true; $aTmp3['orderbyClass'] = $orderByKey == $aTmp2['key'] ? "orderby_" . $orderbyAsc : ""; $aTmp3['thclass'] = isset($aTmp2['thclass']) ? $aTmp2['thclass'] : array("td150"); $aTmp3['tipclass'] = array(); $aGroup['dimen'][$aTmp2['selected']] = $aTmp3; } } } if (isset($aTmp['metric'])) { foreach ($aTmp['metric'] as $i => $aTmp2) { if ($aTmp2['show']) { $aTmp3 = $aTmp2; $aTmp3['pieFieldSelected'] = true; $aTmp3['pieFieldAble'] = true; $aTmp3['sortAble'] = isset($aTmp2['sortAble']) ? $aTmp2['sortAble'] : true; $aTmp3['orderbyClass'] = $orderByKey == $aTmp2['key'] ? "orderby_" . $orderbyAsc : ""; $aTmp3['thclass'] = isset($aTmp2['thclass']) ? $aTmp2['thclass'] : array("td150"); $aTmp3['tipclass'] = array(); $aGroup['metric'][$aTmp2['key']] = $aTmp3; } } } } //print_r($aGroup); $aInput['groups'] = $aGroup; \YcheukfReport\Lib\ALYS\Report\Start::setInput($aInput); }
public function initInputAdvance($type) { $aMainTable = array(); $tables = array(); //$aMainTable ��֯ $table = 'mainTable'; $aMetric = \YcheukfReport\Lib\ALYS\Report\Advance::getAdvanceMetrics($type); if ('detail' == $type) { $aDimens = \YcheukfReport\Lib\ALYS\Report\Advance::getAdvanceDimens($type); $aMainTable['showField'] = array_merge($aDimens, $aMetric); } else { $aMainTable['showField'] = $aMetric; } if (empty($aMainTable['showField'])) { throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'need metrics'); } $aMainTable['field3'] = array(); $aMainTable['table2Field'] = array(); $aMainTable['table'] = $table; //ֻ����һ������ if (is_array($aMainTable['showField'])) { foreach ($aMainTable['showField'] as $f) { $aMainTable['field2Table'][$f] = $table; } } //tables ��֯ $aDimens = \YcheukfReport\Lib\ALYS\Report\Advance::getAdvanceDimens($type); $tables[$table]['dimen']['key'] = $aDimens; $tables[$table]['dimen']['dimenkey2field'] = array_flip($aDimens); $this->aInput['input'][$type]['mainTable'] = $aMainTable; $this->aInput['input'][$type]['tables'] = $tables; //��ʼά�� ָ�� (����) $this->aInput['input'][$type]['table'][$table]['dimen'] = $this->aInput['input'][$type]['advanced']['dimen']; $this->aInput['input'][$type]['table'][$table]['metric'] = $this->aInput['input'][$type]['advanced']['metric']; \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); }
/** * 重写 * 获得数据入口 */ public function getData() { $type_R = 'detail'; $nIndex = 0; $aInput = $this->aInput['input'][$type_R]; $mainTable = $aInput['mainTable']['table']; $dimens = $aInput['tables'][$mainTable]['dimen']; //获取列表数据 $aData_R = array(); $aData_R = $this->aInput['internal']['listData'][$nIndex]; $aConcatKey = array(); //次表条件 if (count($aData_R) > 0) { foreach ($aData_R as $j => $aDataTmp) { foreach ($dimens['key'] as $groupField) { if ('perspective' == $aInput['type']) { //若为透视图的x轴, 则跳过该搜索条件过滤 if ($groupField == $aInput['table'][$mainTable]['xdimen_key'][0]) { continue; } $sValTmp = $aDataTmp[$groupField]; // foreach($aDataTmp[$groupField] as $sKeyTmp =>$sValTmp){ $aConcatKey[$nIndex][$dimens['dimenkey2field'][$groupField]][$sValTmp] = $sValTmp; // } //// $aConcatKey = $aConcatKeyNew; } else { $aConcatKey[$nIndex][$dimens['dimenkey2field'][$groupField]][$j] = $aDataTmp[$groupField]; } } } } // var_export($aConcatKey); // if('perspective' == $aInput['type'] && $group==$aInput['table'][$mainTable]['xdimen_key'][0])// // var_export($aConcatKey); $type = 'flash'; $aConf = $this->getConf($type); $aDates = $this->getDate($type); $aFlashConfig = array(); foreach ($aDates as $k => $Date) { foreach ($aConf as $table => $aConfigTmp) { $aFlashConfig[$k][$table] = $aConfigTmp; $aCondition = $aConfigTmp['condition']; $aCondition = array_merge(array($Date), $aCondition); $aFlashConfig[$k][$table]['condition'] = $aCondition; } } // var_export($aInput['table'][$mainTable]['xdimen_key'][0]); $aConfSeconds = array(); $aSortIndexs = $this->aInput['input'][$type]['sort_indexs']; $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label'); // \YcheukfReport\Lib\ALYS\ALYSFunction::debug( $aSortIndexs, 'a', 'aSortIndexs'); $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric'); $aListDataCondition = array(); $aFlashSeries = array(); //flash legend列表中的翻译 if (count($aConcatKey) > 0) { foreach ($aConcatKey[$nIndex] as $group => $val) { $quotes = $oDict->ALYSgetDimenTypeOf($group); $k = 0; foreach ($val as $v) { if (in_array($k, $aSortIndexs)) { $aLabel = $oId2Label->ALYSchgId2Label(array($group), array($group => array($v))); $aFlashSeries[$k][] = $aLabel[$group][$v]; $groupCondition[$k] = $group . " in (" . $quotes . $v . $quotes . ")"; $aListDataCondition[$k][] = $groupCondition[$k]; } $k++; } } } //重写flash的series栏 $this->aInput['input'][$type]['seriestips'] = array(); foreach ($aFlashSeries as $i => $row) { $this->aInput['input'][$type]['seriestips'][] = join(",", $row); } // unset($aListDataCondition[1]); // \YcheukfReport\Lib\ALYS\ALYSFunction::debug($aFlashConfig, 'a', 'aFlashConfig'); $nIndexSecond = 0; foreach ($aFlashConfig[$nIndex] as $table => $aConfigTmp) { foreach ($aListDataCondition as $sort_i => $aTmp) { $aCondition = $aConfigTmp['condition']; if ($this->aInput['input'][$type]['sort_totalflag'] && $nIndexSecond == 0) { //若需要统计总计 $aConfSeconds[$nIndexSecond][$table] = $aConfigTmp; array_unshift($this->aInput['input'][$type]['seriestips'], \YcheukfReport\Lib\ALYS\ALYSLang::_('SORT_TOTAL')); $nIndexSecond++; } foreach ($aListDataCondition[$sort_i] as $aConditionTmp) { $aCondition[] = $aConditionTmp; } $aConfSeconds[$nIndexSecond][$table] = $aConfigTmp; $aConfSeconds[$nIndexSecond][$table]['condition'] = $aCondition; $nIndexSecond++; } } // \YcheukfReport\Lib\ALYS\ALYSFunction::debug($aConfSeconds, 'a', 'aConfSeconds'); foreach ($aConfSeconds as $k => $aConf) { foreach ($aConf as $table => $aConfigTmp) { list($aData[$k][$table], $nTmpTotal) = $this->{$type}->getAlldata($aConfigTmp); } } $aData = $this->_executeSqlData($type, $aData); \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); return $aData; }
public function getConf($type) { $aConf = array(); if (!count($this->aInput['input'][$type]['table'])) { throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_INPUT_TABLE_EMPTY'); } // $aInput = $this->aInput['input'][$type]; $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric'); //print_r($this->aInput['input'][$type]); $this->aInput['input'][$type]['page']['current_page'] = empty($this->aInput['input'][$type]['page']['current_page']) ? 0 : (int) $this->aInput['input'][$type]['page']['current_page']; $this->aInput['input'][$type]['page']['items_per_page'] = empty($this->aInput['input'][$type]['page']['items_per_page']) ? 10 : (int) $this->aInput['input'][$type]['page']['items_per_page']; $start = $this->aInput['input'][$type]['page']['current_page'] * $this->aInput['input'][$type]['page']['items_per_page']; $is_limit = isset($this->aInput['input'][$type]['page']['is_limit']) ? $this->aInput['input'][$type]['page']['is_limit'] === 0 ? 0 : 1 : 1; foreach ($this->aInput['input'][$type]['tables'] as $table => $aTable) { $aConftion = $this->getCondition($type, $table); $aConftionAry = $this->getCondition($type, $table, 'array'); $aConf[$table] = array('noRecord' => 0, 'limit' => $is_limit, 'start' => $start, 'length' => $this->aInput['input'][$type]['page']['items_per_page'], 'dimen_array' => $this->getDimenFieldArray($type, $table), 'metric_array' => $this->getMetricFieldArray($type, $table), 'field_array' => $this->getField($type, $table, 'array'), 'groupby' => $aTable['dimen']['key'], 'table' => $oDict->ALYStableDefine($table), 'condition' => $aConftion, 'condition_array' => $aConftionAry); if (isset($this->aInput['input'][$type]['orderby'])) { $aConf[$table]['orderby'] = $this->aInput['input'][$type]['orderby']; } break; //只配置主表 } \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); //print_r($aConf); return $aConf; }
/** * 重写output.php */ public function fmtOutput() { $type = 'detail'; $this->_initDimen_Metric($type); $this->aInput['internal']['listData'] = $this->aOutput[$type]; //print_r($this->aOutput[$type]);exit; $this->_chgId2Lable($type); //print_r($this->aOutput[$type]); $this->_formatMetric($type); //print_r($this->aOutput[$type]); //print_r($this->aInput['input'][$type]['page']); $this->_fmtOutput($type); \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput); }