ShuanghongS 2 minggu lalu
induk
melakukan
5c9eaacc06
3 mengubah file dengan 48 tambahan dan 60 penghapusan
  1. 1 0
      service/column.class.php
  2. 1 5
      service/report.class.php
  3. 46 55
      utils/common.class.php

+ 1 - 0
service/column.class.php

@@ -73,6 +73,7 @@ class column {
         $children['All'] = array();
         $children['Reference No.'] = array();
         $children['General'] = array();
+        $children['CO2 Emission'] = array();
         $children['Parties'] = array();
         $children['Packing'] = array();
         $children['Time'] = array();

+ 1 - 5
service/report.class.php

@@ -1144,11 +1144,7 @@ class report {
                     if (utils::startWith($key,"oc") || utils::startWith($key,"oi") || utils::startWith($key,"oe") || utils::startWith($key,"co2_r")
                         || $fiter['field'] == "total_distance"
                         || $fiter['field'] == "last_mile_delivery"
-                        || $key == "COALESCE(oe.import_po_no,oo.po_no)" 
-                        || $key == "oo._voyage" 
-                        || $key == "oo._vessel"
-                        || $key == "oo.new_status"
-                        || $key == "CONCAT_WS('/', oo._vessel, oo._voyage)"){
+                        || $key == "COALESCE(oe.import_po_no,oo.po_no)"){
                         $ocItemSearchKLN .= $temp_sql_where;
                     } else {
                         $klnOceanSearchKLN .= $temp_sql_where;

+ 46 - 55
utils/common.class.php

@@ -4449,7 +4449,14 @@ class common {
             "oo.ex_im" => "ex_im",
             "oo.incoterms" => "incoterms",
             "oe.loadterm"=>"load_terms",
-            "oo.new_status" => "status",
+            "(CASE
+                WHEN (m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Created'::text
+                WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Cargo Received'::text
+                WHEN (m_iffdep is not null and m_iffarr is null and m_iffdel is null) THEN 'Departed'::text
+                WHEN (m_iffarr is not null and m_iffdel is null) THEN 'Arrived'::text
+                WHEN (m_iffdel is not null) THEN 'Completed'::text
+                ELSE 'Created'
+            END)" => "status",
             "oo.carbon_emission" => "total_co2_emission",
             "oo.qty" => "shipment_qty",
             "oo.piece_count" => "shipment_gross_weight",
@@ -4482,9 +4489,40 @@ class common {
             "oo.place_of_delivery_exp" => "place_of_delivery",
             "oo.port_of_transshipment_name" => "port_of_transhipment",
             "oo.carrier" => "carrier",
-            "oo._voyage"=>"voyage_flight",    
-            "oo._vessel"=>"vessel_airline",
-            "CONCAT_WS('/', oo._vessel, oo._voyage)"=>"vslvoy_flight",
+            "(CASE
+                WHEN oo.voyage IS NOT DISTINCT FROM oo.f_voyage THEN oo.voyage
+                WHEN NULLIF(TRIM(oo.voyage), '') IS NOT NULL AND NULLIF(TRIM(oo.f_voyage), '') IS NOT NULL
+                    THEN oo.f_voyage || '/' || oo.voyage
+                WHEN NULLIF(TRIM(oo.voyage), '') IS NOT NULL
+                    THEN oo.voyage
+                ELSE oo.f_voyage
+            END)"=>"voyage_flight",    
+            "(CASE
+                WHEN oo.vessel IS NOT DISTINCT FROM oo.f_vessel THEN oo.vessel
+                WHEN NULLIF(TRIM(oo.vessel), '') IS NOT NULL AND NULLIF(TRIM(oo.f_vessel), '') IS NOT NULL
+                    THEN oo.f_vessel || '/' || oo.vessel
+                WHEN NULLIF(TRIM(oo.vessel), '') IS NOT NULL
+                    THEN oo.vessel
+                ELSE oo.f_vessel
+            END)"=>"vessel_airline",
+            "CONCAT_WS('/', 
+                CASE
+                    WHEN oo.vessel IS NOT DISTINCT FROM oo.f_vessel THEN oo.vessel
+                    WHEN NULLIF(TRIM(oo.vessel), '') IS NOT NULL AND NULLIF(TRIM(oo.f_vessel), '') IS NOT NULL
+                        THEN oo.f_vessel || '/' || oo.vessel
+                    WHEN NULLIF(TRIM(oo.vessel), '') IS NOT NULL
+                        THEN oo.vessel
+                    ELSE oo.f_vessel
+                END, 
+                CASE
+                    WHEN oo.voyage IS NOT DISTINCT FROM oo.f_voyage THEN oo.voyage
+                    WHEN NULLIF(TRIM(oo.voyage), '') IS NOT NULL AND NULLIF(TRIM(oo.f_voyage), '') IS NOT NULL
+                        THEN oo.f_voyage || '/' || oo.voyage
+                    WHEN NULLIF(TRIM(oo.voyage), '') IS NOT NULL
+                        THEN oo.voyage
+                    ELSE oo.f_voyage
+                END
+            )"=>"vslvoy_flight",
             "oo.ams_status" => "ace_m1_status",
             "oo.isisf" => "is_isf",
             "oo.obl_set" => "obl_set",
@@ -4853,11 +4891,6 @@ class common {
         $needOceanExtend   = in_array('oe', $requiredTables) || in_array('Last Mile Delivery', $filterFieldAliases);
         $needCO2           = in_array('co2_r', $requiredTables);
 
-        $needNewStatus     = in_array('new_status', $requiredTables);
-        $needVoyage     = in_array('_voyage', $requiredTables);
-        $needVessel     = in_array('_vessel', $requiredTables);
-
-        $needVSLVOYFLIGHT     = in_array('VSLVOY/FLIGHT', $requiredTables);
         $needteu     = in_array('CARRIER TEU', $requiredTables);
         $needCustomer     = in_array('Controlling Customer', $requiredTables);
 
@@ -4869,42 +4902,6 @@ class common {
             $needContainerData = true;
         }
         
-        $needNewStatusSQL = " ";
-        if ($needNewStatus) {
-            $needNewStatusSQL = "CASE
-                        WHEN (m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Created'::text
-                        WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Cargo Received'::text
-                        WHEN (m_iffdep is not null and m_iffarr is null and m_iffdel is null) THEN 'Departed'::text
-                        WHEN (m_iffarr is not null and m_iffdel is null) THEN 'Arrived'::text
-                        WHEN (m_iffdel is not null) THEN 'Completed'::text
-                        ELSE 'Created'
-                    END AS new_status, ";
-        }
-
-        $needVoyageSQL = " ";
-        if ($needVoyage || $needVSLVOYFLIGHT) {
-            $needVoyageSQL = "CASE
-                        WHEN oo.voyage IS NOT DISTINCT FROM oo.f_voyage THEN oo.voyage
-                        WHEN NULLIF(TRIM(oo.voyage), '') IS NOT NULL AND NULLIF(TRIM(oo.f_voyage), '') IS NOT NULL
-                            THEN oo.f_voyage || '/' || oo.voyage
-                        WHEN NULLIF(TRIM(oo.voyage), '') IS NOT NULL
-                            THEN oo.voyage
-                        ELSE oo.f_voyage
-                    END AS _voyage, ";
-        }
-
-        $needVesselSQL = " ";
-        if ($needVessel || $needVSLVOYFLIGHT) {
-            $needVesselSQL = "CASE
-                        WHEN oo.vessel IS NOT DISTINCT FROM oo.f_vessel THEN oo.vessel
-                        WHEN NULLIF(TRIM(oo.vessel), '') IS NOT NULL AND NULLIF(TRIM(oo.f_vessel), '') IS NOT NULL
-                            THEN oo.f_vessel || '/' || oo.vessel
-                        WHEN NULLIF(TRIM(oo.vessel), '') IS NOT NULL
-                            THEN oo.vessel
-                        ELSE oo.f_vessel
-                    END AS _vessel, ";
-        }
-
         $needCustomerSQL = " ";
         if($needCustomer){
             $needCustomerSQL = " case when oo.order_from  ='public' and oo.transport_mode  ='sea' then (select customer_code from public.ocean_extend ex where ex.serial_no = oo.serial_no limit 1)
@@ -4932,21 +4929,15 @@ class common {
             END	 AS \"CARRIER TEU\", ";
         }
 
-        $needVSLVOYFLIGHTSQL = " ";
-        if($needVSLVOYFLIGHT){
-            $needVSLVOYFLIGHTSQL = " CONCAT_WS('/', oo._vessel, oo._voyage) AS \"VSLVOY/FLIGHT\", ";
-        }
-
-
         // --- CTE: oo (主表) ---
         $sql = "
         with oo as (
-            SELECT {$needNewStatusSQL} {$needVoyageSQL} {$needVesselSQL} * FROM public.kln_ocean oo  <{klnOceanSearchKLN}>
+            SELECT  * FROM public.kln_ocean oo  <{klnOceanSearchKLN}>
         )";
 
         // 如果不需要容器/项数据,直接 COUNT
         if (!$needContainerData) {
-            if(!empty($needCustomerSQL) || !empty($needVSLVOYFLIGHTSQL)){
+            if(!empty($needCustomerSQL)){
                 return $sql . "\n ,vv as (select {$needCustomerSQL} 1 from oo <{ocItemSearchKLN}>) select count(*)  from vv <{vvSearchKLN}>;";
             }
             return $sql . "\n select count(*) from oo <{ocItemSearchKLN}> ;";
@@ -5014,7 +5005,7 @@ class common {
 
         $sql .= ",
         vv_public AS (
-            SELECT {$needCustomerSQL} {$needteuSQL} {$needVSLVOYFLIGHTSQL} 1
+            SELECT {$needCustomerSQL} {$needteuSQL}  1
             FROM oo 
             {$joinPublic}
             {$oeLateral}
@@ -5022,7 +5013,7 @@ class common {
             <{ocItemSearchKLN}>
         ),
         vv_sfs AS (
-            SELECT {$needCustomerSQL} {$needteuSQL} {$needVSLVOYFLIGHTSQL} 1
+            SELECT {$needCustomerSQL} {$needteuSQL} 1
             FROM oo 
             {$joinSfs}
             {$oeLateral}