Commit 06ad4f9b06a05c95ccea27ad70625a82d0d8f531

Authored by 徐烜
1 parent 453efa15

浦东公交计划调度功能优化

1、计划排班时,添加时刻表路牌验证(验证路牌是否作废)
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
... ... @@ -47,6 +47,7 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon
47 47 @Query(value = "select tt from TTInfoDetail tt where tt.ttinfo.id = ?1 and tt.lp.id = ?2 order by tt.fcno asc")
48 48 List<TTInfoDetail> findBcdetails(Long ttinfoId, Long lpId);
49 49  
  50 + @Query(value = "select tt from TTInfoDetail tt left join fetch tt.lp where tt.ttinfo.id = ?1 ")
50 51 List<TTInfoDetail> findByTtinfoId(Long id);
51 52  
52 53 @Modifying
... ...
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
... ... @@ -205,7 +205,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
205 205  
206 206 session.fireAllRules();
207 207  
208   - session.dispose();;
  208 + session.dispose();
209 209  
210 210 return result;
211 211 }
... ...
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/timetable/ErrorBcCountFunction.java
... ... @@ -5,6 +5,10 @@ import org.apache.commons.lang3.StringUtils;
5 5 import org.kie.api.runtime.rule.AccumulateFunction;
6 6  
7 7 import java.io.*;
  8 +import java.util.ArrayList;
  9 +import java.util.HashMap;
  10 +import java.util.List;
  11 +import java.util.Map;
8 12  
9 13 /**
10 14 * Created by xu on 17/2/28.
... ... @@ -18,24 +22,68 @@ public class ErrorBcCountFunction implements AccumulateFunction {
18 22 public void writeExternal(ObjectOutput out) throws IOException {
19 23 }
20 24  
21   - protected static class ErrorCountData implements Externalizable {
22   - public long errorcount = 0;
  25 + protected static class ErrorCountData implements Serializable {
  26 + // TODO:这里暂时这样写,之后新版本去除
23 27 public TTInfoDetail ttInfoDetail;
  28 + /** 错误班次map,key=ttinfodetailId value=ttinfodetail */
  29 + public Map<Long, TTInfoDetail> errorTtInfoDetailMap;
  30 + // 空班次数
  31 + public Integer nullBcCount;
  32 + /** 错误路牌map,key=路牌Id,value=路牌名字 */
  33 + public Map<Long, String> errorlpMap;
24 34  
25 35 public ErrorCountData() {
  36 + nullBcCount = 0;
  37 + errorTtInfoDetailMap = new HashMap<>();
  38 + errorlpMap = new HashMap<>();
26 39 }
27 40  
28   - @Override
29   - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
30   - errorcount = in.readLong();
31   - ttInfoDetail = (TTInfoDetail) in.readObject();
  41 + public void accTTInfoDetail(TTInfoDetail ttInfoDetail) {
  42 + // 计算错误班次
  43 +
  44 + if (ttInfoDetail.getTtinfo() == null) {
  45 + nullBcCount ++;
  46 + return;
  47 + }
  48 +
  49 + // 判定条件(数据库中的对应字段没有非空约束),与界面saTimeTable.js的validInfo方法对应
  50 + // 1、起点站编码,名字为空
  51 + // 2、终点站编码,名字为空
  52 + // 3、班次时间
  53 + // TODO:其他再议
  54 + if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) ||
  55 + StringUtils.isEmpty(ttInfoDetail.getQdzName()) ||
  56 + StringUtils.isEmpty(ttInfoDetail.getZdzCode()) ||
  57 + StringUtils.isEmpty(ttInfoDetail.getZdzName()) ||
  58 + (ttInfoDetail.getBcsj() == null) ) {
  59 +
  60 + errorTtInfoDetailMap.put(ttInfoDetail.getId(), ttInfoDetail);
  61 + }
  62 +
  63 + // 计算错误路牌
  64 + if (ttInfoDetail.getLp().getIsCancel()) {
  65 + errorlpMap.put(ttInfoDetail.getLp().getId(), ttInfoDetail.getLp().getLpName());
  66 + }
