Commit 2248fc4a7f9ca1349ac169c10fc25bb77484a183

Authored by 潘钊
1 parent f3a485b3

update...

src/main/java/com/bsth/controller/geo_data/GeoDataController.java
@@ -83,4 +83,14 @@ public class GeoDataController { @@ -83,4 +83,14 @@ public class GeoDataController {
83 public Map<String, Object> deleteLineVersion(@RequestParam String lineCode,@RequestParam int version){ 83 public Map<String, Object> deleteLineVersion(@RequestParam String lineCode,@RequestParam int version){
84 return geoDataService.deleteLineVersion(lineCode, version); 84 return geoDataService.deleteLineVersion(lineCode, version);
85 } 85 }
  86 +
  87 + @RequestMapping("findFutureVersion")
  88 + public Map<String, Object> findFutureVersion(@RequestParam String lineCode){
  89 + return geoDataService.findFutureVersion(lineCode);
  90 + }
  91 +
  92 + @RequestMapping(value = "addEnableInfo",method = RequestMethod.POST)
  93 + public Map<String, Object> addEnableInfo(@RequestParam String lineCode,@RequestParam int versions, @RequestParam String startDate){
  94 + return geoDataService.addEnableInfo(lineCode, versions, startDate);
  95 + }
86 } 96 }
87 \ No newline at end of file 97 \ No newline at end of file
src/main/java/com/bsth/data/line_version/EnableRouteVersionHandler.java 0 → 100644
  1 +package com.bsth.data.line_version;
  2 +
  3 +import com.bsth.data.line_version.dto.EvSectionRoute;
  4 +import com.bsth.data.line_version.dto.EvStationRoute;
  5 +import org.slf4j.Logger;
  6 +import org.slf4j.LoggerFactory;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.jdbc.core.BeanPropertyRowMapper;
  9 +import org.springframework.jdbc.core.JdbcTemplate;
  10 +import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
  11 +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
  12 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  13 +import org.springframework.stereotype.Component;
  14 +import org.springframework.transaction.TransactionDefinition;
  15 +import org.springframework.transaction.TransactionStatus;
  16 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  17 +
  18 +import java.util.ArrayList;
  19 +import java.util.List;
  20 +
  21 +/**
  22 + * 启用线路路由版本
  23 + * Created by panzhao on 2017/12/28.
  24 + */
  25 +@Component
  26 +public class EnableRouteVersionHandler {
  27 +
  28 + @Autowired
  29 + JdbcTemplate jdbcTemplate;
  30 +
  31 + @Autowired
  32 + NamedParameterJdbcTemplate namedParameterJdbcTemplate;
  33 +
  34 + Logger logger = LoggerFactory.getLogger(this.getClass());
  35 +
  36 + public void enable(String lineCode, int version){
  37 + //编程式事务
  38 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  39 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  40 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  41 + TransactionStatus status = tran.getTransaction(def);
  42 +
  43 +
  44 + try{
  45 + enableStation(lineCode, version);
  46 + enableRoad(lineCode, version);
  47 +
  48 + //将当前版本变为历史版本
  49 + String sql = "update bsth_c_line_versions set status=0, end_date=SYSDATE(),update_date=SYSDATE() where line_code=" + lineCode + " and status=1";
  50 + jdbcTemplate.update(sql);
  51 + //将待更新版本变为启用版本
  52 + sql = "update bsth_c_line_versions set status=1,update_date=SYSDATE() where line_code=" + lineCode + " and versions="+version;
  53 + jdbcTemplate.update(sql);
  54 +
  55 + tran.commit(status);
  56 + }catch (Exception e){
  57 + tran.rollback(status);
  58 + logger.error("", e);
  59 + }
  60 + }
  61 +
  62 + /**
  63 + * 启用新版本站点
  64 + * @param lineCode
  65 + * @param version
  66 + */
  67 + public void enableStation(String lineCode, int version){
  68 + //删除当前站点路由表数据
  69 + String sql = "delete from bsth_c_stationroute where line_code=" + lineCode;
  70 + jdbcTemplate.update(sql);
  71 +
  72 + //将新版本数据插入当前表
  73 + sql = "select * from bsth_c_ls_stationroute where line_code=" + lineCode + " and versions=" + version;
  74 + List<EvStationRoute> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(EvStationRoute.class));
  75 +
  76 + List<BeanPropertySqlParameterSource> sourceList = new ArrayList<>();
  77 + for(EvStationRoute s : list){
  78 + sourceList.add(new BeanPropertySqlParameterSource(s));
  79 + }
  80 +
  81 + sql = "insert into bsth_c_stationroute(id,line,station,station_name,station_route_code,line_code,station_code,station_mark,out_station_nmber,directions,distances,to_time,first_time,end_time,descriptions,destroy,versions,create_date,update_date) " +
  82 + " values(:id,:line,:station,:stationName,:stationRouteCode,:lineCode,:stationCode,:stationMark,:outStationNmber,:directions,:distances,:toTime,:firstTime,:endTime,:descriptions,:destroy,:versions,SYSDATE(),SYSDATE())";
  83 + BeanPropertySqlParameterSource[] beanSources = sourceList.toArray(new BeanPropertySqlParameterSource[sourceList.size()]);
  84 + namedParameterJdbcTemplate.batchUpdate(sql, beanSources);
  85 + }
  86 +
  87 + /**
  88 + * 启用新版本路段
  89 + * @param lineCode
  90 + * @param version
  91 + */
  92 + public void enableRoad(String lineCode, int version){
  93 + //删除当前路段路由表数据
  94 + String sql = "delete from bsth_c_sectionroute where line_code=" + lineCode;
  95 + jdbcTemplate.update(sql);
  96 +
  97 + //将新版本数据插入当前表
  98 + sql = "select * from bsth_c_ls_sectionroute where line_code=" + lineCode + " and versions=" + version;
  99 + List<EvSectionRoute> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(EvSectionRoute.class));
  100 +
  101 + List<BeanPropertySqlParameterSource> sourceList = new ArrayList<>();
  102 + for(EvSectionRoute s : list){
  103 + sourceList.add(new BeanPropertySqlParameterSource(s));
  104 + }
  105 +
  106 + sql = "insert into bsth_c_sectionroute(id,line_code,section_code,sectionroute_code,directions,line,section,descriptions,create_by,create_date,update_by,update_date,versions,destroy,is_roade_speed) " +
  107 + " values(:id,:lineCode,:sectionCode,:sectionrouteCode,:directions,:line,:section,:descriptions,:createBy,SYSDATE(),:updateBy,SYSDATE(),:versions,:destroy,:isRoadeSpeed)";
  108 + BeanPropertySqlParameterSource[] beanSources = sourceList.toArray(new BeanPropertySqlParameterSource[sourceList.size()]);
  109 + namedParameterJdbcTemplate.batchUpdate(sql, beanSources);
  110 + }
  111 +}
src/main/java/com/bsth/data/line_version/dto/EvSectionRoute.java 0 → 100644
  1 +package com.bsth.data.line_version.dto;
  2 +
  3 +import java.util.Date;
  4 +
  5 +/**
  6 + * Created by panzhao on 2017/12/28.
  7 + */
  8 +public class EvSectionRoute {
  9 +
  10 +
  11 + private Integer id;
  12 +
  13 + // 路段路由序号
  14 + private Integer sectionrouteCode;
  15 +
  16 + // 线路编号
  17 + private String lineCode;
  18 +
  19 + // 路段编号
  20 + private String sectionCode;
  21 +
  22 + // 路段路由方向
  23 + private Integer directions;
  24 +
  25 + // 版本号
  26 + private Integer versions;
  27 +
  28 + // 是否撤销
  29 + private Integer destroy;
  30 +
  31 + /** 是否有路段限速数据 <0:分段;1:未分段>*/
  32 + private Integer isRoadeSpeed;
  33 +
  34 + // 描述
  35 + private String descriptions;
  36 +
  37 + // 创建人
  38 + private Integer createBy;
  39 +
  40 + // 修改人
  41 + private Integer updateBy;
  42 +
  43 + // 创建日期
  44 + private Date createDate;
  45 +
  46 + // 修改日期
  47 + private Date updateDate;
  48 +
  49 + // 路段信息
  50 + private Integer section;
  51 +
  52 + // 线路信息
  53 + private Integer line;
  54 +
  55 + public Integer getId() {
  56 + return id;
  57 + }
  58 +
  59 + public void setId(Integer id) {
  60 + this.id = id;
  61 + }
  62 +
  63 + public Integer getSectionrouteCode() {
  64 + return sectionrouteCode;
  65 + }
  66 +
  67 + public void setSectionrouteCode(Integer sectionrouteCode) {
  68 + this.sectionrouteCode = sectionrouteCode;
  69 + }
  70 +
  71 + public String getLineCode() {
  72 + return lineCode;
  73 + }
  74 +
  75 + public void setLineCode(String lineCode) {
  76 + this.lineCode = lineCode;
  77 + }
  78 +
  79 + public String getSectionCode() {
  80 + return sectionCode;
  81 + }
  82 +
  83 + public void setSectionCode(String sectionCode) {
  84 + this.sectionCode = sectionCode;
  85 + }
  86 +
  87 + public Integer getDirections() {
  88 + return directions;
  89 + }
  90 +
  91 + public void setDirections(Integer directions) {
  92 + this.directions = directions;
  93 + }
  94 +
  95 + public Integer getVersions() {
  96 + return versions;
  97 + }
  98 +
  99 + public void setVersions(Integer versions) {
  100 + this.versions = versions;
  101 + }
  102 +
  103 + public Integer getDestroy() {
  104 + return destroy;
  105 + }
  106 +
  107 + public void setDestroy(Integer destroy) {
  108 + this.destroy = destroy;
  109 + }
  110 +
  111 + public Integer getIsRoadeSpeed() {
  112 + return isRoadeSpeed;
  113 + }
  114 +
  115 + public void setIsRoadeSpeed(Integer isRoadeSpeed) {
  116 + this.isRoadeSpeed = isRoadeSpeed;
  117 + }
  118 +
  119 + public String getDescriptions() {
  120 + return descriptions;
  121 + }
  122 +
  123 + public void setDescriptions(String descriptions) {
  124 + this.descriptions = descriptions;
  125 + }
  126 +
  127 + public Integer getCreateBy() {
  128 + return createBy;
  129 + }
  130 +
  131 + public void setCreateBy(Integer createBy) {
  132 + this.createBy = createBy;
  133 + }
  134 +
  135 + public Integer getUpdateBy() {
  136 + return updateBy;
  137 + }
  138 +
  139 + public void setUpdateBy(Integer updateBy) {
  140 + this.updateBy = updateBy;
  141 + }
  142 +
  143 + public Date getCreateDate() {
  144 + return createDate;
  145 + }
  146 +
  147 + public void setCreateDate(Date createDate) {
  148 + this.createDate = createDate;
  149 + }
  150 +
  151 + public Date getUpdateDate() {
  152 + return updateDate;
  153 + }
  154 +
  155 + public void setUpdateDate(Date updateDate) {
  156 + this.updateDate = updateDate;
  157 + }
  158 +
  159 + public Integer getSection() {
  160 + return section;
  161 + }
  162 +
  163 + public void setSection(Integer section) {
  164 + this.section = section;
  165 + }
  166 +
  167 + public Integer getLine() {
  168 + return line;
  169 + }
  170 +
  171 + public void setLine(Integer line) {
  172 + this.line = line;
  173 + }
  174 +}
