Commit 54bdf7ba4e2144bed84b48d0f310a7507e9a720a

Authored by YRF
1 parent b2ed1902

线路版本

src/main/java/com/bsth/controller/LineController.java
1 1 package com.bsth.controller;
2 2  
  3 +import java.text.ParseException;
  4 +import java.text.SimpleDateFormat;
  5 +import java.util.Date;
3 6 import java.util.HashMap;
4 7 import java.util.Map;
5 8  
... ... @@ -11,7 +14,9 @@ import org.springframework.web.bind.annotation.RestController;
11 14  
12 15 import com.bsth.common.ResponseCode;
13 16 import com.bsth.entity.Line;
  17 +import com.bsth.entity.LineVersions;
14 18 import com.bsth.service.LineService;
  19 +import com.bsth.service.LineVersionsService;
15 20 import com.bsth.util.GetUIDAndCode;
16 21  
17 22 /**
... ... @@ -36,6 +41,9 @@ public class LineController extends BaseController<Line, Integer> {
36 41 @Autowired
37 42 private LineService service;
38 43  
  44 + @Autowired
  45 + private LineVersionsService lineVersionsService;
  46 +
39 47 /**
40 48 * 获取线路编码与ID
41 49 *
... ... @@ -74,13 +82,31 @@ public class LineController extends BaseController<Line, Integer> {
74 82 map.put("status", ResponseCode.ERROR);
75 83 return map;
76 84 }
77   - return service.save(t);
  85 + // 添加线路版本
  86 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  87 + try {
  88 + Date endDate = simpleDateFormat.parse("2088-08-08 00:00:00");
  89 + LineVersions lineVersions = new LineVersions();
  90 + lineVersions.setName("原始版本");
  91 + lineVersions.setLine(t);
  92 + lineVersions.setLineCode(t.getLineCode());
  93 + lineVersions.setStartDate(t.getCreateDate());
  94 + lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));// 2088-8-8 00:00:00
  95 + lineVersions.setVersions(1);
  96 + lineVersions.setStatus(1);
  97 + // 先添加线路再添加版本
  98 + service.save(t);
  99 + return lineVersionsService.save(lineVersions);
  100 + } catch (ParseException e) {
  101 + // TODO Auto-generated catch block
  102 + e.printStackTrace();
  103 + map.put("status", ResponseCode.ERROR);
  104 + return map;
  105 + }
78 106 }
79 107  
80 108 /**
81   - *
82 109 * 更改
83   - *
84 110 */
85 111 @RequestMapping(value="/update", method = RequestMethod.POST)
86 112 public Map<String, Object> update(Line l){
... ...
src/main/java/com/bsth/controller/LineVersionsController.java
... ... @@ -12,16 +12,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
12 12 import org.springframework.web.bind.annotation.RequestParam;
13 13 import org.springframework.web.bind.annotation.RestController;
14 14  
15   -import com.alibaba.fastjson.JSON;
16   -import com.alibaba.fastjson.JSONObject;
17   -import com.alibaba.fastjson.TypeReference;
18   -import com.bsth.data.LineVersionsData;
19 15 import com.bsth.entity.Line;
20 16 import com.bsth.entity.LineVersions;
21   -import com.bsth.entity.LsStationRoute;
22   -import com.bsth.entity.StationRoute;
23 17 import com.bsth.repository.LineRepository;
24   -import com.bsth.repository.LsStationRouteRepository;
25 18 import com.bsth.service.LineVersionsService;
26 19  
27 20 /**
... ... @@ -46,8 +39,15 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer
46 39  
47 40 @Autowired
48 41 LineRepository lineRepository;
49   - @Autowired
50   - LsStationRouteRepository lsStationRouteRepository ;
  42 +
  43 + /**
  44 + * 获取线路所有版本
  45 + */
  46 + @RequestMapping(value = "findLineVersionsMax", method = RequestMethod.GET)
  47 + public LineVersions findLineVersionsMax(@RequestParam(defaultValue = "lineId") int lineId) {
  48 + return service.findLineVersionsMax(lineId);
  49 + }
  50 +
51 51 /**
52 52 * 获取线路所有版本
53 53 *
... ... @@ -63,7 +63,6 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer
63 63 */
64 64 @RequestMapping(value = "findById", method = RequestMethod.GET)
65 65 public LineVersions findOne(@RequestParam(defaultValue = "id") int id) {
66   - service.lineUpdate();
67 66 return service.findById(id);
68 67 }
69 68  
... ... @@ -85,6 +84,7 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer
85 84 Date startDate = simpleDateFormat.parse(map.get("startDate").toString());
86 85 Date endDate = simpleDateFormat.parse(map.get("endDate").toString());
87 86 Line line = lineRepository.findOne(Integer.valueOf(map.get("lineId").toString()));
  87 + lineVersions.setName(map.get("name").toString());
88 88 lineVersions.setLine(line);
89 89 lineVersions.setLineCode(map.get("lineCode").toString());
90 90 lineVersions.setStartDate(new java.sql.Date(startDate.getTime()));
... ... @@ -92,6 +92,8 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer
92 92 lineVersions.setVersions(Integer.valueOf(map.get("versions").toString()));
93 93 lineVersions.setStatus(Integer.valueOf(map.get("status").toString()));
94 94 lineVersions.setRemark(map.get("remark").toString());
  95 +
  96 +
95 97 } catch (ParseException e) {
96 98 // TODO Auto-generated catch block
97 99 e.printStackTrace();
... ...
src/main/java/com/bsth/entity/LineVersions.java
... ... @@ -32,6 +32,11 @@ public class LineVersions{
32 32 /** ID 主键(唯一标识符) int length(11) */
33 33 private Integer id;
34 34  
  35 + /** 线路版本名字 varchar length(50)
  36 + * 给排版人员选版本使用
  37 + * */
  38 + private String name;
  39 +
35 40 /** 线路ID int length(11) */
36 41 @ManyToOne
37 42 private Line line;
... ... @@ -71,6 +76,14 @@ public class LineVersions{
71 76 public void setId(Integer id) {
72 77 this.id = id;
73 78 }
  79 +
  80 + public String getName() {
  81 + return name;
  82 + }
  83 +
  84 + public void setName(String name) {
  85 + this.name = name;
  86 + }
74 87  
75 88 public Line getLine() {
76 89 return line;
... ...
src/main/java/com/bsth/repository/LineVersionsRepository.java
... ... @@ -59,5 +59,12 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int
59 59 @Modifying
60 60 @Query(value = "UPDATE LineVersions lv set lv.status=1 where lv.line.id=?1 and lv.lineCode=?2 and lv.versions=?3")
61 61 public void updateNewVersions(Integer lineId, String lineCode, Integer versions);
  62 +
  63 +
  64 + /**
  65 + * 查询线路最大线路版本
  66 + */
  67 + @Query(value = "select lv2 from LineVersions lv2 where lv2.line.id =?1 and lv2.versions=(SELECT max(lv.versions) FROM LineVersions lv where lv.line.id = ?1) ")
  68 + public LineVersions findLineVersionsMax(int lineId);
62 69  
63 70 }
... ...
src/main/java/com/bsth/service/LineVersionsService.java
... ... @@ -32,4 +32,6 @@ public interface LineVersionsService extends BaseService&lt;LineVersions, Integer&gt;
32 32  
33 33 List<LineVersions> lineUpdate();
34 34  
  35 + LineVersions findLineVersionsMax(int lineId);
  36 +
35 37 }
... ...
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
... ... @@ -9,7 +9,6 @@ import java.util.HashMap;
9 9 import java.util.List;
10 10 import java.util.Map;
11 11  
12   -import org.drools.core.time.impl.PseudoClockScheduler;
13 12 import org.springframework.beans.factory.annotation.Autowired;
14 13 import org.springframework.jdbc.core.BatchPreparedStatementSetter;
15 14 import org.springframework.jdbc.core.JdbcTemplate;
... ... @@ -141,9 +140,8 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
141 140 jdbcTemplate.update("delete from bsth_c_stationroute where line = ? and line_code = ?", lineId, lineCode);
142 141  
143 142 String stationSql ="insert into bsth_c_stationroute(id,line,station,station_name,station_route_code,"
144   - + "line_code,station_code,station_mark,out_station_nmber,directions,distances,"
145   - + "to_time,first_time,end_time,descriptions,destroy,versions,create_by,create_date,"
146   - + "update_by,update_date) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  143 + + "line_code,station_code,station_mark,directions,distances,to_time,destroy,versions,"
  144 + + "create_date,update_date) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
147 145 jdbcTemplate.batchUpdate(stationSql, new BatchPreparedStatementSetter() {
148 146  
149 147 @Override
... ... @@ -158,19 +156,13 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
158 156 ps.setString(6, sRoute.getLineCode());
159 157 ps.setString(7, sRoute.getStationCode());
160 158 ps.setString(8, sRoute.getStationMark());
161   - ps.setInt(9, sRoute.getOutStationNmber()==null ? 0:sRoute.getOutStationNmber());
162   - ps.setInt(10, sRoute.getDirections());
163   - ps.setDouble(11, sRoute.getDistances());
164   - ps.setDouble(12, sRoute.getToTime());
165   - ps.setString(13, sRoute.getFirstTime()==null ? "":sRoute.getFirstTime());
166   - ps.setString(14, sRoute.getEndTime()==null ? "":sRoute.getEndTime());
167   - ps.setString(15, sRoute.getDescriptions()==null ? "":sRoute.getDescriptions());
168   - ps.setInt(16, sRoute.getDestroy());
169   - ps.setInt(17, sRoute.getVersions());
170   - ps.setInt(18, sRoute.getCreateBy()==null ? 0:sRoute.getCreateBy());
171   - ps.setDate(19, new java.sql.Date(sRoute.getCreateDate().getTime()));
172   - ps.setInt(20, sRoute.getUpdateBy()==null ? 0:sRoute.getUpdateBy());
173   - ps.setDate(21, new java.sql.Date(sRoute.getUpdateDate().getTime()));
  159 + ps.setInt(9, sRoute.getDirections());
  160 + ps.setDouble(10, sRoute.getDistances());
  161 + ps.setDouble(11, sRoute.getToTime());
  162 + ps.setInt(12, sRoute.getDestroy());
  163 + ps.setInt(13, sRoute.getVersions());
  164 + ps.setDate(14, new java.sql.Date(sRoute.getCreateDate().getTime()));
  165 + ps.setDate(15, new java.sql.Date(sRoute.getUpdateDate().getTime()));
174 166 }
175 167  
176 168 @Override
... ... @@ -182,8 +174,8 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
182 174 jdbcTemplate.update("delete from bsth_c_sectionroute where line = ? and line_code = ?", lineId, lineCode);
183 175  
184 176 String sectionSql ="insert into bsth_c_sectionroute(id,line_code,section_code,sectionroute_code,"
185   - + "directions,line,section,descriptions,create_by,create_date,update_by,update_date,versions,"
186   - + "destroy,is_roade_speed) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  177 + + "directions,line,section,create_date,update_date,versions,"
  178 + + "destroy) values(?,?,?,?,?,?,?,?,?,?,?)";
187 179 jdbcTemplate.batchUpdate(sectionSql, new BatchPreparedStatementSetter() {
188 180  
189 181 @Override
... ... @@ -196,14 +188,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
196 188 ps.setInt(5, sRoute.getDirections());
197 189 ps.setInt(6, sRoute.getLine().getId());
198 190 ps.setInt(7, sRoute.getSection().getId());
199   - ps.setString(8, sRoute.getDescriptions()==null ? "":sRoute.getDescriptions());
200   - ps.setInt(9, sRoute.getCreateBy()==null ? 0:sRoute.getCreateBy());
201   - ps.setDate(10, new java.sql.Date(sRoute.getCreateDate().getTime()));
202   - ps.setInt(11, sRoute.getUpdateBy()==null ? 0:sRoute.getUpdateBy());
203   - ps.setDate(12, new java.sql.Date(sRoute.getUpdateDate().getTime()));
204   - ps.setInt(13, sRoute.getVersions());
205   - ps.setInt(14, sRoute.getDestroy());
206   - ps.setInt(15, sRoute.getIsRoadeSpeed()==null ? 0:sRoute.getIsRoadeSpeed());
  191 + ps.setDate(8, new java.sql.Date(sRoute.getCreateDate().getTime()));
  192 + ps.setDate(9, new java.sql.Date(sRoute.getUpdateDate().getTime()));
  193 + ps.setInt(10, sRoute.getVersions());
  194 + ps.setInt(11, sRoute.getDestroy());
207 195 }
208 196  
209 197 @Override
... ... @@ -231,5 +219,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
231 219 }
232 220 return list;
233 221 }
  222 +
  223 + @Override
  224 + public LineVersions findLineVersionsMax(int lineId) {
  225 + return repository.findLineVersionsMax(lineId);
  226 + }
234 227  
235 228 }
... ...
src/main/resources/static/pages/base/line/editRoute.html
... ... @@ -57,7 +57,7 @@
57 57 <p>
58 58 <span class="help-block" style="color: #1bbc9b;">
59 59 &nbsp;请在文本域中按顺序依次输坐标点,每行中的数据之间用【Tab】键隔开(如果是站点,请将在坐标后面加 stop;没有
60   - stop默认是路段点),每输入完一个坐标时请按回车键【Enter】换行. 例如:<!-- <br> 121.715623
  60 + stop默认是路段点,连续带stop的坐标认为是同一个站点),每输入完一个坐标时请按回车键【Enter】换行. 例如:<!-- <br> 121.715623