32 67 }
33 68  
34   - @Override
35   - public void writeExternal(ObjectOutput out) throws IOException {
36   - out.writeLong(errorcount);
37   - out.writeObject(ttInfoDetail);
  69 + public void reTTInfoDetail(TTInfoDetail ttInfoDetail) {
  70 + if (ttInfoDetail.getTtinfo() == null) {
  71 + nullBcCount --;
  72 + return;
  73 + }
  74 + if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) ||
  75 + StringUtils.isEmpty(ttInfoDetail.getQdzName()) ||
  76 + StringUtils.isEmpty(ttInfoDetail.getZdzCode()) ||
  77 + StringUtils.isEmpty(ttInfoDetail.getZdzName()) ||
  78 + (ttInfoDetail.getBcsj() == null) ) {
  79 +
  80 + errorTtInfoDetailMap.remove(ttInfoDetail.getId());
  81 + }
  82 + if (ttInfoDetail.getLp().getIsCancel()) {
  83 + errorlpMap.remove(ttInfoDetail.getLp().getId());
  84 + }
38 85 }
  86 +
39 87 }
40 88  
41 89 @Override
... ... @@ -44,60 +92,42 @@ public class ErrorBcCountFunction implements AccumulateFunction {
44 92 }
45 93  
46 94 @Override
47   - public void init(Serializable context) throws Exception {
48   - ErrorCountData errorCountData = (ErrorCountData) context;
49   - errorCountData.errorcount = 0;
50   - }
  95 + public void init(Serializable context) throws Exception { }
51 96  
52 97 @Override
53 98 public void accumulate(Serializable context, Object value) {
54 99 ErrorCountData errorCountData = (ErrorCountData) context;
55 100 TTInfoDetail ttInfoDetail = (TTInfoDetail) value;
56   -
57   - if (ttInfoDetail.getTtinfo() == null) {
58   - errorCountData.errorcount ++;
59   - return;
60   - }
61   -
62   - // 判定条件(数据库中的对应字段没有非空约束),与界面saTimeTable.js的validInfo方法对应
63   - // 1、起点站编码,名字为空
64   - // 2、终点站编码,名字为空
65   - // 3、班次时间
66   - // TODO:其他再议
67   - if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) ||
68   - StringUtils.isEmpty(ttInfoDetail.getQdzName()) ||
69   - StringUtils.isEmpty(ttInfoDetail.getZdzCode()) ||
70   - StringUtils.isEmpty(ttInfoDetail.getZdzName()) ||
71   - (ttInfoDetail.getBcsj() == null) ) {
72   -
73   - errorCountData.errorcount ++;
74   - }
  101 + errorCountData.accTTInfoDetail(ttInfoDetail);
75 102 }
76 103  
77 104 @Override
78 105 public void reverse(Serializable context, Object value) throws Exception {
79 106 ErrorCountData errorCountData = (ErrorCountData) context;
80 107 TTInfoDetail ttInfoDetail = (TTInfoDetail) value;
81   -
82   - if (ttInfoDetail.getTtinfo() == null) {
83   - errorCountData.errorcount --;
84   - return;
85   - }
86   -
87   - if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) ||
88   - StringUtils.isEmpty(ttInfoDetail.getQdzName()) ||
89   - StringUtils.isEmpty(ttInfoDetail.getZdzCode()) ||
90   - StringUtils.isEmpty(ttInfoDetail.getZdzName()) ) {
91   -
92   - errorCountData.errorcount --;
93   - }
94   -
  108 + errorCountData.reTTInfoDetail(ttInfoDetail);
