Commit 359a20d97711523c409859dc305d6b0f4df7f5b7

Authored by 潘钊
2 parents e7d1bcc1 81e670d2

update...

Too many changes to show.

To preserve performance only 12 of 42 files are displayed.

src/main/java/com/bsth/controller/report/ReportController.java
@@ -269,9 +269,11 @@ public class ReportController { @@ -269,9 +269,11 @@ public class ReportController {
269 269
270 @RequestMapping(value="/countBusMileage") 270 @RequestMapping(value="/countBusMileage")
271 public List<Map<String,Object>> countBusMileage(@RequestParam Map<String, Object> map){ 271 public List<Map<String,Object>> countBusMileage(@RequestParam Map<String, Object> map){
272 -  
273 return service.countByBusList(map); 272 return service.countByBusList(map);
274 } 273 }
275 274
276 - 275 + @RequestMapping(value="/countDjg")
  276 + public List<Map<String, Object>> countDjg(@RequestParam Map<String, Object> map){
  277 + return service.countDjg(map);
  278 + }
277 } 279 }
src/main/java/com/bsth/data/gpsdata/arrival/utils/SignalSchPlanMatcher.java
@@ -40,8 +40,8 @@ public class SignalSchPlanMatcher { @@ -40,8 +40,8 @@ public class SignalSchPlanMatcher {
40 return; 40 return;
41 41
42 long dt = fbFirst.getDfsjT(); 42 long dt = fbFirst.getDfsjT();
43 - //前5后10 -执行分班的首个营运  
44 - if(dt - t < 1000 * 60 * 5 || t - dt < 1000 * 60 * 10){ 43 + //晚于待发前4分钟 -执行分班的首个营运
  44 + if(dt - t < 1000 * 60 * 4){
45 dayOfSchedule.addExecPlan(fbFirst); 45 dayOfSchedule.addExecPlan(fbFirst);
46 return; 46 return;
47 } 47 }
src/main/java/com/bsth/data/gpsdata/status_manager/GpsStatusManager.java
1 -package com.bsth.data.gpsdata.status_manager;  
2 -  
3 -import com.bsth.Application;  
4 -import com.bsth.data.gpsdata.status_manager.gps_line_state.LineStateHandle;  
5 -import com.bsth.data.gpsdata.status_manager.gps_service_state.ServiceStateHandle;  
6 -import org.springframework.beans.factory.annotation.Autowired;  
7 -import org.springframework.boot.CommandLineRunner;  
8 -import org.springframework.stereotype.Component;  
9 -  
10 -import java.util.concurrent.TimeUnit;  
11 -  
12 -/**  
13 - * GPS 状态管理  
14 - * Created by panzhao on 2017/7/13.  
15 - */  
16 -@Component  
17 -public class GpsStatusManager implements CommandLineRunner {  
18 -  
19 - @Autowired  
20 - StatusCheckThread checkThread;  
21 -  
22 - @Autowired  
23 - LineStateHandle lineStateHandle;  
24 -  
25 - @Autowired  
26 - ServiceStateHandle serviceStateHandle;  
27 -  
28 - /**  
29 - * 切换线路  
30 - * @param nbbm  
31 - * @param lineCode  
32 - * @param sender  
33 - */  
34 - public void changeLine(String nbbm, String lineCode, String sender){  
35 - lineStateHandle.changeLine(nbbm, lineCode, sender);  
36 - }  
37 -  
38 - /**  
39 - * 切换营运状态  
40 - * @param nbbm  
41 - * @param state 0 营运, 1:非营运  
42 - * @param sender  
43 - */  
44 - public void changeServiceState(String nbbm, String upDown,int state, String sender){  
45 - changeServiceState(nbbm, Integer.parseInt(upDown), state, sender);  
46 - }  
47 -  
48 - /**  
49 - * 切换营运状态  
50 - * @param nbbm  
51 - * @param state 0 营运, 1:非营运  
52 - * @param sender  
53 - */  
54 - public void changeServiceState(String nbbm, int upDown,int state, String sender){  
55 - serviceStateHandle.changeState(nbbm, upDown, state, sender);  
56 - }  
57 -  
58 - @Override  
59 - public void run(String... strings) throws Exception {  
60 - Application.mainServices.scheduleWithFixedDelay(checkThread, 120, 120, TimeUnit.SECONDS);  
61 - }  
62 -  
63 - @Component  
64 - public static class StatusCheckThread extends Thread{  
65 -  
66 - @Autowired  
67 - LineStateHandle lineStateHandle;  
68 -  
69 - @Autowired  
70 - ServiceStateHandle serviceStateHandle;  
71 -  
72 - @Override  
73 - public void run() {  
74 - /** 检查线路切换结果 */  
75 - lineStateHandle.checkResultAll();  
76 - /** 检查营运状态切换结果 */  
77 - serviceStateHandle.checkResultAll();  
78 - }  
79 - }  
80 -} 1 +package com.bsth.data.gpsdata.status_manager;
  2 +
  3 +import com.bsth.Application;
  4 +import com.bsth.data.gpsdata.status_manager.gps_line_state.LineStateHandle;
  5 +import com.bsth.data.gpsdata.status_manager.gps_service_state.ServiceStateHandle;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.boot.CommandLineRunner;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +import java.util.concurrent.TimeUnit;
  11 +
  12 +/**
  13 + * GPS 状态管理
  14 + * Created by panzhao on 2017/7/13.
  15 + */
  16 +@Component
  17 +public class GpsStatusManager implements CommandLineRunner {
  18 +
  19 + @Autowired
  20 + StatusCheckThread checkThread;
  21 +
  22 + @Autowired
  23 + LineStateHandle lineStateHandle;
  24 +
  25 + @Autowired
  26 + ServiceStateHandle serviceStateHandle;
  27 +
  28 + /**
  29 + * 切换线路
  30 + * @param nbbm
  31 + * @param lineCode
  32 + * @param sender
  33 + */
  34 + public void changeLine(String nbbm, String lineCode, String sender){
  35 + lineStateHandle.changeLine(nbbm, lineCode, sender);
  36 + }
  37 +
  38 + /**
  39 + * 切换营运状态
  40 + * @param nbbm
  41 + * @param state 0 营运, 1:非营运
  42 + * @param sender
  43 + */
  44 + public void changeServiceState(String nbbm, String upDown,int state, String sender){
  45 + changeServiceState(nbbm, Integer.parseInt(upDown), state, sender);
  46 + }
  47 +
  48 + /**
  49 + * 切换营运状态
  50 + * @param nbbm
  51 + * @param state 0 营运, 1:非营运
  52 + * @param sender
  53 + */
  54 + public void changeServiceState(String nbbm, int upDown,int state, String sender){
  55 + serviceStateHandle.changeState(nbbm, upDown, state, sender);
  56 + }
  57 +
  58 + @Override
  59 + public void run(String... strings) throws Exception {
  60 + Application.mainServices.scheduleWithFixedDelay(checkThread, 120, 120, TimeUnit.SECONDS);
  61 + }
  62 +
  63 + @Component
  64 + public static class StatusCheckThread extends Thread{
  65 +
  66 + @Autowired
  67 + LineStateHandle lineStateHandle;
  68 +
  69 + @Autowired
  70 + ServiceStateHandle serviceStateHandle;
  71 +
  72 + @Override
  73 + public void run() {
  74 + /** 检查线路切换结果 */
  75 + lineStateHandle.checkResultAll();
  76 + /** 检查营运状态切换结果 */
  77 + serviceStateHandle.checkResultAll();
  78 + }
  79 + }
  80 +}
src/main/java/com/bsth/data/gpsdata/status_manager/gps_line_state/ChangeBean.java
1 -package com.bsth.data.gpsdata.status_manager.gps_line_state;  
2 -  
3 -/**  
4 - * Created by panzhao on 2017/7/13.  
5 - */  
6 -public class ChangeBean {  
7 -  
8 - /**  
9 - * 车辆自编号  
10 - */  
11 - private String nbbm;  
12 -  
13 - /**  
14 - * 要切换到的线路  
15 - */  
16 - private String lineCode;  
17 -  
18 - /**  
19 - * 指令发送次数  
20 - */  
21 - private int sendCount;  
22 -  
23 - /**  
24 - * 上次指令时间  
25 - */  
26 - private long st;  
27 -  
28 - /**发送人 */  
29 - private String sender;  
30 -  
31 - public static ChangeBean getInstance(String nbbm, String lineCode, String sender){  
32 - ChangeBean cb = new ChangeBean();  
33 - cb.setNbbm(nbbm);  
34 - cb.setLineCode(lineCode);  
35 - cb.setSendCount(0);  
36 - cb.setSender(sender);  
37 - return cb;  
38 - }  
39 -  
40 - public void countPlus(){  
41 - sendCount ++;  
42 - }  
43 -  
44 - public String getLineCode() {  
45 - return lineCode;  
46 - }  
47 -  
48 - public void setLineCode(String lineCode) {  
49 - this.lineCode = lineCode;  
50 - }  
51 -  
52 - public int getSendCount() {  
53 - return sendCount;  
54 - }  
55 -  
56 - public void setSendCount(int sendCount) {  
57 - this.sendCount = sendCount;  
58 - }  
59 -  
60 - public long getSt() {  
61 - return st;  
62 - }  
63 -  
64 - public void setSt(long st) {  
65 - this.st = st;  
66 - }  
67 -  
68 - public String getSender() {  
69 - return sender;  
70 - }  
71 -  
72 - public void setSender(String sender) {  
73 - this.sender = sender;  
74 - }  
75 -  
76 - public String getNbbm() {  
77 - return nbbm;  
78 - }  
79 -  
80 - public void setNbbm(String nbbm) {  
81 - this.nbbm = nbbm;  
82 - }  
83 -} 1 +package com.bsth.data.gpsdata.status_manager.gps_line_state;
  2 +
  3 +/**
  4 + * Created by panzhao on 2017/7/13.
  5 + */
  6 +public class ChangeBean {
  7 +
  8 + /**
  9 + * 车辆自编号
  10 + */
  11 + private String nbbm;
  12 +
  13 + /**
  14 + * 要切换到的线路
  15 + */
  16 + private String lineCode;
  17 +
  18 + /**
  19 + * 指令发送次数
  20 + */
  21 + private int sendCount;
  22 +
  23 + /**
  24 + * 上次指令时间
  25 + */
  26 + private long st;
  27 +
  28 + /**发送人 */
  29 + private String sender;
  30 +
  31 + public static ChangeBean getInstance(String nbbm, String lineCode, String sender){
  32 + ChangeBean cb = new ChangeBean();
  33 + cb.setNbbm(nbbm);
  34 + cb.setLineCode(lineCode);
  35 + cb.setSendCount(0);
  36 + cb.setSender(sender);
  37 + return cb;
  38 + }
  39 +
  40 + public void countPlus(){
  41 + sendCount ++;
  42 + }
  43 +
  44 + public String getLineCode() {
  45 + return lineCode;
  46 + }
  47 +
  48 + public void setLineCode(String lineCode) {
  49 + this.lineCode = lineCode;
  50 + }
  51 +
  52 + public int getSendCount() {
  53 + return sendCount;
  54 + }
  55 +
  56 + public void setSendCount(int sendCount) {
  57 + this.sendCount = sendCount;
  58 + }
  59 +
  60 + public long getSt() {
  61 + return st;
  62 + }
  63 +
  64 + public void setSt(long st) {
  65 + this.st = st;
  66 + }
  67 +
  68 + public String getSender() {
  69 + return sender;
  70 + }
  71 +
  72 + public void setSender(String sender) {
  73 + this.sender = sender;
  74 + }
  75 +
  76 + public String getNbbm() {
  77 + return nbbm;
  78 + }
  79 +
  80 + public void setNbbm(String nbbm) {
  81 + this.nbbm = nbbm;
  82 + }
  83 +}
src/main/java/com/bsth/data/gpsdata/status_manager/gps_line_state/LineStateHandle.java
1 -package com.bsth.data.gpsdata.status_manager.gps_line_state;  
2 -  
3 -import com.bsth.data.gpsdata.GpsEntity;  
4 -import com.bsth.data.gpsdata.GpsRealData;  
5 -import com.bsth.data.msg_queue.DirectivePushQueue;  
6 -import com.bsth.service.directive.DirectiveService;  
7 -import org.slf4j.Logger;  
8 -import org.slf4j.LoggerFactory;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.stereotype.Component;  
11 -  
12 -import java.util.Collection;  
13 -import java.util.concurrent.ConcurrentHashMap;  
14 -  
15 -/**  
16 - * 设备线路状态处理  
17 - * Created by panzhao on 2017/7/13.  
18 - */  
19 -@Component  
20 -public class LineStateHandle {  
21 -  
22 - private static ConcurrentHashMap<String, ChangeBean> map;  
23 -  
24 - @Autowired  
25 - DirectiveService directiveService;  
26 - @Autowired  
27 - GpsRealData gpsRealData;  
28 -  
29 - Logger logger = LoggerFactory.getLogger(this.getClass());  
30 -  
31 - /** 重发次数 */  
32 - private final static int MAX_SEND_COUNT=3;  
33 - /** 重发间隔 */  
34 - private final static int SEND_SPACE=1000 * 60 * 5;  
35 - /** 最大有效时间 */  
36 - private final static int MAX_AVAIL_TIME=1000 * 60 * 60 * 2;  
37 -  
38 - static{  
39 - map = new ConcurrentHashMap();  
40 - }  
41 -  
42 - public void changeLine(String nbbm, String lineCode, String sender){  
43 - ChangeBean cb = map.get(nbbm);  
44 - if(cb != null && cb.getLineCode().equals(lineCode)){  
45 - return;  
46 - }  
47 -  
48 - cb = ChangeBean.getInstance(nbbm, lineCode, sender);  
49 - map.put(nbbm, cb);  
50 -  
51 - changeLine(cb);  
52 - }  
53 -  
54 - private void changeLine(ChangeBean cb){  
55 - cb.setSt(System.currentTimeMillis());  
56 - cb.countPlus();  
57 - DirectivePushQueue.put64(cb.getNbbm(), cb.getLineCode(), cb.getSender());  
58 - }  
59 -  
60 -  
61 - public void checkResultAll(){  
62 - Collection<ChangeBean> cbs = map.values();  
63 - for(ChangeBean cb : cbs){  
64 - checkResult(cb);  
65 - }  
66 - }  
67 -  
68 - private void checkResult(ChangeBean cb){  
69 - try{  
70 - GpsEntity gps = gpsRealData.getByNbbm(cb.getNbbm());  
71 - if(gps == null)  
72 - return;  
73 -  
74 - if(cb.getLineCode().equals(gps.getLineId())){  
75 - map.remove(cb.getNbbm());  
76 - logger.info("线路切换成功," + cb.getNbbm() + "、" + cb.getLineCode());  
77 - }  
78 - else{  
79 - reSend(cb);  
80 - }  
81 - }catch (Exception e){  
82 - logger.error("", e);  
83 - }  
84 - }  
85 -  
86 - private void reSend(ChangeBean cb){  
87 - if(cb.getSendCount() >= MAX_SEND_COUNT){  
88 - map.remove(cb.getNbbm());  
89 - logger.info("超过重发次数," + cb.getNbbm() + "、" + cb.getLineCode());  
90 - return;  
91 - }  
92 -  
93 - long diff = System.currentTimeMillis() - cb.getSt();  
94 - if(diff >= MAX_AVAIL_TIME){  
95 - map.remove(cb.getNbbm());  
96 - logger.info("超过有效时间," + cb.getNbbm() + "、" + cb.getLineCode() + "、" + cb.getSt());  
97 - return;  
98 - }  
99 -  
100 - if(diff >= SEND_SPACE){  
101 - cb.setSender("补发@系统");  
102 - changeLine(cb);  
103 - logger.info("重发线路切换指令," + cb.getNbbm() + "、" + cb.getLineCode());  
104 - return;  
105 - }  
106 - }  
107 -} 1 +package com.bsth.data.gpsdata.status_manager.gps_line_state;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.GpsRealData;
  5 +import com.bsth.data.msg_queue.DirectivePushQueue;
  6 +import com.bsth.service.directive.DirectiveService;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.Collection;
  13 +import java.util.concurrent.ConcurrentHashMap;
  14 +
  15 +/**
  16 + * 设备线路状态处理
  17 + * Created by panzhao on 2017/7/13.
  18 + */
  19 +@Component
  20 +public class LineStateHandle {
  21 +
  22 + private static ConcurrentHashMap<String, ChangeBean> map;
  23 +
  24 + @Autowired
  25 + DirectiveService directiveService;
  26 + @Autowired
  27 + GpsRealData gpsRealData;
  28 +
  29 + Logger logger = LoggerFactory.getLogger(this.getClass());
  30 +
  31 + /** 重发次数 */
  32 + private final static int MAX_SEND_COUNT=3;
  33 + /** 重发间隔 */
  34 + private final static int SEND_SPACE=1000 * 60 * 5;
  35 + /** 最大有效时间 */
  36 + private final static int MAX_AVAIL_TIME=1000 * 60 * 60 * 2;
  37 +
  38 + static{
  39 + map = new ConcurrentHashMap();
  40 + }
  41 +
  42 + public void changeLine(String nbbm, String lineCode, String sender){
  43 + ChangeBean cb = map.get(nbbm);
  44 + if(cb != null && cb.getLineCode().equals(lineCode)){
  45 + return;
  46 + }
  47 +
  48 + cb = ChangeBean.getInstance(nbbm, lineCode, sender);
  49 + map.put(nbbm, cb);
  50 +
  51 + changeLine(cb);
  52 + }
  53 +
  54 + private void changeLine(ChangeBean cb){
  55 + cb.setSt(System.currentTimeMillis());
  56 + cb.countPlus();
  57 + DirectivePushQueue.put64(cb.getNbbm(), cb.getLineCode(), cb.getSender());
  58 + }
  59 +
  60 +
  61 + public void checkResultAll(){
  62 + Collection<ChangeBean> cbs = map.values();
  63 + for(ChangeBean cb : cbs){
  64 + checkResult(cb);
  65 + }
  66 + }
  67 +
  68 + private void checkResult(ChangeBean cb){
  69 + try{
  70 + GpsEntity gps = gpsRealData.getByNbbm(cb.getNbbm());
  71 + if(gps == null)
  72 + return;
  73 +
  74 + if(cb.getLineCode().equals(gps.getLineId())){
  75 + map.remove(cb.getNbbm());
  76 + logger.info("线路切换成功," + cb.getNbbm() + "、" + cb.getLineCode());
  77 + }
  78 + else{
  79 + reSend(cb);
  80 + }
  81 + }catch (Exception e){
  82 + logger.error("", e);
  83 + }
  84 + }
  85 +
  86 + private void reSend(ChangeBean cb){
  87 + if(cb.getSendCount() >= MAX_SEND_COUNT){
  88 + map.remove(cb.getNbbm());
  89 + logger.info("超过重发次数," + cb.getNbbm() + "、" + cb.getLineCode());
  90 + return;
  91 + }
  92 +
  93 + long diff = System.currentTimeMillis() - cb.getSt();
  94 + if(diff >= MAX_AVAIL_TIME){
  95 + map.remove(cb.getNbbm());
  96 + logger.info("超过有效时间," + cb.getNbbm() + "、" + cb.getLineCode() + "、" + cb.getSt());
  97 + return;
  98 + }
  99 +
  100 + if(diff >= SEND_SPACE){
  101 + cb.setSender("补发@系统");
  102 + changeLine(cb);
  103 + logger.info("重发线路切换指令," + cb.getNbbm() + "、" + cb.getLineCode());
  104 + return;
  105 + }
  106 + }
  107 +}
src/main/java/com/bsth/data/gpsdata/status_manager/gps_service_state/ServiceStateHandle.java
1 -package com.bsth.data.gpsdata.status_manager.gps_service_state;  
2 -  
3 -import com.bsth.data.gpsdata.GpsEntity;  
4 -import com.bsth.data.gpsdata.GpsRealData;  
5 -import com.bsth.data.msg_queue.DirectivePushQueue;  
6 -import com.bsth.service.directive.DirectiveService;  
7 -import org.slf4j.Logger;  
8 -import org.slf4j.LoggerFactory;  
9 -import org.springframework.beans.factory.annotation.Autowired;  
10 -import org.springframework.stereotype.Component;  
11 -  
12 -import java.util.Collection;  
13 -import java.util.concurrent.ConcurrentHashMap;  
14 -  
15 -/**  
16 - * 设备营运状态处理  
17 - * Created by panzhao on 2017/7/13.  
18 - */  
19 -@Component  
20 -public class ServiceStateHandle {  
21 -  
22 - private static ConcurrentHashMap<String, StateBean> map;  
23 -  
24 - @Autowired  
25 - DirectiveService directiveService;  
26 - @Autowired  
27 - GpsRealData gpsRealData;  
28 -  
29 - Logger logger = LoggerFactory.getLogger(this.getClass());  
30 -  
31 - /** 重发次数 */  
32 - private final static int MAX_SEND_COUNT=3;  
33 - /** 重发间隔 */  
34 - private final static int SEND_SPACE=1000 * 60 * 4;  
35 - /** 最大有效时间 */  
36 - private final static int MAX_AVAIL_TIME=1000 * 60 * 60;  
37 -  
38 - static{  
39 - map = new ConcurrentHashMap();  
40 - }  
41 -  
42 - public void changeState(String nbbm, int upDown ,int state, String sender){  
43 - if(map.containsKey(nbbm)){  
44 - return;  
45 - }  
46 - StateBean sb = StateBean.getInstance(nbbm, upDown, state, sender);  
47 - map.put(nbbm, sb);  
48 - changeState(sb);  
49 - }  
50 -  
51 - private void changeState(StateBean sb){  
52 - sb.setSt(System.currentTimeMillis());  
53 - sb.countPlus();  
54 - DirectivePushQueue.put6003(sb.getNbbm(), sb.getState(), sb.getUpDown(), sb.getSender());  
55 - }  
56 -  
57 - public void checkResultAll(){  
58 - Collection<StateBean> sbs = map.values();  
59 - for(StateBean sb : sbs){  
60 - checkResult(sb);  
61 - }  
62 - }  
63 -  
64 - private void checkResult(StateBean sb){  
65 - try{  
66 - GpsEntity gps = gpsRealData.getByNbbm(sb.getNbbm());  
67 - if(gps == null)  
68 - return;  
69 -  
70 - if(gps.getState().equals(sb.getState())){  
71 - map.remove(sb.getNbbm());  
72 - logger.info("营运状态切换成功," + sb.getNbbm() + "、" + sb.getState());  
73 - }  
74 - else  
75 - reSend(sb);  
76 - }catch (Exception e){  
77 - logger.error("", e);  
78 - }  
79 - }  
80 -  
81 - private void reSend(StateBean sb){  
82 - if(sb.getSendCount() >= MAX_SEND_COUNT){  
83 - map.remove(sb.getNbbm());  
84 - logger.info("超过重发次数," + sb.getNbbm() + "、" + sb.getState());  
85 - return;  
86 - }  
87 -  
88 - long diff = System.currentTimeMillis() - sb.getSt();  
89 - if(diff >= MAX_AVAIL_TIME){  
90 - map.remove(sb.getNbbm());  
91 - logger.info("营运状态切换超过有效时间," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getSt());  
92 - return;  
93 - }  
94 -  
95 - if(diff >= SEND_SPACE){  
96 - sb.setSender("补发@系统");  
97 - changeState(sb);  
98 - logger.info("重发营运状态切换指令," + sb.getNbbm() + "、" + sb.getState());  
99 - return;  
100 - }  
101 - }  
102 -} 1 +package com.bsth.data.gpsdata.status_manager.gps_service_state;
  2 +
  3 +import com.bsth.data.gpsdata.GpsEntity;
  4 +import com.bsth.data.gpsdata.GpsRealData;
  5 +import com.bsth.data.msg_queue.DirectivePushQueue;
  6 +import com.bsth.service.directive.DirectiveService;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import java.util.Collection;
  13 +import java.util.concurrent.ConcurrentHashMap;
  14 +
  15 +/**
  16 + * 设备营运状态处理
  17 + * Created by panzhao on 2017/7/13.
  18 + */
  19 +@Component
  20 +public class ServiceStateHandle {
  21 +
  22 + private static ConcurrentHashMap<String, StateBean> map;
  23 +
  24 + @Autowired
  25 + DirectiveService directiveService;
  26 + @Autowired
  27 + GpsRealData gpsRealData;
  28 +
  29 + Logger logger = LoggerFactory.getLogger(this.getClass());
  30 +
  31 + /** 重发次数 */
  32 + private final static int MAX_SEND_COUNT=3;
  33 + /** 重发间隔 */
  34 + private final static int SEND_SPACE=1000 * 60 * 4;
  35 + /** 最大有效时间 */
  36 + private final static int MAX_AVAIL_TIME=1000 * 60 * 60;
  37 +
  38 + static{
  39 + map = new ConcurrentHashMap();
  40 + }
  41 +
  42 + public void changeState(String nbbm, int upDown ,int state, String sender){
  43 + if(map.containsKey(nbbm)){
  44 + return;
  45 + }
  46 + StateBean sb = StateBean.getInstance(nbbm, upDown, state, sender);
  47 + map.put(nbbm, sb);
  48 + changeState(sb);
  49 + }
  50 +
  51 + private void changeState(StateBean sb){
  52 + sb.setSt(System.currentTimeMillis());
  53 + sb.countPlus();
  54 + DirectivePushQueue.put6003(sb.getNbbm(), sb.getState(), sb.getUpDown(), sb.getSender());
  55 + }
  56 +
  57 + public void checkResultAll(){
  58 + Collection<StateBean> sbs = map.values();
  59 + for(StateBean sb : sbs){
  60 + checkResult(sb);
  61 + }
  62 + }
  63 +
  64 + private void checkResult(StateBean sb){
  65 + try{
  66 + GpsEntity gps = gpsRealData.getByNbbm(sb.getNbbm());
  67 + if(gps == null)
  68 + return;
  69 +
  70 + if(gps.getState().equals(sb.getState())){
  71 + map.remove(sb.getNbbm());
  72 + logger.info("营运状态切换成功," + sb.getNbbm() + "、" + sb.getState());
  73 + }
  74 + else
  75 + reSend(sb);
  76 + }catch (Exception e){
  77 + logger.error("", e);
  78 + }
  79 + }
  80 +
  81 + private void reSend(StateBean sb){
  82 + if(sb.getSendCount() >= MAX_SEND_COUNT){
  83 + map.remove(sb.getNbbm());
  84 + logger.info("超过重发次数," + sb.getNbbm() + "、" + sb.getState());
  85 + return;
  86 + }
  87 +
  88 + long diff = System.currentTimeMillis() - sb.getSt();
  89 + if(diff >= MAX_AVAIL_TIME){
  90 + map.remove(sb.getNbbm());
  91 + logger.info("营运状态切换超过有效时间," + sb.getNbbm() + "、" + sb.getState() + "、" + sb.getSt());
  92 + return;
  93 + }
  94 +
  95 + if(diff >= SEND_SPACE){
  96 + sb.setSender("补发@系统");
  97 + changeState(sb);
  98 + logger.info("重发营运状态切换指令," + sb.getNbbm() + "、" + sb.getState());
  99 + return;
  100 + }
  101 + }
  102 +}
src/main/java/com/bsth/data/gpsdata/status_manager/gps_service_state/StateBean.java
1 -package com.bsth.data.gpsdata.status_manager.gps_service_state;  
2 -  
3 -/**  
4 - * Created by panzhao on 2017/7/13.  
5 - */  
6 -public class StateBean {  
7 -  
8 - /**  
9 - * 车辆自编号  
10 - */  
11 - private String nbbm;  
12 -  
13 - /**  
14 - * 要切换到营运状态  
15 - */  
16 - private int state;  
17 -  
18 - /**  
19 - * 要切换到的上下行  
20 - */  
21 - private int upDown;  
22 -  
23 - /**  
24 - * 指令发送次数  
25 - */  
26 - private int sendCount;  
27 -  
28 - /**  
29 - * 上次指令时间  
30 - */  
31 - private long st;  
32 -  
33 - /**发送人 */  
34 - private String sender;  
35 -  
36 - public static StateBean getInstance(String nbbm, int upDown, int state, String sender){  
37 - StateBean sb = new StateBean();  
38 - sb.setNbbm(nbbm);  
39 - sb.setState(state);  
40 - sb.setSendCount(0);  
41 - sb.setSender(sender);  
42 - sb.setUpDown(upDown);  
43 - return sb;  
44 - }  
45 -  
46 - public int getState() {  
47 - return state;  
48 - }  
49 -  
50 - public void setState(int state) {  
51 - this.state = state;  
52 - }  
53 -  
54 - public int getSendCount() {  
55 - return sendCount;  
56 - }  
57 -  
58 - public void setSendCount(int sendCount) {  
59 - this.sendCount = sendCount;  
60 - }  
61 -  
62 - public long getSt() {  
63 - return st;  
64 - }  
65 -  
66 - public void setSt(long st) {  
67 - this.st = st;  
68 - }  
69 -  
70 - public String getSender() {  
71 - return sender;  
72 - }  
73 -  
74 - public void setSender(String sender) {  
75 - this.sender = sender;  
76 - }  
77 -  
78 - public void countPlus(){  
79 - sendCount ++;  
80 - }  
81 -  
82 - public int getUpDown() {  
83 - return upDown;  
84 - }  
85 -  
86 - public void setUpDown(int upDown) {  
87 - this.upDown = upDown;  
88 - }  
89 -  
90 - public String getNbbm() {  
91 - return nbbm;  
92 - }  
93 -  
94 - public void setNbbm(String nbbm) {  
95 - this.nbbm = nbbm;  
96 - }  
97 -} 1 +package com.bsth.data.gpsdata.status_manager.gps_service_state;
  2 +
  3 +/**
  4 + * Created by panzhao on 2017/7/13.
  5 + */
  6 +public class StateBean {
  7 +
  8 + /**
  9 + * 车辆自编号
  10 + */
  11 + private String nbbm;
  12 +
  13 + /**
  14 + * 要切换到营运状态
  15 + */
  16 + private int state;
  17 +
  18 + /**
  19 + * 要切换到的上下行
  20 + */
  21 + private int upDown;
  22 +
  23 + /**
  24 + * 指令发送次数
  25 + */
  26 + private int sendCount;
  27 +
  28 + /**
  29 + * 上次指令时间
  30 + */
  31 + private long st;
  32 +
  33 + /**发送人 */
  34 + private String sender;
  35 +
  36 + public static StateBean getInstance(String nbbm, int upDown, int state, String sender){
  37 + StateBean sb = new StateBean();
  38 + sb.setNbbm(nbbm);
  39 + sb.setState(state);
  40 + sb.setSendCount(0);
  41 + sb.setSender(sender);
  42 + sb.setUpDown(upDown);
  43 + return sb;
  44 + }
  45 +
  46 + public int getState() {
  47 + return state;
  48 + }
  49 +
  50 + public void setState(int state) {
  51 + this.state = state;
  52 + }
  53 +
  54 + public int getSendCount() {
  55 + return sendCount;
  56 + }
  57 +
  58 + public void setSendCount(int sendCount) {
  59 + this.sendCount = sendCount;
  60 + }
  61 +
  62 + public long getSt() {
  63 + return st;
  64 + }
  65 +
  66 + public void setSt(long st) {
  67 + this.st = st;
  68 + }
  69 +
  70 + public String getSender() {
  71 + return sender;
  72 + }
  73 +
  74 + public void setSender(String sender) {
  75 + this.sender = sender;
  76 + }
  77 +
  78 + public void countPlus(){
  79 + sendCount ++;
  80 + }
  81 +
  82 + public int getUpDown() {
  83 + return upDown;
  84 + }
  85 +
  86 + public void setUpDown(int upDown) {
  87 + this.upDown = upDown;
  88 + }
  89 +
  90 + public String getNbbm() {
  91 + return nbbm;
  92 + }
  93 +
  94 + public void setNbbm(String nbbm) {
  95 + this.nbbm = nbbm;
  96 + }
  97 +}
src/main/java/com/bsth/entity/CarDevice.java
1 package com.bsth.entity; 1 package com.bsth.entity;
2 2
3 import com.bsth.entity.schedule.BEntity; 3 import com.bsth.entity.schedule.BEntity;
  4 +import org.hibernate.annotations.Formula;
4 import org.joda.time.DateTime; 5 import org.joda.time.DateTime;
5 6
6 import javax.persistence.*; 7 import javax.persistence.*;
@@ -22,6 +23,16 @@ public class CarDevice extends BEntity { @@ -22,6 +23,16 @@ public class CarDevice extends BEntity {
22 @Column 23 @Column
23 private String gsName; 24 private String gsName;
24 25
  26 + /** 所属公司 varchar length(50) */
  27 + private String company;
  28 +
  29 + /** 分公司 varchar length(50)*/
  30 + private String brancheCompany;
  31 +
  32 + /** 组合公司分公司编码 */
  33 + @Formula(" concat(company, '_', branche_company) ")
  34 + private String cgsbm;
  35 +
25 /** 车辆id,关联bsth_c_cars */ 36 /** 车辆id,关联bsth_c_cars */
26 @Column(nullable = false) 37 @Column(nullable = false)
27 private Integer cl; 38 private Integer cl;
@@ -203,4 +214,20 @@ public class CarDevice extends BEntity { @@ -203,4 +214,20 @@ public class CarDevice extends BEntity {
203 public void setIsCancel(Boolean isCancel) { 214 public void setIsCancel(Boolean isCancel) {
204 this.isCancel = isCancel; 215 this.isCancel = isCancel;
205 } 216 }
  217 +
  218 + public String getCompany() {
  219 + return company;
  220 + }
  221 +
  222 + public void setCompany(String company) {
  223 + this.company = company;
  224 + }
  225 +
  226 + public String getBrancheCompany() {
  227 + return brancheCompany;
  228 + }
  229 +
  230 + public void setBrancheCompany(String brancheCompany) {
  231 + this.brancheCompany = brancheCompany;
  232 + }
206 } 233 }
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
@@ -147,16 +147,20 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -147,16 +147,20 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
147 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date); 147 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date);
148 148
149 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) 149 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  150 + @Query(value="select DISTINCT s from ScheduleRealInfo s where gsBm like %?1% and fgsBm like %?2% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?3 and s.bcType not in ('in','out','ldks') order by s.xlDir,s.realExecDate,s.dfsj, (s.lpName+1)")
  151 + List<ScheduleRealInfo> scheduleByDateAndLineByGs(String gsdm,String fgsdm,String date);
  152 +
  153 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
150 @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlDir,s.realExecDate,s.dfsj, (s.lpName+1)") 154 @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlDir,s.realExecDate,s.dfsj, (s.lpName+1)")
151 List<ScheduleRealInfo> scheduleByDateAndLineQp2(String line,String date); 155 List<ScheduleRealInfo> scheduleByDateAndLineQp2(String line,String date);
152 156
153 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) 157 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
154 - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.bcType not in ('in','out') order by s.xlBm,s.adjustExps,s.fcsj") 158 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm,s.adjustExps,s.fcsj")
155 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date); 159 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date);
156 160
157 //按月统计 161 //按月统计
158 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) 162 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
159 - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m') = ?2 and s.bcType not in ('in','out') order by s.xlBm") 163 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m') = ?2 and s.bcType not in ('in','out','ldks') order by s.xlBm")
160 List<ScheduleRealInfo> scheduleByDateAndLine3(String line,String date); 164 List<ScheduleRealInfo> scheduleByDateAndLine3(String line,String date);
161 165
162 //按照时间段统计 166 //按照时间段统计
src/main/java/com/bsth/service/report/ReportService.java
@@ -46,4 +46,6 @@ public interface ReportService { @@ -46,4 +46,6 @@ public interface ReportService {
46 List<Map<String, Object>> countByList(Map<String, Object> map); 46 List<Map<String, Object>> countByList(Map<String, Object> map);
47 47
48 List<Map<String, Object>> countByBusList(Map<String, Object> map); 48 List<Map<String, Object>> countByBusList(Map<String, Object> map);
  49 +
  50 + List<Map<String, Object>> countDjg(Map<String, Object> map);
49 } 51 }
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
@@ -8,15 +8,19 @@ import com.bsth.entity.oil.Dlb; @@ -8,15 +8,19 @@ import com.bsth.entity.oil.Dlb;
8 import com.bsth.entity.oil.Ylb; 8 import com.bsth.entity.oil.Ylb;
9 import com.bsth.entity.realcontrol.ChildTaskPlan; 9 import com.bsth.entity.realcontrol.ChildTaskPlan;
10 import com.bsth.entity.realcontrol.ScheduleRealInfo; 10 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  11 +import com.bsth.entity.sys.Interval;
11 import com.bsth.repository.LineRepository; 12 import com.bsth.repository.LineRepository;
12 import com.bsth.repository.StationRouteRepository; 13 import com.bsth.repository.StationRouteRepository;
13 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; 14 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
14 import com.bsth.service.report.CulateMileageService; 15 import com.bsth.service.report.CulateMileageService;
15 import com.bsth.service.report.ReportService; 16 import com.bsth.service.report.ReportService;
16 import com.bsth.util.Arith; 17 import com.bsth.util.Arith;
  18 +import com.bsth.util.ComparableChild;