61 61 31.224058 042408.000<br> 121.715623 31.224065 042409.000
62 62 Stop<br> 121.715623 31.224065 042410.000<br> -->
63 63 <br>121.511870 31.180638 043703.000
... ...
src/main/resources/static/pages/base/line/map.html
... ... @@ -175,7 +175,7 @@ $(function(){
175 175 WorldsBMapLine.deleteCutSectionPoint(firstPoint);
176 176 WorldsBMapLine.setIsCutSection(false);
177 177 } else {
178   - layer.msg("没有截取路段,不可以删除!!!");
  178 + layer.msg("没有截取路段,不可以撤销!!!");
179 179 }
180 180 });
181 181 // 滚动轴监听事件
... ...
src/main/resources/static/pages/base/line/submit_select.html
... ... @@ -23,9 +23,9 @@
23 23 </form>
24 24 </div>
25 25 <div class="modal-footer">
26   - <button type="button" class="btn default" data-dismiss="modal">取消</button>
27 26 <button type="button" class="btn btn-primary"
28 27 id="submitSelectnextButton">提交</button>
  28 + <button type="button" class="btn default" data-dismiss="modal">取消</button>
29 29 </div>
30 30 </div>
31 31 </div>
... ... @@ -50,9 +50,9 @@
50 50 }
51 51 if(this.status==1){
52 52 //当前版本为默认
53   - options += '<option value="'+this.versions+','+this.status+','+startDate+'" > 版本'+this.versions+' 启用时间:'+startDate+' 当前版本</option>';
  53 + options += '<option value="'+this.versions+','+this.status+','+startDate+'" selected = "selected" > 版本'+this.versions+' 启用时间:'+startDate+' 当前版本</option>';
54 54 } else if(this.status==2){
55   - options += '<option value="'+this.versions+','+this.status+','+startDate+'" selected = "selected"> 版本'+this.versions+' 启用时间:'+startDate+' 待更新版本</option>';
  55 + options += '<option value="'+this.versions+','+this.status+','+startDate+'"> 版本'+this.versions+' 启用时间:'+startDate+' 待更新版本</option>';
56 56 }
57 57 });
58 58 $('#lineVersions').html(options);
... ...
src/main/resources/static/pages/base/lineversions/add.html
1 1 <!-- 片段标题 START -->
2 2 <div class="page-head">
3 3 <div class="page-title">
4   - <h1>修改添加信息</h1>
  4 + <h1>添加线路版本</h1>