95 109 }
96 110  
97 111 @Override
98 112 public Object getResult(Serializable context) throws Exception {
99 113 ErrorCountData errorCountData = (ErrorCountData) context;
100   - return errorCountData.errorcount;
  114 +
  115 + // 错误班次数
  116 + Integer errorBcCount = errorCountData.nullBcCount + errorCountData.errorTtInfoDetailMap.values().size();
  117 + // 错误路牌数
  118 + Integer errorLpCount = errorCountData.errorlpMap.values().size();
  119 + // 错误路牌描述
  120 + List<String> errorLpInfoList = new ArrayList<>();
  121 + for (String lpName: errorCountData.errorlpMap.values()) {
  122 + errorLpInfoList.add("路牌" + "[" + lpName + "]" + "已作废");
  123 + }
  124 +
  125 + List<Object> resultObj = new ArrayList<>(3);
  126 + resultObj.add(errorBcCount);
  127 + resultObj.add(errorLpCount);
  128 + resultObj.add(errorLpInfoList);
  129 +
  130 + return resultObj;
101 131 }
102 132  
103 133 @Override
... ... @@ -107,6 +137,6 @@ public class ErrorBcCountFunction implements AccumulateFunction {
107 137  
108 138 @Override
109 139 public Class<?> getResultType() {
110   - return Number.class;
  140 + return List.class;
111 141 }
112 142 }
... ...
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/timetable/Result.java
... ... @@ -35,7 +35,12 @@ public class Result {
35 35 private Long yybc;
36 36  
37 37 /** 错误班次数 */
38   - private Long errorbc;
  38 + private Integer errorbc;
  39 +
  40 + /** 错误路牌数 */
  41 + private Integer errorlpCount;
  42 + /** 错误路牌描述 */
  43 + private List<String> errorlpInfo;
39 44  
40 45 public Long getTtid() {
41 46 return ttid;
... ... @@ -85,14 +90,10 @@ public class Result {
85 90 this.yybc = yybc;
86 91 }
87 92  
88   - public Long getErrorbc() {
  93 + public Integer getErrorbc() {
89 94 return errorbc;
90 95 }
91 96  
92   - public void setErrorbc(Long errorbc) {
93   - this.errorbc = errorbc;
94   - }
95   -
96 97 public Integer getLineVersion() {
97 98 return lineVersion;
98 99 }
... ... @@ -100,5 +101,25 @@ public class Result {
100 101 public void setLineVersion(Integer lineVersion) {
101 102 this.lineVersion = lineVersion;
102 103 }
  104 +
  105 + public void setErrorbc(Integer errorbc) {
  106 + this.errorbc = errorbc;
  107 + }
  108 +
  109 + public Integer getErrorlpCount() {
  110 + return errorlpCount;
  111 + }
  112 +
  113 + public void setErrorlpCount(Integer errorlpCount) {
  114 + this.errorlpCount = errorlpCount;
  115 + }
  116 +
  117 + public List<String> getErrorlpInfo() {
  118 + return errorlpInfo;
  119 + }
  120 +
  121 + public void setErrorlpInfo(List<String> errorlpInfo) {
  122 + this.errorlpInfo = errorlpInfo;
  123 + }
103 124 }
104 125 }
... ...
src/main/resources/application-dev.properties
... ... @@ -17,9 +17,9 @@ spring.datasource.driver-class-name= com.mysql.jdbc.Driver
17 17 ##spring.datasource.url= jdbc:mysql://192.168.168.222/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
18 18 #spring.datasource.username= root
19 19 #spring.datasource.password=
20   -spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  20 +spring.datasource.url= jdbc:mysql://127.0.0.1/test_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
21 21 spring.datasource.username= root
22   -spring.datasource.password= root
  22 +spring.datasource.password=
23 23 #spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
24 24 #spring.datasource.username= root
25 25 #spring.datasource.password= root
... ... @@ -48,4 +48,4 @@ http.rfid.url= http://114.80.178.12:29000/rfid
48 48 ## http ticketing interface
49 49 http.ticketing.interface= http://112.64.187.3:1080/gjService/request
50 50 ## first last generate
51   -ms.fl.generate=true
52 51 \ No newline at end of file
  52 +ms.fl.generate=true
... ...
src/main/resources/datatools/config-dev.properties
... ... @@ -10,7 +10,7 @@ datatools.kvars_dbuname=root
10 10 #数据库密码
11 11 datatools.kvars_dbpwd=
12 12 #数据库库名
13   -datatools.kvars_dbdname=control
  13 +datatools.kvars_dbdname=test_control
14 14  
15 15 # 3、上传数据配置信息
16 16 # 上传文件目录配置(根据不同的环境需要修正)
... ...
src/main/resources/rules/kBase3_validate_timetable.drl
... ... @@ -307,7 +307,7 @@ rule &quot;statinfo_result&quot; // 统计计算结果
307 307 $inbc: Long() from accumulate (TTInfoDetail(bcType == "in") from $ttInfoDetails_wrap.getBcInfoList(), count())
308 308 $outbc: Long() from accumulate (TTInfoDetail(bcType == "out") from $ttInfoDetails_wrap.getBcInfoList(), count())
309 309 $yybc: Long() from accumulate (TTInfoDetail(bcType != "out", bcType != "in") from $ttInfoDetails_wrap.getBcInfoList(), count())
310   - $errorbc: Long() from accumulate ($ttd: TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), ecount($ttd))
  310 + $errorbc: List() from accumulate ($ttd: TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), ecount($ttd))
