Commit ef08a72428e4157b7a12c831986c141a723701a5

Authored by 潘钊
1 parent 2f13ff0f

尝试精简websocket 传输...

src/main/java/com/bsth/websocket/dto/WsScheduleRealInfo.java 0 → 100644
  1 +package com.bsth.websocket.dto;
  2 +
  3 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  4 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  5 +
  6 +import javax.persistence.FetchType;
  7 +import javax.persistence.OneToMany;
  8 +import javax.persistence.Transient;
  9 +import java.util.ArrayList;
  10 +import java.util.HashSet;
  11 +import java.util.List;
  12 +import java.util.Set;
  13 +
  14 +/**
  15 + * 精简字段的实际排班 entity
  16 + * webSocket 传输用,去掉了页面不需要的一些字段
  17 + * Created by panzhao on 2017/11/14.
  18 + */
  19 +public class WsScheduleRealInfo {
  20 +
  21 + public static WsScheduleRealInfo getInstance(ScheduleRealInfo sch){
  22 + if(null == sch)
  23 + return null;
  24 + WsScheduleRealInfo wss = new WsScheduleRealInfo();
  25 + wss.id = sch.getId();
  26 + wss.scheduleDateStr = sch.getScheduleDateStr();
  27 + wss.realExecDate = sch.getRealExecDate();
  28 + wss.xlName = sch.getXlName();
  29 + wss.xlBm = sch.getXlBm();
  30 + wss.lpName = sch.getLpName();
  31 + wss.clZbh = sch.getClZbh();
  32 + wss.jGh = sch.getjGh();
  33 + wss.jName = sch.getjName();
  34 + wss.sGh = sch.getsGh();
  35 + wss.sName = sch.getsName();
  36 + wss.xlDir = sch.getXlDir();
  37 + wss.qdzCode = sch.getQdzCode();
  38 + wss.qdzName = sch.getQdzName();
  39 + wss.zdzCode = sch.getZdzCode();
  40 + wss.zdzName = sch.getZdzName();
  41 + wss.fcsj = sch.getFcsj();
  42 + wss.fcsjT = sch.getFcsjT();
  43 + wss.zdsj = sch.getZdsj();
  44 + wss.zdsjT = sch.getZdsjT();
  45 + wss.jhlc = sch.getJhlc();
  46 + wss.jhlcOrig = sch.getJhlcOrig();
  47 + wss.bcsj = sch.getBcsj();
  48 + wss.bcType = sch.getBcType();
  49 + wss.majorStationName = sch.getMajorStationName();
  50 + wss.fcsjActual = sch.getFcsjActual();
  51 + wss.fcsjActualTime = sch.getFcsjActualTime();
  52 + wss.zdsjActual = sch.getZdsjActual();
  53 + wss.zdsjActualTime = sch.getZdsjActualTime();
  54 + wss.status = sch.getStatus();
  55 + wss.adjustExps = sch.getAdjustExps();
  56 + wss.sflj = sch.isSflj();
  57 + wss.late = sch.isLate();
  58 + wss.late2 = sch.isLate2();
  59 + wss.lateMinute = sch.getLateMinute();
  60 + wss.remarks = sch.getRemarks();
  61 + wss.dfsj = sch.getDfsj();
  62 + wss.dfsjT = sch.getDfsjT();
  63 + wss.directiveState = sch.getDirectiveState();
  64 + wss.qdzArrDatejh = sch.getQdzArrDatejh();
  65 + wss.qdzArrDatesj = sch.getQdzArrDatesj();
  66 + wss.cTasks = sch.getcTasks();
  67 + wss.gsName = sch.getGsName();
  68 + wss.gsBm = sch.getGsBm();
  69 + wss.fgsName = sch.getFgsName();
  70 + wss.fgsBm = sch.getFgsBm();
  71 + wss.ccService = sch.isCcService();
  72 + return wss;
  73 + }
  74 +
  75 +
  76 + public static List<WsScheduleRealInfo> getMultiInstance(List<ScheduleRealInfo> list){
  77 + List<WsScheduleRealInfo> rs = new ArrayList<>();
  78 + for(ScheduleRealInfo sch : list){
  79 + rs.add(getInstance(sch));
  80 + }
  81 + return rs;
  82 + }
  83 +
  84 + /** 主键Id */
  85 + private Long id;
  86 +
  87 + /** 排班日期字符串 YYYY-MM-DD */
  88 + private String scheduleDateStr;
  89 +
  90 + /** 真实执行时间 yyyy-MM-dd */
  91 + private String realExecDate;
  92 +
  93 + /** 线路名称 */
  94 + private String xlName;
  95 + /** 线路编码 */
  96 + private String xlBm;
  97 +
  98 + /** 路牌名称 */
  99 + private String lpName;
  100 +
  101 + /** 车辆自编号 */
  102 + private String clZbh;
  103 +
  104 + /** 驾驶员工号 */
  105 + private String jGh;
  106 + /** 驾驶员名字 */
  107 + private String jName;
  108 + /** 售票员工号 */
  109 + private String sGh;
  110 + /** 售票员名字 */
  111 + private String sName;
  112 +
  113 + /** 线路方向 */
  114 + private String xlDir;
  115 + /** 起点站code*/
  116 + private String qdzCode;
  117 + /** 起点站名字 */
  118 + private String qdzName;
  119 +
  120 + /** 终点站code*/
  121 + private String zdzCode;
  122 + /** 终点站名字 */
  123 + private String zdzName;
  124 +
  125 + /** 计划发车时间(格式 HH:mm) */
  126 + private String fcsj;
  127 + /** 计划发车时间戳*/
  128 + @Transient
  129 + private Long fcsjT;
  130 +
  131 + /** 计划终点时间(格式 HH:mm) */
  132 + private String zdsj;
  133 + /** 计划终点时间戳*/
  134 + @Transient
  135 + private Long zdsjT;
  136 +
  137 + /** 计划里程 */
  138 + private Double jhlc;
  139 +
  140 + /** 原始计划里程 (原计调的数据) */
  141 + private Double jhlcOrig;
  142 + /** 班次历时 */
  143 + private Integer bcsj;
  144 +
  145 + /**
  146 + * 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶
  147 + */
  148 + private String bcType;
  149 +
  150 + //放站班次 站点名称
  151 + private String majorStationName;
  152 +
  153 + /** 实际发车时间*/
  154 + private String fcsjActual;
  155 + /** 实际发车时间戳*/
  156 + @Transient
  157 + private Long fcsjActualTime;
  158 + /**实际终点时间 */
  159 + private String zdsjActual;
  160 + /** 实际终点时间戳*/
  161 + @Transient
  162 + private Long zdsjActualTime;
  163 +
  164 + /**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */
  165 + private int status;
  166 +
  167 + private String adjustExps;
  168 +
  169 + /** 是否是临加班次 */
  170 + private boolean sflj;
  171 +
  172 + /** 是否误点 (应发未发)*/
  173 + @Transient
  174 + private boolean late;
  175 +
  176 + /** 是否误点 (应发未到) */
  177 + @Transient
  178 + private boolean late2;
  179 + /** 误点停靠时间 */
  180 + @Transient
  181 + private float lateMinute;
  182 +
  183 + /** 备注*/
  184 + private String remarks;
  185 +
  186 + /**待发时间(格式 HH:mm) */
  187 + private String dfsj;
  188 +
  189 + /**待发时间戳 */
  190 + @Transient
  191 + private Long dfsjT;
  192 +
  193 + /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */
  194 + private Integer directiveState = -1;
  195 +
  196 + /** 起点站计划到达时间 */
  197 + @Transient
  198 + private String qdzArrDatejh;
  199 +
  200 + /** 起点站实际到达时间 */
  201 + @Transient
  202 + private String qdzArrDatesj;
  203 +
  204 + /** 子任务 */
  205 + @OneToMany(fetch = FetchType.LAZY, mappedBy = "schedule")
  206 + private Set<ChildTaskPlan> cTasks = new HashSet<>();
  207 +
  208 + /** 关联的公司名称 */
  209 + private String gsName;
  210 + /** 关联的公司编码 */
  211 + private String gsBm;
  212 + /** 关联的分公司名称 */
  213 + private String fgsName;
  214 + /** 关联的分公司编码 */
  215 + private String fgsBm;
  216 +
  217 + /**
  218 + * 换车营运标记 true 表示该主任务由 【中途换车子任务】 级联生成
  219 + */
  220 + private boolean ccService;
  221 +
  222 + public Long getId() {
  223 + return id;
  224 + }
  225 +
  226 + public void setId(Long id) {
  227 + this.id = id;
  228 + }
  229 +
  230 + public String getScheduleDateStr() {
  231 + return scheduleDateStr;
  232 + }
  233 +
  234 + public void setScheduleDateStr(String scheduleDateStr) {
  235 + this.scheduleDateStr = scheduleDateStr;
  236 + }
  237 +
  238 + public String getRealExecDate() {
  239 + return realExecDate;
  240 + }
  241 +
  242 + public void setRealExecDate(String realExecDate) {
  243 + this.realExecDate = realExecDate;
  244 + }
  245 +
  246 + public String getXlName() {
  247 + return xlName;
  248 + }
  249 +
  250 + public void setXlName(String xlName) {
  251 + this.xlName = xlName;
  252 + }
  253 +
  254 + public String getXlBm() {
  255 + return xlBm;
  256 + }
  257 +
  258 + public void setXlBm(String xlBm) {
  259 + this.xlBm = xlBm;
  260 + }
  261 +
  262 + public String getLpName() {
  263 + return lpName;
  264 + }
  265 +
  266 + public void setLpName(String lpName) {
  267 + this.lpName = lpName;
  268 + }
  269 +
  270 + public String getClZbh() {
  271 + return clZbh;
  272 + }
  273 +
  274 + public void setClZbh(String clZbh) {
  275 + this.clZbh = clZbh;
  276 + }
  277 +
  278 + public String getjGh() {
  279 + return jGh;
  280 + }
  281 +
  282 + public void setjGh(String jGh) {
  283 + this.jGh = jGh;
  284 + }
  285 +
  286 + public String getjName() {
  287 + return jName;
  288 + }
  289 +
  290 + public void setjName(String jName) {
  291 + this.jName = jName;
  292 + }
  293 +
  294 + public String getsGh() {
  295 + return sGh;
  296 + }
  297 +
  298 + public void setsGh(String sGh) {
  299 + this.sGh = sGh;
  300 + }
  301 +
  302 + public String getsName() {
  303 + return sName;
  304 + }
  305 +
  306 + public void setsName(String sName) {
  307 + this.sName = sName;
  308 + }
  309 +
  310 + public String getXlDir() {
  311 + return xlDir;
  312 + }
  313 +
  314 + public void setXlDir(String xlDir) {
  315 + this.xlDir = xlDir;
  316 + }
  317 +
  318 + public String getQdzCode() {
  319 + return qdzCode;
  320 + }
  321 +
  322 + public void setQdzCode(String qdzCode) {
  323 + this.qdzCode = qdzCode;
  324 + }
  325 +
  326 + public String getQdzName() {
  327 + return qdzName;
  328 + }
  329 +
  330 + public void setQdzName(String qdzName) {
  331 + this.qdzName = qdzName;
  332 + }
  333 +
  334 + public String getZdzCode() {
  335 + return zdzCode;
  336 + }
  337 +
  338 + public void setZdzCode(String zdzCode) {
  339 + this.zdzCode = zdzCode;
  340 + }
  341 +
  342 + public String getZdzName() {
  343 + return zdzName;
  344 + }
  345 +
  346 + public void setZdzName(String zdzName) {
  347 + this.zdzName = zdzName;
  348 + }
  349 +
  350 + public String getFcsj() {
  351 + return fcsj;
  352 + }
  353 +
  354 + public void setFcsj(String fcsj) {
  355 + this.fcsj = fcsj;
  356 + }
  357 +
  358 + public Long getFcsjT() {
  359 + return fcsjT;
  360 + }
  361 +
  362 + public void setFcsjT(Long fcsjT) {
  363 + this.fcsjT = fcsjT;
  364 + }
  365 +
  366 + public String getZdsj() {
  367 + return zdsj;
  368 + }
  369 +
  370 + public void setZdsj(String zdsj) {
  371 + this.zdsj = zdsj;
  372 + }
  373 +
  374 + public Long getZdsjT() {
  375 + return zdsjT;
  376 + }
  377 +
  378 + public void setZdsjT(Long zdsjT) {
  379 + this.zdsjT = zdsjT;
  380 + }
  381 +
  382 + public Double getJhlc() {
  383 + return jhlc;
  384 + }
  385 +
  386 + public void setJhlc(Double jhlc) {
  387 + this.jhlc = jhlc;
  388 + }
  389 +
  390 + public Double getJhlcOrig() {
  391 + return jhlcOrig;
  392 + }
  393 +
  394 + public void setJhlcOrig(Double jhlcOrig) {
  395 + this.jhlcOrig = jhlcOrig;
  396 + }
  397 +
  398 + public Integer getBcsj() {
  399 + return bcsj;
  400 + }
  401 +
  402 + public void setBcsj(Integer bcsj) {
  403 + this.bcsj = bcsj;
  404 + }
  405 +
  406 + public String getBcType() {
  407 + return bcType;
  408 + }
  409 +
  410 + public void setBcType(String bcType) {
  411 + this.bcType = bcType;
  412 + }
  413 +
  414 + public String getMajorStationName() {
  415 + return majorStationName;
  416 + }
  417 +
  418 + public void setMajorStationName(String majorStationName) {
  419 + this.majorStationName = majorStationName;
  420 + }
  421 +
  422 + public String getFcsjActual() {
  423 + return fcsjActual;
  424 + }
  425 +
  426 + public void setFcsjActual(String fcsjActual) {
  427 + this.fcsjActual = fcsjActual;
  428 + }
  429 +
  430 + public Long getFcsjActualTime() {
  431 + return fcsjActualTime;
  432 + }
  433 +
  434 + public void setFcsjActualTime(Long fcsjActualTime) {
  435 + this.fcsjActualTime = fcsjActualTime;
  436 + }
  437 +
  438 + public String getZdsjActual() {
  439 + return zdsjActual;
  440 + }
  441 +
  442 + public void setZdsjActual(String zdsjActual) {
  443 + this.zdsjActual = zdsjActual;
  444 + }
  445 +
  446 + public Long getZdsjActualTime() {
  447 + return zdsjActualTime;
  448 + }
  449 +
  450 + public void setZdsjActualTime(Long zdsjActualTime) {
  451 + this.zdsjActualTime = zdsjActualTime;
  452 + }
  453 +
  454 + public int getStatus() {
  455 + return status;
  456 + }
  457 +
  458 + public void setStatus(int status) {
  459 + this.status = status;
  460 + }
  461 +
  462 + public String getAdjustExps() {
  463 + return adjustExps;
  464 + }
  465 +
  466 + public void setAdjustExps(String adjustExps) {
  467 + this.adjustExps = adjustExps;
  468 + }
  469 +
  470 + public boolean isSflj() {
  471 + return sflj;
  472 + }
  473 +
  474 + public void setSflj(boolean sflj) {
  475 + this.sflj = sflj;
  476 + }
  477 +
  478 + public boolean isLate() {
  479 + return late;
  480 + }
  481 +
  482 + public void setLate(boolean late) {
  483 + this.late = late;
  484 + }
  485 +
  486 + public boolean isLate2() {
  487 + return late2;
  488 + }
  489 +
  490 + public void setLate2(boolean late2) {
  491 + this.late2 = late2;
  492 + }
  493 +
  494 + public float getLateMinute() {
  495 + return lateMinute;
  496 + }
  497 +
  498 + public void setLateMinute(float lateMinute) {
  499 + this.lateMinute = lateMinute;
  500 + }
  501 +
  502 + public String getRemarks() {
  503 + return remarks;
  504 + }
  505 +
  506 + public void setRemarks(String remarks) {
  507 + this.remarks = remarks;
  508 + }
  509 +
  510 + public String getDfsj() {
  511 + return dfsj;
  512 + }
  513 +
  514 + public void setDfsj(String dfsj) {
  515 + this.dfsj = dfsj;
  516 + }
  517 +
  518 + public Long getDfsjT() {
  519 + return dfsjT;
  520 + }
  521 +
  522 + public void setDfsjT(Long dfsjT) {
  523 + this.dfsjT = dfsjT;
  524 + }
  525 +
  526 + public Integer getDirectiveState() {
  527 + return directiveState;
  528 + }
  529 +
  530 + public void setDirectiveState(Integer directiveState) {
  531 + this.directiveState = directiveState;
  532 + }
  533 +
  534 + public String getQdzArrDatejh() {
  535 + return qdzArrDatejh;
  536 + }
  537 +
  538 + public void setQdzArrDatejh(String qdzArrDatejh) {
  539 + this.qdzArrDatejh = qdzArrDatejh;
  540 + }
  541 +
  542 + public String getQdzArrDatesj() {
  543 + return qdzArrDatesj;
  544 + }
  545 +
  546 + public void setQdzArrDatesj(String qdzArrDatesj) {
  547 + this.qdzArrDatesj = qdzArrDatesj;
  548 + }
  549 +
  550 + public Set<ChildTaskPlan> getcTasks() {
  551 + return cTasks;
  552 + }
  553 +
  554 + public void setcTasks(Set<ChildTaskPlan> cTasks) {
  555 + this.cTasks = cTasks;
  556 + }
  557 +
  558 + public String getGsName() {
  559 + return gsName;
  560 + }
  561 +
  562 + public void setGsName(String gsName) {
  563 + this.gsName = gsName;
  564 + }
  565 +
  566 + public String getGsBm() {
  567 + return gsBm;
  568 + }
  569 +
  570 + public void setGsBm(String gsBm) {
  571 + this.gsBm = gsBm;
  572 + }
  573 +
  574 + public String getFgsName() {
  575 + return fgsName;
  576 + }
  577 +
  578 + public void setFgsName(String fgsName) {
  579 + this.fgsName = fgsName;
  580 + }
  581 +
  582 + public String getFgsBm() {
  583 + return fgsBm;
  584 + }
  585 +
  586 + public void setFgsBm(String fgsBm) {
  587 + this.fgsBm = fgsBm;
  588 + }
  589 +
  590 + public boolean isCcService() {
  591 + return ccService;
  592 + }
  593 +
  594 + public void setCcService(boolean ccService) {
  595 + this.ccService = ccService;
  596 + }
  597 +}
