Commit 75a6161a5bd99093c267abff09ed6fd3642b42ff

Authored by 潘钊
1 parent 0ea46b62

update...

src/main/java/com/bsth/Application.java
... ... @@ -17,7 +17,7 @@ import java.util.concurrent.ScheduledExecutorService;
17 17 @SpringBootApplication
18 18 public class Application extends SpringBootServletInitializer {
19 19  
20   - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(15);
  20 + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(16);
21 21  
22 22 @Override
23 23 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
... ...
src/main/java/com/bsth/XDApplication.java
... ... @@ -11,6 +11,7 @@ import com.bsth.data.msg_queue.DirectivePushQueue;
11 11 import com.bsth.data.msg_queue.WebSocketPushQueue;
12 12 import com.bsth.data.schedule.edit_logs.SeiPstThread;
13 13 import com.bsth.data.schedule.late_adjust.ScheduleLateThread;
  14 +import com.bsth.data.schedule.signal.SchSiginUpdateDBThread;
14 15 import com.bsth.data.schedule.thread.CalcOilThread;
15 16 import com.bsth.data.schedule.thread.SchedulePstThread;
16 17 import com.bsth.data.schedule.thread.ScheduleRefreshThread;
... ... @@ -61,6 +62,7 @@ public class XDApplication implements CommandLineRunner {
61 62 SeiPstThread seiPstThread;
62 63 @Autowired
63 64 SampleTimeDataLoader sampleTimeDataLoader;
  65 + SchSiginUpdateDBThread schSiginUpdateDBThread;
64 66  
65 67 private static long timeDiff;
66 68 private static long timeDiffTraffic;
... ... @@ -140,8 +142,7 @@ public class XDApplication implements CommandLineRunner {
140 142 sexec.scheduleWithFixedDelay(fcxxUpdateThread, 60, 40, TimeUnit.SECONDS);//发车信息(发车屏、信息发布)
141 143 //线路首末班数据(网关用,班次更新时写入)
142 144 //com.bsth.data.schedule.f_a_l.FirstAndLastHandler
143   - //靠GPS信号无法自动完成的班次信息(网关用,补信号)
144   -
  145 + sexec.scheduleWithFixedDelay(schSiginUpdateDBThread, 60, 60 * 30, TimeUnit.SECONDS);//无法自动完成的班次信息(网关用,补信号)
145 146  
146 147 //运管处静态数据提交
147 148 log.info(timeDiff / 1000 / 60 + "分钟之后提交到运管处");
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
... ... @@ -163,6 +163,7 @@ public class InOutStationSignalHandle extends SignalHandle{
163 163  
164 164 //实发时间
165 165 sch.setFcsjActualAll(rsT);
  166 + sch.setSiginCompate(1);
166 167 //通知客户端
167 168 sendUtils.sendFcsj(sch);
168 169 //持久化
... ... @@ -316,7 +317,7 @@ public class InOutStationSignalHandle extends SignalHandle{
316 317 long rsT = lineConfigData.applyIn(sch, gps.getTimestamp());
317 318  
318 319 sch.setZdsjActualAll(rsT);
319   -
  320 + sch.setSiginCompate(2);
320 321 //通知误点停靠程序,有车辆到站
321 322 LateAdjustHandle.carArrive(gps);
322 323  
... ...
src/main/java/com/bsth/data/schedule/signal/SchSiginUpdateDBThread.java 0 → 100644
  1 +package com.bsth.data.schedule.signal;
  2 +
  3 +import org.slf4j.Logger;
  4 +import org.slf4j.LoggerFactory;
  5 +import org.springframework.stereotype.Component;
  6 +
  7 +/**
  8 + * Created by panzhao on 2017/8/14.
  9 + */
  10 +@Component
  11 +public class SchSiginUpdateDBThread extends Thread{
  12 +
  13 + SignalComplateHandler signalComplateHandler;
  14 +
  15 + Logger logger = LoggerFactory.getLogger(this.getClass());
  16 +
  17 + @Override
  18 + public void run() {
  19 + try{
  20 + signalComplateHandler.handler();
  21 + }catch (Exception e){
  22 + logger.error("", e);
  23 + }
  24 + }
  25 +}
... ...
src/main/java/com/bsth/data/schedule/signal/SignalComplateHandler.java 0 → 100644
  1 +package com.bsth.data.schedule.signal;
  2 +
  3 +import com.bsth.data.schedule.DayOfSchedule;
  4 +import com.bsth.data.schedule.signal.entity.SchSiginCompate;
  5 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import com.bsth.util.db.DBUtils_MS;
  7 +import org.apache.commons.lang3.StringUtils;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  12 +import org.springframework.jdbc.core.JdbcTemplate;
  13 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
  14 +import org.springframework.stereotype.Component;
  15 +import org.springframework.transaction.TransactionDefinition;
  16 +import org.springframework.transaction.TransactionStatus;
  17 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  18 +
  19 +import java.sql.PreparedStatement;
  20 +import java.sql.SQLException;
  21 +import java.util.ArrayList;
  22 +import java.util.Collection;
  23 +import java.util.Date;
  24 +import java.util.List;
  25 +
  26 +/**
  27 + * 班次信号补全(写入数据库,网关以补发的形式提交运管处)
  28 + * Created by panzhao on 2017/8/13.
  29 + */
  30 +@Component
  31 +public class SignalComplateHandler {
  32 +
  33 + @Autowired
  34 + DayOfSchedule dayOfSchedule;
  35 +
  36 + Logger log = LoggerFactory.getLogger(this.getClass());
  37 +
  38 + public void handler(){
  39 + Collection<ScheduleRealInfo> all = dayOfSchedule.findAll();
  40 + List<SchSiginCompate> list = new ArrayList<>();
  41 +
  42 + SchSiginCompate siginCompate;
  43 + Date d = new Date();
  44 + long et = System.currentTimeMillis() - (1000 * 60 * 60 * 2),
  45 + st = et - (1000 * 60 * 60 * 2);
  46 + for(ScheduleRealInfo sch : all){
  47 + if(sch.getDfsjT() > et || sch.getDfsjT() < st)
  48 + continue;
  49 +
  50 + //能自动完成的
  51 + if(sch.getSiginCompate() >= 2)
  52 + continue;
  53 +
  54 + //烂班
  55 + if(sch.isDestroy())
  56 + continue;
  57 +
  58 + //空驶任务
  59 + if(dayOfSchedule.emptyService(sch))
  60 + continue;
  61 +
  62 + siginCompate = new SchSiginCompate(sch);
  63 + if(siginCompate == null || StringUtils.isEmpty(siginCompate.getDeciveId()))
  64 + continue;
  65 +
  66 + //标记已经补发
  67 + sch.setSiginCompate(3);
  68 + siginCompate.setCreateDate(d);
  69 + list.add(siginCompate);
  70 + }
  71 +
  72 + put(list);
  73 + }
  74 +
  75 + public void put(final List<SchSiginCompate> list){
  76 + if(null == list || list.size() == 0)
  77 + return;
  78 +
  79 + JdbcTemplate jdbcTemp = new JdbcTemplate(DBUtils_MS.getDataSource());
  80 + //编程式事务
  81 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemp.getDataSource());
  82 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  83 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  84 + TransactionStatus status = tran.getTransaction(def);
  85 +
  86 + try{
  87 + jdbcTemp.batchUpdate("insert into bsth_t_sigin_complate(id, rq, line_code, decive_id, up_down, s_code, e_code, st, et, create_date, status) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
  88 + @Override
  89 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  90 + SchSiginCompate sc = list.get(i);
  91 + ps.setLong(1, sc.getId());
  92 + ps.setString(2, sc.getRq());
  93 + ps.setString(3, sc.getLineCode());
  94 + ps.setString(4, sc.getDeciveId());
  95 + ps.setInt(5, sc.getUpDown());
  96 + ps.setString(6, sc.getsCode());
  97 + ps.setString(7, sc.geteCode());
  98 + ps.setLong(8, sc.getSt());
  99 + ps.setLong(9, sc.getEt());
  100 + ps.setDate(10, new java.sql.Date(sc.getCreateDate().getTime()));
  101 + ps.setInt(11, sc.getStatus());
  102 + }
  103 +
  104 + @Override
  105 + public int getBatchSize() {
  106 + return list.size();
  107 + }
  108 + });
  109 +
  110 + tran.commit(status);
  111 + log.info("补信号班次入库," + list.size());
  112 + }catch (Exception e){
  113 + log.error("", e);
  114 + tran.rollback(status);
  115 + }
  116 + }
  117 +
  118 +
  119 +}
... ...
src/main/java/com/bsth/data/schedule/signal/entity/SchSiginCompate.java 0 → 100644
  1 +package com.bsth.data.schedule.signal.entity;
  2 +
  3 +import com.bsth.data.BasicData;
  4 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  5 +
  6 +import java.util.Date;
  7 +
  8 +/**
  9 + * 班次信号补偿
  10 + * Created by panzhao on 2017/8/13.
  11 + */
  12 +public class SchSiginCompate {
  13 +
  14 + /** 实际班次ID */
  15 + private long id;
  16 +
  17 + /** 班次日期 */
  18 + private String rq;
  19 +
  20 + /** 线路编码 */
  21 + private String lineCode;
  22 +
  23 + /** 设备号 */
  24 + private String deciveId;
  25 +
  26 + /** 上下行 */
  27 + private int upDown;
  28 +
  29 + /** 起始站编码 */
  30 + private String sCode;
  31 +
  32 + /** 终点站编码 */
  33 + private String eCode;
  34 +
  35 + /** 开始时间戳 */
  36 + private long st;
  37 +
  38 + /** 结束时间戳 */
  39 + private long et;
  40 +
  41 + /** 入库时间 */
  42 + private Date createDate;
  43 +
  44 + private int status = 0;
  45 +
  46 + public SchSiginCompate(ScheduleRealInfo sch) {
  47 + this.id = sch.getId();
  48 + this.rq = sch.getScheduleDateStr();
  49 + this.lineCode = sch.getXlBm();
  50 + this.upDown = Integer.parseInt(sch.getXlDir());
  51 + this.deciveId = BasicData.deviceId2NbbmMap.inverse().get(sch.getClZbh());
  52 + this.sCode = sch.getQdzCode();
  53 + this.eCode = sch.getZdzCode();
  54 + this.st = sch.getDfsjT();
  55 + this.et = sch.getZdsjT();
  56 +
  57 + if(sch.getFcsjActualTime() != null)
  58 + this.st = sch.getFcsjActualTime();
  59 + if(sch.getZdsjActualTime() != null)
  60 + this.et = sch.getZdsjActualTime();
  61 + }
  62 +
  63 + public long getId() {
  64 + return id;
  65 + }
  66 +
  67 + public void setId(long id) {
  68 + this.id = id;
  69 + }
  70 +
  71 + public String getRq() {
  72 + return rq;
  73 + }
  74 +
  75 + public void setRq(String rq) {
  76 + this.rq = rq;
  77 + }
  78 +
  79 + public String getLineCode() {
  80 + return lineCode;
  81 + }
  82 +
  83 + public void setLineCode(String lineCode) {
  84 + this.lineCode = lineCode;
  85 + }
  86 +
  87 + public String getDeciveId() {
  88 + return deciveId;
  89 + }
  90 +
  91 + public void setDeciveId(String deciveId) {
  92 + this.deciveId = deciveId;
  93 + }
  94 +
  95 + public int getUpDown() {
  96 + return upDown;
  97 + }
  98 +
  99 + public void setUpDown(int upDown) {
  100 + this.upDown = upDown;
  101 + }
  102 +
  103 + public String getsCode() {
  104 + return sCode;
  105 + }
  106 +
  107 + public void setsCode(String sCode) {
  108 + this.sCode = sCode;
  109 + }
  110 +
  111 + public String geteCode() {
  112 + return eCode;
  113 + }
  114 +
  115 + public void seteCode(String eCode) {
  116 + this.eCode = eCode;
  117 + }
  118 +
  119 + public long getSt() {
  120 + return st;
  121 + }
  122 +
  123 + public void setSt(long st) {
  124 + this.st = st;
  125 + }
  126 +
  127 + public long getEt() {
  128 + return et;
  129 + }
  130 +
  131 + public void setEt(long et) {
  132 + this.et = et;
  133 + }
  134 +
  135 + public Date getCreateDate() {
  136 + return createDate;
  137 + }
  138 +
  139 + public void setCreateDate(Date createDate) {
  140 + this.createDate = createDate;
  141 + }
  142 +
  143 + public int getStatus() {
  144 + return status;
  145 + }
  146 +
  147 + public void setStatus(int status) {
  148 + this.status = status;
  149 + }
  150 +}
... ...
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
... ... @@ -214,6 +214,9 @@ public class ScheduleRealInfo {
214 214 @JsonIgnore
215 215 private int saveFailCount=0;
216 216  
  217 + /** 是否需要补充GPS信号 (网关提交至运管处动态数据用) 1: 能发车, 2:能到达 3: 补发过*/
  218 + private int siginCompate;
  219 +
217 220 public boolean isDfAuto() {
218 221 return dfAuto;
219 222 }
... ... @@ -303,10 +306,10 @@ public class ScheduleRealInfo {
303 306 String old = this.getRemarks();
304 307 if(StringUtils.isBlank(old))
305 308 old = "";
306   -
  309 +
307 310 old += remark + ";";
308 311 this.setRemarks(old);
309   -
  312 +
310 313 }
311 314  
312 315 public Long getId() {
... ... @@ -622,12 +625,12 @@ public class ScheduleRealInfo {
622 625 this.dfsjT = dfsjT;
623 626 this.dfsj = fmtHHmm.print(this.dfsjT);
624 627 }
625   -
  628 +
626 629 public void setDfsjAll(String dfsj) {
627 630 this.dfsjT = fmtyyyyMMddHHmm.parseMillis(this.realExecDate + dfsj);
628 631 this.dfsj = dfsj;
629 632 }
630   -
  633 +
631 634 public void calcEndTime(){
632 635 //计划终点时间
633 636 if(this.getBcsj() != null){
... ... @@ -665,33 +668,33 @@ public class ScheduleRealInfo {
665 668 public void setSflj(boolean sflj) {
666 669 this.sflj = sflj;
667 670 }
668   -
  671 +
669 672 /**
670   - *
671   - * @Title: setFcsjAll
672   - * @Description: TODO(设置计划发车时间)
  673 + *
  674 + * @Title: setFcsjAll
  675 + * @Description: TODO(设置计划发车时间)
673 676 * @throws
674 677 */
675 678 public void setFcsjAll(String fcsj){
676 679 this.fcsjT = fmtyyyyMMddHHmm.parseMillis(this.realExecDate + fcsj);
677 680 this.fcsj = fcsj;
678 681 }
679   -
  682 +
680 683 /**
681   - *
682   - * @Title: setFcsjAll
683   - * @Description: TODO(设置计划发车时间)
  684 + *
  685 + * @Title: setFcsjAll
  686 + * @Description: TODO(设置计划发车时间)
684 687 * @throws
685 688 */
686 689 public void setFcsjAll(Long fcsjT){
687 690 this.fcsjT = fcsjT;
688 691 this.fcsj = fmtHHmm.print(fcsjT);
689 692 }
690   -
  693 +
691 694 /**
692   - *
693   - * @Title: setFcsjActualAll
694   - * @Description: TODO(设置实际发车时间 字符串)
  695 + *
  696 + * @Title: setFcsjActualAll
  697 + * @Description: TODO(设置实际发车时间 字符串)
695 698 * @throws
696 699 */
697 700 public void setFcsjActualAll(String fcsjActual){
... ... @@ -699,11 +702,11 @@ public class ScheduleRealInfo {
699 702 this.fcsjActual = fcsjActual;
700 703 calcStatus();
701 704 }
702   -
  705 +
703 706 /**
704   - *
705   - * @Title: setFcsjActualAll
706   - * @Description: TODO(设置实际发车时间 时间戳)
  707 + *
  708 + * @Title: setFcsjActualAll
  709 + * @Description: TODO(设置实际发车时间 时间戳)
707 710 * @throws
708 711 */
709 712 public void setFcsjActualAll(Long t){
... ... @@ -713,25 +716,25 @@ public class ScheduleRealInfo {
713 716 //更新班次状态
714 717 calcStatus();
715 718 }
716   -
  719 +
717 720 /**
718   - *
719   - * @Title: setFcsjActualAll
720   - * @Description: TODO(设置实际终点时间)
  721 + *
  722 + * @Title: setFcsjActualAll
  723 + * @Description: TODO(设置实际终点时间)
721 724 * @throws
722 725 */
723 726 public void setZdsjActualAll(Long t){
724 727 this.zdsjActualTime = t;
725 728 this.zdsjActual = fmtHHmm.print(t);
726   -
  729 +
727 730 //更新班次状态
728 731 calcStatus();
729 732 }
730   -
  733 +
731 734 /**
732   - *
733   - * @Title: setFcsjActualAll
734   - * @Description: TODO(设置实际终点时间)
  735 + *
  736 + * @Title: setFcsjActualAll
  737 + * @Description: TODO(设置实际终点时间)
735 738 * @throws
736 739 */
737 740 public void setZdsjActualAll(String zdsjActual){
... ... @@ -740,7 +743,7 @@ public class ScheduleRealInfo {
740 743  
741 744 calcStatus();
742 745 }
743   -
  746 +
744 747 public Long getSpId() {
745 748 return spId;
746 749 }
... ... @@ -760,11 +763,11 @@ public class ScheduleRealInfo {
760 763 public void calcStatus() {
761 764 if(this.status == -1)
762 765 return;
763   -
  766 +
764 767 this.status = 0;
765 768 if(StringUtils.isNotBlank(this.fcsjActual)){
766 769 this.status = 1;
767   -
  770 +
768 771 //进出场班次并且没有计划里程的
769 772 if((this.bcType.equals("out") || this.bcType.equals("in"))
770 773 && this.jhlc == null){
... ... @@ -774,7 +777,7 @@ public class ScheduleRealInfo {
774 777 if(StringUtils.isNotBlank(this.zdsjActual))
775 778 this.status = 2;
776 779 }
777   -
  780 +
778 781 public void destroy(){
779 782 this.jhlc = 0.0;
780 783 if(this.isSflj())
... ... @@ -782,11 +785,11 @@ public class ScheduleRealInfo {
782 785 this.status = -1;
783 786 this.clearFcsjActual();
784 787 }
785   -
  788 +
786 789 public boolean isDestroy(){
787 790 return this.status == -1;
788 791 }
789   -
  792 +
790 793 /* public boolean isNotDestroy(){
791 794 return this.status != -1;
792 795 }*/
... ... @@ -806,18 +809,18 @@ public class ScheduleRealInfo {
806 809 public void setScheduleDateStr(String scheduleDateStr) {
807 810 this.scheduleDateStr = scheduleDateStr;
808 811 }
809   -
  812 +
810 813 public void clearFcsjActual(){
811 814 this.setFcsjActual(null);
812 815 this.setFcsjActualTime(null);
813 816 this.calcStatus();
814 817 }
815   -
  818 +
816 819 //清除实际终点时间
817 820 public void clearZdsjActual(){
818 821 this.setZdsjActual(null);
819 822 this.setZdsjActualTime(null);
820   -
  823 +
821 824 calcStatus();
822 825 }
823 826  
... ... @@ -922,4 +925,12 @@ public class ScheduleRealInfo {
922 925 public void setSaveFailCount(int saveFailCount) {
923 926 this.saveFailCount = saveFailCount;
924 927 }
  928 +
  929 + public int getSiginCompate() {
  930 + return siginCompate;
  931 + }
  932 +
  933 + public void setSiginCompate(int siginCompate) {
  934 + this.siginCompate = siginCompate;
  935 + }
925 936 }
... ...
src/main/resources/static/pages/summary/work_hours/list.html
... ... @@ -263,8 +263,8 @@
263 263 }
264 264  
265 265 //日期选择器
266   - $('[name=rq_eq]', f).val('2017-07-31');
267   - flatpickr('.ct_search_form_wrap [name=rq_eq]', {"locale": "zh", maxDate: '2017-07-31', minDate: '2017-07-01'});
  266 + $('[name=rq_eq]', f).val('2017-08-03');
  267 + flatpickr('.ct_search_form_wrap [name=rq_eq]', {"locale": "zh", maxDate: '2017-08-03', minDate: '2017-07-01'});
268 268  
269 269 var comps;
270 270 //构建公司级联下拉框
... ...