Commit 34547da307897ced161efb4a7c9bd9407d41cc88

Authored by 徐烜
1 parent bbb3ad44

嘉定公交调度系统计划调度功能优化4

1、修正新增排班时的界面,可以提示时刻表冲突和空的信息
src/main/java/com/bsth/service/schedule/SchedulePlanService.java
1 1 package com.bsth.service.schedule;
2 2  
3 3 import com.bsth.entity.schedule.SchedulePlan;
4   -import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult;
5   -import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result;
6   -import org.springframework.web.bind.annotation.RequestParam;
  4 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.PlanProcessValidateTimetableService;
  5 +import com.bsth.service.schedule.plan.process._1_validate._2_rule.PlanProcessValidateRuleService;
7 6  
8 7 import java.util.Date;
9 8 import java.util.Map;
... ... @@ -28,7 +27,7 @@ public interface SchedulePlanService extends BService<SchedulePlan, Long> {
28 27 * @param to 结束时间
29 28 * @return
30 29 */
31   - Result validateTTInfo(Integer xlid, Date from, Date to);
  30 + PlanProcessValidateTimetableService.Result validateTTInfo(Integer xlId, Date from, Date to);
32 31  
33 32 /**
34 33 * 验证规则。
... ... @@ -37,7 +36,7 @@ public interface SchedulePlanService extends BService<SchedulePlan, Long> {
37 36 * @param to 排班计划结束时间
38 37 * @return
39 38 */
40   - ValidateRuleResult validateRule(Integer xlId, Date from, Date to);
  39 + PlanProcessValidateRuleService.Result validateRule(Integer xlId, Date from, Date to);
41 40  
42 41  
43 42 /**
... ... @@ -46,4 +45,4 @@ public interface SchedulePlanService extends BService<SchedulePlan, Long> {
46 45 * @return
47 46 */
48 47 Map<String,Object> listwest(Map map);
49   -}
50 48 \ No newline at end of file
  49 +}
... ...
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
1 1 package com.bsth.service.schedule.impl;
2 2  
3   -import com.bsth.data.gpsdata_v2.entity.StationRoute;
4   -import com.bsth.entity.Line;
5 3 import com.bsth.entity.schedule.SchedulePlan;
6   -import com.bsth.entity.schedule.TTInfo;
7 4 import com.bsth.repository.BusinessRepository;
8 5 import com.bsth.repository.LineRepository;
9 6 import com.bsth.repository.schedule.*;
10 7 import com.bsth.service.schedule.SchedulePlanService;
11 8 import com.bsth.service.schedule.exception.ScheduleException;
12   -import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult;
13   -import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.CalcuParam;
14   -import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result;
15 9 import com.bsth.service.schedule.impl.plan.DroolsSchedulePlan;
16 10 import com.bsth.service.schedule.impl.plan.ScheduleRuleService;
  11 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.PlanProcessValidateTimetableService;
  12 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.PlanProcessValidateTimetableServiceDroolsImpl;
  13 +import com.bsth.service.schedule.plan.process._1_validate._2_rule.PlanProcessValidateRuleService;
  14 +import com.bsth.service.schedule.plan.process._1_validate._2_rule.PlanProcessValidateRuleServiceDroolsImpl;
17 15 import org.joda.time.DateTime;
18 16 import org.kie.api.KieBase;
19   -import org.kie.api.runtime.KieSession;
20 17 import org.slf4j.Logger;
21 18 import org.slf4j.LoggerFactory;
22 19 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -27,7 +24,6 @@ import org.springframework.stereotype.Service;
27 24 import org.springframework.transaction.annotation.Isolation;
28 25 import org.springframework.transaction.annotation.Propagation;
29 26 import org.springframework.transaction.annotation.Transactional;
30   -import org.springframework.web.bind.annotation.RequestParam;
31 27  
32 28 import java.sql.ResultSet;
33 29 import java.sql.SQLException;
... ... @@ -51,10 +47,6 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
51 47 private KieBase preKBase;
52 48  
53 49 @Autowired
54   - @Qualifier("KBase3")
55   - private KieBase validateKBase;
56   -
57   - @Autowired
58 50 private ScheduleRule1FlatRepository scheduleRule1FlatRepository;
59 51 @Autowired
60 52 private TTInfoRepository ttInfoRepository;
... ... @@ -160,63 +152,91 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
160 152 return null;
161 153 }
162 154  
  155 + @Autowired
  156 + @Qualifier("kBaseValidateTimetable_plus")
  157 + private KieBase kBaseValidateTimetable;
