ShuanghongS 8 月之前
父节点
当前提交
bfc1556a8b
共有 1 个文件被更改,包括 22 次插入6 次删除
  1. 22 6
      utils/common.class.php

+ 22 - 6
utils/common.class.php

@@ -1211,17 +1211,17 @@ class common {
         //这里的问题跟 top 一样 。总的排放量查询有问题。目前是总的排放量 暂时等于 sea的排放量
         if ($type == "co2e_orgin"){
             $co2e_shippr_sql = "select SUM(COALESCE(carbon_emission,0)) as catnum ,
-                sum(case when (1<>1 or (transport_mode='air')) then 1 else 0 end) as air_rc,
-                sum(case when (1<>1 or (transport_mode='sea')) then 1 else 0 end) as sea_rc, 
-                sum(case when (1<>1 or (transport_mode='road')) then 1 else 0 end) as road_rc, 
+                sum(case when (1<>1 or (transport_mode='air')) then COALESCE(carbon_emission,0) else 0 end) as air_rc,
+                sum(case when (1<>1 or (transport_mode='sea')) then COALESCE(carbon_emission,0) else 0 end) as sea_rc, 
+                sum(case when (1<>1 or (transport_mode='road')) then COALESCE(carbon_emission,0) else 0 end) as road_rc, 
                 shippr_uncode as station from public.kln_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";
             $co2e_aLL = common::excuteListSql($co2e_shippr_sql);
         }
         if ($type == "co2e_destination"){
             $co2e_consignee_sql = "select SUM(COALESCE(carbon_emission,0)) as catnum ,
-                sum(case when (1<>1 or (transport_mode='air')) then 1 else 0 end) as air_rc,
-                sum(case when (1<>1 or (transport_mode='sea')) then 1 else 0 end) as sea_rc, 
-                sum(case when (1<>1 or (transport_mode='road')) then 1 else 0 end) as road_rc, 
+                sum(case when (1<>1 or (transport_mode='air')) then COALESCE(carbon_emission,0) else 0 end) as air_rc,
+                sum(case when (1<>1 or (transport_mode='sea')) then COALESCE(carbon_emission,0) else 0 end) as sea_rc, 
+                sum(case when (1<>1 or (transport_mode='road')) then COALESCE(carbon_emission,0) else 0 end) as road_rc, 
                 consignee_uncode as station from public.kln_ocean  where 1=1 and COALESCE(consignee_uncode,'')<>'' and carbon_emission is not null $sqlWhere group by consignee_uncode order by catnum desc limit 10";
             $co2e_aLL = common::excuteListSql($co2e_consignee_sql);
         }
@@ -1235,12 +1235,28 @@ class common {
                 $stations[] = $val['station'];
             }
         }
+        // $station_str = utils::implode(',',$stations);
 
         $ContainerCounSeries = array();
         $shipment_mode_arr = array("air","sea","road");
         foreach($shipment_mode_arr as $_shipment_mode){
             //类型有 sea air road,目前之类只查询sea的,其他为空
             $shipment_mode = $_shipment_mode;
+            // $co2e = array();
+            if ($type == "co2e_orgin"){
+                // $co2e_shippr_sql_union = utils::_getSql($station_str,$type,$shipment_mode,$sqlWhere);
+                // if(!empty($co2e_shippr_sql_union)){
+                //     $co2e = common::excuteListSql($co2e_shippr_sql_union);
+                // }
+                $download_name = "CO2e Emission by Origin (Top 10)";
+            }
+            if ($type == "co2e_destination"){
+                // $co2e_consignee_union = utils::_getSql($station_str,$type,$shipment_mode,$sqlWhere);
+                // if(!empty($co2e_consignee_union)){
+                //     $co2e = common::excuteListSql($co2e_consignee_union);
+                // }
+                $download_name = "CO2e Emission by Destination (Top 10)";
+            }
 
             $total = 0;
             $max = 0;