311 311 then
312 312 log.info("时刻表={},id={},班次数={},进场={},出场={},营运={},错误={}", $statInfo.getTtname(), $statInfo.getTtid(), $allbc, $inbc, $outbc, $yybc, $errorbc);
313 313  
... ... @@ -315,7 +315,9 @@ rule &quot;statinfo_result&quot; // 统计计算结果
315 315 $statInfo.setInbc($inbc);
316 316 $statInfo.setOutbc($outbc);
317 317 $statInfo.setYybc($yybc);
318   - $statInfo.setErrorbc($errorbc);
  318 + $statInfo.setErrorbc((Integer) $errorbc.get(0));
  319 + $statInfo.setErrorlpCount((Integer) $errorbc.get(1));
  320 + $statInfo.setErrorlpInfo((List<String>) $errorbc.get(2));
319 321  
320 322 int lineVersion = $ttInfoDetails_wrap.getLineVersion();
321 323 $statInfo.setLineVersion(lineVersion);
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdate.js
... ... @@ -125,6 +125,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(
125 125 scope[ctrlAs].$$ds = [];
126 126  
127 127 var errorTTInfos = 0;
  128 + var errorLpCount = 0;
128 129  
129 130 if (result && result.data && result.data.infos && result.data.infos.length > 0) {
130 131 angular.forEach(result.data.infos, function(obj) {
... ... @@ -140,6 +141,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
140 141 yybc: obj.yybc,
141 142  
142 143 errorbc: obj.errorbc,
  144 + errorlpCount: obj.errorlpCount,
  145 + errorlpInfo: obj.errorlpInfo,
143 146  
144 147 lineVersion: obj.lineVersion
145 148  
... ... @@ -147,6 +150,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
147 150  
148 151 if (obj.errorbc > 0) {
149 152 errorTTInfos ++;
  153 + } else if (obj.errorlpCount > 0) {
  154 + errorLpCount ++;
150 155 } else {
151 156 ttinfonames.push(obj.ttname);
152 157 ttinfoids.push(obj.ttid);
... ... @@ -156,6 +161,9 @@ angular.module(&#39;ScheduleApp&#39;).directive(
156 161 if (errorTTInfos > 0) {
157 162 scope[ctrlAs].$$internalmodel = undefined;
158 163 scope[ctrlAs].error = "时刻表有错误班次";
  164 + } else if (errorLpCount > 0) {
  165 + scope[ctrlAs].$$internalmodel = undefined;
  166 + scope[ctrlAs].error = "时刻表有错误路牌";
159 167 } else {
160 168 scope[ctrlAs].$$internalmodel = "ok";
161 169 scope[ctrlAs].ttinfonames = ttinfonames.join(",");
... ... @@ -228,4 +236,4 @@ angular.module(&#39;ScheduleApp&#39;).directive(
228 236 };
229 237 }
230 238 ]
231   -);
232 239 \ No newline at end of file
  240 +);
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdateTemplate.html
... ... @@ -56,6 +56,8 @@
56 56 <div><span ng-bind="info.ttname"></span></div>
57 57 <div><span>统计班次:{{info.allbc}}个,出场:{{info.outbc}}个,进场:{{info.inbc}}个,营运:{{info.yybc}}个</span></div>
58 58 <div><span>异常班次:{{info.errorbc}}个</span></div>
  59 + <div><span>异常路牌:{{info.errorlpCount}}个</span></div>
  60 + <div><span>异常路牌描述:{{info.errorlpInfo.join(",")}}</span></div>
59 61 </script>
60 62  
61 63 <div ng-repeat="info in $saScpdateCtrl.$$ds track by $index">
... ... @@ -68,8 +70,8 @@
68 70 {{info.ttname}}
69 71 </a>
70 72 </h3>
71   - <span class="glyphicon glyphicon-ok" aria-hidden="true" ng-if="info.errorbc == 0"></span>
72   - <span class="glyphicon glyphicon-remove" aria-hidden="true" ng-if="info.errorbc > 0"></span>
  73 + <span class="glyphicon glyphicon-ok" aria-hidden="true" ng-if="info.errorbc == 0 && info.errorlpCount == 0"></span>
  74 + <span class="glyphicon glyphicon-remove" aria-hidden="true" ng-if="info.errorbc > 0 || info.errorlpCount > 0"></span>
73 75 </div>
74 76 </div>
75 77 </div>
... ... @@ -78,4 +80,4 @@
78 80  
79 81  
80 82  
81   -</div>
82 83 \ No newline at end of file
  84 +</div>
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
... ... @@ -5146,6 +5146,7 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5146 5146 scope[ctrlAs].$$ds = [];
5147 5147  
5148 5148 var errorTTInfos = 0;
  5149 + var errorLpCount = 0;
5149 5150  
5150 5151 if (result && result.data && result.data.infos && result.data.infos.length > 0) {
5151 5152 angular.forEach(result.data.infos, function(obj) {
... ... @@ -5161,6 +5162,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5161 5162 yybc: obj.yybc,
5162 5163  
5163 5164 errorbc: obj.errorbc,
  5165 + errorlpCount: obj.errorlpCount,
  5166 + errorlpInfo: obj.errorlpInfo,
5164 5167  
5165 5168 lineVersion: obj.lineVersion
5166 5169  
... ... @@ -5168,6 +5171,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5168 5171  
5169 5172 if (obj.errorbc > 0) {
5170 5173 errorTTInfos ++;
  5174 + } else if (obj.errorlpCount > 0) {
  5175 + errorLpCount ++;
5171 5176 } else {
5172 5177 ttinfonames.push(obj.ttname);
5173 5178 ttinfoids.push(obj.ttid);
... ... @@ -5177,6 +5182,9 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5177 5182 if (errorTTInfos > 0) {
5178 5183 scope[ctrlAs].$$internalmodel = undefined;
5179 5184 scope[ctrlAs].error = "时刻表有错误班次";
  5185 + } else if (errorLpCount > 0) {
  5186 + scope[ctrlAs].$$internalmodel = undefined;
  5187 + scope[ctrlAs].error = "时刻表有错误路牌";
5180 5188 } else {
5181 5189 scope[ctrlAs].$$internalmodel = "ok";
5182 5190 scope[ctrlAs].ttinfonames = ttinfonames.join(",");
... ... @@ -5249,7 +5257,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5249 5257 };
5250 5258 }
5251 5259 ]
5252   -);
  5260 +);
  5261 +
5253 5262 /**
5254 5263 * saSrule指令(非通用指令,只在排班计划form中使用)。
5255 5264 * 属性如下:
... ...