Commit f96b474a2b3ea67386dfe0277502203eb33f7966

Authored by YRF
1 parent c4e0f3d2

Signed-off-by: YRF <YRF@DESKTOP-UNV37O6>

src/main/java/com/bsth/controller/LineVersionsController.java
@@ -77,28 +77,7 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer @@ -77,28 +77,7 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer
77 77
78 @RequestMapping(value = "add", method = RequestMethod.POST) 78 @RequestMapping(value = "add", method = RequestMethod.POST)
79 public Map<String, Object> add(@RequestParam Map<String, Object> map) { 79 public Map<String, Object> add(@RequestParam Map<String, Object> map) {
80 - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
81 -  
82 - LineVersions lineVersions = new LineVersions();  
83 - try {  
84 - Date startDate = simpleDateFormat.parse(map.get("startDate").toString());  
85 - Date endDate = simpleDateFormat.parse(map.get("endDate").toString());  
86 - Line line = lineRepository.findOne(Integer.valueOf(map.get("lineId").toString()));  
87 - lineVersions.setName(map.get("name").toString());  
88 - lineVersions.setLine(line);  
89 - lineVersions.setLineCode(map.get("lineCode").toString());  
90 - lineVersions.setStartDate(new java.sql.Date(startDate.getTime()));  
91 - lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));  
92 - lineVersions.setVersions(Integer.valueOf(map.get("versions").toString()));  
93 - lineVersions.setStatus(Integer.valueOf(map.get("status").toString()));  
94 - lineVersions.setRemark(map.get("remark").toString());  
95 -  
96 -  
97 - } catch (ParseException e) {  
98 - // TODO Auto-generated catch block  
99 - e.printStackTrace();  
100 - }  
101 - return service.save(lineVersions); 80 + return service.add(map);
102 } 81 }
103 82
104 } 83 }
src/main/java/com/bsth/data/LineVersionsData.java
@@ -45,9 +45,10 @@ public class LineVersionsData implements CommandLineRunner { @@ -45,9 +45,10 @@ public class LineVersionsData implements CommandLineRunner {
45 map.put("lineId", lineId); 45 map.put("lineId", lineId);
46 stationRouteService.usingSingle(map); 46 stationRouteService.usingSingle(map);
47 } 47 }
  48 + logger.info("待更新线路更新成功!");
48 } catch (Exception e) { 49 } catch (Exception e) {
49 - // TODO Auto-generated catch block  
50 e.printStackTrace(); 50 e.printStackTrace();
  51 + logger.error("待更新线路更新出现异常!", e);
51 } 52 }
52 } 53 }
53 } 54 }
src/main/java/com/bsth/repository/LineVersionsRepository.java
@@ -31,7 +31,7 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int @@ -31,7 +31,7 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int
31 * 获取线路所有版本 31 * 获取线路所有版本
32 */ 32 */
33 @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1") 33 @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1")
34 - public List<LineVersions> findBylineCode(int lineId); 34 + public List<LineVersions> findBylineId(int lineId);
35 35
36 @Transactional 36 @Transactional
37 @Modifying 37 @Modifying
@@ -66,5 +66,11 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int @@ -66,5 +66,11 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int
66 */ 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) ") 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); 68 public LineVersions findLineVersionsMax(int lineId);
  69 +
  70 + /**
  71 + * 获取线路版本的上一个版本
  72 + */
  73 + @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1 and lv.versions = (?2 - "+1+")")
  74 + public LineVersions findBylineIdAndVersions(Integer id, Integer versions);
69 75
70 } 76 }
src/main/java/com/bsth/service/LineVersionsService.java
@@ -34,4 +34,6 @@ public interface LineVersionsService extends BaseService&lt;LineVersions, Integer&gt; @@ -34,4 +34,6 @@ public interface LineVersionsService extends BaseService&lt;LineVersions, Integer&gt;
34 34
35 LineVersions findLineVersionsMax(int lineId); 35 LineVersions findLineVersionsMax(int lineId);
36 36
  37 + Map<String, Object> add(Map<String, Object> map);
  38 +
