ShuanghongS 7 mesi fa
parent
commit
4383133039
2 ha cambiato i file con 71 aggiunte e 79 eliminazioni
  1. 64 77
      main_new_version.php
  2. 7 2
      utils/common.class.php

+ 64 - 77
main_new_version.php

@@ -101,8 +101,8 @@ switch ($action) {
             //     "children"=>array(array("index" =>$index.'-1',"label" =>"Operation Log","path"=>"/Operationlog")));
             $systemManagement = array("index"=>"$index","label"=>"System Management","icon"=>"icon_system__management_fill_b","type"=>"list"); 
             $children  = array(); 
-            //$children[] = array("index" =>$index.'-1',"label" =>"System Message","path"=>"/system-message");
-            //$children[] = array("index" =>$index.'-2',"label" =>"System Settings","path"=>"/SystemSettings");  
+            $children[] = array("index" =>$index.'-1',"label" =>"System Message","path"=>"/system-message");
+            $children[] = array("index" =>$index.'-2',"label" =>"System Settings","path"=>"/SystemSettings");  
             //只有chud的账户可以看日志记录
             if(_getLoginName() == "chud" || _getLoginName() == "IT.Andywu" || _getLoginName() == "ra.admin"){
                 $children[] = array("index" =>$index.'-3',"label" =>"Operation Log","path"=>"/Operationlog");  
@@ -121,6 +121,9 @@ switch ($action) {
         exit();
         break;    
     case 'main_report':
+        //分担查询
+        include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
+
         //这里只剩下r3,r4的查询
         $type = $_REQUEST["r_type"];
        
@@ -129,8 +132,11 @@ switch ($action) {
         $sqlWhere .= common::getDashboardTransportationSqlWhere();
         $sqlWhere = common::check_input($sqlWhere);
 
-        $list = common::excuteListSql("select * from public.online_order_status_date_kln_pending('$type'::text, '$sqlWhere'::text) "
-                    . "r (c bigint, e integer, b integer, d text)");
+        // $list = common::excuteListSql("select * from public.online_order_status_date_kln_pending('$type'::text, '$sqlWhere'::text) "
+        //             . "r (c bigint, e integer, b integer, d text)");
+        $sql = "select * from public.online_order_status_date_kln_pending('$type'::text, '$sqlWhere'::text) "
+                    . "r (c bigint, e integer, b integer, d text)";            
+        $list =  $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
    
         $key = "[";
         $value = "[";
@@ -140,7 +146,7 @@ switch ($action) {
                 $key .= ",";
                 $value .= ",";
             }
-            if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
+            if ($type == "r2" || $type == "r3"  || $type == "r4") {
                 $key .= '"' . $vv["d"] . '"';
                 $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
                 $totalValue = $totalValue + $vv["c"];
@@ -157,12 +163,15 @@ switch ($action) {
         }
         $key .= "]";
         $value .= "]";
-        //处理返回原表数据格式
+        //处理返回原表数据格式 r1 r3 r4的数据返回
         $data = common::mian_repot_do($value,$type,$totalValue);
         common::echo_json_encode(200, $data);
         exit();
         break;
     case 'main_report_etd':
+        //分担查询
+        include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
+
         //这里只有r1查询
         $type = "r1";
         $container_type = "";
@@ -184,8 +193,12 @@ switch ($action) {
         $sqlWhere = $sqlWhere . common::getDashboardTransportationSqlWhere();
         $sqlWhere = common::check_input($sqlWhere);
 
-        $list = common::excuteListSql("select * from public.online_order_status_date_kln_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)");                               
+        // $list = common::excuteListSql("select * from public.online_order_status_date_kln_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)"); 
+        $sql = "select * from public.online_order_status_date_kln_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)";            
+        $list =  $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));   
+
         $key = "[";
         $value = "[";
         $totalValue = 0;
@@ -194,7 +207,7 @@ switch ($action) {
                 $key .= ",";
                 $value .= ",";
             }
-            if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
+            if ($type == "r2" || $type == "r3" || $type == "r4") {
                 $key .= '"' . $vv["d"] . '"';
                 $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
                 $totalValue = $totalValue + $vv["c"];
@@ -211,12 +224,15 @@ switch ($action) {
         }
         $key .= "]";
         $value .= "]";
-        //处理返回原表数据格式
+        //处理返回原表数据格式 r1 r3 r4的数据返回
         $data = common::mian_repot_do($value,$type,$totalValue);
         common::echo_json_encode(200, $data);
         exit();
         break;    
     case 'main_report_kpi':
+        //分担查询
+        include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
+
         $type = $_REQUEST["r_type"];
         $sqlWhere = ' and ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
         $sqlWhere = " " . $sqlWhere;
@@ -229,8 +245,11 @@ switch ($action) {
         if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end']))
             $sqlWhere .= " and $date_type <= ''" . common::usDate2sqlDate($_REQUEST['date_end']) . " 23:59:59''";
         
-        $list = common::excuteListSql("select * from public.online_order_status_date_kln_kpi('$type'::text,'$sqlWhere'::text) "
-                . "r (c bigint, d text)");
+        // $list = common::excuteListSql("select * from public.online_order_status_date_kln_kpi('$type'::text,'$sqlWhere'::text) "
+        //         . "r (c bigint, d text)");
+        $sql = "select * from public.online_order_status_date_kln_kpi('$type'::text,'$sqlWhere'::text) "
+                . "r (c bigint, d text)";            
+        $list =  $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));              
     
         $key = "[";
         $value = "[";
@@ -273,80 +292,48 @@ switch ($action) {
         exit();
         break;  
     case 'main_report_container_bar':
-        //新UI 要ALL  20  40  45 四份数据同时查询,且是柱状图,所以与r3 r4查询分开
-        $container_type_arr = array("20","40","45");
-        $container_type_param = "all";
+        //新UI 20  40  45 3份数据同时查询,且是柱状图,所以与r3 r4查询分开
+        $container_type ='';
         $ContainerCounSeries = array();
 
-        foreach($container_type_arr as $_container_type){
-            $container_type = $_container_type;
-            $date_type = strtolower($_REQUEST["date_type"]);
-            $type = $_REQUEST["r_type"];
-            if (empty($_REQUEST["date_start"])) {
-                $bdate = "null";
-            } else {
-                $bdate = $_REQUEST["date_start"];
-                $bdate = "'$bdate'";
-            }
-            if (empty($_REQUEST["date_end"])) {
-                $edate = "null";
-            } else {
-                $edate = $_REQUEST["date_end"];
-                $edate = "'$edate'";
-            }
-            $list= array();
-            //all 查询所有
-            $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
-            $sqlWhere = common::check_input($sqlWhere);
-            $sqlWhere = " " . $sqlWhere;
-            //如果页面查询的是ALL 这个20  40  45都查询出来。否则值查询都对应的size,其他的不查询
-            if(strtolower($container_type_param) == "all"){
-                $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)");      
-            }else{
-                if($container_type_param == $_container_type){
-                    $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;
-            foreach ($list as $vv) {
-                if ($key != "[") {
-                    $key .= ",";
-                    $value .= ",";
-                }
-                if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
-                    $key .= '"' . $vv["d"] . '"';
-                    $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
-                    $totalValue = $totalValue + $vv["c"];
-                } else {
-                    if ($vv["e"] == -1) {
-                        $key .= '"Over 80 Days"';
-                        $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
-                    } else {
-                        $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
-                        $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
-                    }
-                    $totalValue = $totalValue + $vv["c"];
-                }
-            }
-            $key .= "]";
-            $value .= "]";
-            $key_arr = json_decode($key,true);
-            $value_arr = json_decode($value,true);
+        $date_type = strtolower($_REQUEST["date_type"]);
+        $type = $_REQUEST["r_type"];
+        if (empty($_REQUEST["date_start"])) {
+            $bdate = "null";
+        } else {
+            $bdate = $_REQUEST["date_start"];
+            $bdate = "'$bdate'";
+        }
+        if (empty($_REQUEST["date_end"])) {
+            $edate = "null";
+        } else {
+            $edate = $_REQUEST["date_end"];
+            $edate = "'$edate'";
+        }
+        $list= array();
+        $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
+        $sqlWhere = common::check_input($sqlWhere);
+        $sqlWhere = " " . $sqlWhere;
+        //这个20  40  45都查询出来。否则值查询都对应的size,其他的不查询
+        $value_arr = common::excuteListSql("select * from public.online_order_status_date_kln_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text, '$date_type'::text) "
+                    . "r (month_group text, _20_rc numeric, _40_rc numeric, _45_rc numeric)"); 
 
+        $key_arr = array();
+        $container_type_arr = array("20","40","45");
+        foreach($container_type_arr as $_container_type){
             $data = array();
             //每一个size 的所有月份总计
             $total = 0;
             //每一个size 对应的最大值
             $max = 0;
             foreach($value_arr as $arr){
-                $data[] = intval($arr['value']);
-                $total = $total + intval($arr['value']);
-                $max = $max < intval($arr['value']) ? intval($arr['value']) : $max;
+                $data[] = intval($arr['_'.$_container_type.'_rc']);
+                $total = $total + intval($arr['_'.$_container_type.'_rc']);
+                $max = $max < intval($arr['_'.$_container_type.'_rc']) ? intval($arr['_'.$_container_type.'_rc']) : $max;
+
+                if ($_container_type == '20'){
+                    $key_arr[] = $arr['month_group'];
+                }
             }
             $ContainerCounSeries[$container_type] = array("data"=>$data,"total"=>$total,"max"=>$max);
         }

+ 7 - 2
utils/common.class.php

@@ -1181,6 +1181,9 @@ class common {
 
     //单独处理co2e bar
     public static function getCo2eBar(){
+        //分担查询
+        include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
+
         //新UI air sea road 目前只有sea
         $type = $_REQUEST["r_type"];
 
@@ -1215,7 +1218,8 @@ class common {
                 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);
+            //$co2e_aLL = common::excuteListSql($co2e_shippr_sql);
+            $co2e_aLL = $mapdb->GetAll($co2e_shippr_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $co2e_shippr_sql), 0));
         }
         if ($type == "co2e_destination"){
             $co2e_consignee_sql = "select SUM(COALESCE(carbon_emission,0)) as catnum ,
@@ -1223,7 +1227,8 @@ class common {
                 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);
+            //$co2e_aLL = common::excuteListSql($co2e_consignee_sql);
+            $co2e_aLL = $mapdb->GetAll($co2e_consignee_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $co2e_consignee_sql), 0));
         }
         //最大Y值
         $maxY = 0;