Exemplo n.º 1
0
function queryTemp($id)
{
    $cId = getcIdById($id);
    $pinyin = getPinyinById($cId)['pinyin'];
    $capacity = getCapById($id);
    $arr = $_POST;
    $bTemp = $arr['bTime'];
    $lb = strlen($bTemp);
    $bTime = substr($bTemp, $lb - 2, 2) . "-" . substr($bTemp, 0, 2) . "-" . substr($bTemp, 3, 2);
    // string
    $eTemp = $arr['eTime'];
    $le = strlen($eTemp);
    $eTime = substr($eTemp, $le - 2, 2) . "-" . substr($eTemp, 0, 2) . "-" . substr($eTemp, 3, 2);
    // string
    $bsql = "select id from " . $pinyin . "_tmp where date=" . "\"" . $bTime . "\"";
    $esql = "select id from " . $pinyin . "_tmp where date=" . "\"" . $eTime . "\"";
    $bId = fetchOne($bsql)['id'];
    $eId = fetchOne($esql)['id'];
    // 得到两个日期所对应的id
    $l_sql = "select l_tmp from " . $pinyin . "_tmp where id>=" . $bId . " and id<=" . $eId;
    $h_sql = "select h_tmp from " . $pinyin . "_tmp where id>=" . $bId . " and id<=" . $eId;
    $d_sql = "select date from " . $pinyin . "_tmp where id>=" . $bId . " and id<=" . $eId;
    // get all the date
    $l_tmp = fetchAll($l_sql);
    $l_res = array();
    // low_temperature
    $h_tmp = fetchAll($h_sql);
    $h_res = array();
    // high_temperature
    $m_res = array();
    // mid_temperature
    $d_tmp = fetchAll($d_sql);
    // 得到日期
    $d_res = array();
    // the date, 用以存储日期的简洁形式
    $gas_res = array();
    // 产气量
    $gas_total = 0;
    for ($i = 0; $i < count($l_tmp); $i++) {
        $l_res[$i] = $l_tmp[$i]['l_tmp'];
        $h_res[$i] = $h_tmp[$i]['h_tmp'];
        $m_res[$i] = ($h_res[$i] + $l_res[$i]) / 2;
        $gas_res[$i] = (0.01 * $m_res[$i] - 0.02) * $capacity;
        if ($gas_res[$i] < 0) {
            // 即不产生沼气的情况
            $gas_res[$i] = 0;
        }
        $gas_total = $gas_total + $gas_res[$i];
        // from 2015-7-31 to 7/31
        $d_res[$i] = $d_tmp[$i]['date'];
        $d_res[$i] = substr($d_res[$i], strlen($d_res[$i]) - 5, 5);
        $d_res[$i][2] = "/";
    }
    $res = array();
    $res[0] = $gas_res;
    // 沼气产量数组
    $res[1] = $d_res;
    // 日期数组
    $res[2] = $gas_total;
    // 沼气总量
    $res[3] = $m_res;
    // 平均温度数组
    return $res;
    //    print_r($res);
    //    print_r($m_res);
    //    print_r($d_res);
    //    print_r($gas_res);
    //    print_r($capacity);
    //    print_r($gas_total/count($gas_res));
}
Exemplo n.º 2
0
function queryTotalGas($id)
{
    $pinyin = getPinyinById($id)['pinyin'];
    $capacity = getCityCapById($id);
    $arr = $_POST;
    $bTemp = $arr['bTime'];
    $lb = strlen($bTemp);
    $bTime = substr($bTemp, $lb - 2, 2) . "-" . substr($bTemp, 0, 2) . "-" . substr($bTemp, 3, 2);
    // string
    $eTemp = $arr['eTime'];
    $le = strlen($eTemp);
    $eTime = substr($eTemp, $le - 2, 2) . "-" . substr($eTemp, 0, 2) . "-" . substr($eTemp, 3, 2);
    // string
    $bsql = "select id from " . $pinyin . "_tmp where date=" . "\"" . $bTime . "\"";
    $esql = "select id from " . $pinyin . "_tmp where date=" . "\"" . $eTime . "\"";
    $bId = fetchOne($bsql)['id'];
    $eId = fetchOne($esql)['id'];
    // 得到两个日期所对应的id
    $l_sql = "select l_tmp from " . $pinyin . "_tmp where id>=" . $bId . " and id<=" . $eId;
    $h_sql = "select h_tmp from " . $pinyin . "_tmp where id>=" . $bId . " and id<=" . $eId;
    $l_tmp = fetchAll($l_sql);
    $l_res = array();
    // low_temperature
    $h_tmp = fetchAll($h_sql);
    $h_res = array();
    // high_temperature
    $m_res = array();
    // mid_temperature
    $gas_res = array();
    // 产气量
    $gas_total = 0;
    for ($i = 0; $i < count($l_tmp); $i++) {
        $l_res[$i] = $l_tmp[$i]['l_tmp'];
        $h_res[$i] = $h_tmp[$i]['h_tmp'];
        $m_res[$i] = ($h_res[$i] + $l_res[$i]) / 2;
        $gas_res[$i] = (0.01 * $m_res[$i] - 0.02) * $capacity;
        if ($gas_res[$i] < 0) {
            // 即不产生沼气的情况
            $gas_res[$i] = 0;
        }
        $gas_total = $gas_total + $gas_res[$i];
    }
    return $gas_total;
}
Exemplo n.º 3
0
<?php

//聚合页面
require_once dirname(__FILE__) . "/../include/common.inc.php";
require_once dirname(__FILE__) . "/../include/destinations.class.php";
require_once dirname(__FILE__) . "/dest.func.php";
require_once SLINEINC . "/view.class.php";
$file = SLINEDATA . "/autotitle.cache.inc.php";
//载入智能title配置
if (file_exists($file)) {
    require_once $file;
}
//兼容以前老地址,如果使用以前老地址访问则301跳转到新的地址
if (preg_match("/^\\d*\$/", $destid)) {
    $py = getPinyinById($destid);
    $url = $cfg_basehost . "/{$type}/{$py}/";
    head301($url);
}
if ($type != 'raiders') {
    $url = $cfg_basehost . "/{$type}/{$destid}/";
    head301($url);
}
$destpy = $destid;
//拼音赋值
$kindid = $destid = getDestIdByPy($destpy);
//获取目的地ID
if (empty($type)) {
    exit('Error!');
}
$arr = array('lines' => '1', 'hotels' => '2', 'cars' => '3', 'raiders' => '4', 'spots' => '5', 'photos' => '6');
$destyp = Helper_Archive::getDestPinyin($destid);