소스 검색

first version

ShuanghongS 1 년 전
부모
커밋
67c4288f04
8개의 변경된 파일203개의 추가작업 그리고 105개의 파일을 삭제
  1. 3 3
      main_new_version.php
  2. 3 5
      service/ajax.class.php
  3. 2 2
      service/column.class.php
  4. 1 1
      service/login.class.php
  5. 0 1
      service/ocean_booking.class.php
  6. 117 58
      service/ocean_order.class.php
  7. 45 30
      utils/common.class.php
  8. 32 5
      utils/utils.class.php

+ 3 - 3
main_new_version.php

@@ -20,9 +20,9 @@ include 'service/login.class.php';
 include 'service/tools.class.php';
 
 //为了调用,临时做一个登录动作
-// $_POST['uname'] = "ra.admin";
-// $_POST['psw'] = "abc123456789";
-// login::getInstance()->do_login_auto();
+//  $_POST['uname'] = "ra.admin";
+//  $_POST['psw'] = "abc123456789";
+//  login::getInstance()->do_login_auto();
 //验证路由权限
 common::securityCheckHandNew($action);
 if (_is_only_vgm()) {

+ 3 - 5
service/ajax.class.php

@@ -95,7 +95,6 @@ class ajax {
             foreach($rs as $key => $val){
                 $rs[$key]["id"] = $key +1;
             }
-
             $arrTmp = array('searchData' => $rs, 
                     'rc' => $rc,
                     'ps' => $ps,
@@ -104,7 +103,7 @@ class ajax {
             common::echo_json_encode(200,$arrTmp);
             exit();
         }else{
-            $arrTmp = array('searchData' => "nodata");
+            $arrTmp = array('searchData' => array());
             common::echo_json_encode(200, $arrTmp);
             exit();
         }
@@ -136,12 +135,11 @@ class ajax {
             $rs = common::excuteListSql($sql);
         }
 
-        //Shipper 和Consignee  的查询 但是表contact_v ,从ocean和air. 如果不做区分的话,可以上面的apex的Origin Agent/Destination Agent,合并
+        //Shipper 和Consignee  的查询,但是表contact_v ,从ocean和air. 如果不做区分的话,可以上面的apex的Origin Agent/Destination Agent,合并
         if (strtolower($type) == "contanct") {
             $sql = "SELECT company as code from contact_v where active = true and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')";
             $sql .= " order by contact_id limit 20";
-            $rs = common::excuteListSql($sql);
-            
+            $rs = common::excuteListSql($sql); 
         }
 
         if (strtolower($type) == "sales") {

+ 2 - 2
service/column.class.php

@@ -243,7 +243,7 @@ class column {
             "created_time" =>array("formatter" =>"dateTime"),
             "confirmation_time" =>array("formatter" =>"dateTime"),
             "f_etd" =>array("formatter" =>"date"),
-            "f_eta" =>array("formatter" =>"date"));
+            "m_eta" =>array("formatter" =>"date"));
         }
         if ($type == "Ocean_Search"){
             return array("booking_no" =>array("type" =>"link"),
@@ -253,7 +253,7 @@ class column {
             "status" =>array("type" =>"status"),
             "created_time" =>array("formatter" =>"dateTime"),
             "etd" =>array("formatter" =>"date"),
-            "f_eta" =>array("formatter" =>"date"));
+            "eta" =>array("formatter" =>"date"));
         }
     }
 

+ 1 - 1
service/login.class.php

@@ -235,7 +235,7 @@ class login {
                         common::echo_json_encode(500, $data);
                         exit();
                     }else{
-                        //$this -> passwordExpires($loginName,$email);
+                        $this -> passwordExpires($loginName,$email);
                     }
                 }
 

+ 0 - 1
service/ocean_booking.class.php

@@ -268,7 +268,6 @@ class ocean_booking {
                 $rs[$index]["Status"] = $status;
                 $rs[$index]["Transportation Mode"] = "Ocean Freight";
             }