163 158 @Override
164   - public Result validateTTInfo(Integer xlid, Date from, Date to) {
165   - // 构造drools session->载入数据->启动规则->计算->销毁session
166   - // 创建session,内部配置的是stateful
167   - KieSession session = validateKBase.newKieSession();
168   - // 设置gloable对象,在drl中通过别名使用
169   - session.setGlobal("log", logger);
170   - session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
171   -
172   - Result rs = new Result(); // 输出gloable对象
173   - session.setGlobal("rs", rs);
174   -
175   - // 载入数据
176   - Line line = lineRepository.findOne(xlid);
177   - session.insert(line);
178   -
179   - CalcuParam calcuParam = new CalcuParam(
180   - new DateTime(from), new DateTime(to), xlid);
181   - session.insert(calcuParam);
182   - List<TTInfo> ttInfos = ttInfoRepository.findByXlId(xlid);
183   - for (TTInfo ttInfo: ttInfos) {
184   - session.insert(ttInfo);
185   - }
186   -
187   - // 执行rule
188   - session.fireAllRules();
189   -
190   - // 执行完毕销毁,有日志的也要关闭
191   - session.dispose();
  159 + public PlanProcessValidateTimetableService.Result validateTTInfo(Integer xlId, Date from, Date to) {
  160 + // 使用builder创建服务
  161 + PlanProcessValidateTimetableService planProcessValidateTimetableService =
  162 + PlanProcessValidateTimetableServiceDroolsImpl.getBuilder()
  163 + .setkBaseValidateTimetable(kBaseValidateTimetable)
  164 + .setJdbcTemplate(jdbcTemplate)
  165 + .build();
  166 + PlanProcessValidateTimetableService.Result result =
  167 + planProcessValidateTimetableService.validateTTInfovalidateTTInfo(xlId, from, to);
  168 + return result;
192 169  
193   - return rs;
  170 +// // 构造drools session->载入数据->启动规则->计算->销毁session
  171 +// // 创建session,内部配置的是stateful
  172 +// KieSession session = validateKBase.newKieSession();
  173 +// // 设置gloable对象,在drl中通过别名使用
  174 +// session.setGlobal("log", logger);
  175 +// session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
  176 +//
  177 +// Result rs = new Result(); // 输出gloable对象
  178 +// session.setGlobal("rs", rs);
  179 +//
  180 +// // 载入数据
  181 +// Line line = lineRepository.findOne(xlid);
  182 +// session.insert(line);
  183 +//
  184 +// CalcuParam calcuParam = new CalcuParam(
  185 +// new DateTime(from), new DateTime(to), xlid);
  186 +// session.insert(calcuParam);
  187 +// List<TTInfo> ttInfos = ttInfoRepository.findByXlId(xlid);
  188 +// for (TTInfo ttInfo: ttInfos) {
  189 +// session.insert(ttInfo);
  190 +// }
  191 +//
  192 +// // 执行rule
  193 +// session.fireAllRules();
  194 +//
  195 +// // 执行完毕销毁,有日志的也要关闭
  196 +// session.dispose();
  197 +//
  198 +// return rs;
194 199 }
195 200  
  201 + @Autowired
  202 + @Qualifier("kBaseValidateRule_plus")
  203 + private KieBase kBaseValidateRule;
196 204 @Override
197   - public ValidateRuleResult validateRule(Integer xlId, Date from, Date to) {
198   - KieSession session = validateKBase.newKieSession();
199   - session.setGlobal("LOG", logger);
200   - session.setGlobal("ccRepo", carConfigInfoRepository);
201   - session.setGlobal("lpRepo", guideboardInfoRepository);
202   - session.setGlobal("ecRepo", employeeConfigInfoRepository);
203   - session.setGlobal("ruleRepo", scheduleRule1FlatRepository);
204   -
205   - ValidateRuleResult result = new ValidateRuleResult();
206   - session.setGlobal("result", result);
207   -
208   - com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam calcuParam =
209   - new com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam();
210   - calcuParam.setXlId(xlId);
211   - calcuParam.setFromDate(new DateTime(from));
212   - calcuParam.setToDate(new DateTime(to));
213   - session.insert(calcuParam);
214   -
215   - session.fireAllRules();
  205 + public PlanProcessValidateRuleService.Result validateRule(Integer xlId, Date from, Date to) {
  206 + // 使用builder创建服务
  207 + PlanProcessValidateRuleService planProcessValidateRuleService =
  208 + PlanProcessValidateRuleServiceDroolsImpl.getBuilder()
  209 + .setkBaseValidateRule(kBaseValidateRule)
  210 + .setJdbcTemplate(jdbcTemplate)
  211 + .build();
  212 +
  213 + PlanProcessValidateRuleService.Result result =
  214 + planProcessValidateRuleService.validateRule(xlId, from, to);
  215 + return result;
216 216  
217   - session.dispose();;
218 217  
219   - return result;
  218 +// KieSession session = validateKBase.newKieSession();
  219 +// session.setGlobal("LOG", logger);
  220 +// session.setGlobal("ccRepo", carConfigInfoRepository);
  221 +// session.setGlobal("lpRepo", guideboardInfoRepository);
  222 +// session.setGlobal("ecRepo", employeeConfigInfoRepository);
  223 +// session.setGlobal("ruleRepo", scheduleRule1FlatRepository);
  224 +//
  225 +// ValidateRuleResult result = new ValidateRuleResult();
  226 +// session.setGlobal("result", result);
  227 +//
  228 +// com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam calcuParam =
  229 +// new com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam();
  230 +// calcuParam.setXlId(xlId);
  231 +// calcuParam.setFromDate(new DateTime(from));
  232 +// calcuParam.setToDate(new DateTime(to));
  233 +// session.insert(calcuParam);
  234 +//
  235 +// session.fireAllRules();
  236 +//
  237 +// session.dispose();;
  238 +//
  239 +// return result;
220 240 }
221 241  
222 242  
... ... @@ -230,7 +250,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
230 250 if(map.get("fgsdm")!=null){
231 251 fgs=map.get("fgsdm").toString();
232 252 }
233   -
  253 +
234 254 String sql ="" +
235 255 "SELECT sp.xl as xl,sp.tt_info_names as tt_info_name, " +
236 256 " sp.schedule_from_time as from_time ,sp.schedule_to_time as to_time, " +
... ... @@ -267,17 +287,17 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
267 287 map.put("businessName", rs.getString("business_name"));
268 288 return map;
269 289 }
270   -
  290 +
271 291 });
272   -
  292 +