37 } 39 }
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
@@ -75,7 +75,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -75,7 +75,7 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
75 75
76 @Override 76 @Override
77 public List<LineVersions> findByLineCode(int lineId) { 77 public List<LineVersions> findByLineCode(int lineId) {
78 - return repository.findBylineCode(lineId); 78 + return repository.findBylineId(lineId);
79 } 79 }
80 80
81 @Override 81 @Override
@@ -105,7 +105,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -105,7 +105,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
105 // TODO Auto-generated catch block 105 // TODO Auto-generated catch block
106 e.printStackTrace(); 106 e.printStackTrace();
107 resultMap.put("status", ResponseCode.ERROR); 107 resultMap.put("status", ResponseCode.ERROR);
108 - return resultMap;  
109 } 108 }
110 return resultMap; 109 return resultMap;
111 } 110 }
@@ -200,18 +199,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -200,18 +199,6 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
200 return sectionRoutes.size(); 199 return sectionRoutes.size();
201 } 200 }
202 } ); 201 } );
203 - /*for (SectionRoute sectionRoute : sectionRoutes) {  
204 - sectionRouteService.save(sectionRoute);  
205 - }*/  
206 -// sectionRouteService.bulkSave(sectionRoutes);  
207 - //List<StationRoute> stationRoutes = JSONArray.parseArray(JSON.toJSONString(lsStationRoutes), StationRoute.class);  
208 -// stationRouteService.batchUpdate(lineId, lineCode);  
209 -  
210 - //stationRouteRepository.batchDelete(lineId, lineCode);  
211 - /*for (StationRoute stationRoute : stationRoutes) {  
212 - stationRouteService.save(stationRoute);  
213 - }*/  
214 -// stationRouteService.bulkSave(stationRoutes);  
215 // 更新线路版本 202 // 更新线路版本
216 repository.updateOdlVersions(lineId, lineCode); 203 repository.updateOdlVersions(lineId, lineCode);
217 repository.updateNewVersions(lineId,lineCode,versions); 204 repository.updateNewVersions(lineId,lineCode,versions);
@@ -220,9 +207,48 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -220,9 +207,48 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
220 return list; 207 return list;
221 } 208 }
222 209
  210 + /**
  211 + * 查询线路版本最大值
  212 + */
223 @Override 213 @Override
224 public LineVersions findLineVersionsMax(int lineId) { 214 public LineVersions findLineVersionsMax(int lineId) {
225 return repository.findLineVersionsMax(lineId); 215 return repository.findLineVersionsMax(lineId);
226 } 216 }
  217 +
  218 + /**
  219 + * 线路版本添加
  220 + */
  221 + @Override
  222 + public Map<String, Object> add(Map<String, Object> map) {
  223 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  224 + Map<String, Object> resultMap = new HashMap<>();
  225 +
  226 + LineVersions lineVersions = new LineVersions();
  227 + try {
  228 + Date startDate = simpleDateFormat.parse(map.get("startDate").toString());
  229 + Date endDate = simpleDateFormat.parse(map.get("endDate").toString());
  230 + Line line = lineRepository.findOne(Integer.valueOf(map.get("lineId").toString()));
  231 + Integer versions = Integer.valueOf(map.get("versions").toString());
  232 + lineVersions.setName(map.get("name").toString());
  233 + lineVersions.setLine(line);
  234 + lineVersions.setLineCode(map.get("lineCode").toString());
  235 + lineVersions.setStartDate(new java.sql.Date(startDate.getTime()));
  236 + lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));
  237 + lineVersions.setVersions(versions);
  238 + lineVersions.setStatus(Integer.valueOf(map.get("status").toString()));
  239 + lineVersions.setRemark(map.get("remark").toString());
  240 + repository.save(lineVersions);
  241 + // 更新上一版本时间
  242 + LineVersions upLineVersions = repository.findBylineIdAndVersions(line.getId(),versions);
  243 + upLineVersions.setEndDate(new java.sql.Date(startDate.getTime()));
  244 + repository.save(upLineVersions);
  245 + resultMap.put("status", ResponseCode.SUCCESS);
  246 + } catch (ParseException e) {
  247 + // TODO Auto-generated catch block
  248 + e.printStackTrace();
  249 + resultMap.put("status", ResponseCode.ERROR);
  250 + }
  251 + return resultMap;
  252 + }