5 5 </div>
6 6 </div>
7 7 <!-- 片段标题 END -->
8 8  
9   -<!-- 线路信息导航栏组件 START -->
  9 +<!-- 线路版本信息导航栏组件 START -->
10 10 <ul class="page-breadcrumb breadcrumb">
11 11 <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
12 12 <li><span class="active">基础信息</span> <i class="fa fa-circle"></i></li>
13   - <li><a href="/pages/base/line/list.html" data-pjax>线路信息</a> <i class="fa fa-circle"></i></li>
  13 + <li><a href="/pages/base/lineversions/list.html" data-pjax>线路版本信息</a> <i class="fa fa-circle"></i></li>
14 14 <li><span class="active">修改添加信息</span></li>
15 15 </ul>
16   -<!-- 线路信息导航栏组件 END -->
  16 +<!-- 线路版本信息导航栏组件 END -->
17 17  
18 18 <!-- 信息容器组件 START -->
19 19 <div class="portlet light bordered">
... ... @@ -22,7 +22,7 @@
22 22 <div class="portlet-title">
23 23 <div class="caption">
24 24 <i class="icon-equalizer font-red-sunglo"></i>
25   - <span class="caption-subject font-red-sunglo bold uppercase">添加线路信息</span>
  25 + <span class="caption-subject font-red-sunglo bold uppercase">添加线路版本信息</span>
