Esempio n. 1
0
 /**
  * TrackWarnStatModel::getInternalTime()
  * 返回某个运输方式某渠道国内处理时效
  * @param integer $carrierId 运输方式ID
  * @param integer $channelId 渠道ID
  * @param integer $countryId 国家ID
  * @param string $condition 条件
  * @return array 
  */
 public static function getInternalTime($carrierId, $channelId, $condition, $nodeId = "", $countryId)
 {
     self::initDB();
     if (!empty($countryId)) {
         $sql = "SELECT AVG(internalTime),AVG(weight),AVG(cost) FROM " . self::$prefix . self::$tab_track_num . " WHERE {$condition} AND carrierId = {$carrierId} AND channelId = {$channelId} AND countryId = {$countryId} AND internalTime > 0";
     } else {
         $sql = "SELECT AVG(internalTime),AVG(weight),AVG(cost) FROM " . self::$prefix . self::$tab_track_num . " WHERE {$condition} AND carrierId = {$carrierId} AND channelId = {$channelId} AND internalTime > 0";
     }
     $query = self::$dbConn->query($sql);
     if ($query) {
         $data = self::$dbConn->fetch_row($query);
         return array(round(intval($data[0]) / 86400, 2), round(floatval($data[1]), 4), round(floatval($data[2]), 4));
     } else {
         self::$errCode = 10000;
         self::$errMsg = "获取数据失败";
         return 0;
     }
 }