src/main/java/com/bsth/websocket/handler/SendUtils.java
@@ -7,6 +7,7 @@ import com.bsth.data.gpsdata_v2.entity.GpsEntity; @@ -7,6 +7,7 @@ import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7 import com.bsth.data.safe_driv.SafeDriv; 7 import com.bsth.data.safe_driv.SafeDriv;
8 import com.bsth.entity.directive.D80; 8 import com.bsth.entity.directive.D80;
9 import com.bsth.entity.realcontrol.ScheduleRealInfo; 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  10 +import com.bsth.websocket.dto.WsScheduleRealInfo;
10 import com.fasterxml.jackson.core.JsonProcessingException; 11 import com.fasterxml.jackson.core.JsonProcessingException;
11 import com.fasterxml.jackson.databind.ObjectMapper; 12 import com.fasterxml.jackson.databind.ObjectMapper;
12 import org.slf4j.Logger; 13 import org.slf4j.Logger;
@@ -38,7 +39,7 @@ public class SendUtils{ @@ -38,7 +39,7 @@ public class SendUtils{
38 39
39 Map<String, Object> map = new HashMap<>(); 40 Map<String, Object> map = new HashMap<>();
40 map.put("fn", "faChe"); 41 map.put("fn", "faChe");
41 - map.put("t", sch); 42 + map.put("t", WsScheduleRealInfo.getInstance(sch));
42 map.put("dataStr", sdf.format(new Date())); 43 map.put("dataStr", sdf.format(new Date()));
43 44
44 ObjectMapper mapper = new ObjectMapper(); 45 ObjectMapper mapper = new ObjectMapper();
@@ -62,7 +63,7 @@ public class SendUtils{ @@ -62,7 +63,7 @@ public class SendUtils{
62 63
63 Map<String, Object> map = new HashMap<>(); 64 Map<String, Object> map = new HashMap<>();
64 map.put("fn", "refreshSch"); 65 map.put("fn", "refreshSch");
65 - map.put("ts", list); 66 + map.put("ts", WsScheduleRealInfo.getMultiInstance(list));
66 67
67 ObjectMapper mapper = new ObjectMapper(); 68 ObjectMapper mapper = new ObjectMapper();
68 69
@@ -82,8 +83,8 @@ public class SendUtils{ @@ -82,8 +83,8 @@ public class SendUtils{
82 83
83 Map<String, Object> map = new HashMap<>(); 84 Map<String, Object> map = new HashMap<>();
84 map.put("fn", "zhongDian"); 85 map.put("fn", "zhongDian");
85 - map.put("t", sch);  
86 - map.put("nt", nextSch); 86 + map.put("t", WsScheduleRealInfo.getInstance(sch));
  87 + map.put("nt", WsScheduleRealInfo.getInstance(nextSch));
87 map.put("finish", finish); 88 map.put("finish", finish);
88 map.put("dataStr", sdf.format(new Date())); 89 map.put("dataStr", sdf.format(new Date()));
89 90
@@ -123,7 +124,7 @@ public class SendUtils{ @@ -123,7 +124,7 @@ public class SendUtils{
123 124
124 Map<String, Object> map = new HashMap<>(); 125 Map<String, Object> map = new HashMap<>();
125 map.put("fn", "directive"); 126 map.put("fn", "directive");
126 - map.put("t", sch);; 127 + map.put("t", WsScheduleRealInfo.getInstance(sch));;
127 128
128 ObjectMapper mapper = new ObjectMapper(); 129 ObjectMapper mapper = new ObjectMapper();
129 130