ShuanghongS 2 недель назад
Родитель
Сommit
835b67e89c
5 измененных файлов с 205 добавлено и 13 удалено
  1. 1 1
      include.ini.php
  2. 10 10
      main_new_version.php
  3. 5 2
      service/ocean_order.class.php
  4. 40 0
      service/report.class.php
  5. 149 0
      utils/dms_edoc.class.php

+ 1 - 1
include.ini.php

@@ -8,7 +8,7 @@ if (extension_loaded('zlib')) {
 if (!empty($_REQUEST['sessionid'])) {
     session_id($_REQUEST['sessionid']);
 }
-error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
+//error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
 error_reporting(0);
 session_start();
 

+ 10 - 10
main_new_version.php

@@ -100,17 +100,17 @@ switch ($action) {
                         }
                         //特殊处理book,需要加二级菜
                         if($v['s_column'] =="Ocean Booking"){
-                            // $urlData = $menuSetting[$v['s_column']];
-                            // $menuList[] = array("index"=>"$index","label"=>$urlData['label'],"icon"=>$urlData['icon'],"path"=>$urlData['path']);
-                            $bookingManagement = array("index"=>"$index","label"=>"Booking","icon"=>"icon_booking__fill_b","type"=>"list");
-                            $children  = array(); 
-
                             $urlData = $menuSetting[$v['s_column']];
-                            $children[] = array("index"=>$index.'-1',"label"=>"Booking Management","path"=>$urlData['path']);
-                            $children[] = array("index"=>$index.'-2',"label"=>"Destination Delivery","path"=>"/destination-delivery");
-                            $bookingManagement["children"] = $children;
-                            $menuList[] = $bookingManagement;
-                            $index = $index + 1;
+                            $menuList[] = array("index"=>"$index","label"=>$urlData['label'],"icon"=>$urlData['icon'],"path"=>$urlData['path']);
+                            // $bookingManagement = array("index"=>"$index","label"=>"Booking","icon"=>"icon_booking__fill_b","type"=>"list");
+                            // $children  = array(); 
+
+                            // $urlData = $menuSetting[$v['s_column']];
+                            // $children[] = array("index"=>$index.'-1',"label"=>"Booking Management","path"=>$urlData['path']);
+                            // $children[] = array("index"=>$index.'-2',"label"=>"Destination Delivery","path"=>"/destination-delivery");
+                            // $bookingManagement["children"] = $children;
+                            // $menuList[] = $bookingManagement;
+                            // $index = $index + 1;
                         }
                     }
                 }

+ 5 - 2
service/ocean_order.class.php

@@ -935,7 +935,8 @@ class ocean_order {
             $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$textSearch_arr)));
             //$sqlWhere .= " and (ARRAY[$more_param] && array_append(array[lower(booking_no)::text,lower(h_bol)::text, lower(po_no),lower(carrier_booking),lower(tracking_no)],''))";
             $sqlWhere .= " and ((ARRAY[$more_param] && array_append(ARRAY[lower(booking_no::text), lower(h_bol::text), lower(m_bol), lower(carrier_booking), lower(quote_no), lower(tracking_no)]||string_to_array(lower(ctnrs),','), ''::text))
