Commit ad64dc52e1fd2057f9009ebec809418b8592b670
1 parent
fa6bc269
Update
Showing
11 changed files
with
293 additions
and
125 deletions
pom.xml
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController.java
| ... | ... | @@ -81,7 +81,6 @@ public class SchedulePlanController extends BController<SchedulePlan, Long> { |
| 81 | 81 | @PathVariable(value = "from") Date from, |
| 82 | 82 | @PathVariable(value = "to") Date to |
| 83 | 83 | ) throws Exception { |
| 84 | - // TODO:测试数据 | |
| 85 | 84 | Map<String, Object> rtn = new HashMap<>(); |
| 86 | 85 | rtn.put("status", ResponseCode.SUCCESS); |
| 87 | 86 | rtn.put("data", schedulePlanService.validateTTInfo(xlid, from, to)); | ... | ... |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| ... | ... | @@ -8,6 +8,7 @@ import com.bsth.repository.schedule.SchedulePlanInfoRepository; |
| 8 | 8 | import com.bsth.repository.schedule.SchedulePlanRepository; |
| 9 | 9 | import com.bsth.service.LineService; |
| 10 | 10 | import com.bsth.service.schedule.SchedulePlanService; |
| 11 | +import com.bsth.service.schedule.TTInfoDetailService; | |
| 11 | 12 | import com.bsth.service.schedule.TTInfoService; |
| 12 | 13 | import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; |
| 13 | 14 | import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output; |
| ... | ... | @@ -48,6 +49,8 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 48 | 49 | private LineService lineService; |
| 49 | 50 | @Autowired |
| 50 | 51 | private TTInfoService ttInfoService; |
| 52 | + @Autowired | |
| 53 | + private TTInfoDetailService ttInfoDetailService; | |
| 51 | 54 | |
| 52 | 55 | /** 日志记录器 */ |
| 53 | 56 | private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class); |
| ... | ... | @@ -186,9 +189,13 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 186 | 189 | // 构造drools session->载入数据->启动规则->计算->销毁session |
| 187 | 190 | // 创建session,内部配置的是stateful |
| 188 | 191 | KieSession session = kieBase.newKieSession(); |
| 189 | - // TODO:设置gloable对象,在drl中通过别名使用 | |
| 192 | + // 设置gloable对象,在drl中通过别名使用 | |
| 190 | 193 | session.setGlobal("log", logger); |
| 191 | 194 | session.setGlobal("lineService", lineService); |
| 195 | + session.setGlobal("ttInfoDetailService", ttInfoDetailService); | |
| 196 | + | |
| 197 | + Result rs = new Result(); // 输出gloable对象 | |
| 198 | + session.setGlobal("rs", rs); | |
| 192 | 199 | |
| 193 | 200 | // 载入数据 |
| 194 | 201 | CalcuParam calcuParam = new CalcuParam( |
| ... | ... | @@ -206,6 +213,6 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 206 | 213 | session.dispose(); |
| 207 | 214 | |
| 208 | 215 | |
| 209 | - return null; | |
| 216 | + return rs; | |
| 210 | 217 | } |
| 211 | 218 | } | ... | ... |
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
| ... | ... | @@ -52,6 +52,9 @@ public class MyDroolsConfiguration { |
| 52 | 52 | // 3.2、写入drl(写法超多,有点混乱) |
| 53 | 53 | // 这里使用文件的形式写入,TODO:以后考虑从数据库中读drl写入 |
| 54 | 54 | // 注意kfs写的时候如果指定path,强制为src/main/resources/加上文件名,还有就是文件名不要重复否则会覆盖的 |
| 55 | + kfs.write("src/main/resources/functions.drl", kieServices.getResources() | |
| 56 | + .newInputStreamResource(this.getClass().getResourceAsStream( | |
| 57 | + "/rules/functions.drl"), "UTF-8")); | |
| 55 | 58 | kfs.write("src/main/resources/HelloWorld.drl", kieServices.getResources() |
| 56 | 59 | .newInputStreamResource(this.getClass().getResourceAsStream( |
| 57 | 60 | "/rules/HelloWorld.drl"), "UTF-8")); | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ttinfo2/ErrorBcCountFunction.java
0 → 100644
| 1 | +package com.bsth.service.schedule.rules.ttinfo2; | |
| 2 | + | |
| 3 | +import com.bsth.entity.schedule.TTInfoDetail; | |
| 4 | +import org.kie.api.runtime.rule.AccumulateFunction; | |
| 5 | + | |
| 6 | +import java.io.*; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Created by xu on 17/2/28. | |
| 10 | + */ | |
| 11 | +public class ErrorBcCountFunction implements AccumulateFunction { | |
| 12 | + @Override | |
| 13 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 14 | + } | |
| 15 | + | |
| 16 | + @Override | |
| 17 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 18 | + } | |
| 19 | + | |
| 20 | + protected static class ErrorCountData implements Externalizable { | |
| 21 | + public long errorcount = 0; | |
| 22 | + public TTInfoDetail ttInfoDetail; | |
| 23 | + | |
| 24 | + public ErrorCountData() { | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | |
| 29 | + errorcount = in.readLong(); | |
| 30 | + ttInfoDetail = (TTInfoDetail) in.readObject(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public void writeExternal(ObjectOutput out) throws IOException { | |
| 35 | + out.writeLong(errorcount); | |
| 36 | + out.writeObject(ttInfoDetail); | |
| 37 | + } | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public Serializable createContext() { | |
| 42 | + return new ErrorCountData(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public void init(Serializable context) throws Exception { | |
| 47 | + ErrorCountData errorCountData = (ErrorCountData) context; | |
| 48 | + errorCountData.errorcount = 0; | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void accumulate(Serializable context, Object value) { | |
| 53 | + ErrorCountData errorCountData = (ErrorCountData) context; | |
| 54 | + TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 55 | + | |
| 56 | + if (ttInfoDetail.getTtinfo() == null) { | |
| 57 | + errorCountData.errorcount ++; | |
| 58 | + return; | |
| 59 | + } | |
| 60 | + | |
| 61 | + if ("in".equals(ttInfoDetail.getBcType())) { | |
| 62 | + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getTcc() == null) { | |
| 63 | + errorCountData.errorcount ++; | |
| 64 | + } | |
| 65 | + } else if ("out".equals(ttInfoDetail.getBcType())) { | |
| 66 | + if (ttInfoDetail.getTcc() == null || ttInfoDetail.getZdz() == null) { | |
| 67 | + errorCountData.errorcount ++; | |
| 68 | + } | |
| 69 | + } else { | |
| 70 | + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getZdz() == null) { | |
| 71 | + errorCountData.errorcount ++; | |
| 72 | + } | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public void reverse(Serializable context, Object value) throws Exception { | |
| 78 | + ErrorCountData errorCountData = (ErrorCountData) context; | |
| 79 | + TTInfoDetail ttInfoDetail = (TTInfoDetail) value; | |
| 80 | + | |
| 81 | + if (ttInfoDetail.getTtinfo() == null) { | |
| 82 | + errorCountData.errorcount --; | |
| 83 | + return; | |
| 84 | + } | |
| 85 | + | |
| 86 | + if ("in".equals(ttInfoDetail.getBcType())) { | |
| 87 | + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getTcc() == null) { | |
| 88 | + errorCountData.errorcount --; | |
| 89 | + } | |
| 90 | + } else if ("out".equals(ttInfoDetail.getBcType())) { | |
| 91 | + if (ttInfoDetail.getTcc() == null || ttInfoDetail.getZdz() == null) { | |
| 92 | + errorCountData.errorcount --; | |
| 93 | + } | |
| 94 | + } else { | |
| 95 | + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getZdz() == null) { | |
| 96 | + errorCountData.errorcount --; | |
| 97 | + } | |
| 98 | + } | |
| 99 | + | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Override | |
| 103 | + public Object getResult(Serializable context) throws Exception { | |
| 104 | + ErrorCountData errorCountData = (ErrorCountData) context; | |
| 105 | + return errorCountData.errorcount; | |
| 106 | + } | |
| 107 | + | |
| 108 | + @Override | |
| 109 | + public boolean supportsReverse() { | |
| 110 | + return true; | |
| 111 | + } | |
| 112 | + | |
| 113 | + @Override | |
| 114 | + public Class<?> getResultType() { | |
| 115 | + return Number.class; | |
| 116 | + } | |
| 117 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ttinfo2/Result.java
| ... | ... | @@ -9,6 +9,14 @@ import java.util.List; |
| 9 | 9 | public class Result { |
| 10 | 10 | private List<StatInfo> infos = new ArrayList<>(); |
| 11 | 11 | |
| 12 | + public List<StatInfo> getInfos() { | |
| 13 | + return infos; | |
| 14 | + } | |
| 15 | + | |
| 16 | + public void setInfos(List<StatInfo> infos) { | |
| 17 | + this.infos = infos; | |
| 18 | + } | |
| 19 | + | |
| 12 | 20 | public static class StatInfo { |
| 13 | 21 | /** 时刻表id */ |
| 14 | 22 | private Long ttid; |
| ... | ... | @@ -16,16 +24,16 @@ public class Result { |
| 16 | 24 | private String ttname; |
| 17 | 25 | |
| 18 | 26 | /** 所有班次数 */ |
| 19 | - private Integer allbc; | |
| 27 | + private Long allbc; | |
| 20 | 28 | /** 进场班次数 */ |
| 21 | - private Integer inbc; | |
| 29 | + private Long inbc; | |
| 22 | 30 | /** 出场班次数 */ |
| 23 | - private Integer outbc; | |
| 31 | + private Long outbc; | |
| 24 | 32 | /** 营运班次数 */ |
| 25 | - private Integer yybc; | |
| 33 | + private Long yybc; | |
| 26 | 34 | |
| 27 | 35 | /** 错误班次数 */ |
| 28 | - private Integer errorbc; | |
| 36 | + private Long errorbc; | |
| 29 | 37 | |
| 30 | 38 | public Long getTtid() { |
| 31 | 39 | return ttid; |
| ... | ... | @@ -43,43 +51,43 @@ public class Result { |
| 43 | 51 | this.ttname = ttname; |
| 44 | 52 | } |
| 45 | 53 | |
| 46 | - public Integer getAllbc() { | |
| 54 | + public Long getAllbc() { | |
| 47 | 55 | return allbc; |
| 48 | 56 | } |
| 49 | 57 | |
| 50 | - public void setAllbc(Integer allbc) { | |
| 58 | + public void setAllbc(Long allbc) { | |
| 51 | 59 | this.allbc = allbc; |
| 52 | 60 | } |
| 53 | 61 | |
| 54 | - public Integer getInbc() { | |
| 62 | + public Long getInbc() { | |
| 55 | 63 | return inbc; |
| 56 | 64 | } |
| 57 | 65 | |
| 58 | - public void setInbc(Integer inbc) { | |
| 66 | + public void setInbc(Long inbc) { | |
| 59 | 67 | this.inbc = inbc; |
| 60 | 68 | } |
| 61 | 69 | |
| 62 | - public Integer getOutbc() { | |
| 70 | + public Long getOutbc() { | |
| 63 | 71 | return outbc; |
| 64 | 72 | } |
| 65 | 73 | |
| 66 | - public void setOutbc(Integer outbc) { | |
| 74 | + public void setOutbc(Long outbc) { | |
| 67 | 75 | this.outbc = outbc; |
| 68 | 76 | } |
| 69 | 77 | |
| 70 | - public Integer getYybc() { | |
| 78 | + public Long getYybc() { | |
| 71 | 79 | return yybc; |
| 72 | 80 | } |
| 73 | 81 | |
| 74 | - public void setYybc(Integer yybc) { | |
| 82 | + public void setYybc(Long yybc) { | |
| 75 | 83 | this.yybc = yybc; |
| 76 | 84 | } |
| 77 | 85 | |
| 78 | - public Integer getErrorbc() { | |
| 86 | + public Long getErrorbc() { | |
| 79 | 87 | return errorbc; |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | - public void setErrorbc(Integer errorbc) { | |
| 90 | + public void setErrorbc(Long errorbc) { | |
| 83 | 91 | this.errorbc = errorbc; |
| 84 | 92 | } |
| 85 | 93 | } | ... | ... |
src/main/resources/rules/functions.drl
0 → 100644
src/main/resources/rules/ttinfo2.drl
| ... | ... | @@ -13,13 +13,19 @@ import com.bsth.entity.schedule.TTInfoDetail; |
| 13 | 13 | import com.bsth.entity.Line; |
| 14 | 14 | |
| 15 | 15 | import com.bsth.service.LineService; |
| 16 | +import com.bsth.service.schedule.TTInfoDetailService; | |
| 16 | 17 | |
| 17 | 18 | import org.slf4j.Logger |
| 18 | -import org.joda.time.format.DateTimeFormat; | |
| 19 | +import org.joda.time.format.DateTimeFormat | |
| 20 | +import java.lang.String | |
| 21 | +import java.lang.Object; | |
| 22 | + | |
| 19 | 23 | |
| 20 | 24 | // 全局日志类(一般使用调用此规则的service类) |
| 21 | 25 | global Logger log; |
| 22 | 26 | global LineService lineService; |
| 27 | +global TTInfoDetailService ttInfoDetailService; | |
| 28 | + | |
| 23 | 29 | // 输出 |
| 24 | 30 | global Result rs; |
| 25 | 31 | |
| ... | ... | @@ -146,6 +152,11 @@ end |
| 146 | 152 | |
| 147 | 153 | //-------------- 第三阶段、时刻表的日期匹配 ------------// |
| 148 | 154 | |
| 155 | +declare TTInfoDetails_wrap | |
| 156 | + ttInfoId: Long // 时刻表id | |
| 157 | + bcInfoList: List // 班次信息列表 List<TTInfoDetail> | |
| 158 | +end | |
| 159 | + | |
| 149 | 160 | rule "Calcu_iter_days_special_day" // 特殊日期匹配 |
| 150 | 161 | salience 800 |
| 151 | 162 | when |
| ... | ... | @@ -178,6 +189,13 @@ rule "Calcu_iter_days_special_day" // 特殊日期匹配 |
| 178 | 189 | statInfo.setTtid($tid); |
| 179 | 190 | statInfo.setTtname($tname); |
| 180 | 191 | insert(statInfo); |
| 192 | + | |
| 193 | + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap(); | |
| 194 | + ttInfoDetails_wrap.setTtInfoId($tid); | |
| 195 | + Map<String, Object> param = new HashMap<String, Object>(); | |
| 196 | + param.put("ttinfo.id_eq", $tid); | |
| 197 | + ttInfoDetails_wrap.setBcInfoList(ttInfoDetailService.list(param)); | |
| 198 | + insert(ttInfoDetails_wrap); | |
| 181 | 199 | } |
| 182 | 200 | update($cid); |
| 183 | 201 | |
| ... | ... | @@ -218,6 +236,13 @@ rule "Calcu_iter_days_normal_day" // 平日匹配 |
| 218 | 236 | statInfo.setTtid($tid); |
| 219 | 237 | statInfo.setTtname($tname); |
| 220 | 238 | insert(statInfo); |
| 239 | + | |
| 240 | + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap(); | |
| 241 | + ttInfoDetails_wrap.setTtInfoId($tid); | |
| 242 | + Map<String, Object> param = new HashMap<String, Object>(); | |
| 243 | + param.put("ttinfo.id_eq", $tid); | |
| 244 | + ttInfoDetails_wrap.setBcInfoList(ttInfoDetailService.list(param)); | |
| 245 | + insert(ttInfoDetails_wrap); | |
| 221 | 246 | } |
| 222 | 247 | update($cid); |
| 223 | 248 | |
| ... | ... | @@ -257,6 +282,13 @@ rule "Calcu_iter_days_other_day" // 都没有的情况下,匹配 |
| 257 | 282 | statInfo.setTtid($tid); |
| 258 | 283 | statInfo.setTtname($tname); |
| 259 | 284 | insert(statInfo); |
| 285 | + | |
| 286 | + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap(); | |
| 287 | + ttInfoDetails_wrap.setTtInfoId($tid); | |
| 288 | + Map<String, Object> param = new HashMap<String, Object>(); | |
| 289 | + param.put("ttinfo.id_eq", $tid); | |
| 290 | + ttInfoDetails_wrap.setBcInfoList(ttInfoDetailService.list(param)); | |
| 291 | + insert(ttInfoDetails_wrap); | |
| 260 | 292 | } |
| 261 | 293 | update($cid); |
| 262 | 294 | |
| ... | ... | @@ -264,12 +296,27 @@ end |
| 264 | 296 | |
| 265 | 297 | //-------------- 第四阶段、时刻表明细统计值 ------------// |
| 266 | 298 | |
| 267 | -rule "statinfo_result" | |
| 299 | +rule "statinfo_result" // 统计计算结果 | |
| 300 | + salience 300 | |
| 301 | + no-loop | |
| 268 | 302 | when |
| 269 | - $statInfo: StatInfo() | |
| 303 | + $statInfo: StatInfo($tid: ttid) | |
| 304 | + $ttInfoDetails_wrap: TTInfoDetails_wrap(ttInfoId == $tid) | |
| 305 | + $allbc: Long() from accumulate (TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), count()) | |
| 306 | + $inbc: Long() from accumulate (TTInfoDetail(bcType == "in") from $ttInfoDetails_wrap.getBcInfoList(), count()) | |
| 307 | + $outbc: Long() from accumulate (TTInfoDetail(bcType == "out") from $ttInfoDetails_wrap.getBcInfoList(), count()) | |
| 308 | + $yybc: Long() from accumulate (TTInfoDetail(bcType != "out", bcType != "in") from $ttInfoDetails_wrap.getBcInfoList(), count()) | |
| 309 | + $errorbc: Long() from accumulate ($ttd: TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), ecount($ttd)) | |
| 270 | 310 | then |
| 311 | + log.info("时刻表={},id={},班次数={},进场={},出场={},营运={},错误={}", $statInfo.getTtname(), $statInfo.getTtid(), $allbc, $inbc, $outbc, $yybc, $errorbc); | |
| 312 | + | |
| 313 | + $statInfo.setAllbc($allbc); | |
| 314 | + $statInfo.setInbc($inbc); | |
| 315 | + $statInfo.setOutbc($outbc); | |
| 316 | + $statInfo.setYybc($yybc); | |
| 317 | + $statInfo.setErrorbc($errorbc); | |
| 271 | 318 | |
| 272 | - log.info("TODO:时刻表={},id={}", $statInfo.getTtname(), $statInfo.getTtid()); | |
| 319 | + rs.getInfos().add($statInfo); | |
| 273 | 320 | |
| 274 | 321 | end |
| 275 | 322 | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdate.js
| ... | ... | @@ -110,60 +110,52 @@ angular.module('ScheduleApp').directive( |
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | + if (!scope[ctrlAs].$$ds || scope[ctrlAs].$$ds.length == 0) { | |
| 114 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 115 | + scope[ctrlAs].error = "无可用时刻表"; | |
| 116 | + } | |
| 117 | + | |
| 113 | 118 | var QClass = service.ttinfo; |
| 114 | 119 | QClass.val({xlid: xl_id, from: from_date, to: to_date}, |
| 115 | 120 | function(result) { |
| 116 | 121 | scope[ctrlAs].$$ds = []; |
| 117 | 122 | |
| 118 | - // 模拟数据 | |
| 119 | - scope[ctrlAs].$$ds.push( | |
| 120 | - { | |
| 121 | - xlid: 63020, | |
| 122 | - ttid: 79, | |
| 123 | - xlname: '青浦8路', | |
| 124 | - ttname: '测试周末表', | |
| 125 | - | |
| 126 | - allbc: 18, | |
| 127 | - inbc: 4, | |
| 128 | - outbc: 4, | |
| 129 | - yybc: 14, | |
| 130 | - | |
| 131 | - errorbc: 0 | |
| 132 | - | |
| 133 | - }, | |
| 134 | - { | |
| 135 | - xlid: 63020, | |
| 136 | - ttid: 80, | |
| 137 | - xlname: '青浦8路', | |
| 138 | - ttname: '周四周五test', | |
| 139 | - | |
| 140 | - allbc: 18, | |
| 141 | - inbc: 4, | |
| 142 | - outbc: 4, | |
| 143 | - yybc: 14, | |
| 144 | - | |
| 145 | - errorbc: 10 | |
| 146 | - | |
| 147 | - }, | |
| 148 | - { | |
| 149 | - xlid: 63020, | |
| 150 | - ttid: 64, | |
| 151 | - xlname: '青浦8路', | |
| 152 | - ttname: '青浦8路时刻表1111', | |
| 153 | - | |
| 154 | - allbc: 18, | |
| 155 | - inbc: 4, | |
| 156 | - outbc: 4, | |
| 157 | - yybc: 14, | |
| 158 | - | |
| 159 | - errorbc: 10 | |
| 123 | + var errorTTInfos = 0; | |
| 160 | 124 | |
| 161 | - } | |
| 162 | - ); | |
| 125 | + if (result && result.data && result.data.infos && result.data.infos.length > 0) { | |
| 126 | + angular.forEach(result.data.infos, function(obj) { | |
| 127 | + scope[ctrlAs].$$ds.push({ | |
| 128 | + xlid: xl_id, | |
| 129 | + ttid: obj.ttid, | |
| 130 | + xlname: xl_name, | |
| 131 | + ttname: obj.ttname, | |
| 132 | + | |
| 133 | + allbc: obj.allbc, | |
| 134 | + inbc: obj.inbc, | |
| 135 | + outbc: obj.outbc, | |
| 136 | + yybc: obj.yybc, | |
| 163 | 137 | |
| 138 | + errorbc: obj.errorbc | |
| 164 | 139 | |
| 140 | + }); | |
| 141 | + | |
| 142 | + if (obj.errorbc > 0) { | |
| 143 | + errorTTInfos ++; | |
| 144 | + } | |
| 145 | + }); | |
| 146 | + | |
| 147 | + if (errorTTInfos > 0) { | |
| 148 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 149 | + scope[ctrlAs].error = "时刻表有错误班次"; | |
| 150 | + } else { | |
| 151 | + | |
| 152 | + scope[ctrlAs].$$internalmodel = "ok"; | |
| 153 | + } | |
| 165 | 154 | |
| 166 | - scope[ctrlAs].$$internalmodel = "ok"; | |
| 155 | + } else { | |
| 156 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 157 | + scope[ctrlAs].error = "无可用时刻表"; | |
| 158 | + } | |
| 167 | 159 | }, |
| 168 | 160 | function() { |
| 169 | 161 | scope[ctrlAs].$$internalmodel = undefined; | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
| ... | ... | @@ -3930,60 +3930,52 @@ angular.module('ScheduleApp').directive( |
| 3930 | 3930 | return; |
| 3931 | 3931 | } |
| 3932 | 3932 | |
| 3933 | + if (!scope[ctrlAs].$$ds || scope[ctrlAs].$$ds.length == 0) { | |
| 3934 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 3935 | + scope[ctrlAs].error = "无可用时刻表"; | |
| 3936 | + } | |
| 3937 | + | |
| 3933 | 3938 | var QClass = service.ttinfo; |
| 3934 | 3939 | QClass.val({xlid: xl_id, from: from_date, to: to_date}, |
| 3935 | 3940 | function(result) { |
| 3936 | 3941 | scope[ctrlAs].$$ds = []; |
| 3937 | 3942 | |
| 3938 | - // 模拟数据 | |
| 3939 | - scope[ctrlAs].$$ds.push( | |
| 3940 | - { | |
| 3941 | - xlid: 63020, | |
| 3942 | - ttid: 79, | |
| 3943 | - xlname: '青浦8路', | |
| 3944 | - ttname: '测试周末表', | |
| 3945 | - | |
| 3946 | - allbc: 18, | |
| 3947 | - inbc: 4, | |
| 3948 | - outbc: 4, | |
| 3949 | - yybc: 14, | |
| 3950 | - | |
| 3951 | - errorbc: 0 | |
| 3943 | + var errorTTInfos = 0; | |
| 3952 | 3944 | |
| 3953 | - }, | |
| 3954 | - { | |
| 3955 | - xlid: 63020, | |
| 3956 | - ttid: 80, | |
| 3957 | - xlname: '青浦8路', | |
| 3958 | - ttname: '周四周五test', | |
| 3945 | + if (result && result.data && result.data.infos && result.data.infos.length > 0) { | |
| 3946 | + angular.forEach(result.data.infos, function(obj) { | |
| 3947 | + scope[ctrlAs].$$ds.push({ | |
| 3948 | + xlid: xl_id, | |
| 3949 | + ttid: obj.ttid, | |
| 3950 | + xlname: xl_name, | |
| 3951 | + ttname: obj.ttname, | |
| 3959 | 3952 | |
| 3960 | - allbc: 18, | |
| 3961 | - inbc: 4, | |
| 3962 | - outbc: 4, | |
| 3963 | - yybc: 14, | |
| 3953 | + allbc: obj.allbc, | |
| 3954 | + inbc: obj.inbc, | |
| 3955 | + outbc: obj.outbc, | |
| 3956 | + yybc: obj.yybc, | |
| 3964 | 3957 | |
| 3965 | - errorbc: 10 | |
| 3958 | + errorbc: obj.errorbc | |
| 3966 | 3959 | |
| 3967 | - }, | |
| 3968 | - { | |
| 3969 | - xlid: 63020, | |
| 3970 | - ttid: 64, | |
| 3971 | - xlname: '青浦8路', | |
| 3972 | - ttname: '青浦8路时刻表1111', | |
| 3960 | + }); | |
| 3973 | 3961 | |
| 3974 | - allbc: 18, | |
| 3975 | - inbc: 4, | |
| 3976 | - outbc: 4, | |
| 3977 | - yybc: 14, | |
| 3962 | + if (obj.errorbc > 0) { | |
| 3963 | + errorTTInfos ++; | |
| 3964 | + } | |
| 3965 | + }); | |
| 3978 | 3966 | |
| 3979 | - errorbc: 10 | |
| 3967 | + if (errorTTInfos > 0) { | |
| 3968 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 3969 | + scope[ctrlAs].error = "时刻表有错误班次"; | |
| 3970 | + } else { | |
| 3980 | 3971 | |
| 3972 | + scope[ctrlAs].$$internalmodel = "ok"; | |
| 3981 | 3973 | } |
| 3982 | - ); | |
| 3983 | - | |
| 3984 | 3974 | |
| 3985 | - | |
| 3986 | - scope[ctrlAs].$$internalmodel = "ok"; | |
| 3975 | + } else { | |
| 3976 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 3977 | + scope[ctrlAs].error = "无可用时刻表"; | |
| 3978 | + } | |
| 3987 | 3979 | }, |
| 3988 | 3980 | function() { |
| 3989 | 3981 | scope[ctrlAs].$$internalmodel = undefined; | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/form.html
| ... | ... | @@ -106,23 +106,23 @@ |
| 106 | 106 | </div> |
| 107 | 107 | </div> |
| 108 | 108 | |
| 109 | - <!--<div class="form-group has-success has-feedback">--> | |
| 110 | - <!--<label class="col-md-2 control-label">时刻表信息*:</label>--> | |
| 111 | - <!--<div class="col-md-6">--> | |
| 112 | - <!--<sa-Scpdate name="scp_s_t_date"--> | |
| 113 | - <!--xlid="ctrl.schedulePlanManageForSave.xl.id"--> | |
| 114 | - <!--xlname="ctrl.schedulePlanManageForSave.xl.name"--> | |
| 115 | - <!--from="ctrl.schedulePlanManageForSave.scheduleFromTime"--> | |
| 116 | - <!--to="ctrl.schedulePlanManageForSave.scheduleToTime"--> | |
| 117 | - <!--error="ctrl.scperror"--> | |
| 118 | - <!--required--> | |
| 119 | - <!-->--> | |
| 120 | - <!--</sa-Scpdate>--> | |
| 121 | - <!--</div>--> | |
| 122 | - <!--<div class="alert alert-danger well-sm" ng-show="myForm.scp_s_t_date.$error.required">--> | |
| 123 | - <!--{{ctrl.scperror}}--> | |
| 124 | - <!--</div>--> | |
| 125 | - <!--</div>--> | |
| 109 | + <div class="form-group has-success has-feedback"> | |
| 110 | + <label class="col-md-2 control-label">时刻表信息*:</label> | |
| 111 | + <div class="col-md-6"> | |
| 112 | + <sa-Scpdate name="scp_s_t_date" | |
| 113 | + xlid="ctrl.schedulePlanManageForSave.xl.id" | |
| 114 | + xlname="ctrl.schedulePlanManageForSave.xl.name" | |
| 115 | + from="ctrl.schedulePlanManageForSave.scheduleFromTime" | |
| 116 | + to="ctrl.schedulePlanManageForSave.scheduleToTime" | |
| 117 | + error="ctrl.scperror" | |
| 118 | + required | |
| 119 | + > | |
| 120 | + </sa-Scpdate> | |
| 121 | + </div> | |
| 122 | + <div class="alert alert-danger well-sm" ng-show="myForm.scp_s_t_date.$error.required"> | |
| 123 | + {{ctrl.scperror}} | |
| 124 | + </div> | |
| 125 | + </div> | |
| 126 | 126 | |
| 127 | 127 | <!-- 其他form-group --> |
| 128 | 128 | ... | ... |