26 26 </div>
27 27 </div>
28 28 <!-- 信息容器组件标题 END -->
... ... @@ -48,6 +48,17 @@
48 48 <!-- 表单分组组件 form-group START -->
49 49 <div class="form-group">
50 50 <label class="control-label col-md-5">
  51 + <span class="required"> * </span>线路版本名称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:
  52 + </label>
  53 + <div class="col-md-4">
  54 + <input name="name" class="form-control" style="width:100%" id="nameInput" placeholder="请填写更换版本原因,方便排班人员操作!" />
  55 + </div>
  56 + </div>
  57 + <!-- 表单分组组件 form-group END -->
  58 +
  59 + <!-- 表单分组组件 form-group START -->
  60 + <div class="form-group">
  61 + <label class="control-label col-md-5">
51 62 <span class="required"> * </span>线路名称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:
52 63 </label>
53 64 <div class="col-md-4">
... ... @@ -105,9 +116,9 @@
105 116  
106 117 <!-- 表单分组组件 form-group START -->
107 118 <div class="form-group">
108   - <label class="control-label col-md-5"> 描述/说明&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </label>
  119 + <label class="control-label col-md-5"> 描述/说明&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: </label>
109 120 <div class="col-md-4">
110   - <textarea class="form-control" rows="3" name="remark" id="remarkTextarea" placeholder="请填写更换版本原因,方便排班人员操作!"></textarea>
  121 + <textarea class="form-control" rows="3" name="remark" id="remarkTextarea" placeholder="描述/说明"></textarea>