-                or lower(po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%'
+                or lower(kln_ocean.po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%'
+                or lower(oe.import_po_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%'
                 or lower(invoice_no) like '%" . strtolower(common::check_input($_POST["_textSearch"])) . "%')";
         }
         //移除filterTag
@@ -1028,7 +1029,9 @@ class ocean_order {
                 sum(case when ($mode_param_search and m_iffdel is not null) then 1 else 0 end) as completed,
                 string_agg(distinct incoterms, '<$>') as incoterm_str,
                 string_agg(distinct service, '<$>') as service_str 
-            from public.kln_ocean". $sqlWhere_befrom_filterTag;
+            from public.kln_ocean 
+                left join public.kln_ocean_extend oe 
+                    on oe.serial_no::text = kln_ocean.serial_no::text and oe.order_from::text = kln_ocean.order_from::text ". $sqlWhere_befrom_filterTag;
             error_log("online_ocean_search_All_Status: ".$sql);
 
             //$sql_all_status_data = common::excuteObjectSql($sql);

+ 40 - 0
service/report.class.php

@@ -394,6 +394,46 @@ class report {
                 exit();
             }
         }
+
+        if ($operate == "report_detail_column"){
+            $serial_no = common::check_input($_POST ['serial_no']); 
+            $dataReturn = array();
+            $filtersList = array();
+
+            $reportFiled = common::excuteListSql("select * from public.kln_report_field_config where template_serial_no = '".$serial_no."' 
+                and is_enabled = true order by id ");
+            foreach($reportFiled as $filed){
+                if($filed['is_filter_enabled'] == 't'){
+                    $field_display_name = $filed['field_display_name'];
+                    $field_display_name = strtolower($field_display_name);
+                    $field_display_name = preg_replace('/[^a-z0-9]+/', '_', $field_display_name); // 非字母数字 → _
+                    $field_display_name = trim($field_display_name, '_');
+                    
+                    $realSelect = common::getSelectedArray($filed['field_display_name']);
+                    $data_type = $filed['data_type'];
+                    if(!empty($realSelect)){
+                        $data_type = 'select';
+                    }
+                    $supportMultiple = false;
+                    if($filed['field_display_name_user'] == "Consignee" || $filed['field_display_name_user'] == "Consignee ID" 
+                        || $filed['field_display_name_user'] == "Shipper" || $filed['field_display_name_user'] == "Shipper ID"
+                        || $filed['field_display_name_user'] == "Controlling Customer"){
+                        $supportMultiple = true;
+                    }
+                    $filtersList[] = array(
+                        "label"=>$filed['field_display_name_user'],
+                        "field"=>$field_display_name,
+                        "field_real"=>$filed['field_display_name'],
+                        "data_type"=>$data_type,
+                        "value"=>'',"options"=>$realSelect,"supportMultiple"=>$supportMultiple);
+                }
+            }
+            $dataReturn['filtersList'] =  $filtersList;
+            $reportFiled = common::excuteObjectSql("select name,report_sql,count_sql,level from public.kln_report_template where serial_no = '".$serial_no."'");
+            $dataReturn['reportName'] =  $reportFiled['name'];
+            common::echo_json_encode(200, $dataReturn);
+            exit();
+        }
         
         if ($operate == "report_detail") {
             $serial_no = common::check_input($_POST ['serial_no']); 

+ 149 - 0
utils/dms_edoc.class.php

@@ -0,0 +1,149 @@
+<?php
+
+if (!defined('IN_ONLINE')) {
+    exit('Access Denied');
+}
+
+/**
+ * Description of utilsclass
+ *
+ * @author Administrator
+ */
+class utils {
+    private static $cachedToken = null;
+    private static $tokenExpiryTime = 0;
+
+    /**
+     * 获取文件
+    */
+    public static function getEdocFile($hbol,$docTypes){
+        try {
+            $result = null;
+            $data = [
+                'fromStation' => '',
+                'hbol'        => $hbol,
+                'docTypes'    => $docTypes
+            ];
+
+            $accessTokenUrl = 'http://dms.kln.com/keycloak/realms/dsms-realm/protocol/openid-connect/token';
+            //prod 账号
+            $grant_type = 'client_credentials';
+            $client_id = 'online';
+            $client_secret = 'ouuRZ8QbIrcqKZi0NBJLt7PUEiRr5uXd';
+            $accessToken = utils::getAccessToken($accessTokenUrl,$grant_type,$client_id,$client_secret);
+            if ($accessToken === null) {
+                throw new Exception("Failed to obtain access token");
+            }
+
+            $New_Dms_Url = 'http://dms.kln.com/edoc/documents/fileList'; 
+            $result = utils::CURLClient($New_Dms_Url,$accessToken,$data);
+        } catch (Exception $e) {
+            error_log("Error in downloadFiles: " . $e->getMessage());
+        }
+        return $result;
+        
+    }
+
+    public static function getAccessToken($accessTokenUrl,$grant_type,$client_id,$client_secret){
+        if (self::$cachedToken !== null && time() * 1000 < self::$tokenExpiryTime) {
+            return self::$cachedToken;
+        }
+
+        $postData = http_build_query([
+            'grant_type' => $grant_type,
+            'client_id' => $client_id,
+            'client_secret' => $client_secret
+        ]);
+
+        $headers = [
+            'Content-Type: application/x-www-form-urlencoded',
+            'Accept: application/json'
+        ];
+
+        $curlInit = curl_init();
+
+        curl_setopt_array($curlInit, [
+            CURLOPT_URL            => $accessTokenUrl,
+            CURLOPT_POST           => true,
+            CURLOPT_POSTFIELDS     => $postData,
+            CURLOPT_HTTPHEADER     => $headers,
+            CURLOPT_RETURNTRANSFER => true,  // 关键!返回字符串而不是输出
+            CURLOPT_SSL_VERIFYPEER => false, // 生产环境建议开启
+            CURLOPT_TIMEOUT        => 30,
+            CURLOPT_HEADER         => false,  // 不返回 header
+        ]);
+
+        $response = curl_exec($curlInit);
+        $httpCode = curl_getinfo($curlInit, CURLINFO_HTTP_CODE);
+
+        // 关闭 cURL
+        curl_close($curlInit);
+
+        // 解析响应
+        if ($httpCode === 200) {
+            $jsonResponse = json_decode($response, true);
+            if (isset($jsonResponse['access_token'])) {
+                self::$cachedToken = $jsonResponse['access_token'];
+                //计算过期时间,但是换算成毫秒*1000
+                $expiresIn = isset($jsonResponse['expires_in']) ? $jsonResponse['expires_in'] * 1000 : 0;
+                self::$tokenExpiryTime = (time() * 1000) + $expiresIn - 300000;
+                return self::$cachedToken;
+            } 
+        } 
+        self::$cachedToken = null;
+        self::$tokenExpiryTime = 0;
+        return null;
+    }
+
+    /**
+     * 使用 cURL
+    */
+    public static function CURLClient($url,$accessToken,$data){
+        $headers = [
+            'Authorization: Bearer ' . $accessToken,
+            'Content-Type: application/json',
+            'Accept: ' . 'application/json'
+        ];
+        //$url = 'http://dsms-alb-internet-facing-449737170.ap-southeast-1.elb.amazonaws.com/edoc/documents/fileList';
+        //$url = 'http://dms.kln.com/edoc/documents/fileList';
+        // 将数据编码为 JSON
+        $jsonData = json_encode($data);
+        try {
+            $curlInit = curl_init();
+
+            curl_setopt_array($curlInit, [
+                CURLOPT_URL            => $url,
+                CURLOPT_POST           => true,
+                CURLOPT_POSTFIELDS     => $jsonData,
+                CURLOPT_HTTPHEADER     => $headers,
+                CURLOPT_RETURNTRANSFER => true,  // 关键!返回字符串而不是输出
+                CURLOPT_SSL_VERIFYPEER => false, // 生产环境建议开启
+                CURLOPT_TIMEOUT        => 30,
+                CURLOPT_HEADER         => false,  // 不返回 header
+            ]);
+
+            $response = curl_exec($curlInit);
+            // 检查是否有错误
+            if ($response === false) {
+                $error = curl_error($curlInit);
+                error_log("cURL 请求失败: " . $error);
+                throw new Exception("cURL 请求失败: " . $error);
+            }
+            // 获取 HTTP 状态码
+            $httpCode = curl_getinfo($curlInit, CURLINFO_HTTP_CODE);
+            // 关闭 cURL
+            curl_close($curlInit);
+            // 解析响应
+            $result = json_decode($response, true);
+            if ($httpCode == 200 && isset($result['data'])) {
+                return json_encode($result['data'], JSON_UNESCAPED_UNICODE);
+            }else{
+                return null;
+            }
+        } catch (Exception $e) {
+            error_log($e->getMessage());
+        }
+    }
+
+}
+?>