您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

106 行
4.0 KiB

  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. //载入配置文件和连接数据库
  4. require_once 'Common/Mysql.php';
  5. $pdo=conn();
  6. $sql = "select c.area_id,d.area_name,a.line_type as bus_type,e.parent_area_id_list
  7. from opera_line as a,opera_station as b,base_resource as c,base_area as d,base_area_view as e
  8. where a.line_id = b.line_id and b.res_id = c.res_id and c.area_id = d.id and d.id = e.area_id
  9. and a.if_disabled = 0 and a.cancel_flag = 0 group by a.line_type,c.area_id order by c.area_id";
  10. $result=$pdo->query($sql);
  11. //低级POI数组
  12. $area_array = $result->fetchAll(PDO::FETCH_ASSOC);
  13. //以穿梭,直通区分的POI数组
  14. $area_type_array = array();
  15. //以id为索引的低级POI数组
  16. $area_id_array = array();
  17. //高级POI数组
  18. $area_id_parent255 = array();
  19. $area_id_parent256 = array();
  20. foreach($area_array as $v => $k){
  21. $array_info = $k;
  22. unset($array_info['bus_type']);
  23. $area_parent = $k['parent_area_id_list'];
  24. $area_parent = explode('}{',$area_parent);
  25. $area_parent = str_replace('{','',$area_parent);
  26. $area_parent = str_replace('}','',$area_parent);
  27. $array_info['parent_area_id_list'] = $area_parent;
  28. //$area_id_array[$k['area_id']] = $k;
  29. if($k['bus_type'] == 0 || $k['bus_type'] == 255 ){
  30. $area_type_array[255][$k['area_id']] = $array_info;
  31. if(!empty($area_parent[0])){
  32. $area_id_parent255 = array_merge($area_id_parent255,$area_parent);
  33. }
  34. }else{
  35. $area_type_array[256][$k['area_id']] = $array_info;
  36. if(!empty($area_parent[0])){
  37. $area_id_parent256 = array_merge($area_id_parent256,$area_parent);
  38. }
  39. }
  40. }
  41. $area_id_parent255 = array_unique($area_id_parent255);
  42. asort($area_id_parent255);
  43. sort($area_id_parent255);
  44. $area_id_parent256 = array_unique($area_id_parent256);
  45. asort($area_id_parent256);
  46. sort($area_id_parent256);
  47. $sql = "select id as area_id,area_name from base_area where id in (" . implode(",",$area_id_parent255) . ")";
  48. $result=$pdo->query($sql);
  49. $area_array_parent255 = $result->fetchAll(PDO::FETCH_ASSOC);
  50. $sql = "select id as area_id,area_name from base_area where id in (" . implode(",",$area_id_parent256) . ")";
  51. $result=$pdo->query($sql);
  52. $area_array_parent256 = $result->fetchAll(PDO::FETCH_ASSOC);
  53. //print_r($area_array_parent255);
  54. //print_r($area_array_parent256);
  55. foreach($area_type_array as $area_type => $area_type_info){
  56. if($area_type == 255){
  57. foreach($area_array_parent255 as $v){
  58. if(!isset($area_type_info[$v['area_id']])){
  59. $area_type_array[$area_type][$v['area_id']] = $v;
  60. }
  61. }
  62. ksort($area_type_array[$area_type]);
  63. }else{
  64. foreach($area_array_parent256 as $v){
  65. if(!isset($area_type_info[$v['area_id']])){
  66. $area_type_array[$area_type][$v['area_id']] = $v;
  67. }
  68. }
  69. ksort($area_type_array[$area_type]);
  70. }
  71. foreach($area_type_info as $area_key => $area_value){
  72. if(count($area_value) > 0){
  73. foreach($area_value['parent_area_id_list'] as $key => $value){
  74. if(!empty($value)){
  75. $area_type_array[$area_type][$value]['son'][] = $area_value['area_id'];
  76. }
  77. }
  78. $area_type_array[$area_type][$area_key]['son'] = '';
  79. unset($area_type_array[$area_type][$area_key]['parent_area_id_list']);
  80. }
  81. }
  82. foreach($area_type_array[$area_type] as $k => $v){
  83. if($v['son'] != ''){
  84. $area_type_array[$area_type][$k]['son'] = implode(',',$v['son']);
  85. }
  86. }
  87. }
  88. set_memcache('ARY_LINE_POI', $area_type_array );
  89. ?>