273 293 for (Map m : list) {
274 294 m.put("updataDate", sfd.format(sfd.parse(m.get("updataDate").toString())));
275 295 }
276 296 }catch (Exception e){
277 297 e.printStackTrace();
278 298 }
279   -
280   -
  299 +
  300 +
281 301 //分页
282 302 if(page.length() != 0 ){
283 303 int currPage = Integer.valueOf(page);
... ... @@ -287,8 +307,8 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
287 307 } else {
288 308 modelMap.put("dataList", list);
289 309 }
290   -
291   -
  310 +
  311 +
292 312 return modelMap;
293 313 }
294 314 }
... ...
src/main/java/com/bsth/service/schedule/plan/PlanConfig.java
... ... @@ -36,7 +36,7 @@ public class PlanConfig {
36 36 * 验证时刻表kieBase。
37 37 * @return
38 38 */
39   - @Bean(name = "kBaseValidateTimetable")
  39 + @Bean(name = "kBaseValidateTimetable_plus")
40 40 public KieBase kBaseValidateTimetable() {
41 41 KieBase kieBase = this.generateKieBase(
42 42 "kBaseValidateTimetable",
... ... @@ -49,7 +49,7 @@ public class PlanConfig {
49 49 * 验证规则kieBase。
50 50 * @return
51 51 */
52   - @Bean(name = "kBaseValidateRule")
  52 + @Bean(name = "kBaseValidateRule_plus")
53 53 public KieBase kBaseValidateRule() {
54 54 KieBase kieBase = this.generateKieBase(
55 55 "kBaseValidateRule",
... ...
src/main/resources/META-INF/drools.packagebuilder.conf
... ... @@ -10,3 +10,11 @@ drools.accumulate.function.minruleqyrq = com.bsth.service.schedule.impl.plan.kBa
10 10 drools.accumulate.function.vrb = com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidRepeatBcFunction
11 11 drools.accumulate.function.vwrb = com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWholeRerunBcFunction
12 12 drools.accumulate.function.vwlp = com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWantLpFunction
  13 +
  14 +# kBase_validate_timetable.drl使用
  15 +drools.accumulate.function.ecount2 = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_ErrorBcCount
  16 +drools.accumulate.function.as = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_AccumulateStatInfo
  17 +drools.accumulate.function.ac = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_AccumulateConflict
  18 +drools.accumulate.function.ae = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_AccumulateEmpty
  19 +# kBase_validate_rule.drl使用
  20 +drools.accumulate.function.srif2 = com.bsth.service.schedule.plan.process._1_validate._2_rule.drools.KBaseValidateRule_Function_ErrorInfo
... ...
src/main/resources/drools/KBase/validate/rule/KBase_validate_rule.drl
... ... @@ -54,7 +54,7 @@ rule &quot;calcu_error_info&quot;
54 54 $param: KBaseValidateRule_Fact_CalcuParam($xlId: xlId, $fd: fromDate, $td: toDate)
55 55 $allRuleList: ArrayList() from collect(KBaseValidateRule_Fact_Rule(xl.id == $xlId))
56 56 $allWrapRuleList: ArrayList() from collect(WrapRule(rule.xl.id == $xlId))
57   - $errorMap: Map() from accumulate ($wr: WrapRule(rule.xl.id == $xlId), srif($wr))
  57 + $errorMap: Map() from accumulate ($wr: WrapRule(rule.xl.id == $xlId), srif2($wr))
58 58 then
59 59 rs.setXlId($xlId);
60 60 rs.setCount($allRuleList.size());
... ...
src/main/resources/drools/KBase/validate/timetable/KBase_validate_timetable.drl
... ... @@ -165,7 +165,7 @@ rule &quot;group_statinfo&quot;
165 165 $inbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType == "in") from $bcInfoList, count())
166 166 $outbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType == "out") from $bcInfoList, count())
167 167 $yybc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType != "out", bcType != "in") from $bcInfoList, count())
168   - $errorbc: Long() from accumulate ($ttd: KBaseValidateTimeTable_Fact_TTInfoDetail() from $bcInfoList, ecount($ttd))
  168 + $errorbc: Long() from accumulate ($ttd: KBaseValidateTimeTable_Fact_TTInfoDetail() from $bcInfoList, ecount2($ttd))
