main_new_version.php 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  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. $menuList = array();
  50. $menuList[] = array("index"=>'1',"label"=>"Dashboard","icon"=>"icon_data_fill_b","path"=>"/dashboard");
  51. $menuList[] = array("index"=>'3',"label"=>"Booking","icon"=>"icon_booking__fill_b","path"=>"/booking");
  52. $menuList[] = array("index"=>'4',"label"=>"Tracking","icon"=>"icon_tracking__fill_b","path"=>"/tracking");
  53. if(_isApexLogin()){
  54. $menuList[] = array("index"=>'6',"label"=>"System Management","icon"=>"icon_system__management_fill_b","type"=>"list",
  55. "children"=>array(array("index" =>'5-4',"label" =>"Operation Log","path"=>"/Operationlog")));
  56. }
  57. common::echo_json_encode(200, $menuList);
  58. exit();
  59. break;
  60. case 'main_filter':
  61. $data = common::getManagement();
  62. common::echo_json_encode(200, $data['dashboard_filter']);
  63. exit();
  64. break;
  65. case 'main_report':
  66. $type = $_REQUEST["r_type"];
  67. $container_type = $_REQUEST["container_type"];
  68. if (empty($_REQUEST["b_date"])) {
  69. $bdate = "null";
  70. } else {
  71. $bdate = $_REQUEST["b_date"];
  72. $bdate = "'$bdate'";
  73. }
  74. if (empty($_REQUEST["e_date"])) {
  75. $edate = "null";
  76. } else {
  77. $edate = $_REQUEST["e_date"];
  78. $edate = "'$edate'";
  79. }
  80. //Demo测试数据 日期全为空 :前端是由日期过来来的
  81. // $edate = "null";
  82. // $bdate = "null";
  83. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  84. $sqlWhere = common::check_input($sqlWhere);
  85. $sqlWhere = " " . $sqlWhere;
  86. $transportation = $_REQUEST["transportation"];
  87. if(!is_array($transportation)){
  88. $transportation = array($transportation);
  89. }
  90. $list = array();
  91. if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
  92. $transportation = array("Sea","Air","Road");
  93. }
  94. foreach($transportation as $mode){
  95. if($mode == 'Sea'){
  96. $Sealist = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  97. . "r (c bigint, e integer, b integer, d text)");
  98. //拼接数据
  99. if(empty($list)){
  100. $list = $Sealist;
  101. }else{
  102. foreach($list as $lk =>$lv){
  103. $list[$lk]['c'] = $list[$lk]['c'] + $Sealist[$lk]['c'];
  104. }
  105. }
  106. }
  107. if($mode == 'Air'){
  108. //暂时查询空数据
  109. $sqlWhere_air = $sqlWhere ." and 1<>1 ";
  110. $Airlist = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere_air'::text, '$container_type'::text) "
  111. . "r (c bigint, e integer, b integer, d text)");
  112. //拼接数据
  113. if(empty($list)){
  114. $list = $Airlist;
  115. }else{
  116. foreach($list as $lk =>$lv){
  117. $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
  118. }
  119. }
  120. }
  121. if($mode == 'Road'){
  122. $sqlWhere_road = $sqlWhere ." and 1<>1 ";
  123. $roadlist = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere_road'::text, '$container_type'::text) "
  124. . "r (c bigint, e integer, b integer, d text)");
  125. //拼接数据
  126. if(empty($list)){
  127. $list = $roadlist;
  128. }else{
  129. foreach($list as $lk =>$lv){
  130. $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
  131. }
  132. }
  133. }
  134. }
  135. //online_order_status_date_new 与本地的区分,发布上去这去掉new
  136. // $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  137. // . "r (c bigint, e integer, b integer, d text)");
  138. $key = "[";
  139. $value = "[";
  140. $totalValue = 0;
  141. foreach ($list as $vv) {
  142. if ($key != "[") {
  143. $key .= ",";
  144. $value .= ",";
  145. }
  146. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  147. $key .= '"' . $vv["d"] . '"';
  148. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  149. $totalValue = $totalValue + $vv["c"];
  150. } else {
  151. if ($vv["e"] == -1) {
  152. $key .= '"Over 80 Days"';
  153. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  154. } else {
  155. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  156. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  157. }
  158. $totalValue = $totalValue + $vv["c"];
  159. }
  160. }
  161. $key .= "]";
  162. $value .= "]";
  163. //处理返回原表数据格式
  164. $data = common::mian_repot_do($value,$type,$totalValue);
  165. common::echo_json_encode(200, $data);
  166. exit();
  167. break;
  168. case 'main_report_etd':
  169. //这里只有r1查询
  170. $type = "r1";
  171. $container_type = "";
  172. $date_type = strtolower($_REQUEST["date_type"]);
  173. if (empty($_REQUEST["date_start"])) {
  174. $bdate = "null";
  175. } else {
  176. $bdate = $_REQUEST["date_start"];
  177. $bdate = "'$bdate'";
  178. }
  179. if (empty($_REQUEST["date_end"])) {
  180. $edate = "null";
  181. } else {
  182. $edate = $_REQUEST["date_end"];
  183. $edate = "'$edate'";
  184. }
  185. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  186. $sqlWhere = common::check_input($sqlWhere);
  187. $sqlWhere = " " . $sqlWhere;
  188. $transportation = $_REQUEST["transportation"];
  189. if(!is_array($transportation)){
  190. $transportation = array($transportation);
  191. }
  192. $list = array();
  193. if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
  194. $transportation = array("Sea","Air","Road");
  195. }
  196. foreach($transportation as $mode){
  197. if($mode == 'Sea'){
  198. $Sealist = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
  199. . "r (c bigint, e integer, b integer, d text)");
  200. //拼接数据
  201. if(empty($list)){
  202. $list = $Sealist;
  203. }else{
  204. foreach($list as $lk =>$lv){
  205. $list[$lk]['c'] = $list[$lk]['c'] + $Sealist[$lk]['c'];
  206. }
  207. }
  208. }
  209. if($mode == 'Air'){
  210. //暂时查询空数据
  211. $sqlWhere_air = $sqlWhere ." and 1<>1 ";
  212. $Airlist = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere_air'::text, '$container_type'::text,'$date_type'::text) "
  213. . "r (c bigint, e integer, b integer, d text)");
  214. //拼接数据
  215. if(empty($list)){
  216. $list = $Airlist;
  217. }else{
  218. foreach($list as $lk =>$lv){
  219. $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
  220. }
  221. }
  222. }
  223. if($mode == 'Road'){
  224. $sqlWhere_road = $sqlWhere ." and 1<>1 ";
  225. $roadlist = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere_road'::text, '$container_type'::text,'$date_type'::text) "
  226. . "r (c bigint, e integer, b integer, d text)");
  227. //拼接数据
  228. if(empty($list)){
  229. $list = $roadlist;
  230. }else{
  231. foreach($list as $lk =>$lv){
  232. $list[$lk]['c'] = $list[$lk]['c'] + $roadlist[$lk]['c'];
  233. }
  234. }
  235. }
  236. }
  237. // $list = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
  238. // . "r (c bigint, e integer, b integer, d text)");
  239. $key = "[";
  240. $value = "[";
  241. $totalValue = 0;
  242. foreach ($list as $vv) {
  243. if ($key != "[") {
  244. $key .= ",";
  245. $value .= ",";
  246. }
  247. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  248. $key .= '"' . $vv["d"] . '"';
  249. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  250. $totalValue = $totalValue + $vv["c"];
  251. } else {
  252. if ($vv["e"] == -1) {
  253. $key .= '"Over 80 Days"';
  254. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  255. } else {
  256. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  257. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  258. }
  259. $totalValue = $totalValue + $vv["c"];
  260. }
  261. }
  262. $key .= "]";
  263. $value .= "]";
  264. //处理返回原表数据格式
  265. $data = common::mian_repot_do($value,$type,$totalValue);
  266. common::echo_json_encode(200, $data);
  267. exit();
  268. break;
  269. case 'main_report_kpi':
  270. $type = $_REQUEST["r_type"];
  271. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  272. $sqlWhere = common::check_input($sqlWhere);
  273. $sqlWhere = " " . $sqlWhere;
  274. $date_type = strtolower($_REQUEST["date_type"]);
  275. if (isset($_REQUEST['date_start']) && !empty($_REQUEST['date_start']))
  276. $sqlWhere .= " and $date_type >= ''" . common::usDate2sqlDate($_REQUEST['date_start']) . " 00:00:00''";
  277. if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end']))
  278. $sqlWhere .= " and $date_type <= ''" . common::usDate2sqlDate($_REQUEST['date_end']) . " 23:59:59''";
  279. $transportation = $_REQUEST["transportation"];
  280. if(!is_array($transportation)){
  281. $transportation = array($transportation);
  282. }
  283. $list = array();
  284. if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
  285. $transportation = array("Sea","Air","Road");
  286. }
  287. foreach($transportation as $mode){
  288. if($mode == 'Sea'){
  289. $Sealist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere'::text) "
  290. . "r (c bigint, d text)");
  291. //拼接数据
  292. if(empty($list)){
  293. $list = $Sealist;
  294. }else{
  295. foreach($list as $lk =>$lv){
  296. $list[$lk]['c'] = $list[$lk]['c'] + $Sealist[$lk]['c'];
  297. }
  298. }
  299. }
  300. if($mode == 'Air'){
  301. //暂时查询空数据
  302. $sqlWhere_air = $sqlWhere ." and 1<>1 ";
  303. $Airlist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere_air'::text) "
  304. . "r (c bigint, d text)");
  305. //拼接数据
  306. if(empty($list)){
  307. $list = $Airlist;
  308. }else{
  309. foreach($list as $lk =>$lv){
  310. $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
  311. }
  312. }
  313. }
  314. if($mode == 'Road'){
  315. $sqlWhere_road = $sqlWhere ." and 1<>1 ";
  316. $roadlist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere_road'::text) "
  317. . "r (c bigint, d text)");
  318. //拼接数据
  319. if(empty($list)){
  320. $list = $roadlist;
  321. }else{
  322. foreach($list as $lk =>$lv){
  323. $list[$lk]['c'] = $list[$lk]['c'] + $roadlist[$lk]['c'];
  324. }
  325. }
  326. }
  327. }
  328. $key = "[";
  329. $value = "[";
  330. $totalValue = 0;
  331. foreach ($list as $vv) {
  332. if ($key != "[") {
  333. $key .= ",";
  334. $value .= ",";
  335. }
  336. if ($type == "ata_r3" || $type == "atd_r4" ) {
  337. $key .= '"' . $vv["d"] .'"';
  338. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] .'"}';
  339. $totalValue = $totalValue + $vv["c"];
  340. }
  341. }
  342. $key .= "]";
  343. $value .= "]";
  344. //处理返回原表数据格式
  345. $ETDList = array();
  346. $value_arr = json_decode($value,true);
  347. foreach($value_arr as $arr){
  348. $color = common::getItemStyle($type,$arr['name']);
  349. if($arr['name'] == "0 Day"){
  350. $arr['name'] = "≤1 Day";
  351. }
  352. if($arr['name'] == "7 Days"){
  353. $arr['name'] = "≥7 Days";
  354. }
  355. $ETDList[] = array("value" =>intval($arr['value']),"name" =>$arr['name'],"itemStyle" =>array("color" =>$color));
  356. }
  357. if($type == 'atd_r4'){
  358. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Departure","title2" =>"(ATD-ETD)","download_name" => "KPI Departure");
  359. }
  360. if($type == 'ata_r3'){
  361. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Arrival","title2" =>"(ATA-ETA)","download_name" => "KPI Arrival");
  362. }
  363. common::echo_json_encode(200, $data);
  364. exit();
  365. break;
  366. case 'main_report_container_bar':
  367. //新UI 要ALL 20 40 45 四份数据同时查询,且是柱状图,所以与r3 r4查询分开
  368. $container_type_arr = array("20","40","45");
  369. $container_type_param = "all";
  370. $ContainerCounSeries = array();
  371. foreach($container_type_arr as $_container_type){
  372. $container_type = $_container_type;
  373. $date_type = strtolower($_REQUEST["date_type"]);
  374. $type = $_REQUEST["r_type"];
  375. if (empty($_REQUEST["date_start"])) {
  376. $bdate = "null";
  377. } else {
  378. $bdate = $_REQUEST["date_start"];
  379. $bdate = "'$bdate'";
  380. }
  381. if (empty($_REQUEST["date_end"])) {
  382. $edate = "null";
  383. } else {
  384. $edate = $_REQUEST["date_end"];
  385. $edate = "'$edate'";
  386. }
  387. $list= array();
  388. //all 查询所有
  389. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  390. $sqlWhere = common::check_input($sqlWhere);
  391. $sqlWhere = " " . $sqlWhere;
  392. //如果页面查询的是ALL 这个20 40 45都查询出来。否则值查询都对应的size,其他的不查询
  393. if(strtolower($container_type_param) == "all"){
  394. $list = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text, '$date_type'::text) "
  395. . "r (c bigint, e integer, b integer, d text)");
  396. }else{
  397. if($container_type_param == $_container_type){
  398. $list = common::excuteListSql("select * from public.online_order_status_date_new_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text, '$date_type'::text) "
  399. . "r (c bigint, e integer, b integer, d text)");
  400. }
  401. }
  402. $key = "[";
  403. $value = "[";
  404. $totalValue = 0;
  405. foreach ($list as $vv) {
  406. if ($key != "[") {
  407. $key .= ",";
  408. $value .= ",";
  409. }
  410. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  411. $key .= '"' . $vv["d"] . '"';
  412. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  413. $totalValue = $totalValue + $vv["c"];
  414. } else {
  415. if ($vv["e"] == -1) {
  416. $key .= '"Over 80 Days"';
  417. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  418. } else {
  419. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  420. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  421. }
  422. $totalValue = $totalValue + $vv["c"];
  423. }
  424. }
  425. $key .= "]";
  426. $value .= "]";
  427. $key_arr = json_decode($key,true);
  428. $value_arr = json_decode($value,true);
  429. $data = array();
  430. //每一个size 的所有月份总计
  431. $total = 0;
  432. //每一个size 对应的最大值
  433. $max = 0;
  434. foreach($value_arr as $arr){
  435. $data[] = intval($arr['value']);
  436. $total = $total + intval($arr['value']);
  437. $max = $max < intval($arr['value']) ? intval($arr['value']) : $max;
  438. }
  439. $ContainerCounSeries[$container_type] = array("data"=>$data,"total"=>$total,"max"=>$max);
  440. }
  441. //处理返回时数据格式
  442. $ContainerCounSeries_return = array();
  443. //横坐标栏位
  444. $ContainerCount_Title = $key_arr;
  445. //所查的所有模式计算总和
  446. $total = 0;
  447. //所有size下的最大值,方便标注计算最长的Y坐标
  448. $max_all = 0;
  449. foreach($ContainerCounSeries as $k =>$v){
  450. //这个type 是页面传过来的。这个固定r2
  451. $color = common::getItemStyle($type,$k);
  452. $total = $total + $v['total'];
  453. $ContainerCounSeries_return[] = array("name"=>strval($k),"type"=>"bar","emphasis" => array("focus" =>"none"),
  454. "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));
  455. $max_all = $max_all + $v['max'];
  456. }
  457. //计算Y坐标的间隔
  458. $interval = utils::calculateTicks(0,$max_all,5);
  459. if($interval == 0){
  460. //处理返回默认值
  461. $interval = 2;
  462. }
  463. $returnData = array("ContainerCount_Title"=>"Total: $total","ContainerCountList" =>$ContainerCount_Title,"ContainerCounSeries" =>$ContainerCounSeries_return,
  464. "min" => 0,"Max" =>$interval*5,"interval" =>$interval,"download_name" => "Container Count");
  465. //demo
  466. // $json = '{"code":200,"data":{"ContainerCount_Title":"Total: 463518","ContainerCountList":["OCT,23","NOV,23","DEC,23","JAN,24","FEB,24","MAR,24","APR,24","MAY,24","JUN,24","JUL,24","AUG,24","SEP,24","OCT,24"],"ContainerCounSeries":[{"name":"20","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[4400,8600,8804,9271,8961,8793,8534,9476,9530,10277,10081,8997,5784],"itemStyle":{"color":"#FF7500"}},{"name":"40","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[13652,28021,30422,30136,26320,27035,23979,26494,28406,33318,32318,30962,16369],"itemStyle":{"color":"#FFAC66"}},{"name":"45","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[189,337,415,437,439,321,250,320,324,603,328,415,200],"itemStyle":{"color":"#FFE3CC"}}],"min":0,"Max":45000,"interval":9000}}';
  467. // $returnData = json_decode($json,true);
  468. // echo json_encode($returnData);
  469. // exit();
  470. common::echo_json_encode(200, $returnData);
  471. exit();
  472. break;
  473. case 'main_report_co2e_bar':
  474. $returnData = common::getCo2eBar();
  475. common::echo_json_encode(200, $returnData);
  476. exit();
  477. break;
  478. case 'main_report_top10_bar':
  479. $returnData = common::getTopBar();
  480. common::echo_json_encode(200, $returnData);
  481. exit();
  482. break;
  483. case 'main_report_revenue':
  484. $returnData = common::getRevenue();
  485. common::echo_json_encode(200, $returnData);
  486. exit();
  487. break;
  488. case 'main_map':
  489. $uncode = $_POST["uncode"];
  490. $serial_no = $_POST["serial_no"];
  491. $unall = explode("|", $uncode);
  492. $sql = "";
  493. if (!empty($unall[0]) && $unall[0] != "''") {
  494. $sql .= "select lon as lng, lat as lat, uncode, 'Place of receipt: '||name1 as location_namewo, 'por' as type from vessel.vt_unlocode where "
  495. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  496. . "($unall[0])";
  497. }
  498. if (!empty($unall[1]) && $unall[1] != "''") {
  499. if (!empty($sql)) {
  500. $sql .= " union ";
  501. }
  502. $sql .= "select lon as lng, lat as lat, uncode, 'POL: '||name1 as location_namewo, 'pol' as type from vessel.vt_unlocode where "
  503. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  504. . "($unall[1])";
  505. }
  506. if (!empty($unall[2]) && $unall[2] != "''") {
  507. if (!empty($sql)) {
  508. $sql .= " union ";
  509. }
  510. $sql .= "select lon as lng, lat as lat, uncode, 'POD: '||name1 as location_namewo, 'pod' as type from vessel.vt_unlocode where "
  511. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  512. . "($unall[2])";
  513. }
  514. if (!empty($unall[3]) && $unall[3] != "''") {
  515. if (!empty($sql)) {
  516. $sql .= " union ";
  517. }
  518. $sql .= "select lon as lng, lat as lat, uncode, 'Place of delivery: '||name1 as location_namewo, 'poe' as type from vessel.vt_unlocode where "
  519. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  520. . "($unall[3])";
  521. }
  522. $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,
  523. to_char(tl.upload_time, 'MM/DD/YYYY HH24:MI:SS') as utime
  524. from public.tk_general g, public.tk_commodity c left join public.tk_location tl on c.serial_no=tl.serial_no
  525. 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");
  526. foreach ($tkStatus as $vv) {
  527. $ll = explode(",", $vv["location"]);
  528. if ($vv["by_pickup"] == "t") {
  529. $pf = explode("\r\n", $vv["pickup_from_exp"]);
  530. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  531. $dt = explode("\r\n", $vv["consignee_exp"]);
  532. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  533. } else {
  534. $pf = explode("\r\n", $vv["consignee_exp"]);
  535. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  536. $dt = explode("\r\n", $vv["deliveryto_exp"]);
  537. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  538. }
  539. if ($vv["type"] == "26" && !empty($ll[1])) {
  540. if (!empty($sql)) {
  541. $sql .= " union ";
  542. }
  543. $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";
  544. } elseif ($vv["type"] == "25" && !empty($ll[1])) {
  545. if (!empty($sql)) {
  546. $sql .= " union ";
  547. }
  548. $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";
  549. }
  550. }
  551. if (!empty($sql)) {
  552. $gps = common::excuteListSql($sql . "");
  553. }
  554. if (!empty($serial_no)) {
  555. $all = explode(",", $serial_no);
  556. foreach ($all as $a) {
  557. $rs = common::excuteOneSql("select public.get_vessel_position('$a'::text)");
  558. if (!empty($rs)) {
  559. $rss = explode("|", $rs);
  560. $lng_lat = explode(",", $rss[1]);
  561. $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" => "");
  562. }
  563. }
  564. }
  565. $data = array("gps" => $gps);
  566. common::echo_json_encode("200", $data);
  567. exit();
  568. break;
  569. case 'main_map_new':
  570. include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
  571. //修改添加port_of_transshipment 和port_of_transshipment_name的坐标获取(有为空的可能)
  572. $serial_no = $_REQUEST["serial_no"];
  573. //$serial_no = "F41E6016-1A97-4C93-8198-53D8B3B26220";
  574. $sql = "with ss as (select '$serial_no' as sn)
  575. , aa as (
  576. 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.*
  577. from public.online_ocean oo
  578. left join LATERAL (
  579. select (select uncode from ports where code = o.port_of_transshipment) as port_of_transshipment_un,
  580. port_of_transshipment_name
  581. from ocean o where o.serial_no=oo.serial_no order by id desc limit 1
  582. ) dd on true
  583. where serial_no=(select sn from ss) limit 1
  584. )
  585. , rr as (
  586. 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
  587. 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
  588. union all
  589. 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
  590. 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
  591. union all
  592. 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
  593. 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
  594. )
  595. select * from rr order by sort, stime";
  596. $rss = common::excuteListSql($sql);
  597. //$rss = $mapdb->GetAll($sql);
  598. //先固定死
  599. // $json = '[{"lng":"100.78594000","lat":"13.68521000","label":"Origin","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"},
  600. // {"lng":"100.88333333","lat":"13.08333333","label":"Destination","infor":"LAEM CHABANG PORT,THAILAND","sort":"1","stime":null,"ptype":"pol"},
  601. // {"lng":"-122.28640000","lat":"37.79784000","label":"Transfer","infor":"OAKLAND, CA, USA","sort":"2","stime":null,"ptype":"pod"}]';
  602. //$rss = json_decode($json,true);
  603. global $mapdb;
  604. //查询线(包含所有的线)
  605. $Line = $mapdb->GetAll("select * from get_track_data('$serial_no',true)");
  606. $solidLine = array();
  607. $dottedLine = array();
  608. $rangePoint = array();
  609. foreach($Line as $line){
  610. if($line['tp'] == "1"){
  611. $solidLine[] = $line;
  612. }elseif($line['tp'] == "0"){
  613. $dottedLine[] = $line;
  614. }else{
  615. $rangePoint[] = $line;
  616. }
  617. }
  618. //如果没有虚线,这这个范围点也是异常的,不需要显示
  619. if(empty($dottedLine)){
  620. $rangePoint = array();
  621. }
  622. $data = array("point"=>$rss,"solidLine"=>$solidLine,"dottedLine"=>$dottedLine,"rangePoint"=>$rangePoint);
  623. common::echo_json_encode(200, $data);
  624. //common::echo_json_encode(200, $rss);
  625. exit();
  626. break;
  627. case 'main_welcome':
  628. $cp = common::check_input($_POST ['cp']); //current_page
  629. $ps = common::check_input($_POST ['ps']); //ps
  630. if (empty($ps))
  631. $ps = 10;
  632. $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  633. $transportation = $_REQUEST["transportation"];
  634. if(!is_array($transportation)){
  635. $transportation = array($transportation);
  636. }
  637. $list = array();
  638. if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
  639. $transportation = array("Sea","Air","Road");
  640. }else{
  641. if(!in_array("Sea",$transportation)){
  642. $sqlWhere .= " and 1<>1 ";
  643. }
  644. }
  645. // test dome
  646. // $_POST['is_default'] = "no";
  647. // $_POST['date_start'] =null;
  648. // $_POST['date_end'] = null;
  649. //默认初始条件:ALL& ETD& Current Month 当前月的1号到最后一天 这个默认条件已经废除,前端不会这样传参数
  650. if (isset($_POST['is_default']) && strtolower($_POST['is_default']) == "yes" && false){
  651. $sqlWhere .= "and etd>='" . date("Y-m") . "-01' and etd<='" . date("Y-m") . "-01'::date + interval '1 month'";
  652. } else {
  653. $date_type = strtolower(common::check_input($_POST ['date_type']));
  654. if (isset($_POST['date_start']) && !empty($_POST['date_start']))
  655. $sqlWhere .= " and $date_type >= '" . common::usDate2sqlDate($_POST['date_start']) . " 00:00:00'";
  656. if (isset($_POST['date_end']) && !empty($_POST['date_end']))
  657. $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_POST['date_end']) . " 23:59:59'";
  658. }
  659. if (isset($_POST['customer']) && !empty($_POST['customer'])){
  660. $sqlWhere .= " and (shipper ilike '%".common::check_input($_POST['customer'])."%' or shipper_id ilike '%".common::check_input($_POST['customer'])."%'
  661. or consignee ilike '%".common::check_input($_POST['customer'])."%' or consignee_id ilike '%".common::check_input($_POST['customer'])."%')";
  662. }
  663. $rc = $_POST ['rc'];
  664. if ($rc == - 1) {
  665. $sql = "SELECT count(1) from public.online_ocean" . $sqlWhere ." and last_status_315_update_time is not null";
  666. $rc = common::excuteOneSql($sql);
  667. //error_log($sql);
  668. }
  669. $tp = ceil($rc / $ps);
  670. if ($rc > 0) {
  671. $sql = "SELECT order_from as _schemas,serial_no,last_status_city, consignee, shipper, h_bol,final_desination_uncode,
  672. to_char(etd, 'MM/DD/YYYY'::text) as etd, to_char(eta, 'MM/DD/YYYY'::text) AS eta,
  673. fport_of_loading_un, mport_of_discharge_un, place_of_receipt_un, place_of_delivery_un, ctnrs, count_cntr, last_status_ctnr,booking_no,
  674. 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,
  675. f_vessel,f_voyage,
  676. CASE
  677. WHEN dd.status is null THEN 'Created'::text
  678. ELSE dd.status::text
  679. END AS new_status,
  680. dd.act_date,dd.act_time,dd.description,
  681. dd.timezone,dd.code as dd_code
  682. FROM public.online_ocean
  683. left join LATERAL (select case when a.code='IFFBCF' then 'Created'
  684. when a.code='IFFCPU' then 'Cargo Received'
  685. when a.code='IFFREC' then 'Cargo Received'
  686. when a.code='IFFDEP' then 'Departure'
  687. when a.code='IFFARR' then 'Arrived'
  688. when a.code='IFFDEL' then 'Completed'
  689. else 'Created' END as status,
  690. act_date,act_time,
  691. _dd.description as description,
  692. timezone,code
  693. from ocean_milestone a
  694. left join LATERAL (select sno,description from milestone where code=a.code and project_no = '*' order by sno limit 1) _dd on true
  695. where a.serial_no=online_ocean.serial_no
  696. and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFDEL', ','))
  697. and a.act_date is not null
  698. order by id desc limit 1) dd on true
  699. $sqlWhere and last_status_315_update_time is not null";
  700. if (_isDemo()) {
  701. $sql .= " ORDER BY eta DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  702. } else {
  703. $sql .= " ORDER BY last_status_315_update_time DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  704. }
  705. $rss = common::excuteListSql($sql);
  706. //RecentStatusList
  707. $RecentStatusList = array();
  708. foreach ($rss as $key => $value) {
  709. $_schemas = $value['_schemas'];
  710. if($_schemas == "public"){
  711. $_schemas = "ocean";
  712. }
  713. $timezone = "";
  714. //按照最新execl Timezone From 来自于origin
  715. if($value['dd_code'] == "IFFBCF" || $value['dd_code'] == "IFFCPU"){
  716. $sql = "SELECT (select time_zone from public.city_timezone where uncode = LEFT(country, 2) || COALESCE(city_code,'')) as timezone
  717. FROM $_schemas.contacts c WHERE c.contact_id = '".$value['origin']."'";
  718. $timezone = common::excuteOneSql($sql);
  719. }
  720. //按照最新execl Timezone From 来自于final_destination
  721. if($value['dd_code'] == "IFFDEL"){
  722. $sql = "select time_zone from public.city_timezone where uncode = '".$value['final_desination_uncode']."'";
  723. $timezone = common::excuteOneSql($sql);
  724. }
  725. if($value['dd_code'] == "IFFREC" || $value['dd_code'] == "IFFDEP" || $value['dd_code'] == "IFFARR"){
  726. //Timezone From 来自于EDI315
  727. $serial_no = $value["serial_no"];
  728. $EDI315Time = common::getEDI315Time($serial_no);
  729. if($value['dd_code'] == "IFFREC" || $value['dd_code'] == "IFFDEP"){
  730. //先以EDI315 时区为准,如果没有这代表数据是手动输入,或者没有同步情况
  731. $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  732. if(empty($timezone)){
  733. if($value['dd_code'] == "IFFREC"){
  734. $sql = "select time_zone from public.city_timezone where uncode = '".$value['place_of_receipt_un']."'";
  735. }else{
  736. $sql = "select time_zone from public.city_timezone where uncode = '".$value['fport_of_loading_un']."'";
  737. }
  738. $timezone = common::excuteOneSql($sql);
  739. }
  740. }
  741. if($value['dd_code'] == "IFFARR"){
  742. $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  743. if(empty($timezone)){
  744. $sql = "select time_zone from public.city_timezone where uncode = '".$value['mport_of_discharge_un']."'";
  745. $timezone = common::excuteOneSql($sql);
  746. }
  747. }
  748. // 根据IFFDEL这个milestone来判断是否转变为completed
  749. // if($value['dd_code'] == "IFFAFD"){
  750. // $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  751. // if(empty($timezone)){
  752. // $sql = "select time_zone from public.city_timezone where uncode = '".$value['place_of_delivery_un']."'";
  753. // $timezone = common::excuteOneSql($sql);
  754. // }
  755. // }
  756. }
  757. $Arrived = $value['description'];
  758. $RecentStatusList[] = array("Title"=>$value['h_bol'],
  759. "name"=>utils::outDisplayForMerge($value['f_vessel'],$value['f_voyage']),
  760. "bookingNumber" =>$value['booking_no'],
  761. "IsSubscribe" =>false,
  762. "shipperName"=>$value['shipper'],
  763. "consigneeName" =>$value['consignee'],
  764. "startStation"=>$value['fport_of_loading_un'],
  765. "endStation"=>$value['mport_of_discharge_un'],
  766. "ETD"=>$value['etd'],
  767. "ETA"=>$value['eta'],
  768. "type"=>$value['new_status'],
  769. "Arrived"=>$Arrived,
  770. "Time"=>$value["act_date"],
  771. "act_time" =>$value["act_time"],
  772. "timezone"=>$timezone,
  773. "_schemas"=>$value["_schemas"],
  774. "a" =>common::deCode($value['serial_no'], 'E'));
  775. }
  776. $data = common::getManagement();
  777. $arrTmp = array('searchData' => $RecentStatusList,
  778. 'Management' => $data['Management'],
  779. 'dashboard_filter' => $data['dashboard_filter'],
  780. 'is_customer' =>_isCustomerLogin(),
  781. 'rc' => $rc,
  782. 'ps' => $ps,
  783. 'cp' => $cp,
  784. 'tp' => $tp);
  785. } else {
  786. $data = common::getManagement();
  787. $arrTmp = array('searchData' => array(),
  788. 'Management' => $data['Management'],
  789. 'dashboard_filter' => $data['dashboard_filter']);
  790. }
  791. common::echo_json_encode(200,$arrTmp);
  792. exit();
  793. break;
  794. case 'save_layout':
  795. $management = json_encode($_POST["management"]);
  796. $dashboard_filter = json_encode($_POST["dashboardObj"]);
  797. $_param = "";
  798. if(!empty($_POST["management"])){
  799. $_param .= " management = '$management' ";
  800. }
  801. if(!empty($dashboard_filter)){
  802. $_param .= ",dashboard_filter = '$dashboard_filter' ";
  803. }
  804. if(!empty($_param)){
  805. common::excuteUpdateSql("update public.ra_online_user set $_param where lower(user_login) = '" . strtolower(_getLoginName()) . "'");
  806. }
  807. $returnData = array("msg" => "success");
  808. common::echo_json_encode(200, $returnData);
  809. exit();
  810. break;
  811. case 'password':
  812. tools::getInstance()->updatePassword();
  813. break;
  814. case 'tools':
  815. tools::getInstance()->markSystem();
  816. break;
  817. case 'user_guide':
  818. $rootPath = realpath(dirname(__FILE__)) . DS;
  819. //common::download_file($rootPath."images\ACE-M1_ISF_ACI_User_Guide\ACE-M1_ISF_ACI_User_Guide.pdf", "ACE-M1_ISF_ACI_User_Guide_V2.0.pdf");
  820. // PDF文件在服务器上的位置
  821. $filename = $rootPath."userFile". DS."KLN_Online_User_Guide_24.11.26.pdf";
  822. $display_name = "KLN_Online_User_Guide_24_11_26.pdf";
  823. // Header content type
  824. header("Content-type: application/pdf");
  825. header("Content-Length: " . filesize($filename));
  826. header("Content-Disposition:attachment;filename=\"" . $display_name . "\"");
  827. // 将文件发送到浏览器。
  828. readfile($filename);
  829. break;
  830. default:
  831. $data = array(
  832. 'msg' => 'Page not found',
  833. );
  834. common::echo_json_encode(500, $data);
  835. }
  836. $db->Close();
  837. $db = null;
  838. if ($max_ec > 0)
  839. ini_set('max_execution_time', $max_ec); //recover old value
  840. if (!empty($memory_limit))
  841. ini_set('memory_limit', $memory_limit);
  842. ?>