|
|
@@ -163,16 +163,18 @@ class ocean_order {
|
|
|
if ($schemas <> "public") {
|
|
|
$err_msg .= "This hbol do not support.";
|
|
|
}
|
|
|
+ $err_msg_ctnr = "";
|
|
|
+ $err_msg_CFS = "";
|
|
|
foreach ($rs as $cv) {
|
|
|
if (empty($cv["ctnr"])) {
|
|
|
- $err_msg .= "Container# is empty.";
|
|
|
+ $err_msg_ctnr = "Container# is empty.";
|
|
|
}
|
|
|
if (substr($cv["service"], 0, 3) == "CFS") {
|
|
|
- $err_msg .= "CFS cannot support update.";
|
|
|
+ $err_msg_CFS = "CFS cannot support update.";
|
|
|
}
|
|
|
}
|
|
|
if (!empty($err_msg)) {
|
|
|
- $err_msg = "You cant't add this VGM, (" . $err_msg . ")";
|
|
|
+ $err_msg = "You cant't add this VGM, (" . $err_msg ." ". $err_msg_ctnr." ".$err_msg_CFS.")";
|
|
|
}
|
|
|
$serial_no = common::deCode($serial_no, "E");
|
|
|
|
|
|
@@ -646,6 +648,7 @@ class ocean_order {
|
|
|
//处理containerStatusData
|
|
|
$containerStatusData = $vueData['containerStatusData'];
|
|
|
|
|
|
+
|
|
|
//处理ocean_reference
|
|
|
$ref_no = array();
|
|
|
$ref_arr = common::excuteListSql("select * from ocean_reference where lower(serial_no) = '" . strtolower($serial_no) . "'");
|
|
|
@@ -704,7 +707,7 @@ class ocean_order {
|
|
|
$packing = array("Quantity/Unit"=>$quantity_tolal,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
|
|
|
|
|
|
//Milestones info 列名固定
|
|
|
- $Milestones = common::getMilestonesInfo($ocean);
|
|
|
+ $Milestones = common::getMilestonesInfo($ocean,$vueData['EDI315TimeAndLocation']);
|
|
|
|
|
|
//页面固定写死的信息
|
|
|
$document_column = array();
|
|
|
@@ -779,7 +782,6 @@ class ocean_order {
|
|
|
}
|
|
|
$document_info = array("document_column"=>$document_column,"document_data" =>$document_data);
|
|
|
|
|
|
-
|
|
|
$emailRecords = $this->getCommunicationNew($ocean["serial_no"]);
|
|
|
$cc_email = common::excuteOneSql("select cc_email from public.online_ocean_communication where email_uuid='" . $ocean["serial_no"] . "' order by id desc limit 1");
|
|
|
$email = $this->getEmail($ocean["serial_no"]);
|
|
|
@@ -1096,13 +1098,24 @@ class ocean_order {
|
|
|
$_schemas = "ocean";
|
|
|
}
|
|
|
$sql = "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.*,oo.*,
|
|
|
- (select uncode from ports where code = o.port_of_transshipment) as port_of_transshipment_un
|
|
|
+ o.* ,sh.*, cn.* ,aa.*,dd.*,fd.*,oo.*,
|
|
|
+ (select uncode from ports where code = o.port_of_transshipment) as port_of_transshipment_un,
|
|
|
from ocean o
|
|
|
LEFT JOIN LATERAL ( SELECT tracking_no as _tracking_no,shippr_uncode,shipper_city,
|
|
|
consignee_uncode,consignee_city,incoterms,
|
|
|
- fport_of_loading_un,mport_of_discharge_un,
|
|
|
- place_of_receipt_un,place_of_delivery_un,po_no as _po_no,
|
|
|
+ fport_of_loading_un,
|
|
|
+ mport_of_discharge_un,
|
|
|
+ place_of_receipt_un,
|
|
|
+ place_of_delivery_un,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = oo.fport_of_loading_un) as pol_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.fport_of_loading_un) as pol_uncity,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = oo.mport_of_discharge_un) as mpod_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.mport_of_discharge_un) as mpod_uncity,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = oo.place_of_receipt_un) as por_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.place_of_receipt_un) as por_uncity,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = oo.place_of_delivery_un) as pod_timezone,
|
|
|
+ (select uncity from public.ports where uncode = oo.place_of_delivery_un) as pod_uncity,
|
|
|
+ po_no as _po_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_iffafd is null) THEN 'Created'::text
|
|
|
WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffafd is null) THEN 'Cargo Received'::text
|
|
|
@@ -1134,7 +1147,8 @@ class ocean_order {
|
|
|
address_3 as aa_address_3,
|
|
|
address_4 as aa_address_4,
|
|
|
city as aa_city, state as aa_state, zipcode as aa_zipcode, country as aa_country,
|
|
|
- phone_1 as aa_phone
|
|
|
+ phone_1 as aa_phone,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = LEFT(country, 2) || COALESCE(city_code,'')) as aa_timezone
|
|
|
FROM $_schemas.contacts c WHERE o.origin_station::text = c.contact_id::text) aa ON true
|
|
|
LEFT JOIN LATERAL ( SELECT company as dd_company,
|
|
|
address_1 as dd_address_1,
|
|
|
@@ -1142,8 +1156,13 @@ class ocean_order {
|
|
|
address_3 as dd_address_3,
|
|
|
address_4 as dd_address_4,
|
|
|
city as dd_city, state as dd_state, zipcode as dd_zipcode, country as dd_country,
|
|
|
- phone_1 as dd_phone
|
|
|
+ phone_1 as dd_phone,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = LEFT(country, 2) || COALESCE(city_code,'')) as dd_timezone
|
|
|
FROM $_schemas.contacts c WHERE o.destination_station::text = c.contact_id::text) dd ON true
|
|
|
+ LEFT JOIN LATERAL ( SELECT
|
|
|
+ city as fd_city,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = LEFT(country, 2) || COALESCE(city_code,'')) as fd_timezone
|
|
|
+ FROM $_schemas.contacts c WHERE o.final_desination::text = c.contact_id::text) fd ON true
|
|
|
where lower(serial_no) = '" . strtolower($serial_no) . "'";
|
|
|
return $sql;
|
|
|
}
|
|
|
@@ -1162,25 +1181,42 @@ class ocean_order {
|
|
|
$VD = "";
|
|
|
$VA = "";
|
|
|
foreach ($ctnr_data as $cd){
|
|
|
+ //存在柜号为空的数据情况
|
|
|
+ if(empty($cd['ctnr'])){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
$ctnr_status_sql = "select s.source_id, s.event_base as event,
|
|
|
to_char(to_timestamp(s.event_date, 'YYYYMMDD'), 'YYYY-MM-DD') as eventdate,
|
|
|
to_char(to_timestamp(s.event_time, 'HH24MI'), 'HH24:MI') as eventtime,
|
|
|
e.description,s.event_type as eventtype,
|
|
|
- s.event_code as eventcode, s.event_city as eventcity
|
|
|
+ s.event_code as eventcode, s.event_city as eventcity,
|
|
|
+ (select timezonecode from public.city_ports where ctrycitycode = s.event_code) as timezone,
|
|
|
+ (select uncity from public.ports where uncode = s.event_code) as uncity,
|
|
|
+ case when event ='I' then 'IFFREC'::text
|
|
|
+ when event ='AE' then 'IFFONB'::text
|
|
|
+ when event ='VD' then 'IFFDEP'::text
|
|
|
+ when event ='EB' or event ='VA' then 'IFFARR'::text
|
|
|
+ when event ='UV' then 'IFFUND'::text
|
|
|
+ when event ='VA' then 'IFFAFD'::text
|
|
|
+ when event ='AV' then 'IFFCTA'::text
|
|
|
+ when event ='CT' then 'IFFICC'::text
|
|
|
+ when event ='OA' or event ='D' then 'IFFPPD'::text
|
|
|
+ when event ='EE' then 'IFFECP'::text
|
|
|
+ else '' ::text
|
|
|
+ end as milestone_code
|
|
|
from public.ra_online_container_status_v s
|
|
|
left join ra_online_edi_event e on s.event_base = e.ra_name
|
|
|
where s.serial_no = '" . pg_escape_string($cd['serial_no']) . "'
|
|
|
and s.container_no = '" . pg_escape_string($cd['ctnr']) . "' and is_display = true
|
|
|
order by to_timestamp(s.event_date, 'YYYYMMDD') asc,
|
|
|
- to_timestamp(s.event_time, 'HH24MI') asc,
|
|
|
- e.ra_order asc";
|
|
|
+ to_timestamp(s.event_time, 'HH24MI') asc,e.ra_order asc";
|
|
|
$ctnr_status = common::excuteListSql($ctnr_status_sql);
|
|
|
|
|
|
//Container_Status 新版只显示几个状态, CTNR# EE I AE VD VA
|
|
|
$container_status_column = array("EE","I","AE","VD","VA");
|
|
|
$containerStatusDataTemp = array();
|
|
|
- $ctnr_uncodes = "";
|
|
|
$content = array();
|
|
|
+ //按顺序处理 新版只显示几个状态
|
|
|
foreach($container_status_column as $status){
|
|
|
foreach($ctnr_status as $event){
|
|
|
if(strtolower($event['event']) == strtolower($status)){
|
|
|
@@ -1189,24 +1225,28 @@ class ocean_order {
|
|
|
$eventdate.= " " . $event["eventtime"];
|
|
|
}
|
|
|
$location_code = $event["eventcode"];
|
|
|
- $content[] = array("code" =>$status,"title" =>$event['description'],"date"=>$eventdate,"country"=>$location_code);
|
|
|
- $ctnr_uncodes .=$location_code.";";
|
|
|
+ $content[] = array("code" =>$status,"title" =>$event['description'],"date"=>$eventdate,"country"=>$location_code,"timezone"=>$event['timezone']);
|
|
|
+ if(strtolower($event['event']) == "vd" && !empty($eventdate)){
|
|
|
+ $VD = $eventdate;
|
|
|
+ }
|
|
|
+ if(strtolower($event['event']) == "va" && !empty($eventdate)){
|
|
|
+ $VA = $eventdate;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //查询全部uncode timezone
|
|
|
- $uncode_rs = common::getCityPortsInfo($ctnr_uncodes);
|
|
|
- //循环去回填时区
|
|
|
- foreach($content as $ck => $cv){
|
|
|
- $content[$ck]['timezone'] = $uncode_rs[$cv['country']];
|
|
|
- //记录vd
|
|
|
- if($cv['code'] == "VD" && empty($cv['date'])){
|
|
|
- $VD = $cv['date'];
|
|
|
+ //记录所有的信息
|
|
|
+ $EDI315TimeAndLocation = array();
|
|
|
+ foreach($ctnr_status as $event){
|
|
|
+ if(!empty($EDI315TimeAndLocation['IFFARR']) && $EDI315TimeAndLocation['IFFARR']['code'] == "EB"){
|
|
|
+ //如果存在EB 的EB 的优先级最高
|
|
|
+ continue;
|
|
|
}
|
|
|
- //记录vd
|
|
|
- if($cv['code'] == "VA" && empty($cv['date'])){
|
|
|
- $VA = $cv['date'];
|
|
|
+ if(!empty($EDI315TimeAndLocation['IFFPPD']) && $EDI315TimeAndLocation['IFFARR']['code'] == "OA"){
|
|
|
+ //如果存在OA 的OA 的优先级最高
|
|
|
+ continue;
|
|
|
}
|
|
|
+ $EDI315TimeAndLocation[$event['milestone_code']] = array("code"=>$event['event'],"timezone"=>$event['timezone'],"location"=>$event['uncity']);
|
|
|
}
|
|
|
|
|
|
$containerStatusDataTemp['label'] = $cd['ctnr']." / ".$cd['size'];
|
|
|
@@ -1214,6 +1254,7 @@ class ocean_order {
|
|
|
$containerStatusData[] = $containerStatusDataTemp;
|
|
|
}
|
|
|
$data['containerStatusData'] = $containerStatusData;
|
|
|
+ $data['EDI315TimeAndLocation'] = $EDI315TimeAndLocation;
|
|
|
|
|
|
//处理shipment data
|
|
|
$ocean_milestone_status = common::excuteListSql("select code,
|
|
|
@@ -1226,14 +1267,6 @@ class ocean_order {
|
|
|
$ocean_milestone_status_code[$oms['code']] = $oms;
|
|
|
}
|
|
|
|
|
|
- //当EDI315更新时,处理f_etd,m_eta(目前数据未同步,如果以后数据规范后,可以直接用milestone的值)
|
|
|
- if(!empty($VD)){
|
|
|
- $ocean['f_etd'] = $VD;
|
|
|
- }
|
|
|
- if(!empty($VA)){
|
|
|
- $ocean['m_eta'] = $VA;
|
|
|
- }
|
|
|
-
|
|
|
if ($state < 1){
|
|
|
//未发生前
|
|
|
if(!empty($ocean_milestone_status_code['IFFDEP']['est_date'])){
|
|
|
@@ -1247,11 +1280,11 @@ class ocean_order {
|
|
|
}
|
|
|
}
|
|
|
//先处理一下 ATD 和 ATA,在进行后面的取值
|
|
|
- if(empty($ocean['atd'])){
|
|
|
- $ocean['atd'] = $ocean['f_etd'];
|
|
|
+ if(empty($ocean['atd']) && !empty($VD)){
|
|
|
+ $ocean['atd'] = $VD;
|
|
|
}
|
|
|
- if(empty($ocean['ata'])){
|
|
|
- $ocean['ata'] = $ocean['m_eta'];
|
|
|
+ if(empty($ocean['ata']) && !empty($VA)){
|
|
|
+ $ocean['ata'] = $VA;
|
|
|
}
|
|
|
|
|
|
$simplexData = array();
|
|
|
@@ -1321,19 +1354,15 @@ class ocean_order {
|
|
|
$simplexData[] = $place_of_Delivery_status;
|
|
|
$data['shipmentData'] = $simplexData;
|
|
|
|
|
|
- //获取对应uncode 对应的时间
|
|
|
- $uncodes = $ocean['fport_of_loading_un'].";".$ocean['mport_of_discharge_un'];
|
|
|
- $codeinfo = common::getCityPortsInfo($uncodes);
|
|
|
-
|
|
|
//处理transportInfo信息数据
|
|
|
$transportInfo = array("Tracking No." =>$ocean['_tracking_no'],"status"=>$ocean['new_status'],"mode" => "Ocean Freight",
|
|
|
"origin" =>$ocean['shippr_uncode'],"destination" =>$ocean['consignee_uncode'],
|
|
|
"etd" =>$ocean['f_etd'],"atd" =>$ocean['atd'],
|
|
|
- "etd_timezone" =>$codeinfo[$ocean['fport_of_loading_un']],
|
|
|
- "atd_timezone" =>$codeinfo[$ocean['fport_of_loading_un']],
|
|
|
+ "etd_timezone" =>$ocean['pol_timezone'],
|
|
|
+ "atd_timezone" =>$ocean['pol_timezone'],
|
|
|
"eta" =>$ocean['m_eta'],"ata" =>$ocean['ata'],
|
|
|
- "eta_timezone" =>$codeinfo[$ocean['mport_of_discharge_un']],
|
|
|
- "ata_timezone" =>$codeinfo[$ocean['mport_of_discharge_un']]);
|
|
|
+ "eta_timezone" =>$ocean['mpod_timezone'],
|
|
|
+ "ata_timezone" =>$ocean['mpod_timezone']);
|
|
|
$data['transportInfo'] = $transportInfo;
|
|
|
|
|
|
//处理basicInfo信息数据
|
|
|
@@ -1367,11 +1396,11 @@ class ocean_order {
|
|
|
$routes = array(array("mode" =>"Ocean Freight","mode_label" =>"Sea", "origin" =>$ocean['shippr_uncode'],
|
|
|
"destination" => $ocean['port_of_transshipment_un'],
|
|
|
"etd" => $ocean['f_etd'],"atd" => $ocean['atd'],
|
|
|
- "eta" =>$ocean['f_eta'],"ata" => $ocean['f_eta'],
|
|
|
+ "eta" =>$ocean['f_eta'],"ata" =>"",
|
|
|
"vessel" =>$ocean['f_vessel'],"voyageNo" =>$ocean['f_voyage']));
|
|
|
$routes[] = array("mode" =>"Ocean Freight", "mode_label" =>"Sea","origin" =>$ocean['port_of_transshipment_un'],
|
|
|
"destination" => $ocean['consignee_uncode'],
|
|
|
- "etd" => $ocean['m_etd'],"atd" => $ocean['m_etd'],
|
|
|
+ "etd" => $ocean['m_etd'],"atd" => "",
|
|
|
"eta" =>$ocean['m_eta'],"ata" =>$ocean['ata'],
|
|
|
"vessel" =>$ocean['m_vessel'],"voyageNo" =>$ocean['m_voyage']);
|
|
|
}else{
|