169 169 then
170 170 LOGGER.info("时刻表={},id={},线路版本={},班次数={},进场={},出场={},营运={},错误={}",
171 171 $statInfo.getTtname(), $statInfo.getTtid(), $lineVersion, $allbc, $inbc, $outbc, $yybc, $errorbc);
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdate.js
... ... @@ -33,8 +33,12 @@ angular.module(&#39;ScheduleApp&#39;).directive(
33 33 // 内部ng-model值,用于和required配对
34 34 self.$$internalmodel = undefined;
35 35  
36   - // 内部数据源(时刻表的一些信息)
  36 + // 内部数据源(时刻表的统计信息)
37 37 self.$$ds = [];
  38 + // 内部数据源(时刻表的冲突信息)
  39 + self.$$conflictDs = [];
  40 + // 内部数据源(时刻表的空信息)
  41 + self.$$emptyDs = [];
38 42  
39 43 },
40 44 compile: function(tElem, tAttrs) {
... ... @@ -122,10 +126,11 @@ angular.module(&#39;ScheduleApp&#39;).directive(
122 126 var ttinfoids = [];
123 127 QClass.val({xlid: xl_id, from: from_date, to: to_date},
124 128 function(result) {
125   - scope[ctrlAs].$$ds = [];
  129 + var errorList = [];
126 130  
  131 + //---------------- 1、计算时刻表统计信息 ----------------//
  132 + scope[ctrlAs].$$ds = [];
127 133 var errorTTInfos = 0;
128   -
129 134 if (result && result.data && result.data.infos && result.data.infos.length > 0) {
130 135 angular.forEach(result.data.infos, function(obj) {
131 136 scope[ctrlAs].$$ds.push({
... ... @@ -154,17 +159,53 @@ angular.module(&#39;ScheduleApp&#39;).directive(
154 159 });
155 160  
156 161 if (errorTTInfos > 0) {
157   - scope[ctrlAs].$$internalmodel = undefined;
158   - scope[ctrlAs].error = "时刻表有错误班次";
  162 + errorList.push("时刻表有错误班次");
159 163 } else {
160   - scope[ctrlAs].$$internalmodel = "ok";
161 164 scope[ctrlAs].ttinfonames = ttinfonames.join(",");
162 165 scope[ctrlAs].ttinfoids = ttinfoids.join(",");
163 166 }
164 167  
165 168 } else {
  169 + errorList.push("无可用时刻表");
  170 + }
  171 +
  172 + //---------------- 2、计算当天时刻表冲突信息 ----------------//
  173 + scope[ctrlAs].$$conflictDs = [];
  174 + if (result && result.data && result.data.conflictStatInfos && result.data.conflictStatInfos.length > 0) {
  175 + errorList.push("当天时刻表有冲突");
  176 + // 截取前五条数据显示,如果大于五条,加还有更多提示
  177 + var c_temp_list = result.data.conflictStatInfos.splice(0, 5);
  178 + angular.forEach(c_temp_list, function(obj) {
  179 + scope[ctrlAs].$$conflictDs.push({
  180 + desc: obj.dateDesc + "匹配到" + obj.ttIdList.length + "张时刻表"
  181 + });
  182 + });
  183 + if (result.data.conflictStatInfos.length > 5) {
  184 + scope[ctrlAs].$$conflictDs.push({desc : "还有更多"});
  185 + }
  186 + }
  187 +
  188 + //---------------- 3、计算当天空时刻表信息 ----------------//
  189 + scope[ctrlAs].$$emptyDs = [];
  190 + if (result && result.data && result.data.emptyStatInfos && result.data.emptyStatInfos.length > 0) {
  191 + // 截取前五条数据显示,如果大于五条,加还有更多提示
  192 + var e_temp_list = result.data.emptyStatInfos.splice(0, 5);
  193 + angular.forEach(e_temp_list, function(obj) {
  194 + scope[ctrlAs].$$emptyDs.push({
  195 + desc: obj.dateDesc + "没有匹配到时刻表"
  196 + });
  197 + });
  198 + if (result.data.emptyStatInfos.length > 5) {
  199 + scope[ctrlAs].$$emptyDs.push({desc : "还有更多"});
  200 + }
  201 + }
  202 +
  203 + //---------------- 4、输出错误,计算model ----------------//
  204 + if (errorList.length > 0) {
166 205 scope[ctrlAs].$$internalmodel = undefined;
167   - scope[ctrlAs].error = "无可用时刻表";
  206 + scope[ctrlAs].error = errorList.join(",");
  207 + } else {
  208 + scope[ctrlAs].$$internalmodel = "ok";
168 209 }
169 210 },
170 211 function() {
... ... @@ -172,9 +213,6 @@ angular.module(&#39;ScheduleApp&#39;).directive(
172 213 scope[ctrlAs].error = "获取时刻表数据失败!";
173 214 }
174 215 );
175   -
176   -
177   - scope[ctrlAs].$$internalmodel = "ok";
178 216 };
179 217  
180 218 scope[ctrlAs].$$internal_model_refresh(); // 初始执行
... ... @@ -228,4 +266,4 @@ angular.module(&#39;ScheduleApp&#39;).directive(
228 266 };
229 267 }
230 268 ]
231   -);
232 269 \ No newline at end of file
  270 +);
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdateTemplate.html
... ... @@ -72,10 +72,48 @@
72 72 <span class="glyphicon glyphicon-remove" aria-hidden="true" ng-if="info.errorbc > 0"></span>
73 73 </div>
74 74 </div>
  75 +
  76 + <script type="text/ng-template" id="$saScpdateCtrl_popover_2.html">
  77 + <div><span>当天时刻表冲突详细信息,如下:</span></div>
  78 + <div ng-repeat="info in $saScpdateCtrl.$$conflictDs track by $index">
  79 + <span>{{info.desc}}</span>
  80 + </div>
  81 + </script>
  82 + <div ng-if="$saScpdateCtrl.$$conflictDs.length > 0">
  83 + <div class="alert alert-danger well-sm col-md-12" uib-popover-template="'$saScpdateCtrl_popover_2.html'"
  84 + popover-class="increase-popover-width"
  85 + popover-trigger="mouseenter">
  86 + <h3 class="col-md-8">
  87 + {{$saScpdateCtrl.$$conflictDs[0].desc}}
  88 + </h3>
  89 + <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
  90 + </div>
  91 + </div>
  92 +
  93 + <script type="text/ng-template" id="$saScpdateCtrl_popover_3.html">
  94 + <div><span>当天没有时刻表详细信息,如下:</span></div>
  95 + <div ng-repeat="info in $saScpdateCtrl.$$emptyDs track by $index">
  96 + <span>{{info.desc}}</span>
  97 + </div>
  98 + <div><span>业务上确实当天无时刻表,需要调整时刻表或规则适应,方法如下:</span></div>
  99 + <div><span>第一种方法:编写一张假的时刻表,使用假路牌(如添加一个假路牌一个假班次的时刻表)</span></div>
  100 + <div><span>第二种方法:调整相关规则,指定翻班类型为翻班格式,当天没有时刻表的指定为0</span></div>
  101 + </script>
  102 + <div ng-if="$saScpdateCtrl.$$emptyDs.length > 0">
  103 + <div class="alert alert-warning well-sm col-md-12" uib-popover-template="'$saScpdateCtrl_popover_3.html'"
  104 + popover-class="increase-popover-width"
  105 + popover-trigger="mouseenter">
  106 + <h3 class="col-md-8">
  107 + {{$saScpdateCtrl.$$emptyDs[0].desc}}
  108 + </h3>
  109 + <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
  110 + </div>
  111 + </div>
  112 +
75 113 </div>
76 114 </div>
77 115 </div>
78 116  
79 117  
80 118  
81   -</div>
82 119 \ No newline at end of file
  120 +</div>
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
... ... @@ -5033,8 +5033,12 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5033 5033 // 内部ng-model值,用于和required配对
5034 5034 self.$$internalmodel = undefined;
5035 5035  
5036   - // 内部数据源(时刻表的一些信息)
  5036 + // 内部数据源(时刻表的统计信息)
5037 5037 self.$$ds = [];
  5038 + // 内部数据源(时刻表的冲突信息)
  5039 + self.$$conflictDs = [];
  5040 + // 内部数据源(时刻表的空信息)
  5041 + self.$$emptyDs = [];
5038 5042  
5039 5043 },
5040 5044 compile: function(tElem, tAttrs) {
... ... @@ -5122,10 +5126,11 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5122 5126 var ttinfoids = [];
5123 5127 QClass.val({xlid: xl_id, from: from_date, to: to_date},
5124 5128 function(result) {
5125   - scope[ctrlAs].$$ds = [];
  5129 + var errorList = [];
5126 5130  
  5131 + //---------------- 1、计算时刻表统计信息 ----------------//
  5132 + scope[ctrlAs].$$ds = [];
5127 5133 var errorTTInfos = 0;
5128   -
5129 5134 if (result && result.data && result.data.infos && result.data.infos.length > 0) {
5130 5135 angular.forEach(result.data.infos, function(obj) {
5131 5136 scope[ctrlAs].$$ds.push({
... ... @@ -5154,17 +5159,53 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5154 5159 });
5155 5160  
5156 5161 if (errorTTInfos > 0) {
5157   - scope[ctrlAs].$$internalmodel = undefined;
5158   - scope[ctrlAs].error = "时刻表有错误班次";
  5162 + errorList.push("时刻表有错误班次");
5159 5163 } else {
5160   - scope[ctrlAs].$$internalmodel = "ok";
5161 5164 scope[ctrlAs].ttinfonames = ttinfonames.join(",");
5162 5165 scope[ctrlAs].ttinfoids = ttinfoids.join(",");
5163 5166 }
5164 5167  
5165 5168 } else {
  5169 + errorList.push("无可用时刻表");
  5170 + }
  5171 +
  5172 + //---------------- 2、计算当天时刻表冲突信息 ----------------//
  5173 + scope[ctrlAs].$$conflictDs = [];
  5174 + if (result && result.data && result.data.conflictStatInfos && result.data.conflictStatInfos.length > 0) {
  5175 + errorList.push("当天时刻表有冲突");
  5176 + // 截取前五条数据显示,如果大于五条,加还有更多提示
  5177 + var c_temp_list = result.data.conflictStatInfos.splice(0, 5);
  5178 + angular.forEach(c_temp_list, function(obj) {
  5179 + scope[ctrlAs].$$conflictDs.push({
  5180 + desc: obj.dateDesc + "匹配到" + obj.ttIdList.length + "张时刻表"
  5181 + });
  5182 + });
  5183 + if (result.data.conflictStatInfos.length > 5) {
  5184 + scope[ctrlAs].$$conflictDs.push({desc : "还有更多"});
  5185 + }
  5186 + }
  5187 +
  5188 + //---------------- 3、计算当天空时刻表信息 ----------------//
  5189 + scope[ctrlAs].$$emptyDs = [];
  5190 + if (result && result.data && result.data.emptyStatInfos && result.data.emptyStatInfos.length > 0) {
  5191 + // 截取前五条数据显示,如果大于五条,加还有更多提示
  5192 + var e_temp_list = result.data.emptyStatInfos.splice(0, 5);
  5193 + angular.forEach(e_temp_list, function(obj) {
  5194 + scope[ctrlAs].$$emptyDs.push({
  5195 + desc: obj.dateDesc + "没有匹配到时刻表"
  5196 + });
  5197 + });
  5198 + if (result.data.emptyStatInfos.length > 5) {
  5199 + scope[ctrlAs].$$emptyDs.push({desc : "还有更多"});
  5200 + }
  5201 + }
  5202 +
  5203 + //---------------- 4、输出错误,计算model ----------------//
  5204 + if (errorList.length > 0) {
5166 5205 scope[ctrlAs].$$internalmodel = undefined;
5167   - scope[ctrlAs].error = "无可用时刻表";
  5206 + scope[ctrlAs].error = errorList.join(",");
  5207 + } else {
  5208 + scope[ctrlAs].$$internalmodel = "ok";
5168 5209 }
5169 5210 },
5170 5211 function() {
... ... @@ -5172,9 +5213,6 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5172 5213 scope[ctrlAs].error = "获取时刻表数据失败!";
5173 5214 }
5174 5215 );
5175   -
5176   -
5177   - scope[ctrlAs].$$internalmodel = "ok";
5178 5216 };
5179 5217  
5180 5218 scope[ctrlAs].$$internal_model_refresh(); // 初始执行
... ... @@ -5228,7 +5266,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
5228 5266 };
5229 5267 }
5230 5268 ]
5231   -);
  5269 +);
  5270 +