-
             
             $arrTmp = array('searchData' => $rs, 
                 'tagsList' => $tagsList,

+ 117 - 58
service/ocean_order.class.php

@@ -368,11 +368,12 @@ class ocean_order {
         }
 
         //查询tag
-        // IFFBCF;Booking Confirmation
-        // IFFREC;Cargo Arrived at Origin
-        // IFFDEP;Departure
-        // IFFARR;Arrived at Final Destination Port
-        // IFFAFD;Arrived at Final Destination
+        // IFFBCF  Booking Confirmation                      Booked
+        // IFFCPU  Cargo Pickup                              Cargo Received
+        // IFFREC  Cargo Arrived at Origin                   Cargo Received
+        // IFFDEP  Departure                                 Departed
+        // IFFARR  Arrived at Final Destination Port         Arrived
+        // IFFAFD  Arrived at Final Destination              Completed
         if (!empty($_POST["filterTag"])) {
             if (utils::count($_POST['filterTag']) == 1){
                 $filterTag = $_POST['filterTag'][0];
@@ -426,18 +427,18 @@ class ocean_order {
         //这里都要查询,除非多传几个参数回来
         if ($rc == - 1 || true) {
             $sql = "select count(1) from online_ocean
-	            left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
-							when a.description='Cargo Pickup' then 'Cargo Received'
-							when a.description='Cargo Arrived at Origin' then 'Cargo Received'
-							when a.description='Departure' then 'Departed'
-							when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
-							when a.description='Arrived at Final Destination' then 'Completed'
-							else 'Booked' END as status
-				from  ocean_milestone a 
-					where a.serial_no=online_ocean.serial_no 
-					and a.description in (
-						select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
-				 order by id desc limit 1) dd on true" . $sqlWhere;
+	            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+                                when a.code='IFFCPU' then 'Cargo Received'
+                                when a.code='IFFREC' then 'Cargo Received'
+                                when a.code='IFFDEP' then 'Departed'
+                                when a.code='IFFARR' then 'Arrived'
+                                when a.code='IFFAFD' then 'Completed'
+                                else 'Booked' END as status
+                        from  ocean_milestone a 
+                where a.serial_no=online_ocean.serial_no 
+                    and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFAFD', ','))
+                order by id desc limit 1) dd on true" . $sqlWhere;
+                
             $rc = common::excuteOneSql($sql);
             error_log("online_ocean_count_ALL_SQL:".$sql);
 
@@ -499,21 +500,20 @@ class ocean_order {
             $ocean_ref_sql = " LEFT JOIN LATERAL ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no
                             FROM public.ocean_reference temp WHERE temp.serial_no = online_ocean.serial_no) aa ON true ";
 
-            $ocean_status_sql = " LEFT JOIN LATERAL ( select case when a.description='Booking Confirmation' then 'Booked'
-							when a.description='Cargo Pickup' then 'Cargo Received'
-							when a.description='Cargo Arrived at Origin' then 'Cargo Received'
-							when a.description='Departure' then 'Departed'
-							when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
-							when a.description='Arrived at Final Destination' then 'Completed'
-							else 'Booked' END as new_status
-				from  ocean_milestone a 
-					where a.serial_no=online_ocean.serial_no 
-					and a.description in (
-						select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
-				 order by id desc limit 1) dd ON true ";
+            $ocean_status_sql = " LEFT JOIN LATERAL (select case when a.code='IFFBCF' then 'Booked'
+                                    when a.code='IFFCPU' then 'Cargo Received'
+                                    when a.code='IFFREC' then 'Cargo Received'
+                                    when a.code='IFFDEP' then 'Departed'
+                                    when a.code='IFFARR' then 'Arrived'
+                                    when a.code='IFFAFD' then 'Completed'
+                                    else 'Booked' END as new_status
+                            from  ocean_milestone a 
+                    where a.serial_no=online_ocean.serial_no 
+                        and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFAFD', ','))
+                    order by id desc limit 1) dd ON true ";
 
             $sql = "SELECT order_from as _schemas,serial_no as __serial_no, serial_no,
-                    h_bol as _hbol, isf_bol as _isfbol, 
+                    h_bol as _hbol, isf_bol as _isfbol, consignee_city as _consignee_city,
                     CASE
 	    	            WHEN dd.new_status is null THEN 'Booked'::text
 	    	            ELSE dd.new_status::text
@@ -528,7 +528,12 @@ class ocean_order {
                 //返回加密serial_no
                 $rs[$index]["__serial_no"] = common::deCode($val['__serial_no'], 'E');
                 $rs[$index]["mode"] = "Ocean Freight";
+                //status 改为ocean_milestone里的信息
                 $rs[$index]["Status"] = $rs[$index]["new_status"];
+                //以下新增的origin是 shipper和consignee的地址
+                if(array_key_exists("Origin", $val)){
+                    $rs[$index]["Origin"] = utils::outDisplayForMerge($val['Origin'],$val['_consignee_city']);
+                }
             }
         
             $arrTmp = array('searchData' => $rs, 
@@ -621,7 +626,6 @@ class ocean_order {
                 $ref_no[] = array("label"=>$ref["ref_code"],"value"=>$ref["ref_value"]);
             }
         }
-        
         //处理Container :配置Ocean_Container字段 UI 需要的字段有:Container.no Packing,quantity,Gross weight(kg),Gross weight(LB),CBM,seal#,size.service
         $ocean_container_column = array();
         $container_column = column::getInstance()->getDisplayColumnAll('Ocean_Container');
@@ -640,7 +644,7 @@ class ocean_order {
             $g_weight_tolal += $rs['grs_kgs'];
             $ch_weight_tolal += $rs['grs_lbs'];
             $cbm_tolal += $rs['cbm'];
-            $packages = " ".$rs['unit'];
+            $packages = $rs['unit'];
             //特殊处理weight
             if(!empty($rss[$key]['grs_kgs'])){
                 $rss[$key]['grs_kgs'] = $rs['grs_kgs']."KG";
@@ -649,10 +653,10 @@ class ocean_order {
                 $rss[$key]['grs_lbs'] = $rs['grs_lbs']."LB";
             }
         }
+        //Containers信息
         $containers = array("container_column"=>$ocean_container_column,"container_data" =>$rss);
-
         //Packing信息
-        $packing = array("Quantity/Unit"=>$quantity_tolal.$packages,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
+        $packing = array("Quantity/Unit"=>$quantity_tolal." ".$packages,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
        
         /* Container Status */
         //数据库里配置好
@@ -1158,17 +1162,16 @@ class ocean_order {
                 to_char(final_eta, 'MM/DD/YYYY') as _final_eta,
                 o.* ,sh.*, cn.* ,aa.*,dd.*,ee.status as new_status
             from ocean o 
-            left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
-                        when a.description='Cargo Pickup' then 'Cargo Received'
-                        when a.description='Cargo Arrived at Origin' then 'Cargo Received'
-                        when a.description='Departure' then 'Departed'
-                        when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
-                        when a.description='Arrived at Final Destination' then 'Completed'
-                        else 'Booked' END as status
-                from  ocean_milestone a 
-                    where a.serial_no=o.serial_no 
-                    and a.description in (
-                        select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
+            left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
+                                when a.code='IFFCPU' then 'Cargo Received'
+                                when a.code='IFFREC' then 'Cargo Received'
+                                when a.code='IFFDEP' then 'Departed'
+                                when a.code='IFFARR' then 'Arrived'
+                                when a.code='IFFAFD' then 'Completed'
+                                else 'Booked' END as status
+                        from  ocean_milestone a 
+                where a.serial_no=o.serial_no 
+                    and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFAFD', ','))
                 order by id desc limit 1) ee on true
             LEFT JOIN LATERAL ( SELECT company as cn_company,
                 address_1 as cn_address_1,
@@ -1208,25 +1211,81 @@ class ocean_order {
 
     private function returnOceanDetailData($ocean,$state){
         $data = array();
+        //处理shipment data
+        $ocean_milestone_status = common::excuteListSql("select code,
+                act_date,est_date,timezone 
+            from  ocean_milestone a 
+		 		where a.serial_no='".$ocean["serial_no"]."' and code in('IFFREC','IFFONB','IFFDEP','IFFARR','IFFDEL')
+            order by id");
+        $ocean_milestone_status_code = array();
+        foreach($ocean_milestone_status as $oms){
+            $ocean_milestone_status_code[$oms['code']] = $oms;
+        }     
 
-        //处理shipment data暂时写死
         $simplexData = array();
-        $simplexData[] = array("index" =>1,"label" =>"Place of Receipt",
-            "path" =>$ocean['place_of_receipt_exp']."/".$ocean['place_of_receipt'],"isArrival" =>$state == 1 ? true : false);
-
-        $simplexData[] = array("index" =>2,"label" =>"Port of Loading",
-            "path" =>$ocean['fport_of_loading_exp_exp']."/".$ocean['fport_of_loading_exp'],"isArrival" =>$state == 2 ? true : false,
-            "children" =>array(array("label" =>"Cargo arrival at Origin","date" =>"2024-02-01"),
-                            array("label" =>"'Departure","date" =>"2024-02-01")));
-
-        $simplexData[] = array("index" =>3,"label" =>"Port of Discharge",
-            "path" =>$ocean['mport_of_discharge_exp']."/".$ocean['mport_of_discharge'],"isArrival" =>$state == 3 ? true : false,
-            "children" =>array(array("label" =>"ETA","date" =>"2024-02-01")));
+        //place_of_Receipt
+        $place_of_Receipt_stauts =  array("index" =>1,"label" =>"Place of Receipt",
+            "path" =>$ocean['place_of_receipt_exp']."/".$ocean['place_of_receipt'],"isArrival" =>$state >= 1 ? true : false);
+        $children = array();  
+        if($state >= 1 && !empty($ocean_milestone_status_code['IFFREC']['act_date'])){
+            //发生后,未发生前没有
+            $children[] = array("label" =>"Cargo Received","date" =>$ocean_milestone_status_code['IFFREC']['act_date']);
+        }
+        $place_of_Receipt_stauts["children"] = $children;
+        $simplexData[] = $place_of_Receipt_stauts;
+
+        //port_of_Loading
+        $port_of_Loading_stauts = array("index" =>2,"label" =>"Port of Loading",
+            "path" =>$ocean['fport_of_loading_exp_exp']."/".$ocean['fport_of_loading_exp'],"isArrival" =>$state >= 2 ? true : false);
+        $children = array();  
+        if ($state <= 1){
+            //未发生前
+            if(!empty($ocean_milestone_status_code['IFFDEP']['est_date'])){
+                $children[] = array("label" =>"Departure(ETD)","date" =>$ocean_milestone_status_code['IFFDEP']['est_date']);
+            }
+        } else{
+            if(!empty($ocean_milestone_status_code['IFFONB']['act_date'])){
+                $children[] = array("label" =>"On board","date" =>$ocean_milestone_status_code['IFFONB']['act_date']);
+            }
+            if(!empty($ocean_milestone_status_code['IFFDEP']['act_date'])){
+                $children[] = array("label" =>"Departure(ATD)","date" =>$ocean_milestone_status_code['IFFDEP']['act_date']);
+            }
+        }                 
+        $port_of_Loading_stauts["children"] = $children;        
+        $simplexData[] = $port_of_Loading_stauts;
+
+        //Port of Discharge
+        $port_of_Discharge_status = array("index" =>3,"label" =>"Port of Discharge",
+            "path" =>$ocean['mport_of_discharge_exp']."/".$ocean['mport_of_discharge'],"isArrival" =>$state >= 3 ? true : false);
+        $children = array(); 
+        if ($state <= 2){
+            //未发生前
+            if(!empty($ocean_milestone_status_code['IFFARR']['est_date'])){
+                $children[] = array("label" =>"Arrival(ETA)","date" =>$ocean_milestone_status_code['IFFARR']['est_date']);
+            }
+        } else{
+            if(!empty($ocean_milestone_status_code['IFFARR']['act_date'])){
+                $children[] = array("label" =>"Arrival(ATA)","date" =>$ocean_milestone_status_code['IFFARR']['act_date']);
+            }
+        }                 
+        $port_of_Discharge_status["children"] = $children;     
+        $simplexData[] = $port_of_Discharge_status;
 
-        $simplexData[] = array("index" =>4,"label" =>"Place of Delivery",
+        //Place of Delivery
+        $place_of_Delivery_status = array("index" =>4,"label" =>"Place of Delivery",
             "path" =>$ocean['place_of_delivery_exp']."/".$ocean['place_of_delivery'],"isArrival" =>$state == 4 ? true : false);
+        $children = array(); 
+        if ($state <= 3){
+            //未发生前
+        } else{
+            if(!empty($ocean_milestone_status_code['IFFDEL']['act_date'])){
+                $children[] = array("label" =>"Cargo handover/Delivered","date" =>$ocean_milestone_status_code['IFFDEL']['act_date']);
+            }
+        }                 
+        $simplexData[] = $place_of_Delivery_status;
         $data['shipmentData'] = $simplexData;
 
+
         //处理transportInfo信息数据
         $transportInfo = array("Tracking No." =>$ocean['tracking_no'],"status"=>$ocean['new_status'],"mode" => "Ocean Freight",
             "origin" =>$ocean['origin_station'],"destination" =>$ocean['destination_station'],

+ 45 - 30
utils/common.class.php

@@ -1179,29 +1179,54 @@ class common {
     public static function getCo2eBar(){
         //新UI air sea road 目前只有sea
         $type = $_REQUEST["r_type"];
-        $container_type_arr = array("air","sea","road");
+        $shipment_mode_arr = array("air","sea","road");
 
         $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
         $sqlWhere = common::check_input($sqlWhere);
         $sqlWhere = " " . $sqlWhere;
 
-        $ContainerCounSeries = array();
+        $ContainerCount_Title = array();
+        //先查询总的排放量sea air road,确定排名后,在分别查询对应的sea air road
+        if ($type == "co2e_orgin"){
+            $co2e_shippr_sql = "select SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum ,
+                shippr_uncode as station from online_ocean  where 1=1 $sqlWhere group by shippr_uncode order by catnum desc limit 10";
+            $co2e_aLL = common::excuteListSql($co2e_shippr_sql);
+        }
+        if ($type == "co2e_destination"){
+            $co2e_consignee_sql = "select SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum,
+                consignee_uncode as station from online_ocean  where 1=1 $sqlWhere group by consignee_uncode order by catnum desc limit 10";
+            $co2e_aLL = common::excuteListSql($co2e_consignee_sql);
+        }
+        //最大Y值
+        $maxY = 0;
+        $stations = array();
+        foreach($co2e_aLL as $val){
+            $ContainerCount_Title[] = $val['station'];
+            $maxY = $maxY > $val['catnum'] ? $maxY : $val['catnum'];
+            $stations[] = $val['station'];
+        }
+        $station_str = utils::implode(',',$stations);
 
-        foreach($container_type_arr as $_container_type){
+        $ContainerCounSeries = array();
+        foreach($shipment_mode_arr as $_shipment_mode){
             //类型有 sea air road,目前之类只查询sea的,其他为空
-            $container_type = $_container_type;
+            $shipment_mode = $_shipment_mode;
+            $co2e = array();
             if ($type == "co2e_orgin"){
-                $co2e_orgin_sql = "select SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum ,origin as station from online_ocean  where 1=1 $sqlWhere group by origin order by catnum desc limit 10";
-                $co2e = common::excuteListSql($co2e_orgin_sql);
+                $co2e_shippr_sql_union = utils::_getSql($station_str,$type,$shipment_mode);
+                if(!empty($co2e_shippr_sql_union)){
+                    $co2e = common::excuteListSql($co2e_shippr_sql_union);
+                }
             }
             if ($type == "co2e_destination"){
-                $co2e_agent_sql = "select SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum,agent as station from online_ocean  where 1=1 $sqlWhere group by agent order by catnum desc limit 10";
-                $co2e = common::excuteListSql($co2e_agent_sql);
+                $co2e_consignee_union = utils::_getSql($station_str,$type,$shipment_mode);
+                if(!empty($co2e_shippr_sql_union)){
+                    $co2e = common::excuteListSql($co2e_consignee_union);
+                }
             }
 
             $total = 0;
             $max = 0;
-            $ContainerCount_Title = array();
             $data = array();
             foreach($co2e as $val){
                 $ContainerCount_Title[] = $val['station'];
@@ -1209,27 +1234,19 @@ class common {
                 $total = $total + $val['catnum'];
                 $max = $max < $val['catnum'] ? $val['catnum'] : $max;
             }
-            //这里处理为空,目前没有数据
-            if($container_type == "air" || $container_type == "road"){
-                $data = array();
-            }
-            $ContainerCounSeries[$container_type] = array("data"=>$data,"total"=>$total,"max"=>$max);
+            $ContainerCounSeries[$shipment_mode] = array("data"=>$data,"total"=>$total,"max"=>$max);
         }
         
-        //处理返回时数据格式
-        $max = 0;
+        //处理返回时数据格式 其实不太需要计算最大值,在最开始总量查询的时候以及查询出来
         $ContainerCounSeries_return = array();
         foreach($ContainerCounSeries as $k =>$v){
             $color = common::getItemStyle($type,$k);
             $ContainerCounSeries_return[] = array("name"=>$k,"type"=>"bar","emphasis" => array("focus" =>"none"),
                 "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));  
-            //$max = $max + $v['max'];
-            $max = $max < $v['max'] ? $v['max'] : $max;
-            
         }
         //处理返回原表数据格式
         //计算刻度值 最小值是0,最大值是3000,刻度是500  interval
-        $interval = utils::calculateTicks(0,$max,10);
+        $interval = utils::calculateTicks(0,$maxY,10);
         if($interval == 0){
             //处理返回默认值
             $interval = 1;
@@ -1240,28 +1257,27 @@ class common {
     }
 
     public static function getTopBar(){
-
         $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
         $sqlWhere = common::check_input($sqlWhere);
         $sqlWhere = " " . $sqlWhere;
 
-        $orgin10_sql = "select count(origin) as num,origin from online_ocean  where 1=1 $sqlWhere group by origin order by num desc limit 10";
-        $orgin10 = common::excuteListSql($orgin10_sql);
+        $shippr_uncode_10_sql = "select count(shippr_uncode) as num,shippr_uncode from online_ocean  where 1=1 $sqlWhere group by shippr_uncode order by num desc limit 10";
+        $shippr_uncode_10 = common::excuteListSql($shippr_uncode_10_sql);
 
-        $agent10_sql = "select count(agent) as num,agent from online_ocean  where 1=1 $sqlWhere group by agent order by num desc limit 10";
-        $agent10 = common::excuteListSql($agent10_sql);
+        $consignee_uncode_10_sql = "select count(consignee_uncode) as num,consignee_uncode from online_ocean  where 1=1 $sqlWhere group by consignee_uncode order by num desc limit 10";
+        $consignee_uncode_10 = common::excuteListSql($consignee_uncode_10_sql);
 
 
         $toporigin = array();
         $toporiginMap = array();
         $i = 0;
         $origiNunMax = 0;
-        foreach($orgin10 as $orgin){
+        foreach($shippr_uncode_10 as $orgin){
             $i = $i + 1;
             $map_sql = "select lon as lng, lat as lat,
                     '' as label, '' as infor, 3 as sort,
                     null::timestamp without time zone as stime,''::text as ptype 
-				from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode='".$orgin['origin']."'";
+				from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode='".$orgin['shippr_uncode']."'";
             $map = common::excuteObjectSql($map_sql);   
             // $json = '{"lng":"100.78594000","lat":"13.68521000","label":"'.$orgin['origin'].'","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"}';
             // $map = json_decode($json,true); 
@@ -1280,14 +1296,13 @@ class common {
         $topdestinationinMap = array();
         $i = 0;
         $agentiNunMax = 0;
-        foreach($agent10 as $agent){
+        foreach($consignee_uncode_10 as $agent){
             $i = $i + 1;
             $map_sql = "select lon as lng, lat as lat,
                     '' as label, '' as infor, 3 as sort,
                     null::timestamp without time zone as stime,''::text as ptype 
-				from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode='".$agent['agent']."'";
+				from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode='".$agent['consignee_uncode']."'";
             $map = common::excuteObjectSql($map_sql);  
-
             // $json = '{"lng":"100.78594000","lat":"13.68521000","label":"'.$agent['agent'].'","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"}';
             // $map = json_decode($json,true);
 

+ 32 - 5
utils/utils.class.php

@@ -393,11 +393,10 @@ class utils {
     public static function calculateTicks($minValue, $maxValue, $targetTickCount = 10) {
         $tickSpacing = ($maxValue - $minValue);
         $tickSpacing = intval($tickSpacing);
-        $len = strlen($tickSpacing);
-        if($len >=2 ){
-            $interval = ceil($tickSpacing/pow(10,$len-2)/10) *pow(10,$len-2);
-        }else{
-            $interval = ceil($tickSpacing/10);
+		$interval = ceil($tickSpacing / $targetTickCount);
+        $len = strlen($interval);
+        if ($len >1){
+            $interval = ceil($interval/pow(10,$len-1)) *pow(10,$len-1);
         }
         return $interval;
     }
@@ -427,5 +426,33 @@ class utils {
             return false;
         }
     }
+
+    public  static function _getSql($ids, $type,$shipment_mode) {
+        $ids_arr = explode(',', $ids);
+        $sql = "";
+        if($type == "co2e_orgin"){
+            $str = "SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum , shippr_uncode as station ";
+            $filed = "shippr_uncode";
+        } else {
+            $str = "SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum,consignee_uncode as station ";
+            $filed = "consignee_uncode";
+        }
+
+        $shipment_mode_where = " 1=1 ";
+        //这里处理为空,目前没有数据
+        if($shipment_mode == "air" || $shipment_mode == "road"){
+            $shipment_mode_where = " 1<>1 ";
+        }
+        foreach ($ids_arr as $value) {
+            if (!empty($value)) {
+                if (empty($sql)) {
+                    $sql .= "SELECT $str FROM from online_ocean  where $shipment_mode_where and $filed = '$value'";
+                } else {
+                    $sql .= " union all SELECT $str from online_ocean  where $shipment_mode_where and $filed = '$value'";
+                }
+            }
+        }
+        return $sql;
+    }
 }
 ?>