src/main/java/com/bsth/data/line_version/dto/EvStationRoute.java 0 → 100644
  1 +package com.bsth.data.line_version.dto;
  2 +
  3 +import java.util.Date;
  4 +
  5 +/**
  6 + * Created by panzhao on 2017/12/28.
  7 + */
  8 +public class EvStationRoute {
  9 + private Integer id;
  10 +
  11 + // 站点路由序号
  12 + private Integer stationRouteCode;
  13 +
  14 + // 站点编码
  15 + private String stationCode;
  16 +
  17 + // 站点名称
  18 + private String stationName;
  19 +
  20 + // 线路编码
  21 + private String lineCode;
  22 +
  23 + /**
  24 + * 站点类型
  25 + *
  26 + * ------ B:起点站
  27 + *
  28 + * ------ Z:中途站
  29 + *
  30 + * ------ E:终点站
  31 + *
  32 + * ------ T:停车场
  33 + *
  34 + */
  35 + private String stationMark;
  36 +
  37 + // 站点路由出站序号
  38 + private Integer outStationNmber;
  39 +
  40 + // 站点路由到站距离
  41 + private Double distances;
  42 +
  43 + // 站点路由到站时间
  44 + private Double toTime;
  45 +
  46 + // 首班时间
  47 + private String firstTime;
  48 +
  49 + // 末班时间
  50 + private String endTime;
  51 +
  52 + // 站点路由方向
  53 + private Integer directions;
  54 +
  55 + // 版本号
  56 + private Integer versions;
  57 +
  58 + // 是否撤销
  59 + private Integer destroy;
  60 +
  61 + // 描述
  62 + private String descriptions;
  63 +
  64 + // 创建人
  65 + private Integer createBy;
  66 +
  67 + // 修改人
  68 + private Integer updateBy;
  69 +
  70 + // 创建日期
  71 + private Date createDate;
  72 +
  73 + // 修改日期
  74 + private Date updateDate;
  75 +
  76 + // 站点信息
  77 + private Integer station;
  78 +
  79 + // 线路信息
  80 + private Integer line;
  81 +
  82 + public Integer getId() {
  83 + return id;
  84 + }
  85 +
  86 + public void setId(Integer id) {
  87 + this.id = id;
  88 + }
  89 +
  90 + public Integer getStationRouteCode() {
  91 + return stationRouteCode;
  92 + }
  93 +
  94 + public void setStationRouteCode(Integer stationRouteCode) {
  95 + this.stationRouteCode = stationRouteCode;
  96 + }
  97 +
  98 + public String getStationCode() {
  99 + return stationCode;
  100 + }
  101 +
  102 + public void setStationCode(String stationCode) {
  103 + this.stationCode = stationCode;
  104 + }
  105 +
  106 + public String getStationName() {
  107 + return stationName;
  108 + }
  109 +
  110 + public void setStationName(String stationName) {
  111 + this.stationName = stationName;
  112 + }
  113 +
  114 + public String getLineCode() {
  115 + return lineCode;
  116 + }
  117 +
  118 + public void setLineCode(String lineCode) {
  119 + this.lineCode = lineCode;
  120 + }
  121 +
  122 + public String getStationMark() {
  123 + return stationMark;
  124 + }
  125 +
  126 + public void setStationMark(String stationMark) {
  127 + this.stationMark = stationMark;
  128 + }
  129 +
  130 + public Integer getOutStationNmber() {
  131 + return outStationNmber;
  132 + }
  133 +
  134 + public void setOutStationNmber(Integer outStationNmber) {
  135 + this.outStationNmber = outStationNmber;
  136 + }
  137 +
  138 + public Double getDistances() {
  139 + return distances;
  140 + }
  141 +
  142 + public void setDistances(Double distances) {
  143 + this.distances = distances;
  144 + }
  145 +
  146 + public Double getToTime() {
  147 + return toTime;
  148 + }
  149 +
  150 + public void setToTime(Double toTime) {
  151 + this.toTime = toTime;
  152 + }
  153 +
  154 + public String getFirstTime() {
  155 + return firstTime;
  156 + }
  157 +
  158 + public void setFirstTime(String firstTime) {
  159 + this.firstTime = firstTime;
  160 + }
  161 +
  162 + public String getEndTime() {
  163 + return endTime;
  164 + }
  165 +
  166 + public void setEndTime(String endTime) {
  167 + this.endTime = endTime;
  168 + }
  169 +
  170 + public Integer getDirections() {
  171 + return directions;
  172 + }
  173 +
  174 + public void setDirections(Integer directions) {
  175 + this.directions = directions;
  176 + }
  177 +
  178 + public Integer getVersions() {
  179 + return versions;
  180 + }
  181 +
  182 + public void setVersions(Integer versions) {
  183 + this.versions = versions;
  184 + }
  185 +
  186 + public Integer getDestroy() {
  187 + return destroy;
  188 + }
  189 +
  190 + public void setDestroy(Integer destroy) {
  191 + this.destroy = destroy;
  192 + }
  193 +
  194 + public String getDescriptions() {
  195 + return descriptions;
  196 + }
  197 +
  198 + public void setDescriptions(String descriptions) {
  199 + this.descriptions = descriptions;
  200 + }
  201 +
  202 + public Integer getCreateBy() {
  203 + return createBy;
  204 + }
  205 +
  206 + public void setCreateBy(Integer createBy) {
  207 + this.createBy = createBy;
  208 + }
  209 +
  210 + public Integer getUpdateBy() {
  211 + return updateBy;
  212 + }
  213 +
  214 + public void setUpdateBy(Integer updateBy) {
  215 + this.updateBy = updateBy;
  216 + }
  217 +
  218 + public Date getCreateDate() {
  219 + return createDate;
  220 + }
  221 +
  222 + public void setCreateDate(Date createDate) {
  223 + this.createDate = createDate;
  224 + }
  225 +
  226 + public Date getUpdateDate() {
  227 + return updateDate;
  228 + }
  229 +
  230 + public void setUpdateDate(Date updateDate) {
  231 + this.updateDate = updateDate;
  232 + }
  233 +
  234 + public Integer getStation() {
  235 + return station;
  236 + }
  237 +
  238 + public void setStation(Integer station) {
  239 + this.station = station;
  240 + }
  241 +
  242 + public Integer getLine() {
  243 + return line;
  244 + }
  245 +
  246 + public void setLine(Integer line) {
  247 + this.line = line;
  248 + }
  249 +}
src/main/java/com/bsth/data/line_version/thread/FixedEnableVerionsThread.java 0 → 100644
  1 +package com.bsth.data.line_version.thread;
  2 +
  3 +import com.bsth.data.line_version.EnableRouteVersionHandler;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.jdbc.core.JdbcTemplate;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +import java.util.List;
  11 +import java.util.Map;
  12 +
  13 +/**
  14 + * Created by panzhao on 2017/12/28.
  15 + */
  16 +@Component
  17 +public class FixedEnableVerionsThread extends Thread{
  18 +
  19 + @Autowired
  20 + JdbcTemplate jdbcTemplate;
  21 +
  22 + Logger logger = LoggerFactory.getLogger(this.getClass());
  23 +
  24 + @Autowired
  25 + EnableRouteVersionHandler enableRouteVersionHandler;
  26 +
  27 + @Override
  28 + public void run() {
  29 + try{
  30 +
  31 + String sql = "select * from bsth_c_line_versions where status=2 and start_date<=SYSDATE()";
  32 +
  33 + List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
  34 + if(list.size() == 0)
  35 + return;
  36 +
  37 + String lineCode;
  38 + int version;
  39 +
  40 + for(Map<String, Object> map : list){
  41 + lineCode = map.get("line_code").toString();
  42 + version = Integer.parseInt(map.get("versions").toString());
  43 +
  44 + enableRouteVersionHandler.enable(lineCode, version);
  45 + }
  46 + }catch (Exception e){
  47 + logger.error("", e);
  48 + }
  49 + }
  50 +}
src/main/java/com/bsth/service/geo_data/GeoDataService.java
@@ -35,4 +35,8 @@ public interface GeoDataService { @@ -35,4 +35,8 @@ public interface GeoDataService {
35 Map<String,Object> addNewLineVersion(Map<String, Object> map); 35 Map<String,Object> addNewLineVersion(Map<String, Object> map);
36 36
37 Map<String,Object> deleteLineVersion(String lineCode, int version); 37 Map<String,Object> deleteLineVersion(String lineCode, int version);
  38 +
  39 + Map<String,Object> findFutureVersion(String lineCode);
  40 +
  41 + Map<String,Object> addEnableInfo(String lineCode, int version, String enableTime);
38 } 42 }
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
@@ -337,6 +337,18 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -337,6 +337,18 @@ public class GeoDataServiceImpl implements GeoDataService {
337 Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(map.get("startDate").toString()); 337 Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(map.get("startDate").toString());
338 int extendsVersion = Integer.parseInt(map.get("extendsVersion").toString()); 338 int extendsVersion = Integer.parseInt(map.get("extendsVersion").toString());
339 339
  340 + if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){
  341 + rs.put("status", ResponseCode.ERROR);
  342 + rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!");
  343 + return rs;
  344 + }
  345 +
  346 + int nameCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code=" + lineCode + " and name='"+name+"'", Integer.class);
  347 + if(nameCount > 0){
  348 + rs.put("status", ResponseCode.ERROR);
  349 + rs.put("msg", "你不能使用一个已经存在的版本名称!!");
  350 + return rs;
  351 + }
