Commit 2d42e00bd21536ca534d315ce45410535da493ec
1 parent
8c67a447
update
Showing
17 changed files
with
193 additions
and
40 deletions
src/main/java/com/bsth/data/arrival/DataLoader.java
| ... | ... | @@ -96,8 +96,11 @@ public class DataLoader { |
| 96 | 96 | st = conf.getCurrStartTime(); |
| 97 | 97 | if(t < st) |
| 98 | 98 | st = st - DAY_TIME; |
| 99 | - | |
| 100 | - all.addAll(loadByLineAndTime(conf.getLine().getLineCode(), st, t)); | |
| 99 | + try{ | |
| 100 | + all.addAll(loadByLineAndTime(conf.getLine().getLineCode(), st, t)); | |
| 101 | + }catch(Exception e){ | |
| 102 | + logger.error("", e); | |
| 103 | + } | |
| 101 | 104 | } |
| 102 | 105 | |
| 103 | 106 | prveLoadTime = t; | ... | ... |
src/main/java/com/bsth/data/directive/FirstScheduleCheckThread.java
0 → 100644
| 1 | +package com.bsth.data.directive; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | +import java.util.Set; | |
| 5 | + | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.stereotype.Component; | |
| 10 | + | |
| 11 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 12 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 13 | +import com.bsth.service.directive.DirectiveService; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * | |
| 17 | + * @ClassName: FirstScheduleCheckThread | |
| 18 | + * @Description: TODO(首班出场检测) | |
| 19 | + * @author PanZhao | |
| 20 | + * @date 2016年8月27日 上午1:25:21 | |
| 21 | + * | |
| 22 | + */ | |
| 23 | +@Component | |
| 24 | +public class FirstScheduleCheckThread extends Thread{ | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + DayOfSchedule dayOfSchedule; | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + DirectiveService directiveService; | |
| 31 | + | |
| 32 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 33 | + | |
| 34 | + private final static long THREE_MINUTES = 1000 * 60 * 3L; | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public void run() { | |
| 38 | + try{ | |
| 39 | + Set<String> cars = dayOfSchedule.allCar(); | |
| 40 | + | |
| 41 | + long t = System.currentTimeMillis(); | |
| 42 | + List<ScheduleRealInfo> schList; | |
| 43 | + ScheduleRealInfo first; | |
| 44 | + for(String car : cars){ | |
| 45 | + schList = dayOfSchedule.findByNbbm(car); | |
| 46 | + | |
| 47 | + if(null == schList || schList.size() == 0) | |
| 48 | + continue; | |
| 49 | + | |
| 50 | + first = schList.get(0); | |
| 51 | + | |
| 52 | + if(null != first.getBcType() | |
| 53 | + && first.getBcType().equals("out")){ | |
| 54 | + | |
| 55 | + //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令 | |
| 56 | + if(first.getJhlc() == null) | |
| 57 | + first = schList.get(1); | |
| 58 | + | |
| 59 | + //为首班补发指令 | |
| 60 | + if(first.getDirectiveState() == -1 | |
| 61 | + && Math.abs(first.getDfsjT() - t) < THREE_MINUTES){ | |
| 62 | + | |
| 63 | + directiveService.send60Dispatch(first, dayOfSchedule.doneSum(first.getClZbh()), "定补@系统"); | |
| 64 | + } | |
| 65 | + } | |
| 66 | + } | |
| 67 | + }catch(Exception e){ | |
| 68 | + logger.error("", e); | |
| 69 | + } | |
| 70 | + } | |
| 71 | +} | ... | ... |
src/main/java/com/bsth/data/match/Arrival2Schedule.java
| ... | ... | @@ -60,6 +60,10 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 60 | 60 | } |
| 61 | 61 | @Override |
| 62 | 62 | public void run() { |
| 63 | + if(nbbm.equals("YT-CD002")){ | |
| 64 | + System.out.println("debugger.."); | |
| 65 | + } | |
| 66 | + | |
| 63 | 67 | //班次列表 |
| 64 | 68 | List<ScheduleRealInfo> schList = dayOfSchedule.findByNbbm(nbbm); |
| 65 | 69 | //进出起终点数据 |
| ... | ... | @@ -67,6 +71,8 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 67 | 71 | //排序 |
| 68 | 72 | Collections.sort(schList, schComparator); |
| 69 | 73 | Collections.sort(arrList, arrComparator); |
| 74 | + //过滤班次 | |
| 75 | + schList = matchFilter(schList); | |
| 70 | 76 | |
| 71 | 77 | //用实际来匹配计划 |
| 72 | 78 | for(ArrivalEntity arr : arrList){ |
| ... | ... | @@ -74,7 +80,6 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 74 | 80 | } |
| 75 | 81 | } |
| 76 | 82 | private void match(ArrivalEntity arr, List<ScheduleRealInfo> schList) { |
| 77 | - schList = matchFilter(schList); | |
| 78 | 83 | |
| 79 | 84 | if(arr.getInOut() == 1) |
| 80 | 85 | matchOut(arr, schList); |
| ... | ... | @@ -185,7 +190,7 @@ public class Arrival2Schedule implements ApplicationContextAware { |
| 185 | 190 | if(null != next){ |
| 186 | 191 | next.setQdzArrDateSJ(mr.sch.getZdsjActual()); |
| 187 | 192 | //下发调度指令 |
| 188 | - directiveService.send60Dispatch(next, doneSum, "系统"); | |
| 193 | + directiveService.send60Dispatch(next, doneSum, "到站@系统"); | |
| 189 | 194 | } |
| 190 | 195 | else//下发文本指令(已结束运营) |
| 191 | 196 | directiveService.send60Phrase(nbbm, "到达终点 " + mr.sch.getZdzName() + ",已完成当日所有排班。", "系统"); | ... | ... |
src/main/java/com/bsth/data/pilot80/PilotReport.java
| ... | ... | @@ -78,8 +78,13 @@ public class PilotReport { |
| 78 | 78 | ScheduleRealInfo outSch = dayOfSchedule.nextByBcType(nbbm, "out"); |
| 79 | 79 | //如果有对应出场班次 |
| 80 | 80 | if(outSch != null){ |
| 81 | + | |
| 82 | + //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令 | |
| 83 | + if(outSch.getJhlc() == null) | |
| 84 | + outSch = dayOfSchedule.next(outSch); | |
| 85 | + | |
| 81 | 86 | //下发调度指令 |
| 82 | - directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "系统"); | |
| 87 | + directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); | |
| 83 | 88 | d80.setRemarks("计划出场时间:" + outSch.getDfsj()); |
| 84 | 89 | //当前GPS位置 |
| 85 | 90 | GpsEntity gps = gpsRealData.get(d80.getDeviceId()); | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -24,6 +24,7 @@ import com.alibaba.fastjson.JSON; |
| 24 | 24 | import com.alibaba.fastjson.JSONArray; |
| 25 | 25 | import com.bsth.Application; |
| 26 | 26 | import com.bsth.data.LineConfigData; |
| 27 | +import com.bsth.data.directive.FirstScheduleCheckThread; | |
| 27 | 28 | import com.bsth.entity.realcontrol.LineConfig; |
| 28 | 29 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 29 | 30 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| ... | ... | @@ -99,6 +100,9 @@ public class DayOfSchedule implements CommandLineRunner { |
| 99 | 100 | |
| 100 | 101 | @Autowired |
| 101 | 102 | SchedulePstThread schedulePstThread; |
| 103 | + | |
| 104 | + @Autowired | |
| 105 | + FirstScheduleCheckThread firstScheduleCheckThread; | |
| 102 | 106 | |
| 103 | 107 | @Override |
| 104 | 108 | public void run(String... arg0) throws Exception { |
| ... | ... | @@ -106,6 +110,8 @@ public class DayOfSchedule implements CommandLineRunner { |
| 106 | 110 | Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 20, 120, TimeUnit.SECONDS); |
| 107 | 111 | //入库 |
| 108 | 112 | Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS); |
| 113 | + //首班出场指令补发器 | |
| 114 | + Application.mainServices.scheduleWithFixedDelay(firstScheduleCheckThread, 60, 60, TimeUnit.SECONDS); | |
| 109 | 115 | } |
| 110 | 116 | |
| 111 | 117 | public Map<String, String> getCurrSchDate() { |
| ... | ... | @@ -483,7 +489,7 @@ public class DayOfSchedule implements CommandLineRunner { |
| 483 | 489 | int rs = 0; |
| 484 | 490 | |
| 485 | 491 | for(ScheduleRealInfo sch : list){ |
| 486 | - if(sch.getZdsjActual() != null && !sch.isDestroy()) | |
| 492 | + if(sch.getStatus() == 2 && !sch.isDestroy()) | |
| 487 | 493 | rs ++; |
| 488 | 494 | } |
| 489 | 495 | return rs; |
| ... | ... | @@ -583,6 +589,7 @@ public class DayOfSchedule implements CommandLineRunner { |
| 583 | 589 | */ |
| 584 | 590 | public ScheduleRealInfo nextByBcType(String nbbm, String bcType){ |
| 585 | 591 | List<ScheduleRealInfo> list = findByBcType(nbbm, bcType); |
| 592 | + | |
| 586 | 593 | Collections.sort(list, schNoComparator); |
| 587 | 594 | ScheduleRealInfo sch = null; |
| 588 | 595 | for(ScheduleRealInfo temp : list){ |
| ... | ... | @@ -612,4 +619,8 @@ public class DayOfSchedule implements CommandLineRunner { |
| 612 | 619 | nbbmScheduleMap.remove(sch.getClZbh(), sch); |
| 613 | 620 | return sch; |
| 614 | 621 | } |
| 622 | + | |
| 623 | + public Set<String> allCar(){ | |
| 624 | + return nbbmScheduleMap.keySet(); | |
| 625 | + } | |
| 615 | 626 | } | ... | ... |
src/main/java/com/bsth/entity/directive/Directive.java
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
| ... | ... | @@ -14,8 +14,6 @@ import org.apache.commons.lang3.StringUtils; |
| 14 | 14 | import org.slf4j.Logger; |
| 15 | 15 | import org.slf4j.LoggerFactory; |
| 16 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | -import org.springframework.data.domain.Page; | |
| 18 | -import org.springframework.data.domain.PageRequest; | |
| 19 | 17 | import org.springframework.stereotype.Service; |
| 20 | 18 | |
| 21 | 19 | import com.alibaba.fastjson.JSON; |
| ... | ... | @@ -32,12 +30,8 @@ import com.bsth.data.schedule.DayOfSchedule; |
| 32 | 30 | import com.bsth.entity.directive.D60; |
| 33 | 31 | import com.bsth.entity.directive.D64; |
| 34 | 32 | import com.bsth.entity.directive.D80; |
| 35 | -import com.bsth.entity.directive.DC0; | |
| 36 | -import com.bsth.entity.directive.D64.D64Data; | |
| 37 | -import com.bsth.entity.directive.DC0.DC0Data; | |
| 38 | 33 | import com.bsth.entity.directive.Directive; |
| 39 | 34 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 40 | -import com.bsth.entity.search.CustomerSpecs; | |
| 41 | 35 | import com.bsth.entity.sys.SysUser; |
| 42 | 36 | import com.bsth.repository.directive.D60Repository; |
| 43 | 37 | import com.bsth.repository.directive.D64Repository; |
| ... | ... | @@ -129,16 +123,24 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 129 | 123 | logger.error("生成调度指令时出现异常", e); |
| 130 | 124 | return -1; |
| 131 | 125 | } |
| 132 | - | |
| 126 | + | |
| 133 | 127 | if (null == d60) |
| 134 | 128 | return -1; |
| 135 | 129 | |
| 136 | 130 | d60.setSender(sender); |
| 137 | - | |
| 131 | + | |
| 132 | + JSONObject jObj = JSON.parseObject(JSON.toJSONString(d60)); | |
| 133 | + | |
| 134 | + //进场或者出场班次时,附加lock 标识 | |
| 135 | + if(null != sch.getBcType() | |
| 136 | + && (sch.getBcType().equals("out") || sch.getBcType().equals("in"))){ | |
| 137 | + | |
| 138 | + jObj.put("lock", 1); | |
| 139 | + } | |
| 140 | + | |
| 138 | 141 | // 发送指令 |
| 139 | - int code = GatewayHttpUtils.postJson(JSON.toJSONString(d60)); | |
| 142 | + int code = GatewayHttpUtils.postJson(jObj.toJSONString()); | |
| 140 | 143 | |
| 141 | - sch.setDirectiveState(60); | |
| 142 | 144 | // 添加到缓存,等待入库 |
| 143 | 145 | d60.setDispatch(true); |
| 144 | 146 | d60.setSch(sch); |
| ... | ... | @@ -146,9 +148,11 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen |
| 146 | 148 | dayOfDirectives.put60(d60); |
| 147 | 149 | |
| 148 | 150 | if (code == 0) { |
| 149 | - // 通知页面,消息已发出 | |
| 151 | + sch.setDirectiveState(60); | |
| 152 | + // 通知页面 | |
| 150 | 153 | sendD60ToPage(sch); |
| 151 | - } else { | |
| 154 | + } | |
| 155 | + else{ | |
| 152 | 156 | d60.setErrorText("网关通讯失败, code: " + code); |
| 153 | 157 | d60Repository.save(d60); |
| 154 | 158 | } | ... | ... |
src/main/resources/fatso/start.js
| ... | ... | @@ -37,9 +37,9 @@ fs.mkdir(dest, function(e){ |
| 37 | 37 | var cProcess; |
| 38 | 38 | |
| 39 | 39 | ep.tail('mvn-clean',function(){ |
| 40 | - ep.emit('copy-project'); | |
| 40 | + //ep.emit('copy-project'); | |
| 41 | 41 | //清理target |
| 42 | - /*logInfo('mvn clean...'); | |
| 42 | + logInfo('mvn clean...'); | |
| 43 | 43 | cProcess = child_process.exec("mvn clean",{cwd: workspace + '\\' + pName},function(error){ |
| 44 | 44 | if(error) |
| 45 | 45 | logError(error); |
| ... | ... | @@ -47,7 +47,7 @@ ep.tail('mvn-clean',function(){ |
| 47 | 47 | logSuccess('mvn clean success'); |
| 48 | 48 | |
| 49 | 49 | ep.emit('copy-project'); |
| 50 | - });*/ | |
| 50 | + }); | |
| 51 | 51 | output(cProcess); |
| 52 | 52 | }); |
| 53 | 53 | ... | ... |
src/main/resources/logback.xml
| ... | ... | @@ -58,6 +58,33 @@ |
| 58 | 58 | <appender-ref ref="ACCESS" /> |
| 59 | 59 | </logger> |
| 60 | 60 | |
| 61 | + <!-- 和网关通讯日志日志 --> | |
| 62 | + <appender name="GATEWAY" | |
| 63 | + class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
| 64 | + <file>${LOG_BASE}/gateway/gateway.log</file> | |
| 65 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
| 66 | + <fileNamePattern>${LOG_BASE}/gateway/gateway-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
| 67 | + <timeBasedFileNamingAndTriggeringPolicy | |
| 68 | + class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | |
| 69 | + <maxFileSize>100MB</maxFileSize> | |
| 70 | + </timeBasedFileNamingAndTriggeringPolicy> | |
| 71 | + </rollingPolicy> | |
| 72 | + | |
| 73 | + <layout class="ch.qos.logback.classic.PatternLayout"> | |
| 74 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%file:%line] %-5level -%msg%n | |
| 75 | + </pattern> | |
| 76 | + </layout> | |
| 77 | + </appender> | |
| 78 | + <logger name="com.bsth.service.directive.DirectiveServiceImpl" level="INFO" additivity="false" > | |
| 79 | + <appender-ref ref="GATEWAY" /> | |
| 80 | + </logger> | |
| 81 | + <logger name="com.bsth.controller.directive.UpstreamEntrance" level="INFO" additivity="false" > | |
| 82 | + <appender-ref ref="GATEWAY" /> | |
| 83 | + </logger> | |
| 84 | + <logger name="com.bsth.data.directive.GatewayHttpUtils" level="INFO" additivity="false" > | |
| 85 | + <appender-ref ref="GATEWAY" /> | |
| 86 | + </logger> | |
| 87 | + | |
| 61 | 88 | |
| 62 | 89 | <!-- 日志输出级别 --> |
| 63 | 90 | <root level="info"> | ... | ... |
src/main/resources/static/pages/control/line/child_pages/historyDirective.html
| ... | ... | @@ -44,11 +44,11 @@ |
| 44 | 44 | <td>{{item.timeHHmm}}</td> |
| 45 | 45 | <td>{{item.nbbm}}</td> |
| 46 | 46 | <td> |
| 47 | - <div class="text-furl"> | |
| 47 | + <div class="text-furl" title="{{item.data.txtContent}}"> | |
| 48 | 48 | {{item.data.txtContent}} |
| 49 | 49 | </div> |
| 50 | 50 | </td> |
| 51 | - <td>{{item.sender}}</td> | |
| 51 | + <td>{{item.sender}}{{if item.event != null}}<span class="device_event_str">{{item.event}}</span>{{/if}}</td> | |
| 52 | 52 | <td> |
| 53 | 53 | {{if item.errorText != null}} |
| 54 | 54 | <span class="label label-sm label-danger">{{item.errorText}}</span> |
| ... | ... | @@ -102,6 +102,13 @@ |
| 102 | 102 | params.size = pSize; |
| 103 | 103 | |
| 104 | 104 | $.get('/directive/list', params, function(rs){ |
| 105 | + $.each(rs.list, function(i, e){ | |
| 106 | + if(e.sender && e.sender.indexOf('@') != -1){ | |
| 107 | + var ss = e.sender.split('@'); | |
| 108 | + e.sender = ss[1]; | |
| 109 | + e.event = ss[0]; | |
| 110 | + } | |
| 111 | + }); | |
| 105 | 112 | |
| 106 | 113 | var htmlStr = template('history_directive_list_temp', rs); |
| 107 | 114 | $table.find('tbody').html(htmlStr); | ... | ... |
src/main/resources/static/pages/control/line/css/lineControl.css
| ... | ... | @@ -2565,4 +2565,10 @@ tr.linjia td:nth-child(1):AFTER { |
| 2565 | 2565 | padding: 1px 3px 1px 3px; |
| 2566 | 2566 | background: #e7505a; |
| 2567 | 2567 | border-radius: 15px; |
| 2568 | +} | |
| 2569 | + | |
| 2570 | +.device_event_str{ | |
| 2571 | + font-size: 10px; | |
| 2572 | + color: #bdbdbd; | |
| 2573 | + margin-left: 3px; | |
| 2568 | 2574 | } |
| 2569 | 2575 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/control/line/index.html
| ... | ... | @@ -228,8 +228,8 @@ function countDown(name){ |
| 228 | 228 | |
| 229 | 229 | <script> |
| 230 | 230 | var updateLog = { |
| 231 | - text: '<div class="updete_log"><p>1、调整停车场进出场算法。</p><p>2、临加班车可被删除,前提是还没有下发调度指令(即使下发失败)。</p><p class="font-red">注意:进出场班次必须按照起点站划分上下行,起点发出则上行,终点发出为下行,否则该班次将不会有发车时间。</p></div>' | |
| 232 | - ,title: '2016年8月26号凌晨更新日志' | |
| 231 | + text: '<div class="updete_log"><p>1、当出场班次没有计划里程时,系统将下发下一个营运班次指令。</p><p>2、如果首班出场“待发时间”前3分钟没有收到驾驶员出场请求,系统将自动下发调度指令。</p></div>' | |
| 232 | + ,title: '2016年8月27号凌晨更新日志' | |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | var lineCodes = '' //全部线路编码字符串,由data.js初始化 | ... | ... |
src/main/resources/static/pages/control/line/js/home.js
| ... | ... | @@ -87,14 +87,14 @@ var _home = (function() { |
| 87 | 87 | |
| 88 | 88 | setTimeout(function() { |
| 89 | 89 | // 提示文本 |
| 90 | - var promptFlag = storage.getItem('promptFlag_08251'); | |
| 90 | + var promptFlag = storage.getItem('promptFlag_0827'); | |
| 91 | 91 | if (!promptFlag) { |
| 92 | 92 | layer.alert(updateLog.text, { |
| 93 | 93 | title: updateLog.title, |
| 94 | - area: ['490px', '320px'], | |
| 94 | + area: ['410px', '250px'], | |
| 95 | 95 | shift : 5 |
| 96 | 96 | }); |
| 97 | - storage.setItem('promptFlag_08251', 1); | |
| 97 | + storage.setItem('promptFlag_0827', 1); | |
| 98 | 98 | } |
| 99 | 99 | }, 1500); |
| 100 | 100 | } | ... | ... |
src/main/resources/static/pages/control/line/js/toolbarEvent.js
| ... | ... | @@ -20,7 +20,7 @@ var _toolbarEvent = (function(){ |
| 20 | 20 | $.get('/pages/control/line/child_pages/historyDirective.html', function(content){ |
| 21 | 21 | layer.open({ |
| 22 | 22 | type: 1, |
| 23 | - area: '930px', | |
| 23 | + area: '980px', | |
| 24 | 24 | content: content, |
| 25 | 25 | title : false, |
| 26 | 26 | shift: 5, |
| ... | ... | @@ -64,7 +64,7 @@ var _toolbarEvent = (function(){ |
| 64 | 64 | $('#updateLogLink').on('click', function(){ |
| 65 | 65 | layer.alert(updateLog.text, { |
| 66 | 66 | title: updateLog.title, |
| 67 | - area: ['490px', '320px'], | |
| 67 | + area: ['410px', '250px'], | |
| 68 | 68 | shift : 5 |
| 69 | 69 | }); |
| 70 | 70 | }); | ... | ... |
src/main/resources/static/pages/mapmonitor/real/js/map/iMap.js
| ... | ... | @@ -55,7 +55,7 @@ var iMap = (function(){ |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | //绘制车辆icon |
| 58 | - function createCarIcon(gps){ | |
| 58 | + function createCarIcon(gps, w){ | |
| 59 | 59 | var canvas = $('<canvas></canvas>')[0]; |
| 60 | 60 | var ctx = canvas.getContext('2d'); |
| 61 | 61 | |
| ... | ... | @@ -67,7 +67,10 @@ var iMap = (function(){ |
| 67 | 67 | ctx.shadowColor = colours.shadow; // 颜色 |
| 68 | 68 | |
| 69 | 69 | //绘制背景 |
| 70 | - ctx.roundRect(0, 0, 70, 25, 5).stroke(); | |
| 70 | + if(!w) | |
| 71 | + w = 70; | |
| 72 | + | |
| 73 | + ctx.roundRect(0, 0, w, 25, 5).stroke(); | |
| 71 | 74 | ctx.fillStyle=colours.bgColor; |
| 72 | 75 | ctx.fill(); |
| 73 | 76 | //文字 | ... | ... |
src/main/resources/static/pages/mapmonitor/real/js/map/platform/baidu.js
| ... | ... | @@ -175,9 +175,13 @@ var baiduMap = (function(){ |
| 175 | 175 | enableMessage:true |
| 176 | 176 | }; |
| 177 | 177 | function createBDMarkerByGps(gpsData){ |
| 178 | + | |
| 178 | 179 | var point = new BMap.Point(gpsData.bd_lon, gpsData.bd_lat); |
| 179 | - var marker = new BMap.Marker(point/*, {offset: new BMap.Size(-35,-12)}*/); | |
| 180 | - marker.setIcon(new BMap.Icon(iMap.createCarIcon(gpsData), new BMap.Size(70,25))); | |
| 180 | + var marker = new BMap.Marker(point); | |
| 181 | + | |
| 182 | + //根据编码长度 计算marker 宽度 | |
| 183 | + var w = gpsData.nbbm.length * 10; | |
| 184 | + marker.setIcon(new BMap.Icon(iMap.createCarIcon(gpsData, w), new BMap.Size(w,25))); | |
| 181 | 185 | |
| 182 | 186 | marker.infoWindow = new BMap.InfoWindow(bd_gps_info_win_opts); |
| 183 | 187 | marker.gpsData = gpsData; |
| ... | ... | @@ -218,7 +222,9 @@ var baiduMap = (function(){ |
| 218 | 222 | m.setPosition(new BMap.Point(gps.bd_lon, gps.bd_lat)); |
| 219 | 223 | m.gpsData = gps; |
| 220 | 224 | //重新设置icon |
| 221 | - m.setIcon(new BMap.Icon(iMap.createCarIcon(gps), new BMap.Size(70,25))); | |
| 225 | + //根据编码长度 计算marker 宽度 | |
| 226 | + var w = gps.nbbm.length * 10; | |
| 227 | + m.setIcon(new BMap.Icon(iMap.createCarIcon(gps, w), new BMap.Size(w,25))); | |
| 222 | 228 | |
| 223 | 229 | //更新 infoWindow |
| 224 | 230 | if(m.infoWindow.isOpen()){ | ... | ... |
src/main/resources/static/pages/mapmonitor/real/js/map/platform/gaode.js
| ... | ... | @@ -150,12 +150,15 @@ var gaodeMap = (function() { |
| 150 | 150 | return gaodeInstance; |
| 151 | 151 | |
| 152 | 152 | function createGDMarkerByGps(gps){ |
| 153 | + //根据编码长度 计算marker 宽度 | |
| 154 | + var w = gps.nbbm.length * 10; | |
| 155 | + | |
| 153 | 156 | var marker = new AMap.Marker({ |
| 154 | 157 | map: map, |
| 155 | 158 | position: [gps.gcj_lon, gps.gcj_lat], |
| 156 | 159 | icon: new AMap.Icon({ |
| 157 | - size: new AMap.Size(70, 25), //图标大小 | |
| 158 | - image: iMap.createCarIcon(gps) | |
| 160 | + size: new AMap.Size(w, 25), //图标大小 | |
| 161 | + image: iMap.createCarIcon(gps, w) | |
| 159 | 162 | }), |
| 160 | 163 | offset: new AMap.Pixel(-35, -12) |
| 161 | 164 | }); |
| ... | ... | @@ -179,9 +182,11 @@ var gaodeMap = (function() { |
| 179 | 182 | m.setPosition(new AMap.LngLat(gps.gcj_lon, gps.gcj_lat)); |
| 180 | 183 | m.gpsData = gps; |
| 181 | 184 | //重新设置icon |
| 185 | + //根据编码长度 计算marker 宽度 | |
| 186 | + var w = gps.nbbm.length * 10; | |
| 182 | 187 | m.setIcon(new AMap.Icon({ |
| 183 | - size: new AMap.Size(70, 25), | |
| 184 | - image: iMap.createCarIcon(gps) | |
| 188 | + size: new AMap.Size(w, 25), | |
| 189 | + image: iMap.createCarIcon(gps, w) | |
| 185 | 190 | })); |
| 186 | 191 | |
| 187 | 192 | if(m.infoWindow.getIsOpen()) | ... | ... |