ShuanghongS 1 жил өмнө
parent
commit
4bf90564bc
2 өөрчлөгдсөн 183 нэмэгдсэн , 32 устгасан
  1. 149 10
      main_new_version.php
  2. 34 22
      utils/common.class.php

+ 149 - 10
main_new_version.php

@@ -87,9 +87,60 @@ switch ($action) {
         $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
         $sqlWhere = common::check_input($sqlWhere);
         $sqlWhere = " " . $sqlWhere;
+
+        $transportation = $_REQUEST["transportation"];
+        if(!is_array($transportation)){
+            $transportation = array($transportation);
+        }
+
+        $list = array();
+        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+            $transportation = array("Sea","Air","Road");         
+        }
+        foreach($transportation as $mode){
+            if($mode == 'Sea'){
+                $Sealist = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
+                    . "r (c bigint, e integer, b integer, d text)");
+                //拼接数据     
+                if(empty($list)){
+                    $list = $Sealist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $Sealist[$lk]['c'];
+                    }
+                }  
+            }
+            if($mode == 'Air'){
+                //暂时查询空数据 
+                $sqlWhere .= " and 1<>1 ";
+                $Airlist = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
+                    . "r (c bigint, e integer, b integer, d text)");
+                //拼接数据     
+                if(empty($list)){
+                    $list = $Airlist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
+                    }
+                }       
+            }
+            if($mode == 'Road'){
+                $sqlWhere .= " and 1<>1 ";
+                $roadlist = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
+                    . "r (c bigint, e integer, b integer, d text)");  
+                //拼接数据     
+                if(empty($list)){
+                    $list = $roadlist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
+                    }
+                }      
+            }
+        }
         //online_order_status_date_new 与本地的区分,发布上去这去掉new
-        $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
-                        . "r (c bigint, e integer, b integer, d text)");               
+        // $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
+        //                 . "r (c bigint, e integer, b integer, d text)");               
         $key = "[";
         $value = "[";
         $totalValue = 0;
@@ -142,8 +193,57 @@ switch ($action) {
         $sqlWhere = common::check_input($sqlWhere);
         $sqlWhere = " " . $sqlWhere;
 
-        $list = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
-                            . "r (c bigint, e integer, b integer, d text)");               
+        $transportation = $_REQUEST["transportation"];
+        if(!is_array($transportation)){
+            $transportation = array($transportation);
+        }
+        $list = array();
+        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+            $transportation = array("Sea","Air","Road");         
+        }
+        foreach($transportation as $mode){
+            if($mode == 'Sea'){
+                $Sealist = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
+                    . "r (c bigint, e integer, b integer, d text)");
+                //拼接数据     
+                if(empty($list)){
+                    $list = $Sealist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $Sealist[$lk]['c'];
+                    }
+                }  
+            }
+            if($mode == 'Air'){
+                //暂时查询空数据 
+                $sqlWhere .= " and 1<>1 ";
+                $Airlist = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
+                    . "r (c bigint, e integer, b integer, d text)");
+                //拼接数据     
+                if(empty($list)){
+                    $list = $Airlist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
+                    }
+                }       
+            }
+            if($mode == 'Road'){
+                $sqlWhere .= " and 1<>1 ";
+                $roadlist = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
+                    . "r (c bigint, e integer, b integer, d text)");  
+                //拼接数据     
+                if(empty($list)){
+                    $list = $roadlist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $roadlist[$lk]['c'];
+                    }
+                }      
+            }
+        }
+        // $list = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
+        //                     . "r (c bigint, e integer, b integer, d text)");               
         $key = "[";
         $value = "[";
         $totalValue = 0;
@@ -190,14 +290,53 @@ switch ($action) {
         if(!is_array($transportation)){
             $transportation = array($transportation);
         }
-        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
 
-        }else{
-            //这里不用处理,只有sea的数据
+        $list = array();
+        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+            $transportation = array("Sea","Air","Road");         
         }