340 352
341 //当前最大的版本号 353 //当前最大的版本号
342 int maxVersion = jdbcTemplate.queryForObject("select max(versions) as versions from bsth_c_line_versions where line_code=" + lineCode, Integer.class); 354 int maxVersion = jdbcTemplate.queryForObject("select max(versions) as versions from bsth_c_line_versions where line_code=" + lineCode, Integer.class);
@@ -356,6 +368,9 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -356,6 +368,9 @@ public class GeoDataServiceImpl implements GeoDataService {
356 lVersion.setUpdateDate(d); 368 lVersion.setUpdateDate(d);
357 lVersion.setLineCode(lineCode); 369 lVersion.setLineCode(lineCode);
358 370
  371 + //如果有待启用的版本,设置为历史版本
  372 + jdbcTemplate.update("update bsth_c_line_versions set `status`=0, start_date=null,end_date=null where line_code='"+lineCode+"' and `status`=2");
  373 +
359 //入库线路版本 374 //入库线路版本
360 jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " + 375 jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " +
361 " values(?,?,?,?,?,?,?,?,?,?)", lVersion.getName(), lineId, lVersion.getLineCode() 376 " values(?,?,?,?,?,?,?,?,?,?)", lVersion.getName(), lineId, lVersion.getLineCode()
@@ -420,12 +435,19 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -420,12 +435,19 @@ public class GeoDataServiceImpl implements GeoDataService {
420 def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); 435 def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
421 TransactionStatus status = tran.getTransaction(def); 436 TransactionStatus status = tran.getTransaction(def);
422 try{ 437 try{
423 - int versionCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code='"+lineCode+"'", Integer.class); 438 + int enableVersion = jdbcTemplate.queryForObject("select versions from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=1", Integer.class);
  439 +
  440 + if(enableVersion==version){
  441 + rs.put("status", ResponseCode.ERROR);
  442 + rs.put("msg", "你不能删除当前正在启用的走向版本!");
  443 + return rs;
  444 + }
  445 + /*int versionCount = jdbcTemplate.queryForObject("select count(*) from bsth_c_line_versions where line_code='"+lineCode+"'", Integer.class);
424 if(versionCount == 1){ 446 if(versionCount == 1){
425 rs.put("status", ResponseCode.ERROR); 447 rs.put("status", ResponseCode.ERROR);
426 rs.put("msg", "线路至少要保留一个走向版本!"); 448 rs.put("msg", "线路至少要保留一个走向版本!");
427 return rs; 449 return rs;
428 - } 450 + }*/
429 451
430 /* //要删除的站点ID(未被其他线路、版本引用的) 452 /* //要删除的站点ID(未被其他线路、版本引用的)
431 String sql = "select DISTINCT station from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions="+version+" and station not in(" + 453 String sql = "select DISTINCT station from bsth_c_ls_stationroute where line_code='"+lineCode+"' and versions="+version+" and station not in(" +
@@ -459,6 +481,50 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -459,6 +481,50 @@ public class GeoDataServiceImpl implements GeoDataService {
459 } 481 }
460 482
461 /** 483 /**
  484 + * 获取线路的待更新版本信息
  485 + * @param lineCode
  486 + * @return
  487 + */
  488 + @Override
  489 + public Map<String, Object> findFutureVersion(String lineCode) {
  490 + Map<String, Object> rs = new HashMap();
  491 + try{
  492 + List<Map<String, Object>> list = jdbcTemplate.queryForList("select * from bsth_c_line_versions where line_code='"+lineCode+"' and `status`=2 order by start_date");
  493 +
  494 + rs.put("data", list);
  495 + rs.put("status", ResponseCode.SUCCESS);
  496 + }catch (Exception e){
  497 + logger.error("", e);
  498 + rs.put("status", ResponseCode.ERROR);
  499 + rs.put("msg", "服务器出现异常");
  500 + }
  501 + return rs;
  502 + }
  503 +
  504 + @Override
  505 + public Map<String, Object> addEnableInfo(String lineCode, int version, String enableTime) {
  506 + Map<String, Object> rs = new HashMap();
  507 + try{
  508 + Date startDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(enableTime);
  509 + if(startDate.getTime() - System.currentTimeMillis() < 1000 * 60 * 3){
  510 + rs.put("status", ResponseCode.ERROR);
  511 + rs.put("msg", "启用时间最少需要晚于当前服务器时间3分钟!");
  512 + return rs;
  513 + }
  514 +
  515 + jdbcTemplate.update("update bsth_c_line_versions set `status`=0 where line_code="+lineCode+" and versions=" + version);
  516 + jdbcTemplate.update("update bsth_c_line_versions set `status`=2 ,start_date=? where line_code=? and versions=?", startDate, lineCode, version);
  517 +
  518 + rs.put("status", ResponseCode.SUCCESS);
  519 + }catch (Exception e){
  520 + logger.error("", e);
  521 + rs.put("status", ResponseCode.ERROR);
  522 + rs.put("msg", "服务器出现异常");
  523 + }
  524 + return rs;
  525 + }
  526 +
  527 + /**
462 * 批量入库路段 528 * 批量入库路段
463 * @param cssList 529 * @param cssList
464 * @param version 530 * @param version
@@ -644,6 +710,10 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -644,6 +710,10 @@ public class GeoDataServiceImpl implements GeoDataService {
644 nsr.setCreateDate(d); 710 nsr.setCreateDate(d);
645 nsr.setUpdateDate(d); 711 nsr.setUpdateDate(d);
646 nsr.setDestroy(0); 712 nsr.setDestroy(0);
  713 + if (prevRouteId == -1)
  714 + nsr.setStationMark("B");
  715 + else if(routes.size()==1)
  716 + nsr.setStationMark("E");
647 717
648 //routes.add(sr); 718 //routes.add(sr);
649 719
@@ -652,10 +722,10 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -652,10 +722,10 @@ public class GeoDataServiceImpl implements GeoDataService {
652 for (int i = 0, size = routes.size(); i < size; i++) { 722 for (int i = 0, size = routes.size(); i < size; i++) {
653 routes.get(i).setStationMark("Z"); 723 routes.get(i).setStationMark("Z");
654 } 724 }
655 - if(routes.size() > 1){ 725 + if(routes.size() > 0)
656 routes.get(0).setStationMark("B"); 726 routes.get(0).setStationMark("B");
  727 + if(routes.size() > 1)
657 routes.get(routes.size() - 1).setStationMark("E"); 728 routes.get(routes.size() - 1).setStationMark("E");
658 - }  
659 729
660 final List<SaveStationRouteDTO> saveList = routes; 730 final List<SaveStationRouteDTO> saveList = routes;
661 //insert 新路由 (ID自增) 731 //insert 新路由 (ID自增)
src/main/resources/static/pages/base/geo_data_edit/css/mian.css
@@ -84,8 +84,9 @@ div#map_wrap{ @@ -84,8 +84,9 @@ div#map_wrap{
84 a._version_text:hover{ 84 a._version_text:hover{
85 color: #0aae0a; 85 color: #0aae0a;
86 } 86 }
  87 +
87 ._version_dropdown_wrap li.uk-active>a{ 88 ._version_dropdown_wrap li.uk-active>a{
88 - color: #0aae0a; 89 + color: blue;
89 } 90 }
90 .uk-nav-header:not(:first-child) { 91 .uk-nav-header:not(:first-child) {
91 margin-top: 10px; 92 margin-top: 10px;
@@ -102,15 +103,31 @@ a._version_text:hover{ @@ -102,15 +103,31 @@ a._version_text:hover{
102 top: 10px; 103 top: 10px;
103 } 104 }
104 105
  106 +a.clock_enable_version,
  107 +a.clock_enable_version:hover,
  108 +a.clock_enable_version:active,
  109 +a.clock_enable_version:focus{
  110 + color: #ef4f4f;
  111 +}
  112 +
105 .clock_enable_version{ 113 .clock_enable_version{
106 - padding: 4px 0 0 15px;  
107 - font-size: 13px; 114 + padding: 6px 0 0 13px;
  115 + font-size: 12px;
  116 + color: #ef4f4f;
  117 + overflow: hidden;
  118 + text-overflow: ellipsis;
  119 + white-space: nowrap;
  120 + display: block;
  121 +}
  122 +
  123 +.clock_enable_version .t_t_str{
  124 + font-size: 15px;
108 color: #ef4f4f; 125 color: #ef4f4f;
109 } 126 }
110 127
111 .clock_enable_version>a.uk-icon{ 128 .clock_enable_version>a.uk-icon{
112 vertical-align: top; 129 vertical-align: top;
113 - margin-top: 6px; 130 + margin-top: 5px;
114 } 131 }
115 ._route_info_wrap{ 132 ._route_info_wrap{
116 height: calc(100% - 90px); 133 height: calc(100% - 90px);
@@ -617,11 +634,11 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root { @@ -617,11 +634,11 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root {
617 pointer-events: auto; 634 pointer-events: auto;
618 } 635 }
619 636
620 -#add_line_versions_modal form.uk-form-horizontal .uk-form-label{ 637 +.lvm_wrap form.uk-form-horizontal .uk-form-label{
621 width: 100px !important; 638 width: 100px !important;
622 } 639 }
623 640
624 -#add_line_versions_modal form.uk-form-horizontal .uk-form-controls{ 641 +.lvm_wrap form.uk-form-horizontal .uk-form-controls{
625 margin-left: 115px; 642 margin-left: 115px;
626 } 643 }
627 644
@@ -629,7 +646,7 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root { @@ -629,7 +646,7 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root {
629 display: none; 646 display: none;
630 } 647 }
631 648
632 -.add_station_icon{ 649 +.empty_add_icon{
633 width: 140px; 650 width: 140px;
634 border: 1px dashed #e2e2e2 !important; 651 border: 1px dashed #e2e2e2 !important;
635 text-align: center; 652 text-align: center;
@@ -638,16 +655,16 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root { @@ -638,16 +655,16 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root {
638 cursor: pointer; 655 cursor: pointer;
639 } 656 }
640 657
641 -.add_station_icon:hover{ 658 +.empty_add_icon:hover{
642 border: 1px solid #e2e2e2; 659 border: 1px solid #e2e2e2;
643 } 660 }
644 661
645 -.add_station_icon>span.uk-icon{ 662 +.empty_add_icon>span.uk-icon{
646 vertical-align: top; 663 vertical-align: top;
647 margin-top: 3px; 664 margin-top: 3px;
648 } 665 }
649 666
650 -.add_station_icon>a{ 667 +.empty_add_icon>a{
651 color: grey !important; 668 color: grey !important;
652 display: inline-block !important; 669 display: inline-block !important;
653 width: auto !important; 670 width: auto !important;
@@ -656,4 +673,55 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root { @@ -656,4 +673,55 @@ ul.context-menu-list.station-route-ct-menu.context-menu-root {
656 673
657 .road_route>ul.empty{ 674 .road_route>ul.empty{
658 border-left: none; 675 border-left: none;
  676 +}
  677 +
  678 +.s_future_version_info ._line_info{
  679 + height: 95px;
  680 +}
  681 +
  682 +.s_future_version_info ._route_info_wrap{
  683 + height: calc(100% - 105px);
  684 +}
  685 +
  686 +a.b_l_s_link{
  687 + color: red;
  688 + font-size: 13px;
  689 + display: inline-block;
  690 + vertical-align: bottom;
  691 + margin-right: 5px;
  692 +}
  693 +
  694 +.clock_enable_version.green,
  695 +.clock_enable_version.green:hover,
  696 +.clock_enable_version.green:active,
  697 +.clock_enable_version.green:focus{
  698 + color: green;
  699 +}
  700 +
  701 +.clock_enable_version.green .t_t_str{
  702 + color: green !important;
  703 +}
  704 +
  705 +
  706 +.clock_enable_version.orange,
  707 +.clock_enable_version.orange:hover,
  708 +.clock_enable_version.orange:active,
  709 +.clock_enable_version.orange:focus{
  710 + color: #c88408;
  711 +}
  712 +
  713 +.clock_enable_version.orange .t_t_str{
  714 + color: #c88408 !important;
  715 +}
  716 +
  717 +._version_text.e0{
  718 + color: grey !important;
  719 +}
  720 +
  721 +._version_text.e2{
  722 + color: #c88408 !important;
  723 +}
  724 +
  725 +.uk-tooltip.uk-active {
  726 + z-index: 99999;
659 } 727 }
660 \ No newline at end of file 728 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/fragments/f_road_route.html
@@ -20,9 +20,9 @@ @@ -20,9 +20,9 @@
20 20
21 {{if list.length==0}} 21 {{if list.length==0}}
22 <li class="r_r_item"> 22 <li class="r_r_item">
23 - <div class="add_station_icon"> 23 + <div class="empty_add_icon add_road_icon" data-updown="{{updown}}">
24 <span uk-icon="icon: plus;ratio:.8"></span> 24 <span uk-icon="icon: plus;ratio:.8"></span>
25 - <a data-updown="{{updown}}">添加路段</a> 25 + <a>添加路段</a>
26 </div> 26 </div>
27 </li> 27 </li>
28 {{/if}} 28 {{/if}}
src/main/resources/static/pages/base/geo_data_edit/fragments/f_station_route.html
@@ -12,8 +12,8 @@ @@ -12,8 +12,8 @@
12 {{/each}} 12 {{/each}}
13 13
14 {{if list.length==0}} 14 {{if list.length==0}}
15 - <li class="s_r_item">  
16 - <div class="add_station_icon"> 15 + <li class="">
  16 + <div class="empty_add_icon add_station_icon">
17 <span uk-icon="icon: plus;ratio:.8"></span> 17 <span uk-icon="icon: plus;ratio:.8"></span>
18 <a data-updown="{{updown}}">添加站点</a> 18 <a data-updown="{{updown}}">添加站点</a>
19 </div> 19 </div>
src/main/resources/static/pages/base/geo_data_edit/fragments/versions.html
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 {{if data[0]!=null}} 3 {{if data[0]!=null}}
4 <li class="uk-nav-header">历史</li> 4 <li class="uk-nav-header">历史</li>
5 {{each data[0] as obj i}} 5 {{each data[0] as obj i}}
6 - <li class="{{if obj.versions==cvs}}uk-active{{/if}}" data-version="{{obj.versions}}"><a>{{obj.name}}</a></li> 6 + <li class="{{if obj.versions==cvs}}uk-active{{/if}} e0" data-version="{{obj.versions}}"><a>{{obj.name}}</a></li>
7 {{/each}} 7 {{/each}}
8 <li class="uk-nav-divider"></li> 8 <li class="uk-nav-divider"></li>
9 {{/if}} 9 {{/if}}
@@ -11,20 +11,20 @@ @@ -11,20 +11,20 @@
11 {{if data[1]!=null}} 11 {{if data[1]!=null}}
12 <li class="uk-nav-header">启用的</li> 12 <li class="uk-nav-header">启用的</li>
13 {{each data[1] as obj i}} 13 {{each data[1] as obj i}}
14 - <li class="{{if obj.versions==cvs}}uk-active{{/if}}" data-version="{{obj.versions}}"><a>{{obj.name}}</a></li> 14 + <li class="{{if obj.versions==cvs}}uk-active{{/if}} e1" data-version="{{obj.versions}}"><a>{{obj.name}}</a></li>
15 {{/each}} 15 {{/each}}
16 {{/if}} 16 {{/if}}
17 17
18 {{if data[2]!=null}} 18 {{if data[2]!=null}}
19 <li class="uk-nav-header">未来</li> 19 <li class="uk-nav-header">未来</li>
20 {{each data[2] as obj i}} 20 {{each data[2] as obj i}}
21 - <li class="{{if obj.versions==cvs}}uk-active{{/if}}" data-version="{{obj.versions}}"><a>{{obj.name}}</a></li> 21 + <li class="{{if obj.versions==cvs}}uk-active{{/if}} e2" data-version="{{obj.versions}}"><a>{{obj.name}}</a></li>
22 {{/each}} 22 {{/each}}
23 {{/if}} 23 {{/if}}
24 </script> 24 </script>
25 25
26 <script id="geo_d_e_version_add-temp" type="text/html"> 26 <script id="geo_d_e_version_add-temp" type="text/html">
27 - <div id="add_line_versions_modal" uk-modal esc-close="false" bg-close="false"> 27 + <div id="add_line_versions_modal" uk-modal esc-close="false" bg-close="false" class="lvm_wrap">
28 <div class="uk-modal-dialog uk-modal-body"> 28 <div class="uk-modal-dialog uk-modal-body">
29 <button class="uk-modal-close-default" type="button" uk-close></button> 29 <button class="uk-modal-close-default" type="button" uk-close></button>
30 <h2 class="uk-modal-title">添加走向版本</h2> 30 <h2 class="uk-modal-title">添加走向版本</h2>
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <div class="uk-margin"> 43 <div class="uk-margin">
44 <label class="uk-form-label" >启用时间</label> 44 <label class="uk-form-label" >启用时间</label>
45 <div class="uk-form-controls"> 45 <div class="uk-form-controls">
46 - <input class="uk-input _flatpickr" type="text" name="startDate" placeholder="启用该版本走向的时间"> 46 + <input class="uk-input _flatpickr" type="text" name="startDate" placeholder="启用这个走向的时间">
47 </div> 47 </div>
48 </div> 48 </div>
49 49
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 <div class="uk-form-label">继承走向</div> 58 <div class="uk-form-label">继承走向</div>
59 <div class="uk-form-controls"> 59 <div class="uk-form-controls">
60 <select class="uk-select" name="extendsVersion"> 60 <select class="uk-select" name="extendsVersion">
61 - <option>不继承之前的走向</option> 61 + <option value="-1">不继承之前的走向</option>
62 62
63 {{each array as obj i}} 63 {{each array as obj i}}
64 <option value="{{obj.versions}}" data-id="{{obj.id}}">{{obj.name}}</option> 64 <option value="{{obj.versions}}" data-id="{{obj.id}}">{{obj.name}}</option>
@@ -76,4 +76,80 @@ @@ -76,4 +76,80 @@
76 </div> 76 </div>
77 </div> 77 </div>
78 </script> 78 </script>
  79 +
  80 + <script id="geo_d_e_version_enable-temp" type="text/html">
  81 + <div id="enable_line_versions_modal" uk-modal esc-close="false" bg-close="false" class="lvm_wrap">
  82 + <div class="uk-modal-dialog uk-modal-body">
  83 + <button class="uk-modal-close-default" type="button" uk-close></button>
  84 + <h2 class="uk-modal-title">启用版本({{name}})</h2>
  85 +
  86 + <form class="uk-form-horizontal uk-margin-large">
  87 + <div class="uk-margin">
  88 + <label class="uk-form-label" >版本名称</label>
  89 + <div class="uk-form-controls">
  90 + <input class="uk-input" type="text" name="name" value="{{name}}" readonly>
  91 + </div>
  92 + </div>
  93 +
  94 + <div class="uk-margin">
  95 + <label class="uk-form-label" >版本号</label>
  96 + <div class="uk-form-controls">
  97 + <input class="uk-input" type="text" name="versions" value="{{versions}}" readonly>
  98 + </div>
  99 + </div>
  100 +
  101 + <div class="uk-margin">
  102 + <label class="uk-form-label" >启用时间</label>
  103 + <div class="uk-form-controls">
  104 + <input class="uk-input _flatpickr" type="text" name="startDate" placeholder="启用该版本走向的时间">
  105 + </div>
  106 + </div>
  107 + </form>
  108 +
  109 + <p class="uk-text-right">
  110 + <button class="uk-button uk-button-default uk-modal-close" type="button">取消</button>
  111 + <button class="uk-button uk-button-primary _submit" type="button">提交</button>
  112 + </p>
  113 + </div>
  114 + </div>
  115 + </script>
  116 +
  117 + <script id="g_d_e_v_enable_edit-temp" type="text/html">
  118 + <div id="enable_versions_edit_modal" uk-modal esc-close="false" bg-close="false" class="lvm_wrap">
  119 + <div class="uk-modal-dialog uk-modal-body">
  120 + <button class="uk-modal-close-default" type="button" uk-close></button>
  121 + <h2 class="uk-modal-title">待更新版本</h2>
  122 +
  123 + <form class="uk-form-horizontal uk-margin-large">
  124 + <div class="uk-margin">
  125 + <label class="uk-form-label" >启用时间</label>
  126 + <div class="uk-form-controls">
  127 + <input class="uk-input _flatpickr" type="text" name="startDate" value="{{start_date_str}}">
  128 + </div>
  129 + </div>
  130 +
  131 + <div class="uk-margin">
  132 + <label class="uk-form-label" >版本名称</label>
  133 + <div class="uk-form-controls">
  134 + <input class="uk-input" type="text" name="name" value="{{name}}" readonly>
  135 + </div>
  136 + </div>
  137 +
  138 + <div class="uk-margin">
  139 + <label class="uk-form-label" >版本号</label>
  140 + <div class="uk-form-controls">
  141 + <input class="uk-input" type="text" name="versions" value="{{versions}}" readonly>
  142 + </div>
  143 + </div>
  144 + </form>
  145 +
  146 + <p class="uk-text-right">
  147 + <a class="b_l_s_link" title="日后再说" uk-tooltip="pos:top">撤销启用计划</a>
  148 + <button class="uk-button uk-button-default uk-modal-close" type="button">取消</button>
  149 + <!--<button class="uk-button uk-button-danger _cancel" type="button">撤销</button>-->
  150 + <button class="uk-button uk-button-primary _submit" type="button">提交</button>
  151 + </p>
  152 + </div>
  153 + </div>
  154 + </script>
79 </div> 155 </div>
80 \ No newline at end of file 156 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/js/ct_common.js 0 → 100644
  1 +var gb_common = (function () {
  2 +
  3 + var flatpickrDateTimeConfig = {
  4 + enableTime: true,
  5 + time_24hr: true,
  6 + "locale": "zh",
  7 + onOpen: function () {
  8 + $(this.calendarContainer).addClass('showTimeInput');
  9 + }
  10 + };
  11 +
  12 + var groupBy = function (list, field) {
  13 + var rs = {},
  14 + key;
  15 + $.each(list, function () {
  16 + key = this[field];
  17 + if (!rs[key])
  18 + rs[key] = [];
  19 +
  20 + rs[key].push(this);
  21 + });
  22 +
  23 + return rs;
  24 + };
  25 +
  26 + var compileTempByDom = function (dom, opts) {
  27 + var tps = {},
  28 + id;
  29 + $('script[type="text/html"]', dom).each(function () {
  30 + id = $(this).attr('id');
  31 + if (id)
  32 + tps[id] = template.compile($(this).html(), opts);
  33 + });
  34 + return tps;
  35 + };
  36 +
  37 + var $get = function (url, data, successFun) {
  38 + $.ajax({
  39 + url: url,
  40 + data: data,
  41 + complete: function (xhr, ts) {
  42 + ajaxComplete(xhr, ts, successFun);
  43 + }
  44 + });
  45 + };
  46 +
  47 + var $post = function (url, data, successFun) {
  48 + $.ajax({
  49 + url: url,
  50 + method: 'POST',
  51 + data: data,
  52 + complete: function (xhr, ts) {
  53 + ajaxComplete(xhr, ts, successFun);
  54 + }
  55 + });
  56 + };
  57 +
  58 + var $post_arr = function (url, data, successFun) {
  59 + $.ajax({
  60 + url: url,
  61 + method: 'POST',
  62 + traditional: true,
  63 + data: data,
  64 + complete: function (xhr, ts) {
  65 + ajaxComplete(xhr, ts, successFun);
  66 + }
  67 + });
  68 + };
  69 +
  70 + var $del = function (url, successFun) {
  71 + $post(url, {'_method': 'delete'}, function (rs) {
  72 + successFun && successFun(rs);
  73 + });
  74 + };
  75 +
  76 + function hide_wait_modal() {
  77 + $('.main_left_panel_m_layer').hide();
  78 + $loadPanel.hide();
  79 + //gb_ct_map.resetMapStatus();
  80 + }
  81 +
  82 + var errorHead = '<span style="color:red;">异常:</span>';
  83 +
  84 + function successHandle(json, handle) {
  85 + var status = json.status;
  86 + if (status == 407) {
  87 + location.href = '/login.html';
  88 + return;
  89 + }
  90 +
  91 + if (!status) {
  92 + handle && handle(json);
  93 + return;
  94 + }
  95 +
  96 + if (status == 'ERROR'){
  97 + UIkit.modal.alert(errorHead + (json.msg ? json.msg : '未知异常'), {labels: {Ok: '确定'}});
  98 + //关闭wait窗口
  99 + hide_wait_modal();
  100 + }
  101 + else
  102 + handle && handle(json);
  103 + }
  104 +
  105 + function ajaxComplete(xhr, ts, succ) {
  106 + if (ts == 'success') {
  107 + successHandle(JSON.parse(xhr.responseText), succ);
  108 + } else if (ts == 'error') {
  109 + UIkit.modal.alert(errorHead + xhr.responseText, {labels: {Ok: '确定'}});
  110 + //关闭wait窗口
  111 + hide_wait_modal();
  112 + }
  113 + }
  114 +
  115 + var get_vals = function (json) {
  116 + var array = [];
  117 + for (var key in json) {
  118 + array.push(json[key]);
  119 + }
  120 +
  121 + return array;
  122 + };
  123 +
  124 + var get_keys = function (json) {
  125 + var array = [];
  126 + for (var key in json) {
  127 + array.push(key);
  128 + }
  129 + return array;
  130 + };
  131 +
  132 + var accAdd = function (a, b) {
  133 + var c, d, e;
  134 + try {
  135 + c = a.toString().split(".")[1].length;
  136 + } catch (f) {
  137 + c = 0;
  138 + }
  139 + try {
  140 + d = b.toString().split(".")[1].length;
  141 + } catch (f) {
  142 + d = 0;
  143 + }
  144 + return e = Math.pow(10, Math.max(c, d)), (mul(a, e) + mul(b, e)) / e;
  145 + };
  146 +
  147 + function accDiv(arg1,arg2){
  148 + var t1=0,t2=0,r1,r2;
  149 + try{t1=arg1.toString().split(".")[1].length}catch(e){}
  150 + try{t2=arg2.toString().split(".")[1].length}catch(e){}
  151 + with(Math){
  152 + r1=Number(arg1.toString().replace(".",""))
  153 + r2=Number(arg2.toString().replace(".",""))
  154 + return (r1/r2)*pow(10,t2-t1);
  155 + }
  156 + }
  157 +
  158 + function mul(a, b) {
  159 + var c = 0,
  160 + d = a.toString(),
  161 + e = b.toString();
  162 + try {
  163 + c += d.split(".")[1].length;
  164 + } catch (f) {
  165 + }
  166 + try {
  167 + c += e.split(".")[1].length;
  168 + } catch (f) {
  169 + }
  170 + return Number(d.replace(".", "")) * Number(e.replace(".", "")) / Math.pow(10, c);
  171 + }
  172 +
  173 + var numSubtr = function (a, b) {
  174 + var c, d, e;
  175 + try {
  176 + c = a.toString().split(".")[1].length;
  177 + } catch (f) {
  178 + c = 0;
  179 + }
  180 + try {
  181 + d = b.toString().split(".")[1].length;
  182 + } catch (f) {
  183 + d = 0;
  184 + }
  185 + return e = Math.pow(10, Math.max(c, d)), (a * e - b * e) / e;
  186 + };
  187 +
  188 + var trim = function (str, is_global) {
  189 + var result;
  190 + result = str.replace(/(^\s+)|(\s+$)/g, "");
  191 + if (is_global.toLowerCase() == "g") {
  192 + result = result.replace(/\s/g, "");
  193 + }
  194 + return result;
  195 + };
  196 +
  197 + var inverse = function (map) {
  198 + var rs = {};
  199 + for(var k in map){
  200 + rs[map[k]] = k;
  201 + }
  202 +
  203 + return rs;
  204 + };
  205 +
  206 + var next_elem = function (clazz, e) {
  207 + var ne = e.next();
  208 + if(ne.length==0)
  209 + return [];
  210 + else if(ne.hasClass(clazz))
  211 + return ne;
  212 + else
  213 + return next_elem(clazz, ne);
  214 + };
  215 +
  216 + var getDisabledVal = function (f) {
  217 + var rs = {};
  218 + $('input,select', f).each(function () {
  219 + if($(this).attr('disabled')){
  220 + rs[$(this).attr('name')]=$(this).val();
  221 + }
  222 + });
  223 + return rs;
  224 + };
  225 +
  226 + return {
  227 + groupBy: groupBy,
  228 + compileTempByDom: compileTempByDom,
  229 + $get: $get,
  230 + $post: $post,
  231 + $post_arr: $post_arr,
  232 + $del: $del,
  233 + get_vals: get_vals,
  234 + get_keys: get_keys,
  235 + accAdd: accAdd,
  236 + numSubtr: numSubtr,
  237 + trim: trim,
  238 + flatpickrDateTimeConfig: flatpickrDateTimeConfig,
  239 + inverse: inverse,
  240 + accDiv: accDiv,
  241 + mul: mul,
  242 + next_elem: next_elem,
  243 + getDisabledVal: getDisabledVal,
  244 + };
  245 +})();
src/main/resources/static/pages/base/geo_data_edit/js/map.js
@@ -69,24 +69,25 @@ var gb_ct_map = function () { @@ -69,24 +69,25 @@ var gb_ct_map = function () {
69 return updown == 0 ? 'blue' : 'red'; 69 return updown == 0 ? 'blue' : 'red';
70 }; 70 };
71 var _renderRoads = function (data) { 71 var _renderRoads = function (data) {
72 - if(data[0].length==0)  
73 - return;  
74 - _renderPolyline(data[0], updownColor(0));//上行路段  
75 - _renderPolyline(data[1], updownColor(1));//下行路段 72 + if(data[0])
  73 + _renderPolyline(data[0], updownColor(0));//上行路段
  74 + if(data[1])
  75 + _renderPolyline(data[1], updownColor(1));//下行路段
76 }; 76 };
77 77
78 var _renderStation = function (data) { 78 var _renderStation = function (data) {
79 - if(data[0].length==0)  
80 - return;  
81 - _renderStationMarket(data[0]);//上行站点  
82 - _renderStationMarket(data[1]);//下行站点 79 + if(data[0])
  80 + _renderStationMarket(data[0]);//上行站点
  81 + if(data[1])
  82 + _renderStationMarket(data[1]);//下行站点
83 }; 83 };
84 84
85 var _renderStationMarket = function (routes, color) { 85 var _renderStationMarket = function (routes, color) {
  86 + if(routes.length==0)
  87 + return;
86 var marker; 88 var marker;
87 var array = []; 89 var array = [];
88 $.each(routes, function (i) { 90 $.each(routes, function (i) {
89 - this.index = i;  
90 transCoord(this); 91 transCoord(this);
91 marker = createStationMark(this); 92 marker = createStationMark(this);
92 marker.stationCode = this.stationCode; 93 marker.stationCode = this.stationCode;
@@ -107,6 +108,8 @@ var gb_ct_map = function () { @@ -107,6 +108,8 @@ var gb_ct_map = function () {
107 } 108 }
108 109
109 var _renderPolyline = function (routes, color) { 110 var _renderPolyline = function (routes, color) {
  111 + if(routes.length==0)
  112 + return;
110 var pos, temps; 113 var pos, temps;
111 var polyline, _pLines = []; 114 var polyline, _pLines = [];
112 var style = {strokeWeight: 7, strokeColor: color, strokeOpacity: .7}; 115 var style = {strokeWeight: 7, strokeColor: color, strokeOpacity: .7};
@@ -239,8 +242,8 @@ var gb_ct_map = function () { @@ -239,8 +242,8 @@ var gb_ct_map = function () {
239 ctx.fillStyle = '#fff'; 242 ctx.fillStyle = '#fff';
240 243
241 var i = station.index; 244 var i = station.index;
242 - if(!isNaN(i))  
243 - i ++; 245 + /* if(!isNaN(i))
  246 + i ++;*/
244 var left = (i + '').length > 1 ? 3 : 7; 247 var left = (i + '').length > 1 ? 3 : 7;
245 ctx.fillText(i, left, 14); 248 ctx.fillText(i, left, 14);
246 249
@@ -559,7 +562,7 @@ var gb_ct_map = function () { @@ -559,7 +562,7 @@ var gb_ct_map = function () {
559 562
560 var point; 563 var point;
561 var pId = gb_road_route.getAddPrevId(); 564 var pId = gb_road_route.getAddPrevId();
562 - if(pId){ 565 + if(pId && pId !=-1){
563 //从上一个路段继续绘制 566 //从上一个路段继续绘制
564 var prev = gb_road_route.getRoadById(pId), 567 var prev = gb_road_route.getRoadById(pId),
565 coords = prev.bdCoords, 568 coords = prev.bdCoords,
@@ -609,7 +612,7 @@ var gb_ct_map = function () { @@ -609,7 +612,7 @@ var gb_ct_map = function () {
609 var point; 612 var point;
610 if(!pos || pos.length==0){ 613 if(!pos || pos.length==0){
611 var pId = gb_station_route.getAddPrevId(); 614 var pId = gb_station_route.getAddPrevId();
612 - if(pId){ 615 + if(pId && pId!=-1){
613 //百度没有定位到位置,默认靠近在上一个站 616 //百度没有定位到位置,默认靠近在上一个站
614 var prev = gb_station_route.getStationById(pId); 617 var prev = gb_station_route.getStationById(pId);
615 point = new BMap.Point(prev.bd_lon - 0.0001, prev.bd_lat - 0.0001); 618 point = new BMap.Point(prev.bd_lon - 0.0001, prev.bd_lat - 0.0001);
@@ -702,6 +705,7 @@ var gb_ct_map = function () { @@ -702,6 +705,7 @@ var gb_ct_map = function () {
702 * @param upDown 705 * @param upDown
703 */ 706 */
704 var reDrawStation = function (upDown) { 707 var reDrawStation = function (upDown) {
  708 + map_status = 0;
705 $.each(stationMarkers[upDown], function () { 709 $.each(stationMarkers[upDown], function () {
706 map.removeOverlay(this); 710 map.removeOverlay(this);
707 }); 711 });
@@ -857,8 +861,8 @@ var gb_ct_map = function () { @@ -857,8 +861,8 @@ var gb_ct_map = function () {
857 clearfocus: clearfocus, 861 clearfocus: clearfocus,
858 clearAll: function () { 862 clearAll: function () {
859 map_status = 0; 863 map_status = 0;
860 - roadPolylines = [];  
861 - stationMarkers = []; 864 + roadPolylines = {0:[],1:[]};
  865 + stationMarkers = {0:[],1:[]};
862 editCircle = null; 866 editCircle = null;
863 editPolygon = null; 867 editPolygon = null;
864 dragMarker = null; 868 dragMarker = null;
src/main/resources/static/pages/base/geo_data_edit/js/road_route.js
@@ -11,14 +11,18 @@ var gb_road_route = function () { @@ -11,14 +11,18 @@ var gb_road_route = function () {
11 road_maps = data; 11 road_maps = data;
12 temps = temp; 12 temps = temp;
13 13
14 - //按顺序,名称分组  
15 - var ups = _group(road_maps[0]);  
16 - var downs = _group(road_maps[1]);  
17 //渲染 14 //渲染
18 - var upHtmlStr = temps['geo_d_e_road_route-temp']({list: ups});  
19 - $('.up_down_route_list>li:first>.road_route').html(upHtmlStr);  
20 - var downHtmlStr = temps['geo_d_e_road_route-temp']({list: downs});  
21 - $('.up_down_route_list>li:last>.road_route').html(downHtmlStr); 15 + if(road_maps[0]){
  16 + var ups = _group(road_maps[0]);
  17 + var upHtmlStr = temps['geo_d_e_road_route-temp']({list: ups, updown: 0});
  18 + $('.up_down_route_list>li:first>.road_route').html(upHtmlStr);
  19 + }
  20 +
  21 + if(road_maps[1]){
  22 + var downs = _group(road_maps[1]);
  23 + var downHtmlStr = temps['geo_d_e_road_route-temp']({list: downs, updown: 1});
  24 + $('.up_down_route_list>li:last>.road_route').html(downHtmlStr);
  25 + }
22 26
23 cb && cb(); 27 cb && cb();
24 }); 28 });
@@ -71,6 +75,9 @@ var gb_road_route = function () { @@ -71,6 +75,9 @@ var gb_road_route = function () {
71 tempArr.push(obj); 75 tempArr.push(obj);
72 name = obj.sectionName 76 name = obj.sectionName
73 } 77 }
  78 +
  79 + if(tempArr.length > 0)
  80 + rs.push(tempArr);
74 return rs; 81 return rs;
75 }; 82 };
76 83
@@ -130,7 +137,8 @@ var gb_road_route = function () { @@ -130,7 +137,8 @@ var gb_road_route = function () {
130 137
131 var addPrevId;//添加路段路由的上一个路由ID 138 var addPrevId;//添加路段路由的上一个路由ID
132 var insert_road_before = function (road) { 139 var insert_road_before = function (road) {
133 - isPrevEnd(road); 140 + if(!isPrevEnd(road))
  141 + return;
134 142
135 //在之前插入路段 143 //在之前插入路段
136 var cell = getRoadLI(road); 144 var cell = getRoadLI(road);
@@ -142,16 +150,30 @@ var gb_road_route = function () { @@ -142,16 +150,30 @@ var gb_road_route = function () {
142 add_road(addCell); 150 add_road(addCell);
143 }; 151 };
144 152
  153 + /**
  154 + *
  155 + * 路段添加按钮
  156 + */
  157 + $(document).on('click', '.add_road_icon', function () {
  158 + var cell = $(this);
  159 +
  160 + if(!isPrevEnd({directions: cell.data('updown')}))
  161 + return;
  162 +
  163 + var addCell = $(temps['geo_d_e_add_road_panel-temp']({sectionName: '', crosesRoad: ''}));
  164 + cell.after(addCell);
  165 + add_road(addCell);
  166 + });
  167 +
145 var insert_road_after = function (road) { 168 var insert_road_after = function (road) {
146 - isPrevEnd(road); 169 + if(!isPrevEnd(road))
  170 + return;
147 171
148 //在之后插入路段 172 //在之后插入路段
149 var cell = getRoadLI(road); 173 var cell = getRoadLI(road);
150 174
151 var addCell = $(temps['geo_d_e_add_road_panel-temp'](road)); 175 var addCell = $(temps['geo_d_e_add_road_panel-temp'](road));
152 176
153 - //var next = cell.next('.r_r_item');  
154 - //cell.after(addCell);  
155 var $bksList = $('.bks_list', cell); 177 var $bksList = $('.bks_list', cell);
156 if($bksList.length > 0) 178 if($bksList.length > 0)
157 $bksList.prepend(addCell); 179 $bksList.prepend(addCell);
@@ -161,8 +183,11 @@ var gb_road_route = function () { @@ -161,8 +183,11 @@ var gb_road_route = function () {
161 }; 183 };
162 184
163 var isPrevEnd = function (r) { 185 var isPrevEnd = function (r) {
164 - if($('.up_down_route_list>li:eq('+r.directions+')>.road_route .road_li_transient').length > 0)  
165 - return UIkit.notification("你需要完成上一个路段新增!", {status: 'danger'}); 186 + if($('.up_down_route_list>li:eq('+r.directions+')>.road_route .road_li_transient').length > 0) {
  187 + UIkit.notification("你需要完成上一个路段新增!", {status: 'danger'});
  188 + return false;
  189 + }
  190 + return true;
166 }; 191 };
167 192
168 var add_road = function (cell) { 193 var add_road = function (cell) {
@@ -285,7 +310,7 @@ var gb_road_route = function () { @@ -285,7 +310,7 @@ var gb_road_route = function () {
285 }; 310 };
286 311
287 var updateList = function (list) { 312 var updateList = function (list) {
288 - var updown = list[0].directions; 313 + var updown = getUpDown();
289 list.sort(function (a, b) { 314 list.sort(function (a, b) {
290 return parseInt(a.sectionrouteCode) - parseInt(b.sectionrouteCode); 315 return parseInt(a.sectionrouteCode) - parseInt(b.sectionrouteCode);
291 }); 316 });
@@ -337,6 +362,15 @@ var gb_road_route = function () { @@ -337,6 +362,15 @@ var gb_road_route = function () {
337 } 362 }
338 }); 363 });
339 364
  365 + //取消
  366 + $('button.cancel', spp).on('click', function () {
  367 + $('.main_left_panel_m_layer').hide();
  368 + $(this).parents('.buffer_edit_body').parent().remove();
  369 + gb_ct_map.resetMapStatus();
  370 + //debugger
  371 + //gb_ct_map.exitEditRoadStatus(road);
  372 + });
  373 +
340 gb_ct_map.showAddRoadPanel(name, cName); 374 gb_ct_map.showAddRoadPanel(name, cName);
341 }; 375 };
342 376
src/main/resources/static/pages/base/geo_data_edit/js/server_timer.js 0 → 100644
  1 +/**
  2 + * 服务器时间
  3 + * @type {{}}
  4 + */
  5 +var gb_second_timer = (function () {
  6 +
  7 + var now;
  8 + //var _this;
  9 + var secondTimer;
  10 + //var contextFlag;
  11 +
  12 + var setVersionEnableTimeFun;
  13 +
  14 + var init = function () {
  15 + //_this = $('.clock_enable_version .t_t_str')[0];
  16 + getServerTime(function (time) {
  17 + now = time;
  18 + /*$('div.north').bind("contextmenu", function () {
  19 + contextFlag = true;
  20 + });*/
  21 + //setTime();
  22 +
  23 + secondTimer = window.setInterval(function () {
  24 + if (0 == now.getSeconds()) {
  25 + minuteTimer();
  26 + //contextFlag = false;
  27 + }
  28 +
  29 + now = new Date(now.getTime() + 1e3);
  30 + //setTime();
  31 + setVersionEnableTimeFun && setVersionEnableTimeFun(now);
  32 + }, 1e3);
  33 + });
  34 + };
  35 +
  36 + var getServerTime = function (callback) {
  37 + function oncallback(jqXHR) {
  38 + var time = jqXHR && jqXHR.getResponseHeader("Date");
  39 + if (time)
  40 + callback(new Date(time))
  41 + }
  42 +
  43 + if ("function" == typeof callback)
  44 + $.ajax({
  45 + url: "/real_control_v2/assets/imgs/time.gif",
  46 + type: "HEAD"
  47 + }).done(function (data, textStatus, jqXHR) {
  48 + oncallback(jqXHR)
  49 + }).fail(function (jqXHR, textStatus, errorThrown) {
  50 + oncallback(jqXHR)
  51 + })
  52 + };
  53 +
  54 +/* var timeFormat = function (str) {
  55 + return ("0" + str).slice(-2)
  56 + };*/
  57 +
  58 + /* var setTime = function () {
  59 + _this.innerHTML = timeFormat(now.getHours()) + ':' + timeFormat(now.getMinutes()) + '.' + timeFormat(now.getSeconds());
  60 + };*/
  61 +
  62 + var minuteTimer = function () {
  63 + getServerTime(function (time) {
  64 + now = time;
  65 + //setTime()
  66 + })
  67 + };
  68 +
  69 + window.setTimeout(init, 1000);
  70 +
  71 + return {
  72 + now: function () {
  73 + return now;
  74 + },
  75 + initSetVersionEnableTimeFun: function (fun) {
  76 + setVersionEnableTimeFun = fun;
  77 + },
  78 + removeVersionEnableTimeFun: function () {
  79 + setVersionEnableTimeFun = null;
  80 + }
  81 + }
  82 +})();
0 \ No newline at end of file 83 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/js/station_route.js
@@ -12,8 +12,13 @@ var gb_station_route = function () { @@ -12,8 +12,13 @@ var gb_station_route = function () {
12 temps = temp; 12 temps = temp;
13 13
14 //渲染页面 14 //渲染页面
  15 + if(!station_maps[0])
  16 + station_maps[0] = [];
15 var upHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[0],updown:0}); 17 var upHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[0],updown:0});
16 $('.up_down_route_list>li:first>.station_route').html(upHtmlStr); 18 $('.up_down_route_list>li:first>.station_route').html(upHtmlStr);
  19 +
  20 + if(!station_maps[1])
  21 + station_maps[1] = [];
17 var downHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[1],updown:1}); 22 var downHtmlStr = temps['geo_d_e_station_route-temp']({list: station_maps[1],updown:1});
18 $('.up_down_route_list>li:last>.station_route').html(downHtmlStr); 23 $('.up_down_route_list>li:last>.station_route').html(downHtmlStr);
19 24
@@ -32,6 +37,10 @@ var gb_station_route = function () { @@ -32,6 +37,10 @@ var gb_station_route = function () {
32 //当前编辑的线路版本 37 //当前编辑的线路版本
33 storage.setItem("geo_data_edit_line_version" , rs['editVersion']); 38 storage.setItem("geo_data_edit_line_version" , rs['editVersion']);
34 39
  40 + //序号
  41 + for(var i=0,len=rs.list.length;i<len;i++){
  42 + rs.list[i].index = i + 1;
  43 + }
35 var data = {0:[],1:[]}; 44 var data = {0:[],1:[]};
36 if(rs.list.length > 0) 45 if(rs.list.length > 0)
37 data = gb_common.groupBy(rs.list, 'directions'); 46 data = gb_common.groupBy(rs.list, 'directions');
@@ -149,7 +158,6 @@ var gb_station_route = function () { @@ -149,7 +158,6 @@ var gb_station_route = function () {
149 if(is_duplication(name)) 158 if(is_duplication(name))
150 return UIkit.notification("站点路由名称重复!!", {status: 'danger'}); 159 return UIkit.notification("站点路由名称重复!!", {status: 'danger'});
151 160
152 - debugger  
153 //上一个站点的ID 161 //上一个站点的ID
154 var _cell = $(this).parents('.station_li_transient'); 162 var _cell = $(this).parents('.station_li_transient');
155 var $prev = prevs(_cell, 's_r_item') 163 var $prev = prevs(_cell, 's_r_item')
@@ -257,7 +265,7 @@ var gb_station_route = function () { @@ -257,7 +265,7 @@ var gb_station_route = function () {
257 */ 265 */
258 $(document).on('click', '.add_station_icon', function () { 266 $(document).on('click', '.add_station_icon', function () {
259 //在之后插入站点 267 //在之后插入站点
260 - var cell = $(this); 268 + var cell = $(this).parent();
261 269
262 var addCell = $(temps['geo_d_e_add_station_panel-temp']()); 270 var addCell = $(temps['geo_d_e_add_station_panel-temp']());
263 cell.after(addCell); 271 cell.after(addCell);
@@ -411,12 +419,12 @@ var gb_station_route = function () { @@ -411,12 +419,12 @@ var gb_station_route = function () {
411 return parseInt(a.stationRouteCode) - parseInt(b.stationRouteCode); 419 return parseInt(a.stationRouteCode) - parseInt(b.stationRouteCode);
412 }); 420 });
413 421
414 - var upDown = list[0].directions; 422 + var upDown = getUpDown();
415 var dataMaps = {}; 423 var dataMaps = {};
416 //更新数据 424 //更新数据
417 - for(var i=0,s;s=list[i++];){  
418 - s.index = i;  
419 - dataMaps[s.id] = s; 425 + for(var i=0,len=list.length;i<len;i++){
  426 + list[i].index = i + 1;
  427 + dataMaps[list[i].id] = list[i];
420 } 428 }
421 station_maps[upDown] = list; 429 station_maps[upDown] = list;
422 //更新序号 430 //更新序号
@@ -452,6 +460,7 @@ var gb_station_route = function () { @@ -452,6 +460,7 @@ var gb_station_route = function () {
452 460
453 $('.main_left_panel_m_layer').hide(); 461 $('.main_left_panel_m_layer').hide();
454 $('.add_station_search_point_wrap').remove(); 462 $('.add_station_search_point_wrap').remove();
  463 + $('.empty_add_icon.add_station_icon', wrap).remove();
455 }; 464 };
456 465
457 /** 466 /**
@@ -459,6 +468,13 @@ var gb_station_route = function () { @@ -459,6 +468,13 @@ var gb_station_route = function () {
459 * @param list 468 * @param list
460 */ 469 */
461 var destroyEnd = function (list, station) { 470 var destroyEnd = function (list, station) {
  471 + if(list.length==0){
  472 + var updown = getUpDown();
  473 + station_maps[updown] = [];
  474 + var upHtmlStr = temps['geo_d_e_station_route-temp']({list: [],updown:updown});
  475 + $('.up_down_route_list>li:'+(updown==0?'first':'last')+'>.station_route').empty().html(upHtmlStr);
  476 + return;
  477 + }
462 //被撤销的 478 //被撤销的
463 $('.up_down_route_list .s_r_item[data-id='+station.id+']').remove(); 479 $('.up_down_route_list .s_r_item[data-id='+station.id+']').remove();
464 updateStationRouteData(list); 480 updateStationRouteData(list);
src/main/resources/static/pages/base/geo_data_edit/js/version_manage.js
@@ -5,6 +5,7 @@ var gb_version_manage = function () { @@ -5,6 +5,7 @@ var gb_version_manage = function () {
5 var array; 5 var array;
6 var lineName; 6 var lineName;
7 var current; 7 var current;
  8 + var futureInfo;
8 9
9 var temps; 10 var temps;
10 var init = function (enableVersion) { 11 var init = function (enableVersion) {
@@ -18,16 +19,37 @@ var gb_version_manage = function () { @@ -18,16 +19,37 @@ var gb_version_manage = function () {
18 //线路名称 19 //线路名称
19 $('.main_left_panel>._line_info>._line_name>span').text(lineName); 20 $('.main_left_panel>._line_info>._line_name>span').text(lineName);
20 //当前版本 21 //当前版本
21 - $('.main_left_panel ._version_dropdown_wrap>._version_text').html(current.name + '<i uk-icon="icon: chevron-down;ratio:.6"></i>'); 22 + $('.main_left_panel ._version_dropdown_wrap>._version_text')
  23 + .html(current.name + '<i uk-icon="icon: chevron-down;ratio:.6"></i>').removeClass('e0 e1 e2').addClass('e' + current.status);
  24 +
22 25
23 //按status 分组 26 //按status 分组
24 var data = gb_common.groupBy(array, 'status'); 27 var data = gb_common.groupBy(array, 'status');
25 var htmlStr = temps['geo_d_e_version_dropdown-temp']({data: data, cvs: storage.getItem('geo_data_edit_line_version')}); 28 var htmlStr = temps['geo_d_e_version_dropdown-temp']({data: data, cvs: storage.getItem('geo_data_edit_line_version')});
26 $('._version_dropdown_wrap ul.all_version_list').html(htmlStr); 29 $('._version_dropdown_wrap ul.all_version_list').html(htmlStr);
  30 +
  31 +
  32 + /**
  33 + * 展现的不是启用的版本,现在启用icon
  34 + */
  35 + $('.main_rt_tools_panel .t2_enable_icon').remove();
  36 + $('.remove_line_version_icon').hide();
  37 + var v_enable = storage.getItem('geo_data_enable_version');
  38 + var v_edit = storage.getItem('geo_data_edit_line_version');
  39 + if(v_enable != v_edit){
  40 + $('.remove_line_version_icon').show();
  41 + $('.main_rt_tools_panel')
  42 + .prepend('<a data-version="'+v_edit+'" uk-icon="icon: future;ratio: .9" class="_icon t2_enable_icon uk-animation-slide-right-small" title="启用这个走向版本" uk-tooltip="pos:bottom"></a>');
  43 + }
  44 +
  45 + /**
  46 + * 待启用的版本信息
  47 + */
  48 + init_futureInfo(lineCode);
27 }); 49 });
28 50
29 //获取线路版本信息 51 //获取线路版本信息
30 - gb_common.$get('/_geo_data/findVersionInfo', {lineCode: lineCode}, function (rs) { 52 + gb_common.$get('/_geo_data/findVersionInfo?t='+ Math.random(), {lineCode: lineCode}, function (rs) {
31 array = rs.list; 53 array = rs.list;
32 lineName = array[0].lineName; 54 lineName = array[0].lineName;
33 55
@@ -49,6 +71,71 @@ var gb_version_manage = function () { @@ -49,6 +71,71 @@ var gb_version_manage = function () {
49 }); 71 });
50 }; 72 };
51 73
  74 + var init_futureInfo = function (lineCode) {
  75 + futureInfo = null;
  76 + $('.clock_enable_version').empty();
  77 + $('.main_left_panel').removeClass('s_future_version_info');
  78 + gb_common.$get('/_geo_data/findFutureVersion?t='+Math.random(), {lineCode: lineCode}, function (rs) {
  79 + if(rs.data.length > 0)
  80 + futureInfo = rs.data[0];
  81 +
  82 + if(!futureInfo)
  83 + return;
  84 +
  85 + futureInfo.start_date_str = moment(futureInfo['start_date']).format('YYYY-MM-DD HH:mm');
  86 +
  87 + var htmlStr = '<span class="t_t_str">?</span> 后启用('+futureInfo.name+')';
  88 + $('.clock_enable_version').append(htmlStr);
  89 + $('.main_left_panel').addClass('s_future_version_info');
  90 + if(current.versions==futureInfo.versions)
  91 + $('.clock_enable_version').addClass('orange');
  92 + else
  93 + $('.clock_enable_version').removeClass('orange');
  94 +
  95 +
  96 + var _that = $('.clock_enable_version span.t_t_str')[0];
  97 + var st = new Date(futureInfo['start_date']);
  98 + gb_second_timer.initSetVersionEnableTimeFun(function (now) {
  99 + if(st.getTime() - now.getTime() <= 0) {
  100 + $('.clock_enable_version').html('服务器即将切换版本,请稍后刷新页面!').data('status', '-1');
  101 + gb_second_timer.removeVersionEnableTimeFun();
  102 + }
  103 + else{
  104 + var s =getUseTime(st, now);
  105 + _that.innerText = s;
  106 + }
  107 + });
  108 + });
  109 + };
  110 +
  111 + /**
  112 + * 点击版本启用倒计时
  113 + */
  114 + var v_e_edit_modal='#enable_versions_edit_modal';
  115 + $(document).on('click', '.clock_enable_version', function () {
  116 + if($(this).data('status')==-1)
  117 + return;
  118 + var htmlStr = temps['g_d_e_v_enable_edit-temp'](futureInfo);
  119 + $(document.body).append(htmlStr);
  120 + UIkit.modal(v_e_edit_modal).show();
  121 +
  122 + var conf = {minDate: gb_second_timer.now()};
  123 + $.extend(conf, gb_common.flatpickrDateTimeConfig);
  124 + flatpickr(v_e_edit_modal + ' input._flatpickr', conf);
  125 + });
  126 + $(document).on('click', v_e_edit_modal + ' button._submit', function () {
  127 + var f = $('form', v_e_edit_modal);
  128 + var data = f.serializeJSON();
  129 + data.lineCode = storage.getItem('geo_data_edit_line_code');
  130 +
  131 + gb_common.$post('/_geo_data/addEnableInfo', data, function () {
  132 + UIkit.modal(v_e_edit_modal).hide();
  133 + UIkit.notification("修改成功!", {status: 'success'});
  134 + init();
  135 + });
  136 + });
  137 +
  138 +
52 var findOne = function (no) { 139 var findOne = function (no) {
53 for(var i=0,obj;obj=array[i++];){ 140 for(var i=0,obj;obj=array[i++];){
54 if(obj.versions == no) 141 if(obj.versions == no)
@@ -63,7 +150,6 @@ var gb_version_manage = function () { @@ -63,7 +150,6 @@ var gb_version_manage = function () {
63 */ 150 */
64 $('._version_dropdown_wrap ul.all_version_list').on('click', 'li[data-version]', function () { 151 $('._version_dropdown_wrap ul.all_version_list').on('click', 'li[data-version]', function () {
65 var version = $(this).data('version'); 152 var version = $(this).data('version');
66 - //var name = $(this).text();  
67 153
68 storage.setItem("geo_data_edit_line_version" , version); 154 storage.setItem("geo_data_edit_line_version" , version);
69 $loadPanel.show(); 155 $loadPanel.show();
@@ -79,7 +165,10 @@ var gb_version_manage = function () { @@ -79,7 +165,10 @@ var gb_version_manage = function () {
79 165
80 $(document.body).append(htmlStr); 166 $(document.body).append(htmlStr);
81 UIkit.modal('#add_line_versions_modal').show(); 167 UIkit.modal('#add_line_versions_modal').show();
82 - flatpickr('#add_line_versions_modal input._flatpickr', gb_common.flatpickrDateTimeConfig); 168 +
  169 + var conf = {minDate: gb_second_timer.now()};
  170 + $.extend(conf, gb_common.flatpickrDateTimeConfig);
  171 + flatpickr('#add_line_versions_modal input._flatpickr', conf);
83 172
84 173
85 var modal = '#add_line_versions_modal'; 174 var modal = '#add_line_versions_modal';
@@ -92,6 +181,8 @@ var gb_version_manage = function () { @@ -92,6 +181,8 @@ var gb_version_manage = function () {
92 //自动填充版本名称 181 //自动填充版本名称
93 $('[name=remark]', modal).on('change', reSetName); 182 $('[name=remark]', modal).on('change', reSetName);
94 $('[name=startDate]', modal).on('input', reSetName); 183 $('[name=startDate]', modal).on('input', reSetName);
  184 +
  185 + //console.log('时间aaa', gb_second_timer.now().getTime());
95 }); 186 });
96 187
97 /** 188 /**
@@ -117,12 +208,62 @@ var gb_version_manage = function () { @@ -117,12 +208,62 @@ var gb_version_manage = function () {
117 $('.flatpickr-calendar').remove(); 208 $('.flatpickr-calendar').remove();
118 }); 209 });
119 210
  211 + function getUseTime(nowDate, startDate) {
  212 + var hour = nowDate.getHours();
  213 + var min = nowDate.getMinutes();
  214 + var sec = "";
  215 + var showMin = "";
  216 + var showHour = "";
  217 +
  218 + if (nowDate.getSeconds() < startDate.getSeconds()) {
  219 + min = min - 1;
  220 + var sec_int = (nowDate.getSeconds() + 60) - startDate.getSeconds();
  221 + sec = sec_int >= 10 ? sec_int + "" : "0" + sec_int;
  222 + } else {
  223 + var sec_int = nowDate.getSeconds() - startDate.getSeconds();
  224 + sec = sec_int >= 10 ? sec_int + "" : "0" + sec_int;
  225 + }
  226 + if (min < startDate.getMinutes()) {
  227 + hour = hour - 1;
  228 + var min_int = (min + 60) - startDate.getMinutes();
  229 + showMin = min_int >= 10 ? min_int + "" : "0" + min_int;
  230 + } else {
  231 + var min_int = min - startDate.getMinutes();
  232 + showMin = min_int >= 10 ? min_int + "" : "0" + min_int;
  233 + }
  234 + if (hour < startDate.getHours()) {
  235 + var hour_int = (hour + 24) - startDate.getHours();
  236 + showHour = hour_int >= 10 ? hour_int + "" : "0" + hour_int;
  237 + } else {
  238 + var hour_int = hour - startDate.getHours();
  239 + showHour = hour_int >= 10 ? hour_int + "" : "0" + hour_int;
  240 + }
  241 + return showHour + "时" + showMin + "分" + sec;
  242 + }
120 243
121 /** 244 /**
122 - * 提交新增的线路版本 245 + * 启用走向版本
123 */ 246 */
124 - $(document).on('click', '#add_line_versions_modal button._submit', function () { 247 + $(document).on('click', '.main_rt_tools_panel .t2_enable_icon', function () {
  248 + var obj = findOne($(this).data('version'));
  249 + var htmlStr = temps['geo_d_e_version_enable-temp'](obj);
  250 + $(document.body).append(htmlStr);
  251 + UIkit.modal('#enable_line_versions_modal').show();
  252 +
  253 + var conf = {minDate: gb_second_timer.now()};
  254 + $.extend(conf, gb_common.flatpickrDateTimeConfig);
  255 + flatpickr('#enable_line_versions_modal input._flatpickr', conf);
  256 + });
  257 + $(document).on('click', '#enable_line_versions_modal button._submit', function () {
  258 + var f = $('form', '#enable_line_versions_modal');
  259 + var data = f.serializeJSON();
  260 + data.lineCode = storage.getItem('geo_data_edit_line_code');
125 261
  262 + gb_common.$post('/_geo_data/addEnableInfo', data, function () {
  263 + UIkit.modal('#enable_line_versions_modal').hide();
  264 + UIkit.notification("操作成功!", {status: 'success'});
  265 + init();
  266 + });
126 }); 267 });
127 268
128 res_load_ep.emitLater('load_version_manage'); 269 res_load_ep.emitLater('load_version_manage');
src/main/resources/static/pages/base/geo_data_edit/main.html
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 <div class="_line_name"> 27 <div class="_line_name">
28 <span></span> 28 <span></span>
29 29
30 - <a uk-icon="icon: trash" class="remove_line_version_icon" title="删除线路版本" uk-tooltip></a> 30 + <a uk-icon="icon: trash" class="remove_line_version_icon uk-animation-slide-right-small" title="删除线路版本" style="display: none" uk-tooltip></a>
31 <a uk-icon="icon: plus" class="add_line_version_icon" title="新增一个线路版本" uk-tooltip></a> 31 <a uk-icon="icon: plus" class="add_line_version_icon" title="新增一个线路版本" uk-tooltip></a>
32 </div> 32 </div>
33 <div class="_version_dropdown_wrap"> 33 <div class="_version_dropdown_wrap">
@@ -37,9 +37,7 @@ @@ -37,9 +37,7 @@
37 </ul> 37 </ul>
38 </div> 38 </div>
39 </div> 39 </div>
40 - <!--<span class="clock_enable_version">  
41 - <a uk-icon="icon: clock;ratio: .7" class=""></a> 25:30:20 启用(20180206线路改道)  
42 - </span>--> 40 + <a class="clock_enable_version"></a>
43 </div> 41 </div>
44 42
45 <div class="_route_info_wrap"> 43 <div class="_route_info_wrap">
@@ -73,7 +71,9 @@ @@ -73,7 +71,9 @@
73 <div class="ct_search_result"></div> 71 <div class="ct_search_result"></div>
74 </div> 72 </div>
75 <div class="main_rt_tools_panel"> 73 <div class="main_rt_tools_panel">
76 - <a uk-icon="icon: info;ratio: .9" class="_icon"></a> 74 + <!--<a style="color: red;" uk-icon="icon: unlock;ratio: .9" class="_icon" title="当前版本有变更未启用" uk-tooltip="pos:bottom"></a>-->
  75 +
  76 + <a uk-icon="icon: bookmark;ratio: .9" class="_icon" title="变更日志,日后再说" uk-tooltip="pos:bottom"></a>
77 <a uk-icon="icon: expand;ratio: .9" class="_icon full_screen_icon"></a> 77 <a uk-icon="icon: expand;ratio: .9" class="_icon full_screen_icon"></a>
78 </div> 78 </div>
79 </div> 79 </div>
@@ -106,7 +106,7 @@ @@ -106,7 +106,7 @@
106 <!-- jquery.serializejson JSON序列化插件 --> 106 <!-- jquery.serializejson JSON序列化插件 -->
107 <script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script> 107 <script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script>
108 <!-- common js --> 108 <!-- common js -->
109 -<script src="/real_control_v2/js/common.js"></script> 109 +<script src="/pages/base/geo_data_edit/js/ct_common.js"></script>
110 <script src="/assets/js/TransGPS.js" ></script> 110 <script src="/assets/js/TransGPS.js" ></script>
111 <!-- Geolib --> 111 <!-- Geolib -->
112 <script src="/real_control_v2/geolib/geolib.js" ></script> 112 <script src="/real_control_v2/geolib/geolib.js" ></script>
@@ -129,7 +129,17 @@ @@ -129,7 +129,17 @@
129 if (!top.$('body').hasClass('page-sidebar-closed')) {top.$('.menu-toggler.sidebar-toggler').click();} 129 if (!top.$('body').hasClass('page-sidebar-closed')) {top.$('.menu-toggler.sidebar-toggler').click();}
130 //全屏 130 //全屏
131 $('.full_screen_icon').on('click', function () { 131 $('.full_screen_icon').on('click', function () {
132 - window.parent.$('#geo_edit_wrap_iframe').addClass('full_screen'); 132 + var $iframe = window.parent.$('#geo_edit_wrap_iframe'),
  133 + icon;
  134 + if($(this).attr('uk-icon').indexOf('expand') != -1){
  135 + $iframe.addClass('full_screen');
  136 + icon = 'shrink';
  137 + }
  138 + else{
  139 + $iframe.removeClass('full_screen');
  140 + icon = 'expand';
  141 + }
  142 + $(this).attr('uk-icon', 'icon: '+icon+';ratio: .9');
133 }); 143 });
134 144
135 var gb_main_ep; 145 var gb_main_ep;
@@ -200,6 +210,8 @@ @@ -200,6 +210,8 @@
200 }); 210 });
201 </script> 211 </script>
202 212
  213 +
  214 +<script src="/pages/base/geo_data_edit/js/server_timer.js" ></script>
203 <!--- js --> 215 <!--- js -->
204 <script src="/pages/base/geo_data_edit/js/common_data.js" ></script> 216 <script src="/pages/base/geo_data_edit/js/common_data.js" ></script>
205 <script src="/pages/base/geo_data_edit/js/station_route.js" ></script> 217 <script src="/pages/base/geo_data_edit/js/station_route.js" ></script>
src/main/resources/static/pages/base/line/list.html
@@ -347,7 +347,7 @@ @@ -347,7 +347,7 @@
347 <a href="/pages/base/lineinformation/list.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 查看 </a> 347 <a href="/pages/base/lineinformation/list.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 查看 </a>
348 </td> 348 </td>
349 <td> 349 <td>
350 - <a href="javascript:window.localStorage.setItem('geo_data_edit_line_code' , '{{obj.lineCode}}');window.location.href='/pages/base/geo_data_edit/uk3_wrap.html';" class="btn default blue-stripe btn-sm" data-pjax> 查看 </a> 350 + <a href="javascript:window.localStorage.setItem('geo_data_edit_line_code' , '{{obj.lineCode}}');window.localStorage.removeItem('geo_data_edit_line_version');window.location.href='/pages/base/geo_data_edit/uk3_wrap.html';" class="btn default blue-stripe btn-sm" data-pjax> 查看 </a>
351 </td> 351 </td>
352 <td> 352 <td>
353 <a href="details.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 详细 </a> 353 <a href="details.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 详细 </a>