ShuanghongS hace 1 día
padre
commit
0b0dc03aba
Se han modificado 2 ficheros con 248 adiciones y 39 borrados
  1. 35 39
      service/ocean_order.class.php
  2. 213 0
      service/report.class.php

+ 35 - 39
service/ocean_order.class.php

@@ -1087,6 +1087,7 @@ class ocean_order {
             $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,piece_count as _piece_count,
                     f_vessel as _f_vessel, f_voyage as _f_voyage,
+                    COALESCE(oe.import_po_no,po_no) as _po_no,
                     (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
@@ -1103,24 +1104,18 @@ class ocean_order {
                         manifest_type,
                         volume,
                         last_mile_delivery_date,
-                        container_size
+                        container_size,
+                        import_po_no
                     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.* ,
-                case when oo.transport_mode ='sea'  and oo._schemas ='public'
-                        then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM public.ocean_reference temp 
-                                    WHERE temp.ref_code <> 'PO' 
-                                            AND COALESCE(temp.ref_value,'')<>''
-                                            AND temp.ref_value IS NOT NULL  
-                                            AND LENGTH(TRIM(BOTH FROM temp.ref_value)) > 0  
-                                            AND temp.serial_no = oo.serial_no)
-                    when oo.transport_mode ='sea'   and oo._schemas ='sfs'
-                        then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM sfs.ocean_reference temp 
-                                    WHERE temp.ref_code <> 'PO' 
-                                            AND COALESCE(temp.ref_value,'')<>''
-                                            AND temp.ref_value IS NOT NULL  
-                                            AND LENGTH(TRIM(BOTH FROM temp.ref_value)) > 0 
-                                            AND temp.serial_no = oo.serial_no)    
+                case when oo.transport_mode ='sea'
+                        then ( SELECT string_agg(code ||value, ', ') AS other_refenrence_no FROM public.reference_all temp 
+                                    WHERE temp.code <> 'PO' 
+                                            AND COALESCE(temp.value,'')<>''
+                                            AND temp.value IS NOT NULL  
+                                            AND LENGTH(TRIM(BOTH FROM temp.value)) > 0  
+                                            AND temp.serial_no = oo.serial_no group by code,value)
                     when oo.transport_mode ='air' 
                         then ''
                     else '' 
@@ -1130,6 +1125,7 @@ class ocean_order {
             $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,piece_count as _piece_count,
                     f_vessel as _f_vessel, f_voyage as _f_voyage,
+                    COALESCE(oe.import_po_no,po_no) as _po_no,
                     (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
@@ -1146,24 +1142,18 @@ class ocean_order {
                         manifest_type,
                         volume,
                         last_mile_delivery_date,
-                        container_size
+                        container_size,
+                        import_po_no
                     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.* ,
-                 case when oo.transport_mode ='sea'  and oo._schemas ='public'
-                        then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM public.ocean_reference temp 
-                                    WHERE temp.ref_code <> 'PO' 
-                                            AND COALESCE(temp.ref_value,'')<>''
-                                            AND temp.ref_value IS NOT NULL  
-                                            AND LENGTH(TRIM(BOTH FROM temp.ref_value)) > 0  
-                                            AND temp.serial_no = oo.serial_no)
-                    when oo.transport_mode ='sea'   and oo._schemas ='sfs'
-                        then ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no FROM sfs.ocean_reference temp 
-                                    WHERE temp.ref_code <> 'PO' 
-                                            AND COALESCE(temp.ref_value,'')<>''
-                                            AND temp.ref_value IS NOT NULL  
-                                            AND LENGTH(TRIM(BOTH FROM temp.ref_value)) > 0 
-                                            AND temp.serial_no = oo.serial_no)    
+                 case when oo.transport_mode ='sea'
+                        then ( SELECT string_agg(code ||value, ', ') AS other_refenrence_no FROM public.reference_all temp 
+                                    WHERE temp.code <> 'PO' 
+                                            AND COALESCE(temp.value,'')<>''
+                                            AND temp.value IS NOT NULL  
+                                            AND LENGTH(TRIM(BOTH FROM temp.value)) > 0  
+                                            AND temp.serial_no = oo.serial_no group by code,value)
                     when oo.transport_mode ='air' 
                         then ''
                     else '' 
@@ -1184,7 +1174,10 @@ class ocean_order {
                                                 ($val['transport_mode_extend'] == 'road' ? "Road Freight": "")));
 
                 $rs[$index]["Vessel/Airline"] = utils::outDisplayForMerge($val['_f_vessel'],$val['Vessel/Airline']);
-                $rs[$index]["Voyage/Flight"] = utils::outDisplayForMerge($val['_f_voyage'],$val['Voyage/Flight']); 
+                $rs[$index]["Voyage/Flight"] = utils::outDisplayForMerge($val['_f_voyage'],$val['Voyage/Flight']);
+                
+                //po_no 处理 有import 显示import
+                $rs[$index]["PO No."] = $rs[$index]["_po_no"];
 
                 //status 改为ocean_milestone里的信息
                 $rs[$index]["Status"] = $rs[$index]["new_status"];
@@ -1305,14 +1298,14 @@ class ocean_order {
         if(!empty($ocean['_invoice_no'])){
             $ref_no[] = array("label"=>"Invoice No.","value"=>$ocean['_invoice_no']);
         }
-        $ref_arr = common::excuteListSql("select * from ocean_reference where  ref_code <> 'PO' 
-            and COALESCE(ref_value,'')<>''
-            AND ref_value IS NOT NULL  
-            AND LENGTH(TRIM(BOTH FROM ref_value)) > 0  
-            and lower(serial_no) = '" . strtolower($serial_no) . "'");
+        $ref_arr = common::excuteListSql("select code,value from public.reference_all where  code <> 'PO' 
+            and COALESCE(value,'')<>''
+            AND value IS NOT NULL  
+            AND LENGTH(TRIM(BOTH FROM value)) > 0  
+            and lower(serial_no) = '" . strtolower($serial_no) . "' group by code,value");
         if(!empty($ref_arr)){
             foreach($ref_arr as  $ref) {
-                $ref_no[] = array("label"=>$ref["ref_code"],"value"=>$ref["ref_value"]);
+                $ref_no[] = array("label"=>$ref["code"],"value"=>$ref["value"]);
             }
         }
         //处理Container :配置Ocean_Container字段 UI 需要的字段有:Container.no Packing,quantity,Gross weight(kg),Gross weight(LB),CBM,seal#,size.service
@@ -1705,6 +1698,9 @@ class ocean_order {
                      
             //status 改为ocean_milestone里的信息
             $rs[$index]["Status"] = $rs[$index]["new_status"];
+
+            //po_no 处理 有import 显示import
+            $rs[$index]["PO No."] = $rs[$index]["_po_no"];
         }
         common::echo_json_encode(200,array("msg"=>"success","Data" => $rs));
         exit;
@@ -2219,7 +2215,8 @@ class ocean_order {
             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
+                o.* ,sh.*, cn.* ,aa.*,dd.*,fd.*,oo.*,koe.loadterm,
+                COALESCE(koe.import_po_no,oo.po_no) as _po_no
         from o 
         LEFT JOIN LATERAL ( SELECT tracking_no as _tracking_no,shippr_uncode,shipper_city,
                     consignee_uncode,consignee_city,incoterms,
@@ -2244,7 +2241,6 @@ class ocean_order {
                     (select uncity from $order_from.ports where uncode = oo.place_of_delivery_un limit 1) as pod_uncity,
                     (select time_zone from public.city_timezone where uncode = oo.final_desination_uncode limit 1) as _fd_timezone,
                     (select uncity from $order_from.ports where uncode = oo.final_desination_uncode limit 1) as _pd_uncity,
-                    po_no as _po_no,
                     invoice_no as _invoice_no,
                     CASE
                         WHEN ((m_iffbcf is not null or m_iffbcf is null) and 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

+ 213 - 0
service/report.class.php

@@ -0,0 +1,213 @@
+<?php
+
+if (!defined('IN_ONLINE')) {
+    exit('Access Denied');
+}
+
+/**
+ * Description of operation_log
+ *
+ * @author Administrator
+ */
+class report {
+
+    private static $_report;
+
+    public static function getInstance() {
+        if (!self::$_report) {
+            $c = __CLASS__;
+            self::$_report = new $c;
+        }
+        return self::$_report;
+    }
+
+    /**
+     * report 配置
+    */
+    public function report_config(){
+        $operate = utils::_get('operate');
+        $operate = strtolower($operate);
+
+        /**
+         * report的配置查询,
+        */
+        if ($operate == "search"){
+            $cp = common::check_input($_POST ['cp']); //current_page
+            $ps = common::check_input($_POST ['ps']); //ps
+            if (empty($ps))
+                $ps = 100;
+            if (empty($cp))
+                $cp = 1;
+
+            $rc = $_POST ['rc'];
+            if ($rc == - 1) {
+                $sql = "select count(*) from public.kln_report_template";
+                $rc = common::excuteOneSql($sql);
+            }
+            $tp = ceil($rc / $ps);
+            if ($rc > 0) {
+                $sql = "select * from public.kln_report_template";
+                $sql .= " order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
+                $rs = common::excuteListSql($sql);
+                $arrTmp = array('searchData' => $rs, 
+                        'rc' => intval($rc),
+                        'ps' => intval($ps),
+                        'cp' => intval($cp),
+                        'tp' => intval($tp));
+                common::echo_json_encode(200,$arrTmp);
+                exit();
+            }else{
+                $arrTmp = array('searchData' => array());
+                common::echo_json_encode(200, $arrTmp);
+                exit();
+            }
+        }
+
+        if ($operate == "add"){
+            $id = common::deCode($_REQUEST['id'], 'D');
+            if(!empty($id)){
+                //代表编辑
+                $reportMain = common::excuteObjectSql("select * from kln_report_template where id = $id");
+                $reportField = common::excuteListSql("select * from kln_report_field_config  where template_id = $id order by order_index");
+                $data = array("reportMain" => $reportMain,"reportField" =>$reportField);
+            }else{
+                $data = array("reportMain" =>array(),"reportField" =>array());
+            }
+            common::echo_json_encode(200,$data);                
+            exit(); 
+        }
+       
+        if ($operate == "report_field_load"){
+            $level = common::check_input($_POST['level']);
+            $template_id = common::check_input($_POST['template_id']);
+
+            $all_field = common::excuteListSql("select * from public.kln_report_field where level = '$level' order by id");
+
+            $right_field = common::excuteListSql("select * from public.kln_report_field_config where template_id = '$template_id' order by id");
+
+            $left_field = common::excuteListSql("select * from public.kln_report_field where level = '$level' 
+                    and id != ALL(select field_ids from public.kln_report_template where id = '$template_id') order by id");
+            
+                    
+        }
+
+        if ($operate == "save"){
+            $template_id = common::deCode($_POST['template_id'], 'D');
+            $name = common::check_input($_POST['name']);
+            $description = common::check_input($_POST['description']);
+            $level = common::check_input($_POST['level']);
+            $access_type = common::check_input($_POST['access_type']);
+            $party_ids = $_POST['party_ids'];
+            $group_names = $_POST['group_names'];
+
+            $sql = "";
+            if (!empty($serial_no)){
+                $updateSqlSet = " modify_by = '"._getLoginName()."',update_time = now()";
+                if (!empty($name)) {
+                    $updateSqlSet.= ", name = '$name' ";
+                }
+                if (!empty($description)) {
+                    $updateSqlSet.= ", description = '$description' ";
+                }
+                if (!empty($level)) {
+                    $updateSqlSet.= ", level = '$level' ";
+                }
+                if (!empty($access_type)) {
+                    $updateSqlSet.= ", access_type = '$access_type' ";
+                }
+                if (!empty($party_ids)) {
+                    $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $party_ids)) . '"';
+                    $updateSqlSet.= ", party_ids = '{".$pgsql_array."}'::text[]";
+                }
+                if (!empty($group_names)) {
+                    $pgsql_array = '"' . implode('","', array_map(fn($v) => str_replace("'", "''", $v), $group_names)) . '"';
+                    $updateSqlSet.= ", group_names = '{".$pgsql_array."}'::text[]";
+                }
+                //代表update 
+                $sql .= "update public.kln_report_config set ".$updateSqlSet."
+                    where serial_no = '$serial_no';";
+            } else {
+                //检查配置的站点是否于以前的配置的,是否重合
+                
+            }
+
+            $errmsg = "";
+            //柜子是先删除,后添加
+            $sql .= "delete from  public.kln_report_rule where recommended_delivery_serial_no = '';";
+           
+
+            if (empty($errmsg) && !empty($sql)){
+                common::excuteUpdateSql($sql);
+                $data = array("msg" =>"success");
+            } else {
+                $data = array("msg" =>$errmsg);
+            }  
+            common::echo_json_encode(200,$data);                
+            exit(); 
+        }
+
+        if ($operate == "delete"){
+            $serial_no = common::deCode($_POST['a'], 'D');
+            $sql = "delete from public.kln_report_config where serial_no = '$serial_no';";
+            $sql .= "delete from public.kln_report_rule where recommended_delivery_serial_no = '$serial_no';";
+            error_log($sql);
+            common::excuteUpdateSql($sql);
+            $data = array("msg" =>"success");
+            common::echo_json_encode(200,$data);                
+            exit(); 
+        }
+
+    }
+
+    /**
+     *  shipment_status_report
+    */
+    public function shipment_status_report(){
+        $operate = utils::_get('operate');
+        $operate = strtolower($operate);
+
+        if ($operate == "report_search") {
+            //search
+            //栏位信息
+            $column = column::getInstance()->getDisplayColumn('report_Search');
+            $BookingTableColumns = column::getInstance()->tableColumns('report_Search',$column);
+            $data['TrackingTableColumns'] = $BookingTableColumns;
+            common::echo_json_encode(200,$data);
+            exit();
+        }
+    }
+
+    /**
+     * 关于report 页面的所有的静态加载数据查询
+    */
+    public function report_load(){
+        $operate = utils::_get('operate');
+        $operate = strtolower($operate);
+
+        /**
+         * select country
+         */
+        if ($operate == "country") {
+            $term = $_POST['term'];
+            $term = trim($term);
+            $sql = "select DISTINCT category AS country_code from public.kerry_system_code
+                        where description='COUNTRY-STATION' 
+                              and category ilike '" . common::check_input($term) . "%'";
+            $sql .= " order by category";
+
+            $rs = common::excuteListSql($sql);
+            //前端要加上id 从1开始
+            $retData = array();
+            foreach($rs as $key => $val){
+                if(!empty($val['country_code'])){
+                    $retData[] = array("value" =>$val['country_code'] ,"label"=>$val['country_code']);
+                }
+            }
+            common::echo_json_encode(200,$retData);
+            exit();
+
+        }
+    }
+}
+
+?>