-
-        $list = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere'::text) "
-                        . "r (c bigint, d text)");                
+        foreach($transportation as $mode){
+            if($mode == 'Sea'){
+                $Sealist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere'::text) "
+                    . "r (c bigint, d text)");
+                //拼接数据     
+                if(empty($list)){
+                    $list = $Sealist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $Sealist[$lk]['c'];
+                    }
+                }     
+            }
+            if($mode == 'Air'){
+                //暂时查询空数据 
+                $sqlWhere .= " and 1<>1 ";
+                $Airlist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere'::text) "
+                    . "r (c bigint, d text)");
+                //拼接数据     
+                if(empty($list)){
+                    $list = $Airlist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
+                    }
+                }       
+            }
+            if($mode == 'Road'){
+                $sqlWhere .= " and 1<>1 ";
+                $roadlist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere'::text) "
+                 . "r (c bigint, d text)");  
+                //拼接数据     
+                if(empty($list)){
+                    $list = $roadlist;
+                }else{
+                    foreach($list as $lk =>$lv){
+                        $list[$lk]['c'] = $list[$lk]['c'] + $roadlist[$lk]['c'];
+                    }
+                }       
+            }
+        }
+         
         $key = "[";
         $value = "[";
         $totalValue = 0;

+ 34 - 22
utils/common.class.php

@@ -1296,18 +1296,9 @@ class common {
         if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end']))
             $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_REQUEST['date_end']) . " 23:59:59'";
          
-        $transportation = $_REQUEST["transportation"];
-        if(!is_array($transportation)){
-            $transportation = array($transportation);
-        }
-        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
-
-        }else{
-            //这里不用处理,只有sea的数据
-        }
-
         $ContainerCount_Title = array();
-        //先查询总的排放量sea air road,确定排名后,在分别查询对应的sea air road
+        //先查询总的排放量sea air road,确定排名后,在分别查询对应的sea air road 
+        //这里的问题跟 top 一样 。总的排放量查询有问题。目前是总的排放量 暂时等于 sea的排放量
         if ($type == "co2e_orgin"){
             $co2e_shippr_sql = "select SUM(COALESCE(carbon_emission,0)) as catnum ,
                 shippr_uncode as station from online_ocean  where 1=1 and COALESCE(shippr_uncode,'')<>'' and carbon_emission is not null  $sqlWhere group by shippr_uncode order by catnum desc limit 10";
@@ -1354,10 +1345,25 @@ class common {
             $max = 0;
             $data = array();
             foreach($co2e as $val){
-                $data[] = empty($val['catnum'])? 0 : $val['catnum'];
+                $data[] = empty($val['catnum'])? 0 : number_format($val['catnum'], 4);
                 $total = $total + $val['catnum'];
                 $max = $max < $val['catnum'] ? $val['catnum'] : $max;
             }
+
+            $transportation = $_REQUEST["transportation"];
+            if(!is_array($transportation)){
+                $transportation = array($transportation);
+            }
+            if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+
+            }else{
+                //这里不用处理,只有sea的数据
+                if (!in_array("Sea", $transportation)){
+                    $data = array_fill_keys(array_keys($data), 0);
+                    $total = 0;
+                    $max = 0;
+                }
+            }
             $ContainerCounSeries[$shipment_mode] = array("data"=>$data,"total"=>$total,"max"=>$max);
         }
         
@@ -1391,16 +1397,6 @@ class common {
         if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end']))
             $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_REQUEST['date_end']) . " 23:59:59'";
          
-        $transportation = $_REQUEST["transportation"];
-        if(!is_array($transportation)){
-            $transportation = array($transportation);
-        }
-        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
-
-        }else{
-            //这里不用处理,只有sea的数据
-        }
-
         $toporiginType = "shippr_uncode";
         $shippr_uncode_10_sql ="with aa as  (select count(shippr_uncode) as num,shippr_uncode,
                                 (array_agg(shipper_city))[1] AS shipper_city from online_ocean  
@@ -1448,6 +1444,22 @@ class common {
             $consignee_uncode_10 = common::excuteListSql($consignee_uncode_10_sql);
         }
 
+        //Top查询有点问题,暂时这样查询: 理论上查询air sea road 所有数据的top 10,在更加这个top的站点,分别去查询对于mode的数据计总。
+        //但是目前只有sea, 所有模式计总 = sea计总(以后这里是要改的)
+        $transportation = $_REQUEST["transportation"];
+        if(!is_array($transportation)){
+            $transportation = array($transportation);
+        }
+        if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
+
+        }else{
+            //这里不用处理,只有sea的数据
+            if (!in_array("Sea", $transportation)){
+                $shippr_uncode_10 = array();
+                $consignee_uncode_10 = array();
+            }
+        }
+
         $toporigin = array();
         $toporiginMap = array();
         $i = 0;