Esempio n. 2
0
 /**
  * TrackWarnStatAct::act_viewPic()
  * 列出某个运输方式各渠道各节点的(处理、时效)效率
  * @param integer $carrierId 运输方式ID
  * @param integer $channelId 渠道ID
  * @param string $timeNode 时间条件
  * @param string $statType 统计类型
  * @return json string 
  */
 public function act_viewPic()
 {
     $condition = "1";
     $title = "";
     $countryStr = "";
     $carrierId = isset($_POST['carrierId']) ? abs(intval($_POST['carrierId'])) : 0;
     $channelId = isset($_POST['channelId']) ? abs(intval($_POST['channelId'])) : 0;
     $countryId = isset($_POST['countryId']) ? abs(intval($_POST['countryId'])) : 0;
     $timeNode = isset($_GET['timeNode']) ? post_check(trim($_GET['timeNode'])) : '';
     $statType = isset($_POST['statType']) ? post_check(trim($_POST['statType'])) : '';
     $is_warn = isset($_POST['is_warn']) ? post_check(trim($_POST['is_warn'])) : 0;
     $act = isset($_REQUEST["act"]) ? post_check($_REQUEST["act"]) : "";
     $mod = isset($_REQUEST["mod"]) ? post_check($_REQUEST["mod"]) : "";
     if (!AuthUser::checkLogin($mod, $act)) {
         self::$errCode = 10000;
         self::$errMsg = "对不起,您无跟踪号统计查看权限!";
         return false;
     }
     if (empty($carrierId)) {
         self::$errCode = 10001;
         self::$errMsg = "运输方式参数有误";
         return false;
     }
     if (empty($timeNode) || !in_array($timeNode, array('scanTime'))) {
         self::$errCode = 10002;
         self::$errMsg = "时间条件参数有误";
         return false;
     }
     if (empty($statType) || !in_array($statType, array('nodeEff', 'nodeEffPer', 'nodeTime', 'internalTime', 'todayWarnPer'))) {
         self::$errCode = 10003;
         self::$errMsg = "统计类型参数有误";
         return false;
     }
     if (!in_array($is_warn, array(0, 1))) {
         self::$errCode = 10004;
         self::$errMsg = "预警天数参数有误";
         return false;
     }
     if (!empty($timeNode)) {
         $startTime = isset($_GET['startTime']) ? strtotime(trim($_GET['startTime']) . " 00:00:00") : strtotime(date("Y-m-d", time()) . " 00:00:00");
         $endTime = isset($_GET['endTime']) ? strtotime(trim($_GET['endTime']) . " 23:59:59") : strtotime(date("Y-m-d", time()) . " 23:59:59");
         if ($startTime && $endTime) {
             $condition .= ' AND ' . $timeNode . " BETWEEN '" . $startTime . "' AND " . "'" . $endTime . "'";
         }
     }
     if (empty($countryId)) {
         $countryStr = " 国家";
     } else {
         $res = TransOpenApiModel::getCountriesStandardById($countryId);
         $countryStr = " ({$res['countryNameCn']})";
     }
     switch ($statType) {
         case "nodeEff":
             $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道节点处理效率统计" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道节点处理效率统计";
             break;
         case "nodeTime":
             $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道节点处理时效统计" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道节点处理时效统计";
             break;
         case "nodeEffPer":
             $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道节点处理效率百分比" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道节点处理效率百分比";
             break;
         case "internalTime":
             $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道处理时效" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道处理时效";
             break;
     }
     if (in_array($statType, array('todayWarnPer'))) {
         $res = "";
         $nodeArr = TransOpenApiModel::getRandTrackNodeList($carrierId);
         foreach ($nodeArr as $key => $nd) {
             $condition = array(1, $timeNode, $startTime, $endTime, $key, "container" . $key);
             $res .= TrackWarnStatModel::getViewTodayPic($carrierId, $channelId, $statType, $condition, "{$nd['nodeName']}节点--各渠道预警率信息一览表", $is_warn, $countryId);
         }
     } else {
         $res = TrackWarnStatModel::getViewPic($carrierId, $channelId, $statType, $condition, $title, $is_warn, $countryId);
     }
     self::$errCode = TrackWarnStatModel::$errCode;
     self::$errMsg = TrackWarnStatModel::$errMsg;
     return $res;
 }
                $realPercent = round($realTotal / $total, 2) * 100;
                $warnPercent = round(($realTotal - $warnTotal) / $total, 2) * 100;
                $table .= "<td>{$total}</td><td>{$realPercent}%</td><td style=\"color:red\">{$warnPercent}%</td>";
                $key++;
            }
            $table .= "</tr>";
        }
        $table .= "</table>";
    }
    $table .= '<p style="' . $css_height . '">详情请登录:<a href="' . $system_url . '" target="_blank">' . $system_name . '</a><br/></br>' . date('Y-m-d', $endTime) . '<br/>' . $system_name . '</p>';
    echo $table, "\n";
} else {
    $startTime = strtotime("-{$day} day" . " 00:00:01");
    $endTime = strtotime(date('Y-m-d') . " 23:59:59");
    $table = "";
    $title = "【日预警率简报】" . date('Y-m-d', time()) . " 运输方式{$res['carrierNameCn']}渠道各节点{$day}日内预警率数据一览表";
    $nodeArr = TransOpenApiModel::getRandTrackNodeList($carrierId);
    foreach ($nodeArr as $key => $nd) {
        $channelId = $ch['id'];
        $timeNode = "scanTime";
        $condition = array(1, $timeNode, $startTime, $endTime, $key, $nd['nodeName'] . '节点--各渠道预警率信息一览表');
        $table .= "<p style=\"{$css_height}\">" . TrackWarnStatModel::getViewTodayTable($carrierId, $channelId, "todayWarnPer", $condition, 0, 0) . "</p>";
    }
    $table .= '<p style="' . $css_height . '">详情请登录:<a href="' . $system_url . '" target="_blank">' . $system_name . '</a><br/></br>' . date('Y-m-d', $endTime) . '<br/>' . $system_name . '</p>';
    echo $table, "\n";
}
$message = TransOpenApiModel::sendMessage("{$type}", "{$from}", "{$to}", $table, "{$title}");
echo $message, "\n";
echo "\n\n完成时间" . date('Y-m-d H:i:s', time()) . "\n";
$dbConn->close();
exit;