17 import com.bsth.util.ComparableJob; 19 import com.bsth.util.ComparableJob;
18 import com.bsth.util.ReportUtils; 20 import com.bsth.util.ReportUtils;
19 import com.bsth.util.db.DBUtils_MS; 21 import com.bsth.util.db.DBUtils_MS;
  22 +import com.google.protobuf.StringValue;
  23 +
20 import org.apache.commons.lang.StringUtils; 24 import org.apache.commons.lang.StringUtils;
21 import org.slf4j.Logger; 25 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory; 26 import org.slf4j.LoggerFactory;
@@ -57,6 +61,7 @@ public class ReportServiceImpl implements ReportService{ @@ -57,6 +61,7 @@ public class ReportServiceImpl implements ReportService{
57 LineRepository lineRepository; 61 LineRepository lineRepository;
58 @Autowired 62 @Autowired
59 StationRouteRepository stationRouteRepository; 63 StationRouteRepository stationRouteRepository;
  64 +
60 @Override 65 @Override
61 public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) { 66 public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) {
62 // TODO Auto-generated method stub 67 // TODO Auto-generated method stub
@@ -2221,5 +2226,244 @@ public class ReportServiceImpl implements ReportService{ @@ -2221,5 +2226,244 @@ public class ReportServiceImpl implements ReportService{
2221 } 2226 }
2222 return lMap; 2227 return lMap;
2223 } 2228 }
  2229 + @Override
  2230 + public List<Map<String, Object>> countDjg(Map<String, Object> map) {
  2231 + // TODO Auto-generated method stub
  2232 + List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();
  2233 + String line=map.get("line").toString().trim();
  2234 + String date=map.get("date").toString();
  2235 + String gsbm=map.get("gsbm").toString();
  2236 + String fgsbm=map.get("fgsbm").toString();
  2237 + List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>();
  2238 + if(line.equals("")){
  2239 + list=scheduleRealInfoRepository.scheduleByDateAndLineByGs(gsbm, fgsbm, date);
  2240 +
  2241 + }else{
  2242 + list=scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
  2243 + }
  2244 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
  2245 +// Collections.sort(listInfo,new ComparableAcuals());
  2246 + //查询所有线路
  2247 + String xlSql="select line_code,spac_grade from bsth_c_line ";
  2248 + if(line.equals("")){
  2249 + xlSql +=" where company ='"+gsbm+"'";
  2250 + }else{
  2251 + xlSql +=" where line_code ='"+line+"'";
  2252 + }
  2253 +
  2254 + List<Map<String, Object>> xlList=jdbcTemplate.query(xlSql, new RowMapper<Map<String, Object>>() {
  2255 + @Override
  2256 + public Map<String, Object> mapRow(ResultSet arg0, int arg1) throws SQLException {
  2257 + Map<String, Object> map=new HashMap<String,Object>();
  2258 + map.put("line",arg0.getString("line_code"));
  2259 + map.put("grade", arg0.getString("spac_grade"));
  2260 + return map;
  2261 + }
  2262 + });
  2263 + //查询大间隔时间
  2264 + String djgSql="select * from bsth_c_interval";
  2265 + List<Interval> djgList=jdbcTemplate.query(djgSql, new RowMapper<Interval>() {
  2266 + @Override
  2267 + public Interval mapRow(ResultSet arg0, int arg1) throws SQLException {
  2268 + Interval m=new Interval();
  2269 + m.setLevel(arg0.getString("level"));
  2270 + m.setPeak(arg0.getInt("peak"));
  2271 + m.setTrough(arg0.getInt("trough"));
  2272 + return m;
  2273 + }
  2274 + });
  2275 +
  2276 +
  2277 + for (int i = 0; i < xlList.size(); i++) {
  2278 + String lineCode=xlList.get(i).get("line").toString();
  2279 + String grade =xlList.get(i).get("grade").toString();
  2280 + int peak=0;
  2281 + int trough=0;
  2282 + for (int j = 0; j < djgList.size(); j++) {
  2283 + Interval il=djgList.get(j);
  2284 + if(il.getLevel().equals(grade)){
  2285 + peak=il.getPeak();
  2286 + trough=il.getTrough();
  2287 + continue;
  2288 + }
  2289 + }
  2290 + List<ScheduleRealInfo> list_=new ArrayList<ScheduleRealInfo>();
  2291 + List<ScheduleRealInfo> listInfo=new ArrayList<ScheduleRealInfo>();
  2292 + for (int j = 0; j < list.size(); j++) {
  2293 + ScheduleRealInfo sinfo=list.get(j);
  2294 + try {
  2295 + if(sinfo.getXlBm().equals(lineCode)){
  2296 + list_.add(sinfo);
  2297 + ScheduleRealInfo s=checkBc(sinfo);
  2298 + String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual();
  2299 + if(!fcsj.equals("")){
  2300 + Long fcsjAcual = sdf.parse(s.getRealExecDate() + " " + s.getFcsjActual()).getTime();
  2301 + s.setFcsjActualTime(fcsjAcual);
  2302 + s.setFcsjActual(fcsj);
  2303 + listInfo.add(s);
  2304 + }
  2305 +
  2306 + }
  2307 + } catch (ParseException e) {
  2308 + // TODO Auto-generated catch block
  2309 + e.printStackTrace();
  2310 + }
  2311 + }
  2312 + if(listInfo.size()>0){
  2313 + int sjbcs=culateService.culateSjbc(list_, "")+culateService.culateLjbc(list_, "");
  2314 + Map<String, Object> m=listDjg(gsbm,fgsbm,lineCode,sjbcs,peak,trough,listInfo,grade);
  2315 + lMap.add(m);
  2316 + }
  2317 +
  2318 + }
  2319 + return lMap;
  2320 + }
