Commit f4fbc36d5563b8ed716890275c4361938f42c7d1

Authored by 潘钊
1 parent 64ffcea9

update

src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -797,6 +797,7 @@ public class DayOfSchedule {
797 797  
798 798 public void save(ScheduleRealInfo sch) {
799 799 //schRepository.save(sch);
  800 + sch.setUpdateDate(new Date());
800 801 pstBuffer.add(sch);
801 802 }
802 803  
... ...
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
1 1 package com.bsth.data.schedule.thread;
2 2  
  3 +import com.alibaba.fastjson.JSON;
3 4 import com.bsth.data.schedule.DayOfSchedule;
4 5 import com.bsth.entity.realcontrol.ScheduleRealInfo;
5 6 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
6 7 import org.slf4j.Logger;
7 8 import org.slf4j.LoggerFactory;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9   -import org.springframework.orm.jpa.JpaObjectRetrievalFailureException;
  10 +import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
  11 +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
10 12 import org.springframework.stereotype.Component;
11 13  
12   -import javax.persistence.EntityNotFoundException;
13   -
14 14 /**
15 15 * @author PanZhao
16 16 * @ClassName: SchedulePstThread
... ... @@ -23,36 +23,68 @@ public class SchedulePstThread extends Thread {
23 23 @Autowired
24 24 ScheduleRealInfoRepository scheduleRepository;
25 25  
  26 + @Autowired
  27 + NamedParameterJdbcTemplate jdbcTemplate;
  28 +
  29 + @Autowired
  30 + DayOfSchedule dayOfSchedule;
  31 +
26 32 Logger logger = LoggerFactory.getLogger(this.getClass());
27 33  
28 34 @Override
29 35 public void run() {
30 36  
31   - //LinkedList<ScheduleRealInfo> list = DayOfSchedule.pstBuffer;
32   -
33 37 ScheduleRealInfo schedule;
34 38 for (int i = 0; i < 1000; i++) {
35 39 schedule = DayOfSchedule.pstBuffer.poll();
36 40 if (null == schedule)
37 41 break;
38 42  
39   - if(schedule.isDeleted()){
  43 + if (schedule.isDeleted()) {
40 44 logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId());
41 45 continue;
42 46 }
43 47  
44   - try {
45   - scheduleRepository.save(schedule);
46   - }
47   - catch (JpaObjectRetrievalFailureException e1){
48   - logger.error("JpaObjectRetrievalFailureException error.... 可忽略");
49   - }
50   - catch(EntityNotFoundException e2){
51   - logger.error("EntityNotFoundException error.... 可忽略");
52   - }
53   - catch (Exception e) {
54   - logger.error("班次入库的时候出现未知异常!!", e);
55   - }
  48 + save(schedule);
  49 + }
  50 + }
  51 +
  52 + /**
  53 + * 班次更新到数据库,不走jpa
  54 + *
  55 + * @param sch
  56 + */
  57 + public void save(ScheduleRealInfo sch) {
  58 + if (sch.getId() == null) {
  59 + logger.error("入库的班次没有ID, " + JSON.toJSONString(sch));
  60 + return;
  61 + }
  62 +
  63 + if(sch.getSaveFailCount() > 5){
  64 + logger.error("入库失败上限, " + JSON.toJSONString(sch));
  65 + return;
  66 + }
  67 +
  68 + try {
  69 + String sql = "UPDATE bsth_c_s_sp_info_real" +
  70 + " SET adjust_exps=:adjustExps, bc_type=:bcType, bcs=:bcs, bcsj=:bcsj, ccno=:ccno, cl_zbh=:clZbh, df_auto=:dfAuto," +
  71 + " dfsj=:dfsj, directive_state=:directiveState, fcno=:fcno, fcsj=:fcsj, fcsj_actual=:fcsjActual, fgs_bm=:fgsBm, fgs_name=:fgsName, gs_bm=:gsBm, gs_name=:gsName," +
  72 + " j_gh=:jGh, j_name=:jName, jhlc=:jhlc, jhlc_orig=:jhlcOrig, lp_name=:lpName, ONLINE=:online, qdz_code=:qdzCode, qdz_name=:qdzName," +
  73 + " real_exec_date=:realExecDate, reissue=:reissue, remarks=:remarks, s_gh=:sGh, s_name=:sName, schedule_date=:scheduleDate," +
  74 + " schedule_date_str=:scheduleDateStr, sflj=:sflj, sp_id=:spId, STATUS=:status, update_date=:updateDate, xl_bm=:xlBm, xl_dir=:xlDir, xl_name=:xlName," +
  75 + " zdsj=:zdsj, zdsj_actual=:zdsjActual, zdz_code=:zdzCode, zdz_name=:zdzName" +
  76 + " WHERE " +
  77 + " id=:id";
  78 +
  79 + jdbcTemplate.update(sql, new BeanPropertySqlParameterSource(sch));
  80 + sch.setSaveFailCount(0);
  81 + } catch (Exception e) {
  82 + //下次入库再试
  83 + sch.setSaveFailCount(sch.getSaveFailCount()+1);
  84 + dayOfSchedule.save(sch);
  85 +
  86 + logger.error("班次 " + sch.getId() + "入库失败," + JSON.toJSONString(sch));
  87 + logger.error("", e);
56 88 }
57 89 }
58 90 }
... ...
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
... ... @@ -30,8 +30,9 @@ public class ScheduleRealInfo {
30 30 /** 计划ID */
31 31 private Long spId;
32 32  
33   - /** 排班计划日期 */
  33 + /** 排班计划日期 --no webSocket */
34 34 private Date scheduleDate;
  35 + /** 排班日期字符串 YYYY-MM-DD */
35 36 private String scheduleDateStr;
36 37  
37 38 /** 真实执行时间 yyyy-MM-dd */
... ... @@ -81,9 +82,9 @@ public class ScheduleRealInfo {
81 82 @Transient
82 83 private Long zdsjT;
83 84  
84   - /** 发车顺序号 */
  85 + /** 发车顺序号 --no webSocket*/
85 86 private Integer fcno;
86   - /** 对应班次数 */
  87 + /** 对应班次数 --no webSocket*/
87 88 private Integer bcs;
88 89 /** 计划里程 */
89 90 private Double jhlc;
... ... @@ -91,10 +92,12 @@ public class ScheduleRealInfo {
91 92 /** 原始计划里程 (原计调的数据) */
92 93 private Double jhlcOrig;
93 94  
94   - /** 实际里程 这个字段被废弃*/
  95 + /** 实际里程 --no webSocket*/
  96 + @Transient
  97 + @JsonIgnore
95 98 private Double realMileage;
96 99  
97   - /** 实际里程 */
  100 + /** 实际里程 --no webSocket */
98 101 @Transient
99 102 private String sjlc;
100 103 /** 班次历时 */
... ... @@ -153,7 +156,8 @@ public class ScheduleRealInfo {
153 156 /** 备注*/
154 157 private String remarks;
155 158  
156   - /** 原计划排班备注 */
  159 + /** 原计划排班备注 --no webSocket */
  160 + @Transient
157 161 private String remark;
158 162  
159 163 /**待发时间(格式 HH:mm) */
... ... @@ -166,9 +170,6 @@ public class ScheduleRealInfo {
166 170 /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */
167 171 private Integer directiveState = -1;
168 172  
169   - /** “运营状态” 指令下发状态 60: 已发送, 100: 设备确认收到 0:失败*/
170   - private Integer opDirectiveState;
171   -
172 173 /** 起点站计划到达时间 */
173 174 @Transient
174 175 private String qdzArrDatejh;
... ... @@ -200,7 +201,7 @@ public class ScheduleRealInfo {
200 201 /** 是否有补发GPS信号 */
201 202 private boolean reissue;
202 203  
203   - /** 发车屏 发车顺序号,不持久化,会动态变化 */
  204 + /** 发车屏 发车顺序号,不持久化,会动态变化 --no webSocket*/
204 205 @Transient
205 206 private int fcpSn;
206 207  
... ... @@ -209,6 +210,10 @@ public class ScheduleRealInfo {
209 210 @JsonIgnore
210 211 private boolean deleted;
211 212  
  213 + @Transient
  214 + @JsonIgnore
  215 + private int saveFailCount=0;
  216 +
212 217 public boolean isDfAuto() {
213 218 return dfAuto;
214 219 }
... ... @@ -486,7 +491,7 @@ public class ScheduleRealInfo {
486 491 if(this.isSflj())
487 492 this.setJhlcOrig(this.getJhlc());
488 493 }
489   -
  494 +
490 495 public String getSjlc() {
491 496 return sjlc;
492 497 }
... ... @@ -816,22 +821,6 @@ public class ScheduleRealInfo {
816 821 calcStatus();
817 822 }
818 823  
819   - public Integer getOpDirectiveState() {
820   - return opDirectiveState;
821   - }
822   -
823   - public void setOpDirectiveState(Integer opDirectiveState) {
824   - this.opDirectiveState = opDirectiveState;
825   - }
826   -
827   -/* public ScheduleRealInfo getTwinsSch() {
828   - return twinsSch;
829   - }
830   -
831   - public void setTwinsSch(ScheduleRealInfo twinsSch) {
832   - this.twinsSch = twinsSch;
833   - }*/
834   -
835 824 public boolean isLate() {
836 825 return late;
837 826 }
... ... @@ -925,4 +914,12 @@ public class ScheduleRealInfo {
925 914 public void setDeleted(boolean deleted) {
926 915 this.deleted = deleted;
927 916 }
  917 +
  918 + public int getSaveFailCount() {
  919 + return saveFailCount;
  920 + }
  921 +
  922 + public void setSaveFailCount(int saveFailCount) {
  923 + this.saveFailCount = saveFailCount;
  924 + }
928 925 }
... ...
src/main/resources/static/real_control_v2/js/main.js
... ... @@ -169,8 +169,8 @@ var disabled_submit_btn = function (form) {
169 169 function showUpdateDescription() {
170 170 //更新说明
171 171 var updateDescription = {
172   - date: '2017-07-17',
173   - text: '<h5>1、修复了一个蛮蠢的bug,这个bug曾经导致在分班进场班次发出晚20分钟的时候,有一定几率实发时间跳到下午首班营运班次上。</h5>'
  172 + date: '2017-07-21',
  173 + text: '<h5>1、修复一个蛮严肃的问题,这个问题有极低的概率导致个别班次的操作不会同步到路单!!!</h5>'
174 174 };
175 175  
176 176 var storage = window.localStorage
... ...