ShuanghongS 3 minggu lalu
induk
melakukan
832d52bfad

+ 21 - 4
service/destination_delivery.class.php

@@ -60,7 +60,7 @@ class destination_delivery {
             $sql  = "select code from public.kerry_system_code 
                     where description='COUNTRY-STATION'  
                         and category = '".$country."'   
-                        and code NOT LIKE 'Online_%' order by code";
+                        and code NOT LIKE 'ONLINE_%' order by code";
             $rs = common::excuteListSql($sql);
             foreach($rs as $key => $val){
                 if(!empty($val['code'])){
@@ -907,10 +907,18 @@ class destination_delivery {
                                 serial_no, action,notes, create_by, created_time, created_zone)
                         VALUES ('$serial_no', 'Submit','".$modify_reason."', '"._getLoginName()."', now(), ''); ";        
             } else {  
-                $saveData = $this->groupShipments($booking_no,$manifest_type,$h_bol,$h_serial_no,$order_from,$m_bol,$ctnr,$kln_pic,$consignee,$consignee_id,
+                //array("msg"=>"","result"=>$result);
+                $saveDataArr = $this->groupShipments($booking_no,$manifest_type,$h_bol,$h_serial_no,$order_from,$m_bol,$ctnr,$kln_pic,$consignee,$consignee_id,
                     $recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
                     $recommended_delivery_from,$recommended_delivery_to,$dc_country);
                 
+                if(!empty($saveDataArr['msg'])){
+                    $data = array("msg" =>$saveDataArr['msg']);
+                    common::echo_json_encode(200,$data); 
+                    exit();
+                }
+                
+                $saveData = $saveDataArr['result'];
                 foreach($saveData as $sData){
                     $serial_no = common::uuid();
 
@@ -1669,7 +1677,7 @@ class destination_delivery {
             $dc_country = $item['dc_country'];
             $consignee_id = $item['consignee_id'];
 
-            if($item['manifest_type'] == 'BCN'){
+            if(strtoupper($item['manifest_type']) == 'BCN'){
                 if (!isset($groupedByMbol[$m_bol])) {
                     $item['h_bol'] = array();
                     $item['h_bol_multiple_link'] = array();
@@ -1713,6 +1721,15 @@ class destination_delivery {
             }
         }
 
+        //检查是否选中所有的BCN
+        foreach($groupedByMbol as $mkey => $mval){
+            $mcount = common::excuteObjectSql("select count(*) from kln_ocean where m_bol = '".common::check_input($mkey)."'");
+            $hcount = count($mval['h_serial_no']);
+            if($mcount <> $hcount){
+                return array("msg"=>"MBL No.: ".$mkey.",The shipment of BCN has not been fully selected");
+            }
+        }
+
         $result = array();
         foreach($groupedByMbol as $mb){
             $result[] = $mb;
@@ -1720,7 +1737,7 @@ class destination_delivery {
         foreach($groupedByShipmentId as $hb){
             $result[] = $hb;
         }
-        return $result;
+        return array("msg"=>"","result"=>$result);
     }
 }
 

+ 11 - 6
service/ocean_order.class.php

@@ -1080,7 +1080,7 @@ class ocean_order {
             //                 FROM public.ocean_reference temp WHERE temp.serial_no = oo.serial_no) aa ON true ";
 
             $sql = "with oo  as (SELECT oe.*, order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,transport_mode_extend,
-                    h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
+                    h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,piece_count as _piece_count,
                     (select user_login from public.kln_user_subscribed us  
                         where lower(us.user_login) = '".strtolower(_getLoginName())."' and us.subscribed_serial_no = kln_ocean.serial_no) as is_subscribe,
                     CASE
@@ -1095,7 +1095,8 @@ class ocean_order {
                 from public.kln_ocean
                     LEFT JOIN LATERAL ( SELECT loadterm,
                         manifest_type,
-                        volume
+                        volume,
+                        last_mile_delivery_date
                     FROM public.kln_ocean_extend oe WHERE oe.serial_no::text = kln_ocean.serial_no::text and oe.order_from::text = kln_ocean.order_from::text) oe ON true " 
                 . $sqlWhere . " order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps.") 
             select oo.* ,
@@ -1120,7 +1121,7 @@ class ocean_order {
             from oo";
 
             $tmp_search_without_limit = "with oo  as (SELECT oe.*, order_from as _schemas,serial_no as __serial_no, serial_no,transport_mode,transport_mode_extend,
-                    h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
+                    h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,piece_count as _piece_count,
                     (select user_login from public.kln_user_subscribed us  
                         where lower(us.user_login) = '".strtolower(_getLoginName())."' and us.subscribed_serial_no = kln_ocean.serial_no) as is_subscribe,
                     CASE
@@ -1135,7 +1136,8 @@ class ocean_order {
                 from public.kln_ocean
                     LEFT JOIN LATERAL ( SELECT loadterm,
                         manifest_type,
-                        volume
+                        volume,
+                        last_mile_delivery_date
                     FROM public.kln_ocean_extend oe WHERE oe.serial_no::text = kln_ocean.serial_no::text and oe.order_from::text = kln_ocean.order_from::text) oe ON true " 
                 . $sqlWhere . " order by $order_by) 
            select oo.* ,
@@ -1173,6 +1175,9 @@ class ocean_order {
                                                 ($val['transport_mode_extend'] == 'road' ? "Road Freight": "")));
                 //status 改为ocean_milestone里的信息
                 $rs[$index]["Status"] = $rs[$index]["new_status"];
+                if($val['transport_mode'] == 'sea'){
+                    $rs[$index]["Chargeable Weight"] = $rs[$index]["_piece_count"];
+                }
                 $rs[$index]["Shipment Type"] = $rs[$index]["Shipment Type"] == 'GPE' ? 'LCL' : $rs[$index]["Shipment Type"];
                 //订阅的参数
                 if(empty($rs[$index]["is_subscribe"])){
@@ -1373,8 +1378,8 @@ class ocean_order {
         $cbm_tolal = sprintf("%.4f", $cbm_tolal);
         //Containers信息
         $containers = array("container_column"=>$ocean_container_column,"container_data" =>$rss);
-        //Packing信息
-        $packing = array("Quantity/Unit"=>$quantity_tolal,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
+        //Packing信息  ocean G和 Ch Weight 改成一样
+        $packing = array("Quantity/Unit"=>$quantity_tolal,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $g_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
         
         //Milestones info  列名固定
         $Milestones = common::getMilestonesInfo($ocean,"sea",$_schemas,$vueData['EDI315TimeAndLocation']);

+ 7 - 3
utils/common.class.php

@@ -4115,9 +4115,13 @@ class common {
         //从UI 设计的case来讲,一个hbol就生成成一个wo ID 
         foreach($h_serial_no_arr as $serial_no){
             $sql = "";
-            $oceanInfo = common::excuteObjectSql("select * from public.kln_ocean oo where oo.serial_no ='".$serial_no."'" );
-            //空運我們先不管,不做同步,就只做創建到審批,後面的讓他們自己錄入系統處理吧
-            if ($oceanInfo['transport_mode'] == "air"){
+            $oceanInfo = common::excuteObjectSql("select *,
+                case when order_from = 'public' and transport_mode ='sea' then (select manifest_type from public.ocean o where o.serial_no = oo.serial_no  limit 1)
+                     when order_from = 'sfs' and transport_mode ='sea' then (select manifest_type from sfs.ocean o where o.serial_no = oo.serial_no  limit 1)
+                else ''::text end as _manifest_type
+            from public.kln_ocean oo where oo.serial_no ='".$serial_no."'" );
+            //空運我們先不管,不做同步,就只做創建到審批,後面的讓他們自己錄入系統處理吧  
+            if ($oceanInfo['transport_mode'] == "air" || strtoupper($oceanInfo['_manifest_type']) == "BCN"){
                 continue;
             }
             $biztype = $oceanInfo['ex_im'] == "Export" && $oceanInfo['transport_mode'] == "sea" ? "SE" :(