Commit 9955cf0fda3874ce54e35470bdb13a1d140c56d4
1 parent
a3082e3a
站点间预测样本页面
Showing
10 changed files
with
199 additions
and
87 deletions
src/main/java/com/bsth/controller/forecast/SampleController.java
| 1 | package com.bsth.controller.forecast; | 1 | package com.bsth.controller.forecast; |
| 2 | 2 | ||
| 3 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 3 | import org.springframework.web.bind.annotation.RequestMapping; | 4 | import org.springframework.web.bind.annotation.RequestMapping; |
| 4 | import org.springframework.web.bind.annotation.RestController; | 5 | import org.springframework.web.bind.annotation.RestController; |
| 5 | 6 | ||
| 6 | import com.bsth.controller.BaseController; | 7 | import com.bsth.controller.BaseController; |
| 7 | import com.bsth.entity.forecast.Sample; | 8 | import com.bsth.entity.forecast.Sample; |
| 9 | +import com.bsth.service.forecast.SampleService; | ||
| 8 | 10 | ||
| 9 | @RestController | 11 | @RestController |
| 10 | @RequestMapping("sample") | 12 | @RequestMapping("sample") |
| 11 | public class SampleController extends BaseController<Sample, Long>{ | 13 | public class SampleController extends BaseController<Sample, Long>{ |
| 12 | 14 | ||
| 15 | + @Autowired | ||
| 16 | + SampleService sampleService; | ||
| 17 | + | ||
| 18 | + @RequestMapping("/create/gps") | ||
| 19 | + public int createDataByGps(String lineCode, Integer updown){ | ||
| 20 | + return sampleService.createDataByGps(lineCode, updown); | ||
| 21 | + } | ||
| 13 | } | 22 | } |
src/main/java/com/bsth/data/BasicData.java
| @@ -75,7 +75,7 @@ public class BasicData implements CommandLineRunner{ | @@ -75,7 +75,7 @@ public class BasicData implements CommandLineRunner{ | ||
| 75 | 75 | ||
| 76 | @Override | 76 | @Override |
| 77 | public void run(String... arg0) throws Exception { | 77 | public void run(String... arg0) throws Exception { |
| 78 | - Application.mainServices.scheduleWithFixedDelay(dataLoader, 0, 2, TimeUnit.HOURS); | 78 | + Application.mainServices.scheduleWithFixedDelay(dataLoader, 0, 1, TimeUnit.HOURS); |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | 81 |
src/main/java/com/bsth/repository/forecast/SampleRepository.java
| 1 | package com.bsth.repository.forecast; | 1 | package com.bsth.repository.forecast; |
| 2 | 2 | ||
| 3 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 4 | +import org.springframework.data.jpa.repository.Query; | ||
| 3 | import org.springframework.stereotype.Repository; | 5 | import org.springframework.stereotype.Repository; |
| 6 | +import org.springframework.transaction.annotation.Transactional; | ||
| 4 | 7 | ||
| 5 | import com.bsth.entity.forecast.Sample; | 8 | import com.bsth.entity.forecast.Sample; |
| 6 | import com.bsth.repository.BaseRepository; | 9 | import com.bsth.repository.BaseRepository; |
| @@ -8,4 +11,9 @@ import com.bsth.repository.BaseRepository; | @@ -8,4 +11,9 @@ import com.bsth.repository.BaseRepository; | ||
| 8 | @Repository | 11 | @Repository |
| 9 | public interface SampleRepository extends BaseRepository<Sample, Long>{ | 12 | public interface SampleRepository extends BaseRepository<Sample, Long>{ |
| 10 | 13 | ||
| 14 | + | ||
| 15 | + @Transactional | ||
| 16 | + @Modifying | ||
| 17 | + @Query("delete Sample where lineCode=?1 and updown=?2") | ||
| 18 | + void deleteByLineAndUpdown(Integer lineCode, int updown); | ||
| 11 | } | 19 | } |
src/main/java/com/bsth/service/forecast/SampleService.java
| @@ -5,4 +5,6 @@ import com.bsth.service.BaseService; | @@ -5,4 +5,6 @@ import com.bsth.service.BaseService; | ||
| 5 | 5 | ||
| 6 | public interface SampleService extends BaseService<Sample, Long>{ | 6 | public interface SampleService extends BaseService<Sample, Long>{ |
| 7 | 7 | ||
| 8 | + int createDataByGps(String lineCode, Integer updown); | ||
| 9 | + | ||
| 8 | } | 10 | } |
src/main/java/com/bsth/service/forecast/SampleServiceImpl.java
| @@ -3,15 +3,22 @@ package com.bsth.service.forecast; | @@ -3,15 +3,22 @@ package com.bsth.service.forecast; | ||
| 3 | import java.util.Iterator; | 3 | import java.util.Iterator; |
| 4 | import java.util.Map; | 4 | import java.util.Map; |
| 5 | 5 | ||
| 6 | +import javax.transaction.Transactional; | ||
| 7 | + | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
| 7 | 10 | ||
| 8 | import com.bsth.data.BasicData; | 11 | import com.bsth.data.BasicData; |
| 9 | import com.bsth.entity.forecast.Sample; | 12 | import com.bsth.entity.forecast.Sample; |
| 13 | +import com.bsth.repository.forecast.SampleRepository; | ||
| 10 | import com.bsth.service.impl.BaseServiceImpl; | 14 | import com.bsth.service.impl.BaseServiceImpl; |
| 11 | 15 | ||
| 12 | @Service | 16 | @Service |
| 13 | -public class SampleServiceImpl extends BaseServiceImpl<Sample, Long>{ | 17 | +public class SampleServiceImpl extends BaseServiceImpl<Sample, Long> implements SampleService{ |
| 14 | 18 | ||
| 19 | + @Autowired | ||
| 20 | + SampleRepository sampleRepository; | ||
| 21 | + | ||
| 15 | @Override | 22 | @Override |
| 16 | public Iterable<Sample> list(Map<String, Object> map) { | 23 | public Iterable<Sample> list(Map<String, Object> map) { |
| 17 | Iterable<Sample> rs = super.list(map); | 24 | Iterable<Sample> rs = super.list(map); |
| @@ -26,4 +33,13 @@ public class SampleServiceImpl extends BaseServiceImpl<Sample, Long>{ | @@ -26,4 +33,13 @@ public class SampleServiceImpl extends BaseServiceImpl<Sample, Long>{ | ||
| 26 | } | 33 | } |
| 27 | return rs; | 34 | return rs; |
| 28 | } | 35 | } |
| 36 | + | ||
| 37 | + @Transactional | ||
| 38 | + @Override | ||
| 39 | + public int createDataByGps(String lineCode, Integer updown) { | ||
| 40 | + //删除原有数据 | ||
| 41 | + sampleRepository.deleteByLineAndUpdown(Integer.parseInt(lineCode), updown); | ||
| 42 | + | ||
| 43 | + return 0; | ||
| 44 | + } | ||
| 29 | } | 45 | } |
src/main/java/com/bsth/websocket/handler/SendUtils.java
| @@ -18,6 +18,7 @@ import com.bsth.data.LineConfigData; | @@ -18,6 +18,7 @@ import com.bsth.data.LineConfigData; | ||
| 18 | import com.bsth.data.schedule.DayOfSchedule; | 18 | import com.bsth.data.schedule.DayOfSchedule; |
| 19 | import com.bsth.entity.directive.D80; | 19 | import com.bsth.entity.directive.D80; |
| 20 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 20 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 21 | +import com.fasterxml.jackson.core.JsonProcessingException; | ||
| 21 | import com.fasterxml.jackson.databind.ObjectMapper; | 22 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 22 | 23 | ||
| 23 | @Component | 24 | @Component |
| @@ -130,10 +131,18 @@ public class SendUtils{ | @@ -130,10 +131,18 @@ public class SendUtils{ | ||
| 130 | * @Description: TODO(调度指令状态推送) | 131 | * @Description: TODO(调度指令状态推送) |
| 131 | */ | 132 | */ |
| 132 | public void sendDirectiveToPage(ScheduleRealInfo sch) { | 133 | public void sendDirectiveToPage(ScheduleRealInfo sch) { |
| 133 | - JSONObject json = new JSONObject(); | ||
| 134 | - json.put("fn", "directive"); | ||
| 135 | - json.put("t", sch); | ||
| 136 | - socketHandler.sendMessageToLine(sch.getXlBm(), json.toJSONString()); | 134 | + |
| 135 | + Map<String, Object> map = new HashMap<>(); | ||
| 136 | + map.put("fn", "directive"); | ||
| 137 | + map.put("t", sch);; | ||
| 138 | + | ||
| 139 | + ObjectMapper mapper = new ObjectMapper(); | ||
| 140 | + | ||
| 141 | + try { | ||
| 142 | + socketHandler.sendMessageToLine(sch.getXlBm(), mapper.writeValueAsString(map)); | ||
| 143 | + } catch (JsonProcessingException e) { | ||
| 144 | + logger.error("", e); | ||
| 145 | + } | ||
| 137 | } | 146 | } |
| 138 | 147 | ||
| 139 | public void send80ToPage(D80 d80) { | 148 | public void send80ToPage(D80 d80) { |
src/main/resources/static/pages/forecast/sample/css/main.css
| 1 | -#lineConfigPanel{ | 1 | +#forecastSamplePanel{ |
| 2 | background: #fff; | 2 | background: #fff; |
| 3 | overflow: hidden; | 3 | overflow: hidden; |
| 4 | font-family: 'Segoe UI',Arial,'Microsoft Yahei',sans-serif !important; | 4 | font-family: 'Segoe UI',Arial,'Microsoft Yahei',sans-serif !important; |
| 5 | min-width: 1392px; | 5 | min-width: 1392px; |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | -#lineConfigPanel h1{ | 8 | +#forecastSamplePanel h1{ |
| 9 | -webkit-margin-start: 23px; | 9 | -webkit-margin-start: 23px; |
| 10 | color: rgb(92, 97, 102); | 10 | color: rgb(92, 97, 102); |
| 11 | margin-bottom: 1em; | 11 | margin-bottom: 1em; |
| @@ -13,26 +13,26 @@ | @@ -13,26 +13,26 @@ | ||
| 13 | font-size: 1.5em; | 13 | font-size: 1.5em; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | -#lineConfigPanel .line_config_tree ul { | 16 | +#forecastSamplePanel .line_config_tree ul { |
| 17 | list-style-type: none; | 17 | list-style-type: none; |
| 18 | padding: 0; | 18 | padding: 0; |
| 19 | height: 100% !important; | 19 | height: 100% !important; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | -#lineConfigPanel .line_config_tree ul li{ | 22 | +#forecastSamplePanel .line_config_tree ul li{ |
| 23 | -webkit-border-start: 6px solid transparent; | 23 | -webkit-border-start: 6px solid transparent; |
| 24 | -webkit-padding-start: 18px; | 24 | -webkit-padding-start: 18px; |
| 25 | -webkit-user-select: none; | 25 | -webkit-user-select: none; |
| 26 | cursor: pointer; | 26 | cursor: pointer; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | -#lineConfigPanel .line_config_tree ul li.selected{ | 29 | +#forecastSamplePanel .line_config_tree ul li.selected{ |
| 30 | -webkit-border-start-color: #1bbc9b; | 30 | -webkit-border-start-color: #1bbc9b; |
| 31 | cursor: default; | 31 | cursor: default; |
| 32 | pointer-events: none; | 32 | pointer-events: none; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | -#lineConfigPanel .line_config_tree ul li button{ | 35 | +#forecastSamplePanel .line_config_tree ul li button{ |
| 36 | background-color: white; | 36 | background-color: white; |
| 37 | border: 0; | 37 | border: 0; |
| 38 | color: #999; | 38 | color: #999; |
| @@ -43,25 +43,26 @@ | @@ -43,25 +43,26 @@ | ||
| 43 | padding: 0; | 43 | padding: 0; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | -#lineConfigPanel .line_config_tree ul li.selected button{ | 46 | +#forecastSamplePanel .line_config_tree ul li.selected button{ |
| 47 | color: #1bbc9b; | 47 | color: #1bbc9b; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -#lineConfigPanel #trafficChart{ | 50 | +#forecastSamplePanel #trafficChart{ |
| 51 | display: inline-block; | 51 | display: inline-block; |
| 52 | width: calc(100% - 152px); | 52 | width: calc(100% - 152px); |
| 53 | vertical-align: top; | 53 | vertical-align: top; |
| 54 | height: 100%; | 54 | height: 100%; |
| 55 | + overflow: auto; | ||
| 56 | + padding-bottom: 12px; | ||
| 55 | } | 57 | } |
| 56 | 58 | ||
| 57 | -#lineConfigPanel #trafficChart .sample_tags{ | 59 | +#forecastSamplePanel #trafficChart .sample_tags{ |
| 58 | width: 100%; | 60 | width: 100%; |
| 59 | - height: 65px; | ||
| 60 | text-align: right; | 61 | text-align: right; |
| 61 | - padding: 20px 40px 0; | 62 | + padding: 20px 40px 10px; |
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | -#lineConfigPanel #trafficChart .sample_tags a.tag{ | 65 | +#forecastSamplePanel #trafficChart .sample_tags a.tag{ |
| 65 | display: inline-block; | 66 | display: inline-block; |
| 66 | line-height: 1; | 67 | line-height: 1; |
| 67 | vertical-align: baseline; | 68 | vertical-align: baseline; |
| @@ -79,37 +80,44 @@ | @@ -79,37 +80,44 @@ | ||
| 79 | font-weight: 400; | 80 | font-weight: 400; |
| 80 | } | 81 | } |
| 81 | 82 | ||
| 82 | -#lineConfigPanel #trafficChart svg{ | ||
| 83 | - width: 100%; | ||
| 84 | - height: calc(100% - 65px); | 83 | +#forecastSamplePanel #trafficChart svg{ |
| 84 | + width: calc(100% - 11px); | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +#svgWrap{ | ||
| 88 | + width: calc(100% - 10px); | ||
| 89 | + border: 1px solid #dadada; | ||
| 90 | + border-radius: 3px !important; | ||
| 91 | + box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12); | ||
| 92 | + transition: all .3s ease; | ||
| 85 | } | 93 | } |
| 86 | 94 | ||
| 87 | -#lineConfigPanel #trafficChart svg circle{ | 95 | +#forecastSamplePanel #trafficChart svg circle{ |
| 88 | fill: #b9b7b7; | 96 | fill: #b9b7b7; |
| 89 | r: 6; | 97 | r: 6; |
| 90 | stroke: rgb(253, 253, 253); | 98 | stroke: rgb(253, 253, 253); |
| 91 | stroke-width: 3; | 99 | stroke-width: 3; |
| 92 | } | 100 | } |
| 93 | 101 | ||
| 94 | -#lineConfigPanel #trafficChart svg path{ | 102 | +#forecastSamplePanel #trafficChart svg path{ |
| 95 | stroke-width: 6.4px; | 103 | stroke-width: 6.4px; |
| 96 | opacity: 0.9; | 104 | opacity: 0.9; |
| 97 | stroke: #b2afaf; | 105 | stroke: #b2afaf; |
| 98 | cursor: pointer; | 106 | cursor: pointer; |
| 99 | } | 107 | } |
| 100 | 108 | ||
| 101 | -#lineConfigPanel #trafficChart svg path.active{ | 109 | +#forecastSamplePanel #trafficChart svg path.active{ |
| 102 | stroke: #1bbc9b; | 110 | stroke: #1bbc9b; |
| 103 | } | 111 | } |
| 104 | 112 | ||
| 105 | -#lineConfigPanel #trafficChart svg text{ | 113 | +#forecastSamplePanel #trafficChart svg text{ |
| 106 | font-size: 85%; | 114 | font-size: 85%; |
| 107 | fill: #6b6666; | 115 | fill: #6b6666; |
| 108 | font-weight: bold; | 116 | font-weight: bold; |
| 109 | pointer-events: none; | 117 | pointer-events: none; |
| 110 | } | 118 | } |
| 111 | 119 | ||
| 112 | -#lineConfigPanel #trafficChart .sample_tags a.tag.active{ | 120 | +#forecastSamplePanel #trafficChart .sample_tags a.tag.active{ |
| 113 | background-color: #1bbc9b; | 121 | background-color: #1bbc9b; |
| 114 | color: white; | 122 | color: white; |
| 115 | } | 123 | } |
| @@ -120,7 +128,7 @@ | @@ -120,7 +128,7 @@ | ||
| 120 | height: 100%; | 128 | height: 100%; |
| 121 | } | 129 | } |
| 122 | 130 | ||
| 123 | -#lineConfigPanel .slimScrollBar{ | 131 | +#forecastSamplePanel .slimScrollBar{ |
| 124 | border-radius: 7px !important; | 132 | border-radius: 7px !important; |
| 125 | background: rgb(176, 173, 173) !important; | 133 | background: rgb(176, 173, 173) !important; |
| 126 | width: 4px !important; | 134 | width: 4px !important; |
| @@ -179,8 +187,10 @@ | @@ -179,8 +187,10 @@ | ||
| 179 | } | 187 | } |
| 180 | 188 | ||
| 181 | .left_station_route .tabbable-line .tab-content{ | 189 | .left_station_route .tabbable-line .tab-content{ |
| 182 | - height: 100% !important; | ||
| 183 | - padding: 20px 0 0; | 190 | + height: calc(100% - 63px); |
| 191 | + padding: 20px 0 0; | ||
| 192 | + overflow: auto; | ||
| 193 | + border-top: 0; | ||
| 184 | } | 194 | } |
| 185 | 195 | ||
| 186 | rect.station_rect{ | 196 | rect.station_rect{ |
| @@ -196,10 +206,43 @@ rect.f_rect{ | @@ -196,10 +206,43 @@ rect.f_rect{ | ||
| 196 | cursor: pointer; | 206 | cursor: pointer; |
| 197 | } | 207 | } |
| 198 | 208 | ||
| 199 | -#lineConfigPanel #trafficChart svg text.f_text{ | 209 | +#forecastSamplePanel #trafficChart svg text.f_text{ |
| 200 | fill: #ffffff; | 210 | fill: #ffffff; |
| 201 | } | 211 | } |
| 202 | 212 | ||
| 203 | .select2-container--open{ | 213 | .select2-container--open{ |
| 204 | z-index: 100000000; | 214 | z-index: 100000000; |
| 215 | +} | ||
| 216 | + | ||
| 217 | +.inline-link{ | ||
| 218 | + font-size: 12px; | ||
| 219 | + color: red; | ||
| 220 | + text-decoration: underline; | ||
| 221 | + display: inline-block; | ||
| 222 | + vertical-align: bottom; | ||
| 223 | + margin: 0 8px 7px 0; | ||
| 224 | +} | ||
| 225 | + | ||
| 226 | + | ||
| 227 | +#forecastSamplePanel .tab-content::-webkit-scrollbar, | ||
| 228 | +#forecastSamplePanel #trafficChart::-webkit-scrollbar { | ||
| 229 | + width: 15px; | ||
| 230 | + height: 16px; | ||
| 231 | +} | ||
| 232 | +#forecastSamplePanel .tab-content::-webkit-scrollbar-track, | ||
| 233 | +#forecastSamplePanel .tab-content::-webkit-scrollbar-thumb, | ||
| 234 | +#forecastSamplePanel #trafficChart::-webkit-scrollbar-track, | ||
| 235 | +#forecastSamplePanel #trafficChart::-webkit-scrollbar-thumb { | ||
| 236 | + border-radius: 999px; | ||
| 237 | + border: 5px solid transparent; | ||
| 238 | +} | ||
| 239 | +#forecastSamplePanel .tab-content::-webkit-scrollbar-thumb, | ||
| 240 | +#forecastSamplePanel #trafficChart::-webkit-scrollbar-thumb { | ||
| 241 | + min-height: 20px; | ||
| 242 | + background-clip: content-box; | ||
| 243 | + box-shadow: 0 0 0 5px rgba(0,0,0,.2) inset; | ||
| 244 | +} | ||
| 245 | +#forecastSamplePanel .tab-content::-webkit-scrollbar-corner, | ||
| 246 | +#forecastSamplePanel #trafficChart::-webkit-scrollbar-corner { | ||
| 247 | + background: transparent; | ||
| 205 | } | 248 | } |
| 206 | \ No newline at end of file | 249 | \ No newline at end of file |
src/main/resources/static/pages/forecast/sample/js/svg.js
| @@ -53,10 +53,10 @@ var sampleSvg = (function(){ | @@ -53,10 +53,10 @@ var sampleSvg = (function(){ | ||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | function draw(opt){ | 55 | function draw(opt){ |
| 56 | - $('#trafficChart svg').remove(); | ||
| 57 | - svg = d3.select('#trafficChart').append('svg'); | 56 | + $('#svgWrap svg').remove(); |
| 57 | + svg = d3.select('#svgWrap').append('svg'); | ||
| 58 | //容器宽度 | 58 | //容器宽度 |
| 59 | - var width = $('#trafficChart svg').width(); | 59 | + var width = $('#svgWrap svg').width(); |
| 60 | margin = (width - (rowNum - 1) * itemWidth) / 2; | 60 | margin = (width - (rowNum - 1) * itemWidth) / 2; |
| 61 | var rts = opt.rts | 61 | var rts = opt.rts |
| 62 | _count = rts.length; | 62 | _count = rts.length; |
| @@ -69,6 +69,10 @@ var sampleSvg = (function(){ | @@ -69,6 +69,10 @@ var sampleSvg = (function(){ | ||
| 69 | stationMapp[obj.stationCode] = obj.stationName; | 69 | stationMapp[obj.stationCode] = obj.stationName; |
| 70 | }); | 70 | }); |
| 71 | 71 | ||
| 72 | + var h = rts[rts.length - 1].cy + 50; | ||
| 73 | + svg.style('height', h).style('opacity', 0); | ||
| 74 | + $('#svgWrap').css('height', h + 6); | ||
| 75 | + | ||
| 72 | //画线 | 76 | //画线 |
| 73 | svg.selectAll('path').data(rts) | 77 | svg.selectAll('path').data(rts) |
| 74 | .enter().append('path') | 78 | .enter().append('path') |
| @@ -91,13 +95,16 @@ var sampleSvg = (function(){ | @@ -91,13 +95,16 @@ var sampleSvg = (function(){ | ||
| 91 | drawText(rts); | 95 | drawText(rts); |
| 92 | //显示tags | 96 | //显示tags |
| 93 | showTags(); | 97 | showTags(); |
| 98 | + | ||
| 99 | + //d3 anim | ||
| 100 | + svg.transition().delay(100).style('opacity', 1); | ||
| 94 | } | 101 | } |
| 95 | 102 | ||
| 96 | //tag 点击事件 | 103 | //tag 点击事件 |
| 97 | $('#trafficChart').on('click', '.sample_tags a.tag', function(){ | 104 | $('#trafficChart').on('click', '.sample_tags a.tag', function(){ |
| 98 | $('.sample_tags a.tag.active').removeClass('active'); | 105 | $('.sample_tags a.tag.active').removeClass('active'); |
| 99 | $(this).addClass('active'); | 106 | $(this).addClass('active'); |
| 100 | - var tag = $(this).text(); | 107 | + var tag = $(this).attr('title'); |
| 101 | clearRunTimeE(); | 108 | clearRunTimeE(); |
| 102 | //show | 109 | //show |
| 103 | showRunTimeE(_data[tag]) | 110 | showRunTimeE(_data[tag]) |
| @@ -115,7 +122,6 @@ var sampleSvg = (function(){ | @@ -115,7 +122,6 @@ var sampleSvg = (function(){ | ||
| 115 | .attr('data-sid', this.id); | 122 | .attr('data-sid', this.id); |
| 116 | }); | 123 | }); |
| 117 | 124 | ||
| 118 | - console.log('showRunTimeE...', rs); | ||
| 119 | //背景 | 125 | //背景 |
| 120 | svg.selectAll('.f_rect') | 126 | svg.selectAll('.f_rect') |
| 121 | .data(rs).enter().append('rect') | 127 | .data(rs).enter().append('rect') |
| @@ -153,11 +159,14 @@ var sampleSvg = (function(){ | @@ -153,11 +159,14 @@ var sampleSvg = (function(){ | ||
| 153 | $.each(rs, function(i, d){ | 159 | $.each(rs, function(i, d){ |
| 154 | if(!_data[d.tag]){ | 160 | if(!_data[d.tag]){ |
| 155 | _data[d.tag] = []; | 161 | _data[d.tag] = []; |
| 156 | - tags += '<a class="tag">'+d.tag+'</a>'; | 162 | + tags += '<a class="tag" title="'+d.tag+'">'+(d.tag + ' ' + d.sDate + ' - ' + d.eDate)+'</a>'; |
| 157 | } | 163 | } |
| 158 | _data[d.tag].push(d); | 164 | _data[d.tag].push(d); |
| 159 | }); | 165 | }); |
| 160 | - $('#trafficChart .sample_tags').html(tags); | 166 | + |
| 167 | + var wrap = $('#trafficChart .sample_tags'); | ||
| 168 | + wrap.find('a.tag').remove(); | ||
| 169 | + wrap.append(tags); | ||
| 161 | //选中第一个tag | 170 | //选中第一个tag |
| 162 | $('#trafficChart .sample_tags a.tag:eq(0)').click(); | 171 | $('#trafficChart .sample_tags a.tag:eq(0)').click(); |
| 163 | }); | 172 | }); |
| @@ -173,42 +182,16 @@ var sampleSvg = (function(){ | @@ -173,42 +182,16 @@ var sampleSvg = (function(){ | ||
| 173 | } | 182 | } |
| 174 | 183 | ||
| 175 | function popAddModal(id){ | 184 | function popAddModal(id){ |
| 176 | - //var eid = id ,sid = prve(id); | ||
| 177 | - //if(!sid)return; | ||
| 178 | - | ||
| 179 | - //var opts = {sid: sid, eid: eid, sName: stationMapp[sid], eName: stationMapp[eid]}; | ||
| 180 | $.get('/pages/forecast/sample/modal.html', function(rs){ | 185 | $.get('/pages/forecast/sample/modal.html', function(rs){ |
| 181 | var index = layer.open({ | 186 | var index = layer.open({ |
| 182 | type: 1, | 187 | type: 1, |
| 183 | area: '550px', | 188 | area: '550px', |
| 184 | content: rs, | 189 | content: rs, |
| 185 | shift: 5, | 190 | shift: 5, |
| 186 | - // title: '...', | 191 | + title: '人工编辑', |
| 187 | success: function(layero, index){ | 192 | success: function(layero, index){ |
| 188 | var activeTag = $('.sample_tags a.tag.active'); | 193 | var activeTag = $('.sample_tags a.tag.active'); |
| 189 | - $('#forecast_sample_modal').trigger('init', {layero: layero, _opt: _opt, _data: _data, id: id, tag: activeTag.length > 0?activeTag.text():''}); | ||
| 190 | - /*$("#addSampleForm select[name=tag]").select2({ | ||
| 191 | - maximumSelectionLength: 1, | ||
| 192 | - tags: true | ||
| 193 | - }) | ||
| 194 | - .on('change', function(){ | ||
| 195 | - var t = $(this).val(); | ||
| 196 | - if(tagRange[t]){ | ||
| 197 | - $("#addSampleForm input[name=sDate]").val(tagRange[t].s); | ||
| 198 | - $("#addSampleForm input[name=eDate]").val(tagRange[t].e); | ||
| 199 | - } | ||
| 200 | - }); | ||
| 201 | - | ||
| 202 | - //提交 | ||
| 203 | - $('#addSampleForm .confirm').on('click', function(){ | ||
| 204 | - if(customFormValidate('#addSampleForm')){ | ||
| 205 | - console.log(_opt); | ||
| 206 | - var param = $('#addSampleForm').serializeJSON(); | ||
| 207 | - param.lineCode = _opt.lineCode; | ||
| 208 | - param.updown = _opt.updown; | ||
| 209 | - $post('/sample', param, function(){layer.close(index);}); | ||
| 210 | - } | ||
| 211 | - });*/ | 194 | + $('#forecast_sample_modal').trigger('init', {drawObject: drawObject, layero: layero, _opt: _opt, _data: _data, id: id, tag: activeTag.length > 0?activeTag.attr('title'):''}); |
| 212 | } | 195 | } |
| 213 | }); | 196 | }); |
| 214 | }); | 197 | }); |
src/main/resources/static/pages/forecast/sample/main.html
| 1 | <link href="/pages/forecast/sample/css/main.css" rel="stylesheet" type="text/css" /> | 1 | <link href="/pages/forecast/sample/css/main.css" rel="stylesheet" type="text/css" /> |
| 2 | -<div id="lineConfigPanel"> | 2 | +<div id="forecastSamplePanel"> |
| 3 | <div class="line_config_tree" > | 3 | <div class="line_config_tree" > |
| 4 | <h1 >线路</h1> | 4 | <h1 >线路</h1> |
| 5 | <ul></ul> | 5 | <ul></ul> |
| @@ -29,7 +29,12 @@ | @@ -29,7 +29,12 @@ | ||
| 29 | </div> | 29 | </div> |
| 30 | 30 | ||
| 31 | <div id="trafficChart" > | 31 | <div id="trafficChart" > |
| 32 | - <div class="sample_tags"></div> | 32 | + <div class="sample_tags"> |
| 33 | + <a href="javascript:;" class="inline-link" id="gpsCreateDataLink"><i class="fa fa-sign-in"> </i> GPS生成数据</a> | ||
| 34 | + </div> | ||
| 35 | + <div id="svgWrap" > | ||
| 36 | + | ||
| 37 | + </div> | ||
| 33 | </div> | 38 | </div> |
| 34 | </div> | 39 | </div> |
| 35 | </div> | 40 | </div> |
| @@ -57,23 +62,23 @@ | @@ -57,23 +62,23 @@ | ||
| 57 | //站点路由信息 | 62 | //站点路由信息 |
| 58 | var routes = {}; | 63 | var routes = {}; |
| 59 | 64 | ||
| 60 | - var $panel = $('#lineConfigPanel') | 65 | + var $panel = $('#forecastSamplePanel') |
| 61 | ,$body = $('.line_config_content .body'); | 66 | ,$body = $('.line_config_content .body'); |
| 62 | var h = $('.page-container>.page-sidebar-wrapper>.page-sidebar').height(); | 67 | var h = $('.page-container>.page-sidebar-wrapper>.page-sidebar').height(); |
| 63 | $panel.css('height', h - 18); | 68 | $panel.css('height', h - 18); |
| 64 | 69 | ||
| 65 | - //线路滚动条 | 70 | + //线路滚动条 |
| 66 | $('.line_config_tree ul').slimscroll({ | 71 | $('.line_config_tree ul').slimscroll({ |
| 67 | height : 'calc(100% - 68px)', | 72 | height : 'calc(100% - 68px)', |
| 68 | alwaysVisible : true, | 73 | alwaysVisible : true, |
| 69 | opacity : .8 | 74 | opacity : .8 |
| 70 | }); | 75 | }); |
| 71 | 76 | ||
| 72 | - //路由 | 77 | +/* //路由 |
| 73 | $('.left_station_route .tab-content').slimscroll({ | 78 | $('.left_station_route .tab-content').slimscroll({ |
| 74 | height : 'calc(100% - 46px)', | 79 | height : 'calc(100% - 46px)', |
| 75 | opacity : .8 | 80 | opacity : .8 |
| 76 | - }); | 81 | + }); */ |
| 77 | 82 | ||
| 78 | //上下行切换事件 | 83 | //上下行切换事件 |
| 79 | $('.left_station_route .tabbable-line ul li').on('click', function(){setTimeout(drawSvg, 300);}); | 84 | $('.left_station_route .tabbable-line ul li').on('click', function(){setTimeout(drawSvg, 300);}); |
| @@ -149,8 +154,21 @@ | @@ -149,8 +154,21 @@ | ||
| 149 | sampleSvg.draw({lineCode: getLineCode(), rts: rts, updown: getUpdown()}); | 154 | sampleSvg.draw({lineCode: getLineCode(), rts: rts, updown: getUpdown()}); |
| 150 | } | 155 | } |
| 151 | 156 | ||
| 152 | - $('#lineConfigPanel').on('click', '.sample_route_item', function(){ | 157 | + $('#forecastSamplePanel').on('click', '.sample_route_item', function(){ |
| 153 | sampleSvg.popAddModal($(this).data('id')); | 158 | sampleSvg.popAddModal($(this).data('id')); |
| 154 | }) | 159 | }) |
| 160 | + | ||
| 161 | + | ||
| 162 | + $('#gpsCreateDataLink').on('click', function(){ | ||
| 163 | + var lineName = $('.line_config_tree ul li.selected button').text(); | ||
| 164 | + var updownText = $('.left_station_route ul li.active a').text(); | ||
| 165 | + | ||
| 166 | + layer.confirm('使用GPS轨迹生成【'+lineName+' -'+updownText+'】站点间耗时数据? 该操作将会清除原有数据。', { | ||
| 167 | + btn: ['我确定','算了吧'], | ||
| 168 | + icon: 3 | ||
| 169 | + }, function(){ | ||
| 170 | + | ||
| 171 | + }); | ||
| 172 | + }); | ||
| 155 | }(); | 173 | }(); |
| 156 | </script> | 174 | </script> |
| 157 | \ No newline at end of file | 175 | \ No newline at end of file |
src/main/resources/static/pages/forecast/sample/modal.html
| @@ -19,10 +19,12 @@ | @@ -19,10 +19,12 @@ | ||
| 19 | <div class="tab-content"> | 19 | <div class="tab-content"> |
| 20 | {{each data as obj i}} | 20 | {{each data as obj i}} |
| 21 | <div class="tab-pane" id="tab_sample_{{i}}"> | 21 | <div class="tab-pane" id="tab_sample_{{i}}"> |
| 22 | - <form class="form-horizontal" role="form" style="padding: 35px 25px;" id="addSampleForm"> | 22 | + <form class="form-horizontal" role="form" style="padding: 35px 25px;" id="editSampleForm_{{i}}"> |
| 23 | <input type="hidden" name="id" value="{{obj.d.id}}"/> | 23 | <input type="hidden" name="id" value="{{obj.d.id}}"/> |
| 24 | - <input type="hidden" name="sStation" value="{{obj.d.sid}}"/> | ||
| 25 | - <input type="hidden" name="eStation" value="{{obj.d.eid}}"/> | 24 | + <input type="hidden" name="sStation" value="{{obj.d.sStation}}"/> |
| 25 | + <input type="hidden" name="eStation" value="{{obj.d.eStation}}"/> | ||
| 26 | + <input type="hidden" name="tag" value="{{obj.d.tag}}"/> | ||
| 27 | + | ||
| 26 | <div class="form-body"> | 28 | <div class="form-body"> |
| 27 | <div class="form-group"> | 29 | <div class="form-group"> |
| 28 | <label class="col-md-3 control-label">开始站:</label> | 30 | <label class="col-md-3 control-label">开始站:</label> |
| @@ -57,8 +59,8 @@ | @@ -57,8 +59,8 @@ | ||
| 57 | <div class="form-actions"> | 59 | <div class="form-actions"> |
| 58 | <div class="row"> | 60 | <div class="row"> |
| 59 | <div class="col-md-offset-4 col-md-8"> | 61 | <div class="col-md-offset-4 col-md-8"> |
| 60 | - <button type="button" class="btn green confirm"><i class="fa fa-check"></i> 保存</button> | ||
| 61 | - <button type="button" class="btn red layui-layer-close">删除</button> | 62 | + <button type="button" class="btn green confirm" data-form="#editSampleForm_{{i}}"><i class="fa fa-check"></i> 保存</button> |
| 63 | + <button type="button" class="btn red remove" data-id="{{obj.d.id}}">删除</button> | ||
| 62 | </div> | 64 | </div> |
| 63 | </div> | 65 | </div> |
| 64 | </div> | 66 | </div> |
| @@ -113,8 +115,8 @@ | @@ -113,8 +115,8 @@ | ||
| 113 | <br> | 115 | <br> |
| 114 | <div class="form-actions"> | 116 | <div class="form-actions"> |
| 115 | <div class="row"> | 117 | <div class="row"> |
| 116 | - <div class="col-md-offset-4 col-md-8"> | ||
| 117 | - <button type="button" class="btn green confirm"><i class="fa fa-check"></i> 提交</button> | 118 | + <div class="col-md-offset-5 col-md-7"> |
| 119 | + <button type="button" class="btn green confirm" data-form="#addSampleForm"><i class="fa fa-check"></i> 提交</button> | ||
| 118 | </div> | 120 | </div> |
| 119 | </div> | 121 | </div> |
| 120 | </div> | 122 | </div> |
| @@ -126,18 +128,26 @@ | @@ -126,18 +128,26 @@ | ||
| 126 | 128 | ||
| 127 | <script> | 129 | <script> |
| 128 | !function(){ | 130 | !function(){ |
| 129 | - var _data,_opt,id, currentData, layero; | 131 | + var _data,_opt,id, currentData, layero, drawObject; |
| 130 | var tagRange = {'早高峰': {s: '06:31', e: '08:30'}, '平峰': {s: '08:31', e: '16:00'}, '晚高峰': {s: '16:01', e: '18:00'}}; | 132 | var tagRange = {'早高峰': {s: '06:31', e: '08:30'}, '平峰': {s: '08:31', e: '16:00'}, '晚高峰': {s: '16:01', e: '18:00'}}; |
| 131 | 133 | ||
| 132 | $('#forecast_sample_modal').on('init', function(e, rs){ | 134 | $('#forecast_sample_modal').on('init', function(e, rs){ |
| 133 | _data = rs._data; | 135 | _data = rs._data; |
| 134 | _opt = rs._opt; | 136 | _opt = rs._opt; |
| 137 | + drawObject = rs.drawObject; | ||
| 135 | layero = rs.layero; | 138 | layero = rs.layero; |
| 136 | id = rs.id; | 139 | id = rs.id; |
| 137 | 140 | ||
| 138 | - var eid = id, sid = prve(id).stationCode; | 141 | + var _prve = prve(id); |
| 142 | + if(!_prve){ | ||
| 143 | + layer.closeAll(); | ||
| 144 | + layer.msg('没有上一站,无法录入数据!'); | ||
| 145 | + return; | ||
| 146 | + } | ||
| 147 | + var eid = id, sid = _prve.stationCode; | ||
| 139 | var sampData = searchData(sid, eid); | 148 | var sampData = searchData(sid, eid); |
| 140 | var baseData = {sid: sid, eid: eid, sName: toName(sid), eName: toName(eid)}; | 149 | var baseData = {sid: sid, eid: eid, sName: toName(sid), eName: toName(eid)}; |
| 150 | + console.log('baseData', baseData); | ||
| 141 | var html = template('forecast_sample_tab_detail_temp', {data: sampData, base: baseData}); | 151 | var html = template('forecast_sample_tab_detail_temp', {data: sampData, base: baseData}); |
| 142 | $('#forecast_sample_modal .row').html(html); | 152 | $('#forecast_sample_modal .row').html(html); |
| 143 | //默认选中tab | 153 | //默认选中tab |
| @@ -158,15 +168,30 @@ | @@ -158,15 +168,30 @@ | ||
| 158 | 168 | ||
| 159 | toCenter(layero); | 169 | toCenter(layero); |
| 160 | 170 | ||
| 161 | - $('#addSampleForm .confirm').on('click', function(){ | ||
| 162 | - if(customFormValidate('#addSampleForm')){ | ||
| 163 | - console.log(_opt); | ||
| 164 | - var param = $('#addSampleForm').serializeJSON(); | 171 | + //确定 |
| 172 | + $('#forecast_sample_modal .confirm').on('click', function(){ | ||
| 173 | + var f = $(this).data('form'); | ||
| 174 | + if(customFormValidate(f)){ | ||
| 175 | + var param = $(f).serializeJSON(); | ||
| 165 | param.lineCode = _opt.lineCode; | 176 | param.lineCode = _opt.lineCode; |
| 166 | param.updown = _opt.updown; | 177 | param.updown = _opt.updown; |
| 167 | - $post('/sample', param, function(){layer.close(index);}); | 178 | + |
| 179 | + layer.msg('操作中...', {icon: 16}); | ||
| 180 | + $post('/sample', param, function(){ | ||
| 181 | + layer.closeAll(); | ||
| 182 | + layer.msg('保存成功!'); | ||
| 183 | + drawObject.draw(_opt); | ||
| 184 | + }); | ||
| 168 | } | 185 | } |
| 169 | }); | 186 | }); |
| 187 | + | ||
| 188 | + //删除 | ||
| 189 | + $('#forecast_sample_modal .remove').on('click', function(){ | ||
| 190 | + removeConfirm('确定删除这条数据?', '/sample/' + $(this).data('id'), function(){ | ||
| 191 | + layer.closeAll(); | ||
| 192 | + drawObject.draw(_opt); | ||
| 193 | + }); | ||
| 194 | + }); | ||
| 170 | }); | 195 | }); |
| 171 | 196 | ||
| 172 | 197 | ||
| @@ -180,7 +205,6 @@ | @@ -180,7 +205,6 @@ | ||
| 180 | 205 | ||
| 181 | } | 206 | } |
| 182 | } | 207 | } |
| 183 | - | ||
| 184 | return null; | 208 | return null; |
| 185 | } | 209 | } |
| 186 | 210 |