5232 5271 /**
5233 5272 * saSrule指令(非通用指令,只在排班计划form中使用)。
5234 5273 * 属性如下:
... ...
src/test/java/com/bsth/service/schedule/PlanValidateTest.java
... ... @@ -34,11 +34,11 @@ public class PlanValidateTest extends BaseTest_junit4 {
34 34 }
35 35  
36 36 @Autowired
37   - @Qualifier("kBaseValidateTimetable")
  37 + @Qualifier("kBaseValidateTimetable_plus")
38 38 private KieBase kBaseValidateTimetable;
39 39  
40 40 @Autowired
41   - @Qualifier("kBaseValidateRule")
  41 + @Qualifier("kBaseValidateRule_plus")
42 42 private KieBase kBaseValidateRule;
43 43  
44 44 @Autowired
... ... @@ -213,4 +213,6 @@ public class PlanValidateTest extends BaseTest_junit4 {
213 213 validateRuleResult.getErrorInfos().size()
214 214 });
215 215 }
  216 +
  217 + // TODO:有空再把排班的逻辑移植过来
216 218 }
... ...
src/test/resources/META-INF/drools.packagebuilder.conf
1 1 # 貌似用import accumulate报错,使用配置文件方式
2 2  
3 3 # kBase_validate_timetable.drl使用
4   -drools.accumulate.function.ecount = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_ErrorBcCount
  4 +drools.accumulate.function.ecount2 = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_ErrorBcCount
5 5 drools.accumulate.function.as = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_AccumulateStatInfo
6 6 drools.accumulate.function.ac = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_AccumulateConflict
7 7 drools.accumulate.function.ae = com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Function_AccumulateEmpty
8 8 # kBase_validate_rule.drl使用
9   -drools.accumulate.function.srif = com.bsth.service.schedule.plan.process._1_validate._2_rule.drools.KBaseValidateRule_Function_ErrorInfo
  9 +drools.accumulate.function.srif2 = com.bsth.service.schedule.plan.process._1_validate._2_rule.drools.KBaseValidateRule_Function_ErrorInfo
... ...