main_new_version.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <?php
  2. $max_ec = ini_get('max_execution_time'); //set max_excution_time
  3. ini_set('max_execution_time', '600');
  4. $memory_limit = "";
  5. $action = "";
  6. if (isset($_GET['action']))
  7. $action = strtolower($_GET['action']);
  8. if (isset($_POST['action']))
  9. $action = strtolower($_POST['action']);
  10. include "include.ini.php";
  11. include 'service/ocean_booking.class.php';
  12. include 'service/ocean_order.class.php';
  13. include 'service/operation_log.class.php';
  14. include 'service/search.class.php';
  15. include 'service/column.class.php';
  16. include 'service/ajax.class.php';
  17. include 'service/login.class.php';
  18. include 'service/tools.class.php';
  19. //为了调用,临时做一个登录动作
  20. // $_POST['uname'] = "ra.admin";
  21. // $_POST['psw'] = "abc123456789";
  22. // login::getInstance()->do_login_auto();
  23. //验证路由权限
  24. common::securityCheckHandNew($action);
  25. if (_is_only_vgm()) {
  26. Header("Location:main.php?action=main");
  27. }
  28. error_log("--------------前端请求post参数---------------");
  29. error_log(utils::jsonFiltration("null", "\"\"", json_encode($_POST)));
  30. error_log("--------------前端请求get参数---------------");
  31. error_log(utils::jsonFiltration("null", "\"\"", json_encode($_GET)));
  32. //Operation log 日志记录
  33. utils::operation_log_records();
  34. switch ($action) {
  35. case 'ocean_booking':
  36. ocean_booking::getInstance()->ocean_booking();
  37. break;
  38. case 'ocean_order':
  39. include ONLINE_ROOT . 'libs' . DS . 'ams_config.ini.php';
  40. ocean_order::getInstance()->ocean_order();
  41. break;
  42. case 'ajax':
  43. echo ajax::getInstance()->run();
  44. break;
  45. case 'opreation_log':
  46. echo operation_log::getInstance()->operation_log();
  47. break;
  48. case 'main':
  49. //todo
  50. break;
  51. case 'main_report':
  52. $type = $_REQUEST["r_type"];
  53. $container_type = $_REQUEST["container_type"];
  54. if (empty($_REQUEST["b_date"])) {
  55. $bdate = "null";
  56. } else {
  57. $bdate = $_REQUEST["b_date"];
  58. $bdate = "'$bdate'";
  59. }
  60. if (empty($_REQUEST["e_date"])) {
  61. $edate = "null";
  62. } else {
  63. $edate = $_REQUEST["e_date"];
  64. $edate = "'$edate'";
  65. }
  66. //Demo测试数据 日期全为空 :前端是由日期过来来的
  67. //$edate = "null";
  68. //$bdate = "null";
  69. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  70. $sqlWhere = common::check_input($sqlWhere);
  71. $sqlWhere = " " . $sqlWhere;
  72. //online_order_status_date_new 与本地的区分,发布上去这去掉new
  73. $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  74. . "r (c bigint, e integer, b integer, d text)");
  75. $key = "[";
  76. $value = "[";
  77. $totalValue = 0;
  78. foreach ($list as $vv) {
  79. if ($key != "[") {
  80. $key .= ",";
  81. $value .= ",";
  82. }
  83. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  84. $key .= '"' . $vv["d"] . '"';
  85. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  86. $totalValue = $totalValue + $vv["c"];
  87. } else {
  88. if ($vv["e"] == -1) {
  89. $key .= '"Over 80 Days"';
  90. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  91. } else {
  92. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  93. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  94. }
  95. $totalValue = $totalValue + $vv["c"];
  96. }
  97. }
  98. $key .= "]";
  99. $value .= "]";
  100. //处理返回原表数据格式
  101. $data = common::mian_repot_do($value,$type,$totalValue);
  102. common::echo_json_encode(200, $data);
  103. exit();
  104. break;
  105. case 'main_report_kpi':
  106. $type = $_REQUEST["r_type"];
  107. $container_type = $_REQUEST["container_type"];
  108. if (empty($_REQUEST["b_date"])) {
  109. $bdate = "null";
  110. } else {
  111. $bdate = $_REQUEST["b_date"];
  112. $bdate = "'$bdate'";
  113. }
  114. if (empty($_REQUEST["e_date"])) {
  115. $edate = "null";
  116. } else {
  117. $edate = $_REQUEST["e_date"];
  118. $edate = "'$edate'";
  119. }
  120. //Demo测试数据 日期全为空
  121. //$edate = "null";
  122. //$bdate = "null";
  123. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  124. $sqlWhere = common::check_input($sqlWhere);
  125. $sqlWhere = " " . $sqlWhere;
  126. $list = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere'::text) "
  127. . "r (c bigint, d text)");
  128. $key = "[";
  129. $value = "[";
  130. $totalValue = 0;
  131. foreach ($list as $vv) {
  132. if ($key != "[") {
  133. $key .= ",";
  134. $value .= ",";
  135. }
  136. if ($type == "ata_r3" || $type == "atd_r4" ) {
  137. $key .= '"' . $vv["d"] .'"';
  138. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] .'"}';
  139. $totalValue = $totalValue + $vv["c"];
  140. }
  141. }
  142. $key .= "]";
  143. $value .= "]";
  144. //处理返回原表数据格式
  145. $ETDList = array();
  146. $value_arr = json_decode($value,true);
  147. foreach($value_arr as $arr){
  148. $color = common::getItemStyle($type,$arr['name']);
  149. $ETDList[] = array("value" =>intval($arr['value']),"name" =>$arr['name'],"itemStyle" =>array("color" =>$color));
  150. }
  151. if($type == 'atd_r4'){
  152. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Departure","title2" =>"(ATD-ETD)");
  153. }
  154. if($type == 'ata_r3'){
  155. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Arrival","title2" =>"(ATD-ETD)");
  156. }
  157. common::echo_json_encode(200, $data);
  158. exit();
  159. break;
  160. case 'main_report_container_bar':
  161. //新UI 要ALL 20 40 45 四份数据同时查询,且是柱状图,所以与r3 r4查询分开
  162. $container_type_arr = array("20","40","45");
  163. $container_type_param = $_REQUEST["container_type"];
  164. $ContainerCounSeries = array();
  165. foreach($container_type_arr as $_container_type){
  166. $container_type = $_container_type;
  167. $type = $_REQUEST["r_type"];
  168. if (empty($_REQUEST["b_date"])) {
  169. $bdate = "null";
  170. } else {
  171. $bdate = $_REQUEST["b_date"];
  172. $bdate = "'$bdate'";
  173. }
  174. if (empty($_REQUEST["e_date"])) {
  175. $edate = "null";
  176. } else {
  177. $edate = $_REQUEST["e_date"];
  178. $edate = "'$edate'";
  179. }
  180. $list= array();
  181. //all 查询所有
  182. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  183. $sqlWhere = common::check_input($sqlWhere);
  184. $sqlWhere = " " . $sqlWhere;
  185. //如果页面查询的是ALL 这个20 40 45都查询出来。否则值查询都对应的size,其他的不查询
  186. if(strtolower($container_type_param) == "all"){
  187. $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  188. . "r (c bigint, e integer, b integer, d text)");
  189. }else{
  190. if($container_type_param == $_container_type){
  191. $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  192. . "r (c bigint, e integer, b integer, d text)");
  193. }
  194. }
  195. $key = "[";
  196. $value = "[";
  197. $totalValue = 0;
  198. foreach ($list as $vv) {
  199. if ($key != "[") {
  200. $key .= ",";
  201. $value .= ",";
  202. }
  203. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  204. $key .= '"' . $vv["d"] . '"';
  205. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  206. $totalValue = $totalValue + $vv["c"];
  207. } else {
  208. if ($vv["e"] == -1) {
  209. $key .= '"Over 80 Days"';
  210. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  211. } else {
  212. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  213. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  214. }
  215. $totalValue = $totalValue + $vv["c"];
  216. }
  217. }
  218. $key .= "]";
  219. $value .= "]";
  220. $key_arr = json_decode($key,true);
  221. $value_arr = json_decode($value,true);
  222. $data = array();
  223. //每一个size 的所有月份总计
  224. $total = 0;
  225. //每一个size 对应的最大值
  226. $max = 0;
  227. foreach($value_arr as $arr){
  228. $data[] = intval($arr['value']);
  229. $total = $total + intval($arr['value']);
  230. $max = $max < intval($arr['value']) ? intval($arr['value']) : $max;
  231. }
  232. $ContainerCounSeries[$container_type] = array("data"=>$data,"total"=>$total,"max"=>$max);
  233. }
  234. //处理返回时数据格式
  235. $ContainerCounSeries_return = array();
  236. //横坐标栏位
  237. $ContainerCount_Title = $key_arr;
  238. //所查的所有模式计算总和
  239. $total = 0;
  240. //所有size下的最大值,方便标注计算最长的Y坐标
  241. $max_all = 0;
  242. foreach($ContainerCounSeries as $k =>$v){
  243. //这个type 是页面传过来的。这个固定r2
  244. $color = common::getItemStyle($type,$k);
  245. $total = $total + $v['total'];
  246. $ContainerCounSeries_return[] = array("name"=>$k,"type"=>"bar","emphasis" => array("focus" =>"none"),
  247. "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));
  248. $max_all = $max_all + $v['max'];
  249. }
  250. //计算Y坐标的间隔
  251. $interval = utils::calculateTicks(0,$max_all,5);
  252. if($interval == 0){
  253. //处理返回默认值
  254. $interval = 2;
  255. }
  256. $returnData = array("ContainerCount_Title"=>"Total: $total","ContainerCountList" =>$ContainerCount_Title,"ContainerCounSeries" =>$ContainerCounSeries_return,
  257. "min" => 0,"Max" =>$interval*5,"interval" =>$interval);
  258. common::echo_json_encode(200, $returnData);
  259. exit();
  260. break;
  261. case 'main_report_co2e_bar':
  262. $returnData = common::getCo2eBar();
  263. common::echo_json_encode(200, $returnData);
  264. exit();
  265. break;
  266. case 'main_report_top10_bar':
  267. $returnData = common::getTopBar();
  268. common::echo_json_encode(200, $returnData);
  269. exit();
  270. break;
  271. case 'main_map':
  272. $uncode = $_POST["uncode"];
  273. $serial_no = $_POST["serial_no"];
  274. $unall = explode("|", $uncode);
  275. $sql = "";
  276. if (!empty($unall[0]) && $unall[0] != "''") {
  277. $sql .= "select lon as lng, lat as lat, uncode, 'Place of receipt: '||name1 as location_namewo, 'por' as type from vessel.vt_unlocode where "
  278. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  279. . "($unall[0])";
  280. }
  281. if (!empty($unall[1]) && $unall[1] != "''") {
  282. if (!empty($sql)) {
  283. $sql .= " union ";
  284. }
  285. $sql .= "select lon as lng, lat as lat, uncode, 'POL: '||name1 as location_namewo, 'pol' as type from vessel.vt_unlocode where "
  286. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  287. . "($unall[1])";
  288. }
  289. if (!empty($unall[2]) && $unall[2] != "''") {
  290. if (!empty($sql)) {
  291. $sql .= " union ";
  292. }
  293. $sql .= "select lon as lng, lat as lat, uncode, 'POD: '||name1 as location_namewo, 'pod' as type from vessel.vt_unlocode where "
  294. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  295. . "($unall[2])";
  296. }
  297. if (!empty($unall[3]) && $unall[3] != "''") {
  298. if (!empty($sql)) {
  299. $sql .= " union ";
  300. }
  301. $sql .= "select lon as lng, lat as lat, uncode, 'Place of delivery: '||name1 as location_namewo, 'poe' as type from vessel.vt_unlocode where "
  302. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  303. . "($unall[3])";
  304. }
  305. $tkStatus = common::excuteListSql("select tl.by_pickup, g.consignee_exp, g.pickup_from_exp, c.ctnr, g.deliveryto_exp, g.serial_no, tl.location, tl.type, tl.id,
  306. to_char(tl.upload_time, 'MM/DD/YYYY HH24:MI:SS') as utime
  307. from public.tk_general g, public.tk_commodity c left join public.tk_location tl on c.serial_no=tl.serial_no
  308. where g.serial_no=c.serial_no and g.bol=(select m_bol from public.ocean where serial_no='$serial_no') order by tl.order_id");
  309. foreach ($tkStatus as $vv) {
  310. $ll = explode(",", $vv["location"]);
  311. if ($vv["by_pickup"] == "t") {
  312. $pf = explode("\r\n", $vv["pickup_from_exp"]);
  313. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  314. $dt = explode("\r\n", $vv["consignee_exp"]);
  315. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  316. } else {
  317. $pf = explode("\r\n", $vv["consignee_exp"]);
  318. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  319. $dt = explode("\r\n", $vv["deliveryto_exp"]);
  320. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  321. }
  322. if ($vv["type"] == "26" && !empty($ll[1])) {
  323. if (!empty($sql)) {
  324. $sql .= " union ";
  325. }
  326. $sql .= "select '" . $ll[1] . "' as lng, '" . $ll[0] . "' as lat, '" . $vv["ctnr"] . "' as uncode, 'Pick up: " . $vv["utime"] . "<br>'||'" . $pf . "' as location_namewo, 'pickup' as type";
  327. } elseif ($vv["type"] == "25" && !empty($ll[1])) {
  328. if (!empty($sql)) {
  329. $sql .= " union ";
  330. }
  331. $sql .= "select '" . $ll[1] . "' as lng, '" . $ll[0] . "' as lat, '" . $vv["ctnr"] . "' as uncode, 'Delivery: " . $vv["utime"] . "<br>'||'" . $dt . "' as location_namewo, 'delivery' as type";
  332. }
  333. }
  334. if (!empty($sql)) {
  335. $gps = common::excuteListSql($sql . "");
  336. }
  337. if (!empty($serial_no)) {
  338. $all = explode(",", $serial_no);
  339. foreach ($all as $a) {
  340. $rs = common::excuteOneSql("select public.get_vessel_position('$a'::text)");
  341. if (!empty($rs)) {
  342. $rss = explode("|", $rs);
  343. $lng_lat = explode(",", $rss[1]);
  344. $gps[] = array("lng" => $lng_lat[0], "lat" => $lng_lat[1], "uncode" => "", "location_namewo" => "", "type" => "vessel", "vessel_name" => $rss[2], "m_shipname" => "", "mmsi" => "", "imo" => "", "m_shipstate" => "", "m_shiptype" => "", "m_dest" => "", "m_newshiparrive" => "", "m_newlasttime" => "", "lasttime" => "", "sub" => "");
  345. }
  346. }
  347. }
  348. $data = array("gps" => $gps);
  349. common::echo_json_encode("200", $data);
  350. exit();
  351. break;
  352. case 'main_map_new':
  353. //修改添加port_of_transshipment 和port_of_transshipment_name的坐标获取(有为空的可能)
  354. $serial_no = $_POST["serial_no"];
  355. $sql = "with ss as (select '$serial_no' as sn)
  356. , aa as (
  357. select place_of_receipt_un, place_of_delivery_un, fport_of_loading_un, mport_of_discharge_un, port_of_loading, port_of_discharge, place_of_delivery_exp, place_of_receipt_exp,dd.*
  358. from public.online_ocean oo
  359. left join LATERAL (
  360. select (select uncode from ports where code = o.port_of_transshipment) as port_of_transshipment_un,
  361. port_of_transshipment_name
  362. from ocean o where o.serial_no=oo.serial_no order by id desc limit 1
  363. ) dd on true
  364. where serial_no=(select sn from ss) limit 1
  365. )
  366. , v1 as (select public.get_vessel_position(sn::text) bbb from ss)
  367. , t1 as (
  368. select tl.upload_time, tl.by_pickup, split_part(g.consignee_exp,'\n',1) as consignee_exp, split_part(g.pickup_from_exp,'\n',1) as pickup_from_exp,
  369. c.ctnr, split_part(g.deliveryto_exp,'\n',1) as deliveryto_exp,g.serial_no, tl.location, tl.type, tl.id,
  370. to_char(tl.upload_time, 'MM/DD/YYYY HH24:MI:SS') as utime
  371. from public.tk_general g, public.tk_commodity c
  372. left join public.tk_location tl on c.serial_no=tl.serial_no
  373. where g.serial_no=c.serial_no and g.bol=(select m_bol from public.ocean where serial_no=(select sn from ss)) order by tl.order_id)
  374. , rr as (
  375. select lon as lng, lat as lat, 'Origin' as label, port_of_loading as infor, 1 as sort, null::timestamp without time zone as stime, 'pol'::text as ptype
  376. from vessel.vt_unlocode, aa where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=fport_of_loading_un
  377. union all
  378. select lon as lng, lat as lat, 'Destination' as label, port_of_discharge as infor, 2 as sort, null::timestamp without time zone as stime, 'pod'::text as ptype
  379. from vessel.vt_unlocode, aa where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=mport_of_discharge_un
  380. union all
  381. select lon as lng, lat as lat, 'Transfer' as label, port_of_transshipment_name as infor, 3 as sort, null::timestamp without time zone as stime, 'poe'::text as ptype
  382. from vessel.vt_unlocode, aa where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=port_of_transshipment_un
  383. )
  384. select * from rr order by sort, stime";
  385. $rss = common::excuteListSql($sql);
  386. //先固定死
  387. // $json = '[{"lng":"100.78594000","lat":"13.68521000","label":"Origin","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"},
  388. // {"lng":"100.88333333","lat":"13.08333333","label":"Destination","infor":"LAEM CHABANG PORT,THAILAND","sort":"1","stime":null,"ptype":"pol"},
  389. // {"lng":"-122.28640000","lat":"37.79784000","label":"Transfer","infor":"OAKLAND, CA, USA","sort":"2","stime":null,"ptype":"pod"}]';
  390. $rss = json_decode($json,true);
  391. common::echo_json_encode(200, $rss);
  392. exit();
  393. break;
  394. case 'main_welcome':
  395. $cp = common::check_input($_POST ['cp']); //current_page
  396. $ps = common::check_input($_POST ['ps']); //ps
  397. if (empty($ps))
  398. $ps = 10;
  399. $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  400. //默认初始条件:ALL& ETD& Current Month 当前月的1号到最后一天
  401. if (isset($_POST['is_default']) && strtolower($_POST['is_default']) == "yes"){
  402. $sqlWhere .= "and etd>='" . date("Y-m") . "-01' and etd<='" . date("Y-m") . "-01'::date + interval '1 month'";
  403. } else {
  404. $date_type = common::check_input($_POST ['date_type']);
  405. if (isset($_POST['date_start']) && !empty($_POST['date_start']))
  406. $sqlWhere .= " and $date_type >= '" . common::usDate2sqlDate($_POST['date_start']) . " 00:00:00'";
  407. if (isset($_POST['date_end']) && !empty($_POST['date_end']))
  408. $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_POST['date_end']) . " 23:59:59'";
  409. }
  410. if (isset($_POST['customer']) && !empty($_POST['customer'])){
  411. $sqlWhere .= " and (shipper ilike '%".common::check_input($_POST['customer'])."%' or shipper_id ilike '%".common::check_input($_POST['customer'])."%'
  412. or consignee ilike '%".common::check_input($_POST['customer'])."%' or consignee_id ilike '%".common::check_input($_POST['customer'])."%')";
  413. }
  414. $rc = $_POST ['rc'];
  415. if ($rc == - 1) {
  416. $sql = "SELECT count(1) from public.online_ocean" . $sqlWhere ." and last_status_315_update_time is not null";
  417. $rc = common::excuteOneSql($sql);
  418. error_log($sql);
  419. }
  420. $tp = ceil($rc / $ps);
  421. if ($rc > 0) {
  422. $sql = "SELECT serial_no,last_status_city, consignee, shipper, h_bol,
  423. to_char(etd, 'MM/DD/YYYY'::text) as etd, to_char(eta, 'MM/DD/YYYY'::text) AS eta,
  424. fport_of_loading_un, mport_of_discharge_un, place_of_receipt_un, place_of_delivery_un, ctnrs, count_cntr, last_status_ctnr,booking_no,
  425. to_char(last_status_315_date, 'MM/DD/YYYY'::text) as last_status_315_date,last_status_315_code, last_status_loc, last_status_city, order_from,
  426. f_vessel,f_voyage,dd.*
  427. FROM public.online_ocean
  428. left join LATERAL (select case when a.code='IFFBCF' then 'Booked'
  429. when a.code='IFFCPU' then 'Cargo Received'
  430. when a.code='IFFREC' then 'Cargo Received'
  431. when a.code='IFFDEP' then 'Departed'
  432. when a.code='IFFARR' then 'Arrived'
  433. when a.code='IFFAFD' then 'Completed'
  434. else 'Booked' END as status,act_date,act_date,description
  435. from ocean_milestone a
  436. where a.serial_no=online_ocean.serial_no
  437. and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFAFD', ','))
  438. order by id desc limit 1) dd on true
  439. $sqlWhere and last_status_315_update_time is not null";
  440. if (_isDemo()) {
  441. $sql .= " ORDER BY eta DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  442. } else {
  443. $sql .= " ORDER BY last_status_315_update_time DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  444. }
  445. $rss = common::excuteListSql($sql);
  446. //RecentStatusList
  447. $RecentStatusList = array();
  448. foreach ($rss as $key => $value) {
  449. //这个换成ocean_milestone,但是保留以前逻辑
  450. //$Arrived = utils::outDisplayForMerge(common::getStatusDesc($value["last_status_315_code"]),common::_toString($value["last_status_loc"]),";");
  451. $Arrived = $value['description'];
  452. $RecentStatusList[] = array("Title"=>$value['h_bol'],
  453. "name"=>$value['f_vessel']." / ".$value['f_voyage'],
  454. "bookingNumber" =>$value['booking_no'],
  455. "IsSubscribe" =>false,
  456. "shipperName"=>$value['shipper'],
  457. "consigneeName" =>$value['consignee'],
  458. "startStation"=>$value['fport_of_loading_un'],
  459. "endStation"=>$value['mport_of_discharge_un'],
  460. "ETD"=>$value['etd'],
  461. "ETA"=>$value['eta'],
  462. "type"=>$value['status'],
  463. "Arrived"=>$Arrived,
  464. "Time"=>$value["act_date"],
  465. "a" =>common::deCode($value['serial_no'], 'E'));
  466. }
  467. $arrTmp = array('searchData' => $RecentStatusList,
  468. 'Management' => common::getManagement(),
  469. 'is_customer' =>_isCustomerLogin(),
  470. 'rc' => $rc,
  471. 'ps' => $ps,
  472. 'cp' => $cp,
  473. 'tp' => $tp);
  474. } else {
  475. $arrTmp = array('searchData' => array(),
  476. 'Management' => common::getManagement());
  477. }
  478. common::echo_json_encode(200,$arrTmp);
  479. exit();
  480. break;
  481. case 'save_layout':
  482. $management = json_encode($_POST["management"]);
  483. common::excuteUpdateSql("update public.ra_online_user set management = '$management' where lower(user_login) = '" . strtolower(_getLoginName()) . "'");
  484. $returnData = array("msg" => "success");
  485. common::echo_json_encode(200, $returnData);
  486. exit();
  487. break;
  488. case 'password':
  489. tools::getInstance()->updatePassword();
  490. break;
  491. case 'tools':
  492. tools::getInstance()->markSystem();
  493. break;
  494. default:
  495. $data = array(
  496. 'msg' => 'Page not found',
  497. );
  498. common::echo_json_encode(500, $data);
  499. }
  500. $db->Close();
  501. $db = null;
  502. if ($max_ec > 0)
  503. ini_set('max_execution_time', $max_ec); //recover old value
  504. if (!empty($memory_limit))
  505. ini_set('memory_limit', $memory_limit);
  506. ?>