Commit 4003b459d65a6f5eb010303894725fcba9e859e2

Authored by 潘钊
1 parent 54cc32a4

update...

src/main/resources/static/real_control_v2/js/utils/svg_data_convert.js
@@ -4,8 +4,6 @@ var gb_svg_data_convert = (function () { @@ -4,8 +4,6 @@ var gb_svg_data_convert = (function () {
4 * 合并上下行路由 4 * 合并上下行路由
5 * type 0 上行 1 下行 2 同名合并 3 异名合并 5 * type 0 上行 1 下行 2 同名合并 3 异名合并
6 * 6 *
7 - * 因为基础的数据的各种奇葩搞法,这块打了很多补丁,有时间一定要重写  
8 - *  
9 * enableAttr: 是否启用配置信息 7 * enableAttr: 是否启用配置信息
10 */ 8 */
11 function mergeRoute(routes, enableAttr, lineCode, loopLine) { 9 function mergeRoute(routes, enableAttr, lineCode, loopLine) {
src/main/resources/static/real_control_v2/js/utils/svg_data_convert_cx.js 0 → 100644
  1 +var gb_svg_data_convert = (function () {
  2 +
  3 + /**
  4 + * 合并上下行路由
  5 + * type 0 上行 1 下行 2 同名合并 3 异名合并
  6 + *
  7 + * enableAttr: 是否启用配置信息
  8 + */
  9 + function mergeRoute(rs, enableAttr, lineCode, loopLine) {
  10 + //按上下行拆分
  11 + rs = gb_common.groupBy(rs, 'directions');
  12 + //排序
  13 + sort_station_route(rs);
  14 + //模拟图配置信息
  15 + use_chart_config(enableAttr, lineCode, rs);
  16 +
  17 + var data = [].concat(rs[0]);
  18 +
  19 +
  20 + return data;
  21 + }
  22 +
  23 + var use_chart_config = function (isEnable, lineCode, rs) {
  24 + if (isEnable) {
  25 + var config = gb_data_basic.getSvgAttr(lineCode);
  26 + if (config) {
  27 + rs[0] = filterByAttr(config, rs[0]);
  28 + rs[1] = filterByAttr(config, rs[1]);
  29 + }
  30 + }
  31 + };
  32 +
  33 + var filterByAttr = function (svgAttr, rs) {
  34 + var hsArray = svgAttr.hideStations ? svgAttr.hideStations : [];
  35 + var nsArray = svgAttr.nicknames ? svgAttr.nicknames : {};
  36 + var newRoutes = [];
  37 +
  38 + for (var i = 0, s; s = rs[i++];) {
  39 + if (isHidden(s.stationCode, hsArray))
  40 + return;
  41 +
  42 + if (nsArray[s.stationName])
  43 + s.stationName = nsArray[s.stationName];
  44 +
  45 + newRoutes.push(s);
  46 + }
  47 + return newRoutes;
  48 + };
  49 +
  50 + var isHidden = function (code, array) {
  51 + for (var i = 0, temp; temp = array[i++];) {
  52 + if (code == temp)
  53 + return true;
  54 + }
  55 +
  56 + return false;
  57 + };
  58 +
  59 + var sort_station_route = function (routes) {
  60 + try{
  61 + routes[0].sort(upSort);
  62 + routes[1].sort(downSort);
  63 + }catch (e){
  64 + console.log(e);
  65 + notify_err('有站点路由数据异常!');
  66 + }
  67 + };
  68 +
  69 + var upSort = function (a, b) {
  70 + return a.stationRouteCode - b.stationRouteCode;
  71 + };
  72 +
  73 + var downSort = function (a, b) {
  74 + return b.stationRouteCode - a.stationRouteCode;
  75 + };
  76 +
  77 +
  78 + var nvl_get = function (list, index) {
  79 + return list[index] == null ? {} : list[index];
  80 + };
  81 +
  82 + var groupByStationAndUpdown = function (data) {
  83 + var rs = {}, key;
  84 + $.each(data, function () {
  85 + key = this['stopNo'] + '_' + this['upDown'];
  86 + if (!rs[key])
  87 + rs[key] = [];
  88 +
  89 + rs[key].push(this);
  90 + });
  91 +
  92 + return rs;
  93 + };
  94 + return {mergeRoute: mergeRoute, groupByStationAndUpdown: groupByStationAndUpdown};
  95 +})();