2224 2321
  2322 + public ScheduleRealInfo checkBc(ScheduleRealInfo s){
  2323 + //如果班次有子任务 且 子任务中有属于营运的。把该子任务的发车时间设置成班次的发车时间
  2324 + String fcsj=s.getFcsjActual()==null?"":s.getFcsjActual();
  2325 + if(fcsj.equals("")){
  2326 + Set<ChildTaskPlan> childTaskPlans = s.getcTasks();
  2327 + if(!childTaskPlans.isEmpty()){
  2328 + List<ChildTaskPlan> listit=new ArrayList<ChildTaskPlan>(childTaskPlans);
  2329 + Collections.sort(listit, new ComparableChild());
  2330 + for (int i = 0; i < listit.size(); i++) {
  2331 + ChildTaskPlan c=listit.get(i);
  2332 + if(!c.isDestroy()){
  2333 + if(c.getMileageType().equals("service")){
  2334 + s.setFcsjActual(c.getStartDate());
  2335 + break;
  2336 + }
  2337 +
  2338 + }
  2339 + }
  2340 + }
  2341 + }
  2342 + return s;
  2343 + }
  2344 +
  2345 + public Map<String, Object> listDjg(String gsdm,String fgsdm,String line,int sjbcs,int peak,int trough,List<ScheduleRealInfo> listInfo,String grade){
  2346 + DecimalFormat df = new DecimalFormat("#0.00");
  2347 + Collections.sort(listInfo,new ComparableAcuals());
  2348 + List<ScheduleRealInfo> listInfo0=new ArrayList<ScheduleRealInfo>();
  2349 + List<ScheduleRealInfo> listInfo1=new ArrayList<ScheduleRealInfo>();
  2350 + for (int i = 0; i < listInfo.size(); i++) {
  2351 + ScheduleRealInfo s=listInfo.get(i);
  2352 + if(s.getXlDir().equals("0")){
  2353 + listInfo0.add(s);
  2354 + }else{
  2355 + listInfo0.add(s);
  2356 + }
  2357 +
  2358 + }
  2359 + Map<String, Object> map=new HashMap<String, Object>();
  2360 + map.put("line", line);
  2361 + map.put("xlName", BasicData.lineCode2NameMap.get(line));
  2362 + map.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  2363 + map.put("bcs", sjbcs);
  2364 + map.put("djgde", grade);
  2365 + int djgcs=0;
  2366 + List<Map<String, Object>> mapList=new ArrayList<Map<String, Object>>();
  2367 + for (int i = 0; i < listInfo0.size(); i++) {
  2368 + ScheduleRealInfo s=listInfo.get(i);
  2369 + Long fcsjTime=s.getFcsjActualTime();
  2370 + String time=s.getFcsjActual();
  2371 + String[] fcsjStr = time.split(":");
  2372 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  2373 + if(i<listInfo.size()-1){
  2374 + Long djg=0l;
  2375 + Long fscjNext=listInfo.get(i+1).getFcsjActualTime();
  2376 + if((fcsj>=zgf1&&fcsj<=zgf2)||(fcsj>=wgf1&&fcsj<=wgf2)){
  2377 + djg = (long) (peak*60*1000);
  2378 + if(fscjNext-fcsjTime>djg){
  2379 + djgcs ++;
  2380 + Map<String, Object> m=new HashMap<String,Object>();
  2381 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  2382 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  2383 + m.put("djgde", grade);
  2384 + m.put("qJh", s.getFcsj());
  2385 + m.put("qSj", time);
  2386 + m.put("hJh", listInfo.get(i+1).getFcsj());
  2387 + m.put("hSj", listInfo.get(i+1).getFcsjActual());
  2388 + mapList.add(m);
  2389 + }
  2390 + }else{
  2391 + djg = (long) (trough*60*1000);
  2392 + if(fscjNext-fcsjTime>djg){
  2393 + djgcs ++;
  2394 + Map<String, Object> m=new HashMap<String,Object>();
  2395 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  2396 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  2397 + m.put("djgde", grade);
  2398 + m.put("qJh", s.getFcsj());
  2399 + m.put("qSj", time);
  2400 + m.put("hJh", listInfo.get(i+1).getFcsj());
  2401 + m.put("hSj", listInfo.get(i+1).getFcsjActual());
  2402 + mapList.add(m);
  2403 + }
  2404 + }
  2405 + }
  2406 + }
  2407 +
  2408 + for (int i = 0; i < listInfo1.size(); i++) {
  2409 + ScheduleRealInfo s=listInfo.get(i);
  2410 + Long fcsjTime=s.getFcsjActualTime();
  2411 + String time=s.getFcsjActual();
  2412 + String[] fcsjStr = time.split(":");
  2413 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  2414 + if(i<listInfo.size()-1){
  2415 + Long djg=0l;
  2416 + Long fscjNext=listInfo.get(i+1).getFcsjActualTime();
  2417 + if((fcsj>=zgf1&&fcsj<=zgf2)||(fcsj>=wgf1&&fcsj<=wgf2)){
  2418 + djg = (long) (peak*60*1000);
  2419 + if(fscjNext-fcsjTime>djg){
  2420 + djgcs ++;
  2421 + Map<String, Object> m=new HashMap<String,Object>();
  2422 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  2423 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  2424 + m.put("djgde", grade);
  2425 + m.put("qJh", s.getFcsj());
  2426 + m.put("qSj", time);
  2427 + m.put("hJh", listInfo.get(i+1).getFcsj());
  2428 + m.put("hSj", listInfo.get(i+1).getFcsjActual());
  2429 + mapList.add(m);
  2430 + }
  2431 + }else{
  2432 + djg = (long) (trough*60*1000);
  2433 + if(fscjNext-fcsjTime>djg){
  2434 + djgcs ++;
  2435 + Map<String, Object> m=new HashMap<String,Object>();
  2436 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  2437 + m.put("fgsname", BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  2438 + m.put("djgde", grade);
  2439 + m.put("qJh", s.getFcsj());
  2440 + m.put("qSj", time);
  2441 + m.put("hJh", listInfo.get(i+1).getFcsj());
  2442 + m.put("hSj", listInfo.get(i+1).getFcsjActual());
  2443 + mapList.add(m);
  2444 + }
  2445 + }
  2446 + }
  2447 + }
  2448 + double fsl=0.0;
  2449 + if(sjbcs>0){
  2450 + fsl=Arith.div(djgcs,sjbcs, 2)*100;
  2451 + }
  2452 +
  2453 + map.put("djgcs", djgcs);
  2454 + map.put("fsl", df.format(fsl)+"%");
  2455 + map.put("djgxx", mapList);
  2456 + return map;
  2457 + }
  2458 +
  2459 +}
  2460 +
  2461 +class ComparableAcuals implements Comparator<ScheduleRealInfo>{
  2462 +
  2463 + @Override
  2464 + public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) {
  2465 + // TODO Auto-generated method stub
  2466 + return o1.getFcsjActualTime().compareTo(o2.getFcsjActualTime());
  2467 + }
  2468 +
2225 } 2469 }
src/main/java/com/bsth/service/schedule/ScheduleRule1FlatService.java
@@ -6,4 +6,6 @@ import com.bsth.entity.schedule.rule.ScheduleRule1Flat; @@ -6,4 +6,6 @@ import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
6 * Created by xu on 16/7/4. 6 * Created by xu on 16/7/4.
7 */ 7 */
8 public interface ScheduleRule1FlatService extends BService<ScheduleRule1Flat, Long> { 8 public interface ScheduleRule1FlatService extends BService<ScheduleRule1Flat, Long> {
  9 +
  10 +
9 } 11 }