227 253
228 } 254 }
src/main/resources/static/pages/base/line/js/map.js
@@ -14,7 +14,7 @@ var WorldsBMapLine = function () { @@ -14,7 +14,7 @@ var WorldsBMapLine = function () {
14 14
15 /** WorldsBMapLine 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数; 15 /** WorldsBMapLine 全局变量定义 mapBValue:地图对象;polyUpline:走向折线;sectionList:截取过的路段 ;pointIndex:计算路段被切的次数;
16 * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/ 16 * firstPoint:截取路段的第一个点;iseditStatus:路段是否在编辑状态;isCutSection : 获取路段是否在截取状态*/
17 - var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = {}, isCutSection = false; 17 + var mapBValue = '', polyUpline='', sectionList = [], pointIndex = 0, iseditStatus = false, firstPoint = null, isCutSection = false;
18 18
19 var Bmap = { 19 var Bmap = {
20 20
@@ -50,6 +50,10 @@ var WorldsBMapLine = function () { @@ -50,6 +50,10 @@ var WorldsBMapLine = function () {
50 getFirstPoint : function() { 50 getFirstPoint : function() {
51 return firstPoint; 51 return firstPoint;
52 }, 52 },
  53 + /** 第一个切路段的点 */
  54 + setFirstPoint : function(Point) {
  55 + firstPoint = Point;
  56 + },
53 /** 获取地图对象 @return 地图对象map */ 57 /** 获取地图对象 @return 地图对象map */
54 getmapBValue : function() { 58 getmapBValue : function() {
55 59
@@ -329,17 +333,21 @@ var WorldsBMapLine = function () { @@ -329,17 +333,21 @@ var WorldsBMapLine = function () {
329 }, 333 },
330 // 批量画点 334 // 批量画点
331 batchPaintingPoint : function() { 335 batchPaintingPoint : function() {
  336 + // 画第一个点
  337 + var Point = WorldsBMapLine.getFirstPoint();
  338 + if(Point){
  339 + var marker = new BMap.Marker(new BMap.Point(Point.lng, Point.lat)); // 创建点
  340 + var label = new BMap.Label(1,{offset:new BMap.Size(4,0)});
  341 + label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});
  342 + marker.setLabel(label);
  343 + marker.isFlag = true;
  344 + mapBValue.addOverlay(marker);// 添加覆盖物
  345 +
  346 + WorldsBMapLine.getFirstPoint();
  347 + }
332 $.each(sectionList, function(index, value) { 348 $.each(sectionList, function(index, value) {
333 var section = value.section; 349 var section = value.section;
334 - debugger  
335 - if(index == 0){  
336 - var marker = new BMap.Marker(new BMap.Point(section[0].lng, section[0].lat)); // 创建点  
337 - var label = new BMap.Label(index+1,{offset:new BMap.Size(index>8?0:4,0)});  
338 - label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});  
339 - marker.setLabel(label);  
340 - marker.isFlag = true;  
341 - mapBValue.addOverlay(marker);// 添加覆盖物  
342 - } 350 +
343 var marker = new BMap.Marker(new BMap.Point(section[1].lng, section[1].lat)); // 创建点 351 var marker = new BMap.Marker(new BMap.Point(section[1].lng, section[1].lat)); // 创建点
344 var label = new BMap.Label(index+2,{offset:new BMap.Size(index>7?0:4,0)}); 352 var label = new BMap.Label(index+2,{offset:new BMap.Size(index>7?0:4,0)});
345 label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"}); 353 label.setStyle({border :"0", color : "white",backgroundColor:"rgba(0,0,0,0)"});
@@ -704,7 +712,6 @@ var WorldsBMapLine = function () { @@ -704,7 +712,6 @@ var WorldsBMapLine = function () {
704 mapBValue.panBy(10,-200,PanOptions_); 712 mapBValue.panBy(10,-200,PanOptions_);
705 713
706 // 关闭按钮事件 714 // 关闭按钮事件
707 - debugger  
708 PublicFunctions.addAChangeCssAddDisabled(); 715 PublicFunctions.addAChangeCssAddDisabled();
709 716
710 // 编辑圆监听事件 717 // 编辑圆监听事件
src/main/resources/static/pages/base/line/map.html
@@ -130,14 +130,15 @@ $(function(){ @@ -130,14 +130,15 @@ $(function(){
130 $(pjaxContainer).append(m); 130 $(pjaxContainer).append(m);
131 $('#edit_route_mobal').trigger('editRouteMobal.show',[TransGPS,EditRoute,WorldsBMapLine,DrawingManagerObj,GetAjaxData,PublicFunctions]); 131 $('#edit_route_mobal').trigger('editRouteMobal.show',[TransGPS,EditRoute,WorldsBMapLine,DrawingManagerObj,GetAjaxData,PublicFunctions]);
132 }); 132 });
133 - // 更新section_table 和缓存中的一切过的点数 133 + // 更新section_table 和缓存中的切点
134 WorldsBMapLine.initCutSectionPoint(); 134 WorldsBMapLine.initCutSectionPoint();
135 WorldsBMapLine.setPointIndex(0); 135 WorldsBMapLine.setPointIndex(0);
  136 + WorldsBMapLine.setFirstPoint(null);// 删除点后清空数据(第一个点坐标)
136 }); 137 });
137 138
138 // 提交截取事件 139 // 提交截取事件
139 - $('#cutSection').on('click', function() {  
140 - if(WorldsBMapLine.getPointIndex() > 0) { 140 + $('#cutSection').on('click', function() {
  141 + if(WorldsBMapLine.getSectionList().length != 0) {
141 var sectionList = WorldsBMapLine.getSectionList(); 142 var sectionList = WorldsBMapLine.getSectionList();
142 var data = {}; 143 var data = {};
143 var section = EditSectionObj.getEitdSection(); 144 var section = EditSectionObj.getEitdSection();
@@ -169,12 +170,12 @@ $(function(){ @@ -169,12 +170,12 @@ $(function(){
169 WorldsBMapLine.deleteCutSectionPoint(point); 170 WorldsBMapLine.deleteCutSectionPoint(point);
170 WorldsBMapLine.refreshCutSectionTable(); 171 WorldsBMapLine.refreshCutSectionTable();
171 } else if(WorldsBMapLine.getPointIndex() == 1 ) { 172 } else if(WorldsBMapLine.getPointIndex() == 1 ) {
172 - // 点总数-1  
173 var pointIndex = WorldsBMapLine.getPointIndex() - 1; 173 var pointIndex = WorldsBMapLine.getPointIndex() - 1;
174 WorldsBMapLine.setPointIndex(pointIndex); 174 WorldsBMapLine.setPointIndex(pointIndex);
175 var firstPoint = WorldsBMapLine.getFirstPoint(); 175 var firstPoint = WorldsBMapLine.getFirstPoint();
176 WorldsBMapLine.deleteCutSectionPoint(firstPoint); 176 WorldsBMapLine.deleteCutSectionPoint(firstPoint);
177 WorldsBMapLine.setIsCutSection(false); 177 WorldsBMapLine.setIsCutSection(false);
  178 + WorldsBMapLine.setFirstPoint(null);// 删除点后清空数据
178 } else { 179 } else {
179 layer.msg("没有截取路段,不可以撤销!!!"); 180 layer.msg("没有截取路段,不可以撤销!!!");
180 } 181 }
src/main/resources/static/pages/base/section/js/add-input-function.js
@@ -79,16 +79,12 @@ var PublicFunctions = function () { @@ -79,16 +79,12 @@ var PublicFunctions = function () {
79 // 获取某线路下的路段路由. 79 // 获取某线路下的路段路由.
80 getSectionRouteInfo : function(line,callback) { 80 getSectionRouteInfo : function(line,callback) {
81 $get('/sectionroute/all',{'line.id_eq':line,'destroy_eq':0},function(result) { 81 $get('/sectionroute/all',{'line.id_eq':line,'destroy_eq':0},function(result) {
82 - /*if(result.length>0)  
83 - result.sort(function(a,b){return a.sectionrouteCode-b.sectionrouteCode});*/  
84 callback && callback(result); 82 callback && callback(result);
85 }); 83 });
86 }, 84 },
87 // 新增路段保存. 85 // 新增路段保存.
88 sectionSave : function(section,callback) { 86 sectionSave : function(section,callback) {
89 - debugger  
90 $post('/section/sectionSave',section,function(data) { 87 $post('/section/sectionSave',section,function(data) {
91 - debugger  
92 callback && callback(data); 88 callback && callback(data);
93 }); 89 });
94 } 90 }