111 122 </div>
112 123 </div>
113 124 <!-- 表单分组组件 form-group END -->
... ... @@ -130,5 +141,5 @@
130 141 </div>
131 142 <!-- 信息容器组件 END -->
132 143  
133   -<!-- 线路信息添加片段JS模块 -->
  144 +<!-- 线路版本信息添加片段JS模块 -->
134 145 <script src="/pages/base/lineversions/js/lineversions-add-from.js"></script>
135 146 \ No newline at end of file
... ...
src/main/resources/static/pages/base/lineversions/js/lineversions-add-from.js
... ... @@ -70,6 +70,9 @@
70 70 $('#lineIdInput').val('');// 设值线路ID.
71 71 }else {
72 72 var lineSelectValueArray = lineSelectValue.split('_');// 切割线路名称值.
  73 + $.get('/lineVersions/findLineVersionsMax',{'lineId':lineSelectValueArray[1]}, function(lineVersionsMax){
  74 + $('#versionsInput').val(++lineVersionsMax.versions);// 设值线路编码.
  75 + });
73 76 $('#lineIdInput').val(lineSelectValueArray[0]);// 设值线路编码.
74 77 $('#lineCodeInput').val(lineSelectValueArray[1]);// 设值线路ID.
75 78 }
... ... @@ -110,6 +113,7 @@
110 113 focusInvalid : true,
111 114 // 需要验证的表单元素
112 115 rules : {
  116 + 'name' : {required : true,maxlength: 30},// 线路名称 必填项、最大长度.
113 117 'line' : {required : true,maxlength: 30},// 线路名称 必填项、最大长度.
114 118 'startDate' : {required : true},// 启用时间 不为空.
115 119 'endDate' : {required : true},// 结束时间.
... ...
src/main/resources/static/pages/base/stationroute/edit_select.html
... ... @@ -124,6 +124,10 @@ $(&#39;#edit_select_mobal&#39;).on(&#39;editSelectMobal_show&#39;, function(e, map_,drw,ajaxd,ed
124 124 // 打开绘制工具
125 125 drw.openDrawingManager();
126 126 map_.localtionPoint(editStationName);
  127 + layer.open({
  128 + title: '友情提示'
  129 + ,content: '重绘站点,会修改站点编码,影响已做好的排班和线路文件。请谨慎使用,谢谢!'
  130 + });
127 131 }else if(params.editselect==1){
128 132 // 弹出添加失败提示消息,2秒关闭(如果不配置,默认是3秒)
129 133 var mindex = layer.msg('编辑完图形后,请双击图形区域保存',{ offset: '126px',
... ...