/** * TrackWarnNodeDataAct::actModify() * 返回某个国家预警数据信息 * @param int $id 查询ID * @return array */ public function actModify() { $data = array(); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; if (empty($id)) { show_message($this->smarty, "ID不能为空?", ""); return false; } $data['id'] = $id; $data['lists'] = TransOpenApiModel::getTrackNodeList(61); //预警节点列表 $data['res'] = TrackWarnNodeDataModel::modModify($id); if (empty($data['res'])) { show_message($this->smarty, "数据为空,请返回确认条件!", ""); return false; } self::$errCode = TrackWarnNodeDataModel::$errCode; self::$errMsg = TrackWarnNodeDataModel::$errMsg; if (self::$errCode != 0) { show_message($this->smarty, self::$errMsg, ""); return false; } return $data; }
/** * TrackWarnExportModel::exportXls() * 导出xls文件 * @param array $res 结果值 * @return string 文件路径 */ private function exportXls($tharr, $res) { $data = array(); $tdarr = array(); $dates = array(); $pos = array(); $filename = 'track_number_info_' . date('Y-m-d', time()) . '_' . $_SESSION[C('USER_AUTH_SYS_ID')]; $statusList = C('TRACK_STATUS_DETAIL'); $fileurl = WEB_URL . "temp/" . $filename . ".xls"; $filepath = WEB_PATH . "html/temp/" . $filename . ".xls"; array_push($data, $tharr); foreach ($res as $v) { $nodeList = TransOpenApiModel::getTrackNodeList($v['carrierId'], $v['channelId']); $detail = TransOpenApiModel::getTrackInfoLocal($v['trackNumber'], $v['carrierId']); $i = 0; foreach ($nodeList as $n) { foreach ($detail as $val) { $keys = explode(" ", $n['nodeKey']); foreach ($keys as $key) { if (strpos($val['event'], $key) !== false && !in_array($val['event'], array('未妥投'))) { $dates[$i] = !empty($val['trackTime']) ? date('Y-m-d H:i:s', $val['trackTime']) : ''; $pos[$i] = $val['postion']; break; } } } $i++; } $tdarr = array($v['carrierNameCn'], $v['channelName'], $v['orderSn'], $v['recordId'], $v['trackNumber'], $v['weight'], $v['cost'], date('Y-m-d H:i:s', $v['scanTime']), $v['toCountry'], $v['lastEvent'], $v['lastPostion'], date('Y-m-d H:i:s', $v['lastTime']), $statusList[$v['status']], $dates[0], $pos[0], $dates[1], $pos[1], $dates[2], $pos[2], $v['platAccount'], $v['platForm']); array_push($data, $tdarr); } require_once WEB_PATH . "lib/php-export-data.class.php"; $excel = new ExportDataExcel('file'); $excel->filename = $filepath; $excel->initialize(); foreach ($data as $row) { $excel->addRow($row); } $excel->finalize(); unset($data); if (file_exists($filepath)) { return $fileurl; } else { return "fail"; } }
/** * TrackWarnStatModel::getViewPic() * 列出某个运输方式各节点的效率 * @param integer $carrierId 运输方式ID * @param integer $channelId 渠道ID * @param integer $is_warn 是否包含预警天数 0包含,1不包含 * @param string $statType 统计类型 * @param string $condition 条件 * @param string $title 图形标题 * @return json string */ public static function getViewPic($carrierId, $channelId, $statType, $condition, $title, $is_warn, $countryId) { self::initDB(); $data = array(); $channelArr = array(); $nodeArr = array(); $res = array(); $total = 0; $realTotal = 0; $channelArr = TransOpenApiModel::getCarrierChannel($carrierId, $channelId); foreach ($channelArr as $k => $ch) { $nodeArr = TransOpenApiModel::getTrackNodeList($carrierId, $ch['id']); $res[$k]['data'] = array(); $res[$k]['name'] = $ch['channelName']; $key = 0; $percent = 0; $nodeStr = ""; $nodeEffStr = ""; //X轴 if ($statType != 'internalTime') { if ($k == 0) { // foreach ($nodeArr as $v) { array_push($data, $v['nodeName']); } } } else { array_push($data, $ch['channelName']); } //Y轴 if ($statType != 'internalTime') { foreach ($nodeArr as $nd) { if ($statType == 'nodeEff' || $statType == 'nodeEffPer') { if ($key == 0) { $nodeEffStr = " AND nodeEff like '1%'"; } else { $nodeStr = str_pad($nodeStr, $key, "_", STR_PAD_LEFT); $nodeEffStr = " AND nodeEff like '{$nodeStr}1%'"; } } $callFunction = 'get' . $statType; if ($statType == 'nodeEffPer' && $key == 0) { $total = self::getNodeEffTotal($carrierId, $ch['id'], $condition, $nd['id'], $countryId); } $realTotal = self::$callFunction($carrierId, $ch['id'], $condition . $nodeEffStr, $nd['id'], $countryId); if ($statType == 'nodeEffPer') { $percent = round($realTotal / $total, 4) * 100; array_push($res[$k]['data'], $percent); } else { array_push($res[$k]['data'], $realTotal); } $key++; } } else { $nodeWarnStr = $is_warn ? " AND warnLevel > 0" : ''; $total = self::getInternalTime($carrierId, $ch['id'], $condition . $nodeWarnStr, "", $countryId); array_push($res[$k]['data'], $total[0]); array_push($res[$k]['data'], $total[1]); array_push($res[$k]['data'], $total[2]); } } switch ($statType) { case "nodeEff": $unit = "件"; $y_title = "包裹数量"; break; case "nodeTime": $unit = "天"; $y_title = "平均处理天数"; break; case "nodeEffPer": $unit = "%"; $y_title = "百分比"; break; case "internalTime": $unit = ""; $y_title = ""; unset($data); if ($carrierId == 46 || $carrierId == 47) { $priceUnit = "\$"; } else { $priceUnit = "¥"; } $data = array('国内平均处理时间(天)', '平均处理重量(KG)', "平均处理运费({$priceUnit})"); break; } $categories = json_encode($data); $series = json_encode($res); $data = "\$('#container').highcharts({\n\t\t\t\t\t\tchart: {\n\t\t\t\t\t\t\ttype: 'spline'\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttitle: {\n\t\t\t\t\t\t\ttext: '{$title}'\n\t\t\t\t\t\t},\n\t\t\t\t\t\txAxis: {\n\t\t\t\t\t\t\tcategories: {$categories},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyAxis: {\n\t\t\t\t\t\t\ttitle: {\n\t\t\t\t\t\t\t\ttext: '{$y_title}'\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\tformatter: function() {\n\t\t\t\t\t\t\t\t\treturn this.value +'{$unit}'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttooltip: {\n\t\t\t\t\t\t\tcrosshairs: true,\n\t\t\t\t\t\t\tshared: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tplotOptions: {\n\t\t\t\t\t\t\tspline: {\n\t\t\t\t\t\t\t\tmarker: {\n\t\t\t\t\t\t\t\t\tradius: 4,\n\t\t\t\t\t\t\t\t\tlineColor: '#666666',\n\t\t\t\t\t\t\t\t\tlineWidth: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tseries: {$series}\n\t\t\t\t\t});"; if ($statType == 'internalTime') { exit($data); } return $data; }
if ($item == "todayPer") { $dayArr = explode(",", $day); //统计时间:30天,60天内 $title = "【各渠道处理效率简报】" . date('Y-m-d', time()) . " 运输方式{$res['carrierNameCn']}"; $table = '<p style="' . $css_height . '"><b>大家好:</b><br/>以下为运输方式<b>' . $res['carrierNameCn'] . '</b>各渠道各节点处理效率简报,请查阅</p>'; foreach ($dayArr as $days) { $startTime = strtotime(date('Y-m-d', time() - 86400 * $days) . " 00:00:01"); $endTime = strtotime(date('Y-m-d', time()) . " 23:59:59"); $condition = "1"; $condition .= " AND scanTime BETWEEN {$startTime} AND {$endTime}"; echo $condition, "\n"; echo "开始时间" . date('Y-m-d H:i:s', time()) . "\n\n"; $channelArr = TransOpenApiModel::getCarrierChannel($carrierId); $table .= '<p style="' . $css_height . '">' . $days . '天以内的统计数据<br/></p><table border="1" cellpadding="0" cellspacing="0" width="791">'; foreach ($channelArr as $k => $ch) { $nodeArr = TransOpenApiModel::getTrackNodeList($carrierId, $ch['id']); if ($k == 0) { $table .= "<tr><th>渠道</th>"; foreach ($nodeArr as $v) { $table .= "<th>{$v['nodeName']}</th><th>已处理</th><th style=\"color:red\">预警率</th>"; } $table .= "</tr>"; } $table .= "<tr><td>{$ch['channelName']}</td>"; $key = 0; $percent = 0; $nodeStr = ""; $nodeEffStr = ""; $nodeWarnStr = ""; foreach ($nodeArr as $nd) { if ($key == 0) {
/** * TransOpenApiAct::act_getTrackNodeList() * 根据运输方式ID获取预警节点 * @param string $carrierId * @param string $channelId * @return string ; */ public function act_getTrackNodeList() { $carrierId = isset($_REQUEST['carrierId']) ? abs(intval($_REQUEST['carrierId'])) : 0; $channelId = isset($_REQUEST['channelId']) ? abs(intval($_REQUEST['channelId'])) : 0; if (empty($carrierId)) { self::$errCode = 10000; self::$errMsg = '运输方式ID有误!'; return false; } if (empty($channelId)) { self::$errCode = 10001; self::$errMsg = '渠道ID有误!'; return false; } $nodeInfo = TransOpenApiModel::getTrackNodeList($carrierId, $channelId); return $nodeInfo; }
$numberList = array(); //跟踪号列表 $data = array(); $trackTime = 0; $page = isset($argv[1]) ? abs(intval($argv[1])) : 1; //页码 $pagenum = isset($argv[2]) ? abs(intval($argv[2])) : 2000; //每页多少条 $carrierId = isset($argv[3]) ? abs(intval($argv[3])) : ""; //运输方式ID $where = isset($argv[4]) ? $argv[4] : ""; //跟踪号状态 $hours = isset($argv[5]) ? $argv[5] : 0; //最近几个小时内数据 $countrys = TransOpenApiModel::getCountriesStandard("ALL"); $nodes = TransOpenApiModel::getTrackNodeList(61); print_r($nodes); if (empty($nodes)) { exit("未设置运德物流预警节点,暂没法分析数据!\n"); } foreach ($countrys as $c) { $country = $c['countryNameEn']; $postion = empty($where) ? "toCountry = '{$country}'" : $where . " AND toCountry = '{$country}'"; $numberList = TransOpenApiModel::getTrackNumberList($page, $pagenum, $carrierId, $postion, $hours, 'DESC'); //获取符合条件的跟踪号列表 $total = count($numberList); echo date('Y-m-d H:i:s', time()) . "===" . $c['countryNameEn'] . "===" . $total . "条数据分析开始!" . "\n\n"; //得到原始数据 foreach ($numberList as $v) { $timestr = date('Y-m-d H:i:s', time()); $times = $v['scanTime'];