ShuanghongS há 1 mês atrás
pai
commit
c537a33b0c
2 ficheiros alterados com 70 adições e 2 exclusões
  1. 69 1
      service/ocean_order.class.php
  2. 1 1
      service/tools.class.php

+ 69 - 1
service/ocean_order.class.php

@@ -2171,7 +2171,7 @@ class ocean_order {
             $_schemas = "ocean";
         }
         $sql = "with o as(
-            SELECT  o.* from ocean o where serial_no = '" . $serial_no . "'
+            SELECT  o.* from $order_from.ocean o where serial_no = '" . $serial_no . "'
         )
         SELECT m_eta as _m_eta,  h_bol as _h_bol, m_bol as _m_bol,job_no as _job_bol,
                 o.* ,sh.*, cn.* ,aa.*,dd.*,fd.*,oo.*,koe.loadterm
@@ -2338,10 +2338,74 @@ class ocean_order {
         $ocean['shippr_uncode'] = $ocean['place_of_receipt_un'];
         $ocean['consignee_uncode'] = $ocean['place_of_delivery_un'];
 
+        //delivery
+        $order_from = $_REQUEST['_schemas'];
+        $deliverySql = "with aa as (SELECT o.serial_no, o.master_base_number from  $order_from.ocean o WHERE o.serial_no='".$ocean["serial_no"]."'),
+                            bb as (select o.serial_no from $order_from.ocean o
+                                    where exists(select 1 from aa where aa.master_base_number= o.master_base_number) 
+                                        and o.bol_type = 'CONSOL' and o.status::text <> 'Cancelled'::text),
+                            cc as (select serial_no from aa 
+                                    union all 
+                                    select serial_no from bb 
+                                ),              
+                            h as (select * from station_data.do_header h where h.serial_no = (select serial_no from cc) and from_station = '".$ocean["from_station"]."')
+                    
+                    select h.est_delivery_date,h.est_delivery_time,
+                        h.consignee_country_code,h.consignee_city_code,
+                        (select time_zone from public.city_timezone where uncode = CONCAT(h.consignee_country_code, h.consignee_city_code) limit 1) as timezone,
+                        d.ctnr 
+                    from h left join station_data.do_detail d on h.id = d.do_header_id  order by h.est_delivery_date";
+        // $deliverySql = "with aa as (SELECT o.serial_no, o.master_base_number from  $order_from.ocean o WHERE o.serial_no='".$ocean["serial_no"]."'),
+        //                     bb as (select o.serial_no from $order_from.ocean o
+        //                             where exists(select 1 from aa where aa.master_base_number= o.master_base_number) 
+        //                                 and o.bol_type = 'CONSOL' and o.status::text <> 'Cancelled'::text),
+        //                     cc as (select serial_no from aa 
+        //                             union all 
+        //                             select serial_no from bb 
+        //                         ),              
+        //                     h as (select * from do_header h where h.serial_no = (select serial_no from cc))
+                    
+        //             select h.est_delivery_date,h.est_delivery_time,
+        //                 h.consignee_country_code,h.consignee_city_code,
+        //                 (select time_zone from public.city_timezone where uncode = CONCAT(h.consignee_country_code, h.consignee_city_code) limit 1) as timezone,
+        //                 d.ctnr 
+        //             from h left join do_detail d on h.do_serial_no = d.do_serial_no  order by h.est_delivery_date";            
+
+        $delivery = common::excuteListSql($deliverySql);            
+
         /* Container Status */
         //Container_Status 新版只显示几个状态, CTNR# EE I AE VD VA
         //记录所有的信息 EDI315TimeAndLocation
         $EDIDate = common::getEDI315StatusForDetail($ocean["serial_no"]);
+        $deliveredData = array();
+        $deliveredChildrenDate = "";
+        if(!empty($delivery)){
+            foreach($delivery as $_delivery){
+                //添加containerStatusData的delivery
+                $est_delivery_date = $_delivery["est_delivery_date"];
+                if (!empty($_delivery["est_delivery_time"])) {
+                    $est_delivery_date.= " " . $_delivery["est_delivery_time"];
+                }
+
+                $location_code = $_delivery["consignee_country_code"]."".$_delivery["consignee_city_code"];
+
+                foreach($EDIDate['containerStatusData'] as $cskey => $csval){
+                    if($csval['ctnr_label'] == $_delivery['ctnr']){
+                        $contentTemp = array("title" =>"Last Mile Delivery",
+                                "date"=>$est_delivery_date,
+                                "country"=>$location_code,
+                                "timezone"=>$_delivery['timezone']);
+
+                        $EDIDate['containerStatusData'][$cskey]['content'][] = $contentTemp;
+                    }
+                }
+                //添加simplexData的delivery
+                $deliveredData[] = array("label" =>"Delivered","date"=>$est_delivery_date,"location"=>$location_code,
+                    "container"=>$_delivery['ctnr'],'timezone'=>$_delivery['timezone']);
+                $deliveredChildrenDate =  $_delivery["est_delivery_date"];  
+            }
+        }
+
         $data['containerStatusData'] = $EDIDate['containerStatusData'];
         $data['EDI315TimeAndLocation'] = $EDIDate['EDI315TimeAndLocation'];
         $VD = $EDIDate['VD'];
@@ -2442,6 +2506,10 @@ class ocean_order {
                 $children[] = array("label" =>"Cargo handover/Delivered","date" =>$ocean_milestone_status_code['IFFDEL']['act_date']);
             }
         }
+        $children[] = array("label" =>"Delivered","date" =>$deliveredChildrenDate);
+
+        $place_of_Delivery_status["children"] = $children;
+        $place_of_Delivery_status["deliveredData"] = $deliveredData;     
         $simplexData[] = $place_of_Delivery_status;
         $data['shipmentData'] = $simplexData;
 

+ 1 - 1
service/tools.class.php

@@ -2134,7 +2134,7 @@ class tools {
         //                     where id = ni.id ) eee on true
         //                 left join LATERAL (select COALESCE(ke.default_time_zone,'UTC-08') as default_time_zone from public.kln_user_extend ke where lower(ke.user_login) = lower(ni.user_login) limit 1) ddd on true    
         //         order by ni.insert_date desc) aa";
-        error_log($sql);        
+        //error_log($sql);        
         $retData = common::excuteListSql($sql);
         return $retData;
     }