Commit 1cb69210b707f031d6c9f79792a883e23d5a1ca2

Authored by 廖磊
2 parents e0f4b2b1 deb01f8b

Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control

into pudong
Showing 50 changed files with 8018 additions and 7965 deletions
src/main/java/com/bsth/controller/LineVersionsController.java
1 package com.bsth.controller; 1 package com.bsth.controller;
2 2
3 -import java.util.List;  
4 -import java.util.Map;  
5 - 3 +import com.bsth.entity.LineVersions;
  4 +import com.bsth.repository.LineRepository;
  5 +import com.bsth.service.LineVersionsService;
6 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.web.bind.annotation.RequestMapping; 7 import org.springframework.web.bind.annotation.RequestMapping;
8 import org.springframework.web.bind.annotation.RequestMethod; 8 import org.springframework.web.bind.annotation.RequestMethod;
9 import org.springframework.web.bind.annotation.RequestParam; 9 import org.springframework.web.bind.annotation.RequestParam;
10 import org.springframework.web.bind.annotation.RestController; 10 import org.springframework.web.bind.annotation.RestController;
11 11
12 -import com.bsth.entity.LineVersions;  
13 -import com.bsth.repository.LineRepository;  
14 -import com.bsth.service.LineVersionsService; 12 +import java.util.List;
  13 +import java.util.Map;
15 14
16 /** 15 /**
17 * 16 *
@@ -75,7 +74,11 @@ public class LineVersionsController extends BaseController<LineVersions, Integer @@ -75,7 +74,11 @@ public class LineVersionsController extends BaseController<LineVersions, Integer
75 public Map<String, Object> add(@RequestParam Map<String, Object> map) { 74 public Map<String, Object> add(@RequestParam Map<String, Object> map) {
76 return service.add(map); 75 return service.add(map);
77 } 76 }
78 - 77 + @RequestMapping(value = "delete", method = RequestMethod.POST)
  78 + public Map<String, Object> delete(@RequestParam (defaultValue = "id") int id) {
  79 + return service.delete(id);
  80 + }
  81 +
79 /** 82 /**
80 * 根据线路id获取当前版本号 83 * 根据线路id获取当前版本号
81 * 84 *
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
@@ -376,7 +376,7 @@ public class GeoDataServiceImpl implements GeoDataService { @@ -376,7 +376,7 @@ public class GeoDataServiceImpl implements GeoDataService {
376 lVersion.setLineCode(lineCode); 376 lVersion.setLineCode(lineCode);
377 377
378 //如果有待启用的版本,设置为历史版本 378 //如果有待启用的版本,设置为历史版本
379 - jdbcTemplate.update("update bsth_c_line_versions set `status`=0, start_date=null,end_date=null where line_code='"+lineCode+"' and `status`=2"); 379 + jdbcTemplate.update("update bsth_c_line_versions set `status`=2, start_date=null,end_date=null where line_code='"+lineCode+"' and `status`=0");
380 380
381 //入库线路版本 381 //入库线路版本
382 jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " + 382 jdbcTemplate.update("insert into bsth_c_line_versions(name, line, line_code, versions, start_date, create_date, update_date, remark,status, isupdate) " +
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
1 package com.bsth.service.impl; 1 package com.bsth.service.impl;
2 2
3 -import java.sql.PreparedStatement;  
4 -import java.sql.SQLException;  
5 -import java.text.ParseException;  
6 -import java.text.SimpleDateFormat;  
7 -import java.util.Date;  
8 -import java.util.HashMap;  
9 -import java.util.List;  
10 -import java.util.Map;  
11 -  
12 -import org.springframework.beans.factory.annotation.Autowired;  
13 -import org.springframework.jdbc.core.BatchPreparedStatementSetter;  
14 -import org.springframework.jdbc.core.JdbcTemplate;  
15 -import org.springframework.stereotype.Service;  
16 -import org.springframework.transaction.annotation.Transactional;  
17 -  
18 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
19 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
20 import com.bsth.common.ResponseCode; 5 import com.bsth.common.ResponseCode;
@@ -31,6 +16,20 @@ import com.bsth.repository.LsStationRouteRepository; @@ -31,6 +16,20 @@ import com.bsth.repository.LsStationRouteRepository;
31 import com.bsth.service.LineVersionsService; 16 import com.bsth.service.LineVersionsService;
32 import com.bsth.service.SectionRouteService; 17 import com.bsth.service.SectionRouteService;
33 import com.bsth.service.StationRouteService; 18 import com.bsth.service.StationRouteService;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  21 +import org.springframework.jdbc.core.JdbcTemplate;
  22 +import org.springframework.stereotype.Service;
  23 +import org.springframework.transaction.annotation.Transactional;
  24 +
  25 +import java.sql.PreparedStatement;
  26 +import java.sql.SQLException;
  27 +import java.text.ParseException;
  28 +import java.text.SimpleDateFormat;
  29 +import java.util.Date;
  30 +import java.util.HashMap;
  31 +import java.util.List;
  32 +import java.util.Map;
34 33
35 /** 34 /**
36 * 35 *
@@ -97,8 +96,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -97,8 +96,10 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
97 int statu = repository.update(id,line,lineCode,new java.sql.Date(startDate.getTime()), 96 int statu = repository.update(id,line,lineCode,new java.sql.Date(startDate.getTime()),
98 new java.sql.Date(endDate.getTime()),versions,status,remark); 97 new java.sql.Date(endDate.getTime()),versions,status,remark);
99 LineVersions upLineVersions = repository.findBylineIdAndVersions(line.getId(),versions); 98 LineVersions upLineVersions = repository.findBylineIdAndVersions(line.getId(),versions);
100 - upLineVersions.setEndDate(new java.sql.Date(startDate.getTime()));  
101 - repository.save(upLineVersions); 99 + if(upLineVersions != null){
  100 + upLineVersions.setEndDate(new java.sql.Date(startDate.getTime()));
  101 + repository.save(upLineVersions);
  102 + }
102 if (statu==1) { 103 if (statu==1) {
103 resultMap.put("status", ResponseCode.SUCCESS); 104 resultMap.put("status", ResponseCode.SUCCESS);
104 } else { 105 } else {
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
1 package com.bsth.service.impl; 1 package com.bsth.service.impl;
2 2
3 import com.bsth.common.ResponseCode; 3 import com.bsth.common.ResponseCode;
4 -import com.bsth.entity.*; 4 +import com.bsth.entity.Line;
  5 +import com.bsth.entity.LsStationRoute;
  6 +import com.bsth.entity.Station;
  7 +import com.bsth.entity.StationRoute;
  8 +import com.bsth.entity.StationRouteCache;
5 import com.bsth.entity.search.CustomerSpecs; 9 import com.bsth.entity.search.CustomerSpecs;
6 -import com.bsth.repository.*; 10 +import com.bsth.repository.LineRepository;
  11 +import com.bsth.repository.LsStationRouteRepository;
  12 +import com.bsth.repository.SectionRouteRepository;
  13 +import com.bsth.repository.StationRepository;
  14 +import com.bsth.repository.StationRouteCacheRepository;
  15 +import com.bsth.repository.StationRouteRepository;
7 import com.bsth.service.StationRouteService; 16 import com.bsth.service.StationRouteService;
8 import com.bsth.util.ExcelUtil; 17 import com.bsth.util.ExcelUtil;
9 import com.bsth.util.FTPClientUtils; 18 import com.bsth.util.FTPClientUtils;
10 -import com.bsth.util.PackTarGZUtils;  
11 import com.bsth.util.Geo.GeoUtils; 19 import com.bsth.util.Geo.GeoUtils;
12 import com.bsth.util.Geo.Point; 20 import com.bsth.util.Geo.Point;
  21 +import com.bsth.util.PackTarGZUtils;
13 import com.bsth.util.db.DBUtils_MS; 22 import com.bsth.util.db.DBUtils_MS;
14 import com.google.common.base.Splitter; 23 import com.google.common.base.Splitter;
15 import org.springframework.beans.factory.annotation.Autowired; 24 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,13 +27,17 @@ import org.springframework.data.domain.Sort.Direction; @@ -18,13 +27,17 @@ import org.springframework.data.domain.Sort.Direction;
18 import org.springframework.stereotype.Service; 27 import org.springframework.stereotype.Service;
19 import org.springframework.transaction.annotation.Transactional; 28 import org.springframework.transaction.annotation.Transactional;
20 29
  30 +import javax.servlet.http.HttpServletResponse;
21 import java.io.ByteArrayInputStream; 31 import java.io.ByteArrayInputStream;
22 import java.io.File; 32 import java.io.File;
23 import java.io.InputStream; 33 import java.io.InputStream;
24 import java.text.DecimalFormat; 34 import java.text.DecimalFormat;
25 -import java.util.*;  
26 -  
27 -import javax.servlet.http.HttpServletResponse; 35 +import java.util.ArrayList;
  36 +import java.util.HashMap;
  37 +import java.util.Iterator;
  38 +import java.util.List;
  39 +import java.util.Map;
  40 +import java.util.Properties;
28 41
29 /** 42 /**
30 * 43 *
@@ -93,7 +106,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -93,7 +106,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
93 public Map<String, Object> getSectionRouteExport(Integer id, HttpServletResponse resp) { 106 public Map<String, Object> getSectionRouteExport(Integer id, HttpServletResponse resp) {
94 Map<String, Object> resultMap = new HashMap<String, Object>(); 107 Map<String, Object> resultMap = new HashMap<String, Object>();
95 try { 108 try {
96 - // List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); 109 + // List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
97 Map<String,Object> resultExcel = new HashMap<String,Object>();//导出参数的对象 110 Map<String,Object> resultExcel = new HashMap<String,Object>();//导出参数的对象
98 /* 添加表头*/ 111 /* 添加表头*/
99 List<String> title = new ArrayList<String>(); 112 List<String> title = new ArrayList<String>();
@@ -113,10 +126,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -113,10 +126,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
113 if(strtionList == null){ 126 if(strtionList == null){
114 logger.info("没有数据导,出用户信息失败!"); 127 logger.info("没有数据导,出用户信息失败!");
115 } else { 128 } else {
116 - 129 +
117 for (int i = 0; i < strtionList.size(); i++) { 130 for (int i = 0; i < strtionList.size(); i++) {
118 StationRoute station = strtionList.get(i); 131 StationRoute station = strtionList.get(i);
119 - 132 +
120 List<String> varList = new ArrayList<String>(); 133 List<String> varList = new ArrayList<String>();
121 varList.add(station.getLine().getId().toString()); 134 varList.add(station.getLine().getId().toString());
122 varList.add(station.getDirections().toString()); 135 varList.add(station.getDirections().toString());
src/main/java/com/bsth/service/impl/StationServiceImpl.java
@@ -1372,8 +1372,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1372,8 +1372,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1372 // 匹配到了用数据库中的点替换 1372 // 匹配到了用数据库中的点替换
1373 if (GeoUtils.isPointInCircle(point, circle)) { 1373 if (GeoUtils.isPointInCircle(point, circle)) {
1374 map.put("name", s.getStationName().toString()); 1374 map.put("name", s.getStationName().toString());
1375 - map.put("potion_lng", points[0]);  
1376 - map.put("potion_lat", points[1]); 1375 + // 匹配到站点后用这个站点的名字,但是使用gps点作为中心点
  1376 +// map.put("potion_lng", points[0]);
  1377 +// map.put("potion_lat", points[1]);
  1378 + map.put("potion_lng", lon);
  1379 + map.put("potion_lat", lat);
1377 map.put("isHave", "true"); 1380 map.put("isHave", "true");
1378 map.put("id", s.getId()); 1381 map.put("id", s.getId());
1379 isMatch = true; 1382 isMatch = true;
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/CalcuParam.java
1 -package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;  
2 -  
3 -import org.joda.time.DateTime;  
4 -  
5 -/**  
6 - * 计算用参数。  
7 - */  
8 -public class CalcuParam {  
9 - /** 线路Id */  
10 - private Integer xlId;  
11 -  
12 - /** 计划开始计算日期 */  
13 - private DateTime fromDate;  
14 - /** 计划结束计算日期 */  
15 - private DateTime toDate;  
16 -  
17 - public Integer getXlId() {  
18 - return xlId;  
19 - }  
20 -  
21 - public void setXlId(Integer xlId) {  
22 - this.xlId = xlId;  
23 - }  
24 -  
25 - public DateTime getFromDate() {  
26 - return fromDate;  
27 - }  
28 -  
29 - public void setFromDate(DateTime fromDate) {  
30 - this.fromDate = fromDate;  
31 - }  
32 -  
33 - public DateTime getToDate() {  
34 - return toDate;  
35 - }  
36 -  
37 - public void setToDate(DateTime toDate) {  
38 - this.toDate = toDate;  
39 - }  
40 -} 1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +import org.joda.time.DateTime;
  4 +
  5 +/**
  6 + * 计算用参数。
  7 + */
  8 +public class CalcuParam {
  9 + /** 线路Id */
  10 + private Integer xlId;
  11 +
  12 + /** 计划开始计算日期 */
  13 + private DateTime fromDate;
  14 + /** 计划结束计算日期 */
  15 + private DateTime toDate;
  16 +
  17 + public Integer getXlId() {
  18 + return xlId;
  19 + }
  20 +
  21 + public void setXlId(Integer xlId) {
  22 + this.xlId = xlId;
  23 + }
  24 +
  25 + public DateTime getFromDate() {
  26 + return fromDate;
  27 + }
  28 +
  29 + public void setFromDate(DateTime fromDate) {
  30 + this.fromDate = fromDate;
  31 + }
  32 +
  33 + public DateTime getToDate() {
  34 + return toDate;
  35 + }
  36 +
  37 + public void setToDate(DateTime toDate) {
  38 + this.toDate = toDate;
  39 + }
  40 +}
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/ErrorInfoFunction.java
1 -package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;  
2 -  
3 -  
4 -import com.bsth.entity.schedule.EmployeeConfigInfo;  
5 -import com.bsth.entity.schedule.GuideboardInfo;  
6 -import org.apache.commons.lang3.StringUtils;  
7 -import org.apache.commons.lang3.math.NumberUtils;  
8 -import org.kie.api.runtime.rule.AccumulateFunction;  
9 -  
10 -import java.io.*;  
11 -import java.util.HashMap;  
12 -import java.util.Map;  
13 -  
14 -/**  
15 - * 查找错误函数。  
16 - */  
17 -public class ErrorInfoFunction implements AccumulateFunction {  
18 - @Override  
19 - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {  
20 -  
21 - }  
22 -  
23 - @Override  
24 - public void writeExternal(ObjectOutput out) throws IOException {  
25 -  
26 - }  
27 -  
28 - protected static class ErrorInfoContext implements Externalizable {  
29 - /** 错误数量 */  
30 - public Integer errorCount = 0;  
31 - /** 错误Map,Map<规则id,errorInfo> */  
32 - public Map<Long, ValidateRuleResult.ErrorInfo> errorInfoMap = new HashMap<>();  
33 -  
34 - public ErrorInfoContext() {  
35 -  
36 - }  
37 -  
38 - @Override  
39 - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {  
40 - errorCount = in.readInt();  
41 - errorInfoMap = (Map<Long, ValidateRuleResult.ErrorInfo>) in.readObject();  
42 -  
43 - }  
44 -  
45 - @Override  
46 - public void writeExternal(ObjectOutput out) throws IOException {  
47 - out.writeInt(errorCount);  
48 - out.writeObject(errorInfoMap);  
49 - }  
50 -  
51 - }  
52 -  
53 - @Override  
54 - public Serializable createContext() {  
55 - return new ErrorInfoContext();  
56 - }  
57 -  
58 - @Override  
59 - public void init(Serializable serializable) throws Exception {  
60 - ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;  
61 - errorInfoContext.errorCount = 0;  
62 - errorInfoContext.errorInfoMap = new HashMap<>();  
63 - }  
64 -  
65 - @Override  
66 - public void accumulate(Serializable serializable, Object o) {  
67 - ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;  
68 - WrapInput wrapInput = (WrapInput) o;  
69 -  
70 - ValidateRuleResult.ErrorInfo errorInfo = new ValidateRuleResult.ErrorInfo();  
71 - errorInfo.setRuleId(wrapInput.getRuleId());  
72 - errorInfo.setClZbh(wrapInput.getClZbh());  
73 - errorInfo.setQyrq(wrapInput.getQyrq());  
74 -  
75 - // 1、车辆配置验证  
76 - if (StringUtils.isNotEmpty(wrapInput.getClZbh())) { // 自编号不能为空  
77 - if (wrapInput.getCcInfos().get(wrapInput.getClZbh()) == null) { // 车辆配置不在当前线路上  
78 - errorInfo.getErrorDescList().add("车辆配置不在当前线路,请重新编辑保存!");  
79 - }  
80 - } else {  
81 - errorInfo.getErrorDescList().add("自编号不能为空,请重新编辑保存!");  
82 - }  
83 -  
84 - // 2、路牌id,路牌名字,路牌起始索引验证  
85 - if (StringUtils.isNotEmpty(wrapInput.getLpIds()) &&  
86 - StringUtils.isNotEmpty(wrapInput.getLpNames())) { // 冗余的路牌id和路牌名字都不能为空  
87 - String[] lpIds = wrapInput.getLpIds().split(",");  
88 - String[] lpNames = wrapInput.getLpNames().split(",");  
89 - if (lpIds.length == lpNames.length) { // 路牌id和路牌名字个数一致  
90 - for (int i = 0; i < lpIds.length; i++) {  
91 - if (!NumberUtils.isDigits(lpIds[i])) { // 冗余路牌id必须是数字  
92 - errorInfo.getErrorDescList().add("冗余路牌id必须是数字,请重新编辑保存!");  
93 - break;  
94 - }  
95 -  
96 - GuideboardInfo lpInfo = wrapInput.getLpInfos().get(NumberUtils.toLong(lpIds[i]));  
97 - if (lpInfo == null) { // 路牌不在当前线路上  
98 - errorInfo.getErrorDescList().add("路牌不在当前线路上,请重新编辑保存!");  
99 - } else {  
100 - if (StringUtils.isEmpty(lpNames[i]) ||  
101 - !(lpNames[i].equals(lpInfo.getLpName()))) { // 路牌id和路牌名字不对应  
102 - errorInfo.getErrorDescList().add("路牌id和路牌名字不对应,请重新编辑保存!");  
103 - break;  
104 - }  
105 - }  
106 - }  
107 -  
108 - if (wrapInput.getLpStartIndex() < 1 ||  
109 - wrapInput.getLpStartIndex() > lpIds.length) { // 路牌起始索引溢出  
110 - errorInfo.getErrorDescList().add("路牌起始索引溢出,请重新编辑保存!");  
111 - }  
112 - } else {  
113 - errorInfo.getErrorDescList().add("路牌id和路牌名字个数不一致,请重新编辑保存!");  
114 - }  
115 - } else {  
116 - errorInfo.getErrorDescList().add("冗余的路牌id和路牌名字都不能为空,请重新编辑保存!");  
117 - }  
118 -  
119 - // 3、人员配置,搭班编码,人员起始索引验证  
120 - if (StringUtils.isNotEmpty(wrapInput.getEcIds()) &&  
121 - StringUtils.isNotEmpty(wrapInput.getEcDbbms())) { // 冗余的人员配置id和人员搭班编码都不能为空  
122 - String[] ecIds = wrapInput.getEcIds().split(",");  
123 - String[] ecDbbms = wrapInput.getEcDbbms().split(",");  
124 - if (ecIds.length == ecDbbms.length) { // 人员配置id和搭班编码个数一致  
125 - for (int i = 0; i < ecIds.length; i++) {  
126 - if (ecIds[i].contains("-")) { // 分班标识  
127 - String[] fb_ecIds = ecIds[i].split("-");  
128 - String[] fb_ecDbbms = ecDbbms[i].split("-");  
129 - if (fb_ecIds.length != 2 || fb_ecDbbms.length != 2) { // 只能早晚分班  
130 - errorInfo.getErrorDescList().add("只能早晚分班,请重新编辑保存!");  
131 - break;  
132 - } else {  
133 - EmployeeConfigInfo fb_ecInfo1 = wrapInput.getEcInfos().get(NumberUtils.toLong(fb_ecIds[0]));  
134 - EmployeeConfigInfo fb_ecInfo2 = wrapInput.getEcInfos().get(NumberUtils.toLong(fb_ecIds[1]));  
135 - if (fb_ecInfo1 == null || fb_ecInfo2 == null) { // 分班的人员配置不在当前线路  
136 - errorInfo.getErrorDescList().add("分班的人员配置不在当前线路,请重新编辑保存!");  
137 - break;  
138 - } else {  
139 - if (StringUtils.isEmpty(fb_ecDbbms[0]) ||  
140 - StringUtils.isEmpty(fb_ecDbbms[1]) ||  
141 - !(fb_ecDbbms[0].equals(fb_ecInfo1.getDbbm())) ||  
142 - !(fb_ecDbbms[1].equals(fb_ecInfo2.getDbbm()))) { // 分班人员配置id和搭班编码不对应  
143 - errorInfo.getErrorDescList().add("分班人员配置id和搭班编码不对应,请重新编辑保存!");  
144 - break;  
145 - }  
146 - }  
147 - }  
148 -  
149 - } else {  
150 - if (!NumberUtils.isDigits(ecIds[i])) { // 冗余的人员配置id必须是数字  
151 - errorInfo.getErrorDescList().add("冗余的人员配置id必须是数字,请重新编辑保存!");  
152 - break;  
153 - }  
154 -  
155 - EmployeeConfigInfo ecInfo = wrapInput.getEcInfos().get(NumberUtils.toLong(ecIds[i]));  
156 - if (ecInfo == null) { // 人员配置不在当前线路  
157 - errorInfo.getErrorDescList().add("人员配置不在当前线路,请重新编辑保存!");  
158 - break;  
159 - } else {  
160 - if (StringUtils.isEmpty(ecDbbms[i]) ||  
161 - !(ecDbbms[i].equals(ecInfo.getDbbm()))) { // 人员配置id和搭班编码不对应  
162 - errorInfo.getErrorDescList().add("人员配置id和搭班编码不对应,请重新编辑保存!");  
163 - break;  
164 - }  
165 - }  
166 - }  
167 - }  
168 -  
169 - if (wrapInput.getEcStartIndex() < 1 ||  
170 - wrapInput.getEcStartIndex() > ecIds.length) { // 人员起始索引溢出  
171 - errorInfo.getErrorDescList().add("人员起始索引溢出,请重新编辑保存!");  
172 - }  
173 - } else {  
174 - errorInfo.getErrorDescList().add("人员配置id和搭班编码个数不一致,请重新编辑保存!");  
175 - }  
176 - }  
177 -  
178 - if (errorInfo.getErrorDescList().size() > 0) {  
179 - errorInfoContext.errorCount ++;  
180 - errorInfoContext.errorInfoMap.put(wrapInput.getRuleId(), errorInfo);  
181 - }  
182 -  
183 - }  
184 -  
185 - @Override  
186 - public void reverse(Serializable serializable, Object o) throws Exception {  
187 - ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;  
188 - WrapInput wrapInput = (WrapInput) o;  
189 -  
190 - if (errorInfoContext.errorInfoMap.get(wrapInput.getRuleId()) != null) {  
191 - errorInfoContext.errorInfoMap.remove(wrapInput.getRuleId());  
192 - errorInfoContext.errorCount --;  
193 - }  
194 - }  
195 -  
196 - @Override  
197 - public Object getResult(Serializable serializable) throws Exception {  
198 - ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;  
199 - return errorInfoContext.errorInfoMap;  
200 - }  
201 -  
202 - @Override  
203 - public boolean supportsReverse() {  
204 - return true;  
205 - }  
206 -  
207 - @Override  
208 - public Class<?> getResultType() {  
209 - return Map.class;  
210 - }  
211 -  
212 -} 1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +
  4 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  5 +import com.bsth.entity.schedule.GuideboardInfo;
  6 +import org.apache.commons.lang3.StringUtils;
  7 +import org.apache.commons.lang3.math.NumberUtils;
  8 +import org.kie.api.runtime.rule.AccumulateFunction;
  9 +
  10 +import java.io.*;
  11 +import java.util.HashMap;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * 查找错误函数。
  16 + */
  17 +public class ErrorInfoFunction implements AccumulateFunction {
  18 + @Override
  19 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  20 +
  21 + }
  22 +
  23 + @Override
  24 + public void writeExternal(ObjectOutput out) throws IOException {
  25 +
  26 + }
  27 +
  28 + protected static class ErrorInfoContext implements Externalizable {
  29 + /** 错误数量 */
  30 + public Integer errorCount = 0;
  31 + /** 错误Map,Map<规则id,errorInfo> */
  32 + public Map<Long, ValidateRuleResult.ErrorInfo> errorInfoMap = new HashMap<>();
  33 +
  34 + public ErrorInfoContext() {
  35 +
  36 + }
  37 +
  38 + @Override
  39 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  40 + errorCount = in.readInt();
  41 + errorInfoMap = (Map<Long, ValidateRuleResult.ErrorInfo>) in.readObject();
  42 +
  43 + }
  44 +
  45 + @Override
  46 + public void writeExternal(ObjectOutput out) throws IOException {
  47 + out.writeInt(errorCount);
  48 + out.writeObject(errorInfoMap);
  49 + }
  50 +
  51 + }
  52 +
  53 + @Override
  54 + public Serializable createContext() {
  55 + return new ErrorInfoContext();
  56 + }
  57 +
  58 + @Override
  59 + public void init(Serializable serializable) throws Exception {
  60 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  61 + errorInfoContext.errorCount = 0;
  62 + errorInfoContext.errorInfoMap = new HashMap<>();
  63 + }
  64 +
  65 + @Override
  66 + public void accumulate(Serializable serializable, Object o) {
  67 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  68 + WrapInput wrapInput = (WrapInput) o;
  69 +
  70 + ValidateRuleResult.ErrorInfo errorInfo = new ValidateRuleResult.ErrorInfo();
  71 + errorInfo.setRuleId(wrapInput.getRuleId());
  72 + errorInfo.setClZbh(wrapInput.getClZbh());
  73 + errorInfo.setQyrq(wrapInput.getQyrq());
  74 +
  75 + // 1、车辆配置验证
  76 + if (StringUtils.isNotEmpty(wrapInput.getClZbh())) { // 自编号不能为空
  77 + if (wrapInput.getCcInfos().get(wrapInput.getClZbh()) == null) { // 车辆配置不在当前线路上
  78 + errorInfo.getErrorDescList().add("车辆配置不在当前线路,请重新编辑保存!");
  79 + }
  80 + } else {
  81 + errorInfo.getErrorDescList().add("自编号不能为空,请重新编辑保存!");
  82 + }
  83 +
  84 + // 2、路牌id,路牌名字,路牌起始索引验证
  85 + if (StringUtils.isNotEmpty(wrapInput.getLpIds()) &&
  86 + StringUtils.isNotEmpty(wrapInput.getLpNames())) { // 冗余的路牌id和路牌名字都不能为空
  87 + String[] lpIds = wrapInput.getLpIds().split(",");
  88 + String[] lpNames = wrapInput.getLpNames().split(",");
  89 + if (lpIds.length == lpNames.length) { // 路牌id和路牌名字个数一致
  90 + for (int i = 0; i < lpIds.length; i++) {
  91 + if (!NumberUtils.isDigits(lpIds[i])) { // 冗余路牌id必须是数字
  92 + errorInfo.getErrorDescList().add("冗余路牌id必须是数字,请重新编辑保存!");
  93 + break;
  94 + }
  95 +
  96 + GuideboardInfo lpInfo = wrapInput.getLpInfos().get(NumberUtils.toLong(lpIds[i]));
  97 + if (lpInfo == null) { // 路牌不在当前线路上
  98 + errorInfo.getErrorDescList().add("路牌不在当前线路上,请重新编辑保存!");
  99 + } else {
  100 + if (StringUtils.isEmpty(lpNames[i]) ||
  101 + !(lpNames[i].equals(lpInfo.getLpName()))) { // 路牌id和路牌名字不对应
  102 + errorInfo.getErrorDescList().add("路牌id和路牌名字不对应,请重新编辑保存!");
  103 + break;
  104 + }
  105 + }
  106 + }
  107 +
  108 + if (wrapInput.getLpStartIndex() < 1 ||
  109 + wrapInput.getLpStartIndex() > lpIds.length) { // 路牌起始索引溢出
  110 + errorInfo.getErrorDescList().add("路牌起始索引溢出,请重新编辑保存!");
  111 + }
  112 + } else {
  113 + errorInfo.getErrorDescList().add("路牌id和路牌名字个数不一致,请重新编辑保存!");
  114 + }
  115 + } else {
  116 + errorInfo.getErrorDescList().add("冗余的路牌id和路牌名字都不能为空,请重新编辑保存!");
  117 + }
  118 +
  119 + // 3、人员配置,搭班编码,人员起始索引验证
  120 + if (StringUtils.isNotEmpty(wrapInput.getEcIds()) &&
  121 + StringUtils.isNotEmpty(wrapInput.getEcDbbms())) { // 冗余的人员配置id和人员搭班编码都不能为空
  122 + String[] ecIds = wrapInput.getEcIds().split(",");
  123 + String[] ecDbbms = wrapInput.getEcDbbms().split(",");
  124 + if (ecIds.length == ecDbbms.length) { // 人员配置id和搭班编码个数一致
  125 + for (int i = 0; i < ecIds.length; i++) {
  126 + if (ecIds[i].contains("-")) { // 分班标识
  127 + String[] fb_ecIds = ecIds[i].split("-");
  128 + String[] fb_ecDbbms = ecDbbms[i].split("-");
  129 + if (fb_ecIds.length != 2 || fb_ecDbbms.length != 2) { // 只能早晚分班
  130 + errorInfo.getErrorDescList().add("只能早晚分班,请重新编辑保存!");
  131 + break;
  132 + } else {
  133 + EmployeeConfigInfo fb_ecInfo1 = wrapInput.getEcInfos().get(NumberUtils.toLong(fb_ecIds[0]));
  134 + EmployeeConfigInfo fb_ecInfo2 = wrapInput.getEcInfos().get(NumberUtils.toLong(fb_ecIds[1]));
  135 + if (fb_ecInfo1 == null || fb_ecInfo2 == null) { // 分班的人员配置不在当前线路
  136 + errorInfo.getErrorDescList().add("分班的人员配置不在当前线路,请重新编辑保存!");
  137 + break;
  138 + } else {
  139 + if (StringUtils.isEmpty(fb_ecDbbms[0]) ||
  140 + StringUtils.isEmpty(fb_ecDbbms[1]) ||
  141 + !(fb_ecDbbms[0].equals(fb_ecInfo1.getDbbm())) ||
  142 + !(fb_ecDbbms[1].equals(fb_ecInfo2.getDbbm()))) { // 分班人员配置id和搭班编码不对应
  143 + errorInfo.getErrorDescList().add("分班人员配置id和搭班编码不对应,请重新编辑保存!");
  144 + break;
  145 + }
  146 + }
  147 + }
  148 +
  149 + } else {
  150 + if (!NumberUtils.isDigits(ecIds[i])) { // 冗余的人员配置id必须是数字
  151 + errorInfo.getErrorDescList().add("冗余的人员配置id必须是数字,请重新编辑保存!");
  152 + break;
  153 + }
  154 +
  155 + EmployeeConfigInfo ecInfo = wrapInput.getEcInfos().get(NumberUtils.toLong(ecIds[i]));
  156 + if (ecInfo == null) { // 人员配置不在当前线路
  157 + errorInfo.getErrorDescList().add("人员配置不在当前线路,请重新编辑保存!");
  158 + break;
  159 + } else {
  160 + if (StringUtils.isEmpty(ecDbbms[i]) ||
  161 + !(ecDbbms[i].equals(ecInfo.getDbbm()))) { // 人员配置id和搭班编码不对应
  162 + errorInfo.getErrorDescList().add("人员配置id和搭班编码不对应,请重新编辑保存!");
  163 + break;
  164 + }
  165 + }
  166 + }
  167 + }
  168 +
  169 + if (wrapInput.getEcStartIndex() < 1 ||
  170 + wrapInput.getEcStartIndex() > ecIds.length) { // 人员起始索引溢出
  171 + errorInfo.getErrorDescList().add("人员起始索引溢出,请重新编辑保存!");
  172 + }
  173 + } else {
  174 + errorInfo.getErrorDescList().add("人员配置id和搭班编码个数不一致,请重新编辑保存!");
  175 + }
  176 + }
  177 +
  178 + if (errorInfo.getErrorDescList().size() > 0) {
  179 + errorInfoContext.errorCount ++;
  180 + errorInfoContext.errorInfoMap.put(wrapInput.getRuleId(), errorInfo);
  181 + }
  182 +
  183 + }
  184 +
  185 + @Override
  186 + public void reverse(Serializable serializable, Object o) throws Exception {
  187 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  188 + WrapInput wrapInput = (WrapInput) o;
  189 +
  190 + if (errorInfoContext.errorInfoMap.get(wrapInput.getRuleId()) != null) {
  191 + errorInfoContext.errorInfoMap.remove(wrapInput.getRuleId());
  192 + errorInfoContext.errorCount --;
  193 + }
  194 + }
  195 +
  196 + @Override
  197 + public Object getResult(Serializable serializable) throws Exception {
  198 + ErrorInfoContext errorInfoContext = (ErrorInfoContext) serializable;
  199 + return errorInfoContext.errorInfoMap;
  200 + }
  201 +
  202 + @Override
  203 + public boolean supportsReverse() {
  204 + return true;
  205 + }
  206 +
  207 + @Override
  208 + public Class<?> getResultType() {
  209 + return Map.class;
  210 + }
  211 +
  212 +}
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/ValidateRuleResult.java
1 -package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;  
2 -  
3 -import java.util.ArrayList;  
4 -import java.util.Date;  
5 -import java.util.List;  
6 -  
7 -/**  
8 - * 输出结果值。  
9 - */  
10 -public class ValidateRuleResult {  
11 - /** 线路id */  
12 - private Integer xlId;  
13 - /** 规则总数量 */  
14 - private Integer count;  
15 - /** 启用的规则数量 */  
16 - private Integer qyCount;  
17 - /** 启用规则中的错误数量 */  
18 - private Integer qyErrorCount;  
19 - /** 错误列表 */  
20 - private List<ErrorInfo> errorInfos = new ArrayList<>();  
21 -  
22 - public Integer getXlId() {  
23 - return xlId;  
24 - }  
25 -  
26 - public void setXlId(Integer xlId) {  
27 - this.xlId = xlId;  
28 - }  
29 -  
30 - public Integer getCount() {  
31 - return count;  
32 - }  
33 -  
34 - public void setCount(Integer count) {  
35 - this.count = count;  
36 - }  
37 -  
38 - public Integer getQyCount() {  
39 - return qyCount;  
40 - }  
41 -  
42 - public void setQyCount(Integer qyCount) {  
43 - this.qyCount = qyCount;  
44 - }  
45 -  
46 - public Integer getQyErrorCount() {  
47 - return qyErrorCount;  
48 - }  
49 -  
50 - public void setQyErrorCount(Integer qyErrorCount) {  
51 - this.qyErrorCount = qyErrorCount;  
52 - }  
53 -  
54 - public List<ErrorInfo> getErrorInfos() {  
55 - return errorInfos;  
56 - }  
57 -  
58 - public void setErrorInfos(List<ErrorInfo> errorInfos) {  
59 - this.errorInfos = errorInfos;  
60 - }  
61 -  
62 - public static class ErrorInfo {  
63 - /** 规则id */  
64 - private Long ruleId;  
65 - /** 车辆自编号 */  
66 - private String clZbh;  
67 - /** 启用日期 */  
68 - private Date qyrq;  
69 - /** 错误描述 */  
70 - private List<String> errorDescList = new ArrayList<>();  
71 -  
72 - public Long getRuleId() {  
73 - return ruleId;  
74 - }  
75 -  
76 - public void setRuleId(Long ruleId) {  
77 - this.ruleId = ruleId;  
78 - }  
79 -  
80 - public String getClZbh() {  
81 - return clZbh;  
82 - }  
83 -  
84 - public void setClZbh(String clZbh) {  
85 - this.clZbh = clZbh;  
86 - }  
87 -  
88 - public Date getQyrq() {  
89 - return qyrq;  
90 - }  
91 -  
92 - public void setQyrq(Date qyrq) {  
93 - this.qyrq = qyrq;  
94 - }  
95 -  
96 - public List<String> getErrorDescList() {  
97 - return errorDescList;  
98 - }  
99 -  
100 - public void setErrorDescList(List<String> errorDescList) {  
101 - this.errorDescList = errorDescList;  
102 - }  
103 - }  
104 -} 1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.Date;
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 输出结果值。
  9 + */
  10 +public class ValidateRuleResult {
  11 + /** 线路id */
  12 + private Integer xlId;
  13 + /** 规则总数量 */
  14 + private Integer count;
  15 + /** 启用的规则数量 */
  16 + private Integer qyCount;
  17 + /** 启用规则中的错误数量 */
  18 + private Integer qyErrorCount;
  19 + /** 错误列表 */
  20 + private List<ErrorInfo> errorInfos = new ArrayList<>();
  21 +
  22 + public Integer getXlId() {
  23 + return xlId;
  24 + }
  25 +
  26 + public void setXlId(Integer xlId) {
  27 + this.xlId = xlId;
  28 + }
  29 +
  30 + public Integer getCount() {
  31 + return count;
  32 + }
  33 +
  34 + public void setCount(Integer count) {
  35 + this.count = count;
  36 + }
  37 +
  38 + public Integer getQyCount() {
  39 + return qyCount;
  40 + }
  41 +
  42 + public void setQyCount(Integer qyCount) {
  43 + this.qyCount = qyCount;
  44 + }
  45 +
  46 + public Integer getQyErrorCount() {
  47 + return qyErrorCount;
  48 + }
  49 +
  50 + public void setQyErrorCount(Integer qyErrorCount) {
  51 + this.qyErrorCount = qyErrorCount;
  52 + }
  53 +
  54 + public List<ErrorInfo> getErrorInfos() {
  55 + return errorInfos;
  56 + }
  57 +
  58 + public void setErrorInfos(List<ErrorInfo> errorInfos) {
  59 + this.errorInfos = errorInfos;
  60 + }
  61 +
  62 + public static class ErrorInfo {
  63 + /** 规则id */
  64 + private Long ruleId;
  65 + /** 车辆自编号 */
  66 + private String clZbh;
  67 + /** 启用日期 */
  68 + private Date qyrq;
  69 + /** 错误描述 */
  70 + private List<String> errorDescList = new ArrayList<>();
  71 +
  72 + public Long getRuleId() {
  73 + return ruleId;
  74 + }
  75 +
  76 + public void setRuleId(Long ruleId) {
  77 + this.ruleId = ruleId;
  78 + }
  79 +
  80 + public String getClZbh() {
  81 + return clZbh;
  82 + }
  83 +
  84 + public void setClZbh(String clZbh) {
  85 + this.clZbh = clZbh;
  86 + }
  87 +
  88 + public Date getQyrq() {
  89 + return qyrq;
  90 + }
  91 +
  92 + public void setQyrq(Date qyrq) {
  93 + this.qyrq = qyrq;
  94 + }
  95 +
  96 + public List<String> getErrorDescList() {
  97 + return errorDescList;
  98 + }
  99 +
  100 + public void setErrorDescList(List<String> errorDescList) {
  101 + this.errorDescList = errorDescList;
  102 + }
  103 + }
  104 +}
src/main/java/com/bsth/service/schedule/impl/plan/kBase3/validate/rule/WrapInput.java
1 -package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;  
2 -  
3 -import com.bsth.entity.schedule.CarConfigInfo;  
4 -import com.bsth.entity.schedule.EmployeeConfigInfo;  
5 -import com.bsth.entity.schedule.GuideboardInfo;  
6 -import com.bsth.entity.schedule.rule.ScheduleRule1Flat;  
7 -import org.springframework.util.CollectionUtils;  
8 -  
9 -import java.util.*;  
10 -  
11 -/**  
12 - * 聚合输入的待判定数据。  
13 - */  
14 -public class WrapInput {  
15 - /** 线路Id */  
16 - private Integer xlId;  
17 - /** 车辆自编号 */  
18 - private String clZbh;  
19 - /** 路牌id列表 */  
20 - private String lpIds;  
21 - /** 路牌名字列表 */  
22 - private String lpNames;  
23 - /** 人员配置列表 */  
24 - private String ecIds;  
25 - /** 人员搭班编码列表 */  
26 - private String ecDbbms;  
27 - /** 路牌循环起始索引 */  
28 - private Integer lpStartIndex;  
29 - /** 人员循环起始索引 */  
30 - private Integer ecStartIndex;  
31 - /** 规则id */  
32 - private Long ruleId;  
33 - /** 启用日期 */  
34 - private Date qyrq;  
35 -  
36 - private Map<String, CarConfigInfo> ccInfos = new HashMap<>();  
37 - private Map<Long, GuideboardInfo> lpInfos = new HashMap<>();  
38 - private Map<Long, EmployeeConfigInfo> ecInfos = new HashMap<>();  
39 -  
40 - public WrapInput(ScheduleRule1Flat r,  
41 - Map<String, CarConfigInfo> cc,  
42 - Map<Long, GuideboardInfo> lp,  
43 - Map<Long, EmployeeConfigInfo> ec) {  
44 - this.xlId = r.getXl().getId();  
45 - this.clZbh = r.getCarConfigInfo().getCl().getInsideCode();  
46 - this.lpIds = r.getLpIds();  
47 - this.lpNames = r.getLpNames();  
48 - this.ecIds = r.getRyConfigIds();  
49 - this.ecDbbms = r.getRyDbbms();  
50 - this.lpStartIndex = r.getLpStart();  
51 - this.ecStartIndex = r.getRyStart();  
52 - this.ruleId = r.getId();  
53 - this.qyrq = r.getQyrq();  
54 -  
55 - if (!CollectionUtils.isEmpty(cc)) {  
56 - this.ccInfos.putAll(cc);  
57 - }  
58 - if (!CollectionUtils.isEmpty(lp)) {  
59 - this.lpInfos.putAll(lp);  
60 - }  
61 - if (!CollectionUtils.isEmpty(ec)) {  
62 - this.ecInfos.putAll(ec);  
63 - }  
64 -  
65 - }  
66 -  
67 - public Integer getXlId() {  
68 - return xlId;  
69 - }  
70 -  
71 - public void setXlId(Integer xlId) {  
72 - this.xlId = xlId;  
73 - }  
74 -  
75 - public String getClZbh() {  
76 - return clZbh;  
77 - }  
78 -  
79 - public void setClZbh(String clZbh) {  
80 - this.clZbh = clZbh;  
81 - }  
82 -  
83 - public String getLpIds() {  
84 - return lpIds;  
85 - }  
86 -  
87 - public void setLpIds(String lpIds) {  
88 - this.lpIds = lpIds;  
89 - }  
90 -  
91 - public String getLpNames() {  
92 - return lpNames;  
93 - }  
94 -  
95 - public void setLpNames(String lpNames) {  
96 - this.lpNames = lpNames;  
97 - }  
98 -  
99 - public String getEcIds() {  
100 - return ecIds;  
101 - }  
102 -  
103 - public void setEcIds(String ecIds) {  
104 - this.ecIds = ecIds;  
105 - }  
106 -  
107 - public String getEcDbbms() {  
108 - return ecDbbms;  
109 - }  
110 -  
111 - public void setEcDbbms(String ecDbbms) {  
112 - this.ecDbbms = ecDbbms;  
113 - }  
114 -  
115 - public Integer getLpStartIndex() {  
116 - return lpStartIndex;  
117 - }  
118 -  
119 - public void setLpStartIndex(Integer lpStartIndex) {  
120 - this.lpStartIndex = lpStartIndex;  
121 - }  
122 -  
123 - public Integer getEcStartIndex() {  
124 - return ecStartIndex;  
125 - }  
126 -  
127 - public void setEcStartIndex(Integer ecStartIndex) {  
128 - this.ecStartIndex = ecStartIndex;  
129 - }  
130 -  
131 - public Long getRuleId() {  
132 - return ruleId;  
133 - }  
134 -  
135 - public void setRuleId(Long ruleId) {  
136 - this.ruleId = ruleId;  
137 - }  
138 -  
139 - public Date getQyrq() {  
140 - return qyrq;  
141 - }  
142 -  
143 - public void setQyrq(Date qyrq) {  
144 - this.qyrq = qyrq;  
145 - }  
146 -  
147 - public Map<String, CarConfigInfo> getCcInfos() {  
148 - return ccInfos;  
149 - }  
150 -  
151 - public void setCcInfos(Map<String, CarConfigInfo> ccInfos) {  
152 - this.ccInfos = ccInfos;  
153 - }  
154 -  
155 - public Map<Long, GuideboardInfo> getLpInfos() {  
156 - return lpInfos;  
157 - }  
158 -  
159 - public void setLpInfos(Map<Long, GuideboardInfo> lpInfos) {  
160 - this.lpInfos = lpInfos;  
161 - }  
162 -  
163 - public Map<Long, EmployeeConfigInfo> getEcInfos() {  
164 - return ecInfos;  
165 - }  
166 -  
167 - public void setEcInfos(Map<Long, EmployeeConfigInfo> ecInfos) {  
168 - this.ecInfos = ecInfos;  
169 - }  
170 -} 1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +import com.bsth.entity.schedule.CarConfigInfo;
  4 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  5 +import com.bsth.entity.schedule.GuideboardInfo;
  6 +import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  7 +import org.springframework.util.CollectionUtils;
  8 +
  9 +import java.util.*;
  10 +
  11 +/**
  12 + * 聚合输入的待判定数据。
  13 + */
  14 +public class WrapInput {
  15 + /** 线路Id */
  16 + private Integer xlId;
  17 + /** 车辆自编号 */
  18 + private String clZbh;
  19 + /** 路牌id列表 */
  20 + private String lpIds;
  21 + /** 路牌名字列表 */
  22 + private String lpNames;
  23 + /** 人员配置列表 */
  24 + private String ecIds;
  25 + /** 人员搭班编码列表 */
  26 + private String ecDbbms;
  27 + /** 路牌循环起始索引 */
  28 + private Integer lpStartIndex;
  29 + /** 人员循环起始索引 */
  30 + private Integer ecStartIndex;
  31 + /** 规则id */
  32 + private Long ruleId;
  33 + /** 启用日期 */
  34 + private Date qyrq;
  35 +
  36 + private Map<String, CarConfigInfo> ccInfos = new HashMap<>();
  37 + private Map<Long, GuideboardInfo> lpInfos = new HashMap<>();
  38 + private Map<Long, EmployeeConfigInfo> ecInfos = new HashMap<>();
  39 +
  40 + public WrapInput(ScheduleRule1Flat r,
  41 + Map<String, CarConfigInfo> cc,
  42 + Map<Long, GuideboardInfo> lp,
  43 + Map<Long, EmployeeConfigInfo> ec) {
  44 + this.xlId = r.getXl().getId();
  45 + this.clZbh = r.getCarConfigInfo().getCl().getInsideCode();
  46 + this.lpIds = r.getLpIds();
  47 + this.lpNames = r.getLpNames();
  48 + this.ecIds = r.getRyConfigIds();
  49 + this.ecDbbms = r.getRyDbbms();
  50 + this.lpStartIndex = r.getLpStart();
  51 + this.ecStartIndex = r.getRyStart();
  52 + this.ruleId = r.getId();
  53 + this.qyrq = r.getQyrq();
  54 +
  55 + if (!CollectionUtils.isEmpty(cc)) {
  56 + this.ccInfos.putAll(cc);
  57 + }
  58 + if (!CollectionUtils.isEmpty(lp)) {
  59 + this.lpInfos.putAll(lp);
  60 + }
  61 + if (!CollectionUtils.isEmpty(ec)) {
  62 + this.ecInfos.putAll(ec);
  63 + }
  64 +
  65 + }
  66 +
  67 + public Integer getXlId() {
  68 + return xlId;
  69 + }
  70 +
  71 + public void setXlId(Integer xlId) {
  72 + this.xlId = xlId;
  73 + }
  74 +
  75 + public String getClZbh() {
  76 + return clZbh;
  77 + }
  78 +
  79 + public void setClZbh(String clZbh) {
  80 + this.clZbh = clZbh;
  81 + }
  82 +
  83 + public String getLpIds() {
  84 + return lpIds;
  85 + }
  86 +
  87 + public void setLpIds(String lpIds) {
  88 + this.lpIds = lpIds;
  89 + }
  90 +
  91 + public String getLpNames() {
  92 + return lpNames;
  93 + }
  94 +
  95 + public void setLpNames(String lpNames) {
  96 + this.lpNames = lpNames;
  97 + }
  98 +
  99 + public String getEcIds() {
  100 + return ecIds;
  101 + }
  102 +
  103 + public void setEcIds(String ecIds) {
  104 + this.ecIds = ecIds;
  105 + }
  106 +
  107 + public String getEcDbbms() {
  108 + return ecDbbms;
  109 + }
  110 +
  111 + public void setEcDbbms(String ecDbbms) {
  112 + this.ecDbbms = ecDbbms;
  113 + }
  114 +
  115 + public Integer getLpStartIndex() {
  116 + return lpStartIndex;
  117 + }
  118 +
  119 + public void setLpStartIndex(Integer lpStartIndex) {
  120 + this.lpStartIndex = lpStartIndex;
  121 + }
  122 +
  123 + public Integer getEcStartIndex() {
  124 + return ecStartIndex;
  125 + }
  126 +
  127 + public void setEcStartIndex(Integer ecStartIndex) {
  128 + this.ecStartIndex = ecStartIndex;
  129 + }
  130 +
  131 + public Long getRuleId() {
  132 + return ruleId;
  133 + }
  134 +
  135 + public void setRuleId(Long ruleId) {
  136 + this.ruleId = ruleId;
  137 + }
  138 +
  139 + public Date getQyrq() {
  140 + return qyrq;
  141 + }
  142 +
  143 + public void setQyrq(Date qyrq) {
  144 + this.qyrq = qyrq;
  145 + }
  146 +
  147 + public Map<String, CarConfigInfo> getCcInfos() {
  148 + return ccInfos;
  149 + }
  150 +
  151 + public void setCcInfos(Map<String, CarConfigInfo> ccInfos) {
  152 + this.ccInfos = ccInfos;
  153 + }
  154 +
  155 + public Map<Long, GuideboardInfo> getLpInfos() {
  156 + return lpInfos;
  157 + }
  158 +
  159 + public void setLpInfos(Map<Long, GuideboardInfo> lpInfos) {
  160 + this.lpInfos = lpInfos;
  161 + }
  162 +
  163 + public Map<Long, EmployeeConfigInfo> getEcInfos() {
  164 + return ecInfos;
  165 + }
  166 +
  167 + public void setEcInfos(Map<Long, EmployeeConfigInfo> ecInfos) {
  168 + this.ecInfos = ecInfos;
  169 + }
  170 +}
src/main/resources/application-dev.properties
@@ -31,4 +31,4 @@ http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all @@ -31,4 +31,4 @@ http.gps.real.cache.url= http://10.10.150.24:12580/realGps/all
31 ## gateway real data 31 ## gateway real data
32 http.gps.real.url= http://114.80.178.12:18080/transport_server/rtgps/ 32 http.gps.real.url= http://114.80.178.12:18080/transport_server/rtgps/
33 ## gateway send directive 33 ## gateway send directive
34 -http.send.directive = http://192.168.168.201:9090/transport_server/message/ 34 +http.send.directive = http://192.168.168.201:9090/transport_server/message/
35 \ No newline at end of file 35 \ No newline at end of file
src/main/resources/datatools/ktrs/carsDataOutput.ktr
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<transformation>  
3 - <info>  
4 - <name>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x5bfc;&#x51fa;</name>  
5 - <description>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x5bfc;&#x51fa;</description>  
6 - <extended_description>&#x8f66;&#x8f86;&#x57fa;&#x7840;&#x4fe1;&#x606f;</extended_description>  
7 - <trans_version/>  
8 - <trans_type>Normal</trans_type>  
9 - <trans_status>0</trans_status>  
10 - <directory>&#x2f;</directory>  
11 - <parameters>  
12 - <parameter>  
13 - <name>QUERY</name>  
14 - <default_value/>  
15 - <description>&#x67e5;&#x8be2;</description>  
16 - </parameter>  
17 - <parameter>  
18 - <name>cgsbm_in</name>  
19 - <default_value/>  
20 - <description>&#x5206;&#x516c;&#x53f8;&#x7f16;&#x7801;</description>  
21 - </parameter>  
22 - <parameter>  
23 - <name>filepath</name>  
24 - <default_value>1&#x3d;1</default_value>  
25 - <description>excel&#x6587;&#x4ef6;&#x8def;&#x5f84;</description>  
26 - </parameter>  
27 - </parameters>  
28 - <log>  
29 -<trans-log-table><connection/>  
30 -<schema/>  
31 -<table/>  
32 -<size_limit_lines/>  
33 -<interval/>  
34 -<timeout_days/>  
35 -<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STATUS</id><enabled>Y</enabled><name>STATUS</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name><subject/></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name><subject/></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name><subject/></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name><subject/></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name><subject/></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name><subject/></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>STARTDATE</id><enabled>Y</enabled><name>STARTDATE</name></field><field><id>ENDDATE</id><enabled>Y</enabled><name>ENDDATE</name></field><field><id>LOGDATE</id><enabled>Y</enabled><name>LOGDATE</name></field><field><id>DEPDATE</id><enabled>Y</enabled><name>DEPDATE</name></field><field><id>REPLAYDATE</id><enabled>Y</enabled><name>REPLAYDATE</name></field><field><id>LOG_FIELD</id><enabled>Y</enabled><name>LOG_FIELD</name></field><field><id>EXECUTING_SERVER</id><enabled>N</enabled><name>EXECUTING_SERVER</name></field><field><id>EXECUTING_USER</id><enabled>N</enabled><name>EXECUTING_USER</name></field><field><id>CLIENT</id><enabled>N</enabled><name>CLIENT</name></field></trans-log-table>  
36 -<perf-log-table><connection/>  
37 -<schema/>  
38 -<table/>  
39 -<interval/>  
40 -<timeout_days/>  
41 -<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>SEQ_NR</id><enabled>Y</enabled><name>SEQ_NR</name></field><field><id>LOGDATE</id><enabled>Y</enabled><name>LOGDATE</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STEPNAME</id><enabled>Y</enabled><name>STEPNAME</name></field><field><id>STEP_COPY</id><enabled>Y</enabled><name>STEP_COPY</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>INPUT_BUFFER_ROWS</id><enabled>Y</enabled><name>INPUT_BUFFER_ROWS</name></field><field><id>OUTPUT_BUFFER_ROWS</id><enabled>Y</enabled><name>OUTPUT_BUFFER_ROWS</name></field></perf-log-table>  
42 -<channel-log-table><connection/>  
43 -<schema/>  
44 -<table/>  
45 -<timeout_days/>  
46 -<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>LOGGING_OBJECT_TYPE</id><enabled>Y</enabled><name>LOGGING_OBJECT_TYPE</name></field><field><id>OBJECT_NAME</id><enabled>Y</enabled><name>OBJECT_NAME</name></field><field><id>OBJECT_COPY</id><enabled>Y</enabled><name>OBJECT_COPY</name></field><field><id>REPOSITORY_DIRECTORY</id><enabled>Y</enabled><name>REPOSITORY_DIRECTORY</name></field><field><id>FILENAME</id><enabled>Y</enabled><name>FILENAME</name></field><field><id>OBJECT_ID</id><enabled>Y</enabled><name>OBJECT_ID</name></field><field><id>OBJECT_REVISION</id><enabled>Y</enabled><name>OBJECT_REVISION</name></field><field><id>PARENT_CHANNEL_ID</id><enabled>Y</enabled><name>PARENT_CHANNEL_ID</name></field><field><id>ROOT_CHANNEL_ID</id><enabled>Y</enabled><name>ROOT_CHANNEL_ID</name></field></channel-log-table>  
47 -<step-log-table><connection/>  
48 -<schema/>  
49 -<table/>  
50 -<timeout_days/>  
51 -<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STEPNAME</id><enabled>Y</enabled><name>STEPNAME</name></field><field><id>STEP_COPY</id><enabled>Y</enabled><name>STEP_COPY</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>LOG_FIELD</id><enabled>N</enabled><name>LOG_FIELD</name></field></step-log-table>  
52 -<metrics-log-table><connection/>  
53 -<schema/>  
54 -<table/>  
55 -<timeout_days/>  
56 -<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>METRICS_DATE</id><enabled>Y</enabled><name>METRICS_DATE</name></field><field><id>METRICS_CODE</id><enabled>Y</enabled><name>METRICS_CODE</name></field><field><id>METRICS_DESCRIPTION</id><enabled>Y</enabled><name>METRICS_DESCRIPTION</name></field><field><id>METRICS_SUBJECT</id><enabled>Y</enabled><name>METRICS_SUBJECT</name></field><field><id>METRICS_TYPE</id><enabled>Y</enabled><name>METRICS_TYPE</name></field><field><id>METRICS_VALUE</id><enabled>Y</enabled><name>METRICS_VALUE</name></field></metrics-log-table>  
57 - </log>  
58 - <maxdate>  
59 - <connection/>  
60 - <table/>  
61 - <field/>  
62 - <offset>0.0</offset>  
63 - <maxdiff>0.0</maxdiff>  
64 - </maxdate>  
65 - <size_rowset>10000</size_rowset>  
66 - <sleep_time_empty>50</sleep_time_empty>  
67 - <sleep_time_full>50</sleep_time_full>  
68 - <unique_connections>N</unique_connections>  
69 - <feedback_shown>Y</feedback_shown>  
70 - <feedback_size>50000</feedback_size>  
71 - <using_thread_priorities>Y</using_thread_priorities>  
72 - <shared_objects_file/>  
73 - <capture_step_performance>N</capture_step_performance>  
74 - <step_performance_capturing_delay>1000</step_performance_capturing_delay>  
75 - <step_performance_capturing_size_limit>100</step_performance_capturing_size_limit>  
76 - <dependencies>  
77 - </dependencies>  
78 - <partitionschemas>  
79 - </partitionschemas>  
80 - <slaveservers>  
81 - </slaveservers>  
82 - <clusterschemas>  
83 - </clusterschemas>  
84 - <created_user>-</created_user>  
85 - <created_date>2016&#x2f;08&#x2f;05 16&#x3a;42&#x3a;22.753</created_date>  
86 - <modified_user>-</modified_user>  
87 - <modified_date>2016&#x2f;08&#x2f;05 16&#x3a;42&#x3a;22.753</modified_date>  
88 - <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA&#x3d;</key_for_session_key>  
89 - <is_key_private>N</is_key_private>  
90 - </info>  
91 - <notepads>  
92 - </notepads>  
93 - <connection>  
94 - <name>192.168.168.1_jwgl_dw</name>  
95 - <server>192.168.168.1</server>  
96 - <type>ORACLE</type>  
97 - <access>Native</access>  
98 - <database>orcl</database>  
99 - <port>1521</port>  
100 - <username>jwgl_dw</username>  
101 - <password>Encrypted 2be98afc86aa7f2e4cb13b977d2adabcd</password>  
102 - <servername/>  
103 - <data_tablespace/>  
104 - <index_tablespace/>  
105 - <attributes>  
106 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
107 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
108 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
109 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
110 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
111 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
112 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
113 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
114 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
115 - </attributes>  
116 - </connection>  
117 - <connection>  
118 - <name>bus_control_variable</name>  
119 - <server>&#x24;&#x7b;v_db_ip&#x7d;</server>  
120 - <type>MYSQL</type>  
121 - <access>Native</access>  
122 - <database>&#x24;&#x7b;v_db_dname&#x7d;</database>  
123 - <port>3306</port>  
124 - <username>&#x24;&#x7b;v_db_uname&#x7d;</username>  
125 - <password>&#x24;&#x7b;v_db_pwd&#x7d;</password>  
126 - <servername/>  
127 - <data_tablespace/>  
128 - <index_tablespace/>  
129 - <attributes>  
130 - <attribute><code>EXTRA_OPTION_MYSQL.characterEncoding</code><attribute>utf8</attribute></attribute>  
131 - <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>  
132 - <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>  
133 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
134 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
135 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
136 - <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>  
137 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
138 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
139 - <attribute><code>STREAM_RESULTS</code><attribute>N</attribute></attribute>  
140 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
141 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
142 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
143 - </attributes>  
144 - </connection>  
145 - <connection>  
146 - <name>bus_control_&#x516c;&#x53f8;_201</name>  
147 - <server>localhost</server>  
148 - <type>MYSQL</type>  
149 - <access>Native</access>  
150 - <database>control</database>  
151 - <port>3306</port>  
152 - <username>root</username>  
153 - <password>Encrypted </password>  
154 - <servername/>  
155 - <data_tablespace/>  
156 - <index_tablespace/>  
157 - <attributes>  
158 - <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>  
159 - <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>  
160 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
161 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
162 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
163 - <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>  
164 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
165 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
166 - <attribute><code>STREAM_RESULTS</code><attribute>N</attribute></attribute>  
167 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
168 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
169 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
170 - </attributes>  
171 - </connection>  
172 - <connection>  
173 - <name>bus_control_&#x672c;&#x673a;</name>  
174 - <server>localhost</server>  
175 - <type>MYSQL</type>  
176 - <access>Native</access>  
177 - <database>control</database>  
178 - <port>3306</port>  
179 - <username>root</username>  
180 - <password>Encrypted </password>  
181 - <servername/>  
182 - <data_tablespace/>  
183 - <index_tablespace/>  
184 - <attributes>  
185 - <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>  
186 - <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>  
187 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
188 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
189 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
190 - <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>  
191 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
192 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
193 - <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>  
194 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
195 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
196 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
197 - </attributes>  
198 - </connection>  
199 - <connection>  
200 - <name>JGJW_VM</name>  
201 - <server>192.168.198.240</server>  
202 - <type>ORACLE</type>  
203 - <access>Native</access>  
204 - <database>orcl</database>  
205 - <port>1521</port>  
206 - <username>jwgl</username>  
207 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10d485a8d6</password>  
208 - <servername/>  
209 - <data_tablespace/>  
210 - <index_tablespace/>  
211 - <attributes>  
212 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
213 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
214 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
215 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
216 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
217 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
218 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
219 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
220 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
221 - </attributes>  
222 - </connection>  
223 - <connection>  
224 - <name>NHJW_VM</name>  
225 - <server>192.168.198.240</server>  
226 - <type>ORACLE</type>  
227 - <access>Native</access>  
228 - <database>orcl</database>  
229 - <port>1521</port>  
230 - <username>nhjw</username>  
231 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10d09aa5cd</password>  
232 - <servername/>  
233 - <data_tablespace/>  
234 - <index_tablespace/>  
235 - <attributes>  
236 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
237 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
238 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
239 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
240 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
241 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
242 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
243 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
244 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
245 - </attributes>  
246 - </connection>  
247 - <connection>  
248 - <name>PDGJ_VM</name>  
249 - <server>192.168.198.240</server>  
250 - <type>ORACLE</type>  
251 - <access>Native</access>  
252 - <database>orcl</database>  
253 - <port>1521</port>  
254 - <username>pdgj</username>  
255 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10ce96a8d0</password>  
256 - <servername/>  
257 - <data_tablespace/>  
258 - <index_tablespace/>  
259 - <attributes>  
260 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
261 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
262 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
263 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
264 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
265 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
266 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
267 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
268 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
269 - </attributes>  
270 - </connection>  
271 - <connection>  
272 - <name>SNJW_VM</name>  
273 - <server>192.168.198.240</server>  
274 - <type>ORACLE</type>  
275 - <access>Native</access>  
276 - <database>orcl</database>  
277 - <port>1521</port>  
278 - <username>snjw</username>  
279 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10cd9ca5cd</password>  
280 - <servername/>  
281 - <data_tablespace/>  
282 - <index_tablespace/>  
283 - <attributes>  
284 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
285 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
286 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
287 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
288 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
289 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
290 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
291 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
292 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
293 - </attributes>  
294 - </connection>  
295 - <connection>  
296 - <name>xlab_mysql_youle</name>  
297 - <server>101.231.124.8</server>  
298 - <type>MYSQL</type>  
299 - <access>Native</access>  
300 - <database>xlab_youle</database>  
301 - <port>45687</port>  
302 - <username>xlab-youle</username>  
303 - <password>Encrypted 2be98afc86aa78a88aa1be369d187a3df</password>  
304 - <servername/>  
305 - <data_tablespace/>  
306 - <index_tablespace/>  
307 - <attributes>  
308 - <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>  
309 - <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>  
310 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
311 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
312 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
313 - <attribute><code>PORT_NUMBER</code><attribute>45687</attribute></attribute>  
314 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
315 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
316 - <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>  
317 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>N</attribute></attribute>  
318 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>N</attribute></attribute>  
319 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
320 - </attributes>  
321 - </connection>  
322 - <connection>  
323 - <name>xlab_mysql_youle&#xff08;&#x672c;&#x673a;&#xff09;</name>  
324 - <server>localhost</server>  
325 - <type>MYSQL</type>  
326 - <access>Native</access>  
327 - <database>xlab_youle</database>  
328 - <port>3306</port>  
329 - <username>root</username>  
330 - <password>Encrypted </password>  
331 - <servername/>  
332 - <data_tablespace/>  
333 - <index_tablespace/>  
334 - <attributes>  
335 - <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>  
336 - <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>  
337 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
338 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
339 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
340 - <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>  
341 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
342 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
343 - <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>  
344 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>N</attribute></attribute>  
345 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>N</attribute></attribute>  
346 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
347 - </attributes>  
348 - </connection>  
349 - <connection>  
350 - <name>xlab_youle</name>  
351 - <server/>  
352 - <type>MYSQL</type>  
353 - <access>JNDI</access>  
354 - <database>xlab_youle</database>  
355 - <port>1521</port>  
356 - <username/>  
357 - <password>Encrypted </password>  
358 - <servername/>  
359 - <data_tablespace/>  
360 - <index_tablespace/>  
361 - <attributes>  
362 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
363 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
364 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
365 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
366 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
367 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
368 - <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>  
369 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
370 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
371 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
372 - </attributes>  
373 - </connection>  
374 - <connection>  
375 - <name>YGJW_VM</name>  
376 - <server>192.168.198.240</server>  
377 - <type>ORACLE</type>  
378 - <access>Native</access>  
379 - <database>orcl</database>  
380 - <port>1521</port>  
381 - <username>ygjw</username>  
382 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10c795a5cd</password>  
383 - <servername/>  
384 - <data_tablespace/>  
385 - <index_tablespace/>  
386 - <attributes>  
387 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
388 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
389 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
390 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
391 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
392 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
393 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
394 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
395 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
396 - </attributes>  
397 - </connection>  
398 - <connection>  
399 - <name>&#x516c;&#x53f8;jgjw</name>  
400 - <server>192.168.168.1</server>  
401 - <type>ORACLE</type>  
402 - <access>Native</access>  
403 - <database>orcl</database>  
404 - <port>1521</port>  
405 - <username>jwgl</username>  
406 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10d485a8d6</password>  
407 - <servername/>  
408 - <data_tablespace/>  
409 - <index_tablespace/>  
410 - <attributes>  
411 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
412 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
413 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
414 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
415 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
416 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
417 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
418 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
419 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
420 - </attributes>  
421 - </connection>  
422 - <connection>  
423 - <name>&#x516c;&#x53f8;snjw</name>  
424 - <server>192.168.168.1</server>  
425 - <type>ORACLE</type>  
426 - <access>Native</access>  
427 - <database>orcl</database>  
428 - <port>1521</port>  
429 - <username>snjw</username>  
430 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10cd9ca5cd</password>  
431 - <servername/>  
432 - <data_tablespace/>  
433 - <index_tablespace/>  
434 - <attributes>  
435 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
436 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
437 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
438 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
439 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
440 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
441 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
442 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
443 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
444 - </attributes>  
445 - </connection>  
446 - <connection>  
447 - <name>&#x516c;&#x53f8;ygjw</name>  
448 - <server>192.168.168.1</server>  
449 - <type>ORACLE</type>  
450 - <access>Native</access>  
451 - <database>orcl</database>  
452 - <port>1521</port>  
453 - <username>ygjw</username>  
454 - <password>Encrypted 2be98afc86aa7f2e4cb79ce10c795a5cd</password>  
455 - <servername/>  
456 - <data_tablespace/>  
457 - <index_tablespace/>  
458 - <attributes>  
459 - <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>  
460 - <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>  
461 - <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>  
462 - <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>  
463 - <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>  
464 - <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>  
465 - <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>  
466 - <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>  
467 - <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>  
468 - </attributes>  
469 - </connection>  
470 - <order>  
471 - <hop> <from>&#x516c;&#x53f8;&#x67e5;&#x8be2;</from><to>&#x5206;&#x516c;&#x53f8;&#x67e5;&#x8be2;</to><enabled>Y</enabled> </hop>  
472 - <hop> <from>&#x5206;&#x516c;&#x53f8;&#x67e5;&#x8be2;</from><to>&#x5b57;&#x6bb5;&#x9009;&#x62e9;</to><enabled>Y</enabled> </hop>  
473 - <hop> <from>&#x6dfb;&#x52a0;&#x67e5;&#x8be2;&#x5e38;&#x91cf;</from><to>&#x516c;&#x53f8;&#x67e5;&#x8be2;</to><enabled>Y</enabled> </hop>  
474 - <hop> <from>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x8868;&#x8f93;&#x5165;</from><to>&#x6dfb;&#x52a0;&#x67e5;&#x8be2;&#x5e38;&#x91cf;</to><enabled>Y</enabled> </hop>  
475 - <hop> <from>&#x5b57;&#x6bb5;&#x9009;&#x62e9;</from><to>&#x662f;&#x5426;&#x7535;&#x8f66;</to><enabled>Y</enabled> </hop>  
476 - <hop> <from>&#x662f;&#x5426;&#x7535;&#x8f66;</from><to>Excel&#x8f93;&#x51fa;</to><enabled>Y</enabled> </hop>  
477 - </order>  
478 - <step>  
479 - <name>Excel&#x8f93;&#x51fa;</name>  
480 - <type>ExcelOutput</type>  
481 - <description/>  
482 - <distribute>Y</distribute>  
483 - <custom_distribution/>  
484 - <copies>1</copies>  
485 - <partitioning>  
486 - <method>none</method>  
487 - <schema_name/>  
488 - </partitioning>  
489 - <header>Y</header>  
490 - <footer>N</footer>  
491 - <encoding/>  
492 - <append>N</append>  
493 - <add_to_result_filenames>Y</add_to_result_filenames>  
494 - <file>  
495 - <name>&#x24;&#x7b;filepath&#x7d;</name>  
496 - <extention>xls</extention>  
497 - <do_not_open_newfile_init>N</do_not_open_newfile_init>  
498 - <create_parent_folder>N</create_parent_folder>  
499 - <split>N</split>  
500 - <add_date>N</add_date>  
501 - <add_time>N</add_time>  
502 - <SpecifyFormat>N</SpecifyFormat>  
503 - <date_time_format>yyyyMMddHHmmss</date_time_format>  
504 - <sheetname>&#x5de5;&#x4f5c;&#x8868;1</sheetname>  
505 - <autosizecolums>N</autosizecolums>  
506 - <nullisblank>N</nullisblank>  
507 - <protect_sheet>N</protect_sheet>  
508 - <password>Encrypted </password>  
509 - <splitevery>0</splitevery>  
510 - <usetempfiles>N</usetempfiles>  
511 - <tempdirectory/>  
512 - </file>  
513 - <template>  
514 - <enabled>N</enabled>  
515 - <append>N</append>  
516 - <filename>template.xls</filename>  
517 - </template>  
518 - <fields>  
519 - <field>  
520 - <name>&#x8f66;&#x724c;&#x53f7;</name>  
521 - <type>String</type>  
522 - <format/>  
523 - </field>  
524 - <field>  
525 - <name>&#x5185;&#x90e8;&#x7f16;&#x7801;</name>  
526 - <type>String</type>  
527 - <format/>  
528 - </field>  
529 - <field>  
530 - <name>&#x6240;&#x5c5e;&#x516c;&#x53f8;</name>  
531 - <type>String</type>  
532 - <format/>  
533 - </field>  
534 - <field>  
535 - <name>&#x6240;&#x5c5e;&#x5206;&#x516c;&#x53f8;</name>  
536 - <type>String</type>  
537 - <format/>  
538 - </field>  
539 - <field>  
540 - <name>&#x8bbe;&#x5907;&#x4f9b;&#x5e94;&#x5382;&#x5546;</name>  
541 - <type>String</type>  
542 - <format/>  
543 - </field>  
544 - <field>  
545 - <name>&#x8bbe;&#x5907;&#x7ec8;&#x7aef;&#x53f7;</name>  
546 - <type>String</type>  
547 - <format/>  
548 - </field>  
549 - <field>  
550 - <name>&#x662f;&#x5426;&#x7535;&#x8f66;</name>  
551 - <type>String</type>  
552 - <format/>  
553 - </field>  
554 - </fields>  
555 - <custom>  
556 - <header_font_name>arial</header_font_name>  
557 - <header_font_size>10</header_font_size>  
558 - <header_font_bold>N</header_font_bold>  
559 - <header_font_italic>N</header_font_italic>  
560 - <header_font_underline>no</header_font_underline>  
561 - <header_font_orientation>horizontal</header_font_orientation>  
562 - <header_font_color>black</header_font_color>  
563 - <header_background_color>none</header_background_color>  
564 - <header_row_height>255</header_row_height>  
565 - <header_alignment>left</header_alignment>  
566 - <header_image/>  
567 - <row_font_name>arial</row_font_name>  
568 - <row_font_size>10</row_font_size>  
569 - <row_font_color>black</row_font_color>  
570 - <row_background_color>none</row_background_color>  
571 - </custom>  
572 - <cluster_schema/>  
573 - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>  
574 - <xloc>498</xloc>  
575 - <yloc>348</yloc>  
576 - <draw>Y</draw>  
577 - </GUI>  
578 - </step>  
579 -  
580 - <step>  
581 - <name>&#x516c;&#x53f8;&#x67e5;&#x8be2;</name>  
582 - <type>DBLookup</type>  
583 - <description/>  
584 - <distribute>Y</distribute>  
585 - <custom_distribution/>  
586 - <copies>1</copies>  
587 - <partitioning>  
588 - <method>none</method>  
589 - <schema_name/>  
590 - </partitioning>  
591 - <connection>bus_control_variable</connection>  
592 - <cache>N</cache>  
593 - <cache_load_all>N</cache_load_all>  
594 - <cache_size>0</cache_size>  
595 - <lookup>  
596 - <schema/>  
597 - <table>bsth_c_business</table>  
598 - <orderby/>  
599 - <fail_on_multiple>N</fail_on_multiple>  
600 - <eat_row_on_failure>N</eat_row_on_failure>  
601 - <key>  
602 - <name>up_code</name>  
603 - <field>up_code</field>  
604 - <condition>&#x3d;</condition>  
605 - <name2/>  
606 - </key>  
607 - <key>  
608 - <name>business_code</name>  
609 - <field>business_code</field>  
610 - <condition>&#x3d;</condition>  
611 - <name2/>  
612 - </key>  
613 - <value>  
614 - <name>business_name</name>  
615 - <rename>gs</rename>  
616 - <default/>  
617 - <type>String</type>  
618 - </value>  
619 - </lookup>  
620 - <cluster_schema/>  
621 - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>  
622 - <xloc>364</xloc>  
623 - <yloc>60</yloc>  
624 - <draw>Y</draw>  
625 - </GUI>  
626 - </step>  
627 -  
628 - <step>  
629 - <name>&#x5206;&#x516c;&#x53f8;&#x67e5;&#x8be2;</name>  
630 - <type>DBLookup</type>  
631 - <description/>  
632 - <distribute>Y</distribute>  
633 - <custom_distribution/>  
634 - <copies>1</copies>  
635 - <partitioning>  
636 - <method>none</method>  
637 - <schema_name/>  
638 - </partitioning>  
639 - <connection>bus_control_variable</connection>  
640 - <cache>N</cache>  
641 - <cache_load_all>N</cache_load_all>  
642 - <cache_size>0</cache_size>  
643 - <lookup>  
644 - <schema/>  
645 - <table>bsth_c_business</table>  
646 - <orderby/>  
647 - <fail_on_multiple>N</fail_on_multiple>  
648 - <eat_row_on_failure>N</eat_row_on_failure>  
649 - <key>  
650 - <name>business_code</name>  
651 - <field>up_code</field>  
652 - <condition>&#x3d;</condition>  
653 - <name2/>  
654 - </key>  
655 - <key>  
656 - <name>branche_company_code</name>  
657 - <field>business_code</field>  
658 - <condition>&#x3d;</condition>  
659 - <name2/>  
660 - </key>  
661 - <value>  
662 - <name>business_name</name>  
663 - <rename>fgs</rename>  
664 - <default/>  
665 - <type>String</type>  
666 - </value>  
667 - </lookup>  
668 - <cluster_schema/>  
669 - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>  
670 - <xloc>491</xloc>  
671 - <yloc>60</yloc>  
672 - <draw>Y</draw>  
673 - </GUI>  
674 - </step>  
675 -  
676 - <step>  
677 - <name>&#x5b57;&#x6bb5;&#x9009;&#x62e9;</name>  
678 - <type>SelectValues</type>  
679 - <description/>  
680 - <distribute>N</distribute>  
681 - <custom_distribution/>  
682 - <copies>1</copies>  
683 - <partitioning>  
684 - <method>none</method>  
685 - <schema_name/>  
686 - </partitioning>  
687 - <fields> <field> <name>car_plate</name>  
688 - <rename>&#x8f66;&#x724c;&#x53f7;</rename>  
689 - <length>-2</length>  
690 - <precision>-2</precision>  
691 - </field> <field> <name>inside_code</name>  
692 - <rename>&#x5185;&#x90e8;&#x7f16;&#x7801;</rename>  
693 - <length>-2</length>  
694 - <precision>-2</precision>  
695 - </field> <field> <name>gs</name>  
696 - <rename>&#x6240;&#x5c5e;&#x516c;&#x53f8;</rename>  
697 - <length>-2</length>  
698 - <precision>-2</precision>  
699 - </field> <field> <name>fgs</name>  
700 - <rename>&#x6240;&#x5c5e;&#x5206;&#x516c;&#x53f8;</rename>  
701 - <length>-2</length>  
702 - <precision>-2</precision>  
703 - </field> <field> <name>supplier_name</name>  
704 - <rename>&#x8bbe;&#x5907;&#x4f9b;&#x5e94;&#x5382;&#x5546;</rename>  
705 - <length>-2</length>  
706 - <precision>-2</precision>  
707 - </field> <field> <name>equipment_code</name>  
708 - <rename>&#x8bbe;&#x5907;&#x7ec8;&#x7aef;&#x53f7;</rename>  
709 - <length>-2</length>  
710 - <precision>-2</precision>  
711 - </field> <field> <name>sfdc</name>  
712 - <rename>sfdc_cal</rename>  
713 - <length>-2</length>  
714 - <precision>-2</precision>  
715 - </field> <select_unspecified>N</select_unspecified>  
716 - </fields> <cluster_schema/>  
717 - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>  
718 - <xloc>495</xloc>  
719 - <yloc>173</yloc>  
720 - <draw>Y</draw>  
721 - </GUI>  
722 - </step>  
723 -  
724 - <step>  
725 - <name>&#x662f;&#x5426;&#x7535;&#x8f66;</name>  
726 - <type>ScriptValueMod</type>  
727 - <description/>  
728 - <distribute>Y</distribute>  
729 - <custom_distribution/>  
730 - <copies>1</copies>  
731 - <partitioning>  
732 - <method>none</method>  
733 - <schema_name/>  
734 - </partitioning>  
735 - <compatible>N</compatible>  
736 - <optimizationLevel>9</optimizationLevel>  
737 - <jsScripts> <jsScript> <jsScript_type>0</jsScript_type>  
738 - <jsScript_name>Script 1</jsScript_name>  
739 - <jsScript_script>&#x2f;&#x2f;Script here&#xa;&#xa;var &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x5426;&#x22;&#x3b;&#xa;&#xa;if&#x28;sfdc_cal &#x3d;&#x3d; 0&#x29; &#x7b;&#xa; &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x5426;&#x22;&#x3b;&#xa;&#x7d; else if &#x28;sfdc_cal &#x3d;&#x3d; 1&#x29; &#x7b;&#xa; &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x662f;&#x22;&#x3b;&#xa;&#x7d; else &#x7b;&#xa; &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x5426;&#x22;&#x3b;&#xa;&#x7d;&#xa;</jsScript_script>  
740 - </jsScript> </jsScripts> <fields> <field> <name>&#x662f;&#x5426;&#x7535;&#x8f66;</name>  
741 - <rename>&#x662f;&#x5426;&#x7535;&#x8f66;</rename>  
742 - <type>String</type>  
743 - <length>-1</length>  
744 - <precision>-1</precision>  
745 - <replace>N</replace>  
746 - </field> </fields> <cluster_schema/>  
747 - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>  
748 - <xloc>695</xloc>  
749 - <yloc>173</yloc>  
750 - <draw>Y</draw>  
751 - </GUI>  
752 - </step>  
753 -  
754 - <step>  
755 - <name>&#x6dfb;&#x52a0;&#x67e5;&#x8be2;&#x5e38;&#x91cf;</name>  
756 - <type>ScriptValueMod</type>  
757 - <description/>  
758 - <distribute>Y</distribute>  
759 - <custom_distribution/>  
760 - <copies>1</copies>  
761 - <partitioning>  
762 - <method>none</method>  
763 - <schema_name/>  
764 - </partitioning>  
765 - <compatible>N</compatible>  
766 - <optimizationLevel>9</optimizationLevel>  
767 - <jsScripts> <jsScript> <jsScript_type>0</jsScript_type>  
768 - <jsScript_name>Script 1</jsScript_name>  
769 - <jsScript_script>&#x2f;&#x2f;Script here&#xa;&#xa;var up_code &#x3d; &#x27;88&#x27;&#x3b;</jsScript_script>  
770 - </jsScript> </jsScripts> <fields> <field> <name>up_code</name>  
771 - <rename>up_code</rename>  
772 - <type>String</type>  
773 - <length>-1</length>  
774 - <precision>-1</precision>  
775 - <replace>N</replace>  
776 - </field> </fields> <cluster_schema/>  
777 - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>  
778 - <xloc>227</xloc>  
779 - <yloc>59</yloc>  
780 - <draw>Y</draw>  
781 - </GUI>  
782 - </step>  
783 -  
784 - <step>  
785 - <name>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x8868;&#x8f93;&#x5165;</name>  
786 - <type>TableInput</type>  
787 - <description/>  
788 - <distribute>Y</distribute>  
789 - <custom_distribution/>  
790 - <copies>1</copies>  
791 - <partitioning>  
792 - <method>none</method>  
793 - <schema_name/>  
794 - </partitioning>  
795 - <connection>bus_control_variable</connection>  
796 - <sql>SELECT &#x2a; FROM bsth_c_cars&#xa;where &#x24;&#x7b;QUERY&#x7d;</sql>  
797 - <limit>0</limit>  
798 - <lookup/>  
799 - <execute_each_row>N</execute_each_row>  
800 - <variables_active>Y</variables_active>  
801 - <lazy_conversion_active>N</lazy_conversion_active>  
802 - <cluster_schema/>  
803 - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>  
804 - <xloc>88</xloc>  
805 - <yloc>59</yloc>  
806 - <draw>Y</draw>  
807 - </GUI>  
808 - </step>  
809 -  
810 - <step_error_handling>  
811 - </step_error_handling>  
812 - <slave-step-copy-partition-distribution>  
813 -</slave-step-copy-partition-distribution>  
814 - <slave_transformation>N</slave_transformation>  
815 -  
816 -</transformation> 1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<transformation>
  3 + <info>
  4 + <name>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x5bfc;&#x51fa;</name>
  5 + <description>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x5bfc;&#x51fa;</description>
  6 + <extended_description>&#x8f66;&#x8f86;&#x57fa;&#x7840;&#x4fe1;&#x606f;</extended_description>
  7 + <trans_version/>
  8 + <trans_type>Normal</trans_type>
  9 + <trans_status>0</trans_status>
  10 + <directory>&#x2f;</directory>
  11 + <parameters>
  12 + <parameter>
  13 + <name>QUERY</name>
  14 + <default_value/>
  15 + <description>&#x67e5;&#x8be2;</description>
  16 + </parameter>
  17 + <parameter>
  18 + <name>cgsbm_in</name>
  19 + <default_value/>
  20 + <description>&#x5206;&#x516c;&#x53f8;&#x7f16;&#x7801;</description>
  21 + </parameter>
  22 + <parameter>
  23 + <name>filepath</name>
  24 + <default_value>1&#x3d;1</default_value>
  25 + <description>excel&#x6587;&#x4ef6;&#x8def;&#x5f84;</description>
  26 + </parameter>
  27 + </parameters>
  28 + <log>
  29 +<trans-log-table><connection/>
  30 +<schema/>
  31 +<table/>
  32 +<size_limit_lines/>
  33 +<interval/>
  34 +<timeout_days/>
  35 +<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STATUS</id><enabled>Y</enabled><name>STATUS</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name><subject/></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name><subject/></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name><subject/></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name><subject/></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name><subject/></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name><subject/></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>STARTDATE</id><enabled>Y</enabled><name>STARTDATE</name></field><field><id>ENDDATE</id><enabled>Y</enabled><name>ENDDATE</name></field><field><id>LOGDATE</id><enabled>Y</enabled><name>LOGDATE</name></field><field><id>DEPDATE</id><enabled>Y</enabled><name>DEPDATE</name></field><field><id>REPLAYDATE</id><enabled>Y</enabled><name>REPLAYDATE</name></field><field><id>LOG_FIELD</id><enabled>Y</enabled><name>LOG_FIELD</name></field><field><id>EXECUTING_SERVER</id><enabled>N</enabled><name>EXECUTING_SERVER</name></field><field><id>EXECUTING_USER</id><enabled>N</enabled><name>EXECUTING_USER</name></field><field><id>CLIENT</id><enabled>N</enabled><name>CLIENT</name></field></trans-log-table>
  36 +<perf-log-table><connection/>
  37 +<schema/>
  38 +<table/>
  39 +<interval/>
  40 +<timeout_days/>
  41 +<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>SEQ_NR</id><enabled>Y</enabled><name>SEQ_NR</name></field><field><id>LOGDATE</id><enabled>Y</enabled><name>LOGDATE</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STEPNAME</id><enabled>Y</enabled><name>STEPNAME</name></field><field><id>STEP_COPY</id><enabled>Y</enabled><name>STEP_COPY</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>INPUT_BUFFER_ROWS</id><enabled>Y</enabled><name>INPUT_BUFFER_ROWS</name></field><field><id>OUTPUT_BUFFER_ROWS</id><enabled>Y</enabled><name>OUTPUT_BUFFER_ROWS</name></field></perf-log-table>
  42 +<channel-log-table><connection/>
  43 +<schema/>
  44 +<table/>
  45 +<timeout_days/>
  46 +<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>LOGGING_OBJECT_TYPE</id><enabled>Y</enabled><name>LOGGING_OBJECT_TYPE</name></field><field><id>OBJECT_NAME</id><enabled>Y</enabled><name>OBJECT_NAME</name></field><field><id>OBJECT_COPY</id><enabled>Y</enabled><name>OBJECT_COPY</name></field><field><id>REPOSITORY_DIRECTORY</id><enabled>Y</enabled><name>REPOSITORY_DIRECTORY</name></field><field><id>FILENAME</id><enabled>Y</enabled><name>FILENAME</name></field><field><id>OBJECT_ID</id><enabled>Y</enabled><name>OBJECT_ID</name></field><field><id>OBJECT_REVISION</id><enabled>Y</enabled><name>OBJECT_REVISION</name></field><field><id>PARENT_CHANNEL_ID</id><enabled>Y</enabled><name>PARENT_CHANNEL_ID</name></field><field><id>ROOT_CHANNEL_ID</id><enabled>Y</enabled><name>ROOT_CHANNEL_ID</name></field></channel-log-table>
  47 +<step-log-table><connection/>
  48 +<schema/>
  49 +<table/>
  50 +<timeout_days/>
  51 +<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>TRANSNAME</id><enabled>Y</enabled><name>TRANSNAME</name></field><field><id>STEPNAME</id><enabled>Y</enabled><name>STEPNAME</name></field><field><id>STEP_COPY</id><enabled>Y</enabled><name>STEP_COPY</name></field><field><id>LINES_READ</id><enabled>Y</enabled><name>LINES_READ</name></field><field><id>LINES_WRITTEN</id><enabled>Y</enabled><name>LINES_WRITTEN</name></field><field><id>LINES_UPDATED</id><enabled>Y</enabled><name>LINES_UPDATED</name></field><field><id>LINES_INPUT</id><enabled>Y</enabled><name>LINES_INPUT</name></field><field><id>LINES_OUTPUT</id><enabled>Y</enabled><name>LINES_OUTPUT</name></field><field><id>LINES_REJECTED</id><enabled>Y</enabled><name>LINES_REJECTED</name></field><field><id>ERRORS</id><enabled>Y</enabled><name>ERRORS</name></field><field><id>LOG_FIELD</id><enabled>N</enabled><name>LOG_FIELD</name></field></step-log-table>
  52 +<metrics-log-table><connection/>
  53 +<schema/>
  54 +<table/>
  55 +<timeout_days/>
  56 +<field><id>ID_BATCH</id><enabled>Y</enabled><name>ID_BATCH</name></field><field><id>CHANNEL_ID</id><enabled>Y</enabled><name>CHANNEL_ID</name></field><field><id>LOG_DATE</id><enabled>Y</enabled><name>LOG_DATE</name></field><field><id>METRICS_DATE</id><enabled>Y</enabled><name>METRICS_DATE</name></field><field><id>METRICS_CODE</id><enabled>Y</enabled><name>METRICS_CODE</name></field><field><id>METRICS_DESCRIPTION</id><enabled>Y</enabled><name>METRICS_DESCRIPTION</name></field><field><id>METRICS_SUBJECT</id><enabled>Y</enabled><name>METRICS_SUBJECT</name></field><field><id>METRICS_TYPE</id><enabled>Y</enabled><name>METRICS_TYPE</name></field><field><id>METRICS_VALUE</id><enabled>Y</enabled><name>METRICS_VALUE</name></field></metrics-log-table>
  57 + </log>
  58 + <maxdate>
  59 + <connection/>
  60 + <table/>
  61 + <field/>
  62 + <offset>0.0</offset>
  63 + <maxdiff>0.0</maxdiff>
  64 + </maxdate>
  65 + <size_rowset>10000</size_rowset>
  66 + <sleep_time_empty>50</sleep_time_empty>
  67 + <sleep_time_full>50</sleep_time_full>
  68 + <unique_connections>N</unique_connections>
  69 + <feedback_shown>Y</feedback_shown>
  70 + <feedback_size>50000</feedback_size>
  71 + <using_thread_priorities>Y</using_thread_priorities>
  72 + <shared_objects_file/>
  73 + <capture_step_performance>N</capture_step_performance>
  74 + <step_performance_capturing_delay>1000</step_performance_capturing_delay>
  75 + <step_performance_capturing_size_limit>100</step_performance_capturing_size_limit>
  76 + <dependencies>
  77 + </dependencies>
  78 + <partitionschemas>
  79 + </partitionschemas>
  80 + <slaveservers>
  81 + </slaveservers>
  82 + <clusterschemas>
  83 + </clusterschemas>
  84 + <created_user>-</created_user>
  85 + <created_date>2016&#x2f;08&#x2f;05 16&#x3a;42&#x3a;22.753</created_date>
  86 + <modified_user>-</modified_user>
  87 + <modified_date>2016&#x2f;08&#x2f;05 16&#x3a;42&#x3a;22.753</modified_date>
  88 + <key_for_session_key>H4sIAAAAAAAAAAMAAAAAAAAAAAA&#x3d;</key_for_session_key>
  89 + <is_key_private>N</is_key_private>
  90 + </info>
  91 + <notepads>
  92 + </notepads>
  93 + <connection>
  94 + <name>192.168.168.1_jwgl_dw</name>
  95 + <server>192.168.168.1</server>
  96 + <type>ORACLE</type>
  97 + <access>Native</access>
  98 + <database>orcl</database>
  99 + <port>1521</port>
  100 + <username>jwgl_dw</username>
  101 + <password>Encrypted 2be98afc86aa7f2e4cb13b977d2adabcd</password>
  102 + <servername/>
  103 + <data_tablespace/>
  104 + <index_tablespace/>
  105 + <attributes>
  106 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  107 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  108 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  109 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  110 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  111 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  112 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  113 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  114 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  115 + </attributes>
  116 + </connection>
  117 + <connection>
  118 + <name>bus_control_variable</name>
  119 + <server>&#x24;&#x7b;v_db_ip&#x7d;</server>
  120 + <type>MYSQL</type>
  121 + <access>Native</access>
  122 + <database>&#x24;&#x7b;v_db_dname&#x7d;</database>
  123 + <port>3306</port>
  124 + <username>&#x24;&#x7b;v_db_uname&#x7d;</username>
  125 + <password>&#x24;&#x7b;v_db_pwd&#x7d;</password>
  126 + <servername/>
  127 + <data_tablespace/>
  128 + <index_tablespace/>
  129 + <attributes>
  130 + <attribute><code>EXTRA_OPTION_MYSQL.characterEncoding</code><attribute>utf8</attribute></attribute>
  131 + <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
  132 + <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
  133 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  134 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  135 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  136 + <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>
  137 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  138 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  139 + <attribute><code>STREAM_RESULTS</code><attribute>N</attribute></attribute>
  140 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  141 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  142 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  143 + </attributes>
  144 + </connection>
  145 + <connection>
  146 + <name>bus_control_&#x516c;&#x53f8;_201</name>
  147 + <server>localhost</server>
  148 + <type>MYSQL</type>
  149 + <access>Native</access>
  150 + <database>control</database>
  151 + <port>3306</port>
  152 + <username>root</username>
  153 + <password>Encrypted </password>
  154 + <servername/>
  155 + <data_tablespace/>
  156 + <index_tablespace/>
  157 + <attributes>
  158 + <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
  159 + <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
  160 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  161 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  162 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  163 + <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>
  164 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  165 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  166 + <attribute><code>STREAM_RESULTS</code><attribute>N</attribute></attribute>
  167 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  168 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  169 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  170 + </attributes>
  171 + </connection>
  172 + <connection>
  173 + <name>bus_control_&#x672c;&#x673a;</name>
  174 + <server>localhost</server>
  175 + <type>MYSQL</type>
  176 + <access>Native</access>
  177 + <database>control</database>
  178 + <port>3306</port>
  179 + <username>root</username>
  180 + <password>Encrypted </password>
  181 + <servername/>
  182 + <data_tablespace/>
  183 + <index_tablespace/>
  184 + <attributes>
  185 + <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
  186 + <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
  187 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  188 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  189 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  190 + <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>
  191 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  192 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  193 + <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>
  194 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  195 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  196 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  197 + </attributes>
  198 + </connection>
  199 + <connection>
  200 + <name>JGJW_VM</name>
  201 + <server>192.168.198.240</server>
  202 + <type>ORACLE</type>
  203 + <access>Native</access>
  204 + <database>orcl</database>
  205 + <port>1521</port>
  206 + <username>jwgl</username>
  207 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10d485a8d6</password>
  208 + <servername/>
  209 + <data_tablespace/>
  210 + <index_tablespace/>
  211 + <attributes>
  212 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  213 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  214 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  215 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  216 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  217 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  218 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  219 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  220 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  221 + </attributes>
  222 + </connection>
  223 + <connection>
  224 + <name>NHJW_VM</name>
  225 + <server>192.168.198.240</server>
  226 + <type>ORACLE</type>
  227 + <access>Native</access>
  228 + <database>orcl</database>
  229 + <port>1521</port>
  230 + <username>nhjw</username>
  231 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10d09aa5cd</password>
  232 + <servername/>
  233 + <data_tablespace/>
  234 + <index_tablespace/>
  235 + <attributes>
  236 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  237 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  238 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  239 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  240 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  241 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  242 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  243 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  244 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  245 + </attributes>
  246 + </connection>
  247 + <connection>
  248 + <name>PDGJ_VM</name>
  249 + <server>192.168.198.240</server>
  250 + <type>ORACLE</type>
  251 + <access>Native</access>
  252 + <database>orcl</database>
  253 + <port>1521</port>
  254 + <username>pdgj</username>
  255 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10ce96a8d0</password>
  256 + <servername/>
  257 + <data_tablespace/>
  258 + <index_tablespace/>
  259 + <attributes>
  260 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  261 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  262 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  263 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  264 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  265 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  266 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  267 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  268 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  269 + </attributes>
  270 + </connection>
  271 + <connection>
  272 + <name>SNJW_VM</name>
  273 + <server>192.168.198.240</server>
  274 + <type>ORACLE</type>
  275 + <access>Native</access>
  276 + <database>orcl</database>
  277 + <port>1521</port>
  278 + <username>snjw</username>
  279 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10cd9ca5cd</password>
  280 + <servername/>
  281 + <data_tablespace/>
  282 + <index_tablespace/>
  283 + <attributes>
  284 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  285 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  286 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  287 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  288 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  289 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  290 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  291 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  292 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  293 + </attributes>
  294 + </connection>
  295 + <connection>
  296 + <name>xlab_mysql_youle</name>
  297 + <server>101.231.124.8</server>
  298 + <type>MYSQL</type>
  299 + <access>Native</access>
  300 + <database>xlab_youle</database>
  301 + <port>45687</port>
  302 + <username>xlab-youle</username>
  303 + <password>Encrypted 2be98afc86aa78a88aa1be369d187a3df</password>
  304 + <servername/>
  305 + <data_tablespace/>
  306 + <index_tablespace/>
  307 + <attributes>
  308 + <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
  309 + <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
  310 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  311 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  312 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  313 + <attribute><code>PORT_NUMBER</code><attribute>45687</attribute></attribute>
  314 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  315 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  316 + <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>
  317 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>N</attribute></attribute>
  318 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>N</attribute></attribute>
  319 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  320 + </attributes>
  321 + </connection>
  322 + <connection>
  323 + <name>xlab_mysql_youle&#xff08;&#x672c;&#x673a;&#xff09;</name>
  324 + <server>localhost</server>
  325 + <type>MYSQL</type>
  326 + <access>Native</access>
  327 + <database>xlab_youle</database>
  328 + <port>3306</port>
  329 + <username>root</username>
  330 + <password>Encrypted </password>
  331 + <servername/>
  332 + <data_tablespace/>
  333 + <index_tablespace/>
  334 + <attributes>
  335 + <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
  336 + <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
  337 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  338 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  339 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  340 + <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>
  341 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  342 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  343 + <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>
  344 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>N</attribute></attribute>
  345 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>N</attribute></attribute>
  346 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  347 + </attributes>
  348 + </connection>
  349 + <connection>
  350 + <name>xlab_youle</name>
  351 + <server/>
  352 + <type>MYSQL</type>
  353 + <access>JNDI</access>
  354 + <database>xlab_youle</database>
  355 + <port>1521</port>
  356 + <username/>
  357 + <password>Encrypted </password>
  358 + <servername/>
  359 + <data_tablespace/>
  360 + <index_tablespace/>
  361 + <attributes>
  362 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  363 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  364 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  365 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  366 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  367 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  368 + <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>
  369 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  370 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  371 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  372 + </attributes>
  373 + </connection>
  374 + <connection>
  375 + <name>YGJW_VM</name>
  376 + <server>192.168.198.240</server>
  377 + <type>ORACLE</type>
  378 + <access>Native</access>
  379 + <database>orcl</database>
  380 + <port>1521</port>
  381 + <username>ygjw</username>
  382 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10c795a5cd</password>
  383 + <servername/>
  384 + <data_tablespace/>
  385 + <index_tablespace/>
  386 + <attributes>
  387 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  388 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  389 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  390 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  391 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  392 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  393 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  394 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  395 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  396 + </attributes>
  397 + </connection>
  398 + <connection>
  399 + <name>&#x516c;&#x53f8;jgjw</name>
  400 + <server>192.168.168.1</server>
  401 + <type>ORACLE</type>
  402 + <access>Native</access>
  403 + <database>orcl</database>
  404 + <port>1521</port>
  405 + <username>jwgl</username>
  406 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10d485a8d6</password>
  407 + <servername/>
  408 + <data_tablespace/>
  409 + <index_tablespace/>
  410 + <attributes>
  411 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  412 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  413 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  414 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  415 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  416 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  417 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  418 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  419 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  420 + </attributes>
  421 + </connection>
  422 + <connection>
  423 + <name>&#x516c;&#x53f8;snjw</name>
  424 + <server>192.168.168.1</server>
  425 + <type>ORACLE</type>
  426 + <access>Native</access>
  427 + <database>orcl</database>
  428 + <port>1521</port>
  429 + <username>snjw</username>
  430 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10cd9ca5cd</password>
  431 + <servername/>
  432 + <data_tablespace/>
  433 + <index_tablespace/>
  434 + <attributes>
  435 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  436 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  437 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  438 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  439 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  440 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  441 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  442 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  443 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  444 + </attributes>
  445 + </connection>
  446 + <connection>
  447 + <name>&#x516c;&#x53f8;ygjw</name>
  448 + <server>192.168.168.1</server>
  449 + <type>ORACLE</type>
  450 + <access>Native</access>
  451 + <database>orcl</database>
  452 + <port>1521</port>
  453 + <username>ygjw</username>
  454 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10c795a5cd</password>
  455 + <servername/>
  456 + <data_tablespace/>
  457 + <index_tablespace/>
  458 + <attributes>
  459 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  460 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  461 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  462 + <attribute><code>PORT_NUMBER</code><attribute>1521</attribute></attribute>
  463 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  464 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  465 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  466 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  467 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  468 + </attributes>
  469 + </connection>
  470 + <order>
  471 + <hop> <from>&#x516c;&#x53f8;&#x67e5;&#x8be2;</from><to>&#x5206;&#x516c;&#x53f8;&#x67e5;&#x8be2;</to><enabled>Y</enabled> </hop>
  472 + <hop> <from>&#x5206;&#x516c;&#x53f8;&#x67e5;&#x8be2;</from><to>&#x5b57;&#x6bb5;&#x9009;&#x62e9;</to><enabled>Y</enabled> </hop>
  473 + <hop> <from>&#x6dfb;&#x52a0;&#x67e5;&#x8be2;&#x5e38;&#x91cf;</from><to>&#x516c;&#x53f8;&#x67e5;&#x8be2;</to><enabled>Y</enabled> </hop>
  474 + <hop> <from>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x8868;&#x8f93;&#x5165;</from><to>&#x6dfb;&#x52a0;&#x67e5;&#x8be2;&#x5e38;&#x91cf;</to><enabled>Y</enabled> </hop>
  475 + <hop> <from>&#x5b57;&#x6bb5;&#x9009;&#x62e9;</from><to>&#x662f;&#x5426;&#x7535;&#x8f66;</to><enabled>Y</enabled> </hop>
  476 + <hop> <from>&#x662f;&#x5426;&#x7535;&#x8f66;</from><to>Excel&#x8f93;&#x51fa;</to><enabled>Y</enabled> </hop>
  477 + </order>
  478 + <step>
  479 + <name>Excel&#x8f93;&#x51fa;</name>
  480 + <type>ExcelOutput</type>
  481 + <description/>
  482 + <distribute>Y</distribute>
  483 + <custom_distribution/>
  484 + <copies>1</copies>
  485 + <partitioning>
  486 + <method>none</method>
  487 + <schema_name/>
  488 + </partitioning>
  489 + <header>Y</header>
  490 + <footer>N</footer>
  491 + <encoding/>
  492 + <append>N</append>
  493 + <add_to_result_filenames>Y</add_to_result_filenames>
  494 + <file>
  495 + <name>&#x24;&#x7b;filepath&#x7d;</name>
  496 + <extention>xls</extention>
  497 + <do_not_open_newfile_init>N</do_not_open_newfile_init>
  498 + <create_parent_folder>N</create_parent_folder>
  499 + <split>N</split>
  500 + <add_date>N</add_date>
  501 + <add_time>N</add_time>
  502 + <SpecifyFormat>N</SpecifyFormat>
  503 + <date_time_format>yyyyMMddHHmmss</date_time_format>
  504 + <sheetname>&#x5de5;&#x4f5c;&#x8868;1</sheetname>
  505 + <autosizecolums>N</autosizecolums>
  506 + <nullisblank>N</nullisblank>
  507 + <protect_sheet>N</protect_sheet>
  508 + <password>Encrypted </password>
  509 + <splitevery>0</splitevery>
  510 + <usetempfiles>N</usetempfiles>
  511 + <tempdirectory/>
  512 + </file>
  513 + <template>
  514 + <enabled>N</enabled>
  515 + <append>N</append>
  516 + <filename>template.xls</filename>
  517 + </template>
  518 + <fields>
  519 + <field>
  520 + <name>&#x8f66;&#x724c;&#x53f7;</name>
  521 + <type>String</type>
  522 + <format/>
  523 + </field>
  524 + <field>
  525 + <name>&#x5185;&#x90e8;&#x7f16;&#x7801;</name>
  526 + <type>String</type>
  527 + <format/>
  528 + </field>
  529 + <field>
  530 + <name>&#x6240;&#x5c5e;&#x516c;&#x53f8;</name>
  531 + <type>String</type>
  532 + <format/>
  533 + </field>
  534 + <field>
  535 + <name>&#x6240;&#x5c5e;&#x5206;&#x516c;&#x53f8;</name>
  536 + <type>String</type>
  537 + <format/>
  538 + </field>
  539 + <field>
  540 + <name>&#x8bbe;&#x5907;&#x4f9b;&#x5e94;&#x5382;&#x5546;</name>
  541 + <type>String</type>
  542 + <format/>
  543 + </field>
  544 + <field>
  545 + <name>&#x8bbe;&#x5907;&#x7ec8;&#x7aef;&#x53f7;</name>
  546 + <type>String</type>
  547 + <format/>
  548 + </field>
  549 + <field>
  550 + <name>&#x662f;&#x5426;&#x7535;&#x8f66;</name>
  551 + <type>String</type>
  552 + <format/>
  553 + </field>
  554 + </fields>
  555 + <custom>
  556 + <header_font_name>arial</header_font_name>
  557 + <header_font_size>10</header_font_size>
  558 + <header_font_bold>N</header_font_bold>
  559 + <header_font_italic>N</header_font_italic>
  560 + <header_font_underline>no</header_font_underline>
  561 + <header_font_orientation>horizontal</header_font_orientation>
  562 + <header_font_color>black</header_font_color>
  563 + <header_background_color>none</header_background_color>
  564 + <header_row_height>255</header_row_height>
  565 + <header_alignment>left</header_alignment>
  566 + <header_image/>
  567 + <row_font_name>arial</row_font_name>
  568 + <row_font_size>10</row_font_size>
  569 + <row_font_color>black</row_font_color>
  570 + <row_background_color>none</row_background_color>
  571 + </custom>
  572 + <cluster_schema/>
  573 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  574 + <xloc>498</xloc>
  575 + <yloc>348</yloc>
  576 + <draw>Y</draw>
  577 + </GUI>
  578 + </step>
  579 +
  580 + <step>
  581 + <name>&#x516c;&#x53f8;&#x67e5;&#x8be2;</name>
  582 + <type>DBLookup</type>
  583 + <description/>
  584 + <distribute>Y</distribute>
  585 + <custom_distribution/>
  586 + <copies>1</copies>
  587 + <partitioning>
  588 + <method>none</method>
  589 + <schema_name/>
  590 + </partitioning>
  591 + <connection>bus_control_variable</connection>
  592 + <cache>N</cache>
  593 + <cache_load_all>N</cache_load_all>
  594 + <cache_size>0</cache_size>
  595 + <lookup>
  596 + <schema/>
  597 + <table>bsth_c_business</table>
  598 + <orderby/>
  599 + <fail_on_multiple>N</fail_on_multiple>
  600 + <eat_row_on_failure>N</eat_row_on_failure>
  601 + <key>
  602 + <name>up_code</name>
  603 + <field>up_code</field>
  604 + <condition>&#x3d;</condition>
  605 + <name2/>
  606 + </key>
  607 + <key>
  608 + <name>business_code</name>
  609 + <field>business_code</field>
  610 + <condition>&#x3d;</condition>
  611 + <name2/>
  612 + </key>
  613 + <value>
  614 + <name>business_name</name>
  615 + <rename>gs</rename>
  616 + <default/>
  617 + <type>String</type>
  618 + </value>
  619 + </lookup>
  620 + <cluster_schema/>
  621 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  622 + <xloc>364</xloc>
  623 + <yloc>60</yloc>
  624 + <draw>Y</draw>
  625 + </GUI>
  626 + </step>
  627 +
  628 + <step>
  629 + <name>&#x5206;&#x516c;&#x53f8;&#x67e5;&#x8be2;</name>
  630 + <type>DBLookup</type>
  631 + <description/>
  632 + <distribute>Y</distribute>
  633 + <custom_distribution/>
  634 + <copies>1</copies>
  635 + <partitioning>
  636 + <method>none</method>
  637 + <schema_name/>
  638 + </partitioning>
  639 + <connection>bus_control_variable</connection>
  640 + <cache>N</cache>
  641 + <cache_load_all>N</cache_load_all>
  642 + <cache_size>0</cache_size>
  643 + <lookup>
  644 + <schema/>
  645 + <table>bsth_c_business</table>
  646 + <orderby/>
  647 + <fail_on_multiple>N</fail_on_multiple>
  648 + <eat_row_on_failure>N</eat_row_on_failure>
  649 + <key>
  650 + <name>business_code</name>
  651 + <field>up_code</field>
  652 + <condition>&#x3d;</condition>
  653 + <name2/>
  654 + </key>
  655 + <key>
  656 + <name>branche_company_code</name>
  657 + <field>business_code</field>
  658 + <condition>&#x3d;</condition>
  659 + <name2/>
  660 + </key>
  661 + <value>
  662 + <name>business_name</name>
  663 + <rename>fgs</rename>
  664 + <default/>
  665 + <type>String</type>
  666 + </value>
  667 + </lookup>
  668 + <cluster_schema/>
  669 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  670 + <xloc>491</xloc>
  671 + <yloc>60</yloc>
  672 + <draw>Y</draw>
  673 + </GUI>
  674 + </step>
  675 +
  676 + <step>
  677 + <name>&#x5b57;&#x6bb5;&#x9009;&#x62e9;</name>
  678 + <type>SelectValues</type>
  679 + <description/>
  680 + <distribute>N</distribute>
  681 + <custom_distribution/>
  682 + <copies>1</copies>
  683 + <partitioning>
  684 + <method>none</method>
  685 + <schema_name/>
  686 + </partitioning>
  687 + <fields> <field> <name>car_plate</name>
  688 + <rename>&#x8f66;&#x724c;&#x53f7;</rename>
  689 + <length>-2</length>
  690 + <precision>-2</precision>
  691 + </field> <field> <name>inside_code</name>
  692 + <rename>&#x5185;&#x90e8;&#x7f16;&#x7801;</rename>
  693 + <length>-2</length>
  694 + <precision>-2</precision>
  695 + </field> <field> <name>gs</name>
  696 + <rename>&#x6240;&#x5c5e;&#x516c;&#x53f8;</rename>
  697 + <length>-2</length>
  698 + <precision>-2</precision>
  699 + </field> <field> <name>fgs</name>
  700 + <rename>&#x6240;&#x5c5e;&#x5206;&#x516c;&#x53f8;</rename>
  701 + <length>-2</length>
  702 + <precision>-2</precision>
  703 + </field> <field> <name>supplier_name</name>
  704 + <rename>&#x8bbe;&#x5907;&#x4f9b;&#x5e94;&#x5382;&#x5546;</rename>
  705 + <length>-2</length>
  706 + <precision>-2</precision>
  707 + </field> <field> <name>equipment_code</name>
  708 + <rename>&#x8bbe;&#x5907;&#x7ec8;&#x7aef;&#x53f7;</rename>
  709 + <length>-2</length>
  710 + <precision>-2</precision>
  711 + </field> <field> <name>sfdc</name>
  712 + <rename>sfdc_cal</rename>
  713 + <length>-2</length>
  714 + <precision>-2</precision>
  715 + </field> <select_unspecified>N</select_unspecified>
  716 + </fields> <cluster_schema/>
  717 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  718 + <xloc>495</xloc>
  719 + <yloc>173</yloc>
  720 + <draw>Y</draw>
  721 + </GUI>
  722 + </step>
  723 +
  724 + <step>
  725 + <name>&#x662f;&#x5426;&#x7535;&#x8f66;</name>
  726 + <type>ScriptValueMod</type>
  727 + <description/>
  728 + <distribute>Y</distribute>
  729 + <custom_distribution/>
  730 + <copies>1</copies>
  731 + <partitioning>
  732 + <method>none</method>
  733 + <schema_name/>
  734 + </partitioning>
  735 + <compatible>N</compatible>
  736 + <optimizationLevel>9</optimizationLevel>
  737 + <jsScripts> <jsScript> <jsScript_type>0</jsScript_type>
  738 + <jsScript_name>Script 1</jsScript_name>
  739 + <jsScript_script>&#x2f;&#x2f;Script here&#xa;&#xa;var &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x5426;&#x22;&#x3b;&#xa;&#xa;if&#x28;sfdc_cal &#x3d;&#x3d; 0&#x29; &#x7b;&#xa; &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x5426;&#x22;&#x3b;&#xa;&#x7d; else if &#x28;sfdc_cal &#x3d;&#x3d; 1&#x29; &#x7b;&#xa; &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x662f;&#x22;&#x3b;&#xa;&#x7d; else &#x7b;&#xa; &#x662f;&#x5426;&#x7535;&#x8f66; &#x3d; &#x22;&#x5426;&#x22;&#x3b;&#xa;&#x7d;&#xa;</jsScript_script>
  740 + </jsScript> </jsScripts> <fields> <field> <name>&#x662f;&#x5426;&#x7535;&#x8f66;</name>
  741 + <rename>&#x662f;&#x5426;&#x7535;&#x8f66;</rename>
  742 + <type>String</type>
  743 + <length>-1</length>
  744 + <precision>-1</precision>
  745 + <replace>N</replace>
  746 + </field> </fields> <cluster_schema/>
  747 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  748 + <xloc>695</xloc>
  749 + <yloc>173</yloc>
  750 + <draw>Y</draw>
  751 + </GUI>
  752 + </step>
  753 +
  754 + <step>
  755 + <name>&#x6dfb;&#x52a0;&#x67e5;&#x8be2;&#x5e38;&#x91cf;</name>
  756 + <type>ScriptValueMod</type>
  757 + <description/>
  758 + <distribute>Y</distribute>
  759 + <custom_distribution/>
  760 + <copies>1</copies>
  761 + <partitioning>
  762 + <method>none</method>
  763 + <schema_name/>
  764 + </partitioning>
  765 + <compatible>N</compatible>
  766 + <optimizationLevel>9</optimizationLevel>
  767 + <jsScripts> <jsScript> <jsScript_type>0</jsScript_type>
  768 + <jsScript_name>Script 1</jsScript_name>
  769 + <jsScript_script>&#x2f;&#x2f;Script here&#xa;&#xa;var up_code &#x3d; &#x27;88&#x27;&#x3b;</jsScript_script>
  770 + </jsScript> </jsScripts> <fields> <field> <name>up_code</name>
  771 + <rename>up_code</rename>
  772 + <type>String</type>
  773 + <length>-1</length>
  774 + <precision>-1</precision>
  775 + <replace>N</replace>
  776 + </field> </fields> <cluster_schema/>
  777 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  778 + <xloc>227</xloc>
  779 + <yloc>59</yloc>
  780 + <draw>Y</draw>
  781 + </GUI>
  782 + </step>
  783 +
  784 + <step>
  785 + <name>&#x8f66;&#x8f86;&#x4fe1;&#x606f;&#x8868;&#x8f93;&#x5165;</name>
  786 + <type>TableInput</type>
  787 + <description/>
  788 + <distribute>Y</distribute>
  789 + <custom_distribution/>
  790 + <copies>1</copies>
  791 + <partitioning>
  792 + <method>none</method>
  793 + <schema_name/>
  794 + </partitioning>
  795 + <connection>bus_control_variable</connection>
  796 + <sql>SELECT &#x2a; FROM bsth_c_cars&#xa;where &#x24;&#x7b;QUERY&#x7d;</sql>
  797 + <limit>0</limit>
  798 + <lookup/>
  799 + <execute_each_row>N</execute_each_row>
  800 + <variables_active>Y</variables_active>
  801 + <lazy_conversion_active>N</lazy_conversion_active>
  802 + <cluster_schema/>
  803 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  804 + <xloc>88</xloc>
  805 + <yloc>59</yloc>
  806 + <draw>Y</draw>
  807 + </GUI>
  808 + </step>
  809 +
  810 + <step_error_handling>
  811 + </step_error_handling>
  812 + <slave-step-copy-partition-distribution>
  813 +</slave-step-copy-partition-distribution>
  814 + <slave_transformation>N</slave_transformation>
  815 +
  816 +</transformation>
src/main/resources/rules/kBase1_core_functions.drl
1 -package com.bsth.service.schedule.impl.plan.kBase1.core;  
2 -  
3 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidsCountFunction gidscount;  
4 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbTimeFunction gidfbtime;  
5 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbFcnoFunction gidfbfcno;  
6 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResultsFunction lpinforesult;  
7 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.MinRuleQyrqFunction minruleqyrq;  
8 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidRepeatBcFunction vrb;  
9 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWholeRerunBcFunction vwrb;  
10 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWantLpFunction vwlp; 1 +package com.bsth.service.schedule.impl.plan.kBase1.core;
  2 +
  3 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidsCountFunction gidscount;
  4 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbTimeFunction gidfbtime;
  5 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbFcnoFunction gidfbfcno;
  6 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResultsFunction lpinforesult;
  7 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.MinRuleQyrqFunction minruleqyrq;
  8 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidRepeatBcFunction vrb;
  9 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWholeRerunBcFunction vwrb;
  10 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWantLpFunction vwlp;
src/main/resources/rules/kBase1_core_plan.drl
1 -package com.bsth.service.schedule.impl.plan.kBase1.core.plan;  
2 -  
3 -import org.joda.time.*;  
4 -import java.util.*;  
5 -  
6 -import com.bsth.service.schedule.impl.plan.kBase1.core.plan.PlanCalcuParam_input;  
7 -import com.bsth.service.schedule.impl.plan.kBase1.core.plan.PlanResult;  
8 -  
9 -import com.bsth.repository.schedule.TTInfoDetailRepository;  
10 -import com.bsth.repository.schedule.CarConfigInfoRepository;  
11 -import com.bsth.repository.schedule.EmployeeConfigInfoRepository;  
12 -import com.bsth.repository.LineRepository;  
13 -import com.bsth.repository.BusinessRepository;  
14 -  
15 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResult_output;  
16 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;  
17 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResult_output;  
18 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResults_output;  
19 -import com.bsth.entity.Line;  
20 -import com.bsth.entity.Business;  
21 -  
22 -import com.bsth.entity.schedule.CarConfigInfo;  
23 -import com.bsth.entity.schedule.EmployeeConfigInfo;  
24 -import com.bsth.entity.schedule.TTInfo;  
25 -import com.bsth.entity.schedule.TTInfoDetail;  
26 -import com.bsth.entity.schedule.SchedulePlanInfo;  
27 -  
28 -import org.slf4j.Logger  
29 -import org.joda.time.format.DateTimeFormat  
30 -import org.apache.commons.lang3.StringUtils  
31 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;  
32 -  
33 -  
34 -// 全局日志类(一般使用调用此规则的service类)  
35 -global Logger log;  
36 -  
37 -global TTInfoDetailRepository tTInfoDetailRepository;  
38 -global CarConfigInfoRepository carConfigInfoRepository;  
39 -global EmployeeConfigInfoRepository employeeConfigInfoRepository;  
40 -global LineRepository lineRepository;  
41 -global BusinessRepository businessRepository;  
42 -  
43 -// 输出  
44 -global PlanResult planResult;  
45 -  
46 -function Map xlidParams(String xlid) {  
47 - Map param = new HashMap();  
48 - param.put("xl.id_eq", Integer.valueOf(xlid));  
49 - return param;  
50 -}  
51 -  
52 -function List ecList(EmployeeConfigInfoRepository repo, String ecids) {  
53 - List<String> ids = Arrays.asList(ecids.split("-"));  
54 - List rst = new ArrayList();  
55 - for (int i = 0; i < ids.size(); i++) {  
56 - rst.add(repo.findOne(Long.parseLong(ids.get(i))));  
57 - }  
58 - return rst;  
59 -}  
60 -  
61 -function LocalTime fcsjTime(String fcsj) {  
62 - if ("NULL".equals(fcsj)) {  
63 - return null;  
64 - }  
65 - return LocalTime.parse(fcsj, DateTimeFormat.forPattern("HH:mm"));  
66 -}  
67 -  
68 -function String ttInfoId_sd(Map map, DateTime sd) {  
69 - TTInfoResult_output ttInfoResult_output = (TTInfoResult_output) map.get(sd);  
70 - return ttInfoResult_output.getTtInfoId();  
71 -}  
72 -  
73 -function Map gsMap(List gses) {  
74 - Map gsMap = new HashMap();  
75 - for (int i = 0; i < gses.size(); i++) {  
76 - Business gs = (Business) gses.get(i);  
77 - if (StringUtils.isNotEmpty(gs.getBusinessCode())) {  
78 - if ("88".equals(gs.getUpCode())) { // 浦东公交  
79 - gsMap.put(gs.getBusinessCode(), gs);  
80 - }  
81 - if (gs.getBusinessCode().equals(gs.getUpCode())) { // 闵行,青浦  
82 - gsMap.put(gs.getBusinessCode(), gs);  
83 - }  
84 - }  
85 - }  
86 - return gsMap;  
87 -}  
88 -  
89 -function Map fgsMap(List gses) {  
90 - // 这里简单将 businessCode和upCode合并  
91 - Map fgsMap = new HashMap();  
92 - for (int i = 0; i < gses.size(); i++) {  
93 - Business gs = (Business) gses.get(i);  
94 - if (StringUtils.isNotEmpty(gs.getBusinessCode()) && StringUtils.isNotEmpty(gs.getUpCode())) {  
95 - fgsMap.put(gs.getUpCode() + "_" + gs.getBusinessCode(), gs);  
96 - }  
97 - }  
98 - return fgsMap;  
99 -}  
100 -  
101 -/*  
102 - 规则说明:  
103 - 根据循环规则输出,时刻表选择规则输出,组合计算排班明细  
104 -*/  
105 -  
106 -//-------------------- 第一阶段、计算迭代数据 -----------------//  
107 -declare Loop_result  
108 - xlId: String // 线路id  
109 -  
110 - ruleLoop: List // 每天分配的规则 List<ScheduleResult_output>  
111 -  
112 - ttInfoMapLoop_temp: Map // 每天分配的时刻表 Map<DataTime, Collection<TTInfoResult_output>>  
113 - ttInfoMapLoop: Map // 每天分配的时刻表 Map<DataTime, TTInfoResult_output>  
114 - ttInfoMap: Map // 总共用到的时刻表 Map<id, TTInfoResult_output>  
115 -end  
116 -  
117 -rule "calcu_step1_Loop_result"  
118 - salience 1000  
119 - when  
120 - $param: PlanCalcuParam_input($xlId: xlId)  
121 - then  
122 - Loop_result loop_result = new Loop_result();  
123 - loop_result.setXlId($xlId);  
124 - loop_result.setRuleLoop($param.getScheduleResults_output().getResults());  
125 -  
126 - loop_result.setTtInfoMapLoop(new HashMap());  
127 - loop_result.setTtInfoMap(new HashMap());  
128 -  
129 - com.google.common.collect.Multimap ttInfoMap_temp =  
130 - (com.google.common.collect.Multimap)  
131 - $param.getTtInfoResults_output().getResults().get(  
132 - String.valueOf($xlId));  
133 -  
134 - loop_result.setTtInfoMapLoop_temp(ttInfoMap_temp.asMap());  
135 -  
136 - insert(loop_result);  
137 -  
138 -// log.info("calcu_step1_Loop_result");  
139 -end  
140 -  
141 -rule "calcu_step2_loop_result"  
142 - salience 1000  
143 - no-loop  
144 - when  
145 - $param: PlanCalcuParam_input($xlId: xlId)  
146 - $lr: Loop_result(xlId == $xlId)  
147 - $sd: DateTime() from $lr.ttInfoMapLoop_temp.keySet()  
148 - then  
149 - // 当天时刻表只取第一张 TODO:  
150 - Collection col = (Collection) $lr.getTtInfoMapLoop_temp().get($sd);  
151 - Iterator iter = col.iterator();  
152 - TTInfoResult_output ttInfo_result = (TTInfoResult_output) iter.next();  
153 - $lr.getTtInfoMapLoop().put($sd, ttInfo_result);  
154 -  
155 - // 总共使用的时刻表  
156 - $lr.getTtInfoMap().put(ttInfo_result.getTtInfoId(), ttInfo_result);  
157 -  
158 - update($lr);  
159 -  
160 -// log.info("calcu_step2_Loop_result");  
161 -end  
162 -  
163 -//-------------------- 第二阶段、将时刻表班次,车辆配置,人员配置信息载入 -----------------//  
164 -  
165 -//--------------- 车辆配置信息载入 -------------//  
166 -declare CarConfig_Wraps  
167 - xlId: String // 线路Id  
168 - ccMap: Map // 车辆配置Map Map<id, CarConfigInfo>  
169 -end  
170 -  
171 -rule "calcu_CarConfig_Wraps"  
172 - salience 800  
173 - when  
174 - $lr: Loop_result($xlId: xlId)  
175 - then  
176 - List carConfigInfos = carConfigInfoRepository.findByXlId(Integer.parseInt($xlId));  
177 -  
178 - CarConfig_Wraps carConfig_wraps = new CarConfig_Wraps();  
179 - carConfig_wraps.setXlId($xlId);  
180 - carConfig_wraps.setCcMap(new HashMap());  
181 -  
182 - for (int i = 0; i < carConfigInfos.size(); i++) {  
183 - CarConfigInfo carConfigInfo = (CarConfigInfo) carConfigInfos.get(i);  
184 - carConfig_wraps.getCcMap().put(carConfigInfo.getId().toString(), carConfigInfo);  
185 - }  
186 -  
187 - insert(carConfig_wraps);  
188 -  
189 - log.info("calcu_CarConfig_Wrap");  
190 -end  
191 -  
192 -//--------------- 人员配置信息载入 --------------//  
193 -declare EmployeeConfig_Wraps  
194 - xlId: String // 线路Id  
195 - ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>  
196 -end  
197 -  
198 -rule "calcu_EmployeeConfig_Wraps"  
199 - salience 800  
200 - when  
201 - $lr: Loop_result($xlId: xlId)  
202 - then  
203 - List employeeConfigInfos = employeeConfigInfoRepository.findByXlId(Integer.parseInt($xlId));  
204 -  
205 - EmployeeConfig_Wraps employeeConfig_wraps = new EmployeeConfig_Wraps();  
206 - employeeConfig_wraps.setXlId($xlId);  
207 - employeeConfig_wraps.setEcMap(new HashMap());  
208 -  
209 - for (int i = 0; i < employeeConfigInfos.size(); i++) {  
210 - EmployeeConfigInfo employeeConfigInfo = (EmployeeConfigInfo) employeeConfigInfos.get(i);  
211 - employeeConfig_wraps.getEcMap().put(employeeConfigInfo.getId().toString(), employeeConfigInfo);  
212 - }  
213 -  
214 - insert(employeeConfig_wraps);  
215 -  
216 - log.info("calcu_EmployeeConfig_Wrap");  
217 -end  
218 -  
219 -//----------------- 时刻表班次信息载入 -----------------//  
220 -declare TTInfo_gid_stat  
221 - xlId: String // 线路id(cast字符串-方便比较)  
222 - ttInfoId: String // 时刻表id(cast字符串-方便比较)  
223 - gid: String // 路牌id(cast字符串-方便比较)  
224 -  
225 - maxFcno: Integer // 最大发车顺序号  
226 -  
227 - fbTime: LocalTime // 分班时间  
228 - fbfcno: Integer // 分班发车顺序号  
229 -end  
230 -  
231 -rule "calcu_TTInfo_gid_stat"  
232 - salience 800  
233 - when  
234 - $lr: Loop_result($xlId: xlId)  
235 - $ttInfoId: String() from $lr.getTtInfoMap().keySet()  
236 - $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd))  
237 - $gid: String() from $gids  
238 - $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbtime($ttd))  
239 - $fbfcno: Integer() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbfcno($ttd))  
240 - $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno()))  
241 - then  
242 - TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat();  
243 - ttInfo_gid_stat.setXlId($xlId);  
244 - ttInfo_gid_stat.setTtInfoId($ttInfoId);  
245 - ttInfo_gid_stat.setGid($gid);  
246 -  
247 - ttInfo_gid_stat.setMaxFcno($maxfcno.intValue());  
248 - ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str));  
249 - ttInfo_gid_stat.setFbfcno($fbfcno);  
250 -  
251 - insert(ttInfo_gid_stat);  
252 -  
253 -// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={},fbfcno={}",  
254 -// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime(), ttInfo_gid_stat.getFbfcno());  
255 -  
256 -end  
257 -  
258 -declare TTInfoDetail_Wrap  
259 - isFirstBc: Boolean = false // 是否是当前路牌的第一个班次  
260 - isLastBc: Boolean = false // 是否是当前路牌的最后一个班次  
261 - isFb: Boolean = false // 是否分班  
262 -  
263 - self: TTInfoDetail // 原始数据  
264 -end  
265 -  
266 -declare TTInfoDetail_Wraps  
267 - xlId: String // 线路id(cast字符串-方便比较)  
268 - ttInfoId: String // 时刻表id(cast字符串-方便比较)  
269 -  
270 - detailsMap: Map // 明细Map,Map<路牌id, List<TTInfoDetail_Wrap>>  
271 -end  
272 -  
273 -rule "calcu_TTInfoDetail_Wraps"  
274 - salience 700  
275 - when  
276 - $lr: Loop_result($xlId: xlId)  
277 - $ttInfoId: String() from $lr.getTtInfoMap().keySet()  
278 - $ttInfoStatList: List(size > 0) from collect (TTInfo_gid_stat(ttInfoId == $ttInfoId))  
279 - then  
280 - TTInfoDetail_Wraps ttInfoDetail_wraps = new TTInfoDetail_Wraps();  
281 - ttInfoDetail_wraps.setXlId($xlId);  
282 - ttInfoDetail_wraps.setTtInfoId($ttInfoId);  
283 - ttInfoDetail_wraps.setDetailsMap(new HashMap());  
284 -  
285 - // 将list的形式变成 Map<路牌id, TTInfo_gid_stat>  
286 - Map statMap = new HashMap();  
287 - for (int i = 0; i < $ttInfoStatList.size(); i++) {  
288 - TTInfo_gid_stat ttInfo_gid_stat = (TTInfo_gid_stat) $ttInfoStatList.get(i);  
289 - statMap.put(ttInfo_gid_stat.getGid(), ttInfo_gid_stat);  
290 - }  
291 -  
292 - // 迭代ttinfodetail,拼装 TTInfoDetail_Wraps  
293 - List detaillist = tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId));  
294 - for (int j = 0; j < detaillist.size(); j++) {  
295 - TTInfoDetail ttInfoDetail = (TTInfoDetail) detaillist.get(j);  
296 - String gid = String.valueOf(ttInfoDetail.getLp().getId());  
297 -  
298 - if (ttInfoDetail_wraps.getDetailsMap().get(gid) == null) {  
299 - ttInfoDetail_wraps.getDetailsMap().put(gid, new ArrayList());  
300 - }  
301 -  
302 - // 获取stat  
303 - TTInfo_gid_stat ttInfo_gid_stat = (TTInfo_gid_stat) statMap.get(gid);  
304 -  
305 - TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap();  
306 - ttInfoDetail_wrap.setIsFirstBc(1 == ttInfoDetail.getFcno());  
307 - ttInfoDetail_wrap.setIsLastBc(ttInfo_gid_stat.getMaxFcno() == ttInfoDetail.getFcno());  
308 -  
309 - LocalTime fcsj = fcsjTime(ttInfoDetail.getFcsj());  
310 - LocalTime fbsj = ttInfo_gid_stat.getFbTime();  
311 - Integer fbfcno = ttInfo_gid_stat.getFbfcno();  
312 - // 不用时间判定,因为有的路牌,后面的班次都是凌晨的,时间反而比分班时间早,不合理,所以使用发车顺序号做第二次比较  
313 -// ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));  
314 - ttInfoDetail_wrap.setIsFb(fbsj == null ? false : ttInfoDetail.getFcno() >= fbfcno);  
315 -  
316 - ttInfoDetail_wrap.setSelf(ttInfoDetail);  
317 -  
318 - ((List) ttInfoDetail_wraps.getDetailsMap().get(gid)).add(ttInfoDetail_wrap);  
319 -  
320 - }  
321 -  
322 -  
323 - insert(ttInfoDetail_wraps);  
324 -  
325 - log.info("xlid={}, ttinfoid={}, lpstatCount={}, detailLpCount={}",  
326 - $xlId, $ttInfoId, $ttInfoStatList.size(), ttInfoDetail_wraps.getDetailsMap().keySet().size());  
327 -  
328 -  
329 -end  
330 -  
331 -declare TTInfoDetail_Wraps_map  
332 - xlId: String // 线路id(cast字符串-方便比较)  
333 -  
334 - wrapsMap: Map // 明细Map,Map<时刻表Id, TTInfoDetail_Wraps>  
335 -end  
336 -  
337 -rule "calcu_TTInfoDetail_Wraps_toMap"  
338 - salience 600  
339 - when  
340 - $lr: Loop_result($xlId: xlId)  
341 - $wrapsList: List(size > 0) from collect (TTInfoDetail_Wraps(xlId == $xlId))  
342 - then  
343 - // 转换成Map  
344 - TTInfoDetail_Wraps_map all = new TTInfoDetail_Wraps_map();  
345 - all.setXlId($xlId);  
346 - all.setWrapsMap(new HashMap());  
347 -  
348 - for (int i = 0; i < $wrapsList.size(); i++) {  
349 - TTInfoDetail_Wraps ttInfoDetail_wraps = (TTInfoDetail_Wraps) $wrapsList.get(i);  
350 - all.getWrapsMap().put(ttInfoDetail_wraps.getTtInfoId(), ttInfoDetail_wraps);  
351 - }  
352 -  
353 - insert(all);  
354 -end  
355 -  
356 -  
357 -  
358 -  
359 -//-------------------- 第三阶段、合并计算SchedulePlanInfo -----------------//  
360 -  
361 -  
362 -rule "Calcu_SchedulePlanInfo"  
363 - salience 500  
364 - when  
365 - $param: PlanCalcuParam_input($xlId: xlId)  
366 - $lr: Loop_result(xlId == $xlId)  
367 - $ccs: CarConfig_Wraps(xlId == $xlId)  
368 - $ecs: EmployeeConfig_Wraps(xlId == $xlId)  
369 - $tts: TTInfoDetail_Wraps_map(xlId == $xlId)  
370 - then  
371 - // 线路  
372 - Line xl = lineRepository.findOne(Integer.parseInt($xlId));  
373 -  
374 - // 查找公司  
375 - List gses = (List) businessRepository.findAll();  
376 - // 构造公司代码对应map  
377 - Map gsMap = gsMap(gses);  
378 - // 构造分公司对应的map  
379 - Map fgsMap = fgsMap(gses);  
380 -  
381 - for (int i = 0; i < $lr.getRuleLoop().size(); i++) {  
382 - ScheduleResult_output sro = (ScheduleResult_output) $lr.getRuleLoop().get(i);  
383 -  
384 - // 日期  
385 - DateTime sd = sro.getSd();  
386 - // 路牌  
387 - String gid = sro.getGuideboardId();  
388 - // 车辆配置  
389 - CarConfigInfo carConfigInfo = sro.getsType() == ScheduleRule_Type.NORMAL ?  
390 - (CarConfigInfo) $ccs.getCcMap().get(sro.getCarConfigId()) : null;  
391 - // 人员配置  
392 - List eclist = sro.getsType() == ScheduleRule_Type.NORMAL ?  
393 - ecList(employeeConfigInfoRepository, sro.getEmployeeConfigId()) : null;  
394 -  
395 - // 时刻表id  
396 - String ttInfoId = ttInfoId_sd($lr.getTtInfoMapLoop(), sd);  
397 - TTInfoDetail_Wraps ttInfoDetail_wraps = (TTInfoDetail_Wraps) $tts.getWrapsMap().get(ttInfoId);  
398 - if (ttInfoDetail_wraps == null) {  
399 - // 时刻表为空,直接跳过  
400 - // 如1118路,周末不开,此是时刻表指定一个空表  
401 - // TODO:这个以后要改的,选时刻表的规则要修正,没有默认的时刻表  
402 - continue;  
403 - }  
404 -  
405 - List detaillist = (List) ttInfoDetail_wraps.getDetailsMap().get(gid);  
406 - if (detaillist == null) {  
407 - // 这里翻到的路牌时刻表里可能没有,  
408 - // 因为没有考虑翻班格式(就是做几休几)  
409 - // 所有翻班格式全由时刻表决定,即时刻表有的路牌就做,没有不做  
410 - continue;  
411 - }  
412 -  
413 - for (int j = 0; j < detaillist.size(); j++) {  
414 - TTInfoDetail_Wrap wrap = (TTInfoDetail_Wrap) detaillist.get(j);  
415 -  
416 - SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(  
417 - xl,  
418 - sro,  
419 - wrap.getSelf(),  
420 - wrap.getIsFb(),  
421 - carConfigInfo,  
422 - eclist,  
423 - $param.getSchedulePlan(),  
424 - wrap.getIsFirstBc(),  
425 - wrap.getIsLastBc(),  
426 - sro.getsType()  
427 - );  
428 -  
429 - // 获取公司,分公司信息  
430 - String gsbm = xl.getCompany();  
431 - String fgsbm = xl.getBrancheCompany();  
432 - Business gs = null;  
433 - Business fgs = null;  
434 -  
435 - if (StringUtils.isNotEmpty(gsbm)) {  
436 - gs = (Business) gsMap.get(gsbm);  
437 - }  
438 - if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) {  
439 - fgs = (Business) fgsMap.get(gsbm + "_" + fgsbm);  
440 - }  
441 -  
442 - if (gs != null) {  
443 - schedulePlanInfo.setGsBm(gs.getBusinessCode());  
444 - schedulePlanInfo.setGsName(gs.getBusinessName());  
445 - }  
446 - if (fgs != null) {  
447 - schedulePlanInfo.setFgsBm(fgs.getBusinessCode());  
448 - schedulePlanInfo.setFgsName(fgs.getBusinessName());  
449 - }  
450 -  
451 - // 操作人,操作时间  
452 - schedulePlanInfo.setCreateBy($param.getSchedulePlan().getCreateBy());  
453 - schedulePlanInfo.setCreateDate($param.getSchedulePlan().getCreateDate());  
454 - schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy());  
455 - schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate());  
456 -  
457 - // result 输出  
458 - planResult.getSchedulePlanInfos().add(schedulePlanInfo);  
459 -  
460 - }  
461 -  
462 - }  
463 -  
464 - log.info("xlid={} plan ok!", $xlId);  
465 -  
466 -end  
467 -  
468 -  
469 -  
470 -  
471 -  
472 -  
473 -  
474 -  
475 -  
476 -  
477 -  
478 -  
479 -  
480 - 1 +package com.bsth.service.schedule.impl.plan.kBase1.core.plan;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +
  6 +import com.bsth.service.schedule.impl.plan.kBase1.core.plan.PlanCalcuParam_input;
  7 +import com.bsth.service.schedule.impl.plan.kBase1.core.plan.PlanResult;
  8 +
  9 +import com.bsth.repository.schedule.TTInfoDetailRepository;
  10 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  11 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
  12 +import com.bsth.repository.LineRepository;
  13 +import com.bsth.repository.BusinessRepository;
  14 +
  15 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResult_output;
  16 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;
  17 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResult_output;
  18 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResults_output;
  19 +import com.bsth.entity.Line;
  20 +import com.bsth.entity.Business;
  21 +
  22 +import com.bsth.entity.schedule.CarConfigInfo;
  23 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  24 +import com.bsth.entity.schedule.TTInfo;
  25 +import com.bsth.entity.schedule.TTInfoDetail;
  26 +import com.bsth.entity.schedule.SchedulePlanInfo;
  27 +
  28 +import org.slf4j.Logger
  29 +import org.joda.time.format.DateTimeFormat
  30 +import org.apache.commons.lang3.StringUtils
  31 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;
  32 +
  33 +
  34 +// 全局日志类(一般使用调用此规则的service类)
  35 +global Logger log;
  36 +
  37 +global TTInfoDetailRepository tTInfoDetailRepository;
  38 +global CarConfigInfoRepository carConfigInfoRepository;
  39 +global EmployeeConfigInfoRepository employeeConfigInfoRepository;
  40 +global LineRepository lineRepository;
  41 +global BusinessRepository businessRepository;
  42 +
  43 +// 输出
  44 +global PlanResult planResult;
  45 +
  46 +function Map xlidParams(String xlid) {
  47 + Map param = new HashMap();
  48 + param.put("xl.id_eq", Integer.valueOf(xlid));
  49 + return param;
  50 +}
  51 +
  52 +function List ecList(EmployeeConfigInfoRepository repo, String ecids) {
  53 + List<String> ids = Arrays.asList(ecids.split("-"));
  54 + List rst = new ArrayList();
  55 + for (int i = 0; i < ids.size(); i++) {
  56 + rst.add(repo.findOne(Long.parseLong(ids.get(i))));
  57 + }
  58 + return rst;
  59 +}
  60 +
  61 +function LocalTime fcsjTime(String fcsj) {
  62 + if ("NULL".equals(fcsj)) {
  63 + return null;
  64 + }
  65 + return LocalTime.parse(fcsj, DateTimeFormat.forPattern("HH:mm"));
  66 +}
  67 +
  68 +function String ttInfoId_sd(Map map, DateTime sd) {
  69 + TTInfoResult_output ttInfoResult_output = (TTInfoResult_output) map.get(sd);
  70 + return ttInfoResult_output.getTtInfoId();
  71 +}
  72 +
  73 +function Map gsMap(List gses) {
  74 + Map gsMap = new HashMap();
  75 + for (int i = 0; i < gses.size(); i++) {
  76 + Business gs = (Business) gses.get(i);
  77 + if (StringUtils.isNotEmpty(gs.getBusinessCode())) {
  78 + if ("88".equals(gs.getUpCode())) { // 浦东公交
  79 + gsMap.put(gs.getBusinessCode(), gs);
  80 + }
  81 + if (gs.getBusinessCode().equals(gs.getUpCode())) { // 闵行,青浦
  82 + gsMap.put(gs.getBusinessCode(), gs);
  83 + }
  84 + }
  85 + }
  86 + return gsMap;
  87 +}
  88 +
  89 +function Map fgsMap(List gses) {
  90 + // 这里简单将 businessCode和upCode合并
  91 + Map fgsMap = new HashMap();
  92 + for (int i = 0; i < gses.size(); i++) {
  93 + Business gs = (Business) gses.get(i);
  94 + if (StringUtils.isNotEmpty(gs.getBusinessCode()) && StringUtils.isNotEmpty(gs.getUpCode())) {
  95 + fgsMap.put(gs.getUpCode() + "_" + gs.getBusinessCode(), gs);
  96 + }
  97 + }
  98 + return fgsMap;
  99 +}
  100 +
  101 +/*
  102 + 规则说明:
  103 + 根据循环规则输出,时刻表选择规则输出,组合计算排班明细
  104 +*/
  105 +
  106 +//-------------------- 第一阶段、计算迭代数据 -----------------//
  107 +declare Loop_result
  108 + xlId: String // 线路id
  109 +
  110 + ruleLoop: List // 每天分配的规则 List<ScheduleResult_output>
  111 +
  112 + ttInfoMapLoop_temp: Map // 每天分配的时刻表 Map<DataTime, Collection<TTInfoResult_output>>
  113 + ttInfoMapLoop: Map // 每天分配的时刻表 Map<DataTime, TTInfoResult_output>
  114 + ttInfoMap: Map // 总共用到的时刻表 Map<id, TTInfoResult_output>
  115 +end
  116 +
  117 +rule "calcu_step1_Loop_result"
  118 + salience 1000
  119 + when
  120 + $param: PlanCalcuParam_input($xlId: xlId)
  121 + then
  122 + Loop_result loop_result = new Loop_result();
  123 + loop_result.setXlId($xlId);
  124 + loop_result.setRuleLoop($param.getScheduleResults_output().getResults());
  125 +
  126 + loop_result.setTtInfoMapLoop(new HashMap());
  127 + loop_result.setTtInfoMap(new HashMap());
  128 +
  129 + com.google.common.collect.Multimap ttInfoMap_temp =
  130 + (com.google.common.collect.Multimap)
  131 + $param.getTtInfoResults_output().getResults().get(
  132 + String.valueOf($xlId));
  133 +
  134 + loop_result.setTtInfoMapLoop_temp(ttInfoMap_temp.asMap());
  135 +
  136 + insert(loop_result);
  137 +
  138 +// log.info("calcu_step1_Loop_result");
  139 +end
  140 +
  141 +rule "calcu_step2_loop_result"
  142 + salience 1000
  143 + no-loop
  144 + when
  145 + $param: PlanCalcuParam_input($xlId: xlId)
  146 + $lr: Loop_result(xlId == $xlId)
  147 + $sd: DateTime() from $lr.ttInfoMapLoop_temp.keySet()
  148 + then
  149 + // 当天时刻表只取第一张 TODO:
  150 + Collection col = (Collection) $lr.getTtInfoMapLoop_temp().get($sd);
  151 + Iterator iter = col.iterator();
  152 + TTInfoResult_output ttInfo_result = (TTInfoResult_output) iter.next();
  153 + $lr.getTtInfoMapLoop().put($sd, ttInfo_result);
  154 +
  155 + // 总共使用的时刻表
  156 + $lr.getTtInfoMap().put(ttInfo_result.getTtInfoId(), ttInfo_result);
  157 +
  158 + update($lr);
  159 +
  160 +// log.info("calcu_step2_Loop_result");
  161 +end
  162 +
  163 +//-------------------- 第二阶段、将时刻表班次,车辆配置,人员配置信息载入 -----------------//
  164 +
  165 +//--------------- 车辆配置信息载入 -------------//
  166 +declare CarConfig_Wraps
  167 + xlId: String // 线路Id
  168 + ccMap: Map // 车辆配置Map Map<id, CarConfigInfo>
  169 +end
  170 +
  171 +rule "calcu_CarConfig_Wraps"
  172 + salience 800
  173 + when
  174 + $lr: Loop_result($xlId: xlId)
  175 + then
  176 + List carConfigInfos = carConfigInfoRepository.findByXlId(Integer.parseInt($xlId));
  177 +
  178 + CarConfig_Wraps carConfig_wraps = new CarConfig_Wraps();
  179 + carConfig_wraps.setXlId($xlId);
  180 + carConfig_wraps.setCcMap(new HashMap());
  181 +
  182 + for (int i = 0; i < carConfigInfos.size(); i++) {
  183 + CarConfigInfo carConfigInfo = (CarConfigInfo) carConfigInfos.get(i);
  184 + carConfig_wraps.getCcMap().put(carConfigInfo.getId().toString(), carConfigInfo);
  185 + }
  186 +
  187 + insert(carConfig_wraps);
  188 +
  189 + log.info("calcu_CarConfig_Wrap");
  190 +end
  191 +
  192 +//--------------- 人员配置信息载入 --------------//
  193 +declare EmployeeConfig_Wraps
  194 + xlId: String // 线路Id
  195 + ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>
  196 +end
  197 +
  198 +rule "calcu_EmployeeConfig_Wraps"
  199 + salience 800
  200 + when
  201 + $lr: Loop_result($xlId: xlId)
  202 + then
  203 + List employeeConfigInfos = employeeConfigInfoRepository.findByXlId(Integer.parseInt($xlId));
  204 +
  205 + EmployeeConfig_Wraps employeeConfig_wraps = new EmployeeConfig_Wraps();
  206 + employeeConfig_wraps.setXlId($xlId);
  207 + employeeConfig_wraps.setEcMap(new HashMap());
  208 +
  209 + for (int i = 0; i < employeeConfigInfos.size(); i++) {
  210 + EmployeeConfigInfo employeeConfigInfo = (EmployeeConfigInfo) employeeConfigInfos.get(i);
  211 + employeeConfig_wraps.getEcMap().put(employeeConfigInfo.getId().toString(), employeeConfigInfo);
  212 + }
  213 +
  214 + insert(employeeConfig_wraps);
  215 +
  216 + log.info("calcu_EmployeeConfig_Wrap");
  217 +end
  218 +
  219 +//----------------- 时刻表班次信息载入 -----------------//
  220 +declare TTInfo_gid_stat
  221 + xlId: String // 线路id(cast字符串-方便比较)
  222 + ttInfoId: String // 时刻表id(cast字符串-方便比较)
  223 + gid: String // 路牌id(cast字符串-方便比较)
  224 +
  225 + maxFcno: Integer // 最大发车顺序号
  226 +
  227 + fbTime: LocalTime // 分班时间
  228 + fbfcno: Integer // 分班发车顺序号
  229 +end
  230 +
  231 +rule "calcu_TTInfo_gid_stat"
  232 + salience 800
  233 + when
  234 + $lr: Loop_result($xlId: xlId)
  235 + $ttInfoId: String() from $lr.getTtInfoMap().keySet()
  236 + $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd))
  237 + $gid: String() from $gids
  238 + $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbtime($ttd))
  239 + $fbfcno: Integer() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbfcno($ttd))
  240 + $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno()))
  241 + then
  242 + TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat();
  243 + ttInfo_gid_stat.setXlId($xlId);
  244 + ttInfo_gid_stat.setTtInfoId($ttInfoId);
  245 + ttInfo_gid_stat.setGid($gid);
  246 +
  247 + ttInfo_gid_stat.setMaxFcno($maxfcno.intValue());
  248 + ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str));
  249 + ttInfo_gid_stat.setFbfcno($fbfcno);
  250 +
  251 + insert(ttInfo_gid_stat);
  252 +
  253 +// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={},fbfcno={}",
  254 +// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime(), ttInfo_gid_stat.getFbfcno());
  255 +
  256 +end
  257 +
  258 +declare TTInfoDetail_Wrap
  259 + isFirstBc: Boolean = false // 是否是当前路牌的第一个班次
  260 + isLastBc: Boolean = false // 是否是当前路牌的最后一个班次
  261 + isFb: Boolean = false // 是否分班
  262 +
  263 + self: TTInfoDetail // 原始数据
  264 +end
  265 +
  266 +declare TTInfoDetail_Wraps
  267 + xlId: String // 线路id(cast字符串-方便比较)
  268 + ttInfoId: String // 时刻表id(cast字符串-方便比较)
  269 +
  270 + detailsMap: Map // 明细Map,Map<路牌id, List<TTInfoDetail_Wrap>>
  271 +end
  272 +
  273 +rule "calcu_TTInfoDetail_Wraps"
  274 + salience 700
  275 + when
  276 + $lr: Loop_result($xlId: xlId)
  277 + $ttInfoId: String() from $lr.getTtInfoMap().keySet()
  278 + $ttInfoStatList: List(size > 0) from collect (TTInfo_gid_stat(ttInfoId == $ttInfoId))
  279 + then
  280 + TTInfoDetail_Wraps ttInfoDetail_wraps = new TTInfoDetail_Wraps();
  281 + ttInfoDetail_wraps.setXlId($xlId);
  282 + ttInfoDetail_wraps.setTtInfoId($ttInfoId);
  283 + ttInfoDetail_wraps.setDetailsMap(new HashMap());
  284 +
  285 + // 将list的形式变成 Map<路牌id, TTInfo_gid_stat>
  286 + Map statMap = new HashMap();
  287 + for (int i = 0; i < $ttInfoStatList.size(); i++) {
  288 + TTInfo_gid_stat ttInfo_gid_stat = (TTInfo_gid_stat) $ttInfoStatList.get(i);
  289 + statMap.put(ttInfo_gid_stat.getGid(), ttInfo_gid_stat);
  290 + }
  291 +
  292 + // 迭代ttinfodetail,拼装 TTInfoDetail_Wraps
  293 + List detaillist = tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId));
  294 + for (int j = 0; j < detaillist.size(); j++) {
  295 + TTInfoDetail ttInfoDetail = (TTInfoDetail) detaillist.get(j);
  296 + String gid = String.valueOf(ttInfoDetail.getLp().getId());
  297 +
  298 + if (ttInfoDetail_wraps.getDetailsMap().get(gid) == null) {
  299 + ttInfoDetail_wraps.getDetailsMap().put(gid, new ArrayList());
  300 + }
  301 +
  302 + // 获取stat
  303 + TTInfo_gid_stat ttInfo_gid_stat = (TTInfo_gid_stat) statMap.get(gid);
  304 +
  305 + TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap();
  306 + ttInfoDetail_wrap.setIsFirstBc(1 == ttInfoDetail.getFcno());
  307 + ttInfoDetail_wrap.setIsLastBc(ttInfo_gid_stat.getMaxFcno() == ttInfoDetail.getFcno());
  308 +
  309 + LocalTime fcsj = fcsjTime(ttInfoDetail.getFcsj());
  310 + LocalTime fbsj = ttInfo_gid_stat.getFbTime();
  311 + Integer fbfcno = ttInfo_gid_stat.getFbfcno();
  312 + // 不用时间判定,因为有的路牌,后面的班次都是凌晨的,时间反而比分班时间早,不合理,所以使用发车顺序号做第二次比较
  313 +// ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));
  314 + ttInfoDetail_wrap.setIsFb(fbsj == null ? false : ttInfoDetail.getFcno() >= fbfcno);
  315 +
  316 + ttInfoDetail_wrap.setSelf(ttInfoDetail);
  317 +
  318 + ((List) ttInfoDetail_wraps.getDetailsMap().get(gid)).add(ttInfoDetail_wrap);
  319 +
  320 + }
  321 +
  322 +
  323 + insert(ttInfoDetail_wraps);
  324 +
  325 + log.info("xlid={}, ttinfoid={}, lpstatCount={}, detailLpCount={}",
  326 + $xlId, $ttInfoId, $ttInfoStatList.size(), ttInfoDetail_wraps.getDetailsMap().keySet().size());
  327 +
  328 +
  329 +end
  330 +
  331 +declare TTInfoDetail_Wraps_map
  332 + xlId: String // 线路id(cast字符串-方便比较)
  333 +
  334 + wrapsMap: Map // 明细Map,Map<时刻表Id, TTInfoDetail_Wraps>
  335 +end
  336 +
  337 +rule "calcu_TTInfoDetail_Wraps_toMap"
  338 + salience 600
  339 + when
  340 + $lr: Loop_result($xlId: xlId)
  341 + $wrapsList: List(size > 0) from collect (TTInfoDetail_Wraps(xlId == $xlId))
  342 + then
  343 + // 转换成Map
  344 + TTInfoDetail_Wraps_map all = new TTInfoDetail_Wraps_map();
  345 + all.setXlId($xlId);
  346 + all.setWrapsMap(new HashMap());
  347 +
  348 + for (int i = 0; i < $wrapsList.size(); i++) {
  349 + TTInfoDetail_Wraps ttInfoDetail_wraps = (TTInfoDetail_Wraps) $wrapsList.get(i);
  350 + all.getWrapsMap().put(ttInfoDetail_wraps.getTtInfoId(), ttInfoDetail_wraps);
  351 + }
  352 +
  353 + insert(all);
  354 +end
  355 +
  356 +
  357 +
  358 +
  359 +//-------------------- 第三阶段、合并计算SchedulePlanInfo -----------------//
  360 +
  361 +
  362 +rule "Calcu_SchedulePlanInfo"
  363 + salience 500
  364 + when
  365 + $param: PlanCalcuParam_input($xlId: xlId)
  366 + $lr: Loop_result(xlId == $xlId)
  367 + $ccs: CarConfig_Wraps(xlId == $xlId)
  368 + $ecs: EmployeeConfig_Wraps(xlId == $xlId)
  369 + $tts: TTInfoDetail_Wraps_map(xlId == $xlId)
  370 + then
  371 + // 线路
  372 + Line xl = lineRepository.findOne(Integer.parseInt($xlId));
  373 +
  374 + // 查找公司
  375 + List gses = (List) businessRepository.findAll();
  376 + // 构造公司代码对应map
  377 + Map gsMap = gsMap(gses);
  378 + // 构造分公司对应的map
  379 + Map fgsMap = fgsMap(gses);
  380 +
  381 + for (int i = 0; i < $lr.getRuleLoop().size(); i++) {
  382 + ScheduleResult_output sro = (ScheduleResult_output) $lr.getRuleLoop().get(i);
  383 +
  384 + // 日期
  385 + DateTime sd = sro.getSd();
  386 + // 路牌
  387 + String gid = sro.getGuideboardId();
  388 + // 车辆配置
  389 + CarConfigInfo carConfigInfo = sro.getsType() == ScheduleRule_Type.NORMAL ?
  390 + (CarConfigInfo) $ccs.getCcMap().get(sro.getCarConfigId()) : null;
  391 + // 人员配置
  392 + List eclist = sro.getsType() == ScheduleRule_Type.NORMAL ?
  393 + ecList(employeeConfigInfoRepository, sro.getEmployeeConfigId()) : null;
  394 +
  395 + // 时刻表id
  396 + String ttInfoId = ttInfoId_sd($lr.getTtInfoMapLoop(), sd);
  397 + TTInfoDetail_Wraps ttInfoDetail_wraps = (TTInfoDetail_Wraps) $tts.getWrapsMap().get(ttInfoId);
  398 + if (ttInfoDetail_wraps == null) {
  399 + // 时刻表为空,直接跳过
  400 + // 如1118路,周末不开,此是时刻表指定一个空表
  401 + // TODO:这个以后要改的,选时刻表的规则要修正,没有默认的时刻表
  402 + continue;
  403 + }
  404 +
  405 + List detaillist = (List) ttInfoDetail_wraps.getDetailsMap().get(gid);
  406 + if (detaillist == null) {
  407 + // 这里翻到的路牌时刻表里可能没有,
  408 + // 因为没有考虑翻班格式(就是做几休几)
  409 + // 所有翻班格式全由时刻表决定,即时刻表有的路牌就做,没有不做
  410 + continue;
  411 + }
  412 +
  413 + for (int j = 0; j < detaillist.size(); j++) {
  414 + TTInfoDetail_Wrap wrap = (TTInfoDetail_Wrap) detaillist.get(j);
  415 +
  416 + SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(
  417 + xl,
  418 + sro,
  419 + wrap.getSelf(),
  420 + wrap.getIsFb(),
  421 + carConfigInfo,
  422 + eclist,
  423 + $param.getSchedulePlan(),
  424 + wrap.getIsFirstBc(),
  425 + wrap.getIsLastBc(),
  426 + sro.getsType()
  427 + );
  428 +
  429 + // 获取公司,分公司信息
  430 + String gsbm = xl.getCompany();
  431 + String fgsbm = xl.getBrancheCompany();
  432 + Business gs = null;
  433 + Business fgs = null;
  434 +
  435 + if (StringUtils.isNotEmpty(gsbm)) {
  436 + gs = (Business) gsMap.get(gsbm);
  437 + }
  438 + if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) {
  439 + fgs = (Business) fgsMap.get(gsbm + "_" + fgsbm);
  440 + }
  441 +
  442 + if (gs != null) {
  443 + schedulePlanInfo.setGsBm(gs.getBusinessCode());
  444 + schedulePlanInfo.setGsName(gs.getBusinessName());
  445 + }
  446 + if (fgs != null) {
  447 + schedulePlanInfo.setFgsBm(fgs.getBusinessCode());
  448 + schedulePlanInfo.setFgsName(fgs.getBusinessName());
  449 + }
  450 +
  451 + // 操作人,操作时间
  452 + schedulePlanInfo.setCreateBy($param.getSchedulePlan().getCreateBy());
  453 + schedulePlanInfo.setCreateDate($param.getSchedulePlan().getCreateDate());
  454 + schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy());
  455 + schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate());
  456 +
  457 + // result 输出
  458 + planResult.getSchedulePlanInfos().add(schedulePlanInfo);
  459 +
  460 + }
  461 +
  462 + }
  463 +
  464 + log.info("xlid={} plan ok!", $xlId);
  465 +
  466 +end
  467 +
  468 +
  469 +
  470 +
  471 +
  472 +
  473 +
  474 +
  475 +
  476 +
  477 +
  478 +
  479 +
  480 +
src/main/resources/rules/kBase1_core_rerun.drl
1 -package com.bsth.service.schedule.impl.plan.kBase1.core.rerun;  
2 -  
3 -import org.joda.time.*;  
4 -import java.util.*;  
5 -  
6 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResult_output;  
7 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;  
8 -  
9 -import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;  
10 -import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_param;  
11 -  
12 -import com.bsth.repository.schedule.CarConfigInfoRepository;  
13 -import com.bsth.repository.schedule.EmployeeConfigInfoRepository;  
14 -  
15 -import org.slf4j.Logger;  
16 -import com.bsth.entity.schedule.CarConfigInfo;  
17 -import java.util.HashMap;  
18 -import com.bsth.entity.schedule.EmployeeConfigInfo;  
19 -import com.bsth.entity.schedule.SchedulePlanInfo;  
20 -  
21 -// 全局日志类(一般使用调用此规则的service类)  
22 -global Logger log;  
23 -  
24 -global CarConfigInfoRepository carConfigInfoRepository;  
25 -global EmployeeConfigInfoRepository employeeConfigInfoRepository;  
26 -  
27 -// 输出  
28 -  
29 -  
30 -/*  
31 - 规则说明:  
32 - 1、对应路牌规则:将对应路牌的车辆,人员替换指定的套跑班次已有的配置  
33 - 2、对应班车规则:直接使用指定的人员,车辆替换指定的套跑班次已有的配置  
34 -*/  
35 -  
36 -//-------------------- 第一阶段、计算对应路牌套跑的车辆配置,人员配置数据 -----------------//  
37 -  
38 -//--------------- 车辆配置信息载入 -------------//  
39 -declare Dylp_CarConfig_Wraps  
40 - xlId: String // 线路Id  
41 - ccMap: Map // 车辆配置Map Map<id, CarConfigInfo>  
42 -end  
43 -  
44 -rule "calcu_Dylp_CarConfig_Wraps"  
45 - salience 1000  
46 - when  
47 - $rp: RerunRule_param($xlId: mxlid)  
48 - $dylpxlid: String() from $rp.getXlIds_dylp()  
49 - then  
50 - List carConfigInfos = carConfigInfoRepository.findByXlId(Integer.parseInt($dylpxlid));  
51 -  
52 - Dylp_CarConfig_Wraps carConfig_wraps = new Dylp_CarConfig_Wraps();  
53 - carConfig_wraps.setXlId($dylpxlid);  
54 - carConfig_wraps.setCcMap(new HashMap());  
55 -  
56 - for (int i = 0; i < carConfigInfos.size(); i++) {  
57 - CarConfigInfo carConfigInfo = (CarConfigInfo) carConfigInfos.get(i);  
58 - carConfig_wraps.getCcMap().put(carConfigInfo.getId().toString(), carConfigInfo);  
59 - }  
60 -  
61 - insert(carConfig_wraps);  
62 -  
63 - log.info("calcu_Dylp_CarConfig_Wraps");  
64 -  
65 -end  
66 -  
67 -//--------------- 人员配置信息载入 --------------//  
68 -declare Dylp_EmployeeConfig_Wraps  
69 - xlId: String // 线路Id  
70 - ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>  
71 -end  
72 -  
73 -rule "calcu_Dylp_EmployeeConfig_Wraps"  
74 - salience 1000  
75 - when  
76 - $rp: RerunRule_param($xlId: mxlid)  
77 - $dylpxlid: String() from $rp.getXlIds_dylp()  
78 - then  
79 - List employeeConfigInfos = employeeConfigInfoRepository.findByXlId(Integer.parseInt($dylpxlid));  
80 -  
81 - Dylp_EmployeeConfig_Wraps employeeConfig_wraps = new Dylp_EmployeeConfig_Wraps();  
82 - employeeConfig_wraps.setXlId($dylpxlid);  
83 - employeeConfig_wraps.setEcMap(new HashMap());  
84 -  
85 - for (int i = 0; i < employeeConfigInfos.size(); i++) {  
86 - EmployeeConfigInfo employeeConfigInfo = (EmployeeConfigInfo) employeeConfigInfos.get(i);  
87 - employeeConfig_wraps.getEcMap().put(employeeConfigInfo.getId().toString(), employeeConfigInfo);  
88 - }  
89 -  
90 - insert(employeeConfig_wraps);  
91 -  
92 - log.info("calcu_Dylp_EmployeeConfig_Wraps");  
93 -  
94 -end  
95 -  
96 -//-------------------- 第二阶段、包装对应路牌的循环规则输出 -----------------//  
97 -  
98 -declare Dylp_ScheduleResult_output_wrap  
99 - xlId: String // 线路  
100 - sd: DateTime // 日期  
101 - lp: String // 路牌  
102 - cc: CarConfigInfo // 使用的车辆配置  
103 - ec: List // 使用的人员配置 List<EmployeeConfigInfo>  
104 -end  
105 -  
106 -rule "calcu_Dylp_ScheduleResult_output_wrap"  
107 - salience 900  
108 - when  
109 - $sro: ScheduleResults_output($xlId: xlid)  
110 - $sr: ScheduleResult_output() from $sro.getResults()  
111 - Dylp_CarConfig_Wraps(xlId == $xlId, $ccmap: ccMap)  
112 - Dylp_EmployeeConfig_Wraps(xlId == $xlId, $ecmap: ecMap)  
113 - then  
114 - Dylp_ScheduleResult_output_wrap wrap = new Dylp_ScheduleResult_output_wrap();  
115 - wrap.setXlId($xlId);  
116 - wrap.setSd($sr.getSd());  
117 - wrap.setLp($sr.getGuideboardId());  
118 - wrap.setCc((CarConfigInfo) $ccmap.get($sr.getCarConfigId()));  
119 -  
120 - List ecs = new ArrayList();  
121 - String[] ecids = $sr.getEmployeeConfigId().split("-"); // 分班的人  
122 - for (int i = 0; i < ecids.length; i++) {  
123 - ecs.add($ecmap.get(ecids[i]));  
124 - }  
125 - wrap.setEc(ecs);  
126 -  
127 -// log.info("xlid = {}", $xlId);  
128 -  
129 - insert(wrap);  
130 -end  
131 -  
132 -//-------------------- 第三阶段、套跑线路,替换班次的车辆,人员 --------------------//  
133 -rule "calcu_Dylp_rerun_update_dylp"  
134 - salience 800  
135 -// no-loop  
136 - when  
137 - $spi: SchedulePlanInfo($xlid: xl, $sd: scheduleDate, $lp: lp, $fcsj: fcsj, $ttinfo: ttInfo)  
138 - $ri: RerunRule_input(  
139 - type == "dylp",  
140 - xl == $xlid.toString(),  
141 - ttinfo == $ttinfo.toString(),  
142 - lp == $lp.toString(),  
143 - fcsj == $fcsj,  
144 - $sxl: s_xl, $slp: s_lp, $type: usetype, $hrtype: userhrtype  
145 - )  
146 - $dsro: Dylp_ScheduleResult_output_wrap(  
147 - xlId == $sxl,  
148 - lp == $slp,  
149 - sd.getMillis() == $sd.getTime()  
150 - )  
151 - then  
152 -// log.info("TODO:测试 {}", $fcsj);  
153 -  
154 - $spi.setRerunInfoDylp($dsro.getCc(), $dsro.getEc(), $type, $hrtype);  
155 -  
156 -end  
157 -  
158 -rule "calcu_Dylp_rerun_update_dybc"  
159 - salience 700  
160 - when  
161 - $spi: SchedulePlanInfo($xlid: xl, $sd: scheduleDate, $lp: lp, $fcsj: fcsj, $ttinfo: ttInfo)  
162 - $ri: RerunRule_input(  
163 - type == "dybc",  
164 - xl == $xlid.toString(),  
165 - ttinfo == $ttinfo.toString(),  
166 - lp == $lp.toString(),  
167 - fcsj == $fcsj  
168 - )  
169 -  
170 - then  
171 -  
172 - $spi.setRerunInfoDybc($ri);  
173 -  
174 -  
175 -end  
176 -  
177 -  
178 -  
179 -  
180 -  
181 -  
182 -  
183 -  
184 -  
185 -  
186 -  
187 -  
188 -  
189 -  
190 -  
191 -  
192 - 1 +package com.bsth.service.schedule.impl.plan.kBase1.core.rerun;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +
  6 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResult_output;
  7 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;
  8 +
  9 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;
  10 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_param;
  11 +
  12 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  13 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
  14 +
  15 +import org.slf4j.Logger;
  16 +import com.bsth.entity.schedule.CarConfigInfo;
  17 +import java.util.HashMap;
  18 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  19 +import com.bsth.entity.schedule.SchedulePlanInfo;
  20 +
  21 +// 全局日志类(一般使用调用此规则的service类)
  22 +global Logger log;
  23 +
  24 +global CarConfigInfoRepository carConfigInfoRepository;
  25 +global EmployeeConfigInfoRepository employeeConfigInfoRepository;
  26 +
  27 +// 输出
  28 +
  29 +
  30 +/*
  31 + 规则说明:
  32 + 1、对应路牌规则:将对应路牌的车辆,人员替换指定的套跑班次已有的配置
  33 + 2、对应班车规则:直接使用指定的人员,车辆替换指定的套跑班次已有的配置
  34 +*/
  35 +
  36 +//-------------------- 第一阶段、计算对应路牌套跑的车辆配置,人员配置数据 -----------------//
  37 +
  38 +//--------------- 车辆配置信息载入 -------------//
  39 +declare Dylp_CarConfig_Wraps
  40 + xlId: String // 线路Id
  41 + ccMap: Map // 车辆配置Map Map<id, CarConfigInfo>
  42 +end
  43 +
  44 +rule "calcu_Dylp_CarConfig_Wraps"
  45 + salience 1000
  46 + when
  47 + $rp: RerunRule_param($xlId: mxlid)
  48 + $dylpxlid: String() from $rp.getXlIds_dylp()
  49 + then
  50 + List carConfigInfos = carConfigInfoRepository.findByXlId(Integer.parseInt($dylpxlid));
  51 +
  52 + Dylp_CarConfig_Wraps carConfig_wraps = new Dylp_CarConfig_Wraps();
  53 + carConfig_wraps.setXlId($dylpxlid);
  54 + carConfig_wraps.setCcMap(new HashMap());
  55 +
  56 + for (int i = 0; i < carConfigInfos.size(); i++) {
  57 + CarConfigInfo carConfigInfo = (CarConfigInfo) carConfigInfos.get(i);
  58 + carConfig_wraps.getCcMap().put(carConfigInfo.getId().toString(), carConfigInfo);
  59 + }
  60 +
  61 + insert(carConfig_wraps);
  62 +
  63 + log.info("calcu_Dylp_CarConfig_Wraps");
  64 +
  65 +end
  66 +
  67 +//--------------- 人员配置信息载入 --------------//
  68 +declare Dylp_EmployeeConfig_Wraps
  69 + xlId: String // 线路Id
  70 + ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>
  71 +end
  72 +
  73 +rule "calcu_Dylp_EmployeeConfig_Wraps"
  74 + salience 1000
  75 + when
  76 + $rp: RerunRule_param($xlId: mxlid)
  77 + $dylpxlid: String() from $rp.getXlIds_dylp()
  78 + then
  79 + List employeeConfigInfos = employeeConfigInfoRepository.findByXlId(Integer.parseInt($dylpxlid));
  80 +
  81 + Dylp_EmployeeConfig_Wraps employeeConfig_wraps = new Dylp_EmployeeConfig_Wraps();
  82 + employeeConfig_wraps.setXlId($dylpxlid);
  83 + employeeConfig_wraps.setEcMap(new HashMap());
  84 +
  85 + for (int i = 0; i < employeeConfigInfos.size(); i++) {
  86 + EmployeeConfigInfo employeeConfigInfo = (EmployeeConfigInfo) employeeConfigInfos.get(i);
  87 + employeeConfig_wraps.getEcMap().put(employeeConfigInfo.getId().toString(), employeeConfigInfo);
  88 + }
  89 +
  90 + insert(employeeConfig_wraps);
  91 +
  92 + log.info("calcu_Dylp_EmployeeConfig_Wraps");
  93 +
  94 +end
  95 +
  96 +//-------------------- 第二阶段、包装对应路牌的循环规则输出 -----------------//
  97 +
  98 +declare Dylp_ScheduleResult_output_wrap
  99 + xlId: String // 线路
  100 + sd: DateTime // 日期
  101 + lp: String // 路牌
  102 + cc: CarConfigInfo // 使用的车辆配置
  103 + ec: List // 使用的人员配置 List<EmployeeConfigInfo>
  104 +end
  105 +
  106 +rule "calcu_Dylp_ScheduleResult_output_wrap"
  107 + salience 900
  108 + when
  109 + $sro: ScheduleResults_output($xlId: xlid)
  110 + $sr: ScheduleResult_output() from $sro.getResults()
  111 + Dylp_CarConfig_Wraps(xlId == $xlId, $ccmap: ccMap)
  112 + Dylp_EmployeeConfig_Wraps(xlId == $xlId, $ecmap: ecMap)
  113 + then
  114 + Dylp_ScheduleResult_output_wrap wrap = new Dylp_ScheduleResult_output_wrap();
  115 + wrap.setXlId($xlId);
  116 + wrap.setSd($sr.getSd());
  117 + wrap.setLp($sr.getGuideboardId());
  118 + wrap.setCc((CarConfigInfo) $ccmap.get($sr.getCarConfigId()));
  119 +
  120 + List ecs = new ArrayList();
  121 + String[] ecids = $sr.getEmployeeConfigId().split("-"); // 分班的人
  122 + for (int i = 0; i < ecids.length; i++) {
  123 + ecs.add($ecmap.get(ecids[i]));
  124 + }
  125 + wrap.setEc(ecs);
  126 +
  127 +// log.info("xlid = {}", $xlId);
  128 +
  129 + insert(wrap);
  130 +end
  131 +
  132 +//-------------------- 第三阶段、套跑线路,替换班次的车辆,人员 --------------------//
  133 +rule "calcu_Dylp_rerun_update_dylp"
  134 + salience 800
  135 +// no-loop
  136 + when
  137 + $spi: SchedulePlanInfo($xlid: xl, $sd: scheduleDate, $lp: lp, $fcsj: fcsj, $ttinfo: ttInfo)
  138 + $ri: RerunRule_input(
  139 + type == "dylp",
  140 + xl == $xlid.toString(),
  141 + ttinfo == $ttinfo.toString(),
  142 + lp == $lp.toString(),
  143 + fcsj == $fcsj,
  144 + $sxl: s_xl, $slp: s_lp, $type: usetype, $hrtype: userhrtype
  145 + )
  146 + $dsro: Dylp_ScheduleResult_output_wrap(
  147 + xlId == $sxl,
  148 + lp == $slp,
  149 + sd.getMillis() == $sd.getTime()
  150 + )
  151 + then
  152 +// log.info("TODO:测试 {}", $fcsj);
  153 +
  154 + $spi.setRerunInfoDylp($dsro.getCc(), $dsro.getEc(), $type, $hrtype);
  155 +
  156 +end
  157 +
  158 +rule "calcu_Dylp_rerun_update_dybc"
  159 + salience 700
  160 + when
  161 + $spi: SchedulePlanInfo($xlid: xl, $sd: scheduleDate, $lp: lp, $fcsj: fcsj, $ttinfo: ttInfo)
  162 + $ri: RerunRule_input(
  163 + type == "dybc",
  164 + xl == $xlid.toString(),
  165 + ttinfo == $ttinfo.toString(),
  166 + lp == $lp.toString(),
  167 + fcsj == $fcsj
  168 + )
  169 +
  170 + then
  171 +
  172 + $spi.setRerunInfoDybc($ri);
  173 +
  174 +
  175 +end
  176 +
  177 +
  178 +
  179 +
  180 +
  181 +
  182 +
  183 +
  184 +
  185 +
  186 +
  187 +
  188 +
  189 +
  190 +
  191 +
  192 +
src/main/resources/rules/kBase1_core_shiftloop.drl
1 -package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;  
2 -  
3 -import org.joda.time.*;  
4 -import java.util.*;  
5 -  
6 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;  
7 -  
8 -import com.bsth.service.schedule.utils.Md5Util;  
9 -  
10 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleCalcuParam_input;  
11 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;  
12 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;  
13 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResult_output;  
14 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;  
15 -  
16 -import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;  
17 -  
18 -import com.bsth.entity.schedule.SchedulePlan;  
19 -  
20 -import com.bsth.service.schedule.impl.plan.ScheduleRuleService;  
21 -  
22 -import org.slf4j.Logger;  
23 -  
24 -global Logger log;  
25 -global ScheduleResults_output scheduleResult;  
26 -global ScheduleRuleService scheduleRuleService;  
27 -  
28 -/*  
29 - 存在(翻班格式)  
30 -*/  
31 -  
32 -//------------------------- 第一阶段、计算规则准备数据(天数) ----------------------------//  
33 -  
34 -declare Calcu_days_result_pre  
35 - ruleId: String // 规则Id  
36 - ruleMd5: String // 规则md5  
37 - ruleEcCount: Integer // 人员范围个数  
38 -  
39 - calcu_index_lp : Integer // 计算之后路牌的起始索引  
40 - calcu_index_ry : Integer // 计算之后人员的起始索引  
41 -  
42 - fbtype: Integer // 翻班type,0:时刻表type 1:翻班格式type  
43 - fbweeks: List // 翻班格式,如:1111001111001  
44 - fbgs_index: Integer // 翻班格式起始索引(从0开始)  
45 -  
46 - // 1、第一部分循环需要用到的数据(当开始日期大于启用日期的时候才有)  
47 - calcu_start_date_1: DateTime // 第一部分开始计算日期  
48 - calcu_end_date_1: DateTime // 第一部分结束计算日期  
49 -  
50 - // 2、第二部分循环需要用到的数据  
51 - sdays : Integer // 总共需要排班的天数  
52 - calcu_start_date_2 : DateTime // 开始计算日期  
53 - calcu_end_date_2 : DateTime // 结束计算日期  
54 -  
55 -end  
56 -  
57 -/*  
58 - 计算启用日期,开始计算日期,结束计算日期,相差天数  
59 - 1、规则启用日期小于开始计算日期  
60 - 2、规则启用日期大于等于开始日期,小于等于结束日期  
61 -*/  
62 -// 1、启用日期 < 开始日期  
63 -rule "calcu_days_1_"  
64 - salience 1000  
65 - when  
66 - ScheduleCalcuParam_input(  
67 - fromDate.isBefore(toDate) || fromDate.isEqual(toDate),  
68 - $fromDate : fromDate,  
69 - $toDate : toDate,  
70 - $xlId: xlId  
71 - )  
72 - $sri: ScheduleRule_input(  
73 - $ruleId : ruleId, $qyrq : qyrq,  
74 - $lpindex : startGbdIndex, $ryindex: startEIndex)  
75 - eval($qyrq.isBefore($fromDate))  
76 - then  
77 - scheduleResult.setXlid($xlId);  
78 -  
79 - // 构造Calcu_days_result_pre,用于路牌  
80 - Calcu_days_result_pre cdrp = new Calcu_days_result_pre();  
81 - cdrp.setRuleId($ruleId);  
82 - cdrp.setCalcu_index_lp($lpindex);  
83 - cdrp.setCalcu_index_ry($ryindex);  
84 - cdrp.setCalcu_start_date_1($qyrq);  
85 - cdrp.setCalcu_end_date_1($fromDate);  
86 - Period p2 = new Period($fromDate, $toDate, PeriodType.days());  
87 - cdrp.setSdays(p2.getDays() + 1);  
88 - cdrp.setCalcu_start_date_2($fromDate);  
89 - cdrp.setCalcu_end_date_2($toDate);  
90 -  
91 - // 翻班相关  
92 - cdrp.setFbtype($sri.getFbtype());  
93 - cdrp.setFbgs_index(0);  
94 - cdrp.setFbweeks($sri.getWeekdays());  
95 -  
96 - /**  
97 - * 规则md5值(不使用id判定,使用md5判定)  
98 - * 使用,启用日期,路牌范围,结合生成md5编码  
99 - */  
100 - String ruleMd5 = Md5Util.getMd5(  
101 - String.valueOf($qyrq.getMillis()) +  
102 - "_" +  
103 - $sri.getSelf().getLpIds() +  
104 - "_" +  
105 - $sri.getSelf().getLpStart().toString()  
106 - );  
107 - cdrp.setRuleMd5(ruleMd5);  
108 - // 人员范围个数  
109 - cdrp.setRuleEcCount($sri.getEmployeeConfigIds().size());  
110 -  
111 - insert(cdrp);  
112 -  
113 -// log.info("总共需要排班的天数 sdays={} ruleId={} from={} to={}", (p2.getDays() + 1), $ruleId, $fromDate, $toDate);  
114 -  
115 -end  
116 -  
117 -// 启用日期 属于 [开始日期,结束日期]  
118 -rule "calcu_days_2_"  
119 - salience 1000  
120 - when  
121 - ScheduleCalcuParam_input(  
122 - fromDate.isBefore(toDate) || fromDate.isEqual(toDate),  
123 - $fromDate : fromDate,  
124 - $toDate : toDate,  
125 - $xlId: xlId  
126 - )  
127 - $sri: ScheduleRule_input(  
128 - $ruleId : ruleId, $qyrq : qyrq,  
129 - $lpindex : startGbdIndex, $ryindex: startEIndex)  
130 - eval((!$qyrq.isBefore($fromDate)) && (!$qyrq.isAfter($toDate)))  
131 - then  
132 - scheduleResult.setXlid($xlId);  
133 -  
134 - // 构造Calcu_days_result_pre,用于路牌  
135 - Calcu_days_result_pre cdrp = new Calcu_days_result_pre();  
136 - cdrp.setRuleId($ruleId);  
137 - cdrp.setCalcu_index_lp($lpindex);  
138 - cdrp.setCalcu_index_ry($ryindex);  
139 - cdrp.setCalcu_start_date_1($qyrq);  
140 - cdrp.setCalcu_end_date_1($qyrq);  
141 - Period p2 = new Period($qyrq, $toDate, PeriodType.days());  
142 - cdrp.setSdays(p2.getDays() + 1);  
143 - cdrp.setCalcu_start_date_2($qyrq);  
144 - cdrp.setCalcu_end_date_2($toDate);  
145 -  
146 - // 翻班相关  
147 - cdrp.setFbtype($sri.getFbtype());  
148 - cdrp.setFbgs_index(0);  
149 - cdrp.setFbweeks($sri.getWeekdays());  
150 -  
151 - /**  
152 - * 规则md5值(不使用id判定,使用md5判定)  
153 - * 使用,启用日期,路牌范围,结合生成md5编码  
154 - */  
155 - String ruleMd5 = Md5Util.getMd5(  
156 - String.valueOf($qyrq.getMillis()) +  
157 - "_" +  
158 - $sri.getSelf().getLpIds() +  
159 - "_" +  
160 - $sri.getSelf().getLpStart().toString()  
161 - );  
162 - cdrp.setRuleMd5(ruleMd5);  
163 - // 人员范围个数  
164 - cdrp.setRuleEcCount($sri.getEmployeeConfigIds().size());  
165 -  
166 - insert(cdrp);  
167 -  
168 -// log.info("总共需要排班的天数 sdays={} ruleId={} from={} to={}", (p2.getDays() + 1), $ruleId, $qyrq, $toDate);  
169 -  
170 -end  
171 -  
172 -// 使用已经排过班的数据修正Calcu_days_result_pre  
173 -// 1、避免每次从规则的启用日期开始算  
174 -// 2、时刻表会不停的修正,如果每次都从规则启用日期开始算,会出错  
175 -  
176 -declare SchedulePlanRuleResult_wrap  
177 - ruleId: String // 规则Id  
178 - ruleMd5: String // 规则md5编码  
179 - scheduleDate: DateTime // 排班日期  
180 -  
181 - isUsed: Boolean = false // 是否被使用过  
182 -  
183 - self: SchedulePlanRuleResult; // 原始对象数据  
184 -end  
185 -  
186 -rule "Calcu_SchedulePlanRuleResult_wrap"  
187 - salience 950  
188 - when  
189 - ScheduleCalcuParam_input(  
190 - fromDate.isBefore(toDate) || fromDate.isEqual(toDate),  
191 - $fromDate : fromDate,  
192 - $toDate : toDate,  
193 - $xlId: xlId,  
194 - $self: schedulePlan  
195 - )  
196 - eval($self.getIsHistoryPlanFirst() == true) // 是否使用历史排班标识  
197 - $sprr: SchedulePlanRuleResult() from scheduleRuleService.findLastByXl($xlId, $fromDate.toDate())  
198 - eval($sprr.getQyrq() != null)  
199 -  
200 - then  
201 - // 创建班序历史结果数据  
202 - SchedulePlanRuleResult_wrap schedulePlanRuleResult_wrap = new SchedulePlanRuleResult_wrap();  
203 - schedulePlanRuleResult_wrap.setRuleId($sprr.getRuleId());  
204 - schedulePlanRuleResult_wrap.setScheduleDate(new DateTime($sprr.getScheduleDate()));  
205 - schedulePlanRuleResult_wrap.setSelf($sprr);  
206 -  
207 - // 规则Md5编码  
208 - String md5 = Md5Util.getMd5(  
209 - String.valueOf($sprr.getQyrq().getTime()) +  
210 - "_" +  
211 - $sprr.getGids() +  
212 - "_" +  
213 - $sprr.getOrigingidindex()  
214 - );  
215 -  
216 -// System.out.println("修改后的md5:" + md5 + "车辆:" + $sprr.getCcZbh());  
217 -  
218 - schedulePlanRuleResult_wrap.setRuleMd5(md5);  
219 -  
220 - insert(schedulePlanRuleResult_wrap);  
221 -end  
222 -  
223 -  
224 -// 1、启用日期 < 开始日期  
225 -// 2、如果最近的排班规则历史时间在 (启用日期,开始日期) 之间,需要重新修正预处理数据  
226 -rule "calcu_days_1_with_result"  
227 - no-loop  
228 - salience 960  
229 - when  
230 - $cdrp: Calcu_days_result_pre(  
231 - calcu_start_date_1.isBefore(calcu_start_date_2),  
232 - $ruleId: ruleId,  
233 - $ruleMd5: ruleMd5,  
234 - $ruleEcCount: ruleEcCount  
235 - )  
236 - $srrr_wrap: SchedulePlanRuleResult_wrap(  
237 -// ruleId == $ruleId,  
238 - ruleMd5 == $ruleMd5,  
239 - scheduleDate.isAfter($cdrp.calcu_start_date_1),  
240 - scheduleDate.isBefore($cdrp.calcu_start_date_2),  
241 - isUsed == false,  
242 - $scheduleDate: scheduleDate,  
243 - $self: self  
244 - )  
245 - then  
246 - // 修正排班数据  
247 -// log.info("准备修正 ruleId={} historyDate={}", $ruleId, $scheduleDate);  
248 -  
249 - // 路牌范围起始index使用历史数据  
250 - $cdrp.setCalcu_index_lp(Integer.valueOf($self.getGidindex()));  
251 - // 人员范围起始index,需要判定,如果长度都是一样的,使用历史的,否则不更新,使用最新的  
252 - String history_ecids = $self.getEcids();  
253 - if ($ruleEcCount == history_ecids.split(",").length) {  
254 - $cdrp.setCalcu_index_ry(Integer.valueOf($self.getEcindex()));  
255 - }  
256 -  
257 - // 翻班格式利用路牌的历史index更新  
258 - int fb_temp = Integer.valueOf($self.getGidindex()) % $cdrp.getFbweeks().size();  
259 - $cdrp.setFbgs_index(fb_temp);  
260 -  
261 - $cdrp.setCalcu_start_date_1($scheduleDate);  
262 - update($cdrp);  
263 -  
264 - $srrr_wrap.setIsUsed(true);  
265 - update($srrr_wrap);  
266 -  
267 -end  
268 -  
269 -  
270 -  
271 -//------------------------- 第二阶段、计算规则准备数据2(第一组循环) ----------------------------//  
272 -  
273 -function void calcu_loop1_fb(Calcu_days_result_pre $cdrp, ScheduleRule_input $sri, Logger log) {  
274 - Integer $lpindex = $cdrp.getCalcu_index_lp();  
275 - Integer $lprangesize = $sri.getGuideboardIds().size();  
276 - Integer $ryindex = $cdrp.getCalcu_index_ry();  
277 - Integer $ryrangesize = $sri.getEmployeeConfigIds().size();  
278 - Integer $fbindex = $cdrp.getFbgs_index();  
279 - Integer $fbfangesize = $sri.getWeekdays().size();  
280 - DateTime $csd1 = $cdrp.getCalcu_start_date_1();  
281 - DateTime $ced1 = $cdrp.getCalcu_end_date_1();  
282 -  
283 - String $ruleId = $cdrp.getRuleId();  
284 -  
285 - $cdrp.setCalcu_index_lp(($lpindex + 1) % $lprangesize);  
286 - $cdrp.setCalcu_index_ry(($ryindex + 1) % $ryrangesize);  
287 -  
288 - $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);  
289 - $cdrp.setCalcu_start_date_1($csd1.plusDays(1));  
290 -  
291 -// log.info("calcu_loop1_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",  
292 -// $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd1, $ced1);  
293 -  
294 -}  
295 -function void calcu_loop1_not_fb(Calcu_days_result_pre $cdrp, ScheduleRule_input $sri, Logger log) {  
296 - DateTime $csd1 = $cdrp.getCalcu_start_date_1();  
297 - DateTime $ced1 = $cdrp.getCalcu_end_date_1();  
298 - Integer $fbindex = $cdrp.getFbgs_index();  
299 - Integer $fbfangesize = $sri.getWeekdays().size();  
300 -  
301 - $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);  
302 - $cdrp.setCalcu_start_date_1($csd1.plusDays(1));  
303 -  
304 -// log.info("calcu_loop1_not_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",  
305 -// $cdrp.getRuleId(), $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd1, $ced1);  
306 -}  
307 -  
308 -  
309 -rule "Calcu_loop1_fbtype_with_0_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是false,就跳过  
310 - salience 900  
311 - when  
312 - $cdrp: Calcu_days_result_pre(  
313 - calcu_start_date_1.isBefore(calcu_end_date_1),  
314 - $ruleId: ruleId,  
315 - fbtype == "1",  
316 - $fbindex : fbgs_index  
317 - )  
318 - $sri: ScheduleRule_input(  
319 - ruleId == $ruleId,  
320 - weekdays[$fbindex] == false  
321 - )  
322 - then  
323 - calcu_loop1_not_fb($cdrp, $sri, log);  
324 - update($cdrp);  
325 -end  
326 -  
327 -rule "Calcu_loop1_fbtype_with_1_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里存在指定路牌,就翻  
328 - salience 900  
329 - when  
330 - $cdrp: Calcu_days_result_pre(  
331 - calcu_start_date_1.isBefore(calcu_end_date_1),  
332 - $csd1: calcu_start_date_1,  
333 - $ruleId: ruleId,  
334 - fbtype == "1",  
335 - $lpindex: calcu_index_lp,  
336 - $fbindex : fbgs_index  
337 - )  
338 - $sri: ScheduleRule_input(  
339 - ruleId == $ruleId,  
340 - $gids: guideboardIds,  
341 - weekdays[$fbindex] == true  
342 - )  
343 - $liro: LpInfoResult_output(  
344 - dateTime.isEqual($csd1),  
345 - $gids[$lpindex] == lpId  
346 - )  
347 - then  
348 - calcu_loop1_fb($cdrp, $sri, log);  
349 - update($cdrp);  
350 -  
351 -end  
352 -  
353 -rule "Calcu_loop1_fbtype_with_1_no_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里不存在指定路牌,就跳过  
354 - salience 900  
355 - when  
356 - $cdrp: Calcu_days_result_pre(  
357 - calcu_start_date_1.isBefore(calcu_end_date_1),  
358 - $csd1: calcu_start_date_1,  
359 - $ruleId: ruleId,  
360 - fbtype == "1",  
361 - $fbindex : fbgs_index  
362 - )  
363 - $sri: ScheduleRule_input(  
364 - ruleId == $ruleId,  
365 - weekdays[$fbindex] == true  
366 - )  
367 - then  
368 - calcu_loop1_not_fb($cdrp, $sri, log);  
369 - update($cdrp);  
370 -end  
371 -  
372 -  
373 -rule "Calcu_loop1_timetabletype_with_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中存在,就翻  
374 - salience 900  
375 - when  
376 - $cdrp: Calcu_days_result_pre(  
377 - calcu_start_date_1.isBefore(calcu_end_date_1),  
378 - $csd1: calcu_start_date_1,  
379 - $ruleId: ruleId,  
380 - fbtype == "0",  
381 - $lpindex: calcu_index_lp  
382 - )  
383 - $sri: ScheduleRule_input(  
384 - ruleId == $ruleId,  
385 - $gids: guideboardIds  
386 - )  
387 - $liro: LpInfoResult_output(  
388 - dateTime.isEqual($csd1),  
389 - $gids[$lpindex] == lpId  
390 - )  
391 - then  
392 - calcu_loop1_fb($cdrp, $sri, log);  
393 - update($cdrp);  
394 -end  
395 -  
396 -rule "Calcu_loop1_timetabletype_with_no_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中不存在,就跳过  
397 - salience 900  
398 - when  
399 - $cdrp: Calcu_days_result_pre(  
400 - calcu_start_date_1.isBefore(calcu_end_date_1),  
401 - $csd1: calcu_start_date_1,  
402 - $ruleId: ruleId,  
403 - fbtype == "0"  
404 - )  
405 - $sri: ScheduleRule_input(  
406 - ruleId == $ruleId  
407 - )  
408 - then  
409 - calcu_loop1_not_fb($cdrp, $sri, log);  
410 - update($cdrp);  
411 -end  
412 -  
413 -//------------------------- 第三阶段、计算规则准备数据2(第二组循环) ----------------------------//  
414 -  
415 -function void calcu_loop2_fb(  
416 - SchedulePlan $sp,  
417 - Calcu_days_result_pre $cdrp,  
418 - ScheduleRule_input $sri,  
419 - LpInfoResult_output $liro,  
420 - ScheduleResults_output rs,  
421 - Logger log) {  
422 - String $ruleId = $cdrp.getRuleId();  
423 - DateTime $csd2 = $cdrp.getCalcu_start_date_2();  
424 - DateTime $ced2 = $cdrp.getCalcu_end_date_2();  
425 - Integer $lpindex = $cdrp.getCalcu_index_lp();  
426 - List $gids = $sri.getGuideboardIds();  
427 - Integer $lprangesize = $sri.getGuideboardIds().size();  
428 - Integer $ryindex = $cdrp.getCalcu_index_ry();  
429 - List $eids = $sri.getEmployeeConfigIds();  
430 - Integer $ryrangesize = $sri.getEmployeeConfigIds().size();  
431 - Integer $fbindex = $cdrp.getFbgs_index();  
432 - Integer $fbfangesize = $sri.getWeekdays().size();  
433 - String $cid = $sri.getCarConfigId();  
434 - String $xlid = $sri.getXlId();  
435 -  
436 - com.bsth.entity.schedule.rule.ScheduleRule1Flat $srf = $sri.getSelf();  
437 -  
438 - String $ttinfoId = $liro.getTtInfoId();  
439 - String $ttinfoName = $liro.getTtInfoName();  
440 -  
441 - ScheduleResult_output ro = new ScheduleResult_output();  
442 - ro.setRuleId($ruleId);  
443 - ro.setSd($csd2);  
444 - ro.setGuideboardId(String.valueOf($gids.get($lpindex)));  
445 - ro.setEmployeeConfigId(String.valueOf($eids.get($ryindex)));  
446 - ro.setCarConfigId($cid);  
447 - ro.setXlId($xlid);  
448 -  
449 - // 类型  
450 - ro.setsType($sri.getsType());  
451 -  
452 - rs.getResults().add(ro);  
453 -  
454 -// log.info("gogoogogogogo");  
455 -  
456 - $cdrp.setCalcu_index_lp(($lpindex + 1) % $lprangesize);  
457 - $cdrp.setCalcu_index_ry(($ryindex + 1) % $ryrangesize);  
458 -  
459 - $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);  
460 - $cdrp.setCalcu_start_date_2($csd2.plusDays(1));  
461 -  
462 - if ($sri.getsType() == ScheduleRule_Type.NORMAL) {  
463 - // 保存排班规则循环结果 --> SchedulePlanRuleResult  
464 - SchedulePlanRuleResult schedulePlanRuleResult = new SchedulePlanRuleResult($sp);  
465 -// schedulePlanRuleResult.setXlId(String.valueOf($srf.getXl().getId()));  
466 - schedulePlanRuleResult.setXlId($srf.getXl().getId());  
467 - schedulePlanRuleResult.setXlName($srf.getXl().getName());  
468 - schedulePlanRuleResult.setRuleId($ruleId);  
469 - schedulePlanRuleResult.setCcId($cid);  
470 - schedulePlanRuleResult.setCcZbh($srf.getCarConfigInfo().getCl().getInsideCode());  
471 - schedulePlanRuleResult.setGids($srf.getLpIds()); // 参与md5计算  
472 - schedulePlanRuleResult.setGnames($srf.getLpNames());  
473 - schedulePlanRuleResult.setGidindex(String.valueOf($lpindex));  
474 - schedulePlanRuleResult.setEcids($srf.getRyConfigIds());  
475 - schedulePlanRuleResult.setEcdbbms($srf.getRyDbbms());  
476 - schedulePlanRuleResult.setEcindex(String.valueOf($ryindex));  
477 - schedulePlanRuleResult.setScheduleDate($csd2.toDate());  
478 - schedulePlanRuleResult.setTtinfoId($ttinfoId);  
479 - schedulePlanRuleResult.setTtinfoName($ttinfoName);  
480 - schedulePlanRuleResult.setQyrq($sri.getQyrq().toDate()); // 参与md5计算  
481 - schedulePlanRuleResult.setOrigingidindex(String.valueOf($sri.getSelf().getLpStart())); // 参与md5计算  
482 -  
483 - rs.getSchedulePlanRuleResults().add(schedulePlanRuleResult);  
484 - }  
485 -  
486 -  
487 -  
488 -// log.info("calcu_loop2_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",  
489 -// $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd2, $ced2);  
490 -  
491 -}  
492 -  
493 -function void calcu_loop2_not_fb(  
494 - Calcu_days_result_pre $cdrp,  
495 - ScheduleRule_input $sri,  
496 - ScheduleResults_output rs,  
497 - Logger log) {  
498 -  
499 - String $ruleId = $cdrp.getRuleId();  
500 - DateTime $csd2 = $cdrp.getCalcu_start_date_2();  
501 - DateTime $ced2 = $cdrp.getCalcu_end_date_2();  
502 - Integer $lpindex = $cdrp.getCalcu_index_lp();  
503 - List $gids = $sri.getGuideboardIds();  
504 - Integer $ryindex = $cdrp.getCalcu_index_ry();  
505 - List $eids = $sri.getEmployeeConfigIds();  
506 - Integer $fbindex = $cdrp.getFbgs_index();  
507 - Integer $fbfangesize = $sri.getWeekdays().size();  
508 - String $cid = $sri.getCarConfigId();  
509 - String $xlid = $sri.getXlId();  
510 -  
511 - ScheduleResult_output ro = new ScheduleResult_output();  
512 - ro.setRuleId($ruleId);  
513 - ro.setSd($csd2);  
514 -// ro.setGuideboardId(String.valueOf($gids.get($lpindex)));  
515 - ro.setGuideboardId("not_fb_lp"); // 不翻班,路牌id用假的,后面会过滤  
516 - ro.setEmployeeConfigId(String.valueOf($eids.get($ryindex)));  
517 - ro.setCarConfigId($cid);  
518 - ro.setXlId($xlid);  
519 -  
520 - // 类型  
521 - ro.setsType($sri.getsType());  
522 -  
523 - rs.getResults().add(ro);  
524 -  
525 - $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);  
526 - $cdrp.setCalcu_start_date_2($csd2.plusDays(1));  
527 -  
528 -// log.info("calcu_loop2_not_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",  
529 -// $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd2, $ced2);  
530 -  
531 -}  
532 -  
533 -rule "Calcu_loop2_fbtype_with_0_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是false,就跳过  
534 - salience 800  
535 - when  
536 - ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)  
537 - $cdrp: Calcu_days_result_pre(  
538 - calcu_start_date_1.isEqual(calcu_end_date_1),  
539 - calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),  
540 - $ruleId: ruleId,  
541 - fbtype == "1",  
542 - $fbindex : fbgs_index  
543 - )  
544 - $sri: ScheduleRule_input(  
545 - ruleId == $ruleId,  
546 - weekdays[$fbindex] == false  
547 - )  
548 - then  
549 - calcu_loop2_not_fb($cdrp, $sri, scheduleResult, log);  
550 - update($cdrp);  
551 -  
552 -end  
553 -  
554 -rule "Calcu_loop2_fbtype_with_1_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里存在指定路牌,就翻  
555 - salience 800  
556 - when  
557 - ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)  
558 - $cdrp: Calcu_days_result_pre(  
559 - calcu_start_date_1.isEqual(calcu_end_date_1),  
560 - calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),  
561 - $csd2: calcu_start_date_2,  
562 - $ruleId: ruleId,  
563 - fbtype == "1",  
564 - $lpindex: calcu_index_lp,  
565 - $fbindex : fbgs_index  
566 - )  
567 - $sri: ScheduleRule_input(  
568 - ruleId == $ruleId,  
569 - $gids: guideboardIds,  
570 - weekdays[$fbindex] == true  
571 - )  
572 - $liro: LpInfoResult_output(  
573 - dateTime.isEqual($csd2),  
574 - $gids[$lpindex] == lpId  
575 - )  
576 - then  
577 - calcu_loop2_fb($sp, $cdrp, $sri, $liro, scheduleResult, log);  
578 - update($cdrp);  
579 -end  
580 -  
581 -rule "Calcu_loop2_fbtype_with_1_no_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里不存在指定路牌,就跳过  
582 - salience 800  
583 - when  
584 - ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)  
585 - $cdrp: Calcu_days_result_pre(  
586 - calcu_start_date_1.isEqual(calcu_end_date_1),  
587 - calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),  
588 - $ruleId: ruleId,  
589 - fbtype == "1",  
590 - $fbindex : fbgs_index  
591 - )  
592 - $sri: ScheduleRule_input(  
593 - ruleId == $ruleId,  
594 - weekdays[$fbindex] == true  
595 - )  
596 - then  
597 - calcu_loop2_not_fb($cdrp, $sri, scheduleResult, log);  
598 - update($cdrp);  
599 -  
600 -end  
601 -  
602 -rule "Calcu_loop2_timetabletype_with_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中存在,就翻  
603 - salience 800  
604 - when  
605 - ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)  
606 - $cdrp: Calcu_days_result_pre(  
607 - calcu_start_date_1.isEqual(calcu_end_date_1),  
608 - calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),  
609 - $csd2: calcu_start_date_2,  
610 - $ruleId: ruleId,  
611 - fbtype == "0",  
612 - $lpindex: calcu_index_lp,  
613 - $fbindex : fbgs_index  
614 - )  
615 - $sri: ScheduleRule_input(  
616 - ruleId == $ruleId,  
617 - $gids: guideboardIds  
618 - )  
619 - $liro: LpInfoResult_output(  
620 - dateTime.isEqual($csd2),  
621 - $gids[$lpindex] == lpId  
622 - )  
623 - then  
624 - calcu_loop2_fb($sp, $cdrp, $sri, $liro, scheduleResult, log);  
625 - update($cdrp);  
626 -  
627 -end  
628 -  
629 -rule "Calcu_loop2_timetabletype_with_no_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中不存在,就跳过  
630 - salience 800  
631 - when  
632 - ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)  
633 - $cdrp: Calcu_days_result_pre(  
634 - calcu_start_date_1.isEqual(calcu_end_date_1),  
635 - calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),  
636 - $ruleId: ruleId,  
637 - fbtype == "0"  
638 - )  
639 - $sri: ScheduleRule_input(  
640 - ruleId == $ruleId  
641 - )  
642 - then  
643 - calcu_loop2_not_fb($cdrp, $sri, scheduleResult, log);  
644 - update($cdrp);  
645 -end  
646 -  
647 -  
648 -  
649 -  
650 -  
651 -  
652 -  
653 - 1 +package com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +
  6 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;
  7 +
  8 +import com.bsth.service.schedule.utils.Md5Util;
  9 +
  10 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleCalcuParam_input;
  11 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;
  12 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;
  13 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResult_output;
  14 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleResults_output;
  15 +
  16 +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
  17 +
  18 +import com.bsth.entity.schedule.SchedulePlan;
  19 +
  20 +import com.bsth.service.schedule.impl.plan.ScheduleRuleService;
  21 +
  22 +import org.slf4j.Logger;
  23 +
  24 +global Logger log;
  25 +global ScheduleResults_output scheduleResult;
  26 +global ScheduleRuleService scheduleRuleService;
  27 +
  28 +/*
  29 + 存在(翻班格式)
  30 +*/
  31 +
  32 +//------------------------- 第一阶段、计算规则准备数据(天数) ----------------------------//
  33 +
  34 +declare Calcu_days_result_pre
  35 + ruleId: String // 规则Id
  36 + ruleMd5: String // 规则md5
  37 + ruleEcCount: Integer // 人员范围个数
  38 +
  39 + calcu_index_lp : Integer // 计算之后路牌的起始索引
  40 + calcu_index_ry : Integer // 计算之后人员的起始索引
  41 +
  42 + fbtype: Integer // 翻班type,0:时刻表type 1:翻班格式type
  43 + fbweeks: List // 翻班格式,如:1111001111001
  44 + fbgs_index: Integer // 翻班格式起始索引(从0开始)
  45 +
  46 + // 1、第一部分循环需要用到的数据(当开始日期大于启用日期的时候才有)
  47 + calcu_start_date_1: DateTime // 第一部分开始计算日期
  48 + calcu_end_date_1: DateTime // 第一部分结束计算日期
  49 +
  50 + // 2、第二部分循环需要用到的数据
  51 + sdays : Integer // 总共需要排班的天数
  52 + calcu_start_date_2 : DateTime // 开始计算日期
  53 + calcu_end_date_2 : DateTime // 结束计算日期
  54 +
  55 +end
  56 +
  57 +/*
  58 + 计算启用日期,开始计算日期,结束计算日期,相差天数
  59 + 1、规则启用日期小于开始计算日期
  60 + 2、规则启用日期大于等于开始日期,小于等于结束日期
  61 +*/
  62 +// 1、启用日期 < 开始日期
  63 +rule "calcu_days_1_"
  64 + salience 1000
  65 + when
  66 + ScheduleCalcuParam_input(
  67 + fromDate.isBefore(toDate) || fromDate.isEqual(toDate),
  68 + $fromDate : fromDate,
  69 + $toDate : toDate,
  70 + $xlId: xlId
  71 + )
  72 + $sri: ScheduleRule_input(
  73 + $ruleId : ruleId, $qyrq : qyrq,
  74 + $lpindex : startGbdIndex, $ryindex: startEIndex)
  75 + eval($qyrq.isBefore($fromDate))
  76 + then
  77 + scheduleResult.setXlid($xlId);
  78 +
  79 + // 构造Calcu_days_result_pre,用于路牌
  80 + Calcu_days_result_pre cdrp = new Calcu_days_result_pre();
  81 + cdrp.setRuleId($ruleId);
  82 + cdrp.setCalcu_index_lp($lpindex);
  83 + cdrp.setCalcu_index_ry($ryindex);
  84 + cdrp.setCalcu_start_date_1($qyrq);
  85 + cdrp.setCalcu_end_date_1($fromDate);
  86 + Period p2 = new Period($fromDate, $toDate, PeriodType.days());
  87 + cdrp.setSdays(p2.getDays() + 1);
  88 + cdrp.setCalcu_start_date_2($fromDate);
  89 + cdrp.setCalcu_end_date_2($toDate);
  90 +
  91 + // 翻班相关
  92 + cdrp.setFbtype($sri.getFbtype());
  93 + cdrp.setFbgs_index(0);
  94 + cdrp.setFbweeks($sri.getWeekdays());
  95 +
  96 + /**
  97 + * 规则md5值(不使用id判定,使用md5判定)
  98 + * 使用,启用日期,路牌范围,结合生成md5编码
  99 + */
  100 + String ruleMd5 = Md5Util.getMd5(
  101 + String.valueOf($qyrq.getMillis()) +
  102 + "_" +
  103 + $sri.getSelf().getLpIds() +
  104 + "_" +
  105 + $sri.getSelf().getLpStart().toString()
  106 + );
  107 + cdrp.setRuleMd5(ruleMd5);
  108 + // 人员范围个数
  109 + cdrp.setRuleEcCount($sri.getEmployeeConfigIds().size());
  110 +
  111 + insert(cdrp);
  112 +
  113 +// log.info("总共需要排班的天数 sdays={} ruleId={} from={} to={}", (p2.getDays() + 1), $ruleId, $fromDate, $toDate);
  114 +
  115 +end
  116 +
  117 +// 启用日期 属于 [开始日期,结束日期]
  118 +rule "calcu_days_2_"
  119 + salience 1000
  120 + when
  121 + ScheduleCalcuParam_input(
  122 + fromDate.isBefore(toDate) || fromDate.isEqual(toDate),
  123 + $fromDate : fromDate,
  124 + $toDate : toDate,
  125 + $xlId: xlId
  126 + )
  127 + $sri: ScheduleRule_input(
  128 + $ruleId : ruleId, $qyrq : qyrq,
  129 + $lpindex : startGbdIndex, $ryindex: startEIndex)
  130 + eval((!$qyrq.isBefore($fromDate)) && (!$qyrq.isAfter($toDate)))
  131 + then
  132 + scheduleResult.setXlid($xlId);
  133 +
  134 + // 构造Calcu_days_result_pre,用于路牌
  135 + Calcu_days_result_pre cdrp = new Calcu_days_result_pre();
  136 + cdrp.setRuleId($ruleId);
  137 + cdrp.setCalcu_index_lp($lpindex);
  138 + cdrp.setCalcu_index_ry($ryindex);
  139 + cdrp.setCalcu_start_date_1($qyrq);
  140 + cdrp.setCalcu_end_date_1($qyrq);
  141 + Period p2 = new Period($qyrq, $toDate, PeriodType.days());
  142 + cdrp.setSdays(p2.getDays() + 1);
  143 + cdrp.setCalcu_start_date_2($qyrq);
  144 + cdrp.setCalcu_end_date_2($toDate);
  145 +
  146 + // 翻班相关
  147 + cdrp.setFbtype($sri.getFbtype());
  148 + cdrp.setFbgs_index(0);
  149 + cdrp.setFbweeks($sri.getWeekdays());
  150 +
  151 + /**
  152 + * 规则md5值(不使用id判定,使用md5判定)
  153 + * 使用,启用日期,路牌范围,结合生成md5编码
  154 + */
  155 + String ruleMd5 = Md5Util.getMd5(
  156 + String.valueOf($qyrq.getMillis()) +
  157 + "_" +
  158 + $sri.getSelf().getLpIds() +
  159 + "_" +
  160 + $sri.getSelf().getLpStart().toString()
  161 + );
  162 + cdrp.setRuleMd5(ruleMd5);
  163 + // 人员范围个数
  164 + cdrp.setRuleEcCount($sri.getEmployeeConfigIds().size());
  165 +
  166 + insert(cdrp);
  167 +
  168 +// log.info("总共需要排班的天数 sdays={} ruleId={} from={} to={}", (p2.getDays() + 1), $ruleId, $qyrq, $toDate);
  169 +
  170 +end
  171 +
  172 +// 使用已经排过班的数据修正Calcu_days_result_pre
  173 +// 1、避免每次从规则的启用日期开始算
  174 +// 2、时刻表会不停的修正,如果每次都从规则启用日期开始算,会出错
  175 +
  176 +declare SchedulePlanRuleResult_wrap
  177 + ruleId: String // 规则Id
  178 + ruleMd5: String // 规则md5编码
  179 + scheduleDate: DateTime // 排班日期
  180 +
  181 + isUsed: Boolean = false // 是否被使用过
  182 +
  183 + self: SchedulePlanRuleResult; // 原始对象数据
  184 +end
  185 +
  186 +rule "Calcu_SchedulePlanRuleResult_wrap"
  187 + salience 950
  188 + when
  189 + ScheduleCalcuParam_input(
  190 + fromDate.isBefore(toDate) || fromDate.isEqual(toDate),
  191 + $fromDate : fromDate,
  192 + $toDate : toDate,
  193 + $xlId: xlId,
  194 + $self: schedulePlan
  195 + )
  196 + eval($self.getIsHistoryPlanFirst() == true) // 是否使用历史排班标识
  197 + $sprr: SchedulePlanRuleResult() from scheduleRuleService.findLastByXl($xlId, $fromDate.toDate())
  198 + eval($sprr.getQyrq() != null)
  199 +
  200 + then
  201 + // 创建班序历史结果数据
  202 + SchedulePlanRuleResult_wrap schedulePlanRuleResult_wrap = new SchedulePlanRuleResult_wrap();
  203 + schedulePlanRuleResult_wrap.setRuleId($sprr.getRuleId());
  204 + schedulePlanRuleResult_wrap.setScheduleDate(new DateTime($sprr.getScheduleDate()));
  205 + schedulePlanRuleResult_wrap.setSelf($sprr);
  206 +
  207 + // 规则Md5编码
  208 + String md5 = Md5Util.getMd5(
  209 + String.valueOf($sprr.getQyrq().getTime()) +
  210 + "_" +
  211 + $sprr.getGids() +
  212 + "_" +
  213 + $sprr.getOrigingidindex()
  214 + );
  215 +
  216 +// System.out.println("修改后的md5:" + md5 + "车辆:" + $sprr.getCcZbh());
  217 +
  218 + schedulePlanRuleResult_wrap.setRuleMd5(md5);
  219 +
  220 + insert(schedulePlanRuleResult_wrap);
  221 +end
  222 +
  223 +
  224 +// 1、启用日期 < 开始日期
  225 +// 2、如果最近的排班规则历史时间在 (启用日期,开始日期) 之间,需要重新修正预处理数据
  226 +rule "calcu_days_1_with_result"
  227 + no-loop
  228 + salience 960
  229 + when
  230 + $cdrp: Calcu_days_result_pre(
  231 + calcu_start_date_1.isBefore(calcu_start_date_2),
  232 + $ruleId: ruleId,
  233 + $ruleMd5: ruleMd5,
  234 + $ruleEcCount: ruleEcCount
  235 + )
  236 + $srrr_wrap: SchedulePlanRuleResult_wrap(
  237 +// ruleId == $ruleId,
  238 + ruleMd5 == $ruleMd5,
  239 + scheduleDate.isAfter($cdrp.calcu_start_date_1),
  240 + scheduleDate.isBefore($cdrp.calcu_start_date_2),
  241 + isUsed == false,
  242 + $scheduleDate: scheduleDate,
  243 + $self: self
  244 + )
  245 + then
  246 + // 修正排班数据
  247 +// log.info("准备修正 ruleId={} historyDate={}", $ruleId, $scheduleDate);
  248 +
  249 + // 路牌范围起始index使用历史数据
  250 + $cdrp.setCalcu_index_lp(Integer.valueOf($self.getGidindex()));
  251 + // 人员范围起始index,需要判定,如果长度都是一样的,使用历史的,否则不更新,使用最新的
  252 + String history_ecids = $self.getEcids();
  253 + if ($ruleEcCount == history_ecids.split(",").length) {
  254 + $cdrp.setCalcu_index_ry(Integer.valueOf($self.getEcindex()));
  255 + }
  256 +
  257 + // 翻班格式利用路牌的历史index更新
  258 + int fb_temp = Integer.valueOf($self.getGidindex()) % $cdrp.getFbweeks().size();
  259 + $cdrp.setFbgs_index(fb_temp);
  260 +
  261 + $cdrp.setCalcu_start_date_1($scheduleDate);
  262 + update($cdrp);
  263 +
  264 + $srrr_wrap.setIsUsed(true);
  265 + update($srrr_wrap);
  266 +
  267 +end
  268 +
  269 +
  270 +
  271 +//------------------------- 第二阶段、计算规则准备数据2(第一组循环) ----------------------------//
  272 +
  273 +function void calcu_loop1_fb(Calcu_days_result_pre $cdrp, ScheduleRule_input $sri, Logger log) {
  274 + Integer $lpindex = $cdrp.getCalcu_index_lp();
  275 + Integer $lprangesize = $sri.getGuideboardIds().size();
  276 + Integer $ryindex = $cdrp.getCalcu_index_ry();
  277 + Integer $ryrangesize = $sri.getEmployeeConfigIds().size();
  278 + Integer $fbindex = $cdrp.getFbgs_index();
  279 + Integer $fbfangesize = $sri.getWeekdays().size();
  280 + DateTime $csd1 = $cdrp.getCalcu_start_date_1();
  281 + DateTime $ced1 = $cdrp.getCalcu_end_date_1();
  282 +
  283 + String $ruleId = $cdrp.getRuleId();
  284 +
  285 + $cdrp.setCalcu_index_lp(($lpindex + 1) % $lprangesize);
  286 + $cdrp.setCalcu_index_ry(($ryindex + 1) % $ryrangesize);
  287 +
  288 + $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);
  289 + $cdrp.setCalcu_start_date_1($csd1.plusDays(1));
  290 +
  291 +// log.info("calcu_loop1_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",
  292 +// $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd1, $ced1);
  293 +
  294 +}
  295 +function void calcu_loop1_not_fb(Calcu_days_result_pre $cdrp, ScheduleRule_input $sri, Logger log) {
  296 + DateTime $csd1 = $cdrp.getCalcu_start_date_1();
  297 + DateTime $ced1 = $cdrp.getCalcu_end_date_1();
  298 + Integer $fbindex = $cdrp.getFbgs_index();
  299 + Integer $fbfangesize = $sri.getWeekdays().size();
  300 +
  301 + $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);
  302 + $cdrp.setCalcu_start_date_1($csd1.plusDays(1));
  303 +
  304 +// log.info("calcu_loop1_not_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",
  305 +// $cdrp.getRuleId(), $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd1, $ced1);
  306 +}
  307 +
  308 +
  309 +rule "Calcu_loop1_fbtype_with_0_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是false,就跳过
  310 + salience 900
  311 + when
  312 + $cdrp: Calcu_days_result_pre(
  313 + calcu_start_date_1.isBefore(calcu_end_date_1),
  314 + $ruleId: ruleId,
  315 + fbtype == "1",
  316 + $fbindex : fbgs_index
  317 + )
  318 + $sri: ScheduleRule_input(
  319 + ruleId == $ruleId,
  320 + weekdays[$fbindex] == false
  321 + )
  322 + then
  323 + calcu_loop1_not_fb($cdrp, $sri, log);
  324 + update($cdrp);
  325 +end
  326 +
  327 +rule "Calcu_loop1_fbtype_with_1_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里存在指定路牌,就翻
  328 + salience 900
  329 + when
  330 + $cdrp: Calcu_days_result_pre(
  331 + calcu_start_date_1.isBefore(calcu_end_date_1),
  332 + $csd1: calcu_start_date_1,
  333 + $ruleId: ruleId,
  334 + fbtype == "1",
  335 + $lpindex: calcu_index_lp,
  336 + $fbindex : fbgs_index
  337 + )
  338 + $sri: ScheduleRule_input(
  339 + ruleId == $ruleId,
  340 + $gids: guideboardIds,
  341 + weekdays[$fbindex] == true
  342 + )
  343 + $liro: LpInfoResult_output(
  344 + dateTime.isEqual($csd1),
  345 + $gids[$lpindex] == lpId
  346 + )
  347 + then
  348 + calcu_loop1_fb($cdrp, $sri, log);
  349 + update($cdrp);
  350 +
  351 +end
  352 +
  353 +rule "Calcu_loop1_fbtype_with_1_no_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里不存在指定路牌,就跳过
  354 + salience 900
  355 + when
  356 + $cdrp: Calcu_days_result_pre(
  357 + calcu_start_date_1.isBefore(calcu_end_date_1),
  358 + $csd1: calcu_start_date_1,
  359 + $ruleId: ruleId,
  360 + fbtype == "1",
  361 + $fbindex : fbgs_index
  362 + )
  363 + $sri: ScheduleRule_input(
  364 + ruleId == $ruleId,
  365 + weekdays[$fbindex] == true
  366 + )
  367 + then
  368 + calcu_loop1_not_fb($cdrp, $sri, log);
  369 + update($cdrp);
  370 +end
  371 +
  372 +
  373 +rule "Calcu_loop1_timetabletype_with_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中存在,就翻
  374 + salience 900
  375 + when
  376 + $cdrp: Calcu_days_result_pre(
  377 + calcu_start_date_1.isBefore(calcu_end_date_1),
  378 + $csd1: calcu_start_date_1,
  379 + $ruleId: ruleId,
  380 + fbtype == "0",
  381 + $lpindex: calcu_index_lp
  382 + )
  383 + $sri: ScheduleRule_input(
  384 + ruleId == $ruleId,
  385 + $gids: guideboardIds
  386 + )
  387 + $liro: LpInfoResult_output(
  388 + dateTime.isEqual($csd1),
  389 + $gids[$lpindex] == lpId
  390 + )
  391 + then
  392 + calcu_loop1_fb($cdrp, $sri, log);
  393 + update($cdrp);
  394 +end
  395 +
  396 +rule "Calcu_loop1_timetabletype_with_no_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中不存在,就跳过
  397 + salience 900
  398 + when
  399 + $cdrp: Calcu_days_result_pre(
  400 + calcu_start_date_1.isBefore(calcu_end_date_1),
  401 + $csd1: calcu_start_date_1,
  402 + $ruleId: ruleId,
  403 + fbtype == "0"
  404 + )
  405 + $sri: ScheduleRule_input(
  406 + ruleId == $ruleId
  407 + )
  408 + then
  409 + calcu_loop1_not_fb($cdrp, $sri, log);
  410 + update($cdrp);
  411 +end
  412 +
  413 +//------------------------- 第三阶段、计算规则准备数据2(第二组循环) ----------------------------//
  414 +
  415 +function void calcu_loop2_fb(
  416 + SchedulePlan $sp,
  417 + Calcu_days_result_pre $cdrp,
  418 + ScheduleRule_input $sri,
  419 + LpInfoResult_output $liro,
  420 + ScheduleResults_output rs,
  421 + Logger log) {
  422 + String $ruleId = $cdrp.getRuleId();
  423 + DateTime $csd2 = $cdrp.getCalcu_start_date_2();
  424 + DateTime $ced2 = $cdrp.getCalcu_end_date_2();
  425 + Integer $lpindex = $cdrp.getCalcu_index_lp();
  426 + List $gids = $sri.getGuideboardIds();
  427 + Integer $lprangesize = $sri.getGuideboardIds().size();
  428 + Integer $ryindex = $cdrp.getCalcu_index_ry();
  429 + List $eids = $sri.getEmployeeConfigIds();
  430 + Integer $ryrangesize = $sri.getEmployeeConfigIds().size();
  431 + Integer $fbindex = $cdrp.getFbgs_index();
  432 + Integer $fbfangesize = $sri.getWeekdays().size();
  433 + String $cid = $sri.getCarConfigId();
  434 + String $xlid = $sri.getXlId();
  435 +
  436 + com.bsth.entity.schedule.rule.ScheduleRule1Flat $srf = $sri.getSelf();
  437 +
  438 + String $ttinfoId = $liro.getTtInfoId();
  439 + String $ttinfoName = $liro.getTtInfoName();
  440 +
  441 + ScheduleResult_output ro = new ScheduleResult_output();
  442 + ro.setRuleId($ruleId);
  443 + ro.setSd($csd2);
  444 + ro.setGuideboardId(String.valueOf($gids.get($lpindex)));
  445 + ro.setEmployeeConfigId(String.valueOf($eids.get($ryindex)));
  446 + ro.setCarConfigId($cid);
  447 + ro.setXlId($xlid);
  448 +
  449 + // 类型
  450 + ro.setsType($sri.getsType());
  451 +
  452 + rs.getResults().add(ro);
  453 +
  454 +// log.info("gogoogogogogo");
  455 +
  456 + $cdrp.setCalcu_index_lp(($lpindex + 1) % $lprangesize);
  457 + $cdrp.setCalcu_index_ry(($ryindex + 1) % $ryrangesize);
  458 +
  459 + $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);
  460 + $cdrp.setCalcu_start_date_2($csd2.plusDays(1));
  461 +
  462 + if ($sri.getsType() == ScheduleRule_Type.NORMAL) {
  463 + // 保存排班规则循环结果 --> SchedulePlanRuleResult
  464 + SchedulePlanRuleResult schedulePlanRuleResult = new SchedulePlanRuleResult($sp);
  465 +// schedulePlanRuleResult.setXlId(String.valueOf($srf.getXl().getId()));
  466 + schedulePlanRuleResult.setXlId($srf.getXl().getId());
  467 + schedulePlanRuleResult.setXlName($srf.getXl().getName());
  468 + schedulePlanRuleResult.setRuleId($ruleId);
  469 + schedulePlanRuleResult.setCcId($cid);
  470 + schedulePlanRuleResult.setCcZbh($srf.getCarConfigInfo().getCl().getInsideCode());
  471 + schedulePlanRuleResult.setGids($srf.getLpIds()); // 参与md5计算
  472 + schedulePlanRuleResult.setGnames($srf.getLpNames());
  473 + schedulePlanRuleResult.setGidindex(String.valueOf($lpindex));
  474 + schedulePlanRuleResult.setEcids($srf.getRyConfigIds());
  475 + schedulePlanRuleResult.setEcdbbms($srf.getRyDbbms());
  476 + schedulePlanRuleResult.setEcindex(String.valueOf($ryindex));
  477 + schedulePlanRuleResult.setScheduleDate($csd2.toDate());
  478 + schedulePlanRuleResult.setTtinfoId($ttinfoId);
  479 + schedulePlanRuleResult.setTtinfoName($ttinfoName);
  480 + schedulePlanRuleResult.setQyrq($sri.getQyrq().toDate()); // 参与md5计算
  481 + schedulePlanRuleResult.setOrigingidindex(String.valueOf($sri.getSelf().getLpStart())); // 参与md5计算
  482 +
  483 + rs.getSchedulePlanRuleResults().add(schedulePlanRuleResult);
  484 + }
  485 +
  486 +
  487 +
  488 +// log.info("calcu_loop2_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",
  489 +// $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd2, $ced2);
  490 +
  491 +}
  492 +
  493 +function void calcu_loop2_not_fb(
  494 + Calcu_days_result_pre $cdrp,
  495 + ScheduleRule_input $sri,
  496 + ScheduleResults_output rs,
  497 + Logger log) {
  498 +
  499 + String $ruleId = $cdrp.getRuleId();
  500 + DateTime $csd2 = $cdrp.getCalcu_start_date_2();
  501 + DateTime $ced2 = $cdrp.getCalcu_end_date_2();
  502 + Integer $lpindex = $cdrp.getCalcu_index_lp();
  503 + List $gids = $sri.getGuideboardIds();
  504 + Integer $ryindex = $cdrp.getCalcu_index_ry();
  505 + List $eids = $sri.getEmployeeConfigIds();
  506 + Integer $fbindex = $cdrp.getFbgs_index();
  507 + Integer $fbfangesize = $sri.getWeekdays().size();
  508 + String $cid = $sri.getCarConfigId();
  509 + String $xlid = $sri.getXlId();
  510 +
  511 + ScheduleResult_output ro = new ScheduleResult_output();
  512 + ro.setRuleId($ruleId);
  513 + ro.setSd($csd2);
  514 +// ro.setGuideboardId(String.valueOf($gids.get($lpindex)));
  515 + ro.setGuideboardId("not_fb_lp"); // 不翻班,路牌id用假的,后面会过滤
  516 + ro.setEmployeeConfigId(String.valueOf($eids.get($ryindex)));
  517 + ro.setCarConfigId($cid);
  518 + ro.setXlId($xlid);
  519 +
  520 + // 类型
  521 + ro.setsType($sri.getsType());
  522 +
  523 + rs.getResults().add(ro);
  524 +
  525 + $cdrp.setFbgs_index(($fbindex + 1) % $fbfangesize);
  526 + $cdrp.setCalcu_start_date_2($csd2.plusDays(1));
  527 +
  528 +// log.info("calcu_loop2_not_fb ruleId={}, calcu_index_lp/ry={}/{}, from={}, to={}",
  529 +// $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry(), $csd2, $ced2);
  530 +
  531 +}
  532 +
  533 +rule "Calcu_loop2_fbtype_with_0_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是false,就跳过
  534 + salience 800
  535 + when
  536 + ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)
  537 + $cdrp: Calcu_days_result_pre(
  538 + calcu_start_date_1.isEqual(calcu_end_date_1),
  539 + calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),
  540 + $ruleId: ruleId,
  541 + fbtype == "1",
  542 + $fbindex : fbgs_index
  543 + )
  544 + $sri: ScheduleRule_input(
  545 + ruleId == $ruleId,
  546 + weekdays[$fbindex] == false
  547 + )
  548 + then
  549 + calcu_loop2_not_fb($cdrp, $sri, scheduleResult, log);
  550 + update($cdrp);
  551 +
  552 +end
  553 +
  554 +rule "Calcu_loop2_fbtype_with_1_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里存在指定路牌,就翻
  555 + salience 800
  556 + when
  557 + ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)
  558 + $cdrp: Calcu_days_result_pre(
  559 + calcu_start_date_1.isEqual(calcu_end_date_1),
  560 + calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),
  561 + $csd2: calcu_start_date_2,
  562 + $ruleId: ruleId,
  563 + fbtype == "1",
  564 + $lpindex: calcu_index_lp,
  565 + $fbindex : fbgs_index
  566 + )
  567 + $sri: ScheduleRule_input(
  568 + ruleId == $ruleId,
  569 + $gids: guideboardIds,
  570 + weekdays[$fbindex] == true
  571 + )
  572 + $liro: LpInfoResult_output(
  573 + dateTime.isEqual($csd2),
  574 + $gids[$lpindex] == lpId
  575 + )
  576 + then
  577 + calcu_loop2_fb($sp, $cdrp, $sri, $liro, scheduleResult, log);
  578 + update($cdrp);
  579 +end
  580 +
  581 +rule "Calcu_loop2_fbtype_with_1_no_lp_" // 翻班模式为 type=1 使用翻班格式翻,当天翻班格式是true,并且当天时刻表里不存在指定路牌,就跳过
  582 + salience 800
  583 + when
  584 + ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)
  585 + $cdrp: Calcu_days_result_pre(
  586 + calcu_start_date_1.isEqual(calcu_end_date_1),
  587 + calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),
  588 + $ruleId: ruleId,
  589 + fbtype == "1",
  590 + $fbindex : fbgs_index
  591 + )
  592 + $sri: ScheduleRule_input(
  593 + ruleId == $ruleId,
  594 + weekdays[$fbindex] == true
  595 + )
  596 + then
  597 + calcu_loop2_not_fb($cdrp, $sri, scheduleResult, log);
  598 + update($cdrp);
  599 +
  600 +end
  601 +
  602 +rule "Calcu_loop2_timetabletype_with_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中存在,就翻
  603 + salience 800
  604 + when
  605 + ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)
  606 + $cdrp: Calcu_days_result_pre(
  607 + calcu_start_date_1.isEqual(calcu_end_date_1),
  608 + calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),
  609 + $csd2: calcu_start_date_2,
  610 + $ruleId: ruleId,
  611 + fbtype == "0",
  612 + $lpindex: calcu_index_lp,
  613 + $fbindex : fbgs_index
  614 + )
  615 + $sri: ScheduleRule_input(
  616 + ruleId == $ruleId,
  617 + $gids: guideboardIds
  618 + )
  619 + $liro: LpInfoResult_output(
  620 + dateTime.isEqual($csd2),
  621 + $gids[$lpindex] == lpId
  622 + )
  623 + then
  624 + calcu_loop2_fb($sp, $cdrp, $sri, $liro, scheduleResult, log);
  625 + update($cdrp);
  626 +
  627 +end
  628 +
  629 +rule "Calcu_loop2_timetabletype_with_no_lp_" // 翻班模式为 type=0 使用时刻表格式翻,路牌在时刻表中不存在,就跳过
  630 + salience 800
  631 + when
  632 + ScheduleCalcuParam_input($sp: schedulePlan, $xlid: xlId)
  633 + $cdrp: Calcu_days_result_pre(
  634 + calcu_start_date_1.isEqual(calcu_end_date_1),
  635 + calcu_start_date_2.isBefore(calcu_end_date_2) || calcu_start_date_2.isEqual(calcu_end_date_2),
  636 + $ruleId: ruleId,
  637 + fbtype == "0"
  638 + )
  639 + $sri: ScheduleRule_input(
  640 + ruleId == $ruleId
  641 + )
  642 + then
  643 + calcu_loop2_not_fb($cdrp, $sri, scheduleResult, log);
  644 + update($cdrp);
  645 +end
  646 +
  647 +
  648 +
  649 +
  650 +
  651 +
  652 +
  653 +
src/main/resources/rules/kBase1_core_ttinfo.drl
1 -package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;  
2 -  
3 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidsCountFunction gidscount;  
4 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbTimeFunction gidfbtime;  
5 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbFcnoFunction gidfbfcno;  
6 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResultsFunction lpinforesult;  
7 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.MinRuleQyrqFunction minruleqyrq;  
8 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidRepeatBcFunction vrb;  
9 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWholeRerunBcFunction vwrb;  
10 -import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWantLpFunction vwlp;  
11 -  
12 -import org.joda.time.*;  
13 -import java.util.*;  
14 -  
15 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoCalcuParam_input;  
16 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfo_input;  
17 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResult_output;  
18 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResults_output;  
19 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;  
20 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResults_output;  
21 -  
22 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;  
23 -  
24 -import com.bsth.repository.schedule.TTInfoDetailRepository;  
25 -  
26 -import com.bsth.entity.schedule.TTInfo;  
27 -import com.bsth.entity.schedule.TTInfoDetail;  
28 -  
29 -import org.slf4j.Logger  
30 -  
31 -// 全局日志  
32 -global Logger log;  
33 -// repostory  
34 -global TTInfoDetailRepository tTInfoDetailRepository;  
35 -// return输出  
36 -global TTInfoResults_output results  
37 -global LpInfoResults_output lpInfoResults_output  
38 -  
39 -function Long ttidParams(List ttinfolist) {  
40 - // 获取第一张时刻表id  
41 - TTInfo_input ttInfo_input = (TTInfo_input) ttinfolist.get(0);  
42 - return Long.parseLong(ttInfo_input.getTtInfoId());  
43 -}  
44 -  
45 -/*  
46 - TODO:规则说明,以后待说明  
47 -*/  
48 -  
49 -//----------------- pre 预处理 param对象 -----------------------//  
50 -  
51 -rule "pre_calcu_TTInfoCalcuParam_input"  
52 - no-loop  
53 - salience 1000  
54 - when  
55 - $ttp: TTInfoCalcuParam_input($xlId : xlId)  
56 - $minqyrq: DateTime() from accumulate ($sri: ScheduleRule_input(xlId == $xlId), minruleqyrq($sri))  
57 - then  
58 - $ttp.setFromDate($minqyrq);  
59 - update($ttp);  
60 -end  
61 -  
62 -//----------------- 第一阶段、计算规则准备数据(天数)----------------//  
63 -  
64 -declare Calcu_days_result  
65 - calcu_day : Integer // 该计算第几天  
66 - calcu_weekday : Integer // 星期几(1到7)  
67 - calcu_date : DateTime // 该计算的具体日期  
68 - calcu_days : Integer // 总共需要计算的天数  
69 - calcu_start_date : DateTime // 开始计算日期  
70 - calcu_end_date : DateTime // 结束计算日期  
71 - xlId : String // 线路Id  
72 -end  
73 -  
74 -rule "calcu_days"  
75 - when  
76 - TTInfoCalcuParam_input(  
77 - $fromDate : fromDate,  
78 - $toDate : toDate,  
79 - $xlId : xlId,  
80 - $fromDate.isBefore($toDate) || $fromDate.isEqual($toDate))  
81 - then  
82 - // 构造Calcu_days_result对象,进行下一阶段计算  
83 - Calcu_days_result cdr = new Calcu_days_result();  
84 - Period p = new Period($fromDate, $toDate, PeriodType.days());  
85 -  
86 - cdr.setCalcu_day(1);  
87 - cdr.setCalcu_date($fromDate);  
88 - cdr.setCalcu_days(p.getDays() + 1);  
89 - cdr.setCalcu_weekday($fromDate.getDayOfWeek());  
90 - cdr.setCalcu_start_date($fromDate);  
91 - cdr.setCalcu_end_date(($toDate));  
92 - cdr.setXlId($xlId);  
93 -  
94 -// log.info("总共需要计算的天数 calcu_days={} 之后的计算从第1天开始 ", p.getDays() + 1);  
95 -  
96 - insert(cdr); // 插入fact数据,进入下一个阶段  
97 -end  
98 -  
99 -//----------------- 第二阶段、判定时刻表是否启用 ----------------//  
100 -  
101 -declare Calcu_ttinfo_enable_result  
102 - xlId : String // 线路id  
103 - ttInfo_input_list : ArrayList // 可用时刻表列表  
104 - calcu_date : DateTime // 计算日期  
105 -end  
106 -  
107 -rule "calcu_ttinfo_enable"  
108 - salience 900  
109 - when  
110 - $calcu_days_result : Calcu_days_result($calcu_date : calcu_date, calcu_day <= calcu_days, $xlId : xlId)  
111 - $ttInfo_input_list : ArrayList(size >= 1) from collect (TTInfo_input(xlId == $xlId, isEnable == true))  
112 - then  
113 - // 构造Calcu_ttinfo_enable_result对象,进行下一步计算  
114 - Calcu_ttinfo_enable_result cter = new Calcu_ttinfo_enable_result();  
115 - cter.setXlId($xlId);  
116 - cter.setTtInfo_input_list($ttInfo_input_list);  
117 - cter.setCalcu_date($calcu_date);  
118 -  
119 -// log.info("启用的时刻表:xlId={} 时刻表个数={}", $xlId, $ttInfo_input_list.size());  
120 -  
121 - insert (cter);  
122 -  
123 -end  
124 -  
125 -//----------------- 第三阶段、时刻表的日期匹配 -------------------//  
126 -  
127 -rule "calcu_ttinfo_special_day" // 特殊日期匹配  
128 - salience 800  
129 - when  
130 - $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)  
131 - $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day)  
132 - $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays contains $calcu_date) from $ttInfo_input_list)  
133 - $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))  
134 - then  
135 - // 更新Calcu_days_result对象  
136 - int new_calcu_day = $calcu_day + 1;  
137 - $calcu_days_result.setCalcu_day(new_calcu_day);  
138 - DateTime new_calcu_date = $calcu_date.plusDays(1);  
139 - $calcu_days_result.setCalcu_date(new_calcu_date);  
140 - $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek());  
141 -  
142 -// log.info("启用特殊日期时刻表:xlId={} 时刻表个数={} 特殊日期={}", $xlId, $ttinfolist.size(), $calcu_date);  
143 -  
144 - // $ttinfolist按时间倒排序,result输出  
145 - Collections.sort($ttinfolist);  
146 - results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);  
147 -  
148 - // lp输出  
149 - for (int i = 0; i < $lpInfoResults.size(); i++) {  
150 - LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);  
151 - lpInfoResult_output.setDateTime($calcu_date); // 设定时间  
152 - lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);  
153 - }  
154 -  
155 - update($calcu_days_result);  
156 -end  
157 -  
158 -rule "calcu_ttinfo_normal_day" // 平日匹配  
159 - salience 700  
160 - when  
161 - $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)  
162 - $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)  
163 - $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == true) from $ttInfo_input_list)  
164 - $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))  
165 - then  
166 - // 更新Calcu_days_result对象  
167 - int new_calcu_day = $calcu_day + 1;  
168 - $calcu_days_result.setCalcu_day(new_calcu_day);  
169 - DateTime new_calcu_date = $calcu_date.plusDays(1);  
170 - $calcu_days_result.setCalcu_date(new_calcu_date);  
171 - $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek());  
172 -  
173 -// log.info("启用常规日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={} 路牌size={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday, $lpInfoResults.size());  
174 -  
175 - // $ttinfolist按时间倒排序,result输出  
176 - Collections.sort($ttinfolist);  
177 - results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);  
178 -  
179 - // lp输出  
180 - for (int i = 0; i < $lpInfoResults.size(); i++) {  
181 - LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);  
182 - lpInfoResult_output.setDateTime($calcu_date); // 设定时间  
183 - lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);  
184 - }  
185 -  
186 - update($calcu_days_result);  
187 -end  
188 -  
189 -rule "calcu_ttinfo_other_day" // 都没有的情况下,匹配  
190 - salience 500  
191 - when  
192 - $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)  
193 - $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)  
194 - $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == false) from $ttInfo_input_list)  
195 - $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))  
196 - then  
197 - // 更新Calcu_days_result对象  
198 - int new_calcu_day = $calcu_day + 1;  
199 - $calcu_days_result.setCalcu_day(new_calcu_day);  
200 - DateTime new_calcu_date = $calcu_date.plusDays(1);  
201 - $calcu_days_result.setCalcu_date(new_calcu_date);  
202 - $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek());  
203 -  
204 -// log.info("启用默认日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday);  
205 -  
206 - // $ttinfolist按时间倒排序,result输出  
207 - Collections.sort($ttinfolist);  
208 - results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);  
209 -  
210 - // lp输出  
211 - for (int i = 0; i < $lpInfoResults.size(); i++) {  
212 - LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);  
213 - lpInfoResult_output.setDateTime($calcu_date); // 设定时间  
214 - lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);  
215 - }  
216 -  
217 - update($calcu_days_result);  
218 - 1 +package com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo;
  2 +
  3 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidsCountFunction gidscount;
  4 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbTimeFunction gidfbtime;
  5 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.GidFbFcnoFunction gidfbfcno;
  6 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResultsFunction lpinforesult;
  7 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.MinRuleQyrqFunction minruleqyrq;
  8 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidRepeatBcFunction vrb;
  9 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWholeRerunBcFunction vwrb;
  10 +import accumulate com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidWantLpFunction vwlp;
  11 +
  12 +import org.joda.time.*;
  13 +import java.util.*;
  14 +
  15 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoCalcuParam_input;
  16 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfo_input;
  17 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResult_output;
  18 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.TTInfoResults_output;
  19 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;
  20 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResults_output;
  21 +
  22 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;
  23 +
  24 +import com.bsth.repository.schedule.TTInfoDetailRepository;
  25 +
  26 +import com.bsth.entity.schedule.TTInfo;
  27 +import com.bsth.entity.schedule.TTInfoDetail;
  28 +
  29 +import org.slf4j.Logger
  30 +
  31 +// 全局日志
  32 +global Logger log;
  33 +// repostory
  34 +global TTInfoDetailRepository tTInfoDetailRepository;
  35 +// return输出
  36 +global TTInfoResults_output results
  37 +global LpInfoResults_output lpInfoResults_output
  38 +
  39 +function Long ttidParams(List ttinfolist) {
  40 + // 获取第一张时刻表id
  41 + TTInfo_input ttInfo_input = (TTInfo_input) ttinfolist.get(0);
  42 + return Long.parseLong(ttInfo_input.getTtInfoId());
  43 +}
  44 +
  45 +/*
  46 + TODO:规则说明,以后待说明
  47 +*/
  48 +
  49 +//----------------- pre 预处理 param对象 -----------------------//
  50 +
  51 +rule "pre_calcu_TTInfoCalcuParam_input"
  52 + no-loop
  53 + salience 1000
  54 + when
  55 + $ttp: TTInfoCalcuParam_input($xlId : xlId)
  56 + $minqyrq: DateTime() from accumulate ($sri: ScheduleRule_input(xlId == $xlId), minruleqyrq($sri))
  57 + then
  58 + $ttp.setFromDate($minqyrq);
  59 + update($ttp);
  60 +end
  61 +
  62 +//----------------- 第一阶段、计算规则准备数据(天数)----------------//
  63 +
  64 +declare Calcu_days_result
  65 + calcu_day : Integer // 该计算第几天
  66 + calcu_weekday : Integer // 星期几(1到7)
  67 + calcu_date : DateTime // 该计算的具体日期
  68 + calcu_days : Integer // 总共需要计算的天数
  69 + calcu_start_date : DateTime // 开始计算日期
  70 + calcu_end_date : DateTime // 结束计算日期
  71 + xlId : String // 线路Id
  72 +end
  73 +
  74 +rule "calcu_days"
  75 + when
  76 + TTInfoCalcuParam_input(
  77 + $fromDate : fromDate,
  78 + $toDate : toDate,
  79 + $xlId : xlId,
  80 + $fromDate.isBefore($toDate) || $fromDate.isEqual($toDate))
  81 + then
  82 + // 构造Calcu_days_result对象,进行下一阶段计算
  83 + Calcu_days_result cdr = new Calcu_days_result();
  84 + Period p = new Period($fromDate, $toDate, PeriodType.days());
  85 +
  86 + cdr.setCalcu_day(1);
  87 + cdr.setCalcu_date($fromDate);
  88 + cdr.setCalcu_days(p.getDays() + 1);
  89 + cdr.setCalcu_weekday($fromDate.getDayOfWeek());
  90 + cdr.setCalcu_start_date($fromDate);
  91 + cdr.setCalcu_end_date(($toDate));
  92 + cdr.setXlId($xlId);
  93 +
  94 +// log.info("总共需要计算的天数 calcu_days={} 之后的计算从第1天开始 ", p.getDays() + 1);
  95 +
  96 + insert(cdr); // 插入fact数据,进入下一个阶段
  97 +end
  98 +
  99 +//----------------- 第二阶段、判定时刻表是否启用 ----------------//
  100 +
  101 +declare Calcu_ttinfo_enable_result
  102 + xlId : String // 线路id
  103 + ttInfo_input_list : ArrayList // 可用时刻表列表
  104 + calcu_date : DateTime // 计算日期
  105 +end
  106 +
  107 +rule "calcu_ttinfo_enable"
  108 + salience 900
  109 + when
  110 + $calcu_days_result : Calcu_days_result($calcu_date : calcu_date, calcu_day <= calcu_days, $xlId : xlId)
  111 + $ttInfo_input_list : ArrayList(size >= 1) from collect (TTInfo_input(xlId == $xlId, isEnable == true))
  112 + then
  113 + // 构造Calcu_ttinfo_enable_result对象,进行下一步计算
  114 + Calcu_ttinfo_enable_result cter = new Calcu_ttinfo_enable_result();
  115 + cter.setXlId($xlId);
  116 + cter.setTtInfo_input_list($ttInfo_input_list);
  117 + cter.setCalcu_date($calcu_date);
  118 +
  119 +// log.info("启用的时刻表:xlId={} 时刻表个数={}", $xlId, $ttInfo_input_list.size());
  120 +
  121 + insert (cter);
  122 +
  123 +end
  124 +
  125 +//----------------- 第三阶段、时刻表的日期匹配 -------------------//
  126 +
  127 +rule "calcu_ttinfo_special_day" // 特殊日期匹配
  128 + salience 800
  129 + when
  130 + $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
  131 + $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day)
  132 + $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays contains $calcu_date) from $ttInfo_input_list)
  133 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))
  134 + then
  135 + // 更新Calcu_days_result对象
  136 + int new_calcu_day = $calcu_day + 1;
  137 + $calcu_days_result.setCalcu_day(new_calcu_day);
  138 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  139 + $calcu_days_result.setCalcu_date(new_calcu_date);
  140 + $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek());
  141 +
  142 +// log.info("启用特殊日期时刻表:xlId={} 时刻表个数={} 特殊日期={}", $xlId, $ttinfolist.size(), $calcu_date);
  143 +
  144 + // $ttinfolist按时间倒排序,result输出
  145 + Collections.sort($ttinfolist);
  146 + results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);
  147 +
  148 + // lp输出
  149 + for (int i = 0; i < $lpInfoResults.size(); i++) {
  150 + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);
  151 + lpInfoResult_output.setDateTime($calcu_date); // 设定时间
  152 + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);
  153 + }
  154 +
  155 + update($calcu_days_result);
  156 +end
  157 +
  158 +rule "calcu_ttinfo_normal_day" // 平日匹配
  159 + salience 700
  160 + when
  161 + $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
  162 + $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)
  163 + $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == true) from $ttInfo_input_list)
  164 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))
  165 + then
  166 + // 更新Calcu_days_result对象
  167 + int new_calcu_day = $calcu_day + 1;
  168 + $calcu_days_result.setCalcu_day(new_calcu_day);
  169 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  170 + $calcu_days_result.setCalcu_date(new_calcu_date);
  171 + $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek());
  172 +
  173 +// log.info("启用常规日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={} 路牌size={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday, $lpInfoResults.size());
  174 +
  175 + // $ttinfolist按时间倒排序,result输出
  176 + Collections.sort($ttinfolist);
  177 + results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);
  178 +
  179 + // lp输出
  180 + for (int i = 0; i < $lpInfoResults.size(); i++) {
  181 + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);
  182 + lpInfoResult_output.setDateTime($calcu_date); // 设定时间
  183 + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);
  184 + }
  185 +
  186 + update($calcu_days_result);
  187 +end
  188 +
  189 +rule "calcu_ttinfo_other_day" // 都没有的情况下,匹配
  190 + salience 500
  191 + when
  192 + $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
  193 + $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)
  194 + $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == false) from $ttInfo_input_list)
  195 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))
  196 + then
  197 + // 更新Calcu_days_result对象
  198 + int new_calcu_day = $calcu_day + 1;
  199 + $calcu_days_result.setCalcu_day(new_calcu_day);
  200 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  201 + $calcu_days_result.setCalcu_date(new_calcu_date);
  202 + $calcu_days_result.setCalcu_weekday(new_calcu_date.getDayOfWeek());
  203 +
  204 +// log.info("启用默认日期时刻表:xlId={} 时刻表个数={} 常规日期={} 星期几={}", $xlId, $ttinfolist.size(), $calcu_date, $calcu_weekday);
  205 +
  206 + // $ttinfolist按时间倒排序,result输出
  207 + Collections.sort($ttinfolist);
  208 + results.addXlTTInfos($xlId, $calcu_date, $ttinfolist);
  209 +
  210 + // lp输出
  211 + for (int i = 0; i < $lpInfoResults.size(); i++) {
  212 + LpInfoResult_output lpInfoResult_output = (LpInfoResult_output) $lpInfoResults.get(i);
  213 + lpInfoResult_output.setDateTime($calcu_date); // 设定时间
  214 + lpInfoResults_output.getLpInfoResult_outputs().add(lpInfoResult_output);
  215 + }
  216 +
  217 + update($calcu_days_result);
  218 +
219 end 219 end
220 \ No newline at end of file 220 \ No newline at end of file
src/main/resources/rules/kBase1_core_validate.drl
1 -package com.bsth.service.schedule.impl.plan.kBase1.core.validate;  
2 -  
3 -import com.bsth.entity.schedule.SchedulePlanInfo;  
4 -import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;  
5 -import com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidateResource;  
6 -  
7 -import org.joda.time.*;  
8 -import java.util.*;  
9 -  
10 -import org.slf4j.Logger;  
11 -  
12 -// 全局日志类(一般使用调用此规则的service类)  
13 -global Logger log;  
14 -  
15 -// 输出  
16 -global ValidateResults_output validResult;  
17 -  
18 -//------------------------- 第一阶段、构造验证源 ----------------------------//  
19 -rule "Calcu_validate_resource"  
20 - salience 2000  
21 - when  
22 - $spi: SchedulePlanInfo($sd: scheduleDate)  
23 - $lpiList: ArrayList() from collect (LpInfoResult_output(dateTime.getMillis() == $sd.getTime()))  
24 - then  
25 - ValidateResource resource = new ValidateResource();  
26 - resource.setSd($sd);  
27 - resource.setSpi($spi);  
28 - resource.setLpiList($lpiList);  
29 -  
30 - insert(resource);  
31 -end  
32 -  
33 -//------------------------- 第二阶段、构造循环体 ----------------------------//  
34 -  
35 -declare Loop_param  
36 - start_date: DateTime // 开始日期(这个要不停的更新迭代)  
37 - end_date: DateTime // 结束日期  
38 - sdays: Integer // 总共循环的天数  
39 -end  
40 -  
41 -rule "Calcu_Loop_param"  
42 - salience 1000  
43 - when  
44 - ValidateParam(  
45 - $fd: fromDate,  
46 - $ed: toDate,  
47 - $days: days  
48 - )  
49 - then  
50 - Loop_param p = new Loop_param();  
51 - p.setStart_date($fd);  
52 - p.setEnd_date($ed);  
53 - p.setSdays($days);  
54 -  
55 - insert(p);  
56 -end  
57 -  
58 -//------------------------- 第三阶段、验证计算 ----------------------------//  
59 -  
60 -  
61 -rule "Valid_repeat_bc" // 验证是否存在重复班次,未套跑班次,未执行路牌  
62 - salience 600  
63 - when  
64 - $lp: Loop_param($sd: start_date, $ed: end_date)  
65 - eval($sd.isBefore($ed) || $sd.isEqual($ed))  
66 - $vrList: ArrayList() from collect (ValidateResource(sd.getTime() == $sd.getMillis()))  
67 - $infos: ArrayList() from accumulate ($vr: ValidateResource() from $vrList, vrb($vr.getSpi()))  
68 - $infos2: ArrayList() from accumulate ($vr: ValidateResource() from $vrList, vwrb($vr.getSpi()))  
69 - $infos3: ArrayList() from accumulate ($vr: ValidateResource() from $vrList, vwlp($vr))  
70 - then  
71 - // TODO:  
72 -// log.info("日期={},班次重复错误数={}", $sd, $infos.size());  
73 -  
74 -// log.info("班次数={}", $vrList.size());  
75 -  
76 - validResult.getInfos().addAll($infos);  
77 - validResult.getInfos().addAll($infos2);  
78 - validResult.getInfos().addAll($infos3);  
79 -  
80 - // 迭代  
81 - $lp.setStart_date($sd.plusDays(1));  
82 - update($lp);  
83 -  
84 -end  
85 -  
86 -//  
87 -//declare LpInfo_wrap  
88 -// sd: DateTime // 具体日期  
89 -// lpId: Long // 路牌Id  
90 -// isPlan: Boolean = false // 是否排班  
91 -//end  
92 -//  
93 -//rule "Calcu_LpInfo_wrap"  
94 -// salience 500  
95 -// when  
96 -// $lp: LpInfoResult_output()  
97 -// then  
98 -// LpInfo_wrap ll = new LpInfo_wrap();  
99 -// ll.setSd($lp.getDateTime());  
100 -// ll.setLpId(Long.parseLong($lp.getLpId()));  
101 -//  
102 -// insert(ll);  
103 -//end  
104 -//  
105 -//rule "Valid_Lp_plan" // 查看路牌是否被排班  
106 -// salience 400  
107 -// no-loop  
108 -// when  
109 -// $sp: SchedulePlanInfo($lp: lp)  
110 -// $ll: LpInfo_wrap(lpId == $lp)  
111 -// then  
112 -// $ll.setIsPlan(true);  
113 -// update($ll);  
114 -//end  
115 -//  
116 -//// TODO:  
117 -  
118 -  
119 -  
120 -  
121 -  
122 -  
123 -  
124 -  
125 -  
126 - 1 +package com.bsth.service.schedule.impl.plan.kBase1.core.validate;
  2 +
  3 +import com.bsth.entity.schedule.SchedulePlanInfo;
  4 +import com.bsth.service.schedule.impl.plan.kBase1.core.ttinfo.LpInfoResult_output;
  5 +import com.bsth.service.schedule.impl.plan.kBase1.core.validate.ValidateResource;
  6 +
  7 +import org.joda.time.*;
  8 +import java.util.*;
  9 +
  10 +import org.slf4j.Logger;
  11 +
  12 +// 全局日志类(一般使用调用此规则的service类)
  13 +global Logger log;
  14 +
  15 +// 输出
  16 +global ValidateResults_output validResult;
  17 +
  18 +//------------------------- 第一阶段、构造验证源 ----------------------------//
  19 +rule "Calcu_validate_resource"
  20 + salience 2000
  21 + when
  22 + $spi: SchedulePlanInfo($sd: scheduleDate)
  23 + $lpiList: ArrayList() from collect (LpInfoResult_output(dateTime.getMillis() == $sd.getTime()))
  24 + then
  25 + ValidateResource resource = new ValidateResource();
  26 + resource.setSd($sd);
  27 + resource.setSpi($spi);
  28 + resource.setLpiList($lpiList);
  29 +
  30 + insert(resource);
  31 +end
  32 +
  33 +//------------------------- 第二阶段、构造循环体 ----------------------------//
  34 +
  35 +declare Loop_param
  36 + start_date: DateTime // 开始日期(这个要不停的更新迭代)
  37 + end_date: DateTime // 结束日期
  38 + sdays: Integer // 总共循环的天数
  39 +end
  40 +
  41 +rule "Calcu_Loop_param"
  42 + salience 1000
  43 + when
  44 + ValidateParam(
  45 + $fd: fromDate,
  46 + $ed: toDate,
  47 + $days: days
  48 + )
  49 + then
  50 + Loop_param p = new Loop_param();
  51 + p.setStart_date($fd);
  52 + p.setEnd_date($ed);
  53 + p.setSdays($days);
  54 +
  55 + insert(p);
  56 +end
  57 +
  58 +//------------------------- 第三阶段、验证计算 ----------------------------//
  59 +
  60 +
  61 +rule "Valid_repeat_bc" // 验证是否存在重复班次,未套跑班次,未执行路牌
  62 + salience 600
  63 + when
  64 + $lp: Loop_param($sd: start_date, $ed: end_date)
  65 + eval($sd.isBefore($ed) || $sd.isEqual($ed))
  66 + $vrList: ArrayList() from collect (ValidateResource(sd.getTime() == $sd.getMillis()))
  67 + $infos: ArrayList() from accumulate ($vr: ValidateResource() from $vrList, vrb($vr.getSpi()))
  68 + $infos2: ArrayList() from accumulate ($vr: ValidateResource() from $vrList, vwrb($vr.getSpi()))
  69 + $infos3: ArrayList() from accumulate ($vr: ValidateResource() from $vrList, vwlp($vr))
  70 + then
  71 + // TODO:
  72 +// log.info("日期={},班次重复错误数={}", $sd, $infos.size());
  73 +
  74 +// log.info("班次数={}", $vrList.size());
  75 +
  76 + validResult.getInfos().addAll($infos);
  77 + validResult.getInfos().addAll($infos2);
  78 + validResult.getInfos().addAll($infos3);
  79 +
  80 + // 迭代
  81 + $lp.setStart_date($sd.plusDays(1));
  82 + update($lp);
  83 +
  84 +end
  85 +
  86 +//
  87 +//declare LpInfo_wrap
  88 +// sd: DateTime // 具体日期
  89 +// lpId: Long // 路牌Id
  90 +// isPlan: Boolean = false // 是否排班
  91 +//end
  92 +//
  93 +//rule "Calcu_LpInfo_wrap"
  94 +// salience 500
  95 +// when
  96 +// $lp: LpInfoResult_output()
  97 +// then
  98 +// LpInfo_wrap ll = new LpInfo_wrap();
  99 +// ll.setSd($lp.getDateTime());
  100 +// ll.setLpId(Long.parseLong($lp.getLpId()));
  101 +//
  102 +// insert(ll);
  103 +//end
  104 +//
  105 +//rule "Valid_Lp_plan" // 查看路牌是否被排班
  106 +// salience 400
  107 +// no-loop
  108 +// when
  109 +// $sp: SchedulePlanInfo($lp: lp)
  110 +// $ll: LpInfo_wrap(lpId == $lp)
  111 +// then
  112 +// $ll.setIsPlan(true);
  113 +// update($ll);
  114 +//end
  115 +//
  116 +//// TODO:
  117 +
  118 +
  119 +
  120 +
  121 +
  122 +
  123 +
  124 +
  125 +
  126 +
src/main/resources/rules/kBase2_wrap_rule.drl
1 -package com.bsth.service.schedule.impl.plan.kBase2.wrap.rule;  
2 -  
3 -import org.joda.time.*;  
4 -import java.util.*;  
5 -import org.slf4j.Logger;  
6 -  
7 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleCalcuParam_input;  
8 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;  
9 -import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;  
10 -import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;  
11 -  
12 -import com.bsth.repository.schedule.RerunRuleRepository;  
13 -import com.bsth.repository.schedule.ScheduleRule1FlatRepository;  
14 -  
15 -import com.bsth.service.schedule.impl.plan.ScheduleRuleService;  
16 -  
17 -import com.bsth.entity.Line;  
18 -import com.bsth.entity.schedule.CarConfigInfo  
19 -import com.bsth.entity.schedule.EmployeeConfigInfo  
20 -import javax.print.attribute.standard.DateTimeAtCompleted;  
21 -  
22 -// 全局日志类(一般使用调用此规则的service类)  
23 -global Logger log;  
24 -  
25 -global ScheduleRule1FlatRepository srf;  
26 -global RerunRuleRepository rrr;  
27 -global ScheduleRuleService srservice;  
28 -global List sriList;  
29 -  
30 -  
31 -declare Sri_Wrap  
32 - xlId : String // 线路id  
33 - lpIds : List // 路牌id  
34 - srf : Object // ScheduleRule1Flat类型  
35 - sri : ScheduleRule_input; // ScheduleRule_input输入  
36 -end  
37 -  
38 -rule "rw1"  
39 - salience 1000  
40 - when  
41 - ScheduleCalcuParam_input(  
42 - $fromDate : fromDate,  
43 - $toDate : toDate,  
44 - $xlId: xlId  
45 - )  
46 - $srf : Object() from srf.findByXlId(Integer.parseInt($xlId))  
47 - then  
48 - // 创建Sri_Wrap  
49 - Sri_Wrap sw = new Sri_Wrap();  
50 - sw.setXlId($xlId);  
51 - sw.setSrf($srf);  
52 - ScheduleRule_input sri = new ScheduleRule_input((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf());  
53 - sw.setSri(sri);  
54 - sw.setLpIds(sri.getGuideboardIds());  
55 -  
56 - insert(sw);  
57 -  
58 -end  
59 -  
60 -rule "rw2"  
61 - salience 800  
62 - no-loop  
63 - when  
64 - ScheduleCalcuParam_input(  
65 - $fromDate : fromDate,  
66 - $toDate : toDate,  
67 - $xlId: xlId  
68 - )  
69 - $reu : RerunRule_input($lpId : lp) from srservice.findRerunrule(Integer.parseInt($xlId))  
70 - not Sri_Wrap(xlId == $xlId, lpIds contains $lpId)  
71 - then  
72 - // 套跑中有规则,主线路的路牌,主线路该路牌不存在,添加一个临时的,做处理  
73 - Sri_Wrap sw = new Sri_Wrap();  
74 - sw.setSrf(new com.bsth.entity.schedule.rule.ScheduleRule1Flat());  
75 - // 线路  
76 - Line xl = new Line();  
77 - xl.setId(Integer.valueOf($xlId));  
78 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setXl(xl);  
79 - // id,使用当前日期作为原始值加上路牌id最为临时id值  
80 - DateTime dt = new DateTime(new Date());  
81 - DateTime dt2 = new DateTime(dt.year().get(), dt.monthOfYear().get(), dt.dayOfMonth().get(), 0, 0, 0);  
82 - long id = (dt2.toDate().getTime() + Long.parseLong($lpId));  
83 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setId(id);  
84 - // 启用日期  
85 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setQyrq($fromDate.toDate());  
86 - // 车辆配置  
87 - CarConfigInfo cci = new CarConfigInfo();  
88 - cci.setId(new Date().getTime());  
89 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setCarConfigInfo(cci);  
90 - // 人员配置  
91 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyConfigIds("TEMP");  
92 - // 人员搭班编码  
93 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyDbbms("TEMP");  
94 - // 起始人员  
95 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyStart(1);  
96 - // 路牌id  
97 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setLpIds($lpId);  
98 - // 起始路牌  
99 - ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setLpStart(1);  
100 -  
101 - ScheduleRule_input sri = new ScheduleRule_input((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf());  
102 - sri.setsType(ScheduleRule_Type.RERUN);  
103 - sw.setSri(sri);  
104 -  
105 - sw.setXlId($xlId);  
106 -  
107 - List lpIds = new ArrayList();  
108 - lpIds.add($lpId);  
109 - sw.setLpIds(lpIds);  
110 -  
111 - insert(sw);  
112 -end  
113 -  
114 -rule "rw3"  
115 - salience 600  
116 - when  
117 - $sri_wrap : Sri_Wrap($sri : sri, $xlId: xlId, $lpIds : lpIds)  
118 - then  
119 - log.info("线路id={},type={},ruleId={},lpids={}", $xlId, $sri.getsType(), $sri.getRuleId(), $lpIds);  
120 - sriList.add($sri); 1 +package com.bsth.service.schedule.impl.plan.kBase2.wrap.rule;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +import org.slf4j.Logger;
  6 +
  7 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleCalcuParam_input;
  8 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_input;
  9 +import com.bsth.service.schedule.impl.plan.kBase1.core.shiftloop.ScheduleRule_Type;
  10 +import com.bsth.service.schedule.impl.plan.kBase1.core.rerun.RerunRule_input;
  11 +
  12 +import com.bsth.repository.schedule.RerunRuleRepository;
  13 +import com.bsth.repository.schedule.ScheduleRule1FlatRepository;
  14 +
  15 +import com.bsth.service.schedule.impl.plan.ScheduleRuleService;
  16 +
  17 +import com.bsth.entity.Line;
  18 +import com.bsth.entity.schedule.CarConfigInfo
  19 +import com.bsth.entity.schedule.EmployeeConfigInfo
  20 +import javax.print.attribute.standard.DateTimeAtCompleted;
  21 +
  22 +// 全局日志类(一般使用调用此规则的service类)
  23 +global Logger log;
  24 +
  25 +global ScheduleRule1FlatRepository srf;
  26 +global RerunRuleRepository rrr;
  27 +global ScheduleRuleService srservice;
  28 +global List sriList;
  29 +
  30 +
  31 +declare Sri_Wrap
  32 + xlId : String // 线路id
  33 + lpIds : List // 路牌id
  34 + srf : Object // ScheduleRule1Flat类型
  35 + sri : ScheduleRule_input; // ScheduleRule_input输入
  36 +end
  37 +
  38 +rule "rw1"
  39 + salience 1000
  40 + when
  41 + ScheduleCalcuParam_input(
  42 + $fromDate : fromDate,
  43 + $toDate : toDate,
  44 + $xlId: xlId
  45 + )
  46 + $srf : Object() from srf.findByXlId(Integer.parseInt($xlId))
  47 + then
  48 + // 创建Sri_Wrap
  49 + Sri_Wrap sw = new Sri_Wrap();
  50 + sw.setXlId($xlId);
  51 + sw.setSrf($srf);
  52 + ScheduleRule_input sri = new ScheduleRule_input((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf());
  53 + sw.setSri(sri);
  54 + sw.setLpIds(sri.getGuideboardIds());
  55 +
  56 + insert(sw);
  57 +
  58 +end
  59 +
  60 +rule "rw2"
  61 + salience 800
  62 + no-loop
  63 + when
  64 + ScheduleCalcuParam_input(
  65 + $fromDate : fromDate,
  66 + $toDate : toDate,
  67 + $xlId: xlId
  68 + )
  69 + $reu : RerunRule_input($lpId : lp) from srservice.findRerunrule(Integer.parseInt($xlId))
  70 + not Sri_Wrap(xlId == $xlId, lpIds contains $lpId)
  71 + then
  72 + // 套跑中有规则,主线路的路牌,主线路该路牌不存在,添加一个临时的,做处理
  73 + Sri_Wrap sw = new Sri_Wrap();
  74 + sw.setSrf(new com.bsth.entity.schedule.rule.ScheduleRule1Flat());
  75 + // 线路
  76 + Line xl = new Line();
  77 + xl.setId(Integer.valueOf($xlId));
  78 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setXl(xl);
  79 + // id,使用当前日期作为原始值加上路牌id最为临时id值
  80 + DateTime dt = new DateTime(new Date());
  81 + DateTime dt2 = new DateTime(dt.year().get(), dt.monthOfYear().get(), dt.dayOfMonth().get(), 0, 0, 0);
  82 + long id = (dt2.toDate().getTime() + Long.parseLong($lpId));
  83 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setId(id);
  84 + // 启用日期
  85 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setQyrq($fromDate.toDate());
  86 + // 车辆配置
  87 + CarConfigInfo cci = new CarConfigInfo();
  88 + cci.setId(new Date().getTime());
  89 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setCarConfigInfo(cci);
  90 + // 人员配置
  91 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyConfigIds("TEMP");
  92 + // 人员搭班编码
  93 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyDbbms("TEMP");
  94 + // 起始人员
  95 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setRyStart(1);
  96 + // 路牌id
  97 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setLpIds($lpId);
  98 + // 起始路牌
  99 + ((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf()).setLpStart(1);
  100 +
  101 + ScheduleRule_input sri = new ScheduleRule_input((com.bsth.entity.schedule.rule.ScheduleRule1Flat) sw.getSrf());
  102 + sri.setsType(ScheduleRule_Type.RERUN);
  103 + sw.setSri(sri);
  104 +
  105 + sw.setXlId($xlId);
  106 +
  107 + List lpIds = new ArrayList();
  108 + lpIds.add($lpId);
  109 + sw.setLpIds(lpIds);
  110 +
  111 + insert(sw);
  112 +end
  113 +
  114 +rule "rw3"
  115 + salience 600
  116 + when
  117 + $sri_wrap : Sri_Wrap($sri : sri, $xlId: xlId, $lpIds : lpIds)
  118 + then
  119 + log.info("线路id={},type={},ruleId={},lpids={}", $xlId, $sri.getsType(), $sri.getRuleId(), $lpIds);
  120 + sriList.add($sri);
121 end 121 end
122 \ No newline at end of file 122 \ No newline at end of file
src/main/resources/rules/kBase3_validate_rule.drl
1 -package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;  
2 -  
3 -import accumulate com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ErrorInfoFunction srif;  
4 -import accumulate com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.ErrorBcCountFunction ecount;  
5 -  
6 -import org.joda.time.*;  
7 -import java.util.*;  
8 -  
9 -import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam;  
10 -import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult;  
11 -import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult.ErrorInfo;  
12 -import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.WrapInput;  
13 -  
14 -import com.bsth.repository.schedule.ScheduleRule1FlatRepository  
15 -import com.bsth.repository.schedule.CarConfigInfoRepository;  
16 -import com.bsth.repository.schedule.GuideboardInfoRepository;  
17 -import com.bsth.repository.schedule.EmployeeConfigInfoRepository;  
18 -  
19 -import com.bsth.entity.schedule.rule.ScheduleRule1Flat;  
20 -import com.bsth.entity.schedule.CarConfigInfo;  
21 -import com.bsth.entity.schedule.GuideboardInfo;  
22 -import com.bsth.entity.schedule.EmployeeConfigInfo;  
23 -  
24 -import org.slf4j.Logger  
25 -  
26 -// 全局日志  
27 -global Logger LOG;  
28 -  
29 -// repository查询  
30 -global CarConfigInfoRepository ccRepo;  
31 -global GuideboardInfoRepository lpRepo;  
32 -global EmployeeConfigInfoRepository ecRepo;  
33 -global ScheduleRule1FlatRepository ruleRepo;  
34 -  
35 -// return输出  
36 -global ValidateRuleResult result;  
37 -  
38 -  
39 -//------------------ 第一阶段、车辆信息,路牌信息,人员信息载入 -----------------//  
40 -  
41 -// 1、车辆信息载入  
42 -declare CarConfig_Wraps  
43 - xlId: Integer // 线路Id  
44 - ccMap: Map // 车辆配置Map Map<车辆自编号, CarConfigInfo>  
45 -end  
46 -  
47 -rule "calcu_CarConfig_Wraps"  
48 - salience 800  
49 - when  
50 - $param: CalcuParam($xlId: xlId)  
51 - then  
52 - List ccInfos = ccRepo.findByXlId($xlId);  
53 -  
54 - CarConfig_Wraps carConfig_wraps = new CarConfig_Wraps();  
55 - carConfig_wraps.setXlId($xlId);  
56 - carConfig_wraps.setCcMap(new HashMap());  
57 -  
58 - for (int i = 0; i < ccInfos.size(); i++) {  
59 - CarConfigInfo ccInfo = (CarConfigInfo) ccInfos.get(i);  
60 - if (!ccInfo.getIsCancel()) {  
61 - carConfig_wraps.getCcMap().put(ccInfo.getCl().getInsideCode(), ccInfo);  
62 - }  
63 - }  
64 -  
65 - insert(carConfig_wraps);  
66 -  
67 - LOG.info("第一阶段 --> 1、车辆信息载入 calcu_CarConfig_Wraps 有效配置车辆数={}", ccInfos.size());  
68 -end  
69 -  
70 -// 2、路牌信息载入  
71 -declare Lp_Wraps  
72 - xlId: Integer // 线路Id  
73 - lpMap: Map // 路牌Map Map<id, GuideboardInfo>  
74 -end  
75 -  
76 -rule "calcu_Lp_Wraps"  
77 - salience 800  
78 - when  
79 - $param: CalcuParam($xlId: xlId)  
80 - then  
81 - List lpInfos = lpRepo.findByXlId($xlId);  
82 - Lp_Wraps lp_wraps = new Lp_Wraps();  
83 - lp_wraps.setXlId($xlId);  
84 - lp_wraps.setLpMap(new HashMap());  
85 -  
86 - for (int i = 0; i < lpInfos.size(); i++) {  
87 - GuideboardInfo lpInfo = (GuideboardInfo) lpInfos.get(i);  
88 - if (!lpInfo.getIsCancel()) {  
89 - lp_wraps.getLpMap().put(lpInfo.getId(), lpInfo);  
90 - }  
91 - }  
92 -  
93 - insert(lp_wraps);  
94 -  
95 - LOG.info("第一阶段 --> 2、路牌信息载入 calcu_Lp_Wraps 有效路牌数={}", lpInfos.size());  
96 -  
97 -end  
98 -  
99 -// 3、人员信息载入  
100 -declare EmployeeConfig_Wraps  
101 - xlId: Integer // 线路Id  
102 - ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>  
103 -end  
104 -  
105 -rule "calcu_EmployeeConfig_Wraps"  
106 - salience 800  
107 - when  
108 - $param: CalcuParam($xlId: xlId)  
109 - then  
110 - List ecInfos = ecRepo.findByXlId($xlId);  
111 -  
112 - EmployeeConfig_Wraps employeeConfig_wraps = new EmployeeConfig_Wraps();  
113 - employeeConfig_wraps.setXlId($xlId);  
114 - employeeConfig_wraps.setEcMap(new HashMap());  
115 -  
116 - for (int i = 0; i < ecInfos.size(); i++) {  
117 - EmployeeConfigInfo ecInfo = (EmployeeConfigInfo) ecInfos.get(i);  
118 - if (!ecInfo.getIsCancel()) {  
119 - employeeConfig_wraps.getEcMap().put(ecInfo.getId(), ecInfo);  
120 - }  
121 - }  
122 -  
123 - insert(employeeConfig_wraps);  
124 -  
125 - LOG.info("第一阶段 --> 3、人员信息载入 calcu_EmployeeConfig_Wraps 有效人员配置数={}", ecInfos.size());  
126 -end  
127 -  
128 -//------------------ 第二阶段、规则载入,计算相关数量 -----------------//  
129 -  
130 -declare Rule_Wraps  
131 - xlId: Integer // 线路Id  
132 - qyrq: Date // 启用日期  
133 - rule: ScheduleRule1Flat // ScheduleRule1Flat规则  
134 -end  
135 -  
136 -rule "calcu_schedule_rule_wrap"  
137 - salience 700  
138 - when  
139 - $param: CalcuParam($xlId: xlId)  
140 - $rule: ScheduleRule1Flat($qyrq: qyrq) from ruleRepo.findByXlId($xlId)  
141 - then  
142 - Rule_Wraps rw = new Rule_Wraps();  
143 - rw.setXlId($xlId);  
144 - rw.setQyrq($qyrq);  
145 - rw.setRule($rule);  
146 - insert(rw);  
147 -end  
148 -  
149 -rule "calcu_all_rule_count"  
150 - salience 600  
151 - when  
152 - $param: CalcuParam($xlId: xlId, $fd: fromDate, $td: toDate)  
153 - $allList: ArrayList() from collect(Rule_Wraps(xlId == $xlId))  
154 - then  
155 - result.setXlId($xlId);  
156 - result.setCount($allList.size());  
157 -  
158 - LOG.info("第二阶段 --> 规则总数={}", $allList.size());  
159 -end  
160 -  
161 -rule "calcu_all_qy_rule_count"  
162 - salience 500  
163 - when  
164 - $param: CalcuParam($xlId: xlId, $fd: fromDate, $td: toDate)  
165 - $qyList: ArrayList() from collect(  
166 - Rule_Wraps(xlId == $xlId, qyrq.getTime() <= $td.getMillis()))  
167 - then  
168 - result.setXlId($xlId);  
169 - result.setQyCount($qyList.size());  
170 -  
171 - LOG.info("第二阶段 --> 启用规则数={}", $qyList.size());  
172 -  
173 -end  
174 -  
175 -//------------------ 第三阶段、规则判定 -----------------//  
176 -  
177 -rule "calcu_Wrap_input"  
178 - salience 400  
179 - when  
180 - $param: CalcuParam($xlId: xlId, $fd: fromDate, $td: toDate)  
181 - $qy_rule: Rule_Wraps(xlId == $xlId, qyrq.getTime() <= $td.getMillis())  
182 - $cc: CarConfig_Wraps(xlId == $xlId)  
183 - $lp: Lp_Wraps(xlId == $xlId)  
184 - $ec: EmployeeConfig_Wraps(xlId == $xlId)  
185 - then  
186 - WrapInput wr = new WrapInput(  
187 - $qy_rule.getRule(),  
188 - $cc.getCcMap(),  
189 - $lp.getLpMap(),  
190 - $ec.getEcMap()  
191 - );  
192 - insert(wr);  
193 -end  
194 -  
195 -rule "calcu_error_info"  
196 - salience 300  
197 - when  
198 - $param: CalcuParam($xlId: xlId)  
199 - $errorMap: Map() from accumulate ($wr: WrapInput(xlId == $xlId), srif($wr))  
200 - then  
201 - result.setQyErrorCount($errorMap.size());  
202 - result.getErrorInfos().addAll($errorMap.values());  
203 -  
204 - LOG.info("第三阶段 --> 规则总数={}, 启用规则数={}, 错误的启用规则数={}",  
205 - result.getCount(), result.getQyCount(), result.getQyErrorCount());  
206 -  
207 -end  
208 -  
209 - 1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.rule;
  2 +
  3 +import accumulate com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ErrorInfoFunction srif;
  4 +import accumulate com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.ErrorBcCountFunction ecount;
  5 +
  6 +import org.joda.time.*;
  7 +import java.util.*;
  8 +
  9 +import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.CalcuParam;
  10 +import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult;
  11 +import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.ValidateRuleResult.ErrorInfo;
  12 +import com.bsth.service.schedule.impl.plan.kBase3.validate.rule.WrapInput;
  13 +
  14 +import com.bsth.repository.schedule.ScheduleRule1FlatRepository
  15 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  16 +import com.bsth.repository.schedule.GuideboardInfoRepository;
  17 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
  18 +
  19 +import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  20 +import com.bsth.entity.schedule.CarConfigInfo;
  21 +import com.bsth.entity.schedule.GuideboardInfo;
  22 +import com.bsth.entity.schedule.EmployeeConfigInfo;
  23 +
  24 +import org.slf4j.Logger
  25 +
  26 +// 全局日志
  27 +global Logger LOG;
  28 +
  29 +// repository查询
  30 +global CarConfigInfoRepository ccRepo;
  31 +global GuideboardInfoRepository lpRepo;
  32 +global EmployeeConfigInfoRepository ecRepo;
  33 +global ScheduleRule1FlatRepository ruleRepo;
  34 +
  35 +// return输出
  36 +global ValidateRuleResult result;
  37 +
  38 +
  39 +//------------------ 第一阶段、车辆信息,路牌信息,人员信息载入 -----------------//
  40 +
  41 +// 1、车辆信息载入
  42 +declare CarConfig_Wraps
  43 + xlId: Integer // 线路Id
  44 + ccMap: Map // 车辆配置Map Map<车辆自编号, CarConfigInfo>
  45 +end
  46 +
  47 +rule "calcu_CarConfig_Wraps"
  48 + salience 800
  49 + when
  50 + $param: CalcuParam($xlId: xlId)
  51 + then
  52 + List ccInfos = ccRepo.findByXlId($xlId);
  53 +
  54 + CarConfig_Wraps carConfig_wraps = new CarConfig_Wraps();
  55 + carConfig_wraps.setXlId($xlId);
  56 + carConfig_wraps.setCcMap(new HashMap());
  57 +
  58 + for (int i = 0; i < ccInfos.size(); i++) {
  59 + CarConfigInfo ccInfo = (CarConfigInfo) ccInfos.get(i);
  60 + if (!ccInfo.getIsCancel()) {
  61 + carConfig_wraps.getCcMap().put(ccInfo.getCl().getInsideCode(), ccInfo);
  62 + }
  63 + }
  64 +
  65 + insert(carConfig_wraps);
  66 +
  67 + LOG.info("第一阶段 --> 1、车辆信息载入 calcu_CarConfig_Wraps 有效配置车辆数={}", ccInfos.size());
  68 +end
  69 +
  70 +// 2、路牌信息载入
  71 +declare Lp_Wraps
  72 + xlId: Integer // 线路Id
  73 + lpMap: Map // 路牌Map Map<id, GuideboardInfo>
  74 +end
  75 +
  76 +rule "calcu_Lp_Wraps"
  77 + salience 800
  78 + when
  79 + $param: CalcuParam($xlId: xlId)
  80 + then
  81 + List lpInfos = lpRepo.findByXlId($xlId);
  82 + Lp_Wraps lp_wraps = new Lp_Wraps();
  83 + lp_wraps.setXlId($xlId);
  84 + lp_wraps.setLpMap(new HashMap());
  85 +
  86 + for (int i = 0; i < lpInfos.size(); i++) {
  87 + GuideboardInfo lpInfo = (GuideboardInfo) lpInfos.get(i);
  88 + if (!lpInfo.getIsCancel()) {
  89 + lp_wraps.getLpMap().put(lpInfo.getId(), lpInfo);
  90 + }
  91 + }
  92 +
  93 + insert(lp_wraps);
  94 +
  95 + LOG.info("第一阶段 --> 2、路牌信息载入 calcu_Lp_Wraps 有效路牌数={}", lpInfos.size());
  96 +
  97 +end
  98 +
  99 +// 3、人员信息载入
  100 +declare EmployeeConfig_Wraps
  101 + xlId: Integer // 线路Id
  102 + ecMap: Map // 人员配置Map Map<id, EmployeeConfigInfo>
  103 +end
  104 +
  105 +rule "calcu_EmployeeConfig_Wraps"
  106 + salience 800
  107 + when
  108 + $param: CalcuParam($xlId: xlId)
  109 + then
  110 + List ecInfos = ecRepo.findByXlId($xlId);
  111 +
  112 + EmployeeConfig_Wraps employeeConfig_wraps = new EmployeeConfig_Wraps();
  113 + employeeConfig_wraps.setXlId($xlId);
  114 + employeeConfig_wraps.setEcMap(new HashMap());
  115 +
  116 + for (int i = 0; i < ecInfos.size(); i++) {
  117 + EmployeeConfigInfo ecInfo = (EmployeeConfigInfo) ecInfos.get(i);
  118 + if (!ecInfo.getIsCancel()) {
  119 + employeeConfig_wraps.getEcMap().put(ecInfo.getId(), ecInfo);
  120 + }
  121 + }
  122 +
  123 + insert(employeeConfig_wraps);
  124 +
  125 + LOG.info("第一阶段 --> 3、人员信息载入 calcu_EmployeeConfig_Wraps 有效人员配置数={}", ecInfos.size());
  126 +end
  127 +
  128 +//------------------ 第二阶段、规则载入,计算相关数量 -----------------//
  129 +
  130 +declare Rule_Wraps
  131 + xlId: Integer // 线路Id
  132 + qyrq: Date // 启用日期
  133 + rule: ScheduleRule1Flat // ScheduleRule1Flat规则
  134 +end
  135 +
  136 +rule "calcu_schedule_rule_wrap"
  137 + salience 700
  138 + when
  139 + $param: CalcuParam($xlId: xlId)
  140 + $rule: ScheduleRule1Flat($qyrq: qyrq) from ruleRepo.findByXlId($xlId)
  141 + then
  142 + Rule_Wraps rw = new Rule_Wraps();
  143 + rw.setXlId($xlId);
  144 + rw.setQyrq($qyrq);
  145 + rw.setRule($rule);
  146 + insert(rw);
  147 +end
  148 +
  149 +rule "calcu_all_rule_count"
  150 + salience 600
  151 + when
  152 + $param: CalcuParam($xlId: xlId, $fd: fromDate, $td: toDate)
  153 + $allList: ArrayList() from collect(Rule_Wraps(xlId == $xlId))
  154 + then
  155 + result.setXlId($xlId);
  156 + result.setCount($allList.size());
  157 +
  158 + LOG.info("第二阶段 --> 规则总数={}", $allList.size());
  159 +end
  160 +
  161 +rule "calcu_all_qy_rule_count"
  162 + salience 500
  163 + when
  164 + $param: CalcuParam($xlId: xlId, $fd: fromDate, $td: toDate)
  165 + $qyList: ArrayList() from collect(
  166 + Rule_Wraps(xlId == $xlId, qyrq.getTime() <= $td.getMillis()))
  167 + then
  168 + result.setXlId($xlId);
  169 + result.setQyCount($qyList.size());
  170 +
  171 + LOG.info("第二阶段 --> 启用规则数={}", $qyList.size());
  172 +
  173 +end
  174 +
  175 +//------------------ 第三阶段、规则判定 -----------------//
  176 +
  177 +rule "calcu_Wrap_input"
  178 + salience 400
  179 + when
  180 + $param: CalcuParam($xlId: xlId, $fd: fromDate, $td: toDate)
  181 + $qy_rule: Rule_Wraps(xlId == $xlId, qyrq.getTime() <= $td.getMillis())
  182 + $cc: CarConfig_Wraps(xlId == $xlId)
  183 + $lp: Lp_Wraps(xlId == $xlId)
  184 + $ec: EmployeeConfig_Wraps(xlId == $xlId)
  185 + then
  186 + WrapInput wr = new WrapInput(
  187 + $qy_rule.getRule(),
  188 + $cc.getCcMap(),
  189 + $lp.getLpMap(),
  190 + $ec.getEcMap()
  191 + );
  192 + insert(wr);
  193 +end
  194 +
  195 +rule "calcu_error_info"
  196 + salience 300
  197 + when
  198 + $param: CalcuParam($xlId: xlId)
  199 + $errorMap: Map() from accumulate ($wr: WrapInput(xlId == $xlId), srif($wr))
  200 + then
  201 + result.setQyErrorCount($errorMap.size());
  202 + result.getErrorInfos().addAll($errorMap.values());
  203 +
  204 + LOG.info("第三阶段 --> 规则总数={}, 启用规则数={}, 错误的启用规则数={}",
  205 + result.getCount(), result.getQyCount(), result.getQyErrorCount());
  206 +
  207 +end
  208 +
  209 +
src/main/resources/rules/kBase3_validate_timetable.drl
1 -package com.bsth.service.schedule.impl.plan.kBase3.validate.timetable;  
2 -  
3 -import org.joda.time.*;  
4 -import java.util.*;  
5 -import org.apache.commons.lang3.StringUtils;  
6 -  
7 -import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result;  
8 -import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result.StatInfo;  
9 -import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.CalcuParam;  
10 -  
11 -import com.bsth.entity.schedule.TTInfo;  
12 -import com.bsth.entity.schedule.TTInfoDetail;  
13 -import com.bsth.entity.Line;  
14 -  
15 -import com.bsth.repository.schedule.TTInfoDetailRepository;  
16 -  
17 -import org.slf4j.Logger  
18 -import org.joda.time.format.DateTimeFormat  
19 -import java.lang.String  
20 -import java.lang.Object;  
21 -  
22 -  
23 -// 全局日志类(一般使用调用此规则的service类)  
24 -global Logger log;  
25 -global TTInfoDetailRepository tTInfoDetailRepository;  
26 -  
27 -// 输出  
28 -global Result rs;  
29 -  
30 -/*  
31 - 规则说明:  
32 - 1、找出指定线路,指定时间范围的时刻表  
33 - 2、统计这些时刻表班次数据的情况  
34 -*/  
35 -  
36 -//-------------- 第一阶段、计算规则迭代数据(天数) ------------//  
37 -declare Calcu_iter_days_result  
38 - xlId: Integer // 线路Id  
39 - xlName: String // 线路名字  
40 -  
41 - // 迭代数据  
42 - calcu_day: Integer // 准备计算第几天  
43 - calcu_weekday: Integer // 准备计算星期几(1到7)  
44 - calcu_date: DateTime // 准备计算的具体日期  
45 -  
46 - // 范围数据  
47 - calcu_days: Integer // 总共需要计算的天数  
48 - calcu_start_date: DateTime // 开始计算日期  
49 - calcu_end_date: DateTime // 结束计算日期  
50 -  
51 - // 时刻表映射数据  
52 - ttinfomap: Map // 指定时间段内,用的时刻表id映射 Map<Long, Long>  
53 -end  
54 -  
55 -rule "calcu_iter_days"  
56 - salience 1900  
57 - when  
58 - CalcuParam(  
59 - $xlId: xlId,  
60 - $fromDate: fromDate,  
61 - $toDate: toDate,  
62 - $fromDate.isBefore($toDate) || $fromDate.isEqual($toDate)  
63 - )  
64 - $line: Line(id == $xlId)  
65 - then  
66 - // 构造Calcu_iter_days_result对象,进行下一步计算  
67 - Calcu_iter_days_result cidr = new Calcu_iter_days_result();  
68 - Period p = new Period($fromDate, $toDate, PeriodType.days());  
69 -  
70 - cidr.setXlId($xlId);  
71 - cidr.setXlName($line.getName());  
72 -  
73 - cidr.setCalcu_day(new Integer(1));  
74 - cidr.setCalcu_weekday(Integer.valueOf($fromDate.getDayOfWeek()));  
75 - cidr.setCalcu_date($fromDate);  
76 -  
77 - cidr.setCalcu_days(Integer.valueOf(p.getDays() + 1));  
78 - cidr.setCalcu_start_date($fromDate);  
79 - cidr.setCalcu_end_date($toDate);  
80 -  
81 - cidr.setTtinfomap(new HashMap());  
82 -  
83 - log.info(  
84 - "线路={}-id={},开始时间={},结束时间={},总共计算的天数={},将从开始时间迭代",  
85 - cidr.getXlName(),  
86 - cidr.getXlId(),  
87 - cidr.getCalcu_start_date(),  
88 - cidr.getCalcu_end_date(),  
89 - cidr.getCalcu_days()  
90 - );  
91 -  
92 - insert(cidr);  
93 -end  
94 -  
95 -//-------------- 第二阶段、包装时刻表实体类到内部对象 ------------//  
96 -  
97 -declare TTInfo_wrap  
98 - id: Long // 时刻表id  
99 - name: String // 时刻表名字  
100 - weekdays: List // 周一到周日是否启用 List<Boolean>  
101 - specialDays: List // 特殊节假日 List<DateTime>  
102 - updateDate: DateTime // 最新修改时间  
103 -end  
104 -  
105 -rule "TTInfo_wrap_result"  
106 - salience 900  
107 - when  
108 - CalcuParam($xlId: xlId)  
109 - $ttinfo: TTInfo(  
110 - xl.id == $xlId,  
111 - isEnableDisTemplate == true,  
112 - isCancel == false  
113 - )  
114 - then  
115 - TTInfo_wrap ttInfo_wrap = new TTInfo_wrap();  
116 - ttInfo_wrap.setId($ttinfo.getId());  
117 - ttInfo_wrap.setName($ttinfo.getName());  
118 - ttInfo_wrap.setUpdateDate(new DateTime($ttinfo.getUpdateDate()));  
119 - ttInfo_wrap.setWeekdays(new ArrayList());  
120 - ttInfo_wrap.setSpecialDays(new ArrayList());  
121 -  
122 - String[] days = $ttinfo.getRule_days().split(",");  
123 - for (int i = 0; i < 7; i++) {  
124 - if ("1".equals(days[i])) {  
125 - ttInfo_wrap.getWeekdays().add(true);  
126 - } else {  
127 - ttInfo_wrap.getWeekdays().add(false);  
128 - }  
129 - }  
130 -  
131 - if (StringUtils.isNotEmpty($ttinfo.getSpecial_days())) {  
132 - String[] sdays = $ttinfo.getSpecial_days().split(",");  
133 - for (int i = 0; i < sdays.length; i++) {  
134 - ttInfo_wrap.getSpecialDays().add(  
135 - DateTimeFormat.forPattern(  
136 - "yyyy-MM-dd").parseDateTime(sdays[i]));  
137 - }  
138 - }  
139 -  
140 - log.info("时刻表={},id={},常规日期={},特殊日期={}",  
141 - ttInfo_wrap.getName(),  
142 - ttInfo_wrap.getId(),  
143 - ttInfo_wrap.getWeekdays(),  
144 - ttInfo_wrap.getSpecialDays());  
145 -  
146 - insert(ttInfo_wrap);  
147 -  
148 -end  
149 -  
150 -//-------------- 第三阶段、时刻表的日期匹配 ------------//  
151 -  
152 -declare TTInfoDetails_wrap  
153 - ttInfoId: Long // 时刻表id  
154 - bcInfoList: List // 班次信息列表 List<TTInfoDetail>  
155 -end  
156 -  
157 -rule "Calcu_iter_days_special_day" // 特殊日期匹配  
158 - salience 800  
159 - when  
160 - $cid : Calcu_iter_days_result(  
161 - $calcu_date: calcu_date,  
162 - $calcu_day: calcu_day,  
163 - calcu_day <= calcu_days  
164 - )  
165 - TTInfo_wrap(  
166 - $tid: id,  
167 - $tname: name,  
168 - specialDays contains $calcu_date  
169 - )  
170 - then  
171 - // 更新迭代对象  
172 - Integer new_calcu_day = Integer.valueOf($calcu_day + 1);  
173 - $cid.setCalcu_day(new_calcu_day);  
174 - DateTime new_calcu_date = $calcu_date.plusDays(1);  
175 - $cid.setCalcu_date(new_calcu_date);  
176 - $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));  
177 -  
178 - log.info("启用特殊日期时刻表:" +  
179 - "时刻表id={} 特殊日期={}",  
180 - $tid, $calcu_date);  
181 -  
182 - // 判定使用的时刻表  
183 - if (!$cid.getTtinfomap().containsKey($tid)) {  
184 - $cid.getTtinfomap().put($tid, $tid);  
185 - StatInfo statInfo = new StatInfo();  
186 - statInfo.setTtid($tid);  
187 - statInfo.setTtname($tname);  
188 - insert(statInfo);  
189 -  
190 - TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();  
191 - ttInfoDetails_wrap.setTtInfoId($tid);  
192 - ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));  
193 - insert(ttInfoDetails_wrap);  
194 - }  
195 - update($cid);  
196 -  
197 -end  
198 -  
199 -rule "Calcu_iter_days_normal_day" // 平日匹配  
200 - salience 700  
201 - when  
202 - $cid : Calcu_iter_days_result(  
203 - $calcu_date: calcu_date,  
204 - $calcu_weekday: calcu_weekday,  
205 - $calcu_day: calcu_day,  
206 - calcu_day <= calcu_days  
207 - )  
208 - TTInfo_wrap(  
209 - $tid: id,  
210 - $tname: name,  
211 - specialDays not contains $calcu_date,  
212 - weekdays[$calcu_weekday - 1] == Boolean.TRUE  
213 - )  
214 - then  
215 - // 更新迭代对象  
216 - Integer new_calcu_day = Integer.valueOf($calcu_day + 1);  
217 - $cid.setCalcu_day(new_calcu_day);  
218 - DateTime new_calcu_date = $calcu_date.plusDays(1);  
219 - $cid.setCalcu_date(new_calcu_date);  
220 - $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));  
221 -  
222 -  
223 - log.info("启用常规日期时刻表:" +  
224 - "时刻表id={} 常规日期={} 星期几={}",  
225 - $tid, $calcu_date, $calcu_weekday);  
226 -  
227 - // 判定使用的时刻表  
228 - if (!$cid.getTtinfomap().containsKey($tid)) {  
229 - $cid.getTtinfomap().put($tid, $tid);  
230 - StatInfo statInfo = new StatInfo();  
231 - statInfo.setTtid($tid);  
232 - statInfo.setTtname($tname);  
233 - insert(statInfo);  
234 -  
235 - TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();  
236 - ttInfoDetails_wrap.setTtInfoId($tid);  
237 - ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));  
238 - insert(ttInfoDetails_wrap);  
239 - }  
240 - update($cid);  
241 -  
242 -end  
243 -  
244 -rule "Calcu_iter_days_other_day" // 都没有的情况下,匹配  
245 - salience 500  
246 - when  
247 - $cid : Calcu_iter_days_result(  
248 - $calcu_date: calcu_date,  
249 - $calcu_weekday: calcu_weekday,  
250 - $calcu_day: calcu_day,  
251 - calcu_day <= calcu_days  
252 - )  
253 - TTInfo_wrap(  
254 - $tid: id,  
255 - $tname: name,  
256 - specialDays not contains $calcu_date,  
257 - weekdays[$calcu_weekday - 1] == false  
258 - )  
259 - then  
260 - // 更新迭代对象  
261 - Integer new_calcu_day = Integer.valueOf($calcu_day + 1);  
262 - $cid.setCalcu_day(new_calcu_day);  
263 - DateTime new_calcu_date = $calcu_date.plusDays(1);  
264 - $cid.setCalcu_date(new_calcu_date);  
265 - $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));  
266 -  
267 - log.info("启用默认日期时刻表:" +  
268 - "时刻表id={} 常规日期={} 星期几={}",  
269 - $tid, $calcu_date, $calcu_weekday);  
270 -  
271 - // 判定使用的时刻表  
272 - if (!$cid.getTtinfomap().containsKey($tid)) {  
273 - $cid.getTtinfomap().put($tid, $tid);  
274 - StatInfo statInfo = new StatInfo();  
275 - statInfo.setTtid($tid);  
276 - statInfo.setTtname($tname);  
277 - insert(statInfo);  
278 -  
279 - TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();  
280 - ttInfoDetails_wrap.setTtInfoId($tid);  
281 - Map<String, Object> param = new HashMap<String, Object>();  
282 - ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));  
283 - insert(ttInfoDetails_wrap);  
284 - }  
285 - update($cid);  
286 -  
287 -end  
288 -  
289 -//-------------- 第四阶段、时刻表明细统计值 ------------//  
290 -  
291 -rule "statinfo_result" // 统计计算结果  
292 - salience 300  
293 - no-loop  
294 - when  
295 - $statInfo: StatInfo($tid: ttid)  
296 - $ttInfoDetails_wrap: TTInfoDetails_wrap(ttInfoId == $tid)  
297 - $allbc: Long() from accumulate (TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), count())  
298 - $inbc: Long() from accumulate (TTInfoDetail(bcType == "in") from $ttInfoDetails_wrap.getBcInfoList(), count())  
299 - $outbc: Long() from accumulate (TTInfoDetail(bcType == "out") from $ttInfoDetails_wrap.getBcInfoList(), count())  
300 - $yybc: Long() from accumulate (TTInfoDetail(bcType != "out", bcType != "in") from $ttInfoDetails_wrap.getBcInfoList(), count())  
301 - $errorbc: Long() from accumulate ($ttd: TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), ecount($ttd))  
302 - then  
303 - log.info("时刻表={},id={},班次数={},进场={},出场={},营运={},错误={}", $statInfo.getTtname(), $statInfo.getTtid(), $allbc, $inbc, $outbc, $yybc, $errorbc);  
304 -  
305 - $statInfo.setAllbc($allbc);  
306 - $statInfo.setInbc($inbc);  
307 - $statInfo.setOutbc($outbc);  
308 - $statInfo.setYybc($yybc);  
309 - $statInfo.setErrorbc($errorbc);  
310 -  
311 - int lineVersion = ((TTInfoDetail) $ttInfoDetails_wrap.getBcInfoList().get(0)).getLineVersion();  
312 - $statInfo.setLineVersion(lineVersion);  
313 -  
314 - rs.getInfos().add($statInfo);  
315 -  
316 -end  
317 -  
318 -  
319 -  
320 -  
321 -  
322 -  
323 -  
324 -  
325 -  
326 -  
327 -  
328 -  
329 -  
330 -  
331 -  
332 - 1 +package com.bsth.service.schedule.impl.plan.kBase3.validate.timetable;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +import org.apache.commons.lang3.StringUtils;
  6 +
  7 +import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result;
  8 +import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.Result.StatInfo;
  9 +import com.bsth.service.schedule.impl.plan.kBase3.validate.timetable.CalcuParam;
  10 +
  11 +import com.bsth.entity.schedule.TTInfo;
  12 +import com.bsth.entity.schedule.TTInfoDetail;
  13 +import com.bsth.entity.Line;
  14 +
  15 +import com.bsth.repository.schedule.TTInfoDetailRepository;
  16 +
  17 +import org.slf4j.Logger
  18 +import org.joda.time.format.DateTimeFormat
  19 +import java.lang.String
  20 +import java.lang.Object;
  21 +
  22 +
  23 +// 全局日志类(一般使用调用此规则的service类)
  24 +global Logger log;
  25 +global TTInfoDetailRepository tTInfoDetailRepository;
  26 +
  27 +// 输出
  28 +global Result rs;
  29 +
  30 +/*
  31 + 规则说明:
  32 + 1、找出指定线路,指定时间范围的时刻表
  33 + 2、统计这些时刻表班次数据的情况
  34 +*/
  35 +
  36 +//-------------- 第一阶段、计算规则迭代数据(天数) ------------//
  37 +declare Calcu_iter_days_result
  38 + xlId: Integer // 线路Id
  39 + xlName: String // 线路名字
  40 +
  41 + // 迭代数据
  42 + calcu_day: Integer // 准备计算第几天
  43 + calcu_weekday: Integer // 准备计算星期几(1到7)
  44 + calcu_date: DateTime // 准备计算的具体日期
  45 +
  46 + // 范围数据
  47 + calcu_days: Integer // 总共需要计算的天数
  48 + calcu_start_date: DateTime // 开始计算日期
  49 + calcu_end_date: DateTime // 结束计算日期
  50 +
  51 + // 时刻表映射数据
  52 + ttinfomap: Map // 指定时间段内,用的时刻表id映射 Map<Long, Long>
  53 +end
  54 +
  55 +rule "calcu_iter_days"
  56 + salience 1900
  57 + when
  58 + CalcuParam(
  59 + $xlId: xlId,
  60 + $fromDate: fromDate,
  61 + $toDate: toDate,
  62 + $fromDate.isBefore($toDate) || $fromDate.isEqual($toDate)
  63 + )
  64 + $line: Line(id == $xlId)
  65 + then
  66 + // 构造Calcu_iter_days_result对象,进行下一步计算
  67 + Calcu_iter_days_result cidr = new Calcu_iter_days_result();
  68 + Period p = new Period($fromDate, $toDate, PeriodType.days());
  69 +
  70 + cidr.setXlId($xlId);
  71 + cidr.setXlName($line.getName());
  72 +
  73 + cidr.setCalcu_day(new Integer(1));
  74 + cidr.setCalcu_weekday(Integer.valueOf($fromDate.getDayOfWeek()));
  75 + cidr.setCalcu_date($fromDate);
  76 +
  77 + cidr.setCalcu_days(Integer.valueOf(p.getDays() + 1));
  78 + cidr.setCalcu_start_date($fromDate);
  79 + cidr.setCalcu_end_date($toDate);
  80 +
  81 + cidr.setTtinfomap(new HashMap());
  82 +
  83 + log.info(
  84 + "线路={}-id={},开始时间={},结束时间={},总共计算的天数={},将从开始时间迭代",
  85 + cidr.getXlName(),
  86 + cidr.getXlId(),
  87 + cidr.getCalcu_start_date(),
  88 + cidr.getCalcu_end_date(),
  89 + cidr.getCalcu_days()
  90 + );
  91 +
  92 + insert(cidr);
  93 +end
  94 +
  95 +//-------------- 第二阶段、包装时刻表实体类到内部对象 ------------//
  96 +
  97 +declare TTInfo_wrap
  98 + id: Long // 时刻表id
  99 + name: String // 时刻表名字
  100 + weekdays: List // 周一到周日是否启用 List<Boolean>
  101 + specialDays: List // 特殊节假日 List<DateTime>
  102 + updateDate: DateTime // 最新修改时间
  103 +end
  104 +
  105 +rule "TTInfo_wrap_result"
  106 + salience 900
  107 + when
  108 + CalcuParam($xlId: xlId)
  109 + $ttinfo: TTInfo(
  110 + xl.id == $xlId,
  111 + isEnableDisTemplate == true,
  112 + isCancel == false
  113 + )
  114 + then
  115 + TTInfo_wrap ttInfo_wrap = new TTInfo_wrap();
  116 + ttInfo_wrap.setId($ttinfo.getId());
  117 + ttInfo_wrap.setName($ttinfo.getName());
  118 + ttInfo_wrap.setUpdateDate(new DateTime($ttinfo.getUpdateDate()));
  119 + ttInfo_wrap.setWeekdays(new ArrayList());
  120 + ttInfo_wrap.setSpecialDays(new ArrayList());
  121 +
  122 + String[] days = $ttinfo.getRule_days().split(",");
  123 + for (int i = 0; i < 7; i++) {
  124 + if ("1".equals(days[i])) {
  125 + ttInfo_wrap.getWeekdays().add(true);
  126 + } else {
  127 + ttInfo_wrap.getWeekdays().add(false);
  128 + }
  129 + }
  130 +
  131 + if (StringUtils.isNotEmpty($ttinfo.getSpecial_days())) {
  132 + String[] sdays = $ttinfo.getSpecial_days().split(",");
  133 + for (int i = 0; i < sdays.length; i++) {
  134 + ttInfo_wrap.getSpecialDays().add(
  135 + DateTimeFormat.forPattern(
  136 + "yyyy-MM-dd").parseDateTime(sdays[i]));
  137 + }
  138 + }
  139 +
  140 + log.info("时刻表={},id={},常规日期={},特殊日期={}",
  141 + ttInfo_wrap.getName(),
  142 + ttInfo_wrap.getId(),
  143 + ttInfo_wrap.getWeekdays(),
  144 + ttInfo_wrap.getSpecialDays());
  145 +
  146 + insert(ttInfo_wrap);
  147 +
  148 +end
  149 +
  150 +//-------------- 第三阶段、时刻表的日期匹配 ------------//
  151 +
  152 +declare TTInfoDetails_wrap
  153 + ttInfoId: Long // 时刻表id
  154 + bcInfoList: List // 班次信息列表 List<TTInfoDetail>
  155 +end
  156 +
  157 +rule "Calcu_iter_days_special_day" // 特殊日期匹配
  158 + salience 800
  159 + when
  160 + $cid : Calcu_iter_days_result(
  161 + $calcu_date: calcu_date,
  162 + $calcu_day: calcu_day,
  163 + calcu_day <= calcu_days
  164 + )
  165 + TTInfo_wrap(
  166 + $tid: id,
  167 + $tname: name,
  168 + specialDays contains $calcu_date
  169 + )
  170 + then
  171 + // 更新迭代对象
  172 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  173 + $cid.setCalcu_day(new_calcu_day);
  174 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  175 + $cid.setCalcu_date(new_calcu_date);
  176 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  177 +
  178 + log.info("启用特殊日期时刻表:" +
  179 + "时刻表id={} 特殊日期={}",
  180 + $tid, $calcu_date);
  181 +
  182 + // 判定使用的时刻表
  183 + if (!$cid.getTtinfomap().containsKey($tid)) {
  184 + $cid.getTtinfomap().put($tid, $tid);
  185 + StatInfo statInfo = new StatInfo();
  186 + statInfo.setTtid($tid);
  187 + statInfo.setTtname($tname);
  188 + insert(statInfo);
  189 +
  190 + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
  191 + ttInfoDetails_wrap.setTtInfoId($tid);
  192 + ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));
  193 + insert(ttInfoDetails_wrap);
  194 + }
  195 + update($cid);
  196 +
  197 +end
  198 +
  199 +rule "Calcu_iter_days_normal_day" // 平日匹配
  200 + salience 700
  201 + when
  202 + $cid : Calcu_iter_days_result(
  203 + $calcu_date: calcu_date,
  204 + $calcu_weekday: calcu_weekday,
  205 + $calcu_day: calcu_day,
  206 + calcu_day <= calcu_days
  207 + )
  208 + TTInfo_wrap(
  209 + $tid: id,
  210 + $tname: name,
  211 + specialDays not contains $calcu_date,
  212 + weekdays[$calcu_weekday - 1] == Boolean.TRUE
  213 + )
  214 + then
  215 + // 更新迭代对象
  216 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  217 + $cid.setCalcu_day(new_calcu_day);
  218 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  219 + $cid.setCalcu_date(new_calcu_date);
  220 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  221 +
  222 +
  223 + log.info("启用常规日期时刻表:" +
  224 + "时刻表id={} 常规日期={} 星期几={}",
  225 + $tid, $calcu_date, $calcu_weekday);
  226 +
  227 + // 判定使用的时刻表
  228 + if (!$cid.getTtinfomap().containsKey($tid)) {
  229 + $cid.getTtinfomap().put($tid, $tid);
  230 + StatInfo statInfo = new StatInfo();
  231 + statInfo.setTtid($tid);
  232 + statInfo.setTtname($tname);
  233 + insert(statInfo);
  234 +
  235 + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
  236 + ttInfoDetails_wrap.setTtInfoId($tid);
  237 + ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));
  238 + insert(ttInfoDetails_wrap);
  239 + }
  240 + update($cid);
  241 +
  242 +end
  243 +
  244 +rule "Calcu_iter_days_other_day" // 都没有的情况下,匹配
  245 + salience 500
  246 + when
  247 + $cid : Calcu_iter_days_result(
  248 + $calcu_date: calcu_date,
  249 + $calcu_weekday: calcu_weekday,
  250 + $calcu_day: calcu_day,
  251 + calcu_day <= calcu_days
  252 + )
  253 + TTInfo_wrap(
  254 + $tid: id,
  255 + $tname: name,
  256 + specialDays not contains $calcu_date,
  257 + weekdays[$calcu_weekday - 1] == false
  258 + )
  259 + then
  260 + // 更新迭代对象
  261 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  262 + $cid.setCalcu_day(new_calcu_day);
  263 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  264 + $cid.setCalcu_date(new_calcu_date);
  265 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  266 +
  267 + log.info("启用默认日期时刻表:" +
  268 + "时刻表id={} 常规日期={} 星期几={}",
  269 + $tid, $calcu_date, $calcu_weekday);
  270 +
  271 + // 判定使用的时刻表
  272 + if (!$cid.getTtinfomap().containsKey($tid)) {
  273 + $cid.getTtinfomap().put($tid, $tid);
  274 + StatInfo statInfo = new StatInfo();
  275 + statInfo.setTtid($tid);
  276 + statInfo.setTtname($tname);
  277 + insert(statInfo);
  278 +
  279 + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
  280 + ttInfoDetails_wrap.setTtInfoId($tid);
  281 + Map<String, Object> param = new HashMap<String, Object>();
  282 + ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));
  283 + insert(ttInfoDetails_wrap);
  284 + }
  285 + update($cid);
  286 +
  287 +end
  288 +
  289 +//-------------- 第四阶段、时刻表明细统计值 ------------//
  290 +
  291 +rule "statinfo_result" // 统计计算结果
  292 + salience 300
  293 + no-loop
  294 + when
  295 + $statInfo: StatInfo($tid: ttid)
  296 + $ttInfoDetails_wrap: TTInfoDetails_wrap(ttInfoId == $tid)
  297 + $allbc: Long() from accumulate (TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), count())
  298 + $inbc: Long() from accumulate (TTInfoDetail(bcType == "in") from $ttInfoDetails_wrap.getBcInfoList(), count())
  299 + $outbc: Long() from accumulate (TTInfoDetail(bcType == "out") from $ttInfoDetails_wrap.getBcInfoList(), count())
  300 + $yybc: Long() from accumulate (TTInfoDetail(bcType != "out", bcType != "in") from $ttInfoDetails_wrap.getBcInfoList(), count())
  301 + $errorbc: Long() from accumulate ($ttd: TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), ecount($ttd))
  302 + then
  303 + log.info("时刻表={},id={},班次数={},进场={},出场={},营运={},错误={}", $statInfo.getTtname(), $statInfo.getTtid(), $allbc, $inbc, $outbc, $yybc, $errorbc);
  304 +
  305 + $statInfo.setAllbc($allbc);
  306 + $statInfo.setInbc($inbc);
  307 + $statInfo.setOutbc($outbc);
  308 + $statInfo.setYybc($yybc);
  309 + $statInfo.setErrorbc($errorbc);
  310 +
  311 + int lineVersion = ((TTInfoDetail) $ttInfoDetails_wrap.getBcInfoList().get(0)).getLineVersion();
  312 + $statInfo.setLineVersion(lineVersion);
  313 +
  314 + rs.getInfos().add($statInfo);
  315 +
  316 +end
  317 +
  318 +
  319 +
  320 +
  321 +
  322 +
  323 +
  324 +
  325 +
  326 +
  327 +
  328 +
  329 +
  330 +
  331 +
  332 +
src/main/resources/static/pages/base/geo_data_edit/js/search.js
@@ -28,7 +28,7 @@ var gb_ct_search = function () { @@ -28,7 +28,7 @@ var gb_ct_search = function () {
28 28
29 var searchComplete = function (e) { 29 var searchComplete = function (e) {
30 console.log('e.wr', e); 30 console.log('e.wr', e);
31 - var htmlStr = template('geo_d_e_search_result-temp', {list: e.Br}); 31 + var htmlStr = template('geo_d_e_search_result-temp', {list: e.Ar});
32 $('.ct_search_result').html(htmlStr); 32 $('.ct_search_result').html(htmlStr);
33 33
34 }; 34 };
src/main/resources/static/pages/base/lineversions/add.html
@@ -108,6 +108,7 @@ @@ -108,6 +108,7 @@
108 <select name="status" class="form-control" id="statusInput"> 108 <select name="status" class="form-control" id="statusInput">
109 <option value="">请选择...</option> 109 <option value="">请选择...</option>
110 <option value="1">当前版本</option> 110 <option value="1">当前版本</option>
  111 +
111 <option value="2">待更新版本</option> 112 <option value="2">待更新版本</option>
112 <option value="0">历史版本</option> 113 <option value="0">历史版本</option>
113 </select> 114 </select>
src/main/resources/static/pages/base/lineversions/edit.html
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 <span class="required"> * </span>线路名称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 54 <span class="required"> * </span>线路名称&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:
55 </label> 55 </label>
56 <div class="col-md-4"> 56 <div class="col-md-4">
57 - <select name="line" class="form-control" style="width:100%" id="lineSelect"></select> 57 + <select name="line" class="form-control" style="width:100%" id="lineSelect" disabled="true"></select>
58 </div> 58 </div>
59 </div> 59 </div>
60 <!-- 表单分组组件 form-group END --> 60 <!-- 表单分组组件 form-group END -->
@@ -87,7 +87,7 @@ @@ -87,7 +87,7 @@
87 <span class="required"> * </span>线路版本&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 87 <span class="required"> * </span>线路版本&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:
88 </label> 88 </label>
89 <div class="col-md-4"> 89 <div class="col-md-4">
90 - <input type="text" class="form-control" name="versions" id="versionsInput" placeholder="线路版本" /> 90 + <input type="text" class="form-control" name="versions" id="versionsInput" placeholder="线路版本" readonly="true" />
91 </div> 91 </div>
92 </div> 92 </div>
93 <!-- 表单分组组件 form-group END --> 93 <!-- 表单分组组件 form-group END -->
src/main/resources/static/pages/base/lineversions/js/lineversions-edit-from.js
@@ -207,7 +207,6 @@ @@ -207,7 +207,6 @@
207 submit(); 207 submit();
208 // 提交 208 // 提交
209 function submit() { 209 function submit() {
210 - debugger  
211 // 添加数据 210 // 添加数据
212 $post('/lineVersions/update', params, function(result) { 211 $post('/lineVersions/update', params, function(result) {
213 // 如果返回结果不为空 212 // 如果返回结果不为空
src/main/resources/static/pages/base/lineversions/js/lineversions-list-table.js
@@ -299,6 +299,36 @@ @@ -299,6 +299,36 @@
299 /** 表格数据分页加载 @param:<params:搜索参数;true:是否重新分页> */ 299 /** 表格数据分页加载 @param:<params:搜索参数;true:是否重新分页> */
300 loadTableDate(params,true); 300 loadTableDate(params,true);
301 }); 301 });
  302 + // 删除待更新线路版本
  303 + $(document).on('click', 'a.update_delete_btn', function () {
  304 + var id = $(this).data('id');
  305 + swal({
  306 + title: "确认删除这个待更新线路版本!",
  307 + type: "warning",
  308 + showCancelButton: true,
  309 + confirmButtonColor: "#DD6B55",
  310 + confirmButtonText: "是的!",
  311 + cancelButtonText: "我在考虑下...",
  312 + closeOnConfirm: false },
  313 + function(isConfirm){
  314 + if(isConfirm){
  315 + $post('/lineVersions/delete', {"id":id}, function(result) {
  316 + // 如果返回结果不为空
  317 + if(result){
  318 + // 返回状态码为"SUCCESS" ,则添加成功;返回状态码为"ERROR" ,则添加失败
  319 + if(result.status=='SUCCESS') {
  320 + // 弹出添加成功提示消息
  321 + layer.msg('删除成功...');
  322 + } else if(result.status=='ERROR') {
  323 + // 弹出添加失败提示消息
  324 + layer.msg('删除失败...');
  325 + }
  326 + }
  327 + });
  328 + swal.close();
  329 + }
  330 + });
  331 + });
302 // 线路版本编辑 332 // 线路版本编辑
303 $(document).on('click', 'a.update_versions_route_btn', function () { 333 $(document).on('click', 'a.update_versions_route_btn', function () {
304 var lineId = $(this).data('lineid'); 334 var lineId = $(this).data('lineid');
src/main/resources/static/pages/base/lineversions/list.html
@@ -145,9 +145,12 @@ @@ -145,9 +145,12 @@
145 {{obj.remark}} 145 {{obj.remark}}
146 </td> 146 </td>
147 <td> 147 <td>
148 - <a href="edit.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 修改 </a> 148 + {{if obj.status != '0'}}
  149 + <a href="edit.html?no={{obj.id}}" class="btn btn-info btn-sm" data-pjax> 修改 </a>
  150 + {{/if}}
149 {{if obj.status == '2'}} 151 {{if obj.status == '2'}}
150 - <a class="update_versions_route_btn btn default blue-stripe btn-sm" data-lineid="{{obj.line.id}}" data-pjax> 编辑版本路线 </a> 152 + <a class="update_delete_btn btn btn-danger btn-sm" data-id="{{obj.id}}" data-pjax> 删除 </a>
  153 + <a class="update_versions_route_btn btn btn-info btn-sm" data-lineid="{{obj.line.id}}" data-pjax> 编辑版本路线 </a>
151 {{/if}} 154 {{/if}}
152 {{if obj.status == '2' && obj.isupdate!=1}} 155 {{if obj.status == '2' && obj.isupdate!=1}}
153 <a class="issue_btn btn btn-danger btn-sm" data-id="{{obj.id}}" data-pjax>发布</a> 156 <a class="issue_btn btn btn-danger btn-sm" data-id="{{obj.id}}" data-pjax>发布</a>
src/main/resources/static/pages/base/roadspeed/js/add-form-wizard.js
@@ -78,7 +78,6 @@ var FormWizard = function() { @@ -78,7 +78,6 @@ var FormWizard = function() {
78 submitHandler : function(f) { 78 submitHandler : function(f) {
79 // 防止用户多次提交 79 // 防止用户多次提交
80 $("#submintBtn").addClass("disabled"); 80 $("#submintBtn").addClass("disabled");
81 - debugger  
82 var params = form.serializeJSON();// 表单序列化. 81 var params = form.serializeJSON();// 表单序列化.
83 if(params.roadVector=='') { 82 if(params.roadVector=='') {
84 layer.msg('路段几何图形为空~请先在路段位置步骤中绘制出线路走向!'); 83 layer.msg('路段几何图形为空~请先在路段位置步骤中绘制出线路走向!');
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
@@ -66,9 +66,9 @@ window.WorldsBMap = function () { @@ -66,9 +66,9 @@ window.WorldsBMap = function () {
66 var dragMarkerDragEvent = function (e) { 66 var dragMarkerDragEvent = function (e) {
67 if (editPolygon) { 67 if (editPolygon) {
68 // 中心点是否超出多边形 68 // 中心点是否超出多边形
69 - if (!BMapLib.GeoUtils.isPointInPolygon(e.target._position, editPolygon)) {  
70 - dragMarker.setPosition(dragMarker._old_point);//还原位置  
71 - } 69 + // if (!BMapLib.GeoUtils.isPointInPolygon(e.target._position, editPolygon)) {
  70 + // dragMarker.setPosition(dragMarker._old_point);//还原位置
  71 + // }
72 centerPoint = e.target._position; 72 centerPoint = e.target._position;
73 } 73 }
74 else if (editCircle) { 74 else if (editCircle) {
@@ -321,7 +321,7 @@ window.WorldsBMap = function () { @@ -321,7 +321,7 @@ window.WorldsBMap = function () {
321 mapBValue.centerAndZoom(point, 18); 321 mapBValue.centerAndZoom(point, 18);
322 editCircle = circle; 322 editCircle = circle;
323 // 允许覆盖物在map.clearOverlays方法中被清除 323 // 允许覆盖物在map.clearOverlays方法中被清除
324 - circle.enableMassClear(); 324 + // circle.enableMassClear();
325 // 百度地图添加覆盖物圆 325 // 百度地图添加覆盖物圆
326 mapBValue.addOverlay(circle); 326 mapBValue.addOverlay(circle);
327 // 开启编辑功能 327 // 开启编辑功能
@@ -349,7 +349,7 @@ window.WorldsBMap = function () { @@ -349,7 +349,7 @@ window.WorldsBMap = function () {
349 $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]); 349 $('#edit_station_mobal').trigger('editSelectMobal_show', [WorldsBMap, GetAjaxData, EditStationObj, LineObj, PublicFunctions]);
350 }); 350 });
351 }); 351 });
352 - // 编辑多 352 + // 编辑多
353 } else if (stationShapesTypeV == 'd') { 353 } else if (stationShapesTypeV == 'd') {
354 // 获取中心点坐标字符串 354 // 获取中心点坐标字符串
355 var testpointStr = station.stationJwpoints; 355 var testpointStr = station.stationJwpoints;
@@ -383,7 +383,9 @@ window.WorldsBMap = function () { @@ -383,7 +383,9 @@ window.WorldsBMap = function () {
383 mapBValue.addOverlay(polygon); 383 mapBValue.addOverlay(polygon);
384 // 开启编辑功能(自 1.1 新增) 384 // 开启编辑功能(自 1.1 新增)
385 polygon.enableEditing(); 385 polygon.enableEditing();
386 - // 添加多变行编辑事件 386 + //禁止覆盖物在map.clearOverlays方法中被清除
  387 + // polygon.disableMassClear();
  388 + // 添加多边形编辑事件
387 polygon.addEventListener('dblclick', function (e) { 389 polygon.addEventListener('dblclick', function (e) {
388 // 获取编辑的多边形对象 390 // 获取编辑的多边形对象
389 var edit_pointE = polygon; 391 var edit_pointE = polygon;
src/main/resources/static/pages/base/stationroute/list.html
@@ -351,7 +351,9 @@ @@ -351,7 +351,9 @@
351 351
352 function setPlace(){ 352 function setPlace(){
353 // myMap.clearOverlays(); //清除地图上所有覆盖物 353 // myMap.clearOverlays(); //清除地图上所有覆盖物
354 - WorldsBMap.clearOtherOverlay(); 354 + var local = new BMap.LocalSearch(myMap, { //智能搜索
  355 + onSearchComplete: myFun
  356 + });
355 function myFun(){ 357 function myFun(){
356 var pp = local.getResults().getPoi(0) == undefined? null:local.getResults().getPoi(0).point; 358 var pp = local.getResults().getPoi(0) == undefined? null:local.getResults().getPoi(0).point;
357 if(pp) { 359 if(pp) {
@@ -361,22 +363,19 @@ @@ -361,22 +363,19 @@
361 layer.msg('找不到您输入的位置!') 363 layer.msg('找不到您输入的位置!')
362 } 364 }
363 } 365 }
364 - var local = new BMap.LocalSearch(myMap, { //智能搜索  
365 - onSearchComplete: myFun  
366 - });  
367 local.search(myValue); 366 local.search(myValue);
368 } 367 }
369 $("#searchInput").on('input propertychange change', function () { 368 $("#searchInput").on('input propertychange change', function () {
370 if($("#searchInput").val() != null && $("#searchInput").val() != "") 369 if($("#searchInput").val() != null && $("#searchInput").val() != "")
371 $('.search_panel .clear').removeClass('hide'); 370 $('.search_panel .clear').removeClass('hide');
372 else { 371 else {
373 - WorldsBMap.clearOtherOverlay(); 372 + // WorldsBMap.clearOtherOverlay();
374 $('.search_panel .clear').addClass('hide'); 373 $('.search_panel .clear').addClass('hide');
375 } 374 }
376 }); 375 });
377 376
378 $('.search_panel .clear').on('click',function () { 377 $('.search_panel .clear').on('click',function () {
379 - WorldsBMap.clearOtherOverlay(); 378 + // WorldsBMap.clearOtherOverlay();
380 $("#searchInput").val(''); 379 $("#searchInput").val('');
381 $("#searchInput").change(); 380 $("#searchInput").change();
382 }); 381 });
src/main/resources/static/pages/base/timesmodel/js/v2_2/InternalScheduleObj.js
1 -/**  
2 - * v2_2版本的行车计划对象。  
3 - *  
4 - * 本次修正和原来区别,一边生成班次,一边调整班次间隔  
5 - * 1、初始化行车计划基本布局,主要是有几辆车,路牌分布情况(连班,分班,5休2分班),上标线的初始班次列表  
6 - *  
7 - */  
8 -var InternalScheduleObj_v2_2 = (function() {  
9 -  
10 - // 内部utils类  
11 - var _utils = function() {  
12 - return {  
13 - /**  
14 - * 创建班次对象。  
15 - * @param lpObj InternalLpObj路牌对象  
16 - * @param bcType 班次类型(normal等等)  
17 - * @param isUp 是否上行  
18 - * @param fcno 发车顺序号  
19 - * @param fcTimeObj 发车时间对象  
20 - * @param paramObj 参数对象  
21 - * @returns {InternalBcObj}  
22 - */  
23 - createBcObj : function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {  
24 - var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType); // 班次里程  
25 - var _fcsj = fcTimeObj; // 发车时间  
26 - // var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp); // 班次历时  
27 - var _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(isUp, _fcsj, paramObj); // 使用策略计算班次行驶时间  
28 -  
29 - // console.log("发车时间=" + _fcsj.format("HH:mm") + ",行驶时间=" + _bcsj);  
30 -  
31 - var _arrsj = paramObj.addMinute(_fcsj, _bcsj); // 到达时间  
32 - // 停站时间范围,[最小停站时间,最大停站时间]  
33 - // var _stopTimeRange = paramObj.calcuTripLayoverTimeRange(_arrsj, isUp, _bcsj);  
34 - var _stopTimeRange = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
35 - _fcsj, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), paramObj);  
36 -  
37 - var _stoptime = _stopTimeRange[0]; // 使用最小停站时间  
38 - var _tccid = paramObj.getTTinfoId();  
39 - var _ttinfoid = paramObj.getTTinfoId();  
40 - var _xl = paramObj.getXlId();  
41 - var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;  
42 - var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;  
43 -  
44 - if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间  
45 - if (isUp) { // 上行  
46 - _fcsj = paramObj.addMinute(  
47 - _fcsj,  
48 - -(paramObj.getUpOutTime() + paramObj.getLbTime()));  
49 - _bcsj = paramObj.getLbTime();  
50 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
51 - _stoptime = 0;  
52 - } else { // 下行  
53 - _fcsj = paramObj.addMinute(  
54 - _fcsj,  
55 - -(paramObj.getDownOutTime() + paramObj.getLbTime()));  
56 - _bcsj = paramObj.getLbTime();  
57 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
58 - _stoptime = 0;  
59 - }  
60 - } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间  
61 - if (isUp) { // 上行  
62 - _fcsj = paramObj.addMinute(  
63 - _fcsj,  
64 - paramObj.getUpInTime());  
65 - _bcsj = paramObj.getLbTime();  
66 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
67 - _stoptime = 0;  
68 - } else { // 下行  
69 - _fcsj = paramObj.addMinute(  
70 - _fcsj,  
71 - paramObj.getDownInTime());  
72 - _bcsj = paramObj.getLbTime();  
73 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
74 - _stoptime = 0;  
75 - }  
76 - } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间  
77 - if (isUp) { // 上行  
78 - _fcsj = paramObj.addMinute(  
79 - _fcsj,  
80 - -paramObj.getUpOutTime());  
81 - _bcsj = paramObj.getUpOutTime();  
82 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
83 - _stoptime = 0;  
84 - } else { // 下行  
85 - _fcsj = paramObj.addMinute(  
86 - _fcsj,  
87 - -paramObj.getDownOutTime());  
88 - _bcsj = paramObj.getDownOutTime();  
89 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
90 - _stoptime = 0;  
91 - }  
92 - } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间  
93 - if (isUp) { // 上行  
94 - _bcsj = paramObj.getUpInTime();  
95 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
96 - _stoptime = 0;  
97 - } else { // 下行  
98 - _bcsj = paramObj.getDownInTime();  
99 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
100 - _stoptime = 0;  
101 - }  
102 - } else if (bcType == "cf") { // 吃饭班次  
103 - // 以13:00为分界,之前的为午饭,之后的为晚饭  
104 - if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {  
105 - _bcsj = paramObj.fnGetLunchTime();  
106 - } else {  
107 - _bcsj = paramObj.fnGetDinnerTime();  
108 - }  
109 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
110 - _stoptime = 0;  
111 - }  
112 -  
113 - var bcParamObj = {};  
114 - bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)  
115 - bcParamObj.isUp = isUp; // boolean是否上下行  
116 - bcParamObj.fcno = fcno; // 发车顺序号  
117 - bcParamObj.fcTimeObj = _fcsj; // 发车时间对象  
118 - bcParamObj.bclc = _bclc; // 班次里程  
119 - bcParamObj.bcsj = _bcsj; // 班次历时  
120 - bcParamObj.arrtime = _arrsj; // 到达时间对象  
121 - bcParamObj.stoptime = _stoptime; // 停站时间  
122 - bcParamObj.tccid = _tccid; // 停车场id  
123 - bcParamObj.ttinfoid = _ttinfoid; // 时刻表id  
124 - bcParamObj.xl = _xl; // 线路id  
125 - bcParamObj.qdzid = _qdz; // 起点站id  
126 - bcParamObj.zdzid = _zdz; // 终点站id  
127 -  
128 - return new InternalBcObj(lpObj, bcParamObj);  
129 - },  
130 -  
131 - /**  
132 - * 修正上标线主站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续说有班次。  
133 - * @param oLp 上标线路牌  
134 - * @param fromFcsj 开始发车时间对象  
135 - * @param fromGroupIndex 开始圈索引  
136 - * @param fromBcIndex 开始班次索引  
137 - * @param isUp 开始班次是上行还是下行  
138 - * @param oParam 参数对象  
139 - */  
140 - modifySBXMasterBc: function(oLp, fromFcsj, fromGroupIndex, fromBcIndex, isUp, oParam) {  
141 - // 清空指定位置班次及后续班次  
142 - oLp.clearBc(fromGroupIndex, fromBcIndex);  
143 - // 初始化上标线,从指定圈索引开始  
144 - oLp.initDataFromTime(fromFcsj, isUp, fromGroupIndex, oParam, _utils);  
145 -  
146 - }  
147 -  
148 - };  
149 - }();  
150 -  
151 -  
152 -  
153 - /**  
154 - * 内部行车计划对象。  
155 - * @param oParam 参数封装对象  
156 - * @param aLp 路牌(甘特图用的路牌对象)  
157 - * @constructor  
158 - */  
159 - function InternalScheduleObj(oParam, aLp) {  
160 - // 参数对象和甘特图用路牌数组  
161 - this._oParam = oParam;  
162 - this._aGanttLpArray = aLp;  
163 -  
164 - // 目前这个只支持主站停站  
165 - if (this._oParam.isTwoWayStop()) {  
166 - alert("v2_2版本不支持双向停站类型线路!");  
167 - throw "v2_2版本不支持双向停站类型线路";  
168 - }  
169 -  
170 - console.log("//->>>>>>>>>>>>>>>>>>>>>>>>> v2_2行车计划,初始化1,圈信息,路牌 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-//");  
171 - //----------------------- 1、确定上标线的方向,圈的方向 -------------------//  
172 - this._qIsUp = true; // 每一圈是上行开始还是下行开始  
173 -  
174 - // 确定_qIsUp,哪个方向的首班车晚就用哪个  
175 - // this._qIsUp = this._oParam.getUpFirstDTimeObj().isBefore(  
176 - // this._oParam.getDownFirstDTimeObj()) ? false : true;  
177 -  
178 - // 确定_qIsUp,哪个方向的首班车晚就用哪个  
179 - // 使用diff判定,如果两个时间相等 this._qIsUp = false  
180 - this._qIsUp = oParam.getUpFirstDTimeObj().diff(oParam.getDownFirstDTimeObj()) <= 0 ? false : true;  
181 -  
182 -  
183 - // 上标线开始时间,就是方向的首班车时间  
184 - var st = this._qIsUp ? oParam.getUpFirstDTimeObj() : oParam.getDownFirstDTimeObj();  
185 - // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向  
186 - var et;  
187 - var et_IsUp;  
188 - if (oParam.getUpLastDtimeObj().isBefore(  
189 - oParam.getDownLastDTimeObj())) {  
190 - et = oParam.getDownLastDTimeObj();  
191 - et_IsUp = false;  
192 - } else {  
193 - et = oParam.getUpLastDtimeObj();  
194 - et_IsUp = true;  
195 - }  
196 - //------------------------ 2、计算总共有多少圈 ------------------------//  
197 - this._qCount = 0; // 总的圈数  
198 -  
199 - // 以开始时间,结束时间,构造上标线用连班班次发车时间  
200 - var bcFcsjArrays = []; // 班次发车时间对象数组  
201 - var bcArsjArrays = []; // 班次到达时间对象数组  
202 - var isUp = this._qIsUp; // 方向  
203 - var bcCount = 1; // 班次数  
204 -  
205 - var _kssj = st; // 开始时间  
206 - var _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(isUp, _kssj, oParam); // 使用策略计算班次行驶时间  
207 - var _arrsj = oParam.addMinute(_kssj, _bcsj); // 到达时间  
208 - var _stoptimeRange = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
209 - _kssj, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam);  
210 - var _stoptime = _stoptimeRange[0]; // 最小停站时间  
211 -  
212 - do {  
213 - bcFcsjArrays.push(_kssj);  
214 - bcArsjArrays.push(_arrsj);  
215 -  
216 - _kssj = oParam.addMinute(_kssj, _bcsj + _stoptime);  
217 - // _bcsj = oParam.calcuTravelTime(_kssj, isUp);  
218 -  
219 - _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(isUp, _kssj, oParam); // 使用策略计算班次行驶时间  
220 - _arrsj = oParam.addMinute(_kssj, _bcsj);  
221 - _stoptimeRange = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
222 - _kssj, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam);  
223 - _stoptime = _stoptimeRange[0]; // 最小停站时间  
224 -  
225 - bcCount ++;  
226 - isUp = !isUp;  
227 - } while(_kssj.isBefore(et));  
228 - bcCount--; // 因为先做do,所以总的班次要减1  
229 -  
230 - var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈  
231 - var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈  
232 -  
233 - // 利用连班数组计算圈数  
234 - this._qCount = 1; // 前面加1圈,补中标线的班次  
235 - this._qCount += _qCount_p1;  
236 - this._qCount += _qCount_p2;  
237 -  
238 - // 计算最后是不是还要补一圈  
239 - if (this._qCount > 1) { // 总的圈数就1圈,没必要加了(其实是不可能的,除非参数里问题)  
240 - if (_qCount_p2 == 0) { // 没有余下班次,整数圈数  
241 - // 最后一个班次的方向一定和开始的方向相反,如:上-下,上-下,上-下,一共三圈,最后一个班次为下行  
242 - // 判定最后一个班次的方向和上标线判定结束时间的班次方向是否一致  
243 - if (!this._qIsUp == et_IsUp) {  
244 - // 一致不用加圈数  
245 - } else {  
246 - // 不一致需要加圈补最后一个结束时间班次  
247 - this._qCount ++;  
248 - }  
249 - } else {  
250 - // 有余下的圈数,最后要不补的班次不管上行,下行都在这一圈里  
251 - // 不需要在补圈数了  
252 - }  
253 - }  
254 - //------------------------ 3、根据路牌数,圈数创建路牌对象 ----------------------//  
255 - this._internalLpArray = []; // 内部路牌(InternalLpObj对象)数组  
256 -  
257 - // 创建内部的路牌数组  
258 - var i;  
259 - for (i = 0; i < this._aGanttLpArray.length; i++) {  
260 - this._internalLpArray.push(  
261 - new InternalLpObj(this._aGanttLpArray[i], this._qCount, this._qIsUp));  
262 - }  
263 -  
264 - // 初始化上标线,从第1圈开始  
265 - this._internalLpArray[0].initDataFromTimeToTime(  
266 - bcFcsjArrays[0], et, this._qIsUp, 1, oParam, _utils);  
267 -  
268 -  
269 - console.log("上行首班车时间:" + oParam.getUpFirstDTimeObj().format("HH:mm") +  
270 - "上行末班车时间:" + oParam.getUpLastDtimeObj().format("HH:mm"));  
271 - console.log("下行首班车时间:" + oParam.getDownFirstDTimeObj().format("HH:mm") +  
272 - "下行末班车时间:" + oParam.getDownLastDTimeObj().format("HH:mm"));  
273 - console.log("总共计算的圈数:" + this._qCount);  
274 - console.log("圈的方向isUP:" + this._qIsUp);  
275 -  
276 - console.log("//->>>>>>>>>>>>>>>>>>>>>>>>> v2_2行车计划,初始化2,工时,路牌信息 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-//");  
277 - //------------------------ 1、以上标线为基础,计算各种班型工时对应的圈数、班次数 -----------------------//  
278 - var aBcArray = this._internalLpArray[0].getBcArray();  
279 - aBcArray[0].fnSetIsFirstBc(true); // 设置首班班次标识  
280 -  
281 - if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算  
282 - aBcArray.splice(aBcArray.length - 1, 1);  
283 - }  
284 -  
285 - var iLTime = oParam.fnGetLunchTime(); // 午饭吃饭时间  
286 - var iDTime = oParam.fnGetDinnerTime(); // 晚饭吃饭时间  
287 - var iOutTime = this._qIsUp ? oParam.getUpOutTime() : oParam.getDownOutTime(); // 出场时间  
288 - var iInTime = this._qIsUp ? oParam.getDownInTime() : oParam.getUpInTime(); // 进场时间  
289 - var iBTime = oParam.getLbTime(); // 例保时间  
290 -  
291 - var sum = 0; // 总班次时间  
292 - for (i = 0; i < aBcArray.length; i++) {  
293 - sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();  
294 - }  
295 - sum += iLTime; // 加午饭时间  
296 - sum += iDTime; // 加晚饭时间  
297 -  
298 - this._aBxDesc = [ // 各种班型描述(班型名称,平均工时,平均需要的班次数,平均工时)  
299 - {'sType':'六工一休', 'fHoursV':6.66, 'fBcCount': 0, 'fAverTime': 0},  
300 - {'sType':'五工一休', 'fHoursV':6.85, 'fBcCount': 0, 'fAverTime': 0},  
301 - {'sType':'四工一休', 'fHoursV':7.14, 'fBcCount': 0, 'fAverTime': 0},  
302 - {'sType':'三工一休', 'fHoursV':7.61, 'fBcCount': 0, 'fAverTime': 0},  
303 - {'sType':'二工一休', 'fHoursV':8.57, 'fBcCount': 0, 'fAverTime': 0},  
304 - {'sType':'一工一休', 'fHoursV':11.42, 'fBcCount': 0, 'fAverTime': 0},  
305 - {'sType':'五工二休', 'fHoursV':7.99, 'fBcCount': 0, 'fAverTime': 0},  
306 - {'sType':'无工休', 'fHoursV':5.43, 'fBcCount': 0, 'fAverTime': 0}  
307 - ];  
308 -  
309 - for (i = 0; i < this._aBxDesc.length; i++) {  
310 - this._aBxDesc[i].fAverTime = sum / (aBcArray.length / 2); // 平均周转时间不算进出场,例保时间  
311 -  
312 - // 计算5休2的班次数(双进出场,4个例保)  
313 - if (i == 6) {  
314 - this._aBxDesc[i].fQCount =  
315 - (this._aBxDesc[i].fHoursV * 60 - iOutTime * 2 - iInTime * 2 - iBTime * 4) /  
316 - this._aBxDesc[i].fAverTime;  
317 - this._aBxDesc[i].fBcCount = this._aBxDesc[i].fQCount * 2;  
318 - } else { // 进出场,2个例保  
319 - this._aBxDesc[i].fQCount =  
320 - (this._aBxDesc[i].fHoursV * 60 - iOutTime - iInTime - iBTime * 2) /  
321 - this._aBxDesc[i].fAverTime;  
322 - this._aBxDesc[i].fBcCount = this._aBxDesc[i].fQCount * 2;  
323 - }  
324 - }  
325 - console.log("班型描述(以下):");  
326 - console.log(this._aBxDesc);  
327 - //--------------------- 2、计算分班连班班型车辆分布数 --------------------//  
328 - this._iBx_lb_lpcount = 0; // 连班路牌数  
329 - this._iBx_5_2_fb_lpcount = 0; // 5休2分班路牌数  
330 - this._iBx_other_fb_lpcount = 0; // 其他分班路牌数  
331 -  
332 - // 总共车辆数(高峰最大车辆数)  
333 - var iCls = InternalScheduleObj_v2_2.calcuClzx(oParam);  
334 - // 计算低谷最大周转时间  
335 - var _iTroughCycleTime =  
336 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(true, oParam.toTimeObj("13:00"), oParam) +  
337 - StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
338 - oParam.toTimeObj("13:00"), true,  
339 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1] +  
340 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, oParam.toTimeObj("13:00"), oParam) +  
341 - StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
342 - oParam.toTimeObj("13:00"), false,  
343 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1];  
344 -  
345 - // 低谷最少配车(预估最少连班车数量)  
346 - var iDgminpc = Math.ceil(_iTroughCycleTime / oParam.getTroughMaxFcjx());  
347 - // 加班车路牌数(做5休2的路牌数)  
348 - var i_5_2_lpes = oParam.getJBLpes();  
349 -  
350 - // v2_2版本的路牌分布就是连班分班加班车分布,总车辆数减去加班车,剩下的车对半开连班和其他分班,但是连班必须大于最少连班  
351 - if (iCls < iDgminpc) {  
352 - alert("总配车数小于低谷最小配车");  
353 - throw "总配车数小于低谷最小配车";  
354 - } else {  
355 - // 5_2路牌数  
356 - this._iBx_5_2_fb_lpcount = i_5_2_lpes;  
357 -  
358 - // 剩余车辆数  
359 - var _iOtherCls = iCls - this._iBx_5_2_fb_lpcount;  
360 - var _iHalfCls1; // 连班路牌数  
361 - var _iHalfCls2; // 其他分班路牌数  
362 - if (_iOtherCls % 2 == 0) { // 能整除  
363 - _iHalfCls1 = _iOtherCls / 2;  
364 - _iHalfCls2 = _iOtherCls / 2;  
365 - } else {  
366 - _iHalfCls1 = Math.floor(_iOtherCls / 2) + 1;  
367 - _iHalfCls2 = Math.floor(_iOtherCls / 2);  
368 - }  
369 - if (_iHalfCls1 > iDgminpc) {  
370 - this._iBx_lb_lpcount = _iHalfCls1;  
371 - this._iBx_other_fb_lpcount = _iHalfCls2;  
372 - } else {  
373 - this._iBx_lb_lpcount = iDgminpc;  
374 - this._iBx_other_fb_lpcount = iCls - this._iBx_lb_lpcount - i_5_2_lpes;  
375 - }  
376 - }  
377 -  
378 - //------------------------ 3、利用间隔法计算连班路牌分布 --------------------//  
379 - var i;  
380 - var j;  
381 - var iC1 = Math.floor(this._internalLpArray.length / this._iBx_lb_lpcount);  
382 - var iC2 = this._internalLpArray.length % this._iBx_lb_lpcount;  
383 - var iLpIndex;  
384 -  
385 - for (i = 0; i < this._iBx_lb_lpcount - iC2; i++) {  
386 - iLpIndex = i * iC1;  
387 - this._internalLpArray[iLpIndex].setBxLb(true);  
388 - this._internalLpArray[iLpIndex].setBxDesc("连班");  
389 - }  
390 - for (j = 0; j < iC2; j++) {  
391 - iLpIndex = i * iC1 + j * (iC1 + 1);  
392 - this._internalLpArray[iLpIndex].setBxLb(true);  
393 - this._internalLpArray[iLpIndex].setBxDesc("连班");  
394 - }  
395 - //------------------------ 4、利用间隔法计算分班班型路牌分布 --------------------//  
396 - // 获取分班路牌索引  
397 - var aNotLbIndexes = [];  
398 - for (i = 0; i < this._internalLpArray.length; i++) {  
399 - if (!this._internalLpArray[i].isBxLb()) {  
400 - aNotLbIndexes.push(i);  
401 - }  
402 - }  
403 - // 先5休2分班  
404 - iC1 = Math.floor(aNotLbIndexes.length / this._iBx_5_2_fb_lpcount);  
405 - iC2 = aNotLbIndexes.length % this._iBx_5_2_fb_lpcount;  
406 -  
407 - for (i = 0; i < this._iBx_5_2_fb_lpcount - iC2; i++) {  
408 - iLpIndex = aNotLbIndexes[i * iC1];  
409 - this._internalLpArray[iLpIndex].setBxLb(false);  
410 - this._internalLpArray[iLpIndex].setBxFb(true);  
411 - this._internalLpArray[iLpIndex].setBxFb5_2(true);  
412 - this._internalLpArray[iLpIndex].setBxDesc("5休2分班");  
413 - }  
414 - for (i = 0; i < iC2; i++) {  
415 - iLpIndex = aNotLbIndexes[this._iBx_5_2_fb_lpcount - iC2 + i * (iC1 + 1)];  
416 - this._internalLpArray[iLpIndex].setBxLb(false);  
417 - this._internalLpArray[iLpIndex].setBxFb(true);  
418 - this._internalLpArray[iLpIndex].setBxFb5_2(true);  
419 - this._internalLpArray[iLpIndex].setBxDesc("5休2分班");  
420 - }  
421 - // 其他分班  
422 - for (i = 0; i < aNotLbIndexes.length; i++) {  
423 - iLpIndex = aNotLbIndexes[i];  
424 - if (!this._internalLpArray[iLpIndex].isBxFb5_2()) {  
425 - this._internalLpArray[iLpIndex].setBxLb(false);  
426 - this._internalLpArray[iLpIndex].setBxFb(true);  
427 - this._internalLpArray[iLpIndex].setBxFb5_2(false);  
428 - this._internalLpArray[iLpIndex].setBxDesc("其他分班");  
429 - }  
430 - }  
431 -  
432 - console.log("高峰周转时间:" + oParam.calcuPeakZzsj());  
433 - console.log("连班路牌数:" + this._iBx_lb_lpcount);  
434 - console.log("5休2分班路牌数:" + this._iBx_5_2_fb_lpcount);  
435 - console.log("其他分班路牌数:" + this._iBx_other_fb_lpcount);  
436 - var aLbIndexes = [];  
437 - for (i = 0; i < this._internalLpArray.length; i++) {  
438 - if (this._internalLpArray[i].isBxLb()) {  
439 - aLbIndexes.push(i);  
440 - }  
441 - }  
442 - console.log("连班路牌indexes=" + aLbIndexes);  
443 - var a_5_2_fbIndexes = [];  
444 - for (i = 0; i < this._internalLpArray.length; i++) {  
445 - if (this._internalLpArray[i].isBxFb() && this._internalLpArray[i].isBxFb5_2()) {  
446 - a_5_2_fbIndexes.push(i);  
447 - }  
448 - }  
449 - console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes);  
450 - var a_other_fbIndexes = [];  
451 - for (i = 0; i < this._internalLpArray.length; i++) {  
452 - if (this._internalLpArray[i].isBxFb() && !this._internalLpArray[i].isBxFb5_2()) {  
453 - a_other_fbIndexes.push(i);  
454 - }  
455 - }  
456 - console.log("其他分班路牌indexes=" + a_other_fbIndexes);  
457 -  
458 - console.log("//->>>>>>>>>>>>>>>>> v2_3行车计划,初始化3,计算上标线第一个主站副站班次信息 <<<<<<<<<<<<<<<<<<<<<-//");  
459 - // 计算上标线第一个主站班次,副站班次的位置  
460 - this._oFirstMasterBc = undefined; // 早高峰主站方向班次  
461 - this._iFirstMasterBcGroupIndex = undefined; // 早高峰主站方向圈索引  
462 - this._iFirstMasterBcIndex = undefined; // 早高峰主站方向班次索引  
463 -  
464 - this._oFirstSlaveBc = undefined; // 早高峰副站方向班次  
465 - this._iFirstSlaveBcGroupIndex = undefined; // 早高峰副站方向圈索引  
466 - this._iFirstSlaveBcIndex = undefined; // 早高峰副站方向班次索引  
467 -  
468 - if (this._qIsUp) {  
469 - if (this._oParam.isUpOneWayStop()) {  
470 - this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 0);  
471 - this._iFirstMasterBcGroupIndex = 1;  
472 - this._iFirstMasterBcIndex = 0;  
473 -  
474 - this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 1);  
475 - this._iFirstSlaveBcGroupIndex = 1;  
476 - this._iFirstSlaveBcIndex = 1;  
477 - } else {  
478 - this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 1);  
479 - this._iFirstMasterBcGroupIndex = 1;  
480 - this._iFirstMasterBcIndex = 1;  
481 -  
482 - this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 0);  
483 - this._iFirstSlaveBcGroupIndex = 1;  
484 - this._iFirstSlaveBcIndex = 0;  
485 - }  
486 - } else {  
487 - if (this._oParam.isUpOneWayStop()) {  
488 - this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 1);  
489 - this._iFirstMasterBcGroupIndex = 1;  
490 - this._iFirstMasterBcIndex = 1;  
491 -  
492 - this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 0);  
493 - this._iFirstSlaveBcGroupIndex = 1;  
494 - this._iFirstSlaveBcIndex = 0;  
495 - } else {  
496 - this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 0);  
497 - this._iFirstMasterBcGroupIndex = 1;  
498 - this._iFirstMasterBcIndex = 0;  
499 -  
500 - this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 1);  
501 - this._iFirstSlaveBcGroupIndex = 1;  
502 - this._iFirstSlaveBcIndex = 1;  
503 - }  
504 - }  
505 -  
506 - console.log("早高峰副站方向(start)班次=" + (this._oFirstSlaveBc ? this._oFirstSlaveBc.getFcTimeObj().format("HH:mm") : "未找到"));  
507 - console.log("早高峰副站方向(start)班次圈索引=" + (this._oFirstSlaveBc ? this._iFirstSlaveBcGroupIndex : "未找到"));  
508 - console.log("早高峰副站方向(start)班次索引=" + (this._oFirstSlaveBc ? this._iFirstSlaveBcIndex : "未找到"));  
509 - console.log("早高峰主站方向(start)班次=" + (this._oFirstMasterBc ? this._oFirstMasterBc.getFcTimeObj().format("HH:mm") : "未找到"));  
510 - console.log("早高峰主站方向(start)班次圈索引=" + (this._oFirstMasterBc ? this._iFirstMasterBcGroupIndex : "未找到"));  
511 - console.log("早高峰主站方向(start)班次索引=" + (this._oFirstMasterBc ? this._iFirstMasterBcIndex : "未找到"));  
512 -  
513 - console.log("//->>>>>>>>>>>>>>>>> v2_4行车计划,初始化4,从上标线第一圈第一个副站班次开始初始化后续路牌班次列表 <<<<<<<<<<<<<<<<<<<<<-//");  
514 - // 初始化上标线副站班次  
515 - var oPreBc; // 上一个班次(从上标线副站班次开始)  
516 - var oNextBc; // 计算的下一个班次  
517 - var oNextBcFcTime; // 下一个班次的发车时间  
518 - var aBcInterval = []; // 班次间隔数组  
519 - var oBcInterval; // 班次间隔对象  
520 - var iNextBcInterval; // 下一个班次发车间隔  
521 -  
522 - // 当初始化完一圈的副站班次后,最后一个班次是下一圈的上标线副站班次(一圈的周转结束班次),需要调整时间及其前一个主站班次的时间  
523 - var _modifyTimeNextGroupIndex; // 上标线下一圈索引  
524 - var _modifyTimeNextBcIndex; // 上标线下一圈班次索引  
525 - var _modifyBc; // 上标线下一个圈的班次  
526 - var _modifyPreBc; // 上标线下一个圈班次的前一个班次  
527 - var _modifyTime; // 上标线下一个圈班次的前一个班次的调整时间  
528 -  
529 - if (this._iFirstSlaveBcIndex == 0) { // 第一圈第二个班次是主站,则第一个班次是副站  
530 - oPreBc = this._internalLpArray[0].getBc(this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex);  
531 -  
532 - aBcInterval = StrategyUtils_v2_2.sFn("CALCU_HEADWAY_2")(  
533 - this,  
534 - this._oParam,  
535 - 1,  
536 - this._iFirstSlaveBcIndex,  
537 - this._$calcuCycleTime(oPreBc.getFcTimeObj())[0],  
538 - this._$calcuCycleTime(oPreBc.getFcTimeObj())[1]  
539 - );  
540 -  
541 - for (i = 1; i < this._internalLpArray.length; i++) {  
542 - oBcInterval = aBcInterval[i - 1];  
543 -  
544 - if (oBcInterval.hasBc) {  
545 - // 参考的发车间隔  
546 - iNextBcInterval = oBcInterval.iFcInterval;  
547 - oNextBcFcTime = this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval);  
548 - this._internalLpArray[i].fnSetVerticalIntervalTime(  
549 - this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex, iNextBcInterval);  
550 - this._internalLpArray[i].fnSetHeadwayS2_P(  
551 - this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex, oBcInterval.fP);  
552 -  
553 - oNextBc = _utils.createBcObj(  
554 - this._internalLpArray[i],  
555 - "normal",  
556 - !this._oParam.isUpOneWayStop(),  
557 - 1,  
558 - oNextBcFcTime,  
559 - this._oParam);  
560 -  
561 - this._internalLpArray[i].setBc(  
562 - this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex, oNextBc);  
563 -  
564 - oPreBc = oNextBc;  
565 - }  
566 - }  
567 -  
568 - // 修正上标线副站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续所有班次  
569 - iNextBcInterval = aBcInterval[i - 1].iFcInterval;  
570 - _modifyTimeNextGroupIndex = this._iFirstSlaveBcGroupIndex + 1;  
571 - _modifyTimeNextBcIndex = this._iFirstSlaveBcIndex;  
572 -  
573 - _utils.modifySBXMasterBc(  
574 - this._internalLpArray[0],  
575 - this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval),  
576 - this._iFirstSlaveBcGroupIndex + 1,  
577 - this._iFirstSlaveBcIndex,  
578 - oPreBc.isUp(),  
579 - this._oParam  
580 - );  
581 -  
582 - // 调整上标线副站班次一圈后的前一个主站班次时间  
583 - _modifyBc = this._internalLpArray[0].getBc(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex);  
584 - if (_modifyBc) {  
585 - this._internalLpArray[0].fnSetVerticalIntervalTime(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex, iNextBcInterval);  
586 -  
587 - _modifyPreBc = this._internalLpArray[0].getPreBc(_modifyBc);  
588 - _modifyTime = _modifyBc.getFcTimeObj().diff(_modifyPreBc.getArrTimeObj(), "m") - 1; // 主站到副站停站使用1分钟  
589 - // 修改发车时间,到达时间,不改行驶时间  
590 - _modifyPreBc.getFcTimeObj().add(_modifyTime, "m");  
591 - _modifyPreBc.getArrTimeObj().add(_modifyTime, "m");  
592 -  
593 - }  
594 -  
595 - }  
596 -  
597 - console.log("//->>>>>>>>>>>>>>>>> v2_6行车计划,初始化6,创建第一圈的主站班次开始班次列表,然后修正 <<<<<<<<<<<<<<<<<<<<<-//");  
598 - this.fnCreateBclistWithMasterBc(1, 1); // 从上标线第一圈的主站班次开始初始化所有路牌的相关班次  
599 - // 第一圈的第一个班次是副站,则需要修正this.fnCreateBclistWithMasterBc(1)班次之间的问题,停站时间为负数  
600 - if (this._iFirstSlaveBcIndex == 0) {  
601 - StrategyUtils_v2_2.sFn("ADJUST_HEADWAY")(  
602 - this, this._oParam,  
603 - this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex,  
604 - this._iFirstMasterBcGroupIndex, this._iFirstMasterBcIndex,  
605 - 5 // 修正至少要5分钟停站  
606 - );  
607 - }  
608 -  
609 - console.log("//->>>>>>>>>>>>>>>>> v2_7行车计划,初始化7,修正中标线班次列表 <<<<<<<<<<<<<<<<<<<<<-//");  
610 - // // TODO:补充中标线班次,这里假设,前一半圈就是中标线,以后再精细处理  
611 - // // 中标线开始时间,早的首班车时间,和上标线的开始时间方向相反  
612 - // var oSt = !this._qIsUp ? this._oParam.getUpFirstDTimeObj() : this._oParam.getDownFirstDTimeObj();  
613 - // var iStRuntime; // 中标线方向班次行驶时间(使用低谷)  
614 - // if (!this._qIsUp) { // 上行  
615 - // if (this._oParam.isTroughBc(oSt)) {  
616 - // iStRuntime = this._oParam.getUpTroughTime();  
617 - // } else {  
618 - // iStRuntime = this._oParam.getUpMPeakTime();  
619 - // }  
620 - // } else { // 下行  
621 - // if (this._oParam.isTroughBc(oSt)) {  
622 - // iStRuntime = this._oParam.getDownTroughTime();  
623 - // } else {  
624 - // iStRuntime = this._oParam.getDownMPeakTime();  
625 - // }  
626 - // }  
627 - //  
628 - // var oSLp;  
629 - // var oSBc;  
630 - // var oSEmuBcFcTime; // 模拟班次发车时间  
631 - // var iTimeDiff;  
632 - // var iTempTime;  
633 - // var iSModifyLpIndex; // 中标线对应路牌索引  
634 - // for (i = 1; i < this._internalLpArray.length; i++) {  
635 - // oSLp = this._internalLpArray[i];  
636 - // oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次  
637 - // if (!oSBc) { // 可能没有,跳过  
638 - // continue;  
639 - // }  
640 - // oSEmuBcFcTime = this._oParam.addMinute(  
641 - // oSBc.getFcTimeObj(),  
642 - // -(iStRuntime + 1)  
643 - // );  
644 - // iTempTime = oSEmuBcFcTime.diff(oSt, "m");  
645 - // if (iTimeDiff == undefined) {  
646 - // iTimeDiff = iTempTime;  
647 - // iSModifyLpIndex = i;  
648 - // } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff) && oSEmuBcFcTime.isAfter(oSt)) {  
649 - // iTimeDiff = iTempTime;  
650 - // iSModifyLpIndex = i;  
651 - // }  
652 - // }  
653 - //  
654 - // // 添加上标线头班次(分班连班都可能)  
655 - // this._internalLpArray[iSModifyLpIndex].setBc(  
656 - // 0, 1,  
657 - // _utils.createBcObj(  
658 - // this._internalLpArray[iSModifyLpIndex],  
659 - // "normal",  
660 - // !this._qIsUp,  
661 - // 1,  
662 - // oSt,  
663 - // this._oParam)  
664 - // );  
665 - //  
666 - // // 从当前班次开始,如果是低谷,隔开方向加班次,如果是高峰,都加班次  
667 - // var iSInverval = Math.ceil((this._oParam.getMPeakMinFcjx() + this._oParam.getMPeakMaxFcjx()) / 2);  
668 - // for (i = iSModifyLpIndex + 1; i < this._internalLpArray.length; i++) {  
669 - // oSLp = this._internalLpArray[i];  
670 - // oSEmuBcFcTime = this._oParam.addMinute(oSt, iSInverval * (i - iSModifyLpIndex));  
671 - // if (this._oParam.isMPeakBc(oSEmuBcFcTime)) { // 高峰  
672 - // if (!this._qIsUp) { // 上行  
673 - // iStRuntime = this._oParam.getUpMPeakTime();  
674 - // } else { // 下行  
675 - // iStRuntime = this._oParam.getDownMPeakTime();  
676 - // }  
677 - // oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次  
678 - // oSLp.setBc(  
679 - // 0, 1,  
680 - // _utils.createBcObj(  
681 - // oSLp,  
682 - // "normal",  
683 - // !this._qIsUp,  
684 - // 1,  
685 - // this._oParam.addMinute(oSBc.getFcTimeObj(), -(iStRuntime + 1)),  
686 - // this._oParam)  
687 - // );  
688 - // } else { // 低谷隔开出班次  
689 - // if (!this._qIsUp) { // 上行  
690 - // iStRuntime = this._oParam.getUpTroughTime();  
691 - // } else { // 下行  
692 - // iStRuntime = this._oParam.getDownTroughTime();  
693 - // }  
694 - //  
695 - // if (!this._internalLpArray[i - 1].getBc(0, 1)) {  
696 - // // 上一个路牌没有班次,添加  
697 - // oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次  
698 - // if (oSBc) {  
699 - // oSLp.setBc(  
700 - // 0, 1,  
701 - // _utils.createBcObj(  
702 - // oSLp,  
703 - // "normal",  
704 - // !this._qIsUp,  
705 - // 1,  
706 - // this._oParam.addMinute(oSBc.getFcTimeObj(), -(iStRuntime + 1)),  
707 - // this._oParam)  
708 - // );  
709 - //  
710 - // // 如果生成的班次行驶时间不足,删除这个班次  
711 - // if (oSLp.getBc(1, 0).getFcTimeObj().isBefore(oSLp.getBc(0, 1).getArrTimeObj())) {  
712 - // oSLp.getGroup(0).setBc1(undefined);  
713 - // oSLp.getGroup(0).setBc2(undefined);  
714 - // }  
715 - // }  
716 - // }  
717 - // }  
718 - // }  
719 - //  
720 - // console.log("中标线路牌索引=" + iSModifyLpIndex);  
721 -  
722 -  
723 - }  
724 -  
725 - //------------------------- 核心业务方法 -----------------------//  
726 -  
727 - /**  
728 - * 核心方法,从上标线主站班次开始,一圈一圈生成每圈的主站班次,  
729 - * 每生成一个主站班次,尝试生成后面紧邻的副站班次(停站时间1到3分种调整)。  
730 - * @param iGroupIndex 圈索引  
731 - * @param iCount 共几圈  
732 - */  
733 - InternalScheduleObj.prototype.fnCreateBclistWithMasterBc = function(iGroupIndex, iCount) {  
734 - var i;  
735 - var j;  
736 - // var oPreBc = this._oFirstMasterBc; // 上一个班次(从上标线主站班次开始)  
737 - var oPreBc = this._internalLpArray[0].getBc(iGroupIndex, this._iFirstMasterBcIndex);  
738 - var oNextBc; // 计算的下一个班次  
739 - var oNextBcFcTime; // 下一个班次的发车时间  
740 - var aBcInterval = []; // 班次间隔数组  
741 - var oBcInterval; // 班次间隔对象  
742 - var iNextBcInterval; // 下一个班次发车间隔  
743 -  
744 - var oPreSlaveBc; // 上一个副站班次(上标线主站后的一个副站班次)  
745 - var oNextSlaveBc; // 下一个副站班次  
746 -  
747 - // 当初始化完一圈的主站班次后,最后一个班次是下一圈的上标线主站班次,需要判定存在然后添加间隔  
748 - var _modifyTimeNextGroupIndex; // 上标线下一圈索引  
749 - var _modifyTimeNextBcIndex; // 上标线下一圈班次索引  
750 - var _modifyBc; // 上标线下一个圈的班次  
751 -  
752 - var iStart = iGroupIndex;  
753 - var iEnd = iGroupIndex + iCount;  
754 - if (iEnd > this._qCount) {  
755 - iEnd = this._qCount;  
756 - }  
757 -  
758 - for (i = iStart; i < iEnd; i++) {  
759 - aBcInterval = StrategyUtils_v2_2.sFn("CALCU_HEADWAY_2")(  
760 - this,  
761 - this._oParam,  
762 - i,  
763 - this._iFirstMasterBcIndex,  
764 - this._$calcuCycleTime(oPreBc.getFcTimeObj())[0],  
765 - this._$calcuCycleTime(oPreBc.getFcTimeObj())[1]  
766 - );  
767 -  
768 - if (aBcInterval.length == 0) {  
769 - // 等于0说明上标线没班次了  
770 - break;  
771 - }  
772 -  
773 - for (j = 1; j < this._internalLpArray.length; j++) {  
774 - oBcInterval = aBcInterval[j - 1];  
775 - if (oBcInterval.hasBc) {  
776 - iNextBcInterval = oBcInterval.iFcInterval;  
777 - oNextBcFcTime = this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval);  
778 - this._internalLpArray[j].fnSetVerticalIntervalTime(i, this._iFirstMasterBcIndex, iNextBcInterval);  
779 - this._internalLpArray[j].fnSetHeadwayS2_P(i, this._iFirstMasterBcIndex, oBcInterval.fP);  
780 -  
781 - oNextBc = _utils.createBcObj(  
782 - this._internalLpArray[j],  
783 - "normal",  
784 - this._oParam.isUpOneWayStop(),  
785 - 1,  
786 - oNextBcFcTime,  
787 - this._oParam);  
788 -  
789 - this._internalLpArray[j].setBc(  
790 - i, this._iFirstMasterBcIndex, oNextBc);  
791 - oPreBc = oNextBc;  
792 - }  
793 - }  
794 -  
795 - // 修正上标线主站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续所有班次  
796 - oBcInterval = aBcInterval[j - 1];  
797 - if (oBcInterval.hasBc) {  
798 - iNextBcInterval = oBcInterval.iFcInterval;  
799 - _modifyTimeNextGroupIndex = i + 1;  
800 - _modifyTimeNextBcIndex = this._iFirstMasterBcIndex;  
801 -  
802 - _utils.modifySBXMasterBc(  
803 - this._internalLpArray[0],  
804 - this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval),  
805 - _modifyTimeNextGroupIndex,  
806 - _modifyTimeNextBcIndex,  
807 - oPreBc.isUp(),  
808 - this._oParam  
809 - );  
810 -  
811 - // 修正上标线主站方向的班次后,一圈结束的班次可能不存在(超过末班车时间了),需要判定  
812 - _modifyBc = this._internalLpArray[0].getBc(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex);  
813 - if (_modifyBc) { // 存在修正间隔值  
814 - this._internalLpArray[0].fnSetVerticalIntervalTime(  
815 - _modifyTimeNextGroupIndex, _modifyTimeNextBcIndex, iNextBcInterval);  
816 - oPreBc = _modifyBc;  
817 - }  
818 -  
819 - }  
820 -  
821 - // 添加副站班次,就是主站班次到达时间加1分钟  
822 - // TODO:因为副站停站时间1分钟到3分钟,几乎没有停站时间,一般前面主站是多少间隔,后面如果有副站的话也是多少间隔  
823 - // TODO:此时,可能出现临界问题,当主站还是高峰接近低谷时,副站已经是低谷,此时副站发车间隔还是高峰间隔  
824 - // TODO:上述情况可以通过让临界的主站高峰班次使用高峰最大间隔,副站使用3分钟的最大停站使副站间隔达到低谷最小间隔  
825 - oPreSlaveBc = this._internalLpArray[0].getBc(  
826 - this._iFirstMasterBcIndex == 0 ? i : i + 1,  
827 - this._iFirstMasterBcIndex == 0 ? 1 : 0  
828 - );  
829 - for (j = 1; j < this._internalLpArray.length; j++) {  
830 - if (oPreSlaveBc) {  
831 - if (aBcInterval[j - 1].hasBc) { // 有主站必有副站  
832 - // 获取当前路牌前一个主站班次  
833 - if (this._internalLpArray[j].getBc(  
834 - i,  
835 - this._iFirstMasterBcIndex)) { // 相同路牌上一个主站班次存在  
836 - oNextSlaveBc = _utils.createBcObj(  
837 - this._internalLpArray[j],  
838 - "normal",  
839 - !this._oParam.isUpOneWayStop(),  
840 - 1,  
841 - this._oParam.addMinute( // 使用1分钟副站停站  
842 - this._internalLpArray[j].getBc(  
843 - i, this._iFirstMasterBcIndex).getArrTimeObj(),  
844 - 1),  
845 - this._oParam);  
846 -  
847 - if (oNextSlaveBc.isUp()) {  
848 - if (!oNextSlaveBc.getFcTimeObj().isAfter(this._oParam.getUpLastDtimeObj())) {  
849 - this._internalLpArray[j].setBc(  
850 - this._iFirstMasterBcIndex == 0 ? i : i + 1,  
851 - this._iFirstMasterBcIndex == 0 ? 1 : 0,  
852 - oNextSlaveBc);  
853 - oPreSlaveBc = oNextSlaveBc;  
854 - }  
855 - } else {  
856 - if (!oPreSlaveBc.getFcTimeObj().isAfter(this._oParam.getDownLastDTimeObj())) {  
857 - this._internalLpArray[j].setBc(  
858 - this._iFirstMasterBcIndex == 0 ? i : i + 1,  
859 - this._iFirstMasterBcIndex == 0 ? 1 : 0,  
860 - oNextSlaveBc);  
861 - oPreSlaveBc = oNextSlaveBc;  
862 - }  
863 - }  
864 - }  
865 - }  
866 - }  
867 - }  
868 -  
869 -  
870 - }  
871 -  
872 - };  
873 -  
874 - //------------- 其他业务方法 -------------//  
875 -  
876 - /**  
877 - * 调整发车间隔。  
878 - */  
879 - InternalScheduleObj.prototype.fnAdjustHeadway = function() {  
880 - // // TODO:572测试,尝试调整第6圈  
881 - // StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(  
882 - // this, this._oParam,  
883 - // 6, 0,  
884 - // 6, 1,  
885 - // 0.2  
886 - // );  
887 - // // TODO:843测试  
888 - // StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(  
889 - // this, this._oParam,  
890 - // 3, 0,  
891 - // 3, 1,  
892 - // 0.2  
893 - // );  
894 -  
895 - var i;  
896 - var bQIsAnotherWay; // 圈的第一个班次是否副站  
897 - if (this._qIsUp) {  
898 - if (this._oParam.getDirAnotherWayStop()) {  
899 - bQIsAnotherWay = true;  
900 - } else {  
901 - bQIsAnotherWay = false;  
902 - }  
903 - } else {  
904 - if (this._oParam.getDirAnotherWayStop()) {  
905 - bQIsAnotherWay = false;  
906 - } else {  
907 - bQIsAnotherWay = true;  
908 - }  
909 - }  
910 -  
911 - if (this._qIsUp == bQIsAnotherWay) {  
912 - for (i = 0; i < this._qCount; i++) {  
913 - StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(  
914 - this, this._oParam,  
915 - i, 0,  
916 - i, 1,  
917 - 0.2  
918 - );  
919 - }  
920 - } else { // 圈的第一个班次是主站班次  
921 - for (i = 0; i < this._qCount; i++) {  
922 - if ((i + 1) < this._qCount) {  
923 - StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(  
924 - this, this._oParam,  
925 - i, 1,  
926 - (i + 1), 0,  
927 - 0.2  
928 - );  
929 - }  
930 - }  
931 - }  
932 -  
933 -  
934 - };  
935 -  
936 - /**  
937 - * 计算吃饭班次。  
938 - */  
939 - InternalScheduleObj.prototype.fnCalcuEatBc = function() {  
940 - var i;  
941 - var j;  
942 - var oLp;  
943 - var oBc;  
944 - // 1、标记吃饭班次  
945 - var oEatFlag = {}; // {"路牌编号":{isLaunch: false, isDinner: false},...}  
946 - for (i = 0; i < this._internalLpArray.length; i++) {  
947 - oLp = this._internalLpArray[i];  
948 - if (oLp.isBxLb()) { // 暂时判定只有连班吃饭  
949 - oEatFlag[oLp.getLpNo()] = {};  
950 - oEatFlag[oLp.getLpNo()]["isLaunch"] = false;  
951 - oEatFlag[oLp.getLpNo()]["isDinner"] = false;  
952 - for (j = 0; j < oLp.getBcArray().length; j++) {  
953 - oBc = oLp.getBcArray()[j];  
954 - // 午饭,暂时判定10:30到13:00  
955 - if (oBc.isUp() == this._oParam.isUpOneWayStop() &&  
956 - oBc.getFcTimeObj().isAfter(this._oParam.toTimeObj("10:30")) &&  
957 - oBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("13:30"))) {  
958 - if (!oEatFlag[oLp.getLpNo()]["isLaunch"]) {  
959 - oBc.fnSetEatTime(this._oParam.fnGetLunchTime());  
960 - oEatFlag[oLp.getLpNo()]["isLaunch"] = true;  
961 - // console.log("吃饭班次时间=" + oBc.format("HH:mm"));  
962 - }  
963 - }  
964 - // 晚饭,暂时判定17:30  
965 - if (oBc.isUp() == this._oParam.isUpOneWayStop() &&  
966 - oBc.getFcTimeObj().isAfter(this._oParam.toTimeObj("17:00")) &&  
967 - oBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("20:00"))) {  
968 - if (!oEatFlag[oLp.getLpNo()]["isDinner"]) {  
969 - oBc.fnSetEatTime(this._oParam.fnGetDinnerTime());  
970 - oEatFlag[oLp.getLpNo()]["isDinner"] = true;  
971 - // console.log("晚饭班次时间=" + oBc.format("HH:mm"));  
972 - }  
973 - }  
974 - }  
975 - }  
976 - }  
977 -  
978 - // 2、调整吃饭所需的停站时间  
979 - StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_3_EAT")(  
980 - this, this._oParam  
981 - );  
982 - };  
983 -  
984 - /**  
985 - * 计算末班车。  
986 - * 1、将上下行拉成上下行两个班次列表(包括标记班次)  
987 - * 2、分别找出离末班车发车时间最近的班次,并替换时间  
988 - * 3、删除之后的班次  
989 - */  
990 - InternalScheduleObj.prototype.fnCalcuLastBc = function() {  
991 - var i;  
992 - var iTimeDiff;  
993 - var iTempTime;  
994 - var aBc;  
995 - var oLastBcTime;  
996 - var oLastBcIsUp;  
997 - var iModifyIndex;  
998 -  
999 - // 查找末班车早的末班车时间和方向  
1000 - if (this._oParam.getUpLastDtimeObj().isBefore(this._oParam.getDownLastDTimeObj())) {  
1001 - oLastBcTime = this._oParam.getUpLastDtimeObj();  
1002 - oLastBcIsUp = true;  
1003 - } else {  
1004 - oLastBcTime = this._oParam.getDownLastDTimeObj();  
1005 - oLastBcIsUp = false;  
1006 - }  
1007 -  
1008 - // 确定早的末班车时间  
1009 - aBc = this.fnGetBcList(oLastBcIsUp);  
1010 - for (i = 0; i < aBc.length; i++) {  
1011 - iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");  
1012 - if (iTimeDiff == undefined) {  
1013 - iTimeDiff = iTempTime;  
1014 - iModifyIndex = i;  
1015 - } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {  
1016 - iTimeDiff = iTempTime;  
1017 - iModifyIndex = i;  
1018 - }  
1019 - }  
1020 - aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间  
1021 - aBc[iModifyIndex].fnSetDelFlag(false);  
1022 - aBc[iModifyIndex].fnSetIsLastBc(true);  
1023 - for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次  
1024 - this._qIsUp == oLastBcIsUp ?  
1025 - aBc[i]._$$_internal_group_obj.setBc1(undefined) :  
1026 - aBc[i]._$$_internal_group_obj.setBc2(undefined);  
1027 - }  
1028 -  
1029 - // 查找末班车晚的末班车时间和方向  
1030 - if (this._oParam.getUpLastDtimeObj().isBefore(this._oParam.getDownLastDTimeObj())) {  
1031 - oLastBcTime = this._oParam.getDownLastDTimeObj();  
1032 - oLastBcIsUp = false;  
1033 - } else {  
1034 - oLastBcTime = this._oParam.getUpLastDtimeObj();  
1035 - oLastBcIsUp = true;  
1036 - }  
1037 - // 确定晚的末班车时间  
1038 - aBc = this.fnGetBcList(oLastBcIsUp);  
1039 - var oBc;  
1040 - var aBcIndex;  
1041 - var iLpIndex;  
1042 - var iQIndex;  
1043 - var iBcIndex;  
1044 -  
1045 - iTimeDiff = undefined;  
1046 - for (i = 0; i < aBc.length; i++) {  
1047 - oBc = aBc[i];  
1048 - aBcIndex = this.fnGetBcIndex(oBc);  
1049 -  
1050 - iLpIndex = aBcIndex[0];  
1051 - iQIndex = aBcIndex[2] == 0 ? aBcIndex[1] -1 : aBcIndex[1];  
1052 - iBcIndex = aBcIndex[2] == 0 ? 1 : 0;  
1053 -  
1054 - if (!this._internalLpArray[iLpIndex].getBc(iQIndex, iBcIndex)) {  
1055 - continue;  
1056 - }  
1057 -  
1058 - iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");  
1059 - if (iTimeDiff == undefined) {  
1060 - iTimeDiff = iTempTime;  
1061 - iModifyIndex = i;  
1062 - } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {  
1063 - iTimeDiff = iTempTime;  
1064 - iModifyIndex = i;  
1065 - }  
1066 - }  
1067 - aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间  
1068 - aBc[iModifyIndex].fnSetDelFlag(false);  
1069 - aBc[iModifyIndex].fnSetIsLastBc(true);  
1070 - for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次  
1071 - this._qIsUp == oLastBcIsUp ?  
1072 - aBc[i]._$$_internal_group_obj.setBc1(undefined) :  
1073 - aBc[i]._$$_internal_group_obj.setBc2(undefined);  
1074 - }  
1075 - };  
1076 -  
1077 - /**  
1078 - * 重新设置停站时间(发车时间减到达时间)。  
1079 - */  
1080 - InternalScheduleObj.prototype.fnReSetLayoverTime = function() {  
1081 - for (var i = 0; i < this._internalLpArray.length; i++) {  
1082 - this._internalLpArray[i].modifyLayoverTimeWithoutFcTime();  
1083 - }  
1084 - };  
1085 -  
1086 - /**  
1087 - * 补进出场例保班次。  
1088 - */  
1089 - InternalScheduleObj.prototype.fnCalcuOtherBc = function() {  
1090 - var i;  
1091 - var j;  
1092 - var iBcChainCount;  
1093 - var oLp;  
1094 - var aOtherBc;  
1095 - var oStartBc;  
1096 - var oEndBc;  
1097 -  
1098 - for (i = 0; i < this._internalLpArray.length; i++) {  
1099 - aOtherBc = [];  
1100 - oLp = this._internalLpArray[i];  
1101 - iBcChainCount = oLp.fnGetBcChainCount();  
1102 -  
1103 - if (iBcChainCount == 1) { // 只有一个车次链,是连班班型  
1104 - // 头部要添加出场,例保班次  
1105 - oStartBc = oLp.getBc(  
1106 - oLp.fnGetBcChainInfo(0)["s_q"],  
1107 - oLp.fnGetBcChainInfo(0)["s_b"]  
1108 - );  
1109 - aOtherBc.push(_utils.createBcObj(  
1110 - oLp, "bd", oStartBc.isUp(), 1,  
1111 - oStartBc.getFcTimeObj(),  
1112 - this._oParam  
1113 - ));  
1114 - aOtherBc.push(_utils.createBcObj(  
1115 - oLp, "out", oStartBc.isUp(), 1,  
1116 - oStartBc.getFcTimeObj(),  
1117 - this._oParam  
1118 - ));  
1119 -  
1120 - // 尾部需添加进场,例保班次  
1121 - oEndBc = oLp.getBc(  
1122 - oLp.fnGetBcChainInfo(0)["e_q"],  
1123 - oLp.fnGetBcChainInfo(0)["e_b"]  
1124 - );  
1125 - oEndBc.fnSetIsLastBc(false); // 有可能最后一个班次是吃饭班次,重置  
1126 - oEndBc.fnSetEatTime(0); // 有可能最后一个班次是吃饭班次,重置  
1127 - aOtherBc.push(_utils.createBcObj(  
1128 - oLp, "in", !oEndBc.isUp(), 1,  
1129 - oEndBc.getArrTimeObj(),  
1130 - this._oParam  
1131 - ));  
1132 - aOtherBc.push(_utils.createBcObj(  
1133 - oLp, "lc", !oEndBc.isUp(), 1,  
1134 - oEndBc.getArrTimeObj(),  
1135 - this._oParam  
1136 - ));  
1137 - } else if (iBcChainCount == 2) { // 两个车次链,是分班班型  
1138 - // 第一个车次链开头有出场,报到班次,车次链结尾只有进场班次  
1139 - oStartBc = oLp.getBc(  
1140 - oLp.fnGetBcChainInfo(0)["s_q"],  
1141 - oLp.fnGetBcChainInfo(0)["s_b"]  
1142 - );  
1143 - aOtherBc.push(_utils.createBcObj(  
1144 - oLp, "bd", oStartBc.isUp(), 1,  
1145 - oStartBc.getFcTimeObj(),  
1146 - this._oParam  
1147 - ));  
1148 - aOtherBc.push(_utils.createBcObj(  
1149 - oLp, "out", oStartBc.isUp(), 1,  
1150 - oStartBc.getFcTimeObj(),  
1151 - this._oParam  
1152 - ));  
1153 -  
1154 - oEndBc = oLp.getBc(  
1155 - oLp.fnGetBcChainInfo(0)["e_q"],  
1156 - oLp.fnGetBcChainInfo(0)["e_b"]  
1157 - );  
1158 - aOtherBc.push(_utils.createBcObj(  
1159 - oLp, "in", !oEndBc.isUp(), 1,  
1160 - oEndBc.getArrTimeObj(),  
1161 - this._oParam  
1162 - ));  
1163 -  
1164 - // 第二个车次链开头有出场,报到班次,车次链结尾有进场,报到班次  
1165 - oStartBc = oLp.getBc(  
1166 - oLp.fnGetBcChainInfo(1)["s_q"],  
1167 - oLp.fnGetBcChainInfo(1)["s_b"]  
1168 - );  
1169 - aOtherBc.push(_utils.createBcObj(  
1170 - oLp, "bd", oStartBc.isUp(), 1,  
1171 - oStartBc.getFcTimeObj(),  
1172 - this._oParam  
1173 - ));  
1174 - aOtherBc.push(_utils.createBcObj(  
1175 - oLp, "out", oStartBc.isUp(), 1,  
1176 - oStartBc.getFcTimeObj(),  
1177 - this._oParam  
1178 - ));  
1179 -  
1180 - oEndBc = oLp.getBc(  
1181 - oLp.fnGetBcChainInfo(1)["e_q"],  
1182 - oLp.fnGetBcChainInfo(1)["e_b"]  
1183 - );  
1184 - aOtherBc.push(_utils.createBcObj(  
1185 - oLp, "in", !oEndBc.isUp(), 1,  
1186 - oEndBc.getArrTimeObj(),  
1187 - this._oParam  
1188 - ));  
1189 - aOtherBc.push(_utils.createBcObj(  
1190 - oLp, "lc", !oEndBc.isUp(), 1,  
1191 - oEndBc.getArrTimeObj(),  
1192 - this._oParam  
1193 - ));  
1194 -  
1195 -  
1196 - } else {  
1197 - // 2个车次链以上,暂时没有此班型  
1198 - }  
1199 -  
1200 - oLp.addOtherBcArray(aOtherBc);  
1201 - }  
1202 - };  
1203 -  
1204 -  
1205 - //------------- 其他非业务方法方法 -------------//  
1206 - /**  
1207 - * 获取班次列表。  
1208 - * @param isUp boolean 是否上行  
1209 - * @returns [(InternalBcObj)]  
1210 - */  
1211 - InternalScheduleObj.prototype.fnGetBcList = function(isUp) {  
1212 - var i;  
1213 - var j;  
1214 - var oLp;  
1215 - var oBc;  
1216 - var aBc = [];  
1217 -  
1218 - for (j = 0; j < this._qCount; j++) {  
1219 - for (i = 0; i < this._internalLpArray.length; i++) {  
1220 - oLp = this._internalLpArray[i];  
1221 - oBc = oLp.getBc(  
1222 - j,  
1223 - this._qIsUp == isUp ? 0 : 1  
1224 - );  
1225 - if (oBc) {  
1226 - aBc.push(oBc);  
1227 - }  
1228 - }  
1229 - }  
1230 -  
1231 - var aBcFcTime = [];  
1232 - for (i = 0; i < aBc.length; i++) {  
1233 - oBc = aBc[i];  
1234 - aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm"));  
1235 - }  
1236 - console.log((isUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(","));  
1237 -  
1238 - return aBc;  
1239 - };  
1240 -  
1241 - /**  
1242 - * 获取班次索引。  
1243 - * @param oBc 班次对象  
1244 - * @returns [{路牌索引},{圈索引},{班次索引}]  
1245 - */  
1246 - InternalScheduleObj.prototype.fnGetBcIndex = function(oBc) {  
1247 - // 路牌索引  
1248 - var i;  
1249 - var iLpIndex;  
1250 - for (i = 0; i < this._internalLpArray.length; i++) {  
1251 - if (this._internalLpArray[i]._$$_orign_lp_obj == oBc._$$_internal_lp_obj._$$_orign_lp_obj) {  
1252 - iLpIndex = i;  
1253 - break;  
1254 - }  
1255 - }  
1256 - // 圈索引  
1257 - var j;  
1258 - var iGroupIndex;  
1259 - var bFlag = false;  
1260 - for (i = 0; i < this._internalLpArray.length; i++) {  
1261 - if (bFlag) {  
1262 - break;  
1263 - }  
1264 - for (j = 0; j < this._qCount; j++) {  
1265 - if (this._internalLpArray[i]._$_groupBcArray[j] == oBc._$$_internal_group_obj) {  
1266 - iGroupIndex = j;  
1267 - bFlag = true;  
1268 - break;  
1269 - }  
1270 - }  
1271 - }  
1272 - // 班次索引  
1273 - var iBcIndex = this._qIsUp == oBc.isUp() ? 0 : 1;  
1274 -  
1275 - if (iLpIndex == undefined) {  
1276 - return null;  
1277 - } else {  
1278 - return [].concat(iLpIndex, iGroupIndex, iBcIndex);  
1279 - }  
1280 - };  
1281 -  
1282 - /**  
1283 - * 返回内部路牌数据列表。  
1284 - * @returns {Array}  
1285 - */  
1286 - InternalScheduleObj.prototype.fnGetLpArray = function() {  
1287 - return this._internalLpArray;  
1288 - };  
1289 -  
1290 - /**  
1291 - * 获取班型描述。  
1292 - * @return {*[]}  
1293 - */  
1294 - InternalScheduleObj.prototype.fnGetBxDesc = function() {  
1295 - return this._aBxDesc;  
1296 - };  
1297 -  
1298 - /**  
1299 - * 获取圈的第一个班次是上行还是下行。  
1300 - * @return {boolean|*}  
1301 - */  
1302 - InternalScheduleObj.prototype.fnGetGroupIsUp = function() {  
1303 - return this._qIsUp;  
1304 - };  
1305 -  
1306 - /**  
1307 - * 返回内部工具对象。  
1308 - * @return {{createBcObj, modifySBXMasterBc}}  
1309 - */  
1310 - InternalScheduleObj.prototype.fnGetUitls = function() {  
1311 - return _utils;  
1312 - };  
1313 -  
1314 - /**  
1315 - * 内部数据转化成显示用的班次数组。  
1316 - */  
1317 - InternalScheduleObj.prototype.fnToGanttBcArray = function() {  
1318 - var aAllBc = [];  
1319 - var aLpBc = [];  
1320 - var aEatBc = [];  
1321 - var oLp;  
1322 - var i;  
1323 - var j;  
1324 -  
1325 - for (i = 0; i < this._internalLpArray.length; i++) {  
1326 - oLp = this._internalLpArray[i];  
1327 - aLpBc = [];  
1328 - aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());  
1329 -  
1330 - aEatBc = [];  
1331 - // TODO:根据班次的吃饭时间添加吃饭班次  
1332 - for (j = 0; j < aLpBc.length; j++) {  
1333 - if (aLpBc[j].fnGetEatTime() > 0) {  
1334 - aEatBc.push(_utils.createBcObj(  
1335 - oLp,  
1336 - "cf",  
1337 - aLpBc[j].isUp(), // 和上一个班次方向相反  
1338 - 1,  
1339 - this._oParam.addMinute(aLpBc[j].getFcTimeObj(), -aLpBc[j].fnGetEatTime()),  
1340 - this._oParam  
1341 - ));  
1342 - }  
1343 - }  
1344 - aLpBc = aLpBc.concat(aEatBc);  
1345 -  
1346 - // 按照发车时间排序  
1347 - aLpBc.sort(function(o1, o2) {  
1348 - if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {  
1349 - return -1;  
1350 - } else {  
1351 - return 1;  
1352 - }  
1353 - });  
1354 -  
1355 - // 重新赋值fcno  
1356 - for (j = 0; j < aLpBc.length; j++) {  
1357 - aLpBc[j].fnSetFcno(j + 1);  
1358 - }  
1359 -  
1360 - aAllBc = aAllBc.concat(aLpBc);  
1361 - }  
1362 -  
1363 - var aGanttBc = [];  
1364 - for (i = 0; i < aAllBc.length; i++) {  
1365 - aGanttBc.push(aAllBc[i].toGanttBcObj());  
1366 - }  
1367 -  
1368 - return aGanttBc;  
1369 - };  
1370 -  
1371 - /**  
1372 - * 计算指定开始时间,指定方向班次执行后的最大最小停站时间。  
1373 - * @param oStartFcTime 开始发车时间  
1374 - * @param isUp 是否上行  
1375 - * @returns array [最小值,最大值]  
1376 - */  
1377 - InternalScheduleObj.prototype._$calcuLayoverTime = function(oStartFcTime, isUp) {  
1378 - var aRtn = [];  
1379 - var _iRunningTime; // 行驶时间  
1380 - var _iLayoverTime; // 停站时间  
1381 -  
1382 - // 最小停站时间  
1383 - _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(  
1384 - isUp, oStartFcTime, this._oParam);  
1385 - _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1386 - oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),  
1387 - this._oParam)[0]; // 最小停站  
1388 - aRtn.push(_iLayoverTime);  
1389 -  
1390 - // 最大停站时间  
1391 - _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(  
1392 - isUp, oStartFcTime, this._oParam);  
1393 - _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1394 - oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),  
1395 - this._oParam)[1]; // 最大停站  
1396 - aRtn.push(_iLayoverTime);  
1397 -  
1398 - return aRtn;  
1399 - };  
1400 -  
1401 - /**  
1402 - * 计算指定时间,指定方向开始的最大最小周转时间  
1403 - * @param oStartFcTime 开始发车时间  
1404 - * @param isUp 是否上行  
1405 - * @returns array [最小值,最大值]  
1406 - * @private  
1407 - */  
1408 - InternalScheduleObj.prototype._$calcuCycleTime = function(oStartFcTime, isUp) {  
1409 - var aRtn = [];  
1410 - var _iRunningTime; // 行驶时间  
1411 - var _iLayoverTime; // 停站时间  
1412 - var _iCycleTime; // 周转时间  
1413 - var _oNextFcTime;  
1414 -  
1415 - // 最小周转时间  
1416 - _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(  
1417 - isUp, oStartFcTime, this._oParam);  
1418 - _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1419 - oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),  
1420 - this._oParam)[0]; // 最小停站  
1421 - _iCycleTime = _iRunningTime + _iLayoverTime;  
1422 - _oNextFcTime = this._oParam.addMinute(oStartFcTime, (_iRunningTime + _iLayoverTime));  
1423 - _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(  
1424 - !isUp, _oNextFcTime, this._oParam);  
1425 - _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1426 - _oNextFcTime, !isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),  
1427 - this._oParam)[0]; // 最小停站  
1428 - _iCycleTime += _iRunningTime;  
1429 - _iCycleTime += _iLayoverTime;  
1430 -  
1431 - aRtn.push(_iCycleTime);  
1432 -  
1433 - // 最大周转时间  
1434 - _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(  
1435 - isUp, oStartFcTime, this._oParam);  
1436 - _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1437 - oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),  
1438 - this._oParam)[1]; // 最大停站  
1439 - _iCycleTime = _iRunningTime + _iLayoverTime;  
1440 - _oNextFcTime = this._oParam.addMinute(oStartFcTime, (_iRunningTime + _iLayoverTime));  
1441 - _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(  
1442 - !isUp, _oNextFcTime, this._oParam);  
1443 - _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1444 - _oNextFcTime, !isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),  
1445 - this._oParam)[1]; // 最大停站  
1446 - _iCycleTime += _iRunningTime;  
1447 - _iCycleTime += _iLayoverTime;  
1448 -  
1449 - aRtn.push(_iCycleTime);  
1450 -  
1451 - return aRtn;  
1452 - };  
1453 -  
1454 - //-------------------- static静态方法 ----------------------//  
1455 -  
1456 - /**  
1457 - * 计算车辆数(最大周转时间/最大发车间隔)。  
1458 - * @param oParam 参数对象  
1459 - */  
1460 - InternalScheduleObj.calcuClzx = function(oParam) {  
1461 - var _iUpRT; // 上行行驶时间  
1462 - var _iUpLT; // 上行停站时间  
1463 - var _iDownRT; // 下行行驶时间  
1464 - var _iDownLT; // 下行停站时间  
1465 -  
1466 - // 计算早高峰最大周转时间  
1467 - _iUpRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(true, oParam.getMPeakStartTimeObj(), oParam);  
1468 - _iUpLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1469 - oParam.getMPeakStartTimeObj(), true,  
1470 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间  
1471 - _iDownRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, oParam.getMPeakStartTimeObj(), oParam);  
1472 - _iDownLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1473 - oParam.getMPeakStartTimeObj(), false,  
1474 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间  
1475 - var _iAMPeakRCTime = _iUpRT + _iUpLT + _iDownRT + _iDownLT;  
1476 - // 早高峰预估车辆数,使用早高峰最大发车间隔  
1477 - var _iAMPeakVehicleCount = _iAMPeakRCTime / oParam.getMPeakMaxFcjx();  
1478 -  
1479 - // 计算晚高峰最大周转时间  
1480 - _iUpRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(true, oParam.getEPeakStartTimeObj(), oParam);  
1481 - _iUpLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1482 - oParam.getEPeakStartTimeObj(), true,  
1483 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间  
1484 - _iDownRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, oParam.getEPeakStartTimeObj(), oParam);  
1485 - _iDownLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
1486 - oParam.getEPeakStartTimeObj(), false,  
1487 - StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间  
1488 - var _iPMPeakRCTime = _iUpRT + _iUpLT + _iDownRT + _iDownLT;  
1489 - // 晚高峰预估车辆数,使用晚高峰最大发车间隔  
1490 - var _iPMPeakVehicleCount = _iPMPeakRCTime / oParam.getEPeakMaxFcjx();  
1491 -  
1492 - // 取最大值为最终车辆数  
1493 - // 大于或等于的最小整数,人话就是有小数点就加1  
1494 - if (_iAMPeakVehicleCount > _iPMPeakVehicleCount) {  
1495 - return Math.ceil(_iAMPeakVehicleCount);  
1496 - } else {  
1497 - return Math.ceil(_iPMPeakVehicleCount);  
1498 - }  
1499 -  
1500 - };  
1501 -  
1502 -  
1503 - return InternalScheduleObj; 1 +/**
  2 + * v2_2版本的行车计划对象。
  3 + *
  4 + * 本次修正和原来区别,一边生成班次,一边调整班次间隔
  5 + * 1、初始化行车计划基本布局,主要是有几辆车,路牌分布情况(连班,分班,5休2分班),上标线的初始班次列表
  6 + *
  7 + */
  8 +var InternalScheduleObj_v2_2 = (function() {
  9 +
  10 + // 内部utils类
  11 + var _utils = function() {
  12 + return {
  13 + /**
  14 + * 创建班次对象。
  15 + * @param lpObj InternalLpObj路牌对象
  16 + * @param bcType 班次类型(normal等等)
  17 + * @param isUp 是否上行
  18 + * @param fcno 发车顺序号
  19 + * @param fcTimeObj 发车时间对象
  20 + * @param paramObj 参数对象
  21 + * @returns {InternalBcObj}
  22 + */
  23 + createBcObj : function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
  24 + var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType); // 班次里程
  25 + var _fcsj = fcTimeObj; // 发车时间
  26 + // var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp); // 班次历时
  27 + var _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(isUp, _fcsj, paramObj); // 使用策略计算班次行驶时间
  28 +
  29 + // console.log("发车时间=" + _fcsj.format("HH:mm") + ",行驶时间=" + _bcsj);
  30 +
  31 + var _arrsj = paramObj.addMinute(_fcsj, _bcsj); // 到达时间
  32 + // 停站时间范围,[最小停站时间,最大停站时间]
  33 + // var _stopTimeRange = paramObj.calcuTripLayoverTimeRange(_arrsj, isUp, _bcsj);
  34 + var _stopTimeRange = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  35 + _fcsj, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), paramObj);
  36 +
  37 + var _stoptime = _stopTimeRange[0]; // 使用最小停站时间
  38 + var _tccid = paramObj.getTTinfoId();
  39 + var _ttinfoid = paramObj.getTTinfoId();
  40 + var _xl = paramObj.getXlId();
  41 + var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
  42 + var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
  43 +
  44 + if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
  45 + if (isUp) { // 上行
  46 + _fcsj = paramObj.addMinute(
  47 + _fcsj,
  48 + -(paramObj.getUpOutTime() + paramObj.getLbTime()));
  49 + _bcsj = paramObj.getLbTime();
  50 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  51 + _stoptime = 0;
  52 + } else { // 下行
  53 + _fcsj = paramObj.addMinute(
  54 + _fcsj,
  55 + -(paramObj.getDownOutTime() + paramObj.getLbTime()));
  56 + _bcsj = paramObj.getLbTime();
  57 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  58 + _stoptime = 0;
  59 + }
  60 + } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
  61 + if (isUp) { // 上行
  62 + _fcsj = paramObj.addMinute(
  63 + _fcsj,
  64 + paramObj.getUpInTime());
  65 + _bcsj = paramObj.getLbTime();
  66 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  67 + _stoptime = 0;
  68 + } else { // 下行
  69 + _fcsj = paramObj.addMinute(
  70 + _fcsj,
  71 + paramObj.getDownInTime());
  72 + _bcsj = paramObj.getLbTime();
  73 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  74 + _stoptime = 0;
  75 + }
  76 + } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
  77 + if (isUp) { // 上行
  78 + _fcsj = paramObj.addMinute(
  79 + _fcsj,
  80 + -paramObj.getUpOutTime());
  81 + _bcsj = paramObj.getUpOutTime();
  82 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  83 + _stoptime = 0;
  84 + } else { // 下行
  85 + _fcsj = paramObj.addMinute(
  86 + _fcsj,
  87 + -paramObj.getDownOutTime());
  88 + _bcsj = paramObj.getDownOutTime();
  89 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  90 + _stoptime = 0;
  91 + }
  92 + } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
  93 + if (isUp) { // 上行
  94 + _bcsj = paramObj.getUpInTime();
  95 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  96 + _stoptime = 0;
  97 + } else { // 下行
  98 + _bcsj = paramObj.getDownInTime();
  99 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  100 + _stoptime = 0;
  101 + }
  102 + } else if (bcType == "cf") { // 吃饭班次
  103 + // 以13:00为分界,之前的为午饭,之后的为晚饭
  104 + if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
  105 + _bcsj = paramObj.fnGetLunchTime();
  106 + } else {
  107 + _bcsj = paramObj.fnGetDinnerTime();
  108 + }
  109 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  110 + _stoptime = 0;
  111 + }
  112 +
  113 + var bcParamObj = {};
  114 + bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
  115 + bcParamObj.isUp = isUp; // boolean是否上下行
  116 + bcParamObj.fcno = fcno; // 发车顺序号
  117 + bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
  118 + bcParamObj.bclc = _bclc; // 班次里程
  119 + bcParamObj.bcsj = _bcsj; // 班次历时
  120 + bcParamObj.arrtime = _arrsj; // 到达时间对象
  121 + bcParamObj.stoptime = _stoptime; // 停站时间
  122 + bcParamObj.tccid = _tccid; // 停车场id
  123 + bcParamObj.ttinfoid = _ttinfoid; // 时刻表id
  124 + bcParamObj.xl = _xl; // 线路id
  125 + bcParamObj.qdzid = _qdz; // 起点站id
  126 + bcParamObj.zdzid = _zdz; // 终点站id
  127 +
  128 + return new InternalBcObj(lpObj, bcParamObj);
  129 + },
  130 +
  131 + /**
  132 + * 修正上标线主站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续说有班次。
  133 + * @param oLp 上标线路牌
  134 + * @param fromFcsj 开始发车时间对象
  135 + * @param fromGroupIndex 开始圈索引
  136 + * @param fromBcIndex 开始班次索引
  137 + * @param isUp 开始班次是上行还是下行
  138 + * @param oParam 参数对象
  139 + */
  140 + modifySBXMasterBc: function(oLp, fromFcsj, fromGroupIndex, fromBcIndex, isUp, oParam) {
  141 + // 清空指定位置班次及后续班次
  142 + oLp.clearBc(fromGroupIndex, fromBcIndex);
  143 + // 初始化上标线,从指定圈索引开始
  144 + oLp.initDataFromTime(fromFcsj, isUp, fromGroupIndex, oParam, _utils);
  145 +
  146 + }
  147 +
  148 + };
  149 + }();
  150 +
  151 +
  152 +
  153 + /**
  154 + * 内部行车计划对象。
  155 + * @param oParam 参数封装对象
  156 + * @param aLp 路牌(甘特图用的路牌对象)
  157 + * @constructor
  158 + */
  159 + function InternalScheduleObj(oParam, aLp) {
  160 + // 参数对象和甘特图用路牌数组
  161 + this._oParam = oParam;
  162 + this._aGanttLpArray = aLp;
  163 +
  164 + // 目前这个只支持主站停站
  165 + if (this._oParam.isTwoWayStop()) {
  166 + alert("v2_2版本不支持双向停站类型线路!");
  167 + throw "v2_2版本不支持双向停站类型线路";
  168 + }
  169 +
  170 + console.log("//->>>>>>>>>>>>>>>>>>>>>>>>> v2_2行车计划,初始化1,圈信息,路牌 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-//");
  171 + //----------------------- 1、确定上标线的方向,圈的方向 -------------------//
  172 + this._qIsUp = true; // 每一圈是上行开始还是下行开始
  173 +
  174 + // 确定_qIsUp,哪个方向的首班车晚就用哪个
  175 + // this._qIsUp = this._oParam.getUpFirstDTimeObj().isBefore(
  176 + // this._oParam.getDownFirstDTimeObj()) ? false : true;
  177 +
  178 + // 确定_qIsUp,哪个方向的首班车晚就用哪个
  179 + // 使用diff判定,如果两个时间相等 this._qIsUp = false
  180 + this._qIsUp = oParam.getUpFirstDTimeObj().diff(oParam.getDownFirstDTimeObj()) <= 0 ? false : true;
  181 +
  182 +
  183 + // 上标线开始时间,就是方向的首班车时间
  184 + var st = this._qIsUp ? oParam.getUpFirstDTimeObj() : oParam.getDownFirstDTimeObj();
  185 + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向
  186 + var et;
  187 + var et_IsUp;
  188 + if (oParam.getUpLastDtimeObj().isBefore(
  189 + oParam.getDownLastDTimeObj())) {
  190 + et = oParam.getDownLastDTimeObj();
  191 + et_IsUp = false;
  192 + } else {
  193 + et = oParam.getUpLastDtimeObj();
  194 + et_IsUp = true;
  195 + }
  196 + //------------------------ 2、计算总共有多少圈 ------------------------//
  197 + this._qCount = 0; // 总的圈数
  198 +
  199 + // 以开始时间,结束时间,构造上标线用连班班次发车时间
  200 + var bcFcsjArrays = []; // 班次发车时间对象数组
  201 + var bcArsjArrays = []; // 班次到达时间对象数组
  202 + var isUp = this._qIsUp; // 方向
  203 + var bcCount = 1; // 班次数
  204 +
  205 + var _kssj = st; // 开始时间
  206 + var _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(isUp, _kssj, oParam); // 使用策略计算班次行驶时间
  207 + var _arrsj = oParam.addMinute(_kssj, _bcsj); // 到达时间
  208 + var _stoptimeRange = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  209 + _kssj, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam);
  210 + var _stoptime = _stoptimeRange[0]; // 最小停站时间
  211 +
  212 + do {
  213 + bcFcsjArrays.push(_kssj);
  214 + bcArsjArrays.push(_arrsj);
  215 +
  216 + _kssj = oParam.addMinute(_kssj, _bcsj + _stoptime);
  217 + // _bcsj = oParam.calcuTravelTime(_kssj, isUp);
  218 +
  219 + _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(isUp, _kssj, oParam); // 使用策略计算班次行驶时间
  220 + _arrsj = oParam.addMinute(_kssj, _bcsj);
  221 + _stoptimeRange = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  222 + _kssj, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam);
  223 + _stoptime = _stoptimeRange[0]; // 最小停站时间
  224 +
  225 + bcCount ++;
  226 + isUp = !isUp;
  227 + } while(_kssj.isBefore(et));
  228 + bcCount--; // 因为先做do,所以总的班次要减1
  229 +
  230 + var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈
  231 + var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈
  232 +
  233 + // 利用连班数组计算圈数
  234 + this._qCount = 1; // 前面加1圈,补中标线的班次
  235 + this._qCount += _qCount_p1;
  236 + this._qCount += _qCount_p2;
  237 +
  238 + // 计算最后是不是还要补一圈
  239 + if (this._qCount > 1) { // 总的圈数就1圈,没必要加了(其实是不可能的,除非参数里问题)
  240 + if (_qCount_p2 == 0) { // 没有余下班次,整数圈数
  241 + // 最后一个班次的方向一定和开始的方向相反,如:上-下,上-下,上-下,一共三圈,最后一个班次为下行
  242 + // 判定最后一个班次的方向和上标线判定结束时间的班次方向是否一致
  243 + if (!this._qIsUp == et_IsUp) {
  244 + // 一致不用加圈数
  245 + } else {
  246 + // 不一致需要加圈补最后一个结束时间班次
  247 + this._qCount ++;
  248 + }
  249 + } else {
  250 + // 有余下的圈数,最后要不补的班次不管上行,下行都在这一圈里
  251 + // 不需要在补圈数了
  252 + }
  253 + }
  254 + //------------------------ 3、根据路牌数,圈数创建路牌对象 ----------------------//
  255 + this._internalLpArray = []; // 内部路牌(InternalLpObj对象)数组
  256 +
  257 + // 创建内部的路牌数组
  258 + var i;
  259 + for (i = 0; i < this._aGanttLpArray.length; i++) {
  260 + this._internalLpArray.push(
  261 + new InternalLpObj(this._aGanttLpArray[i], this._qCount, this._qIsUp));
  262 + }
  263 +
  264 + // 初始化上标线,从第1圈开始
  265 + this._internalLpArray[0].initDataFromTimeToTime(
  266 + bcFcsjArrays[0], et, this._qIsUp, 1, oParam, _utils);
  267 +
  268 +
  269 + console.log("上行首班车时间:" + oParam.getUpFirstDTimeObj().format("HH:mm") +
  270 + "上行末班车时间:" + oParam.getUpLastDtimeObj().format("HH:mm"));
  271 + console.log("下行首班车时间:" + oParam.getDownFirstDTimeObj().format("HH:mm") +
  272 + "下行末班车时间:" + oParam.getDownLastDTimeObj().format("HH:mm"));
  273 + console.log("总共计算的圈数:" + this._qCount);
  274 + console.log("圈的方向isUP:" + this._qIsUp);
  275 +
  276 + console.log("//->>>>>>>>>>>>>>>>>>>>>>>>> v2_2行车计划,初始化2,工时,路牌信息 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-//");
  277 + //------------------------ 1、以上标线为基础,计算各种班型工时对应的圈数、班次数 -----------------------//
  278 + var aBcArray = this._internalLpArray[0].getBcArray();
  279 + aBcArray[0].fnSetIsFirstBc(true); // 设置首班班次标识
  280 +
  281 + if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算
  282 + aBcArray.splice(aBcArray.length - 1, 1);
  283 + }
  284 +
  285 + var iLTime = oParam.fnGetLunchTime(); // 午饭吃饭时间
  286 + var iDTime = oParam.fnGetDinnerTime(); // 晚饭吃饭时间
  287 + var iOutTime = this._qIsUp ? oParam.getUpOutTime() : oParam.getDownOutTime(); // 出场时间
  288 + var iInTime = this._qIsUp ? oParam.getDownInTime() : oParam.getUpInTime(); // 进场时间
  289 + var iBTime = oParam.getLbTime(); // 例保时间
  290 +
  291 + var sum = 0; // 总班次时间
  292 + for (i = 0; i < aBcArray.length; i++) {
  293 + sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();
  294 + }
  295 + sum += iLTime; // 加午饭时间
  296 + sum += iDTime; // 加晚饭时间
  297 +
  298 + this._aBxDesc = [ // 各种班型描述(班型名称,平均工时,平均需要的班次数,平均工时)
  299 + {'sType':'六工一休', 'fHoursV':6.66, 'fBcCount': 0, 'fAverTime': 0},
  300 + {'sType':'五工一休', 'fHoursV':6.85, 'fBcCount': 0, 'fAverTime': 0},
  301 + {'sType':'四工一休', 'fHoursV':7.14, 'fBcCount': 0, 'fAverTime': 0},
  302 + {'sType':'三工一休', 'fHoursV':7.61, 'fBcCount': 0, 'fAverTime': 0},
  303 + {'sType':'二工一休', 'fHoursV':8.57, 'fBcCount': 0, 'fAverTime': 0},
  304 + {'sType':'一工一休', 'fHoursV':11.42, 'fBcCount': 0, 'fAverTime': 0},
  305 + {'sType':'五工二休', 'fHoursV':7.99, 'fBcCount': 0, 'fAverTime': 0},
  306 + {'sType':'无工休', 'fHoursV':5.43, 'fBcCount': 0, 'fAverTime': 0}
  307 + ];
  308 +
  309 + for (i = 0; i < this._aBxDesc.length; i++) {
  310 + this._aBxDesc[i].fAverTime = sum / (aBcArray.length / 2); // 平均周转时间不算进出场,例保时间
  311 +
  312 + // 计算5休2的班次数(双进出场,4个例保)
  313 + if (i == 6) {
  314 + this._aBxDesc[i].fQCount =
  315 + (this._aBxDesc[i].fHoursV * 60 - iOutTime * 2 - iInTime * 2 - iBTime * 4) /
  316 + this._aBxDesc[i].fAverTime;
  317 + this._aBxDesc[i].fBcCount = this._aBxDesc[i].fQCount * 2;
  318 + } else { // 进出场,2个例保
  319 + this._aBxDesc[i].fQCount =
  320 + (this._aBxDesc[i].fHoursV * 60 - iOutTime - iInTime - iBTime * 2) /
  321 + this._aBxDesc[i].fAverTime;
  322 + this._aBxDesc[i].fBcCount = this._aBxDesc[i].fQCount * 2;
  323 + }
  324 + }
  325 + console.log("班型描述(以下):");
  326 + console.log(this._aBxDesc);
  327 + //--------------------- 2、计算分班连班班型车辆分布数 --------------------//
  328 + this._iBx_lb_lpcount = 0; // 连班路牌数
  329 + this._iBx_5_2_fb_lpcount = 0; // 5休2分班路牌数
  330 + this._iBx_other_fb_lpcount = 0; // 其他分班路牌数
  331 +
  332 + // 总共车辆数(高峰最大车辆数)
  333 + var iCls = InternalScheduleObj_v2_2.calcuClzx(oParam);
  334 + // 计算低谷最大周转时间
  335 + var _iTroughCycleTime =
  336 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(true, oParam.toTimeObj("13:00"), oParam) +
  337 + StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  338 + oParam.toTimeObj("13:00"), true,
  339 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1] +
  340 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, oParam.toTimeObj("13:00"), oParam) +
  341 + StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  342 + oParam.toTimeObj("13:00"), false,
  343 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1];
  344 +
  345 + // 低谷最少配车(预估最少连班车数量)
  346 + var iDgminpc = Math.ceil(_iTroughCycleTime / oParam.getTroughMaxFcjx());
  347 + // 加班车路牌数(做5休2的路牌数)
  348 + var i_5_2_lpes = oParam.getJBLpes();
  349 +
  350 + // v2_2版本的路牌分布就是连班分班加班车分布,总车辆数减去加班车,剩下的车对半开连班和其他分班,但是连班必须大于最少连班
  351 + if (iCls < iDgminpc) {
  352 + alert("总配车数小于低谷最小配车");
  353 + throw "总配车数小于低谷最小配车";
  354 + } else {
  355 + // 5_2路牌数
  356 + this._iBx_5_2_fb_lpcount = i_5_2_lpes;
  357 +
  358 + // 剩余车辆数
  359 + var _iOtherCls = iCls - this._iBx_5_2_fb_lpcount;
  360 + var _iHalfCls1; // 连班路牌数
  361 + var _iHalfCls2; // 其他分班路牌数
  362 + if (_iOtherCls % 2 == 0) { // 能整除
  363 + _iHalfCls1 = _iOtherCls / 2;
  364 + _iHalfCls2 = _iOtherCls / 2;
  365 + } else {
  366 + _iHalfCls1 = Math.floor(_iOtherCls / 2) + 1;
  367 + _iHalfCls2 = Math.floor(_iOtherCls / 2);
  368 + }
  369 + if (_iHalfCls1 > iDgminpc) {
  370 + this._iBx_lb_lpcount = _iHalfCls1;
  371 + this._iBx_other_fb_lpcount = _iHalfCls2;
  372 + } else {
  373 + this._iBx_lb_lpcount = iDgminpc;
  374 + this._iBx_other_fb_lpcount = iCls - this._iBx_lb_lpcount - i_5_2_lpes;
  375 + }
  376 + }
  377 +
  378 + //------------------------ 3、利用间隔法计算连班路牌分布 --------------------//
  379 + var i;
  380 + var j;
  381 + var iC1 = Math.floor(this._internalLpArray.length / this._iBx_lb_lpcount);
  382 + var iC2 = this._internalLpArray.length % this._iBx_lb_lpcount;
  383 + var iLpIndex;
  384 +
  385 + for (i = 0; i < this._iBx_lb_lpcount - iC2; i++) {
  386 + iLpIndex = i * iC1;
  387 + this._internalLpArray[iLpIndex].setBxLb(true);
  388 + this._internalLpArray[iLpIndex].setBxDesc("连班");
  389 + }
  390 + for (j = 0; j < iC2; j++) {
  391 + iLpIndex = i * iC1 + j * (iC1 + 1);
  392 + this._internalLpArray[iLpIndex].setBxLb(true);
  393 + this._internalLpArray[iLpIndex].setBxDesc("连班");
  394 + }
  395 + //------------------------ 4、利用间隔法计算分班班型路牌分布 --------------------//
  396 + // 获取分班路牌索引
  397 + var aNotLbIndexes = [];
  398 + for (i = 0; i < this._internalLpArray.length; i++) {
  399 + if (!this._internalLpArray[i].isBxLb()) {
  400 + aNotLbIndexes.push(i);
  401 + }
  402 + }
  403 + // 先5休2分班
  404 + iC1 = Math.floor(aNotLbIndexes.length / this._iBx_5_2_fb_lpcount);
  405 + iC2 = aNotLbIndexes.length % this._iBx_5_2_fb_lpcount;
  406 +
  407 + for (i = 0; i < this._iBx_5_2_fb_lpcount - iC2; i++) {
  408 + iLpIndex = aNotLbIndexes[i * iC1];
  409 + this._internalLpArray[iLpIndex].setBxLb(false);
  410 + this._internalLpArray[iLpIndex].setBxFb(true);
  411 + this._internalLpArray[iLpIndex].setBxFb5_2(true);
  412 + this._internalLpArray[iLpIndex].setBxDesc("5休2分班");
  413 + }
  414 + for (i = 0; i < iC2; i++) {
  415 + iLpIndex = aNotLbIndexes[this._iBx_5_2_fb_lpcount - iC2 + i * (iC1 + 1)];
  416 + this._internalLpArray[iLpIndex].setBxLb(false);
  417 + this._internalLpArray[iLpIndex].setBxFb(true);
  418 + this._internalLpArray[iLpIndex].setBxFb5_2(true);
  419 + this._internalLpArray[iLpIndex].setBxDesc("5休2分班");
  420 + }
  421 + // 其他分班
  422 + for (i = 0; i < aNotLbIndexes.length; i++) {
  423 + iLpIndex = aNotLbIndexes[i];
  424 + if (!this._internalLpArray[iLpIndex].isBxFb5_2()) {
  425 + this._internalLpArray[iLpIndex].setBxLb(false);
  426 + this._internalLpArray[iLpIndex].setBxFb(true);
  427 + this._internalLpArray[iLpIndex].setBxFb5_2(false);
  428 + this._internalLpArray[iLpIndex].setBxDesc("其他分班");
  429 + }
  430 + }
  431 +
  432 + console.log("高峰周转时间:" + oParam.calcuPeakZzsj());
  433 + console.log("连班路牌数:" + this._iBx_lb_lpcount);
  434 + console.log("5休2分班路牌数:" + this._iBx_5_2_fb_lpcount);
  435 + console.log("其他分班路牌数:" + this._iBx_other_fb_lpcount);
  436 + var aLbIndexes = [];
  437 + for (i = 0; i < this._internalLpArray.length; i++) {
  438 + if (this._internalLpArray[i].isBxLb()) {
  439 + aLbIndexes.push(i);
  440 + }
  441 + }
  442 + console.log("连班路牌indexes=" + aLbIndexes);
  443 + var a_5_2_fbIndexes = [];
  444 + for (i = 0; i < this._internalLpArray.length; i++) {
  445 + if (this._internalLpArray[i].isBxFb() && this._internalLpArray[i].isBxFb5_2()) {
  446 + a_5_2_fbIndexes.push(i);
  447 + }
  448 + }
  449 + console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes);
  450 + var a_other_fbIndexes = [];
  451 + for (i = 0; i < this._internalLpArray.length; i++) {
  452 + if (this._internalLpArray[i].isBxFb() && !this._internalLpArray[i].isBxFb5_2()) {
  453 + a_other_fbIndexes.push(i);
  454 + }
  455 + }
  456 + console.log("其他分班路牌indexes=" + a_other_fbIndexes);
  457 +
  458 + console.log("//->>>>>>>>>>>>>>>>> v2_3行车计划,初始化3,计算上标线第一个主站副站班次信息 <<<<<<<<<<<<<<<<<<<<<-//");
  459 + // 计算上标线第一个主站班次,副站班次的位置
  460 + this._oFirstMasterBc = undefined; // 早高峰主站方向班次
  461 + this._iFirstMasterBcGroupIndex = undefined; // 早高峰主站方向圈索引
  462 + this._iFirstMasterBcIndex = undefined; // 早高峰主站方向班次索引
  463 +
  464 + this._oFirstSlaveBc = undefined; // 早高峰副站方向班次
  465 + this._iFirstSlaveBcGroupIndex = undefined; // 早高峰副站方向圈索引
  466 + this._iFirstSlaveBcIndex = undefined; // 早高峰副站方向班次索引
  467 +
  468 + if (this._qIsUp) {
  469 + if (this._oParam.isUpOneWayStop()) {
  470 + this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 0);
  471 + this._iFirstMasterBcGroupIndex = 1;
  472 + this._iFirstMasterBcIndex = 0;
  473 +
  474 + this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 1);
  475 + this._iFirstSlaveBcGroupIndex = 1;
  476 + this._iFirstSlaveBcIndex = 1;
  477 + } else {
  478 + this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 1);
  479 + this._iFirstMasterBcGroupIndex = 1;
  480 + this._iFirstMasterBcIndex = 1;
  481 +
  482 + this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 0);
  483 + this._iFirstSlaveBcGroupIndex = 1;
  484 + this._iFirstSlaveBcIndex = 0;
  485 + }
  486 + } else {
  487 + if (this._oParam.isUpOneWayStop()) {
  488 + this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 1);
  489 + this._iFirstMasterBcGroupIndex = 1;
  490 + this._iFirstMasterBcIndex = 1;
  491 +
  492 + this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 0);
  493 + this._iFirstSlaveBcGroupIndex = 1;
  494 + this._iFirstSlaveBcIndex = 0;
  495 + } else {
  496 + this._oFirstMasterBc = this._internalLpArray[0].getBc(1, 0);
  497 + this._iFirstMasterBcGroupIndex = 1;
  498 + this._iFirstMasterBcIndex = 0;
  499 +
  500 + this._oFirstSlaveBc = this._internalLpArray[0].getBc(1, 1);
  501 + this._iFirstSlaveBcGroupIndex = 1;
  502 + this._iFirstSlaveBcIndex = 1;
  503 + }
  504 + }
  505 +
  506 + console.log("早高峰副站方向(start)班次=" + (this._oFirstSlaveBc ? this._oFirstSlaveBc.getFcTimeObj().format("HH:mm") : "未找到"));
  507 + console.log("早高峰副站方向(start)班次圈索引=" + (this._oFirstSlaveBc ? this._iFirstSlaveBcGroupIndex : "未找到"));
  508 + console.log("早高峰副站方向(start)班次索引=" + (this._oFirstSlaveBc ? this._iFirstSlaveBcIndex : "未找到"));
  509 + console.log("早高峰主站方向(start)班次=" + (this._oFirstMasterBc ? this._oFirstMasterBc.getFcTimeObj().format("HH:mm") : "未找到"));
  510 + console.log("早高峰主站方向(start)班次圈索引=" + (this._oFirstMasterBc ? this._iFirstMasterBcGroupIndex : "未找到"));
  511 + console.log("早高峰主站方向(start)班次索引=" + (this._oFirstMasterBc ? this._iFirstMasterBcIndex : "未找到"));
  512 +
  513 + console.log("//->>>>>>>>>>>>>>>>> v2_4行车计划,初始化4,从上标线第一圈第一个副站班次开始初始化后续路牌班次列表 <<<<<<<<<<<<<<<<<<<<<-//");
  514 + // 初始化上标线副站班次
  515 + var oPreBc; // 上一个班次(从上标线副站班次开始)
  516 + var oNextBc; // 计算的下一个班次
  517 + var oNextBcFcTime; // 下一个班次的发车时间
  518 + var aBcInterval = []; // 班次间隔数组
  519 + var oBcInterval; // 班次间隔对象
  520 + var iNextBcInterval; // 下一个班次发车间隔
  521 +
  522 + // 当初始化完一圈的副站班次后,最后一个班次是下一圈的上标线副站班次(一圈的周转结束班次),需要调整时间及其前一个主站班次的时间
  523 + var _modifyTimeNextGroupIndex; // 上标线下一圈索引
  524 + var _modifyTimeNextBcIndex; // 上标线下一圈班次索引
  525 + var _modifyBc; // 上标线下一个圈的班次
  526 + var _modifyPreBc; // 上标线下一个圈班次的前一个班次
  527 + var _modifyTime; // 上标线下一个圈班次的前一个班次的调整时间
  528 +
  529 + if (this._iFirstSlaveBcIndex == 0) { // 第一圈第二个班次是主站,则第一个班次是副站
  530 + oPreBc = this._internalLpArray[0].getBc(this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex);
  531 +
  532 + aBcInterval = StrategyUtils_v2_2.sFn("CALCU_HEADWAY_2")(
  533 + this,
  534 + this._oParam,
  535 + 1,
  536 + this._iFirstSlaveBcIndex,
  537 + this._$calcuCycleTime(oPreBc.getFcTimeObj())[0],
  538 + this._$calcuCycleTime(oPreBc.getFcTimeObj())[1]
  539 + );
  540 +
  541 + for (i = 1; i < this._internalLpArray.length; i++) {
  542 + oBcInterval = aBcInterval[i - 1];
  543 +
  544 + if (oBcInterval.hasBc) {
  545 + // 参考的发车间隔
  546 + iNextBcInterval = oBcInterval.iFcInterval;
  547 + oNextBcFcTime = this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval);
  548 + this._internalLpArray[i].fnSetVerticalIntervalTime(
  549 + this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex, iNextBcInterval);
  550 + this._internalLpArray[i].fnSetHeadwayS2_P(
  551 + this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex, oBcInterval.fP);
  552 +
  553 + oNextBc = _utils.createBcObj(
  554 + this._internalLpArray[i],
  555 + "normal",
  556 + !this._oParam.isUpOneWayStop(),
  557 + 1,
  558 + oNextBcFcTime,
  559 + this._oParam);
  560 +
  561 + this._internalLpArray[i].setBc(
  562 + this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex, oNextBc);
  563 +
  564 + oPreBc = oNextBc;
  565 + }
  566 + }
  567 +
  568 + // 修正上标线副站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续所有班次
  569 + iNextBcInterval = aBcInterval[i - 1].iFcInterval;
  570 + _modifyTimeNextGroupIndex = this._iFirstSlaveBcGroupIndex + 1;
  571 + _modifyTimeNextBcIndex = this._iFirstSlaveBcIndex;
  572 +
  573 + _utils.modifySBXMasterBc(
  574 + this._internalLpArray[0],
  575 + this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval),
  576 + this._iFirstSlaveBcGroupIndex + 1,
  577 + this._iFirstSlaveBcIndex,
  578 + oPreBc.isUp(),
  579 + this._oParam
  580 + );
  581 +
  582 + // 调整上标线副站班次一圈后的前一个主站班次时间
  583 + _modifyBc = this._internalLpArray[0].getBc(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex);
  584 + if (_modifyBc) {
  585 + this._internalLpArray[0].fnSetVerticalIntervalTime(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex, iNextBcInterval);
  586 +
  587 + _modifyPreBc = this._internalLpArray[0].getPreBc(_modifyBc);
  588 + _modifyTime = _modifyBc.getFcTimeObj().diff(_modifyPreBc.getArrTimeObj(), "m") - 1; // 主站到副站停站使用1分钟
  589 + // 修改发车时间,到达时间,不改行驶时间
  590 + _modifyPreBc.getFcTimeObj().add(_modifyTime, "m");
  591 + _modifyPreBc.getArrTimeObj().add(_modifyTime, "m");
  592 +
  593 + }
  594 +
  595 + }
  596 +
  597 + console.log("//->>>>>>>>>>>>>>>>> v2_6行车计划,初始化6,创建第一圈的主站班次开始班次列表,然后修正 <<<<<<<<<<<<<<<<<<<<<-//");
  598 + this.fnCreateBclistWithMasterBc(1, 1); // 从上标线第一圈的主站班次开始初始化所有路牌的相关班次
  599 + // 第一圈的第一个班次是副站,则需要修正this.fnCreateBclistWithMasterBc(1)班次之间的问题,停站时间为负数
  600 + if (this._iFirstSlaveBcIndex == 0) {
  601 + StrategyUtils_v2_2.sFn("ADJUST_HEADWAY")(
  602 + this, this._oParam,
  603 + this._iFirstSlaveBcGroupIndex, this._iFirstSlaveBcIndex,
  604 + this._iFirstMasterBcGroupIndex, this._iFirstMasterBcIndex,
  605 + 5 // 修正至少要5分钟停站
  606 + );
  607 + }
  608 +
  609 + console.log("//->>>>>>>>>>>>>>>>> v2_7行车计划,初始化7,修正中标线班次列表 <<<<<<<<<<<<<<<<<<<<<-//");
  610 + // // TODO:补充中标线班次,这里假设,前一半圈就是中标线,以后再精细处理
  611 + // // 中标线开始时间,早的首班车时间,和上标线的开始时间方向相反
  612 + // var oSt = !this._qIsUp ? this._oParam.getUpFirstDTimeObj() : this._oParam.getDownFirstDTimeObj();
  613 + // var iStRuntime; // 中标线方向班次行驶时间(使用低谷)
  614 + // if (!this._qIsUp) { // 上行
  615 + // if (this._oParam.isTroughBc(oSt)) {
  616 + // iStRuntime = this._oParam.getUpTroughTime();
  617 + // } else {
  618 + // iStRuntime = this._oParam.getUpMPeakTime();
  619 + // }
  620 + // } else { // 下行
  621 + // if (this._oParam.isTroughBc(oSt)) {
  622 + // iStRuntime = this._oParam.getDownTroughTime();
  623 + // } else {
  624 + // iStRuntime = this._oParam.getDownMPeakTime();
  625 + // }
  626 + // }
  627 + //
  628 + // var oSLp;
  629 + // var oSBc;
  630 + // var oSEmuBcFcTime; // 模拟班次发车时间
  631 + // var iTimeDiff;
  632 + // var iTempTime;
  633 + // var iSModifyLpIndex; // 中标线对应路牌索引
  634 + // for (i = 1; i < this._internalLpArray.length; i++) {
  635 + // oSLp = this._internalLpArray[i];
  636 + // oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次
  637 + // if (!oSBc) { // 可能没有,跳过
  638 + // continue;
  639 + // }
  640 + // oSEmuBcFcTime = this._oParam.addMinute(
  641 + // oSBc.getFcTimeObj(),
  642 + // -(iStRuntime + 1)
  643 + // );
  644 + // iTempTime = oSEmuBcFcTime.diff(oSt, "m");
  645 + // if (iTimeDiff == undefined) {
  646 + // iTimeDiff = iTempTime;
  647 + // iSModifyLpIndex = i;
  648 + // } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff) && oSEmuBcFcTime.isAfter(oSt)) {
  649 + // iTimeDiff = iTempTime;
  650 + // iSModifyLpIndex = i;
  651 + // }
  652 + // }
  653 + //
  654 + // // 添加上标线头班次(分班连班都可能)
  655 + // this._internalLpArray[iSModifyLpIndex].setBc(
  656 + // 0, 1,
  657 + // _utils.createBcObj(
  658 + // this._internalLpArray[iSModifyLpIndex],
  659 + // "normal",
  660 + // !this._qIsUp,
  661 + // 1,
  662 + // oSt,
  663 + // this._oParam)
  664 + // );
  665 + //
  666 + // // 从当前班次开始,如果是低谷,隔开方向加班次,如果是高峰,都加班次
  667 + // var iSInverval = Math.ceil((this._oParam.getMPeakMinFcjx() + this._oParam.getMPeakMaxFcjx()) / 2);
  668 + // for (i = iSModifyLpIndex + 1; i < this._internalLpArray.length; i++) {
  669 + // oSLp = this._internalLpArray[i];
  670 + // oSEmuBcFcTime = this._oParam.addMinute(oSt, iSInverval * (i - iSModifyLpIndex));
  671 + // if (this._oParam.isMPeakBc(oSEmuBcFcTime)) { // 高峰
  672 + // if (!this._qIsUp) { // 上行
  673 + // iStRuntime = this._oParam.getUpMPeakTime();
  674 + // } else { // 下行
  675 + // iStRuntime = this._oParam.getDownMPeakTime();
  676 + // }
  677 + // oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次
  678 + // oSLp.setBc(
  679 + // 0, 1,
  680 + // _utils.createBcObj(
  681 + // oSLp,
  682 + // "normal",
  683 + // !this._qIsUp,
  684 + // 1,
  685 + // this._oParam.addMinute(oSBc.getFcTimeObj(), -(iStRuntime + 1)),
  686 + // this._oParam)
  687 + // );
  688 + // } else { // 低谷隔开出班次
  689 + // if (!this._qIsUp) { // 上行
  690 + // iStRuntime = this._oParam.getUpTroughTime();
  691 + // } else { // 下行
  692 + // iStRuntime = this._oParam.getDownTroughTime();
  693 + // }
  694 + //
  695 + // if (!this._internalLpArray[i - 1].getBc(0, 1)) {
  696 + // // 上一个路牌没有班次,添加
  697 + // oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次
  698 + // if (oSBc) {
  699 + // oSLp.setBc(
  700 + // 0, 1,
  701 + // _utils.createBcObj(
  702 + // oSLp,
  703 + // "normal",
  704 + // !this._qIsUp,
  705 + // 1,
  706 + // this._oParam.addMinute(oSBc.getFcTimeObj(), -(iStRuntime + 1)),
  707 + // this._oParam)
  708 + // );
  709 + //
  710 + // // 如果生成的班次行驶时间不足,删除这个班次
  711 + // if (oSLp.getBc(1, 0).getFcTimeObj().isBefore(oSLp.getBc(0, 1).getArrTimeObj())) {
  712 + // oSLp.getGroup(0).setBc1(undefined);
  713 + // oSLp.getGroup(0).setBc2(undefined);
  714 + // }
  715 + // }
  716 + // }
  717 + // }
  718 + // }
  719 + //
  720 + // console.log("中标线路牌索引=" + iSModifyLpIndex);
  721 +
  722 +
  723 + }
  724 +
  725 + //------------------------- 核心业务方法 -----------------------//
  726 +
  727 + /**
  728 + * 核心方法,从上标线主站班次开始,一圈一圈生成每圈的主站班次,
  729 + * 每生成一个主站班次,尝试生成后面紧邻的副站班次(停站时间1到3分种调整)。
  730 + * @param iGroupIndex 圈索引
  731 + * @param iCount 共几圈
  732 + */
  733 + InternalScheduleObj.prototype.fnCreateBclistWithMasterBc = function(iGroupIndex, iCount) {
  734 + var i;
  735 + var j;
  736 + // var oPreBc = this._oFirstMasterBc; // 上一个班次(从上标线主站班次开始)
  737 + var oPreBc = this._internalLpArray[0].getBc(iGroupIndex, this._iFirstMasterBcIndex);
  738 + var oNextBc; // 计算的下一个班次
  739 + var oNextBcFcTime; // 下一个班次的发车时间
  740 + var aBcInterval = []; // 班次间隔数组
  741 + var oBcInterval; // 班次间隔对象
  742 + var iNextBcInterval; // 下一个班次发车间隔
  743 +
  744 + var oPreSlaveBc; // 上一个副站班次(上标线主站后的一个副站班次)
  745 + var oNextSlaveBc; // 下一个副站班次
  746 +
  747 + // 当初始化完一圈的主站班次后,最后一个班次是下一圈的上标线主站班次,需要判定存在然后添加间隔
  748 + var _modifyTimeNextGroupIndex; // 上标线下一圈索引
  749 + var _modifyTimeNextBcIndex; // 上标线下一圈班次索引
  750 + var _modifyBc; // 上标线下一个圈的班次
  751 +
  752 + var iStart = iGroupIndex;
  753 + var iEnd = iGroupIndex + iCount;
  754 + if (iEnd > this._qCount) {
  755 + iEnd = this._qCount;
  756 + }
  757 +
  758 + for (i = iStart; i < iEnd; i++) {
  759 + aBcInterval = StrategyUtils_v2_2.sFn("CALCU_HEADWAY_2")(
  760 + this,
  761 + this._oParam,
  762 + i,
  763 + this._iFirstMasterBcIndex,
  764 + this._$calcuCycleTime(oPreBc.getFcTimeObj())[0],
  765 + this._$calcuCycleTime(oPreBc.getFcTimeObj())[1]
  766 + );
  767 +
  768 + if (aBcInterval.length == 0) {
  769 + // 等于0说明上标线没班次了
  770 + break;
  771 + }
  772 +
  773 + for (j = 1; j < this._internalLpArray.length; j++) {
  774 + oBcInterval = aBcInterval[j - 1];
  775 + if (oBcInterval.hasBc) {
  776 + iNextBcInterval = oBcInterval.iFcInterval;
  777 + oNextBcFcTime = this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval);
  778 + this._internalLpArray[j].fnSetVerticalIntervalTime(i, this._iFirstMasterBcIndex, iNextBcInterval);
  779 + this._internalLpArray[j].fnSetHeadwayS2_P(i, this._iFirstMasterBcIndex, oBcInterval.fP);
  780 +
  781 + oNextBc = _utils.createBcObj(
  782 + this._internalLpArray[j],
  783 + "normal",
  784 + this._oParam.isUpOneWayStop(),
  785 + 1,
  786 + oNextBcFcTime,
  787 + this._oParam);
  788 +
  789 + this._internalLpArray[j].setBc(
  790 + i, this._iFirstMasterBcIndex, oNextBc);
  791 + oPreBc = oNextBc;
  792 + }
  793 + }
  794 +
  795 + // 修正上标线主站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续所有班次
  796 + oBcInterval = aBcInterval[j - 1];
  797 + if (oBcInterval.hasBc) {
  798 + iNextBcInterval = oBcInterval.iFcInterval;
  799 + _modifyTimeNextGroupIndex = i + 1;
  800 + _modifyTimeNextBcIndex = this._iFirstMasterBcIndex;
  801 +
  802 + _utils.modifySBXMasterBc(
  803 + this._internalLpArray[0],
  804 + this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval),
  805 + _modifyTimeNextGroupIndex,
  806 + _modifyTimeNextBcIndex,
  807 + oPreBc.isUp(),
  808 + this._oParam
  809 + );
  810 +
  811 + // 修正上标线主站方向的班次后,一圈结束的班次可能不存在(超过末班车时间了),需要判定
  812 + _modifyBc = this._internalLpArray[0].getBc(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex);
  813 + if (_modifyBc) { // 存在修正间隔值
  814 + this._internalLpArray[0].fnSetVerticalIntervalTime(
  815 + _modifyTimeNextGroupIndex, _modifyTimeNextBcIndex, iNextBcInterval);
  816 + oPreBc = _modifyBc;
  817 + }
  818 +
  819 + }
  820 +
  821 + // 添加副站班次,就是主站班次到达时间加1分钟
  822 + // TODO:因为副站停站时间1分钟到3分钟,几乎没有停站时间,一般前面主站是多少间隔,后面如果有副站的话也是多少间隔
  823 + // TODO:此时,可能出现临界问题,当主站还是高峰接近低谷时,副站已经是低谷,此时副站发车间隔还是高峰间隔
  824 + // TODO:上述情况可以通过让临界的主站高峰班次使用高峰最大间隔,副站使用3分钟的最大停站使副站间隔达到低谷最小间隔
  825 + oPreSlaveBc = this._internalLpArray[0].getBc(
  826 + this._iFirstMasterBcIndex == 0 ? i : i + 1,
  827 + this._iFirstMasterBcIndex == 0 ? 1 : 0
  828 + );
  829 + for (j = 1; j < this._internalLpArray.length; j++) {
  830 + if (oPreSlaveBc) {
  831 + if (aBcInterval[j - 1].hasBc) { // 有主站必有副站
  832 + // 获取当前路牌前一个主站班次
  833 + if (this._internalLpArray[j].getBc(
  834 + i,
  835 + this._iFirstMasterBcIndex)) { // 相同路牌上一个主站班次存在
  836 + oNextSlaveBc = _utils.createBcObj(
  837 + this._internalLpArray[j],
  838 + "normal",
  839 + !this._oParam.isUpOneWayStop(),
  840 + 1,
  841 + this._oParam.addMinute( // 使用1分钟副站停站
  842 + this._internalLpArray[j].getBc(
  843 + i, this._iFirstMasterBcIndex).getArrTimeObj(),
  844 + 1),
  845 + this._oParam);
  846 +
  847 + if (oNextSlaveBc.isUp()) {
  848 + if (!oNextSlaveBc.getFcTimeObj().isAfter(this._oParam.getUpLastDtimeObj())) {
  849 + this._internalLpArray[j].setBc(
  850 + this._iFirstMasterBcIndex == 0 ? i : i + 1,
  851 + this._iFirstMasterBcIndex == 0 ? 1 : 0,
  852 + oNextSlaveBc);
  853 + oPreSlaveBc = oNextSlaveBc;
  854 + }
  855 + } else {
  856 + if (!oPreSlaveBc.getFcTimeObj().isAfter(this._oParam.getDownLastDTimeObj())) {
  857 + this._internalLpArray[j].setBc(
  858 + this._iFirstMasterBcIndex == 0 ? i : i + 1,
  859 + this._iFirstMasterBcIndex == 0 ? 1 : 0,
  860 + oNextSlaveBc);
  861 + oPreSlaveBc = oNextSlaveBc;
  862 + }
  863 + }
  864 + }
  865 + }
  866 + }
  867 + }
  868 +
  869 +
  870 + }
  871 +
  872 + };
  873 +
  874 + //------------- 其他业务方法 -------------//
  875 +
  876 + /**
  877 + * 调整发车间隔。
  878 + */
  879 + InternalScheduleObj.prototype.fnAdjustHeadway = function() {
  880 + // // TODO:572测试,尝试调整第6圈
  881 + // StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(
  882 + // this, this._oParam,
  883 + // 6, 0,
  884 + // 6, 1,
  885 + // 0.2
  886 + // );
  887 + // // TODO:843测试
  888 + // StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(
  889 + // this, this._oParam,
  890 + // 3, 0,
  891 + // 3, 1,
  892 + // 0.2
  893 + // );
  894 +
  895 + var i;
  896 + var bQIsAnotherWay; // 圈的第一个班次是否副站
  897 + if (this._qIsUp) {
  898 + if (this._oParam.getDirAnotherWayStop()) {
  899 + bQIsAnotherWay = true;
  900 + } else {
  901 + bQIsAnotherWay = false;
  902 + }
  903 + } else {
  904 + if (this._oParam.getDirAnotherWayStop()) {
  905 + bQIsAnotherWay = false;
  906 + } else {
  907 + bQIsAnotherWay = true;
  908 + }
  909 + }
  910 +
  911 + if (this._qIsUp == bQIsAnotherWay) {
  912 + for (i = 0; i < this._qCount; i++) {
  913 + StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(
  914 + this, this._oParam,
  915 + i, 0,
  916 + i, 1,
  917 + 0.2
  918 + );
  919 + }
  920 + } else { // 圈的第一个班次是主站班次
  921 + for (i = 0; i < this._qCount; i++) {
  922 + if ((i + 1) < this._qCount) {
  923 + StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_2")(
  924 + this, this._oParam,
  925 + i, 1,
  926 + (i + 1), 0,
  927 + 0.2
  928 + );
  929 + }
  930 + }
  931 + }
  932 +
  933 +
  934 + };
  935 +
  936 + /**
  937 + * 计算吃饭班次。
  938 + */
  939 + InternalScheduleObj.prototype.fnCalcuEatBc = function() {
  940 + var i;
  941 + var j;
  942 + var oLp;
  943 + var oBc;
  944 + // 1、标记吃饭班次
  945 + var oEatFlag = {}; // {"路牌编号":{isLaunch: false, isDinner: false},...}
  946 + for (i = 0; i < this._internalLpArray.length; i++) {
  947 + oLp = this._internalLpArray[i];
  948 + if (oLp.isBxLb()) { // 暂时判定只有连班吃饭
  949 + oEatFlag[oLp.getLpNo()] = {};
  950 + oEatFlag[oLp.getLpNo()]["isLaunch"] = false;
  951 + oEatFlag[oLp.getLpNo()]["isDinner"] = false;
  952 + for (j = 0; j < oLp.getBcArray().length; j++) {
  953 + oBc = oLp.getBcArray()[j];
  954 + // 午饭,暂时判定10:30到13:00
  955 + if (oBc.isUp() == this._oParam.isUpOneWayStop() &&
  956 + oBc.getFcTimeObj().isAfter(this._oParam.toTimeObj("10:30")) &&
  957 + oBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("13:30"))) {
  958 + if (!oEatFlag[oLp.getLpNo()]["isLaunch"]) {
  959 + oBc.fnSetEatTime(this._oParam.fnGetLunchTime());
  960 + oEatFlag[oLp.getLpNo()]["isLaunch"] = true;
  961 + // console.log("吃饭班次时间=" + oBc.format("HH:mm"));
  962 + }
  963 + }
  964 + // 晚饭,暂时判定17:30
  965 + if (oBc.isUp() == this._oParam.isUpOneWayStop() &&
  966 + oBc.getFcTimeObj().isAfter(this._oParam.toTimeObj("17:00")) &&
  967 + oBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("20:00"))) {
  968 + if (!oEatFlag[oLp.getLpNo()]["isDinner"]) {
  969 + oBc.fnSetEatTime(this._oParam.fnGetDinnerTime());
  970 + oEatFlag[oLp.getLpNo()]["isDinner"] = true;
  971 + // console.log("晚饭班次时间=" + oBc.format("HH:mm"));
  972 + }
  973 + }
  974 + }
  975 + }
  976 + }
  977 +
  978 + // 2、调整吃饭所需的停站时间
  979 + StrategyUtils_v2_2.sFn("ADJUST_HEADWAY_3_EAT")(
  980 + this, this._oParam
  981 + );
  982 + };
  983 +
  984 + /**
  985 + * 计算末班车。
  986 + * 1、将上下行拉成上下行两个班次列表(包括标记班次)
  987 + * 2、分别找出离末班车发车时间最近的班次,并替换时间
  988 + * 3、删除之后的班次
  989 + */
  990 + InternalScheduleObj.prototype.fnCalcuLastBc = function() {
  991 + var i;
  992 + var iTimeDiff;
  993 + var iTempTime;
  994 + var aBc;
  995 + var oLastBcTime;
  996 + var oLastBcIsUp;
  997 + var iModifyIndex;
  998 +
  999 + // 查找末班车早的末班车时间和方向
  1000 + if (this._oParam.getUpLastDtimeObj().isBefore(this._oParam.getDownLastDTimeObj())) {
  1001 + oLastBcTime = this._oParam.getUpLastDtimeObj();
  1002 + oLastBcIsUp = true;
  1003 + } else {
  1004 + oLastBcTime = this._oParam.getDownLastDTimeObj();
  1005 + oLastBcIsUp = false;
  1006 + }
  1007 +
  1008 + // 确定早的末班车时间
  1009 + aBc = this.fnGetBcList(oLastBcIsUp);
  1010 + for (i = 0; i < aBc.length; i++) {
  1011 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1012 + if (iTimeDiff == undefined) {
  1013 + iTimeDiff = iTempTime;
  1014 + iModifyIndex = i;
  1015 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1016 + iTimeDiff = iTempTime;
  1017 + iModifyIndex = i;
  1018 + }
  1019 + }
  1020 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1021 + aBc[iModifyIndex].fnSetDelFlag(false);
  1022 + aBc[iModifyIndex].fnSetIsLastBc(true);
  1023 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1024 + this._qIsUp == oLastBcIsUp ?
  1025 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1026 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
  1027 + }
  1028 +
  1029 + // 查找末班车晚的末班车时间和方向
  1030 + if (this._oParam.getUpLastDtimeObj().isBefore(this._oParam.getDownLastDTimeObj())) {
  1031 + oLastBcTime = this._oParam.getDownLastDTimeObj();
  1032 + oLastBcIsUp = false;
  1033 + } else {
  1034 + oLastBcTime = this._oParam.getUpLastDtimeObj();
  1035 + oLastBcIsUp = true;
  1036 + }
  1037 + // 确定晚的末班车时间
  1038 + aBc = this.fnGetBcList(oLastBcIsUp);
  1039 + var oBc;
  1040 + var aBcIndex;
  1041 + var iLpIndex;
  1042 + var iQIndex;
  1043 + var iBcIndex;
  1044 +
  1045 + iTimeDiff = undefined;
  1046 + for (i = 0; i < aBc.length; i++) {
  1047 + oBc = aBc[i];
  1048 + aBcIndex = this.fnGetBcIndex(oBc);
  1049 +
  1050 + iLpIndex = aBcIndex[0];
  1051 + iQIndex = aBcIndex[2] == 0 ? aBcIndex[1] -1 : aBcIndex[1];
  1052 + iBcIndex = aBcIndex[2] == 0 ? 1 : 0;
  1053 +
  1054 + if (!this._internalLpArray[iLpIndex].getBc(iQIndex, iBcIndex)) {
  1055 + continue;
  1056 + }
  1057 +
  1058 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1059 + if (iTimeDiff == undefined) {
  1060 + iTimeDiff = iTempTime;
  1061 + iModifyIndex = i;
  1062 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1063 + iTimeDiff = iTempTime;
  1064 + iModifyIndex = i;
  1065 + }
  1066 + }
  1067 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1068 + aBc[iModifyIndex].fnSetDelFlag(false);
  1069 + aBc[iModifyIndex].fnSetIsLastBc(true);
  1070 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1071 + this._qIsUp == oLastBcIsUp ?
  1072 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1073 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
  1074 + }
  1075 + };
  1076 +
  1077 + /**
  1078 + * 重新设置停站时间(发车时间减到达时间)。
  1079 + */
  1080 + InternalScheduleObj.prototype.fnReSetLayoverTime = function() {
  1081 + for (var i = 0; i < this._internalLpArray.length; i++) {
  1082 + this._internalLpArray[i].modifyLayoverTimeWithoutFcTime();
  1083 + }
  1084 + };
  1085 +
  1086 + /**
  1087 + * 补进出场例保班次。
  1088 + */
  1089 + InternalScheduleObj.prototype.fnCalcuOtherBc = function() {
  1090 + var i;
  1091 + var j;
  1092 + var iBcChainCount;
  1093 + var oLp;
  1094 + var aOtherBc;
  1095 + var oStartBc;
  1096 + var oEndBc;
  1097 +
  1098 + for (i = 0; i < this._internalLpArray.length; i++) {
  1099 + aOtherBc = [];
  1100 + oLp = this._internalLpArray[i];
  1101 + iBcChainCount = oLp.fnGetBcChainCount();
  1102 +
  1103 + if (iBcChainCount == 1) { // 只有一个车次链,是连班班型
  1104 + // 头部要添加出场,例保班次
  1105 + oStartBc = oLp.getBc(
  1106 + oLp.fnGetBcChainInfo(0)["s_q"],
  1107 + oLp.fnGetBcChainInfo(0)["s_b"]
  1108 + );
  1109 + aOtherBc.push(_utils.createBcObj(
  1110 + oLp, "bd", oStartBc.isUp(), 1,
  1111 + oStartBc.getFcTimeObj(),
  1112 + this._oParam
  1113 + ));
  1114 + aOtherBc.push(_utils.createBcObj(
  1115 + oLp, "out", oStartBc.isUp(), 1,
  1116 + oStartBc.getFcTimeObj(),
  1117 + this._oParam
  1118 + ));
  1119 +
  1120 + // 尾部需添加进场,例保班次
  1121 + oEndBc = oLp.getBc(
  1122 + oLp.fnGetBcChainInfo(0)["e_q"],
  1123 + oLp.fnGetBcChainInfo(0)["e_b"]
  1124 + );
  1125 + oEndBc.fnSetIsLastBc(false); // 有可能最后一个班次是吃饭班次,重置
  1126 + oEndBc.fnSetEatTime(0); // 有可能最后一个班次是吃饭班次,重置
  1127 + aOtherBc.push(_utils.createBcObj(
  1128 + oLp, "in", !oEndBc.isUp(), 1,
  1129 + oEndBc.getArrTimeObj(),
  1130 + this._oParam
  1131 + ));
  1132 + aOtherBc.push(_utils.createBcObj(
  1133 + oLp, "lc", !oEndBc.isUp(), 1,
  1134 + oEndBc.getArrTimeObj(),
  1135 + this._oParam
  1136 + ));
  1137 + } else if (iBcChainCount == 2) { // 两个车次链,是分班班型
  1138 + // 第一个车次链开头有出场,报到班次,车次链结尾只有进场班次
  1139 + oStartBc = oLp.getBc(
  1140 + oLp.fnGetBcChainInfo(0)["s_q"],
  1141 + oLp.fnGetBcChainInfo(0)["s_b"]
  1142 + );
  1143 + aOtherBc.push(_utils.createBcObj(
  1144 + oLp, "bd", oStartBc.isUp(), 1,
  1145 + oStartBc.getFcTimeObj(),
  1146 + this._oParam
  1147 + ));
  1148 + aOtherBc.push(_utils.createBcObj(
  1149 + oLp, "out", oStartBc.isUp(), 1,
  1150 + oStartBc.getFcTimeObj(),
  1151 + this._oParam
  1152 + ));
  1153 +
  1154 + oEndBc = oLp.getBc(
  1155 + oLp.fnGetBcChainInfo(0)["e_q"],
  1156 + oLp.fnGetBcChainInfo(0)["e_b"]
  1157 + );
  1158 + aOtherBc.push(_utils.createBcObj(
  1159 + oLp, "in", !oEndBc.isUp(), 1,
  1160 + oEndBc.getArrTimeObj(),
  1161 + this._oParam
  1162 + ));
  1163 +
  1164 + // 第二个车次链开头有出场,报到班次,车次链结尾有进场,报到班次
  1165 + oStartBc = oLp.getBc(
  1166 + oLp.fnGetBcChainInfo(1)["s_q"],
  1167 + oLp.fnGetBcChainInfo(1)["s_b"]
  1168 + );
  1169 + aOtherBc.push(_utils.createBcObj(
  1170 + oLp, "bd", oStartBc.isUp(), 1,
  1171 + oStartBc.getFcTimeObj(),
  1172 + this._oParam
  1173 + ));
  1174 + aOtherBc.push(_utils.createBcObj(
  1175 + oLp, "out", oStartBc.isUp(), 1,
  1176 + oStartBc.getFcTimeObj(),
  1177 + this._oParam
  1178 + ));
  1179 +
  1180 + oEndBc = oLp.getBc(
  1181 + oLp.fnGetBcChainInfo(1)["e_q"],
  1182 + oLp.fnGetBcChainInfo(1)["e_b"]
  1183 + );
  1184 + aOtherBc.push(_utils.createBcObj(
  1185 + oLp, "in", !oEndBc.isUp(), 1,
  1186 + oEndBc.getArrTimeObj(),
  1187 + this._oParam
  1188 + ));
  1189 + aOtherBc.push(_utils.createBcObj(
  1190 + oLp, "lc", !oEndBc.isUp(), 1,
  1191 + oEndBc.getArrTimeObj(),
  1192 + this._oParam
  1193 + ));
  1194 +
  1195 +
  1196 + } else {
  1197 + // 2个车次链以上,暂时没有此班型
  1198 + }
  1199 +
  1200 + oLp.addOtherBcArray(aOtherBc);
  1201 + }
  1202 + };
  1203 +
  1204 +
  1205 + //------------- 其他非业务方法方法 -------------//
  1206 + /**
  1207 + * 获取班次列表。
  1208 + * @param isUp boolean 是否上行
  1209 + * @returns [(InternalBcObj)]
  1210 + */
  1211 + InternalScheduleObj.prototype.fnGetBcList = function(isUp) {
  1212 + var i;
  1213 + var j;
  1214 + var oLp;
  1215 + var oBc;
  1216 + var aBc = [];
  1217 +
  1218 + for (j = 0; j < this._qCount; j++) {
  1219 + for (i = 0; i < this._internalLpArray.length; i++) {
  1220 + oLp = this._internalLpArray[i];
  1221 + oBc = oLp.getBc(
  1222 + j,
  1223 + this._qIsUp == isUp ? 0 : 1
  1224 + );
  1225 + if (oBc) {
  1226 + aBc.push(oBc);
  1227 + }
  1228 + }
  1229 + }
  1230 +
  1231 + var aBcFcTime = [];
  1232 + for (i = 0; i < aBc.length; i++) {
  1233 + oBc = aBc[i];
  1234 + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm"));
  1235 + }
  1236 + console.log((isUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(","));
  1237 +
  1238 + return aBc;
  1239 + };
  1240 +
  1241 + /**
  1242 + * 获取班次索引。
  1243 + * @param oBc 班次对象
  1244 + * @returns [{路牌索引},{圈索引},{班次索引}]
  1245 + */
  1246 + InternalScheduleObj.prototype.fnGetBcIndex = function(oBc) {
  1247 + // 路牌索引
  1248 + var i;
  1249 + var iLpIndex;
  1250 + for (i = 0; i < this._internalLpArray.length; i++) {
  1251 + if (this._internalLpArray[i]._$$_orign_lp_obj == oBc._$$_internal_lp_obj._$$_orign_lp_obj) {
  1252 + iLpIndex = i;
  1253 + break;
  1254 + }
  1255 + }
  1256 + // 圈索引
  1257 + var j;
  1258 + var iGroupIndex;
  1259 + var bFlag = false;
  1260 + for (i = 0; i < this._internalLpArray.length; i++) {
  1261 + if (bFlag) {
  1262 + break;
  1263 + }
  1264 + for (j = 0; j < this._qCount; j++) {
  1265 + if (this._internalLpArray[i]._$_groupBcArray[j] == oBc._$$_internal_group_obj) {
  1266 + iGroupIndex = j;
  1267 + bFlag = true;
  1268 + break;
  1269 + }
  1270 + }
  1271 + }
  1272 + // 班次索引
  1273 + var iBcIndex = this._qIsUp == oBc.isUp() ? 0 : 1;
  1274 +
  1275 + if (iLpIndex == undefined) {
  1276 + return null;
  1277 + } else {
  1278 + return [].concat(iLpIndex, iGroupIndex, iBcIndex);
  1279 + }
  1280 + };
  1281 +
  1282 + /**
  1283 + * 返回内部路牌数据列表。
  1284 + * @returns {Array}
  1285 + */
  1286 + InternalScheduleObj.prototype.fnGetLpArray = function() {
  1287 + return this._internalLpArray;
  1288 + };
  1289 +
  1290 + /**
  1291 + * 获取班型描述。
  1292 + * @return {*[]}
  1293 + */
  1294 + InternalScheduleObj.prototype.fnGetBxDesc = function() {
  1295 + return this._aBxDesc;
  1296 + };
  1297 +
  1298 + /**
  1299 + * 获取圈的第一个班次是上行还是下行。
  1300 + * @return {boolean|*}
  1301 + */
  1302 + InternalScheduleObj.prototype.fnGetGroupIsUp = function() {
  1303 + return this._qIsUp;
  1304 + };
  1305 +
  1306 + /**
  1307 + * 返回内部工具对象。
  1308 + * @return {{createBcObj, modifySBXMasterBc}}
  1309 + */
  1310 + InternalScheduleObj.prototype.fnGetUitls = function() {
  1311 + return _utils;
  1312 + };
  1313 +
  1314 + /**
  1315 + * 内部数据转化成显示用的班次数组。
  1316 + */
  1317 + InternalScheduleObj.prototype.fnToGanttBcArray = function() {
  1318 + var aAllBc = [];
  1319 + var aLpBc = [];
  1320 + var aEatBc = [];
  1321 + var oLp;
  1322 + var i;
  1323 + var j;
  1324 +
  1325 + for (i = 0; i < this._internalLpArray.length; i++) {
  1326 + oLp = this._internalLpArray[i];
  1327 + aLpBc = [];
  1328 + aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());
  1329 +
  1330 + aEatBc = [];
  1331 + // TODO:根据班次的吃饭时间添加吃饭班次
  1332 + for (j = 0; j < aLpBc.length; j++) {
  1333 + if (aLpBc[j].fnGetEatTime() > 0) {
  1334 + aEatBc.push(_utils.createBcObj(
  1335 + oLp,
  1336 + "cf",
  1337 + aLpBc[j].isUp(), // 和上一个班次方向相反
  1338 + 1,
  1339 + this._oParam.addMinute(aLpBc[j].getFcTimeObj(), -aLpBc[j].fnGetEatTime()),
  1340 + this._oParam
  1341 + ));
  1342 + }
  1343 + }
  1344 + aLpBc = aLpBc.concat(aEatBc);
  1345 +
  1346 + // 按照发车时间排序
  1347 + aLpBc.sort(function(o1, o2) {
  1348 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1349 + return -1;
  1350 + } else {
  1351 + return 1;
  1352 + }
  1353 + });
  1354 +
  1355 + // 重新赋值fcno
  1356 + for (j = 0; j < aLpBc.length; j++) {
  1357 + aLpBc[j].fnSetFcno(j + 1);
  1358 + }
  1359 +
  1360 + aAllBc = aAllBc.concat(aLpBc);
  1361 + }
  1362 +
  1363 + var aGanttBc = [];
  1364 + for (i = 0; i < aAllBc.length; i++) {
  1365 + aGanttBc.push(aAllBc[i].toGanttBcObj());
  1366 + }
  1367 +
  1368 + return aGanttBc;
  1369 + };
  1370 +
  1371 + /**
  1372 + * 计算指定开始时间,指定方向班次执行后的最大最小停站时间。
  1373 + * @param oStartFcTime 开始发车时间
  1374 + * @param isUp 是否上行
  1375 + * @returns array [最小值,最大值]
  1376 + */
  1377 + InternalScheduleObj.prototype._$calcuLayoverTime = function(oStartFcTime, isUp) {
  1378 + var aRtn = [];
  1379 + var _iRunningTime; // 行驶时间
  1380 + var _iLayoverTime; // 停站时间
  1381 +
  1382 + // 最小停站时间
  1383 + _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(
  1384 + isUp, oStartFcTime, this._oParam);
  1385 + _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1386 + oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),
  1387 + this._oParam)[0]; // 最小停站
  1388 + aRtn.push(_iLayoverTime);
  1389 +
  1390 + // 最大停站时间
  1391 + _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(
  1392 + isUp, oStartFcTime, this._oParam);
  1393 + _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1394 + oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),
  1395 + this._oParam)[1]; // 最大停站
  1396 + aRtn.push(_iLayoverTime);
  1397 +
  1398 + return aRtn;
  1399 + };
  1400 +
  1401 + /**
  1402 + * 计算指定时间,指定方向开始的最大最小周转时间
  1403 + * @param oStartFcTime 开始发车时间
  1404 + * @param isUp 是否上行
  1405 + * @returns array [最小值,最大值]
  1406 + * @private
  1407 + */
  1408 + InternalScheduleObj.prototype._$calcuCycleTime = function(oStartFcTime, isUp) {
  1409 + var aRtn = [];
  1410 + var _iRunningTime; // 行驶时间
  1411 + var _iLayoverTime; // 停站时间
  1412 + var _iCycleTime; // 周转时间
  1413 + var _oNextFcTime;
  1414 +
  1415 + // 最小周转时间
  1416 + _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(
  1417 + isUp, oStartFcTime, this._oParam);
  1418 + _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1419 + oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),
  1420 + this._oParam)[0]; // 最小停站
  1421 + _iCycleTime = _iRunningTime + _iLayoverTime;
  1422 + _oNextFcTime = this._oParam.addMinute(oStartFcTime, (_iRunningTime + _iLayoverTime));
  1423 + _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(
  1424 + !isUp, _oNextFcTime, this._oParam);
  1425 + _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1426 + _oNextFcTime, !isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),
  1427 + this._oParam)[0]; // 最小停站
  1428 + _iCycleTime += _iRunningTime;
  1429 + _iCycleTime += _iLayoverTime;
  1430 +
  1431 + aRtn.push(_iCycleTime);
  1432 +
  1433 + // 最大周转时间
  1434 + _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(
  1435 + isUp, oStartFcTime, this._oParam);
  1436 + _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1437 + oStartFcTime, isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),
  1438 + this._oParam)[1]; // 最大停站
  1439 + _iCycleTime = _iRunningTime + _iLayoverTime;
  1440 + _oNextFcTime = this._oParam.addMinute(oStartFcTime, (_iRunningTime + _iLayoverTime));
  1441 + _iRunningTime = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(
  1442 + !isUp, _oNextFcTime, this._oParam);
  1443 + _iLayoverTime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1444 + _oNextFcTime, !isUp, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"),
  1445 + this._oParam)[1]; // 最大停站
  1446 + _iCycleTime += _iRunningTime;
  1447 + _iCycleTime += _iLayoverTime;
  1448 +
  1449 + aRtn.push(_iCycleTime);
  1450 +
  1451 + return aRtn;
  1452 + };
  1453 +
  1454 + //-------------------- static静态方法 ----------------------//
  1455 +
  1456 + /**
  1457 + * 计算车辆数(最大周转时间/最大发车间隔)。
  1458 + * @param oParam 参数对象
  1459 + */
  1460 + InternalScheduleObj.calcuClzx = function(oParam) {
  1461 + var _iUpRT; // 上行行驶时间
  1462 + var _iUpLT; // 上行停站时间
  1463 + var _iDownRT; // 下行行驶时间
  1464 + var _iDownLT; // 下行停站时间
  1465 +
  1466 + // 计算早高峰最大周转时间
  1467 + _iUpRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(true, oParam.getMPeakStartTimeObj(), oParam);
  1468 + _iUpLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1469 + oParam.getMPeakStartTimeObj(), true,
  1470 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间
  1471 + _iDownRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, oParam.getMPeakStartTimeObj(), oParam);
  1472 + _iDownLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1473 + oParam.getMPeakStartTimeObj(), false,
  1474 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间
  1475 + var _iAMPeakRCTime = _iUpRT + _iUpLT + _iDownRT + _iDownLT;
  1476 + // 早高峰预估车辆数,使用早高峰最大发车间隔
  1477 + var _iAMPeakVehicleCount = _iAMPeakRCTime / oParam.getMPeakMaxFcjx();
  1478 +
  1479 + // 计算晚高峰最大周转时间
  1480 + _iUpRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(true, oParam.getEPeakStartTimeObj(), oParam);
  1481 + _iUpLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1482 + oParam.getEPeakStartTimeObj(), true,
  1483 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间
  1484 + _iDownRT = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, oParam.getEPeakStartTimeObj(), oParam);
  1485 + _iDownLT = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  1486 + oParam.getEPeakStartTimeObj(), false,
  1487 + StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), oParam)[1]; // 使用最大停站时间
  1488 + var _iPMPeakRCTime = _iUpRT + _iUpLT + _iDownRT + _iDownLT;
  1489 + // 晚高峰预估车辆数,使用晚高峰最大发车间隔
  1490 + var _iPMPeakVehicleCount = _iPMPeakRCTime / oParam.getEPeakMaxFcjx();
  1491 +
  1492 + // 取最大值为最终车辆数
  1493 + // 大于或等于的最小整数,人话就是有小数点就加1
  1494 + if (_iAMPeakVehicleCount > _iPMPeakVehicleCount) {
  1495 + return Math.ceil(_iAMPeakVehicleCount);
  1496 + } else {
  1497 + return Math.ceil(_iPMPeakVehicleCount);
  1498 + }
  1499 +
  1500 + };
  1501 +
  1502 +
  1503 + return InternalScheduleObj;
1504 }()); 1504 }());
1505 \ No newline at end of file 1505 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2_2/Main_v2_2_ExcelObj.js
1 -/**  
2 - * v2_2版本时刻表excel对象。  
3 - */  
4 -var Main_v2_2_ExcelObj = (function() {  
5 - // html5导出下载文件方法  
6 - var _fnDownloadFile = function(data, mimeType, fileName) {  
7 - var success = false;  
8 - var blob = new Blob([data], { type: mimeType });  
9 - try {  
10 - if (navigator.msSaveBlob)  
11 - navigator.msSaveBlob(blob, fileName);  
12 - else {  
13 - // Try using other saveBlob implementations, if available  
14 - var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;  
15 - if (saveBlob === undefined) throw "Not supported";  
16 - saveBlob(blob, fileName);  
17 - }  
18 - success = true;  
19 - } catch (ex) {  
20 - console.log("saveBlob method failed with the following exception:");  
21 - console.log(ex);  
22 - }  
23 -  
24 - if (!success) {  
25 - // Get the blob url creator  
26 - var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;  
27 - if (urlCreator) {  
28 - // Try to use a download link  
29 - var link = document.createElement('a');  
30 - if ('download' in link) {  
31 - // Try to simulate a click  
32 - try {  
33 - // Prepare a blob URL  
34 - var url = urlCreator.createObjectURL(blob);  
35 - link.setAttribute('href', url);  
36 -  
37 - // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)  
38 - link.setAttribute("download", fileName);  
39 -  
40 - // Simulate clicking the download link  
41 - var event = document.createEvent('MouseEvents');  
42 - event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);  
43 - link.dispatchEvent(event);  
44 - success = true;  
45 -  
46 - } catch (ex) {  
47 - console.log("Download link method with simulated click failed with the following exception:");  
48 - console.log(ex);  
49 - }  
50 - }  
51 -  
52 - if (!success) {  
53 - // Fallback to window.location method  
54 - try {  
55 - // Prepare a blob URL  
56 - // Use application/octet-stream when using window.location to force download  
57 - var url = urlCreator.createObjectURL(blob);  
58 - window.location = url;  
59 - console.log("Download link method with window.location succeeded");  
60 - success = true;  
61 - } catch (ex) {  
62 - console.log("Download link method with window.location failed with the following exception:");  
63 - console.log(ex);  
64 - }  
65 - }  
66 - }  
67 - }  
68 -  
69 - if (!success) {  
70 - // Fallback to window.open method  
71 - console.log("No methods worked for saving the arraybuffer, using last resort window.open");  
72 - window.open("", '_blank', '');  
73 - }  
74 - };  
75 -  
76 - // 计算导出参数sheet数据。  
77 - var _fnCalcuExportParam_sheet = function(_paramObj) {  
78 - return [  
79 - {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")},  
80 - {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")},  
81 - {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")},  
82 - {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")},  
83 - {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")},  
84 - {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")},  
85 - {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")},  
86 - {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")},  
87 - {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()},  
88 - {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()},  
89 - {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()},  
90 - {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()},  
91 - {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()},  
92 - {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()},  
93 - {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()},  
94 - {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()},  
95 - {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()},  
96 - {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()},  
97 - {'paramItem' : '线路规划类型', 'paramValue' : "双向"},  
98 - {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"},  
99 - {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()},  
100 - {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()},  
101 - {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()},  
102 - {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()},  
103 - {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"},  
104 - {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"},  
105 - {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"},  
106 - {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()},  
107 - {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") },  
108 - {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()}  
109 - ]  
110 - };  
111 -  
112 - // 计算班次统计数据sheet数据。  
113 - var _fnCalcuExportStatInfo_sheet = function(aBc, oParam) {  
114 - var countBc = 0, // 总班次  
115 - serviceBc = 0, // 营运班次  
116 - jcbc = 0, // 进场总班次.  
117 - ccbc = 0, // 出场总班次.  
118 - cfbc = 0, // 吃饭总班次.  
119 - zwlbbc = 0, // 早晚例保总班次.  
120 - countGs = 0.0, // 总工时  
121 - servicesj = 0, // 营运班次总时间  
122 - jcsj = 0.0, // 进场总时间.  
123 - ccsj = 0.0, // 出场总时间.  
124 - cfsj = 0.0, // 吃饭总时间.  
125 - zwlbsj = 0.0, // 早晚例保总时间.  
126 - ksBc = 0, // 空驶班次  
127 - serviceLc = 0.0, // 营运里程  
128 - ksLc = 0.0, // 空驶里程  
129 - avgTzjx = 0.0, // 平均停站间隙  
130 - gfServiceBc = 0, // 高峰营运班次  
131 - dgServiceBc = 0, // 低谷营运班次  
132 - gfAvgTzjx = 0.0, // 高峰平均停站间隙  
133 - dgAvgTzjx = 0.0; // 低谷平均停站间隙  
134 -  
135 - var i;  
136 - var oBc;  
137 - for (i = 0; i < aBc.length; i++) {  
138 - oBc = aBc[i];  
139 -  
140 - if (oBc.bcsj > 0) {  
141 - countBc = countBc + 1;  
142 - countGs = countGs + oBc.STOPTIME + oBc.bcsj;  
143 - if (oParam.isTroughBc(oParam.toTimeObj(oBc.fcsj))) {  
144 - if (oBc.bcType == "normal") {  
145 - dgServiceBc = dgServiceBc + 1;  
146 - dgAvgTzjx = dgAvgTzjx + oBc.STOPTIME;  
147 - }  
148 - } else {  
149 - if (oBc.bcType == "normal") {  
150 - gfServiceBc = gfServiceBc + 1;  
151 - gfAvgTzjx = gfAvgTzjx + oBc.STOPTIME;  
152 - }  
153 - }  
154 -  
155 - if (oBc.bcType == "normal" || oBc.bcType == "cf") {  
156 - serviceBc = serviceBc + 1;  
157 - serviceLc = serviceLc + oBc.jhlc;  
158 - servicesj = servicesj + oBc.bcsj;  
159 - avgTzjx = avgTzjx + oBc.STOPTIME;  
160 -  
161 - if (oBc.bcType == "cf") {  
162 - cfbc = cfbc + 1;  
163 - cfsj = cfsj + oBc.bcsj;  
164 - }  
165 - } else if (oBc.bcType == "in") {  
166 - jcbc = jcbc + 1;  
167 - jcsj = jcsj + oBc.bcsj;  
168 - } else if (oBc.bcType == "out") {  
169 - ccbc = ccbc + 1;  
170 - ccsj = ccsj + oBc.bcsj;  
171 - } else if (oBc.bcType == "bd") {  
172 - zwlbbc = zwlbbc + 1;  
173 - zwlbsj = zwlbsj + oBc.bcsj;  
174 - } else if (oBc.bcType == "lc") {  
175 - zwlbbc = zwlbbc + 1;  
176 - zwlbsj = zwlbsj + oBc.bcsj;  
177 - }  
178 - }  
179 - }  
180 -  
181 - dgAvgTzjx = dgAvgTzjx / dgServiceBc;  
182 - gfAvgTzjx = gfAvgTzjx / gfServiceBc;  
183 - avgTzjx = avgTzjx / dgServiceBc;  
184 -  
185 - return [  
186 - {'statItem': '总班次(包括进出场、吃饭时间、早晚例保、营运且班次时间大于零的班次)', 'statValue': countBc},  
187 - {'statItem': '进场总班次(包括进场且班次时间大于零的班次)', 'statValue': jcbc},  
188 - {'statItem': '出场总班次(包括进场且班次时间大于零的班次)', 'statValue': ccbc},  
189 - {'statItem': '吃饭总班次(包括吃饭且班次时间大于零的班次)', 'statValue': cfbc},  
190 - {'statItem': '早晚例保总班次(包括早晚例保且时间大于零的班次)', 'statValue': zwlbbc},  
191 - {'statItem': '营运总班次(包括正常、区间、放大站且班次时间大于零班次)','statValue': serviceBc},  
192 - {'statItem': '进场总时间(包括进场班次且班次时间大于零)', 'statValue': jcsj/60},  
193 - {'statItem': '出场总时间(包括进场班次且班次时间大于零)', 'statValue': ccsj/60},  
194 - {'statItem': '吃饭总时间(包括吃饭班次且班次时间大于零)', 'statValue': cfsj/60},  
195 - {'statItem': '早晚例保总时间(包括早晚例保班次且时间大于零的)', 'statValue': zwlbsj/60},  
196 - {'statItem': '营运班次总时间(包括正常、区间、放大站且班次时间大于零)', 'statValue': servicesj/60},  
197 - {'statItem': '总工时(包括进出场、吃饭时间、早晚例保、营运班次时间)', 'statValue': countGs/60},  
198 - {'statItem': '空驶班次(包括直放班次)', 'statValue': ksBc},  
199 - {'statItem': '营运里程(包括正常、区间、放大站里程)', 'statValue': serviceLc},  
200 - {'statItem': '空驶里程(包括直放里程)', 'statValue': ksLc},  
201 - {'statItem': '平均停站时间(营运班次停站时间总和/营运总班次)', 'statValue': avgTzjx},  
202 - {'statItem': '高峰营运班次(包括早晚高峰时段的正常、区间、放大站班次)', 'statValue': gfServiceBc},  
203 - {'statItem': '低谷营运班次(包括低谷时段的正常、区间、放大站班次)', 'statValue': dgServiceBc},  
204 - {'statItem': '高峰平均停站间隙(高峰营运班次停站时间总和/高峰营运班次总和)', 'statValue': gfAvgTzjx},  
205 - {'statItem': '低谷平均停站间隙(低谷营运班次停站时间总和/低谷营运班次总和)', 'statValue': dgAvgTzjx},  
206 - {'statItem': '综合评估', 'statValue': 3}  
207 - ];  
208 -  
209 - };  
210 -  
211 - /**  
212 - * 内部计算Excel班次方法1,  
213 - * 这里是假设班次按照从早到晚排序,并且路牌也是从小到大排序。  
214 - * @param aExcelLp excel显示用路牌  
215 - * @param aGanttBc 甘特图班次列表  
216 - * @param oParam 参数对象  
217 - * @param bQIsUp 每一圈是上行开始还是下行开始  
218 - * @private  
219 - */  
220 - function InternalCalcuExcelBc1(aExcelLp, aGanttBc, oParam, bQIsUp) {  
221 - this._aExcelLp = aExcelLp;  
222 - this._oParam = oParam;  
223 - this._bQIsUp = bQIsUp;  
224 -  
225 - this._iUpGroupIndex = 0;  
226 - this._iDownGroupIndex = 0;  
227 -  
228 - // {"路牌名字":{"isFlag": 是否为标记班次(表示扫描过但是没有班次对象),"normal":正常班次}}  
229 - this._oLpGroupNormalGanttBc = {};  
230 - // [吃饭类型班次]  
231 - this._aLpGroupCfGanttBc = [];  
232 -  
233 - // TODO:其他类型的班次再议  
234 -  
235 - // 计算上行gantt班次列表,下行gantt班次列表,并排序  
236 - var i;  
237 - var oGanttBc;  
238 - this._aUpGanttBc = [];  
239 - this._aDownGanttBc = [];  
240 - for (i = 0; i < aGanttBc.length; i++) {  
241 - oGanttBc = aGanttBc[i];  
242 - if (oGanttBc.xlDir == "relationshipGraph-up") {  
243 - this._aUpGanttBc.push(oGanttBc);  
244 - } else {  
245 - this._aDownGanttBc.push(oGanttBc);  
246 - }  
247 - }  
248 - // 排序班次  
249 - this._fnSortBc(this._aUpGanttBc);  
250 - this._fnSortBc(this._aDownGanttBc);  
251 -  
252 - if (this._aUpGanttBc.length == 0) {  
253 - throw "没有上行班次,不能导出数据!";  
254 - }  
255 - if (this._aDownGanttBc.length == 0) {  
256 - throw "没有下行班次,不能导出数据!"  
257 - }  
258 -  
259 - }  
260 -  
261 - //----------------------- 外部方法 -----------------------//  
262 - InternalCalcuExcelBc1.prototype.fnGenerateExcelLpBcList = function() {  
263 - // 计算Excel班次  
264 - this._calcuExcelBc();  
265 -  
266 - // 设置路牌圈数  
267 - var iGroupCount = this._iUpGroupIndex > this._iDownGroupIndex ?  
268 - (this._iUpGroupIndex + 1) : (this._iDownGroupIndex + 1);  
269 -  
270 - // 设置路由id  
271 - var oUpNormalBc;  
272 - var oDownNormalBc;  
273 - var i;  
274 - for (i = 0; i < this._aUpGanttBc.length; i++) {  
275 - if (this._aUpGanttBc[i].bcType == "normal") {  
276 - oUpNormalBc = this._aUpGanttBc[i];  
277 - break;  
278 - }  
279 - }  
280 - for (i = 0; i < this._aDownGanttBc.length; i++) {  
281 - if (this._aDownGanttBc[i].bcType == "normal") {  
282 - oDownNormalBc = this._aDownGanttBc[i];  
283 - break;  
284 - }  
285 - }  
286 -  
287 - var stationRouteId1;  
288 - var stationRouteId2;  
289 - if (this._bQIsUp) {  
290 - stationRouteId1 = oUpNormalBc.qdz;  
291 - stationRouteId2 = oDownNormalBc.qdz;  
292 - } else {  
293 - stationRouteId1 = oDownNormalBc.qdz;  
294 - stationRouteId2 = oUpNormalBc.qdz;  
295 - }  
296 -  
297 - var oExcelLp;  
298 - for (i = 0; i < this._aExcelLp.length; i++) {  
299 - oExcelLp = this._aExcelLp[i];  
300 - oExcelLp.groupCount = iGroupCount;  
301 - oExcelLp.stationRouteId1 = stationRouteId1;  
302 - oExcelLp.stationRouteId2 = stationRouteId2;  
303 -  
304 - // 删除临时参数  
305 - delete oExcelLp["_bcObjGroupList"];  
306 - }  
307 -  
308 - // 路牌数据统计  
309 - var j = 0;  
310 - var aLpBc;  
311 - var oLpBc;  
312 - for (i = 0; i < this._aExcelLp.length; i++) {  
313 - oExcelLp = this._aExcelLp[i];  
314 - aLpBc = oExcelLp.bcObjList;  
315 - for (j = 0; j < aLpBc.length; j++) {  
316 - oLpBc = aLpBc[j];  
317 - if (oLpBc.bcType == "normal") {  
318 - oExcelLp.zlc = oExcelLp.zlc +  
319 - oLpBc._bclc; // 总里程  
320 - oExcelLp.yylc = oExcelLp.yylc +  
321 - oLpBc._bclc; // 营运里程  
322 - oExcelLp.yygs = oExcelLp.yygs +  
323 - oLpBc.bcsj + // 班次时间  
324 - oLpBc.ssj + // 停站时间  
325 - oLpBc.eatsj; // 吃饭时间  
326 - oExcelLp.yybc = oExcelLp.yybc + 1;  
327 -  
328 - oExcelLp.zgs = oExcelLp.zgs +  
329 - oLpBc.bcsj + // 班次时间  
330 - oLpBc.ssj + // 停站时间  
331 - oLpBc.eatsj; // 吃饭时间  
332 - oExcelLp.zbc = oExcelLp.zbc + 1;  
333 - } else if (  
334 - oLpBc.bcType == "bd" ||  
335 - oLpBc.bcType == "out" ||  
336 - oLpBc.bcType == "in" ||  
337 - oLpBc.bcType == "lc") {  
338 - oExcelLp.kslc = oExcelLp.kslc +  
339 - oLpBc._bclc; // 里程  
340 - oExcelLp.zlc = oExcelLp.zlc +  
341 - oLpBc._bclc; // 里程  
342 - oExcelLp.zgs = oExcelLp.zgs +  
343 - oLpBc.bcsj + // 班次时间  
344 - oLpBc.ssj; // 停站时间  
345 -  
346 - if (oLpBc.bcType != "bd" && oLpBc.bcType != "lc") {  
347 - oExcelLp.zbc = oExcelLp.zbc + 1;  
348 - }  
349 -  
350 - }  
351 -  
352 - delete oLpBc._bclc; // 删除临时变量  
353 -  
354 - }  
355 - }  
356 -  
357 -  
358 -  
359 - return this._aExcelLp;  
360 - };  
361 -  
362 - //----------------------- 内部方法 ------------------------//  
363 - // 排序班次  
364 - InternalCalcuExcelBc1.prototype._fnSortBc = function(aGanttBc) {  
365 - var oParam = this._oParam;  
366 - aGanttBc.sort(function (o1, o2) { // 时间从早到晚排序  
367 - var o1_fcsj;  
368 - var o2_fcsj;  
369 - if (o1.fcsj.indexOf("00:") >= 0) { // 大于00点是第二天  
370 - o1_fcsj = oParam.toTimeObj(o1.fcsj).add(1, "d");  
371 - } else {  
372 - o1_fcsj = oParam.toTimeObj(o1.fcsj);  
373 - }  
374 -  
375 - if (o2.fcsj.indexOf("00:") >= 0) { // 大于00点是第二天  
376 - o2_fcsj = oParam.toTimeObj(o2.fcsj).add(1, "d");  
377 - } else {  
378 - o2_fcsj = oParam.toTimeObj(o2.fcsj);  
379 - }  
380 -  
381 -  
382 - if (o1_fcsj.isBefore(o2_fcsj)) {  
383 - return -1;  
384 - } else {  
385 - return 1;  
386 - }  
387 - });  
388 - // 此处假设班次按照从早倒晚排,每一圈按照路牌顺序排  
389 -  
390 - // TODO:如果发生同一圈路牌交叉发车,不是按照路牌排序的,导出时有问题,再议  
391 - };  
392 -  
393 - InternalCalcuExcelBc1.prototype._calcuExcelBc = function() {  
394 - var i = 0;  
395 - var j = 0;  
396 -  
397 - var aUpBc;  
398 - var aDownBc;  
399 - if (this._bQIsUp) {  
400 - aUpBc = this._aUpGanttBc;  
401 - aDownBc = this._aDownGanttBc;  
402 - } else {  
403 - aUpBc = this._aDownGanttBc;  
404 - aDownBc = this._aUpGanttBc;  
405 - }  
406 -  
407 - do {  
408 - i = this._calcuExcelBcPerGroup(this._bQIsUp, i);  
409 - j = this._calcuExcelBcPerGroup(!this._bQIsUp, j);  
410 - } while(i < aUpBc.length || j < aDownBc.length);  
411 -  
412 - // 重新计算报到,出场,进场,离场班次的圈,班次索引  
413 - this._resetBdOutInLcBcGroup();  
414 -  
415 - };  
416 -  
417 - /**  
418 - * 重新计算Excel显示班次(计算1圈)。  
419 - * @param bIsUp 是否上行  
420 - * @param iBcIndex 班次索引  
421 - * @return 下一次计算索引  
422 - */  
423 - InternalCalcuExcelBc1.prototype._calcuExcelBcPerGroup = function(bIsUp, iBcIndex) {  
424 - this._oLpGroupNormalGanttBc = {};  
425 -  
426 - var i;  
427 - var j = 0;  
428 - var oExcelLp;  
429 - var oGanttBc;  
430 - var aGBc = bIsUp ? this._aUpGanttBc : this._aDownGanttBc;  
431 -  
432 - for (i = iBcIndex; i < aGBc.length; i++) {  
433 - oGanttBc = aGBc[i];  
434 -  
435 - // 添加到场,出场,进场,离场班次  
436 - this._addBdOutInLcBc(oGanttBc, bIsUp);  
437 -  
438 - while(j < this._aExcelLp.length) {  
439 - oExcelLp = this._aExcelLp[j];  
440 -  
441 - if (oGanttBc.bcType == "cf") { // 吃饭班次  
442 - this._aLpGroupCfGanttBc.push(oGanttBc);  
443 - break;  
444 - } else if (oGanttBc.bcType == "normal") { // 正常班次  
445 - this._oLpGroupNormalGanttBc[oExcelLp.lpname] = {  
446 - "isFlag": true, "normal": null  
447 - };  
448 - if (oExcelLp.lpname == oGanttBc.lpName) {  
449 - this._oLpGroupNormalGanttBc[oExcelLp.lpname].isFlag = false;  
450 - this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal = oGanttBc;  
451 - j++;  
452 - break;  
453 - } else {  
454 - j++;  
455 - }  
456 - } else {  
457 -  
458 - break;  
459 - }  
460 -  
461 - }  
462 -  
463 - if (j == this._aExcelLp.length) { // 完整的一圈处理  
464 - this._resetCalcuGroup(bIsUp);  
465 - j = 0;  
466 - if (oGanttBc.lpName !=  
467 - this._aExcelLp[this._aExcelLp.length - 1].lpname) {  
468 - i--;  
469 - break;  
470 -  
471 - }  
472 -  
473 - break;  
474 - }  
475 -  
476 - }  
477 -  
478 - // 最后一圈reset一下  
479 - if (j > 0) {  
480 - this._resetCalcuGroup(bIsUp);  
481 - }  
482 - return i + 1;  
483 -  
484 - };  
485 -  
486 - InternalCalcuExcelBc1.prototype._resetCalcuGroup = function(bIsUp) {  
487 - // 判定是否开始分班,添加圈数  
488 - if (bIsUp) {  
489 - if (this._fnIsFBcQ(bIsUp)) {  
490 - this._iUpGroupIndex += 1;  
491 - this._iDownGroupIndex += 1;  
492 - }  
493 - } else {  
494 - if (this._fnIsFBcQ(!bIsUp)) {  
495 - this._iUpGroupIndex += 1;  
496 - this._iDownGroupIndex += 1;  
497 - }  
498 - }  
499 -  
500 - // 重置计算圈及班次  
501 - var oExcelLp;  
502 - var oGroupGanttNormalBc;  
503 - var oGroupGanttEatBc;  
504 - for (var i = 0; i < this._aExcelLp.length; i++) {  
505 - oExcelLp = this._aExcelLp[i];  
506 - if (this._oLpGroupNormalGanttBc[oExcelLp.lpname]) {  
507 - if (!this._oLpGroupNormalGanttBc[oExcelLp.lpname].isFlag) { // 非标记班次  
508 - oGroupGanttNormalBc = this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal;  
509 -  
510 - // 获取吃饭班次  
511 - oGroupGanttEatBc = null;  
512 - if (this._aLpGroupCfGanttBc.length > 0) {  
513 - if (this._aLpGroupCfGanttBc[0].lpName == oExcelLp.lpname) {  
514 - if (this._oParam.toTimeObj(this._aLpGroupCfGanttBc[0].fcsj).isBefore(  
515 - this._oParam.toTimeObj(oGroupGanttNormalBc.fcsj))) {  
516 - oGroupGanttEatBc = this._aLpGroupCfGanttBc.shift();  
517 - }  
518 - }  
519 - }  
520 -  
521 - oExcelLp.bcObjList.push({  
522 - "bcsj": oGroupGanttNormalBc.bcsj, // 班次时间  
523 - "ssj": oGroupGanttNormalBc.STOPTIME, // 停站时间  
524 - "eatsj": oGroupGanttEatBc ? oGroupGanttEatBc.bcsj : 0, // 吃饭时间  
525 -  
526 - "tccid": oGroupGanttNormalBc.tcc, // 停车场id  
527 - "qdzid": oGroupGanttNormalBc.qdz, // 起点站id  
528 - "zdzid": oGroupGanttNormalBc.zdz, // 终点站id  
529 -  
530 - "isUp": bIsUp, // 是否上行  
531 -  
532 - "bcType": oGroupGanttNormalBc.bcType, // 班次类型  
533 - "fcsj": oGroupGanttEatBc ?  
534 - ("*" + oGroupGanttNormalBc.fcsj) :  
535 - oGroupGanttNormalBc.fcsj, // 发车时间描述  
536 - "fcsjDesc": oGroupGanttEatBc ?  
537 - ("(吃" + oGroupGanttNormalBc.fcsj + ")") :  
538 - oGroupGanttNormalBc.fcsj, // 发车时间描述2  
539 -  
540 - "groupNo": bIsUp ? this._iUpGroupIndex : this._iDownGroupIndex, // 第几圈  
541 - "groupBcNo": bIsUp == this._bQIsUp ? 0 : 1, // 圈里第几个班次  
542 -  
543 - "_bclc": oGroupGanttNormalBc.jhlc // 班次里程(最后需要删除)  
544 -  
545 - });  
546 -  
547 - oExcelLp._bcObjGroupList.push({  
548 - fcsj: oGroupGanttNormalBc.fcsj, // 发车时间  
549 - groupIndex: bIsUp ? this._iUpGroupIndex : this._iDownGroupIndex, // 第几圈  
550 - bcIndex: bIsUp == this._bQIsUp ? 0 : 1 // 圈里第几个班次  
551 - });  
552 - }  
553 - }  
554 - }  
555 -  
556 - if (bIsUp) {  
557 - this._iUpGroupIndex ++;  
558 - } else {  
559 - this._iDownGroupIndex ++;  
560 - }  
561 - this._oLpGroupNormalGanttBc = {};  
562 - };  
563 -  
564 - // 添加报到,出场,进场,离场班次  
565 - InternalCalcuExcelBc1.prototype._addBdOutInLcBc = function(oGanttBc, bIsUp) {  
566 - var i;  
567 - var oExcelLp;  
568 - var bcType;  
569 - for (i = 0; i < this._aExcelLp.length; i++) {  
570 - oExcelLp = this._aExcelLp[i];  
571 - if (oGanttBc.lpName == oExcelLp.lpname) {  
572 - bcType = oGanttBc.bcType;  
573 - if (bcType == "bd" || bcType == "out" || bcType == "in" || bcType == "lc") {  
574 - oExcelLp.bcObjList.push({  
575 - "bcsj": oGanttBc.bcsj, // 班次时间  
576 - "ssj": oGanttBc.STOPTIME, // 停站时间  
577 - "eatsj": 0, // 吃饭时间  
578 -  
579 - "tccid": oGanttBc.tcc, // 停车场id  
580 - "qdzid": oGanttBc.qdz, // 起点站id  
581 - "zdzid": oGanttBc.zdz, // 终点站id  
582 -  
583 - "isUp": bIsUp, // 是否上行  
584 - "isFb": null, // 是否分班(_resetBdOutInLcBcGroup方法修正)  
585 -  
586 - "bcType": oGanttBc.bcType, // 班次类型(bc、out、in、lc)  
587 - "fcsj": oGanttBc.fcsj, // 发车时间描述  
588 -  
589 - "groupNo": -99, // 第几圈(_resetBdOutInLcBcGroup方法修正)  
590 - "groupBcNo": -99, // 圈里第几个班次(_resetBdOutInLcBcGroup方法修正)  
591 -  
592 - "_bclc": oGanttBc.jhlc // 班次里程(最后需要删除)  
593 - });  
594 - break;  
595 - }  
596 - }  
597 - }  
598 -  
599 - };  
600 - // 重新计算报到,出场,进场,离场班次的圈索引及班次索引  
601 - InternalCalcuExcelBc1.prototype._resetBdOutInLcBcGroup = function() {  
602 - var i;  
603 - var j;  
604 - var k;  
605 - var sFcsjDesc = [];  
606 - var oExcelLp;  
607 - var oLpBc;  
608 -  
609 - // {"bd":到场班次index,"out":出场班次index, "nextBc": 出场后第一个normal班次索引, "nextBcGroup":出场后第一个normal班次group索引}  
610 - var oBdOutLpBc = {};  
611 - // 到场出场班次组合数组  
612 - var aBdOutLpBc = [];  
613 -  
614 - // {"in":进场班次index,"lc":离场班次index, "preBc": 进场前一个normal班次索引, "preBcGroup":进场前一个normal班次group索引}  
615 - var oInLcLpBc = {};  
616 - // 进场离场班次组合数组  
617 - var aInLcLpBc = [];  
618 -  
619 - for (i = 0; i < this._aExcelLp.length; i++) {  
620 - oExcelLp = this._aExcelLp[i];  
621 -  
622 - // 排序oExcelLp班次列表  
623 - this._fnSortBc(oExcelLp.bcObjList);  
624 -  
625 - aBdOutLpBc = [];  
626 - aInLcLpBc = [];  
627 -  
628 - for (j = 0; j < oExcelLp.bcObjList.length; j++) {  
629 - oLpBc = oExcelLp.bcObjList[j];  
630 -  
631 - if (oLpBc.bcType == "out") { // 出场班次  
632 - oBdOutLpBc = {"bd": null, "out": null, "nextBc": null, "nextBcGroup": null};  
633 - oBdOutLpBc["out"] = j;  
634 - // 查找上一个班次是否是报到班次(不存在有可能,中间分班班次可能没有报到时间)  
635 - if ((j - 1) >= 0 && (j - 1) < oExcelLp.bcObjList.length) {  
636 - if (oExcelLp.bcObjList[j - 1].bcType == "bd") {  
637 - oBdOutLpBc["bd"] = j - 1;  
638 - }  
639 - }  
640 - // 查找下一个班次是否是normal班次(不存在或者不是normal班次,这个报到出场班次组合忽略)  
641 - if ((j + 1) < oExcelLp.bcObjList.length) {  
642 - if (oExcelLp.bcObjList[j + 1].bcType == "normal") {  
643 - for (k = 0; k < oExcelLp._bcObjGroupList.length; k++) {  
644 - if (oExcelLp.bcObjList[j + 1].fcsj == oExcelLp._bcObjGroupList[k].fcsj) {  
645 - oBdOutLpBc["nextBc"] = j + 1;  
646 - oBdOutLpBc["nextBcGroup"] = k;  
647 - aBdOutLpBc.push(oBdOutLpBc);  
648 - break;  
649 - }  
650 - }  
651 - }  
652 - }  
653 - } else if (oLpBc.bcType == "in") { // 进场班次  
654 - oInLcLpBc = {"in": null, "lc": null, "preBc": null, "preBcGroup": null};  
655 - oInLcLpBc["in"] = j;  
656 - // 查找系一个班次是否是离场班次(不存在有可能,中间分班班次可能没有离场时间)  
657 - if ((j + 1) < oExcelLp.bcObjList.length) {  
658 - if (oExcelLp.bcObjList[j + 1].bcType == "lc") {  
659 - oInLcLpBc["lc"] = j + 1;  
660 - }  
661 - }  
662 - // 查找上一个班次是否是normal班次(不存在或者不是normal班次,这个进场离场班次组合忽略)  
663 - if ((j - 1) >= 0 && (j - 1) < oExcelLp.bcObjList.length) {  
664 - if (oExcelLp.bcObjList[j - 1].bcType == "normal") {  
665 - for (k = 0; k < oExcelLp._bcObjGroupList.length; k++) {  
666 - if (oExcelLp.bcObjList[j - 1].fcsj == oExcelLp._bcObjGroupList[k].fcsj) {  
667 - oInLcLpBc["preBc"] = j - 1;  
668 - oInLcLpBc["preBcGroup"] = k;  
669 - aInLcLpBc.push(oInLcLpBc);  
670 - break;  
671 - }  
672 - }  
673 - }  
674 - }  
675 -  
676 - }  
677 -  
678 - }  
679 -  
680 - if (aBdOutLpBc.length == 2) { // 分班(以出场班次为主)  
681 - // 处理第一个出场  
682 - sFcsjDesc = [];  
683 - oBdOutLpBc = aBdOutLpBc[0];  
684 - if (oBdOutLpBc.bd != null) {  
685 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.bd];  
686 - oLpBc.isFb = false;  
687 - oLpBc.groupNo = -1;  
688 - oLpBc.groupBcNo = -1;  
689 - sFcsjDesc.push("(到" + oLpBc.fcsj + ")");  
690 - }  
691 -  
692 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.out];  
693 - oLpBc.isFb = false;  
694 - oLpBc.groupNo = -1;  
695 - oLpBc.groupBcNo = -2;  
696 - sFcsjDesc.push("(出" + oLpBc.fcsj + ")");  
697 -  
698 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.nextBc];  
699 - sFcsjDesc.push("(" + oLpBc.fcsj + ")");  
700 - oLpBc.fcsjDesc = sFcsjDesc.join("");  
701 -  
702 - // 处理第二个出场  
703 - sFcsjDesc = [];  
704 - oBdOutLpBc = aBdOutLpBc[1];  
705 - if (oBdOutLpBc.bd != null) {  
706 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.bd];  
707 - oLpBc.isFb = true;  
708 - oLpBc.groupNo = oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].groupIndex - 1;  
709 - oLpBc.groupBcNo = oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].bcIndex;  
710 - sFcsjDesc.push("(到" + oLpBc.fcsj + ")");  
711 - }  
712 -  
713 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.out];  
714 - oLpBc.isFb = true;  
715 - oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].bcIndex == 0) ?  
716 - (oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].groupIndex - 1) :  
717 - oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].groupIndex);  
718 - oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].bcIndex == 0) ? 1 : 0);  
719 - sFcsjDesc.push("(出" + oLpBc.fcsj + ")");  
720 -  
721 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.nextBc];  
722 - sFcsjDesc.push("(" + oLpBc.fcsj + ")");  
723 - oLpBc.fcsjDesc = sFcsjDesc.join("");  
724 -  
725 - // 2个以上进场班次,处理第一个和第二个,第一个做为中间进场  
726 - if (aInLcLpBc.length >= 2) {  
727 - sFcsjDesc = [];  
728 - oInLcLpBc = aInLcLpBc[0];  
729 -  
730 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];  
731 - sFcsjDesc.push("(" + oLpBc.fcsj + ")");  
732 -  
733 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];  
734 - oLpBc.isFb = true;  
735 - oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?  
736 - oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :  
737 - (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));  
738 - oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);  
739 - sFcsjDesc.push("(进" + oLpBc.fcsj + ")");  
740 -  
741 - oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");  
742 -  
743 - sFcsjDesc = [];  
744 - oInLcLpBc = aInLcLpBc[1];  
745 -  
746 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];  
747 - sFcsjDesc.push("(" + oLpBc.fcsj + ")");  
748 -  
749 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];  
750 - oLpBc.isFb = false;  
751 - oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?  
752 - oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :  
753 - (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));  
754 - oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);  
755 - sFcsjDesc.push("(进" + oLpBc.fcsj + ")");  
756 -  
757 - if (oInLcLpBc.lc) {  
758 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.lc];  
759 - oLpBc.isFb = false;  
760 - oLpBc.groupNo = -2;  
761 - oLpBc.groupBcNo = -4;  
762 - sFcsjDesc.push("(离" + oLpBc.fcsj + ")");  
763 - }  
764 - oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");  
765 - }  
766 -  
767 - // 一个进场班次,做为最后一个进场班次处理  
768 - if (aInLcLpBc.length == 1) {  
769 - sFcsjDesc = [];  
770 - oInLcLpBc = aInLcLpBc[0];  
771 -  
772 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];  
773 - sFcsjDesc.push("(" + oLpBc.fcsj + ")");  
774 -  
775 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];  
776 - oLpBc.isFb = false;  
777 - oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?  
778 - oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :  
779 - (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));  
780 - oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);  
781 - sFcsjDesc.push("(进" + oLpBc.fcsj + ")");  
782 -  
783 - if (oInLcLpBc.lc) {  
784 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.lc];  
785 - oLpBc.isFb = false;  
786 - oLpBc.groupNo = -2;  
787 - oLpBc.groupBcNo = -4;  
788 - sFcsjDesc.push("(离" + oLpBc.fcsj + ")");  
789 - }  
790 - oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");  
791 - }  
792 -  
793 -  
794 - } else if (aBdOutLpBc.length == 1) {  
795 - // 处理出场  
796 - sFcsjDesc = [];  
797 - oBdOutLpBc = aBdOutLpBc[0];  
798 - if (oBdOutLpBc.bd != null) {  
799 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.bd];  
800 - oLpBc.isFb = false;  
801 - oLpBc.groupNo = -1;  
802 - oLpBc.groupBcNo = -1;  
803 - sFcsjDesc.push("(到" + oLpBc.fcsj + ")");  
804 - }  
805 -  
806 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.out];  
807 - oLpBc.isFb = false;  
808 - oLpBc.groupNo = -1;  
809 - oLpBc.groupBcNo = -2;  
810 - sFcsjDesc.push("(出" + oLpBc.fcsj + ")");  
811 -  
812 - oLpBc = oExcelLp.bcObjList[oBdOutLpBc.nextBc];  
813 - sFcsjDesc.push("(" + oLpBc.fcsj + ")");  
814 - oLpBc.fcsjDesc = sFcsjDesc.join("");  
815 -  
816 - // 处理进场  
817 - if (aInLcLpBc.length > 0) {  
818 - sFcsjDesc = [];  
819 - oInLcLpBc = aInLcLpBc[0];  
820 -  
821 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];  
822 - sFcsjDesc.push("(" + oLpBc.fcsj + ")");  
823 -  
824 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];  
825 - oLpBc.isFb = false;  
826 - oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?  
827 - oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :  
828 - (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));  
829 - oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);  
830 - sFcsjDesc.push("(进" + oLpBc.fcsj + ")");  
831 -  
832 - if (oInLcLpBc.lc) {  
833 - oLpBc = oExcelLp.bcObjList[oInLcLpBc.lc];  
834 - oLpBc.isFb = false;  
835 - oLpBc.groupNo = -2;  
836 - oLpBc.groupBcNo = -4;  
837 - sFcsjDesc.push("(离" + oLpBc.fcsj + ")");  
838 - }  
839 - oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");  
840 -  
841 - }  
842 -  
843 - }  
844 -  
845 - // console.log("todo");  
846 -  
847 -  
848 - }  
849 -  
850 - // console.log("ddd");  
851 -  
852 - };  
853 -  
854 - // 判定当前圈是否是有分班后的第一个normal班次  
855 - InternalCalcuExcelBc1.prototype._fnIsFBcQ = function(bIsUp) {  
856 - var oExcelLp;  
857 - var i;  
858 - var oLpPreExcelBc;  
859 - var oLpCurGranttBc;  
860 - var oPreBcFcsj;  
861 - var oCurBcFcsj;  
862 - var idiffTime;  
863 - var bFbFlag = false;  
864 - for (i = 0; i < this._aExcelLp.length; i++) {  
865 - oExcelLp = this._aExcelLp[i];  
866 - if (oExcelLp.bcObjList.length > 0) {  
867 - oLpPreExcelBc = oExcelLp.bcObjList[oExcelLp.bcObjList.length - 1];  
868 - if (oLpPreExcelBc.bcType == "normal") {  
869 - oPreBcFcsj = this._oParam.toTimeObj(  
870 - oLpPreExcelBc.fcsj.indexOf("*") >= 0 ? oLpPreExcelBc.fcsj.substr(1) : oLpPreExcelBc.fcsj  
871 - );  
872 - if (this._oLpGroupNormalGanttBc[oExcelLp.lpname]) {  
873 - oLpCurGranttBc = this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal;  
874 - if (oLpCurGranttBc) {  
875 - oCurBcFcsj = this._oParam.toTimeObj(oLpCurGranttBc.fcsj);  
876 - idiffTime = oCurBcFcsj.diff(oPreBcFcsj, "m");  
877 - if (idiffTime > oLpPreExcelBc.bcsj * 3) {  
878 - bFbFlag = true;  
879 - break;  
880 - }  
881 - }  
882 - }  
883 - }  
884 - }  
885 -  
886 - }  
887 -  
888 - return bFbFlag;  
889 -  
890 - };  
891 -  
892 - /**  
893 - * 内部Excel对象。  
894 - * @param oParam 参数对象  
895 - * @param fnGetGanttBcArray 返回gantt用的班次列表  
896 - * @constructor  
897 - */  
898 - function InternalExcelObj(oParam, fnGetGanttBcArray) {  
899 - // 参数对象  
900 - this._oParam = oParam;  
901 - // 获取gantt班次的方法  
902 - this._fnBc = fnGetGanttBcArray;  
903 -  
904 - // 每一圈是上行开始还是下行开始  
905 - this._qIsUp = oParam.getUpFirstDTimeObj().diff(oParam.getDownFirstDTimeObj()) <= 0 ? false : true;  
906 -  
907 - }  
908 -  
909 - // html5导出excel方法  
910 - InternalExcelObj.prototype.downloadFile = function(data, mimeType, fileName) {  
911 - _fnDownloadFile(data, mimeType, fileName);  
912 - };  
913 - /**  
914 - * 获取班次统计数据。  
915 - */  
916 - InternalExcelObj.prototype.fnGetStatInfoList = function() {  
917 - return _fnCalcuExportStatInfo_sheet(this._fnBc(), this._oParam);  
918 - };  
919 - /**  
920 - * 获取参数数据。  
921 - */  
922 - InternalExcelObj.prototype.fnGetParamInfoList = function() {  
923 - return _fnCalcuExportParam_sheet(this._oParam);  
924 - };  
925 - /**  
926 - * 获取路牌班次数据。  
927 - * @return {*}  
928 - */  
929 - InternalExcelObj.prototype.fnGetLpBcInfoList = function() {  
930 - // 构造显示用lp对象  
931 - var oTempLpFlag = {};  
932 - var aGanttBc = this._fnBc();  
933 - var oGanttBc;  
934 - var aLp = [];  
935 - var oLp;  
936 - var i;  
937 - for (i = 0; i < aGanttBc.length; i++) {  
938 - oGanttBc = aGanttBc[i];  
939 - if (oTempLpFlag[oGanttBc.lpName]) {  
940 - // 已经存在路牌,不处理  
941 - continue;  
942 - }  
943 -  
944 - oLp = {  
945 - "lpname": oGanttBc.lpName, // 路牌名字  
946 - "isUp": this._qIsUp, // 每圈的第一个班次是否上行  
947 - "bcObjList": [], // 内部班次列表(后面计算班次列表)  
948 - "_bcObjGroupList": [], // 每个normal班次对应的group对象 {fcsj: 发车时间, groupIndex: 圈索引, bcIndex: 班次索引},最后返回要删除  
949 - "groupCount": 0, // 总圈数(后面计算总圈数)  
950 - "zlc": 0, // 总里程  
951 - "yylc": 0, // 营运里程  
952 - "kslc": 0, // 空驶里程  
953 - "zgs": 0, // 总工时  
954 - "zbc": 0, // 总班次  
955 - "yygs": 0, // 营运工时  
956 - "yybc": 0, // 营运班次  
957 - "stationRouteId1": 0, // 第一个班次起点站路由id  
958 - "stationRouteId2": 0 // 第二个班次起点站路由id  
959 - };  
960 - oTempLpFlag[oGanttBc.lpName] = {"flag" : true}; // 标记一下  
961 - aLp.push(oLp);  
962 - }  
963 -  
964 - // 计算Excel班次  
965 - var _celb = new InternalCalcuExcelBc1(aLp, aGanttBc, this._oParam, this._qIsUp);  
966 - return _celb.fnGenerateExcelLpBcList();  
967 - };  
968 -  
969 - return InternalExcelObj;  
970 - 1 +/**
  2 + * v2_2版本时刻表excel对象。
  3 + */
  4 +var Main_v2_2_ExcelObj = (function() {
  5 + // html5导出下载文件方法
  6 + var _fnDownloadFile = function(data, mimeType, fileName) {
  7 + var success = false;
  8 + var blob = new Blob([data], { type: mimeType });
  9 + try {
  10 + if (navigator.msSaveBlob)
  11 + navigator.msSaveBlob(blob, fileName);
  12 + else {
  13 + // Try using other saveBlob implementations, if available
  14 + var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
  15 + if (saveBlob === undefined) throw "Not supported";
  16 + saveBlob(blob, fileName);
  17 + }
  18 + success = true;
  19 + } catch (ex) {
  20 + console.log("saveBlob method failed with the following exception:");
  21 + console.log(ex);
  22 + }
  23 +
  24 + if (!success) {
  25 + // Get the blob url creator
  26 + var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
  27 + if (urlCreator) {
  28 + // Try to use a download link
  29 + var link = document.createElement('a');
  30 + if ('download' in link) {
  31 + // Try to simulate a click
  32 + try {
  33 + // Prepare a blob URL
  34 + var url = urlCreator.createObjectURL(blob);
  35 + link.setAttribute('href', url);
  36 +
  37 + // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
  38 + link.setAttribute("download", fileName);
  39 +
  40 + // Simulate clicking the download link
  41 + var event = document.createEvent('MouseEvents');
  42 + event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
  43 + link.dispatchEvent(event);
  44 + success = true;
  45 +
  46 + } catch (ex) {
  47 + console.log("Download link method with simulated click failed with the following exception:");
  48 + console.log(ex);
  49 + }
  50 + }
  51 +
  52 + if (!success) {
  53 + // Fallback to window.location method
  54 + try {
  55 + // Prepare a blob URL
  56 + // Use application/octet-stream when using window.location to force download
  57 + var url = urlCreator.createObjectURL(blob);
  58 + window.location = url;
  59 + console.log("Download link method with window.location succeeded");
  60 + success = true;
  61 + } catch (ex) {
  62 + console.log("Download link method with window.location failed with the following exception:");
  63 + console.log(ex);
  64 + }
  65 + }
  66 + }
  67 + }
  68 +
  69 + if (!success) {
  70 + // Fallback to window.open method
  71 + console.log("No methods worked for saving the arraybuffer, using last resort window.open");
  72 + window.open("", '_blank', '');
  73 + }
  74 + };
  75 +
  76 + // 计算导出参数sheet数据。
  77 + var _fnCalcuExportParam_sheet = function(_paramObj) {
  78 + return [
  79 + {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")},
  80 + {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")},
  81 + {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")},
  82 + {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")},
  83 + {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")},
  84 + {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")},
  85 + {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")},
  86 + {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")},
  87 + {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()},
  88 + {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()},
  89 + {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()},
  90 + {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()},
  91 + {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()},
  92 + {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()},
  93 + {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()},
  94 + {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()},
  95 + {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()},
  96 + {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()},
  97 + {'paramItem' : '线路规划类型', 'paramValue' : "双向"},
  98 + {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"},
  99 + {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()},
  100 + {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()},
  101 + {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()},
  102 + {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()},
  103 + {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"},
  104 + {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"},
  105 + {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"},
  106 + {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()},
  107 + {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") },
  108 + {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()}
  109 + ]
  110 + };
  111 +
  112 + // 计算班次统计数据sheet数据。
  113 + var _fnCalcuExportStatInfo_sheet = function(aBc, oParam) {
  114 + var countBc = 0, // 总班次
  115 + serviceBc = 0, // 营运班次
  116 + jcbc = 0, // 进场总班次.
  117 + ccbc = 0, // 出场总班次.
  118 + cfbc = 0, // 吃饭总班次.
  119 + zwlbbc = 0, // 早晚例保总班次.
  120 + countGs = 0.0, // 总工时
  121 + servicesj = 0, // 营运班次总时间
  122 + jcsj = 0.0, // 进场总时间.
  123 + ccsj = 0.0, // 出场总时间.
  124 + cfsj = 0.0, // 吃饭总时间.
  125 + zwlbsj = 0.0, // 早晚例保总时间.
  126 + ksBc = 0, // 空驶班次
  127 + serviceLc = 0.0, // 营运里程
  128 + ksLc = 0.0, // 空驶里程
  129 + avgTzjx = 0.0, // 平均停站间隙
  130 + gfServiceBc = 0, // 高峰营运班次
  131 + dgServiceBc = 0, // 低谷营运班次
  132 + gfAvgTzjx = 0.0, // 高峰平均停站间隙
  133 + dgAvgTzjx = 0.0; // 低谷平均停站间隙
  134 +
  135 + var i;
  136 + var oBc;
  137 + for (i = 0; i < aBc.length; i++) {
  138 + oBc = aBc[i];
  139 +
  140 + if (oBc.bcsj > 0) {
  141 + countBc = countBc + 1;
  142 + countGs = countGs + oBc.STOPTIME + oBc.bcsj;
  143 + if (oParam.isTroughBc(oParam.toTimeObj(oBc.fcsj))) {
  144 + if (oBc.bcType == "normal") {
  145 + dgServiceBc = dgServiceBc + 1;
  146 + dgAvgTzjx = dgAvgTzjx + oBc.STOPTIME;
  147 + }
  148 + } else {
  149 + if (oBc.bcType == "normal") {
  150 + gfServiceBc = gfServiceBc + 1;
  151 + gfAvgTzjx = gfAvgTzjx + oBc.STOPTIME;
  152 + }
  153 + }
  154 +
  155 + if (oBc.bcType == "normal" || oBc.bcType == "cf") {
  156 + serviceBc = serviceBc + 1;
  157 + serviceLc = serviceLc + oBc.jhlc;
  158 + servicesj = servicesj + oBc.bcsj;
  159 + avgTzjx = avgTzjx + oBc.STOPTIME;
  160 +
  161 + if (oBc.bcType == "cf") {
  162 + cfbc = cfbc + 1;
  163 + cfsj = cfsj + oBc.bcsj;
  164 + }
  165 + } else if (oBc.bcType == "in") {
  166 + jcbc = jcbc + 1;
  167 + jcsj = jcsj + oBc.bcsj;
  168 + } else if (oBc.bcType == "out") {
  169 + ccbc = ccbc + 1;
  170 + ccsj = ccsj + oBc.bcsj;
  171 + } else if (oBc.bcType == "bd") {
  172 + zwlbbc = zwlbbc + 1;
  173 + zwlbsj = zwlbsj + oBc.bcsj;
  174 + } else if (oBc.bcType == "lc") {
  175 + zwlbbc = zwlbbc + 1;
  176 + zwlbsj = zwlbsj + oBc.bcsj;
  177 + }
  178 + }
  179 + }
  180 +
  181 + dgAvgTzjx = dgAvgTzjx / dgServiceBc;
  182 + gfAvgTzjx = gfAvgTzjx / gfServiceBc;
  183 + avgTzjx = avgTzjx / dgServiceBc;
  184 +
  185 + return [
  186 + {'statItem': '总班次(包括进出场、吃饭时间、早晚例保、营运且班次时间大于零的班次)', 'statValue': countBc},
  187 + {'statItem': '进场总班次(包括进场且班次时间大于零的班次)', 'statValue': jcbc},
  188 + {'statItem': '出场总班次(包括进场且班次时间大于零的班次)', 'statValue': ccbc},
  189 + {'statItem': '吃饭总班次(包括吃饭且班次时间大于零的班次)', 'statValue': cfbc},
  190 + {'statItem': '早晚例保总班次(包括早晚例保且时间大于零的班次)', 'statValue': zwlbbc},
  191 + {'statItem': '营运总班次(包括正常、区间、放大站且班次时间大于零班次)','statValue': serviceBc},
  192 + {'statItem': '进场总时间(包括进场班次且班次时间大于零)', 'statValue': jcsj/60},
  193 + {'statItem': '出场总时间(包括进场班次且班次时间大于零)', 'statValue': ccsj/60},
  194 + {'statItem': '吃饭总时间(包括吃饭班次且班次时间大于零)', 'statValue': cfsj/60},
  195 + {'statItem': '早晚例保总时间(包括早晚例保班次且时间大于零的)', 'statValue': zwlbsj/60},
  196 + {'statItem': '营运班次总时间(包括正常、区间、放大站且班次时间大于零)', 'statValue': servicesj/60},
  197 + {'statItem': '总工时(包括进出场、吃饭时间、早晚例保、营运班次时间)', 'statValue': countGs/60},
  198 + {'statItem': '空驶班次(包括直放班次)', 'statValue': ksBc},
  199 + {'statItem': '营运里程(包括正常、区间、放大站里程)', 'statValue': serviceLc},
  200 + {'statItem': '空驶里程(包括直放里程)', 'statValue': ksLc},
  201 + {'statItem': '平均停站时间(营运班次停站时间总和/营运总班次)', 'statValue': avgTzjx},
  202 + {'statItem': '高峰营运班次(包括早晚高峰时段的正常、区间、放大站班次)', 'statValue': gfServiceBc},
  203 + {'statItem': '低谷营运班次(包括低谷时段的正常、区间、放大站班次)', 'statValue': dgServiceBc},
  204 + {'statItem': '高峰平均停站间隙(高峰营运班次停站时间总和/高峰营运班次总和)', 'statValue': gfAvgTzjx},
  205 + {'statItem': '低谷平均停站间隙(低谷营运班次停站时间总和/低谷营运班次总和)', 'statValue': dgAvgTzjx},
  206 + {'statItem': '综合评估', 'statValue': 3}
  207 + ];
  208 +
  209 + };
  210 +
  211 + /**
  212 + * 内部计算Excel班次方法1,
  213 + * 这里是假设班次按照从早到晚排序,并且路牌也是从小到大排序。
  214 + * @param aExcelLp excel显示用路牌
  215 + * @param aGanttBc 甘特图班次列表
  216 + * @param oParam 参数对象
  217 + * @param bQIsUp 每一圈是上行开始还是下行开始
  218 + * @private
  219 + */
  220 + function InternalCalcuExcelBc1(aExcelLp, aGanttBc, oParam, bQIsUp) {
  221 + this._aExcelLp = aExcelLp;
  222 + this._oParam = oParam;
  223 + this._bQIsUp = bQIsUp;
  224 +
  225 + this._iUpGroupIndex = 0;
  226 + this._iDownGroupIndex = 0;
  227 +
  228 + // {"路牌名字":{"isFlag": 是否为标记班次(表示扫描过但是没有班次对象),"normal":正常班次}}
  229 + this._oLpGroupNormalGanttBc = {};
  230 + // [吃饭类型班次]
  231 + this._aLpGroupCfGanttBc = [];
  232 +
  233 + // TODO:其他类型的班次再议
  234 +
  235 + // 计算上行gantt班次列表,下行gantt班次列表,并排序
  236 + var i;
  237 + var oGanttBc;
  238 + this._aUpGanttBc = [];
  239 + this._aDownGanttBc = [];
  240 + for (i = 0; i < aGanttBc.length; i++) {
  241 + oGanttBc = aGanttBc[i];
  242 + if (oGanttBc.xlDir == "relationshipGraph-up") {
  243 + this._aUpGanttBc.push(oGanttBc);
  244 + } else {
  245 + this._aDownGanttBc.push(oGanttBc);
  246 + }
  247 + }
  248 + // 排序班次
  249 + this._fnSortBc(this._aUpGanttBc);
  250 + this._fnSortBc(this._aDownGanttBc);
  251 +
  252 + if (this._aUpGanttBc.length == 0) {
  253 + throw "没有上行班次,不能导出数据!";
  254 + }
  255 + if (this._aDownGanttBc.length == 0) {
  256 + throw "没有下行班次,不能导出数据!"
  257 + }
  258 +
  259 + }
  260 +
  261 + //----------------------- 外部方法 -----------------------//
  262 + InternalCalcuExcelBc1.prototype.fnGenerateExcelLpBcList = function() {
  263 + // 计算Excel班次
  264 + this._calcuExcelBc();
  265 +
  266 + // 设置路牌圈数
  267 + var iGroupCount = this._iUpGroupIndex > this._iDownGroupIndex ?
  268 + (this._iUpGroupIndex + 1) : (this._iDownGroupIndex + 1);
  269 +
  270 + // 设置路由id
  271 + var oUpNormalBc;
  272 + var oDownNormalBc;
  273 + var i;
  274 + for (i = 0; i < this._aUpGanttBc.length; i++) {
  275 + if (this._aUpGanttBc[i].bcType == "normal") {
  276 + oUpNormalBc = this._aUpGanttBc[i];
  277 + break;
  278 + }
  279 + }
  280 + for (i = 0; i < this._aDownGanttBc.length; i++) {
  281 + if (this._aDownGanttBc[i].bcType == "normal") {
  282 + oDownNormalBc = this._aDownGanttBc[i];
  283 + break;
  284 + }
  285 + }
  286 +
  287 + var stationRouteId1;
  288 + var stationRouteId2;
  289 + if (this._bQIsUp) {
  290 + stationRouteId1 = oUpNormalBc.qdz;
  291 + stationRouteId2 = oDownNormalBc.qdz;
  292 + } else {
  293 + stationRouteId1 = oDownNormalBc.qdz;
  294 + stationRouteId2 = oUpNormalBc.qdz;
  295 + }
  296 +
  297 + var oExcelLp;
  298 + for (i = 0; i < this._aExcelLp.length; i++) {
  299 + oExcelLp = this._aExcelLp[i];
  300 + oExcelLp.groupCount = iGroupCount;
  301 + oExcelLp.stationRouteId1 = stationRouteId1;
  302 + oExcelLp.stationRouteId2 = stationRouteId2;
  303 +
  304 + // 删除临时参数
  305 + delete oExcelLp["_bcObjGroupList"];
  306 + }
  307 +
  308 + // 路牌数据统计
  309 + var j = 0;
  310 + var aLpBc;
  311 + var oLpBc;
  312 + for (i = 0; i < this._aExcelLp.length; i++) {
  313 + oExcelLp = this._aExcelLp[i];
  314 + aLpBc = oExcelLp.bcObjList;
  315 + for (j = 0; j < aLpBc.length; j++) {
  316 + oLpBc = aLpBc[j];
  317 + if (oLpBc.bcType == "normal") {
  318 + oExcelLp.zlc = oExcelLp.zlc +
  319 + oLpBc._bclc; // 总里程
  320 + oExcelLp.yylc = oExcelLp.yylc +
  321 + oLpBc._bclc; // 营运里程
  322 + oExcelLp.yygs = oExcelLp.yygs +
  323 + oLpBc.bcsj + // 班次时间
  324 + oLpBc.ssj + // 停站时间
  325 + oLpBc.eatsj; // 吃饭时间
  326 + oExcelLp.yybc = oExcelLp.yybc + 1;
  327 +
  328 + oExcelLp.zgs = oExcelLp.zgs +
  329 + oLpBc.bcsj + // 班次时间
  330 + oLpBc.ssj + // 停站时间
  331 + oLpBc.eatsj; // 吃饭时间
  332 + oExcelLp.zbc = oExcelLp.zbc + 1;
  333 + } else if (
  334 + oLpBc.bcType == "bd" ||
  335 + oLpBc.bcType == "out" ||
  336 + oLpBc.bcType == "in" ||
  337 + oLpBc.bcType == "lc") {
  338 + oExcelLp.kslc = oExcelLp.kslc +
  339 + oLpBc._bclc; // 里程
  340 + oExcelLp.zlc = oExcelLp.zlc +
  341 + oLpBc._bclc; // 里程
  342 + oExcelLp.zgs = oExcelLp.zgs +
  343 + oLpBc.bcsj + // 班次时间
  344 + oLpBc.ssj; // 停站时间
  345 +
  346 + if (oLpBc.bcType != "bd" && oLpBc.bcType != "lc") {
  347 + oExcelLp.zbc = oExcelLp.zbc + 1;
  348 + }
  349 +
  350 + }
  351 +
  352 + delete oLpBc._bclc; // 删除临时变量
  353 +
  354 + }
  355 + }
  356 +
  357 +
  358 +
  359 + return this._aExcelLp;
  360 + };
  361 +
  362 + //----------------------- 内部方法 ------------------------//
  363 + // 排序班次
  364 + InternalCalcuExcelBc1.prototype._fnSortBc = function(aGanttBc) {
  365 + var oParam = this._oParam;
  366 + aGanttBc.sort(function (o1, o2) { // 时间从早到晚排序
  367 + var o1_fcsj;
  368 + var o2_fcsj;
  369 + if (o1.fcsj.indexOf("00:") >= 0) { // 大于00点是第二天
  370 + o1_fcsj = oParam.toTimeObj(o1.fcsj).add(1, "d");
  371 + } else {
  372 + o1_fcsj = oParam.toTimeObj(o1.fcsj);
  373 + }
  374 +
  375 + if (o2.fcsj.indexOf("00:") >= 0) { // 大于00点是第二天
  376 + o2_fcsj = oParam.toTimeObj(o2.fcsj).add(1, "d");
  377 + } else {
  378 + o2_fcsj = oParam.toTimeObj(o2.fcsj);
  379 + }
  380 +
  381 +
  382 + if (o1_fcsj.isBefore(o2_fcsj)) {
  383 + return -1;
  384 + } else {
  385 + return 1;
  386 + }
  387 + });
  388 + // 此处假设班次按照从早倒晚排,每一圈按照路牌顺序排
  389 +
  390 + // TODO:如果发生同一圈路牌交叉发车,不是按照路牌排序的,导出时有问题,再议
  391 + };
  392 +
  393 + InternalCalcuExcelBc1.prototype._calcuExcelBc = function() {
  394 + var i = 0;
  395 + var j = 0;
  396 +
  397 + var aUpBc;
  398 + var aDownBc;
  399 + if (this._bQIsUp) {
  400 + aUpBc = this._aUpGanttBc;
  401 + aDownBc = this._aDownGanttBc;
  402 + } else {
  403 + aUpBc = this._aDownGanttBc;
  404 + aDownBc = this._aUpGanttBc;
  405 + }
  406 +
  407 + do {
  408 + i = this._calcuExcelBcPerGroup(this._bQIsUp, i);
  409 + j = this._calcuExcelBcPerGroup(!this._bQIsUp, j);
  410 + } while(i < aUpBc.length || j < aDownBc.length);
  411 +
  412 + // 重新计算报到,出场,进场,离场班次的圈,班次索引
  413 + this._resetBdOutInLcBcGroup();
  414 +
  415 + };
  416 +
  417 + /**
  418 + * 重新计算Excel显示班次(计算1圈)。
  419 + * @param bIsUp 是否上行
  420 + * @param iBcIndex 班次索引
  421 + * @return 下一次计算索引
  422 + */
  423 + InternalCalcuExcelBc1.prototype._calcuExcelBcPerGroup = function(bIsUp, iBcIndex) {
  424 + this._oLpGroupNormalGanttBc = {};
  425 +
  426 + var i;
  427 + var j = 0;
  428 + var oExcelLp;
  429 + var oGanttBc;
  430 + var aGBc = bIsUp ? this._aUpGanttBc : this._aDownGanttBc;
  431 +
  432 + for (i = iBcIndex; i < aGBc.length; i++) {
  433 + oGanttBc = aGBc[i];
  434 +
  435 + // 添加到场,出场,进场,离场班次
  436 + this._addBdOutInLcBc(oGanttBc, bIsUp);
  437 +
  438 + while(j < this._aExcelLp.length) {
  439 + oExcelLp = this._aExcelLp[j];
  440 +
  441 + if (oGanttBc.bcType == "cf") { // 吃饭班次
  442 + this._aLpGroupCfGanttBc.push(oGanttBc);
  443 + break;
  444 + } else if (oGanttBc.bcType == "normal") { // 正常班次
  445 + this._oLpGroupNormalGanttBc[oExcelLp.lpname] = {
  446 + "isFlag": true, "normal": null
  447 + };
  448 + if (oExcelLp.lpname == oGanttBc.lpName) {
  449 + this._oLpGroupNormalGanttBc[oExcelLp.lpname].isFlag = false;
  450 + this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal = oGanttBc;
  451 + j++;
  452 + break;
  453 + } else {
  454 + j++;
  455 + }
  456 + } else {
  457 +
  458 + break;
  459 + }
  460 +
  461 + }
  462 +
  463 + if (j == this._aExcelLp.length) { // 完整的一圈处理
  464 + this._resetCalcuGroup(bIsUp);
  465 + j = 0;
  466 + if (oGanttBc.lpName !=
  467 + this._aExcelLp[this._aExcelLp.length - 1].lpname) {
  468 + i--;
  469 + break;
  470 +
  471 + }
  472 +
  473 + break;
  474 + }
  475 +
  476 + }
  477 +
  478 + // 最后一圈reset一下
  479 + if (j > 0) {
  480 + this._resetCalcuGroup(bIsUp);
  481 + }
  482 + return i + 1;
  483 +
  484 + };
  485 +
  486 + InternalCalcuExcelBc1.prototype._resetCalcuGroup = function(bIsUp) {
  487 + // 判定是否开始分班,添加圈数
  488 + if (bIsUp) {
  489 + if (this._fnIsFBcQ(bIsUp)) {
  490 + this._iUpGroupIndex += 1;
  491 + this._iDownGroupIndex += 1;
  492 + }
  493 + } else {
  494 + if (this._fnIsFBcQ(!bIsUp)) {
  495 + this._iUpGroupIndex += 1;
  496 + this._iDownGroupIndex += 1;
  497 + }
  498 + }
  499 +
  500 + // 重置计算圈及班次
  501 + var oExcelLp;
  502 + var oGroupGanttNormalBc;
  503 + var oGroupGanttEatBc;
  504 + for (var i = 0; i < this._aExcelLp.length; i++) {
  505 + oExcelLp = this._aExcelLp[i];
  506 + if (this._oLpGroupNormalGanttBc[oExcelLp.lpname]) {
  507 + if (!this._oLpGroupNormalGanttBc[oExcelLp.lpname].isFlag) { // 非标记班次
  508 + oGroupGanttNormalBc = this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal;
  509 +
  510 + // 获取吃饭班次
  511 + oGroupGanttEatBc = null;
  512 + if (this._aLpGroupCfGanttBc.length > 0) {
  513 + if (this._aLpGroupCfGanttBc[0].lpName == oExcelLp.lpname) {
  514 + if (this._oParam.toTimeObj(this._aLpGroupCfGanttBc[0].fcsj).isBefore(
  515 + this._oParam.toTimeObj(oGroupGanttNormalBc.fcsj))) {
  516 + oGroupGanttEatBc = this._aLpGroupCfGanttBc.shift();
  517 + }
  518 + }
  519 + }
  520 +
  521 + oExcelLp.bcObjList.push({
  522 + "bcsj": oGroupGanttNormalBc.bcsj, // 班次时间
  523 + "ssj": oGroupGanttNormalBc.STOPTIME, // 停站时间
  524 + "eatsj": oGroupGanttEatBc ? oGroupGanttEatBc.bcsj : 0, // 吃饭时间
  525 +
  526 + "tccid": oGroupGanttNormalBc.tcc, // 停车场id
  527 + "qdzid": oGroupGanttNormalBc.qdz, // 起点站id
  528 + "zdzid": oGroupGanttNormalBc.zdz, // 终点站id
  529 +
  530 + "isUp": bIsUp, // 是否上行
  531 +
  532 + "bcType": oGroupGanttNormalBc.bcType, // 班次类型
  533 + "fcsj": oGroupGanttEatBc ?
  534 + ("*" + oGroupGanttNormalBc.fcsj) :
  535 + oGroupGanttNormalBc.fcsj, // 发车时间描述
  536 + "fcsjDesc": oGroupGanttEatBc ?
  537 + ("(吃" + oGroupGanttNormalBc.fcsj + ")") :
  538 + oGroupGanttNormalBc.fcsj, // 发车时间描述2
  539 +
  540 + "groupNo": bIsUp ? this._iUpGroupIndex : this._iDownGroupIndex, // 第几圈
  541 + "groupBcNo": bIsUp == this._bQIsUp ? 0 : 1, // 圈里第几个班次
  542 +
  543 + "_bclc": oGroupGanttNormalBc.jhlc // 班次里程(最后需要删除)
  544 +
  545 + });
  546 +
  547 + oExcelLp._bcObjGroupList.push({
  548 + fcsj: oGroupGanttNormalBc.fcsj, // 发车时间
  549 + groupIndex: bIsUp ? this._iUpGroupIndex : this._iDownGroupIndex, // 第几圈
  550 + bcIndex: bIsUp == this._bQIsUp ? 0 : 1 // 圈里第几个班次
  551 + });
  552 + }
  553 + }
  554 + }
  555 +
  556 + if (bIsUp) {
  557 + this._iUpGroupIndex ++;
  558 + } else {
  559 + this._iDownGroupIndex ++;
  560 + }
  561 + this._oLpGroupNormalGanttBc = {};
  562 + };
  563 +
  564 + // 添加报到,出场,进场,离场班次
  565 + InternalCalcuExcelBc1.prototype._addBdOutInLcBc = function(oGanttBc, bIsUp) {
  566 + var i;
  567 + var oExcelLp;
  568 + var bcType;
  569 + for (i = 0; i < this._aExcelLp.length; i++) {
  570 + oExcelLp = this._aExcelLp[i];
  571 + if (oGanttBc.lpName == oExcelLp.lpname) {
  572 + bcType = oGanttBc.bcType;
  573 + if (bcType == "bd" || bcType == "out" || bcType == "in" || bcType == "lc") {
  574 + oExcelLp.bcObjList.push({
  575 + "bcsj": oGanttBc.bcsj, // 班次时间
  576 + "ssj": oGanttBc.STOPTIME, // 停站时间
  577 + "eatsj": 0, // 吃饭时间
  578 +
  579 + "tccid": oGanttBc.tcc, // 停车场id
  580 + "qdzid": oGanttBc.qdz, // 起点站id
  581 + "zdzid": oGanttBc.zdz, // 终点站id
  582 +
  583 + "isUp": bIsUp, // 是否上行
  584 + "isFb": null, // 是否分班(_resetBdOutInLcBcGroup方法修正)
  585 +
  586 + "bcType": oGanttBc.bcType, // 班次类型(bc、out、in、lc)
  587 + "fcsj": oGanttBc.fcsj, // 发车时间描述
  588 +
  589 + "groupNo": -99, // 第几圈(_resetBdOutInLcBcGroup方法修正)
  590 + "groupBcNo": -99, // 圈里第几个班次(_resetBdOutInLcBcGroup方法修正)
  591 +
  592 + "_bclc": oGanttBc.jhlc // 班次里程(最后需要删除)
  593 + });
  594 + break;
  595 + }
  596 + }
  597 + }
  598 +
  599 + };
  600 + // 重新计算报到,出场,进场,离场班次的圈索引及班次索引
  601 + InternalCalcuExcelBc1.prototype._resetBdOutInLcBcGroup = function() {
  602 + var i;
  603 + var j;
  604 + var k;
  605 + var sFcsjDesc = [];
  606 + var oExcelLp;
  607 + var oLpBc;
  608 +
  609 + // {"bd":到场班次index,"out":出场班次index, "nextBc": 出场后第一个normal班次索引, "nextBcGroup":出场后第一个normal班次group索引}
  610 + var oBdOutLpBc = {};
  611 + // 到场出场班次组合数组
  612 + var aBdOutLpBc = [];
  613 +
  614 + // {"in":进场班次index,"lc":离场班次index, "preBc": 进场前一个normal班次索引, "preBcGroup":进场前一个normal班次group索引}
  615 + var oInLcLpBc = {};
  616 + // 进场离场班次组合数组
  617 + var aInLcLpBc = [];
  618 +
  619 + for (i = 0; i < this._aExcelLp.length; i++) {
  620 + oExcelLp = this._aExcelLp[i];
  621 +
  622 + // 排序oExcelLp班次列表
  623 + this._fnSortBc(oExcelLp.bcObjList);
  624 +
  625 + aBdOutLpBc = [];
  626 + aInLcLpBc = [];
  627 +
  628 + for (j = 0; j < oExcelLp.bcObjList.length; j++) {
  629 + oLpBc = oExcelLp.bcObjList[j];
  630 +
  631 + if (oLpBc.bcType == "out") { // 出场班次
  632 + oBdOutLpBc = {"bd": null, "out": null, "nextBc": null, "nextBcGroup": null};
  633 + oBdOutLpBc["out"] = j;
  634 + // 查找上一个班次是否是报到班次(不存在有可能,中间分班班次可能没有报到时间)
  635 + if ((j - 1) >= 0 && (j - 1) < oExcelLp.bcObjList.length) {
  636 + if (oExcelLp.bcObjList[j - 1].bcType == "bd") {
  637 + oBdOutLpBc["bd"] = j - 1;
  638 + }
  639 + }
  640 + // 查找下一个班次是否是normal班次(不存在或者不是normal班次,这个报到出场班次组合忽略)
  641 + if ((j + 1) < oExcelLp.bcObjList.length) {
  642 + if (oExcelLp.bcObjList[j + 1].bcType == "normal") {
  643 + for (k = 0; k < oExcelLp._bcObjGroupList.length; k++) {
  644 + if (oExcelLp.bcObjList[j + 1].fcsj == oExcelLp._bcObjGroupList[k].fcsj) {
  645 + oBdOutLpBc["nextBc"] = j + 1;
  646 + oBdOutLpBc["nextBcGroup"] = k;
  647 + aBdOutLpBc.push(oBdOutLpBc);
  648 + break;
  649 + }
  650 + }
  651 + }
  652 + }
  653 + } else if (oLpBc.bcType == "in") { // 进场班次
  654 + oInLcLpBc = {"in": null, "lc": null, "preBc": null, "preBcGroup": null};
  655 + oInLcLpBc["in"] = j;
  656 + // 查找系一个班次是否是离场班次(不存在有可能,中间分班班次可能没有离场时间)
  657 + if ((j + 1) < oExcelLp.bcObjList.length) {
  658 + if (oExcelLp.bcObjList[j + 1].bcType == "lc") {
  659 + oInLcLpBc["lc"] = j + 1;
  660 + }
  661 + }
  662 + // 查找上一个班次是否是normal班次(不存在或者不是normal班次,这个进场离场班次组合忽略)
  663 + if ((j - 1) >= 0 && (j - 1) < oExcelLp.bcObjList.length) {
  664 + if (oExcelLp.bcObjList[j - 1].bcType == "normal") {
  665 + for (k = 0; k < oExcelLp._bcObjGroupList.length; k++) {
  666 + if (oExcelLp.bcObjList[j - 1].fcsj == oExcelLp._bcObjGroupList[k].fcsj) {
  667 + oInLcLpBc["preBc"] = j - 1;
  668 + oInLcLpBc["preBcGroup"] = k;
  669 + aInLcLpBc.push(oInLcLpBc);
  670 + break;
  671 + }
  672 + }
  673 + }
  674 + }
  675 +
  676 + }
  677 +
  678 + }
  679 +
  680 + if (aBdOutLpBc.length == 2) { // 分班(以出场班次为主)
  681 + // 处理第一个出场
  682 + sFcsjDesc = [];
  683 + oBdOutLpBc = aBdOutLpBc[0];
  684 + if (oBdOutLpBc.bd != null) {
  685 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.bd];
  686 + oLpBc.isFb = false;
  687 + oLpBc.groupNo = -1;
  688 + oLpBc.groupBcNo = -1;
  689 + sFcsjDesc.push("(到" + oLpBc.fcsj + ")");
  690 + }
  691 +
  692 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.out];
  693 + oLpBc.isFb = false;
  694 + oLpBc.groupNo = -1;
  695 + oLpBc.groupBcNo = -2;
  696 + sFcsjDesc.push("(出" + oLpBc.fcsj + ")");
  697 +
  698 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.nextBc];
  699 + sFcsjDesc.push("(" + oLpBc.fcsj + ")");
  700 + oLpBc.fcsjDesc = sFcsjDesc.join("");
  701 +
  702 + // 处理第二个出场
  703 + sFcsjDesc = [];
  704 + oBdOutLpBc = aBdOutLpBc[1];
  705 + if (oBdOutLpBc.bd != null) {
  706 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.bd];
  707 + oLpBc.isFb = true;
  708 + oLpBc.groupNo = oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].groupIndex - 1;
  709 + oLpBc.groupBcNo = oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].bcIndex;
  710 + sFcsjDesc.push("(到" + oLpBc.fcsj + ")");
  711 + }
  712 +
  713 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.out];
  714 + oLpBc.isFb = true;
  715 + oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].bcIndex == 0) ?
  716 + (oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].groupIndex - 1) :
  717 + oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].groupIndex);
  718 + oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oBdOutLpBc.nextBcGroup].bcIndex == 0) ? 1 : 0);
  719 + sFcsjDesc.push("(出" + oLpBc.fcsj + ")");
  720 +
  721 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.nextBc];
  722 + sFcsjDesc.push("(" + oLpBc.fcsj + ")");
  723 + oLpBc.fcsjDesc = sFcsjDesc.join("");
  724 +
  725 + // 2个以上进场班次,处理第一个和第二个,第一个做为中间进场
  726 + if (aInLcLpBc.length >= 2) {
  727 + sFcsjDesc = [];
  728 + oInLcLpBc = aInLcLpBc[0];
  729 +
  730 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];
  731 + sFcsjDesc.push("(" + oLpBc.fcsj + ")");
  732 +
  733 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];
  734 + oLpBc.isFb = true;
  735 + oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?
  736 + oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :
  737 + (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));
  738 + oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);
  739 + sFcsjDesc.push("(进" + oLpBc.fcsj + ")");
  740 +
  741 + oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");
  742 +
  743 + sFcsjDesc = [];
  744 + oInLcLpBc = aInLcLpBc[1];
  745 +
  746 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];
  747 + sFcsjDesc.push("(" + oLpBc.fcsj + ")");
  748 +
  749 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];
  750 + oLpBc.isFb = false;
  751 + oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?
  752 + oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :
  753 + (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));
  754 + oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);
  755 + sFcsjDesc.push("(进" + oLpBc.fcsj + ")");
  756 +
  757 + if (oInLcLpBc.lc) {
  758 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.lc];
  759 + oLpBc.isFb = false;
  760 + oLpBc.groupNo = -2;
  761 + oLpBc.groupBcNo = -4;
  762 + sFcsjDesc.push("(离" + oLpBc.fcsj + ")");
  763 + }
  764 + oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");
  765 + }
  766 +
  767 + // 一个进场班次,做为最后一个进场班次处理
  768 + if (aInLcLpBc.length == 1) {
  769 + sFcsjDesc = [];
  770 + oInLcLpBc = aInLcLpBc[0];
  771 +
  772 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];
  773 + sFcsjDesc.push("(" + oLpBc.fcsj + ")");
  774 +
  775 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];
  776 + oLpBc.isFb = false;
  777 + oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?
  778 + oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :
  779 + (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));
  780 + oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);
  781 + sFcsjDesc.push("(进" + oLpBc.fcsj + ")");
  782 +
  783 + if (oInLcLpBc.lc) {
  784 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.lc];
  785 + oLpBc.isFb = false;
  786 + oLpBc.groupNo = -2;
  787 + oLpBc.groupBcNo = -4;
  788 + sFcsjDesc.push("(离" + oLpBc.fcsj + ")");
  789 + }
  790 + oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");
  791 + }
  792 +
  793 +
  794 + } else if (aBdOutLpBc.length == 1) {
  795 + // 处理出场
  796 + sFcsjDesc = [];
  797 + oBdOutLpBc = aBdOutLpBc[0];
  798 + if (oBdOutLpBc.bd != null) {
  799 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.bd];
  800 + oLpBc.isFb = false;
  801 + oLpBc.groupNo = -1;
  802 + oLpBc.groupBcNo = -1;
  803 + sFcsjDesc.push("(到" + oLpBc.fcsj + ")");
  804 + }
  805 +
  806 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.out];
  807 + oLpBc.isFb = false;
  808 + oLpBc.groupNo = -1;
  809 + oLpBc.groupBcNo = -2;
  810 + sFcsjDesc.push("(出" + oLpBc.fcsj + ")");
  811 +
  812 + oLpBc = oExcelLp.bcObjList[oBdOutLpBc.nextBc];
  813 + sFcsjDesc.push("(" + oLpBc.fcsj + ")");
  814 + oLpBc.fcsjDesc = sFcsjDesc.join("");
  815 +
  816 + // 处理进场
  817 + if (aInLcLpBc.length > 0) {
  818 + sFcsjDesc = [];
  819 + oInLcLpBc = aInLcLpBc[0];
  820 +
  821 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.preBc];
  822 + sFcsjDesc.push("(" + oLpBc.fcsj + ")");
  823 +
  824 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.in];
  825 + oLpBc.isFb = false;
  826 + oLpBc.groupNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ?
  827 + oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex :
  828 + (oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].groupIndex + 1));
  829 + oLpBc.groupBcNo = ((oExcelLp._bcObjGroupList[oInLcLpBc.preBcGroup].bcIndex == 0) ? 1 : 0);
  830 + sFcsjDesc.push("(进" + oLpBc.fcsj + ")");
  831 +
  832 + if (oInLcLpBc.lc) {
  833 + oLpBc = oExcelLp.bcObjList[oInLcLpBc.lc];
  834 + oLpBc.isFb = false;
  835 + oLpBc.groupNo = -2;
  836 + oLpBc.groupBcNo = -4;
  837 + sFcsjDesc.push("(离" + oLpBc.fcsj + ")");
  838 + }
  839 + oExcelLp.bcObjList[oInLcLpBc.preBc].fcsjDesc = sFcsjDesc.join("");
  840 +
  841 + }
  842 +
  843 + }
  844 +
  845 + // console.log("todo");
  846 +
  847 +
  848 + }
  849 +
  850 + // console.log("ddd");
  851 +
  852 + };
  853 +
  854 + // 判定当前圈是否是有分班后的第一个normal班次
  855 + InternalCalcuExcelBc1.prototype._fnIsFBcQ = function(bIsUp) {
  856 + var oExcelLp;
  857 + var i;
  858 + var oLpPreExcelBc;
  859 + var oLpCurGranttBc;
  860 + var oPreBcFcsj;
  861 + var oCurBcFcsj;
  862 + var idiffTime;
  863 + var bFbFlag = false;
  864 + for (i = 0; i < this._aExcelLp.length; i++) {
  865 + oExcelLp = this._aExcelLp[i];
  866 + if (oExcelLp.bcObjList.length > 0) {
  867 + oLpPreExcelBc = oExcelLp.bcObjList[oExcelLp.bcObjList.length - 1];
  868 + if (oLpPreExcelBc.bcType == "normal") {
  869 + oPreBcFcsj = this._oParam.toTimeObj(
  870 + oLpPreExcelBc.fcsj.indexOf("*") >= 0 ? oLpPreExcelBc.fcsj.substr(1) : oLpPreExcelBc.fcsj
  871 + );
  872 + if (this._oLpGroupNormalGanttBc[oExcelLp.lpname]) {
  873 + oLpCurGranttBc = this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal;
  874 + if (oLpCurGranttBc) {
  875 + oCurBcFcsj = this._oParam.toTimeObj(oLpCurGranttBc.fcsj);
  876 + idiffTime = oCurBcFcsj.diff(oPreBcFcsj, "m");
  877 + if (idiffTime > oLpPreExcelBc.bcsj * 3) {
  878 + bFbFlag = true;
  879 + break;
  880 + }
  881 + }
  882 + }
  883 + }
  884 + }
  885 +
  886 + }
  887 +
  888 + return bFbFlag;
  889 +
  890 + };
  891 +
  892 + /**
  893 + * 内部Excel对象。
  894 + * @param oParam 参数对象
  895 + * @param fnGetGanttBcArray 返回gantt用的班次列表
  896 + * @constructor
  897 + */
  898 + function InternalExcelObj(oParam, fnGetGanttBcArray) {
  899 + // 参数对象
  900 + this._oParam = oParam;
  901 + // 获取gantt班次的方法
  902 + this._fnBc = fnGetGanttBcArray;
  903 +
  904 + // 每一圈是上行开始还是下行开始
  905 + this._qIsUp = oParam.getUpFirstDTimeObj().diff(oParam.getDownFirstDTimeObj()) <= 0 ? false : true;
  906 +
  907 + }
  908 +
  909 + // html5导出excel方法
  910 + InternalExcelObj.prototype.downloadFile = function(data, mimeType, fileName) {
  911 + _fnDownloadFile(data, mimeType, fileName);
  912 + };
  913 + /**
  914 + * 获取班次统计数据。
  915 + */
  916 + InternalExcelObj.prototype.fnGetStatInfoList = function() {
  917 + return _fnCalcuExportStatInfo_sheet(this._fnBc(), this._oParam);
  918 + };
  919 + /**
  920 + * 获取参数数据。
  921 + */
  922 + InternalExcelObj.prototype.fnGetParamInfoList = function() {
  923 + return _fnCalcuExportParam_sheet(this._oParam);
  924 + };
  925 + /**
  926 + * 获取路牌班次数据。
  927 + * @return {*}
  928 + */
  929 + InternalExcelObj.prototype.fnGetLpBcInfoList = function() {
  930 + // 构造显示用lp对象
  931 + var oTempLpFlag = {};
  932 + var aGanttBc = this._fnBc();
  933 + var oGanttBc;
  934 + var aLp = [];
  935 + var oLp;
  936 + var i;
  937 + for (i = 0; i < aGanttBc.length; i++) {
  938 + oGanttBc = aGanttBc[i];
  939 + if (oTempLpFlag[oGanttBc.lpName]) {
  940 + // 已经存在路牌,不处理
  941 + continue;
  942 + }
  943 +
  944 + oLp = {
  945 + "lpname": oGanttBc.lpName, // 路牌名字
  946 + "isUp": this._qIsUp, // 每圈的第一个班次是否上行
  947 + "bcObjList": [], // 内部班次列表(后面计算班次列表)
  948 + "_bcObjGroupList": [], // 每个normal班次对应的group对象 {fcsj: 发车时间, groupIndex: 圈索引, bcIndex: 班次索引},最后返回要删除
  949 + "groupCount": 0, // 总圈数(后面计算总圈数)
  950 + "zlc": 0, // 总里程
  951 + "yylc": 0, // 营运里程
  952 + "kslc": 0, // 空驶里程
  953 + "zgs": 0, // 总工时
  954 + "zbc": 0, // 总班次
  955 + "yygs": 0, // 营运工时
  956 + "yybc": 0, // 营运班次
  957 + "stationRouteId1": 0, // 第一个班次起点站路由id
  958 + "stationRouteId2": 0 // 第二个班次起点站路由id
  959 + };
  960 + oTempLpFlag[oGanttBc.lpName] = {"flag" : true}; // 标记一下
  961 + aLp.push(oLp);
  962 + }
  963 +
  964 + // 计算Excel班次
  965 + var _celb = new InternalCalcuExcelBc1(aLp, aGanttBc, this._oParam, this._qIsUp);
  966 + return _celb.fnGenerateExcelLpBcList();
  967 + };
  968 +
  969 + return InternalExcelObj;
  970 +
971 } ()); 971 } ());
972 \ No newline at end of file 972 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2_2/main_v2_2.js
1 -/**  
2 - * 主类(v2_2版本)。  
3 - */  
4 -var Main_v2_2 = function() {  
5 -  
6 - var _paramObj; // 参数对象  
7 -  
8 - return {  
9 - /**  
10 - * 使用发车间隔策略生成时刻表。  
11 - * @param paramObj 参数对象  
12 - * @param lpArray 路牌数组  
13 - * @constructor  
14 - */  
15 - BXPplaceClassesTime03 : function(paramObj, lpArray) {  
16 - // 参数对象  
17 - _paramObj = paramObj;  
18 -  
19 - // // 测试行驶时间  
20 - // var _fcsj = paramObj.toTimeObj("16:20");  
21 - // var _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, _fcsj, paramObj); // 使用策略计算班次行驶时间  
22 - // console.log("发车时间=" + _fcsj.format("HH:mm") + ",行驶时间=" + _bcsj);  
23 - //  
24 -  
25 - // // 测试停站时间  
26 - // var _fcsj = paramObj.toTimeObj("05:30");  
27 - // var _layovertime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(  
28 - // _fcsj, false, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), paramObj);  
29 - // console.log("发车时间=" + _fcsj.format("HH:mm") + ",停站layover时间=" + _layovertime);  
30 - //  
31 - // var schedule = {};  
32 -  
33 - // // 测试间隔时间  
34 - // var _fcsj = paramObj.toTimeObj("07:30");  
35 - // var _headway = StrategyUtils_v2_2.sFn("CALCU_HEADWAY_2")(true, _fcsj, _paramObj);  
36 - // console.log("发车时间=" + _fcsj.format("HH:mm") + ",发车间隔=" + _headway);  
37 -  
38 - // 1、初始化行车计划  
39 - var schedule = new InternalScheduleObj_v2_2(paramObj, lpArray);  
40 - // 2、生成班次(从第2圈开始)  
41 - schedule.fnCreateBclistWithMasterBc(2, 20);  
42 - // 3、调整发车间隔  
43 - schedule.fnAdjustHeadway();  
44 - // 4、计算吃饭班次  
45 - schedule.fnCalcuEatBc();  
46 - // // 6、计算末班车  
47 - // schedule.fnCalcuLastBc();  
48 - // 7、重新设置停站时间  
49 - schedule.fnReSetLayoverTime();  
50 - // 8、补进出场例保班次  
51 - schedule.fnCalcuOtherBc();  
52 -  
53 - //-------------------- 输出ganut图上的班次,班型描述 ----------------------//  
54 - // TODO:班型再议  
55 - return {  
56 - 'json':schedule.fnToGanttBcArray(),'bxrcgs':null,  
57 - 'aInternalLpObj': schedule.fnGetLpArray()  
58 - };  
59 - },  
60 -  
61 - //----------------------------------- 导入导出配置 -----------------------------------//  
62 -  
63 - /**  
64 - * 导出时刻表配置。  
65 - * @param fnGetGanttBc 获取gantt班次方法  
66 - */  
67 - exportExcelConfig: function(fnGetGanttBc) {  
68 - var oExcel = new Main_v2_2_ExcelObj(_paramObj, fnGetGanttBc);  
69 -  
70 - $('.exportAddXls').off('click');  
71 - $('.exportAddXlsx').off('click');  
72 -  
73 - $('.exportAddXls').on('click', function() {  
74 -  
75 - var aInfos = {  
76 - "lpObjList": oExcel.fnGetLpBcInfoList(), // 路牌班次信息列表  
77 - "statInfoList": oExcel.fnGetStatInfoList(), // 统计项目列表  
78 - "parameterInfoList" : oExcel.fnGetParamInfoList() // 参数对象  
79 - };  
80 -  
81 - console.log(aInfos);  
82 -  
83 - $(".exportAdd").addClass("disabled");  
84 - $(".exportAddSpan").html("正在导出...");  
85 -  
86 - // 提交  
87 - $.ajax({  
88 - type: 'POST',  
89 - url: "/tidc/exportDTDFile/xls",  
90 - dataType: 'binary',  
91 - contentType: "application/json",  
92 - data: JSON.stringify(aInfos),  
93 - success: function(data){  
94 - oExcel.downloadFile(data, "application/octet-stream", "时刻表信息.xls");  
95 -  
96 - $(".exportAdd").removeClass("disabled");  
97 - $(".exportAddSpan").html(" 导出数据");  
98 - },  
99 - error: function(xhr, type){  
100 - alert('错误:TODO');  
101 -  
102 - $(".exportAdd").removeClass("disabled");  
103 - $(".exportAddSpan").html(" 导出数据");  
104 - }  
105 - });  
106 - });  
107 -  
108 - $('.exportAddXlsx').on('click', function() {  
109 - var aInfos = {  
110 - "lpObjList": oExcel.fnGetLpBcInfoList(), // 路牌班次信息列表  
111 - "statInfoList": oExcel.fnGetStatInfoList(), // 统计项目列表  
112 - "parameterInfoList" : oExcel.fnGetParamInfoList() // 参数对象  
113 - };  
114 -  
115 - console.log(aInfos);  
116 -  
117 - $(".exportAdd").addClass("disabled");  
118 - $(".exportAddSpan").html("正在导出...");  
119 -  
120 - // 提交  
121 - $.ajax({  
122 - type: 'POST',  
123 - url: "/tidc/exportDTDFile/xlsx",  
124 - dataType: 'binary',  
125 - contentType: "application/json",  
126 - data: JSON.stringify(aInfos),  
127 - success: function(data){  
128 - oExcel.downloadFile(data, "application/octet-stream", "时刻表信息.xlsx");  
129 -  
130 - $(".exportAdd").removeClass("disabled");  
131 - $(".exportAddSpan").html(" 导出数据");  
132 - },  
133 - error: function(xhr, type){  
134 - alert('错误:TODO');  
135 -  
136 - $(".exportAdd").removeClass("disabled");  
137 - $(".exportAddSpan").html(" 导出数据");  
138 - }  
139 - });  
140 - });  
141 - }  
142 -  
143 -  
144 - } 1 +/**
  2 + * 主类(v2_2版本)。
  3 + */
  4 +var Main_v2_2 = function() {
  5 +
  6 + var _paramObj; // 参数对象
  7 +
  8 + return {
  9 + /**
  10 + * 使用发车间隔策略生成时刻表。
  11 + * @param paramObj 参数对象
  12 + * @param lpArray 路牌数组
  13 + * @constructor
  14 + */
  15 + BXPplaceClassesTime03 : function(paramObj, lpArray) {
  16 + // 参数对象
  17 + _paramObj = paramObj;
  18 +
  19 + // // 测试行驶时间
  20 + // var _fcsj = paramObj.toTimeObj("16:20");
  21 + // var _bcsj = StrategyUtils_v2_2.sFn("CALCU_RUNTIME")(false, _fcsj, paramObj); // 使用策略计算班次行驶时间
  22 + // console.log("发车时间=" + _fcsj.format("HH:mm") + ",行驶时间=" + _bcsj);
  23 + //
  24 +
  25 + // // 测试停站时间
  26 + // var _fcsj = paramObj.toTimeObj("05:30");
  27 + // var _layovertime = StrategyUtils_v2_2.sFn("CALCU_LAYOVER_TIME")(
  28 + // _fcsj, false, StrategyUtils_v2_2.sFn("CALCU_RUNTIME"), paramObj);
  29 + // console.log("发车时间=" + _fcsj.format("HH:mm") + ",停站layover时间=" + _layovertime);
  30 + //
  31 + // var schedule = {};
  32 +
  33 + // // 测试间隔时间
  34 + // var _fcsj = paramObj.toTimeObj("07:30");
  35 + // var _headway = StrategyUtils_v2_2.sFn("CALCU_HEADWAY_2")(true, _fcsj, _paramObj);
  36 + // console.log("发车时间=" + _fcsj.format("HH:mm") + ",发车间隔=" + _headway);
  37 +
  38 + // 1、初始化行车计划
  39 + var schedule = new InternalScheduleObj_v2_2(paramObj, lpArray);
  40 + // 2、生成班次(从第2圈开始)
  41 + schedule.fnCreateBclistWithMasterBc(2, 20);
  42 + // 3、调整发车间隔
  43 + schedule.fnAdjustHeadway();
  44 + // 4、计算吃饭班次
  45 + schedule.fnCalcuEatBc();
  46 + // // 6、计算末班车
  47 + // schedule.fnCalcuLastBc();
  48 + // 7、重新设置停站时间
  49 + schedule.fnReSetLayoverTime();
  50 + // 8、补进出场例保班次
  51 + schedule.fnCalcuOtherBc();
  52 +
  53 + //-------------------- 输出ganut图上的班次,班型描述 ----------------------//
  54 + // TODO:班型再议
  55 + return {
  56 + 'json':schedule.fnToGanttBcArray(),'bxrcgs':null,
  57 + 'aInternalLpObj': schedule.fnGetLpArray()
  58 + };
  59 + },
  60 +
  61 + //----------------------------------- 导入导出配置 -----------------------------------//
  62 +
  63 + /**
  64 + * 导出时刻表配置。
  65 + * @param fnGetGanttBc 获取gantt班次方法
  66 + */
  67 + exportExcelConfig: function(fnGetGanttBc) {
  68 + var oExcel = new Main_v2_2_ExcelObj(_paramObj, fnGetGanttBc);
  69 +
  70 + $('.exportAddXls').off('click');
  71 + $('.exportAddXlsx').off('click');
  72 +
  73 + $('.exportAddXls').on('click', function() {
  74 +
  75 + var aInfos = {
  76 + "lpObjList": oExcel.fnGetLpBcInfoList(), // 路牌班次信息列表
  77 + "statInfoList": oExcel.fnGetStatInfoList(), // 统计项目列表
  78 + "parameterInfoList" : oExcel.fnGetParamInfoList() // 参数对象
  79 + };
  80 +
  81 + console.log(aInfos);
  82 +
  83 + $(".exportAdd").addClass("disabled");
  84 + $(".exportAddSpan").html("正在导出...");
  85 +
  86 + // 提交
  87 + $.ajax({
  88 + type: 'POST',
  89 + url: "/tidc/exportDTDFile/xls",
  90 + dataType: 'binary',
  91 + contentType: "application/json",
  92 + data: JSON.stringify(aInfos),
  93 + success: function(data){
  94 + oExcel.downloadFile(data, "application/octet-stream", "时刻表信息.xls");
  95 +
  96 + $(".exportAdd").removeClass("disabled");
  97 + $(".exportAddSpan").html(" 导出数据");
  98 + },
  99 + error: function(xhr, type){
  100 + alert('错误:TODO');
  101 +
  102 + $(".exportAdd").removeClass("disabled");
  103 + $(".exportAddSpan").html(" 导出数据");
  104 + }
  105 + });
  106 + });
  107 +
  108 + $('.exportAddXlsx').on('click', function() {
  109 + var aInfos = {
  110 + "lpObjList": oExcel.fnGetLpBcInfoList(), // 路牌班次信息列表
  111 + "statInfoList": oExcel.fnGetStatInfoList(), // 统计项目列表
  112 + "parameterInfoList" : oExcel.fnGetParamInfoList() // 参数对象
  113 + };
  114 +
  115 + console.log(aInfos);
  116 +
  117 + $(".exportAdd").addClass("disabled");
  118 + $(".exportAddSpan").html("正在导出...");
  119 +
  120 + // 提交
  121 + $.ajax({
  122 + type: 'POST',
  123 + url: "/tidc/exportDTDFile/xlsx",
  124 + dataType: 'binary',
  125 + contentType: "application/json",
  126 + data: JSON.stringify(aInfos),
  127 + success: function(data){
  128 + oExcel.downloadFile(data, "application/octet-stream", "时刻表信息.xlsx");
  129 +
  130 + $(".exportAdd").removeClass("disabled");
  131 + $(".exportAddSpan").html(" 导出数据");
  132 + },
  133 + error: function(xhr, type){
  134 + alert('错误:TODO');
  135 +
  136 + $(".exportAdd").removeClass("disabled");
  137 + $(".exportAddSpan").html(" 导出数据");
  138 + }
  139 + });
  140 + });
  141 + }
  142 +
  143 +
  144 + }
145 }(); 145 }();
146 \ No newline at end of file 146 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2_2/strategy/headway/AdjustHeadwayS1.js
1 -/**  
2 - * 调整某一圈的发车间隔,在已有的间隔上做修正。  
3 - * 1、圈的第一个班次,最后一个班次发车时间固定不变,调整其余班次间隔  
4 - * 2、调整的判定原则是某个班次和该路牌下一个班次之间的layovertime为负值,需要调整当前班次间隔  
5 - * 3、TODO:如果仅靠调整间隔无法调整,可以考虑删除某个路牌的班次  
6 - * 4、TODO:目前只用在第一圈第一个方向班次列表上,低谷在前,高峰在后  
7 - */  
8 -var AdjustHeadwayS1 = (function() {  
9 -  
10 - /**  
11 - * 从指定路牌的班次开始往下所有的班次发车时间尝试减一分钟。  
12 - * @param aLp 路牌数组  
13 - * @param lpIndex 从下往上第一个停站时间不足的班次所在路牌索引  
14 - * @param iCurrentGroupIndex 班次圈索引  
15 - * @param iCurrentBcIndex 班次索引  
16 - * @param oParam 参数对象  
17 - */  
18 - function _a_down(aLp, lpIndex, iCurrentGroupIndex, iCurrentBcIndex, oParam) {  
19 - // 如果最后一个路牌的班次就停站时间不足,则不调整  
20 - if (lpIndex == aLp.length - 1) {  
21 - return false;  
22 - }  
23 - // 有班次的路牌索引数组(往下)  
24 - var i;  
25 - var aLpIndex = [];  
26 - for (i = lpIndex; i < aLp.length; i++) {  
27 - if (aLp[i].getBc(iCurrentGroupIndex, iCurrentBcIndex)) {  
28 - aLpIndex.push(i);  
29 - }  
30 - }  
31 -  
32 - // 当前班次开始与下一个路牌的对应班次的发车时间间隔  
33 - var aHeadWay = [];  
34 - var oHeadWay;  
35 - for (i = 0; i < aLpIndex.length - 1; i++) {  
36 - oHeadWay = {};  
37 - oHeadWay.iStartLpIndex = aLpIndex[i];  
38 - oHeadWay.iEndLpIndex = aLpIndex[i + 1];  
39 - if (oParam.isMPeakBc(aLp[aLpIndex[i]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj())) {  
40 - oHeadWay.bMPeakBc = true;  
41 - } else {  
42 - oHeadWay.bMPeakBc = false;  
43 - }  
44 - oHeadWay.iHeadWay = aLp[aLpIndex[i + 1]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj().diff(  
45 - aLp[aLpIndex[i]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj(), "m"  
46 - );  
47 -  
48 - aHeadWay.push(oHeadWay);  
49 - }  
50 -  
51 - // 找出第一个间隔小于高峰最大发车间隔的位置,  
52 - // 然后从lpIndex开始到这个位置减发车时间,  
53 - // 从而达到从lpIndex开始到这个位置,局部减少发车时间的作用  
54 - // 最终的结果是停站时间足够,并且停站时间也是一个过渡效果  
55 - var bIsFind = false;  
56 - var iFindIndex;  
57 - for (i = 0; i < aHeadWay.length; i++) {  
58 - if (aHeadWay[i].bMPeakBc) {  
59 - if (aHeadWay[i].iHeadWay < oParam.getMPeakMaxFcjx()) {  
60 - iFindIndex = i;  
61 - bIsFind = true;  
62 - break;  
63 - }  
64 - } else {  
65 - iFindIndex = i;  
66 - bIsFind = true;  
67 - break;  
68 - }  
69 - }  
70 -  
71 - if (!bIsFind) {  
72 - return false;  
73 - }  
74 -  
75 - // 调整间隔  
76 - var iStartLpIndex = aHeadWay[iFindIndex].iStartLpIndex;  
77 - var oLp;  
78 - var oBc;  
79 - for (i = 0; i < aLpIndex.length; i++) {  
80 - if (aLpIndex[i] <= iStartLpIndex && aLpIndex[i] > lpIndex) {  
81 - oLp = aLp[aLpIndex[i]];  
82 - oBc = oLp.getBc(iCurrentGroupIndex, iCurrentBcIndex);  
83 - oBc.addMinuteToFcsj(-1); // 发车时间,到达时间减1分钟  
84 -  
85 - oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔  
86 - iCurrentGroupIndex, iCurrentBcIndex,  
87 - oLp.fnGetVerticalIntervalTime(iCurrentGroupIndex, iCurrentBcIndex) - 1);  
88 - }  
89 - }  
90 -  
91 - return true;  
92 - }  
93 - // // TODO:向上局部减少发车调整有问题,不能下上所有的班次都减发车时间,需要像_a_down逐步减,下次修正  
94 - // function _a_up2(lpIndex, aLp,  
95 - // iCurrentGroupIndex, iCurrentBcIndex, oParam) {  
96 - // // 有班次的路牌索引数组(往上)  
97 - // var i;  
98 - // var aLpIndex = [];  
99 - // for (i = lpIndex; i >= 0; i--) {  
100 - // if (aLp[i].getBc(iCurrentGroupIndex, iCurrentBcIndex)) {  
101 - // aLpIndex.push(i);  
102 - // }  
103 - // }  
104 - // // 当前班次开始与下一个路牌的对应班次的发车时间间隔  
105 - // var aHeadWay = [];  
106 - // var oHeadWay = {};  
107 - // for (i = 0; i < aLpIndex.length - 1; i++) {  
108 - // oHeadWay = {};  
109 - // oHeadWay.iStartLpIndex = aLpIndex[i + 1];  
110 - // oHeadWay.iEndLpIndex = aLpIndex[i];  
111 - // if (oParam.isMPeakBc(aLp[aLpIndex[i + 1]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj())) {  
112 - // oHeadWay.bMPeakBc = true;  
113 - // } else {  
114 - // oHeadWay.bMPeakBc = false;  
115 - // }  
116 - // oHeadWay.iHeadWay = aLp[aLpIndex[i]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj().diff(  
117 - // aLp[aLpIndex[i + 1]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj(), "m"  
118 - // );  
119 - //  
120 - // aHeadWay.push(oHeadWay);  
121 - // }  
122 - //  
123 - // // 找出第一个间隔小的班次间隔  
124 - // var bIsFind = false;  
125 - // var iFindIndex;  
126 - // for (i = 0; i < aHeadWay.length; i++) {  
127 - // if (aHeadWay[i].bMPeakBc) {  
128 - // if (aHeadWay[i].iHeadWay > oParam.getMPeakMinFcjx()) {  
129 - // iFindIndex = i;  
130 - // bIsFind = true;  
131 - // break;  
132 - // }  
133 - // } else {  
134 - // iFindIndex = i;  
135 - // bIsFind = true;  
136 - // break;  
137 - // }  
138 - // }  
139 - //  
140 - // if (!bIsFind) {  
141 - // return false;  
142 - // }  
143 - //  
144 - // // 调整间隔  
145 - // var iStartLpIndex = aHeadWay[iFindIndex].iStartLpIndex;  
146 - // var oLp;  
147 - // var oBc;  
148 - // for (i = 0; i < aLpIndex.length; i++) {  
149 - // if (aLpIndex[i] <= lpIndex && aLpIndex[i] >= iStartLpIndex) {  
150 - // oLp = aLp[aLpIndex[i]];  
151 - // oBc = oLp.getBc(iCurrentGroupIndex, iCurrentBcIndex);  
152 - // oBc.addMinuteToFcsj(-1); // 发车时间,到达时间减1分钟  
153 - // }  
154 - // }  
155 - //  
156 - // return true;  
157 - //  
158 - // }  
159 -  
160 - /**  
161 - * 从指定路牌的班次开始往上所有的班次发车时间尝试减一分钟。  
162 - * @param lpIndex 开始路牌索引  
163 - * @param aLp 路牌列表  
164 - * @param iCurrentGroupIndex 当前班次圈索引  
165 - * @param iCurrentBcIndex 当前班次索引  
166 - * @param oParam 参数对象  
167 - */  
168 - function _a_up(lpIndex, aLp,  
169 - iCurrentGroupIndex, iCurrentBcIndex, oParam) {  
170 - var i;  
171 - var oLp;  
172 - var oBc;  
173 - for (i = lpIndex; i > 0; i--) { // 第一个路牌的班次不能动  
174 - oLp = aLp[i];  
175 - oBc = oLp.getBc(iCurrentGroupIndex, iCurrentBcIndex);  
176 - if (oBc) {  
177 - oBc.addMinuteToFcsj(-1); // 发车时间,到达时间减1分钟  
178 -  
179 - oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔  
180 - iCurrentGroupIndex, iCurrentBcIndex,  
181 - oLp.fnGetVerticalIntervalTime(iCurrentGroupIndex, iCurrentBcIndex) - 1);  
182 - }  
183 -  
184 - }  
185 - }  
186 -  
187 - /**  
188 - * 主函数。  
189 - * @param oInternalSchedule 行车计划  
190 - * @param oParam 参数对象  
191 - * @param iCGIndex 圈索引  
192 - * @param iCBIndex 班次索引  
193 - * @param iNGIndex 同路牌下一个邻接圈索引  
194 - * @param iNBIndex 同路牌下一个邻接班次索引  
195 - * @param iMinLayoverTime 要求的最小停站时间  
196 - */  
197 - function main(oInternalSchedule, oParam,  
198 - iCGIndex, iCBIndex,  
199 - iNGIndex, iNBIndex,  
200 - iMinLayoverTime) {  
201 - var _iIterCount = 0; // 当前迭代次数  
202 - var _iMaxIter = 100; // 最大迭代100次  
203 -  
204 - var bLpFind = false;  
205 - var iLpIndex;  
206 - var i;  
207 - var aLp = oInternalSchedule.fnGetLpArray();  
208 - var oLp;  
209 - var oCBc;  
210 - var oNBc;  
211 - while (_iIterCount <= _iMaxIter) {  
212 - // 反方向查找第一个停站时间不足的班次  
213 - for (i = aLp.length - 1; i > 0; i--) {  
214 - oLp = aLp[i];  
215 - oCBc = oLp.getBc(iCGIndex, iCBIndex);  
216 - oNBc = oLp.getBc(iNGIndex, iNBIndex);  
217 - if (oCBc && oNBc) {  
218 - if (oNBc.getFcTimeObj().diff(oCBc.getArrTimeObj(), "m") <= (iMinLayoverTime - 1)) {  
219 - iLpIndex = i;  
220 - bLpFind = true;  
221 - break;  
222 - }  
223 - }  
224 - }  
225 - if (!bLpFind) {  
226 - break;  
227 - }  
228 -  
229 - if (iLpIndex == aLp.length - 1) { // 最后一个路牌的班次停站时间不足,不能调整了  
230 - break;  
231 - }  
232 -  
233 - // 如果当前班次和下一个班次的间隔是早高峰最大发车间隔,需要尝试下面的班次发车时间减1分钟  
234 - if (aLp[iLpIndex + 1].getBc(iCGIndex, iCBIndex).getFcTimeObj().diff(  
235 - aLp[iLpIndex].getBc(iCGIndex, iCBIndex).getFcTimeObj(), "m") == oParam.getMPeakMaxFcjx()) {  
236 - if (_a_down(aLp, iLpIndex, iCGIndex, iCBIndex, oParam)) {  
237 - _a_up(iLpIndex, aLp,iCGIndex, iCBIndex, oParam);  
238 - } else {  
239 - break;  
240 - }  
241 - } else {  
242 - _a_up(iLpIndex, aLp,iCGIndex, iCBIndex, oParam);  
243 - }  
244 -  
245 - bLpFind = false;  
246 - _iIterCount ++;  
247 - }  
248 -  
249 - }  
250 -  
251 - return main; 1 +/**
  2 + * 调整某一圈的发车间隔,在已有的间隔上做修正。
  3 + * 1、圈的第一个班次,最后一个班次发车时间固定不变,调整其余班次间隔
  4 + * 2、调整的判定原则是某个班次和该路牌下一个班次之间的layovertime为负值,需要调整当前班次间隔
  5 + * 3、TODO:如果仅靠调整间隔无法调整,可以考虑删除某个路牌的班次
  6 + * 4、TODO:目前只用在第一圈第一个方向班次列表上,低谷在前,高峰在后
  7 + */
  8 +var AdjustHeadwayS1 = (function() {
  9 +
  10 + /**
  11 + * 从指定路牌的班次开始往下所有的班次发车时间尝试减一分钟。
  12 + * @param aLp 路牌数组
  13 + * @param lpIndex 从下往上第一个停站时间不足的班次所在路牌索引
  14 + * @param iCurrentGroupIndex 班次圈索引
  15 + * @param iCurrentBcIndex 班次索引
  16 + * @param oParam 参数对象
  17 + */
  18 + function _a_down(aLp, lpIndex, iCurrentGroupIndex, iCurrentBcIndex, oParam) {
  19 + // 如果最后一个路牌的班次就停站时间不足,则不调整
  20 + if (lpIndex == aLp.length - 1) {
  21 + return false;
  22 + }
  23 + // 有班次的路牌索引数组(往下)
  24 + var i;
  25 + var aLpIndex = [];
  26 + for (i = lpIndex; i < aLp.length; i++) {
  27 + if (aLp[i].getBc(iCurrentGroupIndex, iCurrentBcIndex)) {
  28 + aLpIndex.push(i);
  29 + }
  30 + }
  31 +
  32 + // 当前班次开始与下一个路牌的对应班次的发车时间间隔
  33 + var aHeadWay = [];
  34 + var oHeadWay;
  35 + for (i = 0; i < aLpIndex.length - 1; i++) {
  36 + oHeadWay = {};
  37 + oHeadWay.iStartLpIndex = aLpIndex[i];
  38 + oHeadWay.iEndLpIndex = aLpIndex[i + 1];
  39 + if (oParam.isMPeakBc(aLp[aLpIndex[i]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj())) {
  40 + oHeadWay.bMPeakBc = true;
  41 + } else {
  42 + oHeadWay.bMPeakBc = false;
  43 + }
  44 + oHeadWay.iHeadWay = aLp[aLpIndex[i + 1]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj().diff(
  45 + aLp[aLpIndex[i]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj(), "m"
  46 + );
  47 +
  48 + aHeadWay.push(oHeadWay);
  49 + }
  50 +
  51 + // 找出第一个间隔小于高峰最大发车间隔的位置,
  52 + // 然后从lpIndex开始到这个位置减发车时间,
  53 + // 从而达到从lpIndex开始到这个位置,局部减少发车时间的作用
  54 + // 最终的结果是停站时间足够,并且停站时间也是一个过渡效果
  55 + var bIsFind = false;
  56 + var iFindIndex;
  57 + for (i = 0; i < aHeadWay.length; i++) {
  58 + if (aHeadWay[i].bMPeakBc) {
  59 + if (aHeadWay[i].iHeadWay < oParam.getMPeakMaxFcjx()) {
  60 + iFindIndex = i;
  61 + bIsFind = true;
  62 + break;
  63 + }
  64 + } else {
  65 + iFindIndex = i;
  66 + bIsFind = true;
  67 + break;
  68 + }
  69 + }
  70 +
  71 + if (!bIsFind) {
  72 + return false;
  73 + }
  74 +
  75 + // 调整间隔
  76 + var iStartLpIndex = aHeadWay[iFindIndex].iStartLpIndex;
  77 + var oLp;
  78 + var oBc;
  79 + for (i = 0; i < aLpIndex.length; i++) {
  80 + if (aLpIndex[i] <= iStartLpIndex && aLpIndex[i] > lpIndex) {
  81 + oLp = aLp[aLpIndex[i]];
  82 + oBc = oLp.getBc(iCurrentGroupIndex, iCurrentBcIndex);
  83 + oBc.addMinuteToFcsj(-1); // 发车时间,到达时间减1分钟
  84 +
  85 + oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔
  86 + iCurrentGroupIndex, iCurrentBcIndex,
  87 + oLp.fnGetVerticalIntervalTime(iCurrentGroupIndex, iCurrentBcIndex) - 1);
  88 + }
  89 + }
  90 +
  91 + return true;
  92 + }
  93 + // // TODO:向上局部减少发车调整有问题,不能下上所有的班次都减发车时间,需要像_a_down逐步减,下次修正
  94 + // function _a_up2(lpIndex, aLp,
  95 + // iCurrentGroupIndex, iCurrentBcIndex, oParam) {
  96 + // // 有班次的路牌索引数组(往上)
  97 + // var i;
  98 + // var aLpIndex = [];
  99 + // for (i = lpIndex; i >= 0; i--) {
  100 + // if (aLp[i].getBc(iCurrentGroupIndex, iCurrentBcIndex)) {
  101 + // aLpIndex.push(i);
  102 + // }
  103 + // }
  104 + // // 当前班次开始与下一个路牌的对应班次的发车时间间隔
  105 + // var aHeadWay = [];
  106 + // var oHeadWay = {};
  107 + // for (i = 0; i < aLpIndex.length - 1; i++) {
  108 + // oHeadWay = {};
  109 + // oHeadWay.iStartLpIndex = aLpIndex[i + 1];
  110 + // oHeadWay.iEndLpIndex = aLpIndex[i];
  111 + // if (oParam.isMPeakBc(aLp[aLpIndex[i + 1]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj())) {
  112 + // oHeadWay.bMPeakBc = true;
  113 + // } else {
  114 + // oHeadWay.bMPeakBc = false;
  115 + // }
  116 + // oHeadWay.iHeadWay = aLp[aLpIndex[i]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj().diff(
  117 + // aLp[aLpIndex[i + 1]].getBc(iCurrentGroupIndex, iCurrentBcIndex).getFcTimeObj(), "m"
  118 + // );
  119 + //
  120 + // aHeadWay.push(oHeadWay);
  121 + // }
  122 + //
  123 + // // 找出第一个间隔小的班次间隔
  124 + // var bIsFind = false;
  125 + // var iFindIndex;
  126 + // for (i = 0; i < aHeadWay.length; i++) {
  127 + // if (aHeadWay[i].bMPeakBc) {
  128 + // if (aHeadWay[i].iHeadWay > oParam.getMPeakMinFcjx()) {
  129 + // iFindIndex = i;
  130 + // bIsFind = true;
  131 + // break;
  132 + // }
  133 + // } else {
  134 + // iFindIndex = i;
  135 + // bIsFind = true;
  136 + // break;
  137 + // }
  138 + // }
  139 + //
  140 + // if (!bIsFind) {
  141 + // return false;
  142 + // }
  143 + //
  144 + // // 调整间隔
  145 + // var iStartLpIndex = aHeadWay[iFindIndex].iStartLpIndex;
  146 + // var oLp;
  147 + // var oBc;
  148 + // for (i = 0; i < aLpIndex.length; i++) {
  149 + // if (aLpIndex[i] <= lpIndex && aLpIndex[i] >= iStartLpIndex) {
  150 + // oLp = aLp[aLpIndex[i]];
  151 + // oBc = oLp.getBc(iCurrentGroupIndex, iCurrentBcIndex);
  152 + // oBc.addMinuteToFcsj(-1); // 发车时间,到达时间减1分钟
  153 + // }
  154 + // }
  155 + //
  156 + // return true;
  157 + //
  158 + // }
  159 +
  160 + /**
  161 + * 从指定路牌的班次开始往上所有的班次发车时间尝试减一分钟。
  162 + * @param lpIndex 开始路牌索引
  163 + * @param aLp 路牌列表
  164 + * @param iCurrentGroupIndex 当前班次圈索引
  165 + * @param iCurrentBcIndex 当前班次索引
  166 + * @param oParam 参数对象
  167 + */
  168 + function _a_up(lpIndex, aLp,
  169 + iCurrentGroupIndex, iCurrentBcIndex, oParam) {
  170 + var i;
  171 + var oLp;
  172 + var oBc;
  173 + for (i = lpIndex; i > 0; i--) { // 第一个路牌的班次不能动
  174 + oLp = aLp[i];
  175 + oBc = oLp.getBc(iCurrentGroupIndex, iCurrentBcIndex);
  176 + if (oBc) {
  177 + oBc.addMinuteToFcsj(-1); // 发车时间,到达时间减1分钟
  178 +
  179 + oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔
  180 + iCurrentGroupIndex, iCurrentBcIndex,
  181 + oLp.fnGetVerticalIntervalTime(iCurrentGroupIndex, iCurrentBcIndex) - 1);
  182 + }
  183 +
  184 + }
  185 + }
  186 +
  187 + /**
  188 + * 主函数。
  189 + * @param oInternalSchedule 行车计划
  190 + * @param oParam 参数对象
  191 + * @param iCGIndex 圈索引
  192 + * @param iCBIndex 班次索引
  193 + * @param iNGIndex 同路牌下一个邻接圈索引
  194 + * @param iNBIndex 同路牌下一个邻接班次索引
  195 + * @param iMinLayoverTime 要求的最小停站时间
  196 + */
  197 + function main(oInternalSchedule, oParam,
  198 + iCGIndex, iCBIndex,
  199 + iNGIndex, iNBIndex,
  200 + iMinLayoverTime) {
  201 + var _iIterCount = 0; // 当前迭代次数
  202 + var _iMaxIter = 100; // 最大迭代100次
  203 +
  204 + var bLpFind = false;
  205 + var iLpIndex;
  206 + var i;
  207 + var aLp = oInternalSchedule.fnGetLpArray();
  208 + var oLp;
  209 + var oCBc;
  210 + var oNBc;
  211 + while (_iIterCount <= _iMaxIter) {
  212 + // 反方向查找第一个停站时间不足的班次
  213 + for (i = aLp.length - 1; i > 0; i--) {
  214 + oLp = aLp[i];
  215 + oCBc = oLp.getBc(iCGIndex, iCBIndex);
  216 + oNBc = oLp.getBc(iNGIndex, iNBIndex);
  217 + if (oCBc && oNBc) {
  218 + if (oNBc.getFcTimeObj().diff(oCBc.getArrTimeObj(), "m") <= (iMinLayoverTime - 1)) {
  219 + iLpIndex = i;
  220 + bLpFind = true;
  221 + break;
  222 + }
  223 + }
  224 + }
  225 + if (!bLpFind) {
  226 + break;
  227 + }
  228 +
  229 + if (iLpIndex == aLp.length - 1) { // 最后一个路牌的班次停站时间不足,不能调整了
  230 + break;
  231 + }
  232 +
  233 + // 如果当前班次和下一个班次的间隔是早高峰最大发车间隔,需要尝试下面的班次发车时间减1分钟
  234 + if (aLp[iLpIndex + 1].getBc(iCGIndex, iCBIndex).getFcTimeObj().diff(
  235 + aLp[iLpIndex].getBc(iCGIndex, iCBIndex).getFcTimeObj(), "m") == oParam.getMPeakMaxFcjx()) {
  236 + if (_a_down(aLp, iLpIndex, iCGIndex, iCBIndex, oParam)) {
  237 + _a_up(iLpIndex, aLp,iCGIndex, iCBIndex, oParam);
  238 + } else {
  239 + break;
  240 + }
  241 + } else {
  242 + _a_up(iLpIndex, aLp,iCGIndex, iCBIndex, oParam);
  243 + }
  244 +
  245 + bLpFind = false;
  246 + _iIterCount ++;
  247 + }
  248 +
  249 + }
  250 +
  251 + return main;
252 } ()); 252 } ());
253 \ No newline at end of file 253 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2_2/strategy/headway/AdjustHeadwayS2.js
1 -/**  
2 - * 调整某一圈的发车间隔,在已有的间隔上做修正。  
3 - * 1、圈的第一个班次,发车时间固定不变,调整其余班次间隔  
4 - * 2、当前圈一般是副站圈,与邻接的主站班次之间的layovertime太大,调整  
5 - */  
6 -var AdjustHeadwayS2 = (function() {  
7 -  
8 - /**  
9 - * 调整班次发车时间(当前班次和紧领的下一个班次)  
10 - * @param oBcInfo 内部班次对象  
11 - * @param aLp 路牌列表  
12 - * @param iMinute 时间  
13 - * @private  
14 - */  
15 - function _modifyHeadway(oBcInfo, aLp, iMinute) {  
16 - if (!oBcInfo) {  
17 - return;  
18 - }  
19 -  
20 - // 调整班次发车间隔  
21 - var iBcGroupIndex = oBcInfo.iGroupIndex;  
22 - var iBcIndex = oBcInfo.iBcIndex;  
23 - var oLp = aLp[oBcInfo.iLpIndex];  
24 -  
25 - var oBc = oLp.getBc(iBcGroupIndex, iBcIndex);  
26 - var oNextBc = oLp.getBc(  
27 - iBcIndex == 1 ? iBcGroupIndex + 1 : iBcGroupIndex,  
28 - iBcIndex == 0 ? 1 : 0  
29 - );  
30 - if (oBc) {  
31 - oBc.addMinuteToFcsj(iMinute);  
32 -  
33 - oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔  
34 - iBcGroupIndex, iBcIndex,  
35 - oLp.fnGetVerticalIntervalTime(iBcGroupIndex, iBcIndex) + iMinute);  
36 - }  
37 - if (oNextBc) {  
38 - oNextBc.addMinuteToFcsj(iMinute);  
39 - }  
40 - }  
41 -  
42 - /**  
43 - * 从当前班次开始向上尝试减一分钟。  
44 - * @param oBcInfo 内部班次对象  
45 - * @param aLp 路牌列表  
46 - * @param oParam 参数对象  
47 - * @private  
48 - */  
49 - function _headway_up(oBcInfo, aLp, oParam) {  
50 - if (!oBcInfo) {  
51 - return;  
52 - }  
53 -  
54 - // 有班次的路牌索引数组(往下)  
55 - var i;  
56 - var aLpIndex = [];  
57 - for (i = oBcInfo.iLpIndex; i >= 0; i--) {  
58 - if (aLp[i].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex)) {  
59 - aLpIndex.push(i);  
60 - }  
61 - }  
62 -  
63 - // 当前班次与上一个班次之间的间隔列表  
64 - var aHeadWay = [];  
65 - var oHeadWay;  
66 - for (i = 0; i < aLpIndex.length - 1; i++) {  
67 - oHeadWay = {};  
68 - oHeadWay.iStartLpIndex = aLpIndex[i + 1];  
69 - oHeadWay.iEndLpIndex = aLpIndex[i];  
70 - if (oParam.isMPeakBc(aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {  
71 - oHeadWay.bMPeakBc = true;  
72 - } else if (oParam.isEPeakBc(aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {  
73 - oHeadWay.bEPeakBc = true;  
74 - } else {  
75 - oHeadWay.bTroughBc = true;  
76 - }  
77 -  
78 - oHeadWay.iHeadWay = aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj().diff(  
79 - aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj(), "m"  
80 - );  
81 -  
82 - aHeadWay.push(oHeadWay);  
83 - }  
84 -  
85 - // 找出第一个间隔大于最小发车间隔的位置  
86 - // 从当前位置往上到此位置所有班次往前减一分钟  
87 - var bIsFind = false;  
88 - var iFindIndex;  
89 - for (i = 0; i < aHeadWay.length; i++) {  
90 - if (aHeadWay[i].bMPeakBc) { // 早高峰  
91 - if (aHeadWay[i].iHeadWay > oParam.getMPeakMinFcjx()) {  
92 - iFindIndex = i;  
93 - bIsFind = true;  
94 - break;  
95 - }  
96 - } else if (aHeadWay[i].bEPeakBc) { // 晚高峰  
97 - if (aHeadWay[i].iHeadWay > oParam.getEPeakMinFcjx()) {  
98 - iFindIndex = i;  
99 - bIsFind = true;  
100 - break;  
101 - }  
102 - } else { // 低谷  
103 - if (aHeadWay[i].iHeadWay > oParam.getTroughMinFcjx()) {  
104 - iFindIndex = i;  
105 - bIsFind = true;  
106 - break;  
107 - }  
108 - }  
109 - }  
110 -  
111 - if (!bIsFind) {  
112 - return;  
113 - }  
114 -  
115 - // 调整间隔  
116 - var _oBcInfo;  
117 - for (i = 0; i < iFindIndex; i++) {  
118 - _oBcInfo = {};  
119 - _oBcInfo.iLpIndex = aHeadWay[i].iStartLpIndex;  
120 - _oBcInfo.iGroupIndex = oBcInfo.iGroupIndex;  
121 - _oBcInfo.iBcIndex = oBcInfo.iBcIndex;  
122 - _modifyHeadway(_oBcInfo, aLp, -1);  
123 - }  
124 -  
125 - }  
126 -  
127 - /**  
128 - * 从当前班次开始向下尝试减一分钟。  
129 - * @param oBcInfo 内部班次对象  
130 - * @param aLp 路牌列表  
131 - * @param oParam 参数对象  
132 - * @private  
133 - */  
134 - function _headway_down(oBcInfo, aLp, oParam) {  
135 - if (!oBcInfo) {  
136 - return;  
137 - }  
138 -  
139 - // 有班次的路牌索引数组(往下)  
140 - var i;  
141 - var aLpIndex = [];  
142 - for (i = oBcInfo.iLpIndex; i < aLp.length; i++) {  
143 - if (aLp[i].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex)) {  
144 - aLpIndex.push(i);  
145 - }  
146 - }  
147 -  
148 - // 当前班次与下一个班次之间的间隔列表  
149 - var aHeadWay = [];  
150 - var oHeadWay;  
151 - for (i = 0; i < aLpIndex.length - 1; i++) {  
152 - oHeadWay = {};  
153 - oHeadWay.iStartLpIndex = aLpIndex[i];  
154 - oHeadWay.iEndLpIndex = aLpIndex[i + 1];  
155 - if (oParam.isMPeakBc(aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {  
156 - oHeadWay.bMPeakBc = true;  
157 - } else if (oParam.isEPeakBc(aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {  
158 - oHeadWay.bEPeakBc = true;  
159 - } else {  
160 - oHeadWay.bTroughBc = true;  
161 - }  
162 -  
163 - oHeadWay.iHeadWay = aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj().diff(  
164 - aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj(), "m"  
165 - );  
166 -  
167 - aHeadWay.push(oHeadWay);  
168 - }  
169 -  
170 - // 找出第一个间隔小于最大发车间隔的位置  
171 - // 从当前位置往下到此位置所有班次往前减一分钟  
172 - var bIsFind = false;  
173 - var iFindIndex;  
174 - for (i = 0; i < aHeadWay.length; i++) {  
175 - if (aHeadWay[i].bMPeakBc) { // 早高峰  
176 - if (aHeadWay[i].iHeadWay < oParam.getMPeakMaxFcjx()) {  
177 - iFindIndex = i;  
178 - bIsFind = true;  
179 - break;  
180 - }  
181 - } else if (aHeadWay[i].bEPeakBc) { // 晚高峰  
182 - if (aHeadWay[i].iHeadWay < oParam.getEPeakMaxFcjx()) {  
183 - iFindIndex = i;  
184 - bIsFind = true;  
185 - break;  
186 - }  
187 - } else { // 低谷  
188 - if (aHeadWay[i].iHeadWay < oParam.getTroughMaxFcjx()) {  
189 - iFindIndex = i;  
190 - bIsFind = true;  
191 - break;  
192 - }  
193 - }  
194 - }  
195 -  
196 - if (!bIsFind) {  
197 - return;  
198 - }  
199 -  
200 - // 调整间隔  
201 - var _oBcInfo;  
202 - for (i = 0; i < iFindIndex; i++) {  
203 - _oBcInfo = {};  
204 - _oBcInfo.iLpIndex = aHeadWay[i].iStartLpIndex;  
205 - _oBcInfo.iGroupIndex = oBcInfo.iGroupIndex;  
206 - _oBcInfo.iBcIndex = oBcInfo.iBcIndex;  
207 - if (_oBcInfo.iLpIndex != oBcInfo.iLpIndex) {  
208 - // 跳过当前班次  
209 - _modifyHeadway(_oBcInfo, aLp, -1);  
210 - }  
211 - }  
212 - }  
213 -  
214 - /**  
215 - * 找出当前圈最大需要修正停站时间的班次对象。  
216 - * @param oInternalSchedule 行车计划  
217 - * @param iCGIndex 圈索引(副站班次圈)  
218 - * @param iCBIndex 班次索引  
219 - * @param iNGIndex 同路牌下一个邻接圈索引(主站班次圈)  
220 - * @param iNBIndex 同路牌下一个邻接班次索引  
221 - * @param fPercent 最大超出百分比  
222 - * @return {*} {路牌索引,圈索引,班次索引}  
223 - * @private  
224 - */  
225 - function _maxMoreLayoverBcInfo(  
226 - oInternalSchedule,  
227 - iCGIndex, iCBIndex,  
228 - iNGIndex, iNBIndex,  
229 - fPercent  
230 - ) {  
231 - var i;  
232 - var oLp;  
233 - var oBc;  
234 - var oNextBc;  
235 - var iMaxLayoverTime;  
236 - var iActualLayoverTime;  
237 - var iActualMaxLayoverTime = 0;  
238 - var iActualMaxLayoverTimeLpIndex;  
239 -  
240 - for (i = 0; i < oInternalSchedule.fnGetLpArray().length; i++) {  
241 - oLp = oInternalSchedule.fnGetLpArray()[i];  
242 - oBc = oLp.getBc(iCGIndex, iCBIndex);  
243 - oNextBc = oLp.getBc(iNGIndex, iNBIndex);  
244 - if (oBc && oNextBc) {  
245 - iMaxLayoverTime = oInternalSchedule._$calcuLayoverTime(  
246 - oBc.getFcTimeObj(), oBc.isUp())[1];  
247 - iActualLayoverTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");  
248 -  
249 - if (iActualLayoverTime > iMaxLayoverTime &&  
250 - iActualLayoverTime > iMaxLayoverTime * (1 + fPercent) &&  
251 - iActualLayoverTime > iActualMaxLayoverTime  
252 - ) {  
253 - iActualMaxLayoverTime = iActualLayoverTime;  
254 - iActualMaxLayoverTimeLpIndex = i;  
255 - }  
256 - }  
257 - }  
258 -  
259 - if (iActualMaxLayoverTimeLpIndex == undefined) {  
260 - return false;  
261 - } else {  
262 - return {  
263 - iLpIndex: iActualMaxLayoverTimeLpIndex,  
264 - iGroupIndex: iNGIndex, // 主站班次圈索引  
265 - iBcIndex: iNBIndex  
266 - };  
267 - }  
268 - }  
269 -  
270 - /**  
271 - * 计算当前圈是否需要修正layovertime。  
272 - * @param oInternalSchedule 行车计划对象  
273 - * @param iCGIndex 圈索引(副站班次圈)  
274 - * @param iCBIndex 班次索引  
275 - * @param iNGIndex 同路牌下一个邻接圈索引(主站班次圈)  
276 - * @param iNBIndex 同路牌下一个邻接班次索引  
277 - * @param fPercent 最大超出百分比  
278 - * @return {boolean}  
279 - * @private  
280 - */  
281 - function _isNeedModify(  
282 - oInternalSchedule,  
283 - iCGIndex, iCBIndex,  
284 - iNGIndex, iNBIndex,  
285 - fPercent  
286 - ) {  
287 - var i;  
288 - var oLp;  
289 - var oBc;  
290 - var oNextBc;  
291 - var iMaxLayoverTime = 0;  
292 - // 计算当前圈的所有相关班次总最大标准停站时间  
293 - for (i = 0; i < oInternalSchedule.fnGetLpArray().length; i++) {  
294 - oLp = oInternalSchedule.fnGetLpArray()[i];  
295 - oBc = oLp.getBc(iCGIndex, iCBIndex);  
296 - oNextBc = oLp.getBc(iNGIndex, iNBIndex);  
297 - if (oBc && oNextBc) {  
298 - iMaxLayoverTime += oInternalSchedule._$calcuLayoverTime(  
299 - oBc.getFcTimeObj(), oBc.isUp())[1];  
300 - }  
301 - }  
302 -  
303 - var iActualLayoverTime = 0;  
304 - // 计算当前圈的所有相关班次总停站时间  
305 - for (i = 0; i < oInternalSchedule.fnGetLpArray().length; i++) {  
306 - oLp = oInternalSchedule.fnGetLpArray()[i];  
307 - oBc = oLp.getBc(iCGIndex, iCBIndex);  
308 - oNextBc = oLp.getBc(iNGIndex, iNBIndex);  
309 - if (oBc && oNextBc) {  
310 - iActualLayoverTime += oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");  
311 - }  
312 - }  
313 -  
314 - // console.log("iMaxLayoverTime=" + iMaxLayoverTime);  
315 - // console.log("iActualLayoverTime=" + iActualLayoverTime);  
316 -  
317 - // 判定是否超出指定范围  
318 - if (iActualLayoverTime > iMaxLayoverTime &&  
319 - iActualLayoverTime > iMaxLayoverTime * (1 + fPercent)) {  
320 - return true;  
321 - } else {  
322 - return false;  
323 - }  
324 - }  
325 -  
326 - /**  
327 - * 主函数。  
328 - * @param oInternalSchedule 行车计划  
329 - * @param oParam 参数对象  
330 - * @param iCGIndex 圈索引(副站班次圈)  
331 - * @param iCBIndex 班次索引  
332 - * @param iNGIndex 同路牌下一个邻接圈索引(主站班次圈)  
333 - * @param iNBIndex 同路牌下一个邻接班次索引  
334 - * @param fPercent 最大超出百分比  
335 - */  
336 - function main(  
337 - oInternalSchedule, oParam,  
338 - iCGIndex, iCBIndex,  
339 - iNGIndex, iNBIndex,  
340 - fPercent  
341 - ) {  
342 - var _iIterCount = 0; // 当前迭代次数  
343 - var _iMaxIter = 100; // 最大迭代次数  
344 -  
345 - var oBcInfo; // 内部班次对象  
346 -  
347 - while (_iIterCount <= _iMaxIter) {  
348 -  
349 - // 判定当前圈的layovertime是否超出百分比  
350 - if (_isNeedModify(oInternalSchedule,  
351 - iCGIndex, iCBIndex,  
352 - iNGIndex, iNBIndex, fPercent)) {  
353 - // 找出超出最大的班次对象  
354 - oBcInfo = _maxMoreLayoverBcInfo(  
355 - oInternalSchedule,  
356 - iCGIndex, iCBIndex,  
357 - iNGIndex, iNBIndex, fPercent  
358 - );  
359 - // 尝试向上部分班次逐个调整  
360 - _headway_up(oBcInfo, oInternalSchedule.fnGetLpArray(), oParam);  
361 - // 尝试调整当前班次  
362 - _modifyHeadway(oBcInfo, oInternalSchedule.fnGetLpArray(), -1);  
363 - // 尝试向下部分班次逐个调整  
364 - _headway_down(oBcInfo, oInternalSchedule.fnGetLpArray(), oParam);  
365 -  
366 - }  
367 -  
368 - _iIterCount ++;  
369 - }  
370 -  
371 - }  
372 -  
373 - return main; 1 +/**
  2 + * 调整某一圈的发车间隔,在已有的间隔上做修正。
  3 + * 1、圈的第一个班次,发车时间固定不变,调整其余班次间隔
  4 + * 2、当前圈一般是副站圈,与邻接的主站班次之间的layovertime太大,调整
  5 + */
  6 +var AdjustHeadwayS2 = (function() {
  7 +
  8 + /**
  9 + * 调整班次发车时间(当前班次和紧领的下一个班次)
  10 + * @param oBcInfo 内部班次对象
  11 + * @param aLp 路牌列表
  12 + * @param iMinute 时间
  13 + * @private
  14 + */
  15 + function _modifyHeadway(oBcInfo, aLp, iMinute) {
  16 + if (!oBcInfo) {
  17 + return;
  18 + }
  19 +
  20 + // 调整班次发车间隔
  21 + var iBcGroupIndex = oBcInfo.iGroupIndex;
  22 + var iBcIndex = oBcInfo.iBcIndex;
  23 + var oLp = aLp[oBcInfo.iLpIndex];
  24 +
  25 + var oBc = oLp.getBc(iBcGroupIndex, iBcIndex);
  26 + var oNextBc = oLp.getBc(
  27 + iBcIndex == 1 ? iBcGroupIndex + 1 : iBcGroupIndex,
  28 + iBcIndex == 0 ? 1 : 0
  29 + );
  30 + if (oBc) {
  31 + oBc.addMinuteToFcsj(iMinute);
  32 +
  33 + oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔
  34 + iBcGroupIndex, iBcIndex,
  35 + oLp.fnGetVerticalIntervalTime(iBcGroupIndex, iBcIndex) + iMinute);
  36 + }
  37 + if (oNextBc) {
  38 + oNextBc.addMinuteToFcsj(iMinute);
  39 + }
  40 + }
  41 +
  42 + /**
  43 + * 从当前班次开始向上尝试减一分钟。
  44 + * @param oBcInfo 内部班次对象
  45 + * @param aLp 路牌列表
  46 + * @param oParam 参数对象
  47 + * @private
  48 + */
  49 + function _headway_up(oBcInfo, aLp, oParam) {
  50 + if (!oBcInfo) {
  51 + return;
  52 + }
  53 +
  54 + // 有班次的路牌索引数组(往下)
  55 + var i;
  56 + var aLpIndex = [];
  57 + for (i = oBcInfo.iLpIndex; i >= 0; i--) {
  58 + if (aLp[i].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex)) {
  59 + aLpIndex.push(i);
  60 + }
  61 + }
  62 +
  63 + // 当前班次与上一个班次之间的间隔列表
  64 + var aHeadWay = [];
  65 + var oHeadWay;
  66 + for (i = 0; i < aLpIndex.length - 1; i++) {
  67 + oHeadWay = {};
  68 + oHeadWay.iStartLpIndex = aLpIndex[i + 1];
  69 + oHeadWay.iEndLpIndex = aLpIndex[i];
  70 + if (oParam.isMPeakBc(aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {
  71 + oHeadWay.bMPeakBc = true;
  72 + } else if (oParam.isEPeakBc(aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {
  73 + oHeadWay.bEPeakBc = true;
  74 + } else {
  75 + oHeadWay.bTroughBc = true;
  76 + }
  77 +
  78 + oHeadWay.iHeadWay = aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj().diff(
  79 + aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj(), "m"
  80 + );
  81 +
  82 + aHeadWay.push(oHeadWay);
  83 + }
  84 +
  85 + // 找出第一个间隔大于最小发车间隔的位置
  86 + // 从当前位置往上到此位置所有班次往前减一分钟
  87 + var bIsFind = false;
  88 + var iFindIndex;
  89 + for (i = 0; i < aHeadWay.length; i++) {
  90 + if (aHeadWay[i].bMPeakBc) { // 早高峰
  91 + if (aHeadWay[i].iHeadWay > oParam.getMPeakMinFcjx()) {
  92 + iFindIndex = i;
  93 + bIsFind = true;
  94 + break;
  95 + }
  96 + } else if (aHeadWay[i].bEPeakBc) { // 晚高峰
  97 + if (aHeadWay[i].iHeadWay > oParam.getEPeakMinFcjx()) {
  98 + iFindIndex = i;
  99 + bIsFind = true;
  100 + break;
  101 + }
  102 + } else { // 低谷
  103 + if (aHeadWay[i].iHeadWay > oParam.getTroughMinFcjx()) {
  104 + iFindIndex = i;
  105 + bIsFind = true;
  106 + break;
  107 + }
  108 + }
  109 + }
  110 +
  111 + if (!bIsFind) {
  112 + return;
  113 + }
  114 +
  115 + // 调整间隔
  116 + var _oBcInfo;
  117 + for (i = 0; i < iFindIndex; i++) {
  118 + _oBcInfo = {};
  119 + _oBcInfo.iLpIndex = aHeadWay[i].iStartLpIndex;
  120 + _oBcInfo.iGroupIndex = oBcInfo.iGroupIndex;
  121 + _oBcInfo.iBcIndex = oBcInfo.iBcIndex;
  122 + _modifyHeadway(_oBcInfo, aLp, -1);
  123 + }
  124 +
  125 + }
  126 +
  127 + /**
  128 + * 从当前班次开始向下尝试减一分钟。
  129 + * @param oBcInfo 内部班次对象
  130 + * @param aLp 路牌列表
  131 + * @param oParam 参数对象
  132 + * @private
  133 + */
  134 + function _headway_down(oBcInfo, aLp, oParam) {
  135 + if (!oBcInfo) {
  136 + return;
  137 + }
  138 +
  139 + // 有班次的路牌索引数组(往下)
  140 + var i;
  141 + var aLpIndex = [];
  142 + for (i = oBcInfo.iLpIndex; i < aLp.length; i++) {
  143 + if (aLp[i].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex)) {
  144 + aLpIndex.push(i);
  145 + }
  146 + }
  147 +
  148 + // 当前班次与下一个班次之间的间隔列表
  149 + var aHeadWay = [];
  150 + var oHeadWay;
  151 + for (i = 0; i < aLpIndex.length - 1; i++) {
  152 + oHeadWay = {};
  153 + oHeadWay.iStartLpIndex = aLpIndex[i];
  154 + oHeadWay.iEndLpIndex = aLpIndex[i + 1];
  155 + if (oParam.isMPeakBc(aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {
  156 + oHeadWay.bMPeakBc = true;
  157 + } else if (oParam.isEPeakBc(aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj())) {
  158 + oHeadWay.bEPeakBc = true;
  159 + } else {
  160 + oHeadWay.bTroughBc = true;
  161 + }
  162 +
  163 + oHeadWay.iHeadWay = aLp[aLpIndex[i + 1]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj().diff(
  164 + aLp[aLpIndex[i]].getBc(oBcInfo.iGroupIndex, oBcInfo.iBcIndex).getFcTimeObj(), "m"
  165 + );
  166 +
  167 + aHeadWay.push(oHeadWay);
  168 + }
  169 +
  170 + // 找出第一个间隔小于最大发车间隔的位置
  171 + // 从当前位置往下到此位置所有班次往前减一分钟
  172 + var bIsFind = false;
  173 + var iFindIndex;
  174 + for (i = 0; i < aHeadWay.length; i++) {
  175 + if (aHeadWay[i].bMPeakBc) { // 早高峰
  176 + if (aHeadWay[i].iHeadWay < oParam.getMPeakMaxFcjx()) {
  177 + iFindIndex = i;
  178 + bIsFind = true;
  179 + break;
  180 + }
  181 + } else if (aHeadWay[i].bEPeakBc) { // 晚高峰
  182 + if (aHeadWay[i].iHeadWay < oParam.getEPeakMaxFcjx()) {
  183 + iFindIndex = i;
  184 + bIsFind = true;
  185 + break;
  186 + }
  187 + } else { // 低谷
  188 + if (aHeadWay[i].iHeadWay < oParam.getTroughMaxFcjx()) {
  189 + iFindIndex = i;
  190 + bIsFind = true;
  191 + break;
  192 + }
  193 + }
  194 + }
  195 +
  196 + if (!bIsFind) {
  197 + return;
  198 + }
  199 +
  200 + // 调整间隔
  201 + var _oBcInfo;
  202 + for (i = 0; i < iFindIndex; i++) {
  203 + _oBcInfo = {};
  204 + _oBcInfo.iLpIndex = aHeadWay[i].iStartLpIndex;
  205 + _oBcInfo.iGroupIndex = oBcInfo.iGroupIndex;
  206 + _oBcInfo.iBcIndex = oBcInfo.iBcIndex;
  207 + if (_oBcInfo.iLpIndex != oBcInfo.iLpIndex) {
  208 + // 跳过当前班次
  209 + _modifyHeadway(_oBcInfo, aLp, -1);
  210 + }
  211 + }
  212 + }
  213 +
  214 + /**
  215 + * 找出当前圈最大需要修正停站时间的班次对象。
  216 + * @param oInternalSchedule 行车计划
  217 + * @param iCGIndex 圈索引(副站班次圈)
  218 + * @param iCBIndex 班次索引
  219 + * @param iNGIndex 同路牌下一个邻接圈索引(主站班次圈)
  220 + * @param iNBIndex 同路牌下一个邻接班次索引
  221 + * @param fPercent 最大超出百分比
  222 + * @return {*} {路牌索引,圈索引,班次索引}
  223 + * @private
  224 + */
  225 + function _maxMoreLayoverBcInfo(
  226 + oInternalSchedule,
  227 + iCGIndex, iCBIndex,
  228 + iNGIndex, iNBIndex,
  229 + fPercent
  230 + ) {
  231 + var i;
  232 + var oLp;
  233 + var oBc;
  234 + var oNextBc;
  235 + var iMaxLayoverTime;
  236 + var iActualLayoverTime;
  237 + var iActualMaxLayoverTime = 0;
  238 + var iActualMaxLayoverTimeLpIndex;
  239 +
  240 + for (i = 0; i < oInternalSchedule.fnGetLpArray().length; i++) {
  241 + oLp = oInternalSchedule.fnGetLpArray()[i];
  242 + oBc = oLp.getBc(iCGIndex, iCBIndex);
  243 + oNextBc = oLp.getBc(iNGIndex, iNBIndex);
  244 + if (oBc && oNextBc) {
  245 + iMaxLayoverTime = oInternalSchedule._$calcuLayoverTime(
  246 + oBc.getFcTimeObj(), oBc.isUp())[1];
  247 + iActualLayoverTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  248 +
  249 + if (iActualLayoverTime > iMaxLayoverTime &&
  250 + iActualLayoverTime > iMaxLayoverTime * (1 + fPercent) &&
  251 + iActualLayoverTime > iActualMaxLayoverTime
  252 + ) {
  253 + iActualMaxLayoverTime = iActualLayoverTime;
  254 + iActualMaxLayoverTimeLpIndex = i;
  255 + }
  256 + }
  257 + }
  258 +
  259 + if (iActualMaxLayoverTimeLpIndex == undefined) {
  260 + return false;
  261 + } else {
  262 + return {
  263 + iLpIndex: iActualMaxLayoverTimeLpIndex,
  264 + iGroupIndex: iNGIndex, // 主站班次圈索引
  265 + iBcIndex: iNBIndex
  266 + };
  267 + }
  268 + }
  269 +
  270 + /**
  271 + * 计算当前圈是否需要修正layovertime。
  272 + * @param oInternalSchedule 行车计划对象
  273 + * @param iCGIndex 圈索引(副站班次圈)
  274 + * @param iCBIndex 班次索引
  275 + * @param iNGIndex 同路牌下一个邻接圈索引(主站班次圈)
  276 + * @param iNBIndex 同路牌下一个邻接班次索引
  277 + * @param fPercent 最大超出百分比
  278 + * @return {boolean}
  279 + * @private
  280 + */
  281 + function _isNeedModify(
  282 + oInternalSchedule,
  283 + iCGIndex, iCBIndex,
  284 + iNGIndex, iNBIndex,
  285 + fPercent
  286 + ) {
  287 + var i;
  288 + var oLp;
  289 + var oBc;
  290 + var oNextBc;
  291 + var iMaxLayoverTime = 0;
  292 + // 计算当前圈的所有相关班次总最大标准停站时间
  293 + for (i = 0; i < oInternalSchedule.fnGetLpArray().length; i++) {
  294 + oLp = oInternalSchedule.fnGetLpArray()[i];
  295 + oBc = oLp.getBc(iCGIndex, iCBIndex);
  296 + oNextBc = oLp.getBc(iNGIndex, iNBIndex);
  297 + if (oBc && oNextBc) {
  298 + iMaxLayoverTime += oInternalSchedule._$calcuLayoverTime(
  299 + oBc.getFcTimeObj(), oBc.isUp())[1];
  300 + }
  301 + }
  302 +
  303 + var iActualLayoverTime = 0;
  304 + // 计算当前圈的所有相关班次总停站时间
  305 + for (i = 0; i < oInternalSchedule.fnGetLpArray().length; i++) {
  306 + oLp = oInternalSchedule.fnGetLpArray()[i];
  307 + oBc = oLp.getBc(iCGIndex, iCBIndex);
  308 + oNextBc = oLp.getBc(iNGIndex, iNBIndex);
  309 + if (oBc && oNextBc) {
  310 + iActualLayoverTime += oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  311 + }
  312 + }
  313 +
  314 + // console.log("iMaxLayoverTime=" + iMaxLayoverTime);
  315 + // console.log("iActualLayoverTime=" + iActualLayoverTime);
  316 +
  317 + // 判定是否超出指定范围
  318 + if (iActualLayoverTime > iMaxLayoverTime &&
  319 + iActualLayoverTime > iMaxLayoverTime * (1 + fPercent)) {
  320 + return true;
  321 + } else {
  322 + return false;
  323 + }
  324 + }
  325 +
  326 + /**
  327 + * 主函数。
  328 + * @param oInternalSchedule 行车计划
  329 + * @param oParam 参数对象
  330 + * @param iCGIndex 圈索引(副站班次圈)
  331 + * @param iCBIndex 班次索引
  332 + * @param iNGIndex 同路牌下一个邻接圈索引(主站班次圈)
  333 + * @param iNBIndex 同路牌下一个邻接班次索引
  334 + * @param fPercent 最大超出百分比
  335 + */
  336 + function main(
  337 + oInternalSchedule, oParam,
  338 + iCGIndex, iCBIndex,
  339 + iNGIndex, iNBIndex,
  340 + fPercent
  341 + ) {
  342 + var _iIterCount = 0; // 当前迭代次数
  343 + var _iMaxIter = 100; // 最大迭代次数
  344 +
  345 + var oBcInfo; // 内部班次对象
  346 +
  347 + while (_iIterCount <= _iMaxIter) {
  348 +
  349 + // 判定当前圈的layovertime是否超出百分比
  350 + if (_isNeedModify(oInternalSchedule,
  351 + iCGIndex, iCBIndex,
  352 + iNGIndex, iNBIndex, fPercent)) {
  353 + // 找出超出最大的班次对象
  354 + oBcInfo = _maxMoreLayoverBcInfo(
  355 + oInternalSchedule,
  356 + iCGIndex, iCBIndex,
  357 + iNGIndex, iNBIndex, fPercent
  358 + );
  359 + // 尝试向上部分班次逐个调整
  360 + _headway_up(oBcInfo, oInternalSchedule.fnGetLpArray(), oParam);
  361 + // 尝试调整当前班次
  362 + _modifyHeadway(oBcInfo, oInternalSchedule.fnGetLpArray(), -1);
  363 + // 尝试向下部分班次逐个调整
  364 + _headway_down(oBcInfo, oInternalSchedule.fnGetLpArray(), oParam);
  365 +
  366 + }
  367 +
  368 + _iIterCount ++;
  369 + }
  370 +
  371 + }
  372 +
  373 + return main;
374 } ()); 374 } ());
375 \ No newline at end of file 375 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2_2/strategy/headway/AdjustHeadwayS3_eat.js
1 -/**  
2 - * 调整待吃饭班次的发车间隔,从而调整停站时间满足吃饭时间。  
3 - * 1、因为是单向进场,所以班次一定在主站方向上  
4 - * 2、一般吃饭班次都是跨圈的,所以需要把指定方向上的所有班次组成数组参与判定  
5 - */  
6 -var AdjustHeadwayS3_eat = (function() {  
7 -  
8 - /**  
9 - * 获取班次列表。  
10 - * @param oInternalSchedule 行车计划  
11 - * @param oParam 参数对象  
12 - * @param isUp 是否上行  
13 - */  
14 - function _getBcList(oInternalSchedule, oParam, isUp) {  
15 - var aRtnBc = [];  
16 - var oRtnBc = {oBc: null, iBcIndex: -1, lpIndex: 0, groupIndex: 0, bcIndex: 0};  
17 -  
18 - var i;  
19 - var j;  
20 - var aLp = oInternalSchedule.fnGetLpArray();  
21 - var oLp;  
22 - var oBc;  
23 -  
24 - for (j = 0; j < oInternalSchedule._qCount; j++) {  
25 - for (i = 0; i < aLp.length; i++) {  
26 - oLp = aLp[i];  
27 - oBc = oLp.getBc(  
28 - j,  
29 - oInternalSchedule._qIsUp == isUp ? 0 : 1  
30 - );  
31 -  
32 - if (oBc) {  
33 - oRtnBc = {  
34 - "oBc": oBc,  
35 - "lpIndex": i,  
36 - "groupIndex": j,  
37 - "bcIndex": oInternalSchedule._qIsUp == isUp ? 0 : 1  
38 - };  
39 - oRtnBc.iBcIndex = aRtnBc.length;  
40 - aRtnBc.push(oRtnBc);  
41 - }  
42 - }  
43 - }  
44 -  
45 - return aRtnBc;  
46 - }  
47 -  
48 - /**  
49 - * 判定是否是吃饭班次,是否需要调整相关的时间。  
50 - * @param oRtnBc 内部班次对象  
51 - * @param aLp 路牌列表  
52 - */  
53 - function _isNeedModifyLayoverTime(oRtnBc, aLp) {  
54 - var oBc = oRtnBc.oBc; // 当前班次  
55 - var oLp = aLp[oRtnBc.lpIndex]; // 所在路牌  
56 - var oPreBc = oLp.getPreBc(oBc); // 所在路牌前一个相邻班次  
57 -  
58 - if (!oPreBc) { // 如果当前路牌没有之前的班次,不能吃饭,一般不可能的  
59 - return false;  
60 - }  
61 -  
62 - // 发车之前的停站时间(用于吃饭)  
63 - var recoverTime = oBc.getFcTimeObj().diff(oPreBc.getArrTimeObj(), 'm');  
64 - if (recoverTime < 20) { // 小于20分钟,需要调整  
65 - return true;  
66 - } else {  
67 - return false;  
68 - }  
69 -  
70 - }  
71 -  
72 - /**  
73 - * 调整班次发车时间(当前班次和紧领的下一个班次)  
74 - * @param oRtnBc 内部班次对象  
75 - * @param aLp 路牌列表  
76 - * @param iMinute 时间  
77 - * @private  
78 - */  
79 - function _modifyHeadway(oRtnBc, aLp, iMinute) {  
80 - var iBcGroupIndex = oRtnBc.groupIndex;  
81 - var iBcIndex = oRtnBc.bcIndex;  
82 - var oLp = aLp[oRtnBc.lpIndex];  
83 -  
84 - var oBc = oLp.getBc(iBcGroupIndex, iBcIndex);  
85 - var oNextBc = oLp.getBc(  
86 - iBcIndex == 1 ? iBcGroupIndex + 1 : iBcGroupIndex,  
87 - iBcIndex == 0 ? 1 : 0  
88 - );  
89 - if (oBc) {  
90 - oBc.addMinuteToFcsj(iMinute);  
91 -  
92 - oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔  
93 - iBcGroupIndex, iBcIndex,  
94 - oLp.fnGetVerticalIntervalTime(iBcGroupIndex, iBcIndex) + iMinute);  
95 - }  
96 - if (oNextBc) {  
97 - oNextBc.addMinuteToFcsj(iMinute);  
98 - }  
99 - }  
100 -  
101 - /**  
102 - * 从当前班次开始向上尝试加一分钟。  
103 - * @param oRtnBc 内部班次对象  
104 - * @param aRtnBc 内部班次列表  
105 - * @param aLp 路牌列表  
106 - * @param oParam 参数对象  
107 - * @private  
108 - */  
109 - function _headway_up(oRtnBc, aRtnBc, aLp, oParam) {  
110 - var i;  
111 -  
112 - // 当前班次与上一个班次之间的间隔列表  
113 - var aHeadWay = [];  
114 - var oHeadWay;  
115 - for (i = oRtnBc.iBcIndex; i > 0; i--) {  
116 - oHeadWay = {};  
117 - oHeadWay.iStartRtnBcIndex = (i - 1);  
118 - oHeadWay.iEndRtnBcIndex = i;  
119 - if (oParam.isMPeakBc(aRtnBc[i - 1].oBc.getFcTimeObj())) {  
120 - oHeadWay.bMPeakBc = true;  
121 - } else if (oParam.isEPeakBc(aRtnBc[i - 1].oBc.getFcTimeObj())) {  
122 - oHeadWay.bEPeakBc = true;  
123 - } else {  
124 - oHeadWay.bTroughBc = true;  
125 - }  
126 -  
127 - oHeadWay.iHeadWay = aRtnBc[i].oBc.getFcTimeObj().diff(  
128 - aRtnBc[i - 1].oBc.getFcTimeObj(), "m"  
129 - );  
130 -  
131 - aHeadWay.push(oHeadWay);  
132 - }  
133 -  
134 - // 找出第一个间隔小于最大发车间隔的位置  
135 - // 从当前位置往上到此位置所有班次往后加1分钟  
136 - var bIsFind = false;  
137 - var iFindIndex;  
138 - for (i = 0; i < aHeadWay.length; i++) {  
139 - if (aHeadWay[i].bMPeakBc) { // 早高峰  
140 - if (aHeadWay[i].iHeadWay < oParam.getMPeakMaxFcjx()) {  
141 - iFindIndex = i;  
142 - bIsFind = true;  
143 - break;  
144 - }  
145 - } else if (aHeadWay[i].bEPeakBc) { // 晚高峰  
146 - if (aHeadWay[i].iHeadWay < oParam.getEPeakMaxFcjx()) {  
147 - iFindIndex = i;  
148 - bIsFind = true;  
149 - break;  
150 - }  
151 - } else { // 低谷  
152 - if (aHeadWay[i].iHeadWay < oParam.getTroughMaxFcjx()) {  
153 - iFindIndex = i;  
154 - bIsFind = true;  
155 - break;  
156 - }  
157 - }  
158 - }  
159 -  
160 - if (!bIsFind) {  
161 - return;  
162 - }  
163 -  
164 - // 调整间隔  
165 - for (i = 0; i < iFindIndex; i++) {  
166 - _modifyHeadway(aRtnBc[aHeadWay[i].iStartRtnBcIndex], aLp, 1);  
167 - }  
168 -  
169 - }  
170 -  
171 - /**  
172 - * 从当前班次开始向下尝试加一分钟。  
173 - * @param oRtnBc 内部班次对象  
174 - * @param aRtnBc 内部班次列表  
175 - * @param aLp 路牌列表  
176 - * @param oParam 参数对象  
177 - * @private  
178 - */  
179 - function _headway_down(oRtnBc, aRtnBc, aLp, oParam) {  
180 - var i;  
181 -  
182 - // 当前班次与下一个班次之间的间隔列表  
183 - var aHeadWay = [];  
184 - var oHeadWay;  
185 - for (i = oRtnBc.iBcIndex; i < aRtnBc.length - 1; i++) {  
186 - oHeadWay = {};  
187 - oHeadWay.iStartRtnBcIndex = i;  
188 - oHeadWay.iEndRtnBcIndex = i + 1;  
189 - if (oParam.isMPeakBc(aRtnBc[i].oBc.getFcTimeObj())) {  
190 - oHeadWay.bMPeakBc = true;  
191 - } else if (oParam.isEPeakBc(aRtnBc[i].oBc.getFcTimeObj())) {  
192 - oHeadWay.bEPeakBc = true;  
193 - } else {  
194 - oHeadWay.bTroughBc = true;  
195 - }  
196 -  
197 - oHeadWay.iHeadWay = aRtnBc[i + 1].oBc.getFcTimeObj().diff(  
198 - aRtnBc[i].oBc.getFcTimeObj(), "m"  
199 - );  
200 -  
201 - aHeadWay.push(oHeadWay);  
202 - }  
203 -  
204 - // 找出第一个间隔大于最小发车间隔的位置  
205 - // 从当前位置往上到此位置所有班次往后加1分钟  
206 - var bIsFind = false;  
207 - var iFindIndex;  
208 - for (i = 0; i < aHeadWay.length; i++) {  
209 - if (aHeadWay[i].bMPeakBc) { // 早高峰  
210 - if (aHeadWay[i].iHeadWay > oParam.getMPeakMinFcjx()) {  
211 - iFindIndex = i;  
212 - bIsFind = true;  
213 - break;  
214 - }  
215 - } else if (aHeadWay[i].bEPeakBc) { // 晚高峰  
216 - if (aHeadWay[i].iHeadWay > oParam.getEPeakMinFcjx()) {  
217 - iFindIndex = i;  
218 - bIsFind = true;  
219 - break;  
220 - }  
221 - } else { // 低谷  
222 - if (aHeadWay[i].iHeadWay > oParam.getTroughMinFcjx()) {  
223 - iFindIndex = i;  
224 - bIsFind = true;  
225 - break;  
226 - }  
227 - }  
228 - }  
229 -  
230 - if (!bIsFind) {  
231 - return;  
232 - }  
233 -  
234 - // 调整间隔  
235 - for (i = 0; i <= iFindIndex; i++) {  
236 - _modifyHeadway(aRtnBc[aHeadWay[i].iStartRtnBcIndex], aLp, 1);  
237 - }  
238 - }  
239 -  
240 - /**  
241 - * 主函数。  
242 - * @param oInternalSchedule 行车计划  
243 - * @param oParam 参数对象  
244 - */  
245 - function main(  
246 - oInternalSchedule, oParam  
247 - ) {  
248 - var _iIterCount = 0; // 当前迭代次数  
249 - var _iMaxIter = 100; // 最大迭代次数  
250 -  
251 - var i;  
252 - var oRtnBc;  
253 - var oBc;  
254 -  
255 - while (_iIterCount <= _iMaxIter) {  
256 - // 获取主站方向班次列表  
257 - var aRtnBc = _getBcList(  
258 - oInternalSchedule,  
259 - oParam,  
260 - oParam.isUpOneWayStop());  
261 -  
262 - for (i = 0; i < aRtnBc.length; i++) {  
263 - oRtnBc = aRtnBc[i];  
264 - oBc = oRtnBc.oBc;  
265 - if (oBc.fnGetEatTime() > 0) { // 标记了吃饭时间,吃饭班次  
266 - if (_isNeedModifyLayoverTime(oRtnBc, oInternalSchedule.fnGetLpArray())) { // 是否需要调整停站时间满足吃饭  
267 - // 尝试向上部分班次逐个调整  
268 - _headway_up(oRtnBc, aRtnBc, oInternalSchedule.fnGetLpArray(), oParam);  
269 - // 尝试调整本班次,以及向下部分班次逐个调整  
270 - _headway_down(oRtnBc, aRtnBc, oInternalSchedule.fnGetLpArray(), oParam);  
271 -  
272 - break;  
273 - }  
274 - }  
275 - }  
276 -  
277 -  
278 - _iIterCount ++;  
279 - }  
280 -  
281 -  
282 - }  
283 -  
284 - return main;  
285 - 1 +/**
  2 + * 调整待吃饭班次的发车间隔,从而调整停站时间满足吃饭时间。
  3 + * 1、因为是单向进场,所以班次一定在主站方向上
  4 + * 2、一般吃饭班次都是跨圈的,所以需要把指定方向上的所有班次组成数组参与判定
  5 + */
  6 +var AdjustHeadwayS3_eat = (function() {
  7 +
  8 + /**
  9 + * 获取班次列表。
  10 + * @param oInternalSchedule 行车计划
  11 + * @param oParam 参数对象
  12 + * @param isUp 是否上行
  13 + */
  14 + function _getBcList(oInternalSchedule, oParam, isUp) {
  15 + var aRtnBc = [];
  16 + var oRtnBc = {oBc: null, iBcIndex: -1, lpIndex: 0, groupIndex: 0, bcIndex: 0};
  17 +
  18 + var i;
  19 + var j;
  20 + var aLp = oInternalSchedule.fnGetLpArray();
  21 + var oLp;
  22 + var oBc;
  23 +
  24 + for (j = 0; j < oInternalSchedule._qCount; j++) {
  25 + for (i = 0; i < aLp.length; i++) {
  26 + oLp = aLp[i];
  27 + oBc = oLp.getBc(
  28 + j,
  29 + oInternalSchedule._qIsUp == isUp ? 0 : 1
  30 + );
  31 +
  32 + if (oBc) {
  33 + oRtnBc = {
  34 + "oBc": oBc,
  35 + "lpIndex": i,
  36 + "groupIndex": j,
  37 + "bcIndex": oInternalSchedule._qIsUp == isUp ? 0 : 1
  38 + };
  39 + oRtnBc.iBcIndex = aRtnBc.length;
  40 + aRtnBc.push(oRtnBc);
  41 + }
  42 + }
  43 + }
  44 +
  45 + return aRtnBc;
  46 + }
  47 +
  48 + /**
  49 + * 判定是否是吃饭班次,是否需要调整相关的时间。
  50 + * @param oRtnBc 内部班次对象
  51 + * @param aLp 路牌列表
  52 + */
  53 + function _isNeedModifyLayoverTime(oRtnBc, aLp) {
  54 + var oBc = oRtnBc.oBc; // 当前班次
  55 + var oLp = aLp[oRtnBc.lpIndex]; // 所在路牌
  56 + var oPreBc = oLp.getPreBc(oBc); // 所在路牌前一个相邻班次
  57 +
  58 + if (!oPreBc) { // 如果当前路牌没有之前的班次,不能吃饭,一般不可能的
  59 + return false;
  60 + }
  61 +
  62 + // 发车之前的停站时间(用于吃饭)
  63 + var recoverTime = oBc.getFcTimeObj().diff(oPreBc.getArrTimeObj(), 'm');
  64 + if (recoverTime < 20) { // 小于20分钟,需要调整
  65 + return true;
  66 + } else {
  67 + return false;
  68 + }
  69 +
  70 + }
  71 +
  72 + /**
  73 + * 调整班次发车时间(当前班次和紧领的下一个班次)
  74 + * @param oRtnBc 内部班次对象
  75 + * @param aLp 路牌列表
  76 + * @param iMinute 时间
  77 + * @private
  78 + */
  79 + function _modifyHeadway(oRtnBc, aLp, iMinute) {
  80 + var iBcGroupIndex = oRtnBc.groupIndex;
  81 + var iBcIndex = oRtnBc.bcIndex;
  82 + var oLp = aLp[oRtnBc.lpIndex];
  83 +
  84 + var oBc = oLp.getBc(iBcGroupIndex, iBcIndex);
  85 + var oNextBc = oLp.getBc(
  86 + iBcIndex == 1 ? iBcGroupIndex + 1 : iBcGroupIndex,
  87 + iBcIndex == 0 ? 1 : 0
  88 + );
  89 + if (oBc) {
  90 + oBc.addMinuteToFcsj(iMinute);
  91 +
  92 + oLp.fnSetVerticalIntervalTime( // 调整对应的路牌发车间隔
  93 + iBcGroupIndex, iBcIndex,
  94 + oLp.fnGetVerticalIntervalTime(iBcGroupIndex, iBcIndex) + iMinute);
  95 + }
  96 + if (oNextBc) {
  97 + oNextBc.addMinuteToFcsj(iMinute);
  98 + }
  99 + }
  100 +
  101 + /**
  102 + * 从当前班次开始向上尝试加一分钟。
  103 + * @param oRtnBc 内部班次对象
  104 + * @param aRtnBc 内部班次列表
  105 + * @param aLp 路牌列表
  106 + * @param oParam 参数对象
  107 + * @private
  108 + */
  109 + function _headway_up(oRtnBc, aRtnBc, aLp, oParam) {
  110 + var i;
  111 +
  112 + // 当前班次与上一个班次之间的间隔列表
  113 + var aHeadWay = [];
  114 + var oHeadWay;
  115 + for (i = oRtnBc.iBcIndex; i > 0; i--) {
  116 + oHeadWay = {};
  117 + oHeadWay.iStartRtnBcIndex = (i - 1);
  118 + oHeadWay.iEndRtnBcIndex = i;
  119 + if (oParam.isMPeakBc(aRtnBc[i - 1].oBc.getFcTimeObj())) {
  120 + oHeadWay.bMPeakBc = true;
  121 + } else if (oParam.isEPeakBc(aRtnBc[i - 1].oBc.getFcTimeObj())) {
  122 + oHeadWay.bEPeakBc = true;
  123 + } else {
  124 + oHeadWay.bTroughBc = true;
  125 + }
  126 +
  127 + oHeadWay.iHeadWay = aRtnBc[i].oBc.getFcTimeObj().diff(
  128 + aRtnBc[i - 1].oBc.getFcTimeObj(), "m"
  129 + );
  130 +
  131 + aHeadWay.push(oHeadWay);
  132 + }
  133 +
  134 + // 找出第一个间隔小于最大发车间隔的位置
  135 + // 从当前位置往上到此位置所有班次往后加1分钟
  136 + var bIsFind = false;
  137 + var iFindIndex;
  138 + for (i = 0; i < aHeadWay.length; i++) {
  139 + if (aHeadWay[i].bMPeakBc) { // 早高峰
  140 + if (aHeadWay[i].iHeadWay < oParam.getMPeakMaxFcjx()) {
  141 + iFindIndex = i;
  142 + bIsFind = true;
  143 + break;
  144 + }
  145 + } else if (aHeadWay[i].bEPeakBc) { // 晚高峰
  146 + if (aHeadWay[i].iHeadWay < oParam.getEPeakMaxFcjx()) {
  147 + iFindIndex = i;
  148 + bIsFind = true;
  149 + break;
  150 + }
  151 + } else { // 低谷
  152 + if (aHeadWay[i].iHeadWay < oParam.getTroughMaxFcjx()) {
  153 + iFindIndex = i;
  154 + bIsFind = true;
  155 + break;
  156 + }
  157 + }
  158 + }
  159 +
  160 + if (!bIsFind) {
  161 + return;
  162 + }
  163 +
  164 + // 调整间隔
  165 + for (i = 0; i < iFindIndex; i++) {
  166 + _modifyHeadway(aRtnBc[aHeadWay[i].iStartRtnBcIndex], aLp, 1);
  167 + }
  168 +
  169 + }
  170 +
  171 + /**
  172 + * 从当前班次开始向下尝试加一分钟。
  173 + * @param oRtnBc 内部班次对象
  174 + * @param aRtnBc 内部班次列表
  175 + * @param aLp 路牌列表
  176 + * @param oParam 参数对象
  177 + * @private
  178 + */
  179 + function _headway_down(oRtnBc, aRtnBc, aLp, oParam) {
  180 + var i;
  181 +
  182 + // 当前班次与下一个班次之间的间隔列表
  183 + var aHeadWay = [];
  184 + var oHeadWay;
  185 + for (i = oRtnBc.iBcIndex; i < aRtnBc.length - 1; i++) {
  186 + oHeadWay = {};
  187 + oHeadWay.iStartRtnBcIndex = i;
  188 + oHeadWay.iEndRtnBcIndex = i + 1;
  189 + if (oParam.isMPeakBc(aRtnBc[i].oBc.getFcTimeObj())) {
  190 + oHeadWay.bMPeakBc = true;
  191 + } else if (oParam.isEPeakBc(aRtnBc[i].oBc.getFcTimeObj())) {
  192 + oHeadWay.bEPeakBc = true;
  193 + } else {
  194 + oHeadWay.bTroughBc = true;
  195 + }
  196 +
  197 + oHeadWay.iHeadWay = aRtnBc[i + 1].oBc.getFcTimeObj().diff(
  198 + aRtnBc[i].oBc.getFcTimeObj(), "m"
  199 + );
  200 +
  201 + aHeadWay.push(oHeadWay);
  202 + }
  203 +
  204 + // 找出第一个间隔大于最小发车间隔的位置
  205 + // 从当前位置往上到此位置所有班次往后加1分钟
  206 + var bIsFind = false;
  207 + var iFindIndex;
  208 + for (i = 0; i < aHeadWay.length; i++) {
  209 + if (aHeadWay[i].bMPeakBc) { // 早高峰
  210 + if (aHeadWay[i].iHeadWay > oParam.getMPeakMinFcjx()) {
  211 + iFindIndex = i;
  212 + bIsFind = true;
  213 + break;
  214 + }
  215 + } else if (aHeadWay[i].bEPeakBc) { // 晚高峰
  216 + if (aHeadWay[i].iHeadWay > oParam.getEPeakMinFcjx()) {
  217 + iFindIndex = i;
  218 + bIsFind = true;
  219 + break;
  220 + }
  221 + } else { // 低谷
  222 + if (aHeadWay[i].iHeadWay > oParam.getTroughMinFcjx()) {
  223 + iFindIndex = i;
  224 + bIsFind = true;
  225 + break;
  226 + }
  227 + }
  228 + }
  229 +
  230 + if (!bIsFind) {
  231 + return;
  232 + }
  233 +
  234 + // 调整间隔
  235 + for (i = 0; i <= iFindIndex; i++) {
  236 + _modifyHeadway(aRtnBc[aHeadWay[i].iStartRtnBcIndex], aLp, 1);
  237 + }
  238 + }
  239 +
  240 + /**
  241 + * 主函数。
  242 + * @param oInternalSchedule 行车计划
  243 + * @param oParam 参数对象
  244 + */
  245 + function main(
  246 + oInternalSchedule, oParam
  247 + ) {
  248 + var _iIterCount = 0; // 当前迭代次数
  249 + var _iMaxIter = 100; // 最大迭代次数
  250 +
  251 + var i;
  252 + var oRtnBc;
  253 + var oBc;
  254 +
  255 + while (_iIterCount <= _iMaxIter) {
  256 + // 获取主站方向班次列表
  257 + var aRtnBc = _getBcList(
  258 + oInternalSchedule,
  259 + oParam,
  260 + oParam.isUpOneWayStop());
  261 +
  262 + for (i = 0; i < aRtnBc.length; i++) {
  263 + oRtnBc = aRtnBc[i];
  264 + oBc = oRtnBc.oBc;
  265 + if (oBc.fnGetEatTime() > 0) { // 标记了吃饭时间,吃饭班次
  266 + if (_isNeedModifyLayoverTime(oRtnBc, oInternalSchedule.fnGetLpArray())) { // 是否需要调整停站时间满足吃饭
  267 + // 尝试向上部分班次逐个调整
  268 + _headway_up(oRtnBc, aRtnBc, oInternalSchedule.fnGetLpArray(), oParam);
  269 + // 尝试调整本班次,以及向下部分班次逐个调整
  270 + _headway_down(oRtnBc, aRtnBc, oInternalSchedule.fnGetLpArray(), oParam);
  271 +
  272 + break;
  273 + }
  274 + }
  275 + }
  276 +
  277 +
  278 + _iIterCount ++;
  279 + }
  280 +
  281 +
  282 + }
  283 +
  284 + return main;
  285 +
286 } ()); 286 } ());
287 \ No newline at end of file 287 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/basicInfo/deviceInfoManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/queryOption/saOrderOption.js
1 -/**  
2 - * saOrderoption指令,搜索时的排序选项(在搜索时可以使用,通用的)  
3 - * 属性如下:  
4 - * name(必须):控件的名字  
5 - * columns(必须,独立作用域):字段名字列表,格式:[{name:[字段名],desc:[字段描述]}...]  
6 - * ordercolumns(必须,独立作用域):字段排序列表,格式:{order: '字段1,字段2',direction: 'ASC,DESC'}  
7 - */  
8 -angular.module('ScheduleApp').directive(  
9 - 'saOrderoption',  
10 - [  
11 - function() {  
12 - return {  
13 - restrict: 'E',  
14 - templateUrl: '/pages/scheduleApp/module/common/dts2/queryOption/saOrderOptionTemplate.html',  
15 - scope: {  
16 - columns: '=',  
17 - ordercolumns: '='  
18 - },  
19 - controllerAs: '$saOrderOptionCtrl',  
20 - bindToController: true,  
21 - controller: function() {  
22 - var self = this;  
23 -  
24 - // 字段列表是否预载入  
25 - self.$$columns_loaded = false;  
26 - // 字段排序是否预载入  
27 - self.$$ordercolumns_loaded = false;  
28 -  
29 -  
30 - // 每组选项内部数据源  
31 - // 格式:[{column:[选中的字段名],dir:[ASC/DESC]}]  
32 - self.$$selectgroupds = [];  
33 -  
34 - // TODO:选择事件  
35 -  
36 - self.$$select_column_change = function() {  
37 - self.$$refresh_selectgroupds();  
38 - };  
39 -  
40 - self.$$select_dir_change = function() {  
41 - self.$$refresh_selectgroupds();  
42 - };  
43 -  
44 - self.$$add_option_click = function(index) {  
45 - self.$$selectgroupds.splice(index, 0, {  
46 - column: self.columns[0].name,  
47 - dir: "ASC"  
48 - });  
49 - self.$$refresh_selectgroupds();  
50 - };  
51 - self.$$del_option_click = function(index) {  
52 - self.$$selectgroupds.splice(index, 1);  
53 - self.$$refresh_selectgroupds();  
54 - };  
55 -  
56 - // 刷新选项内部数据源  
57 - self.$$refresh_selectgroupds = function() {  
58 - if (!self.$$columns_loaded || !self.$$ordercolumns_loaded || self.columns.length == 0) {  
59 - // 没有载入完成,或者字段列表为空  
60 - return;  
61 - }  
62 -  
63 - if (self.$$selectgroupds.length == 0) { // 默认添加一组排序  
64 - self.$$selectgroupds.push({  
65 - column: self.columns[0].name,  
66 - dir: "ASC"  
67 - });  
68 - }  
69 -  
70 - // 重新计算ordercolumns  
71 -  
72 - var aColumn = [];  
73 - var aDir = [];  
74 - for (var i = 0; i < self.$$selectgroupds.length; i++) {  
75 - aColumn.push(self.$$selectgroupds[i].column);  
76 - aDir.push(self.$$selectgroupds[i].dir);  
77 - }  
78 - if (self.ordercolumns) {  
79 - self.ordercolumns.order = aColumn.join(",");  
80 - self.ordercolumns.direction = aDir.join(",");  
81 - } else {  
82 - self.ordercolumns = {order: aColumn.join(","), direction: aDir.join(",")}  
83 - }  
84 -  
85 - }  
86 - },  
87 - compile: function(tElem, tAttrs) {  
88 - // 获取所有属性,并验证  
89 - var $name_attr = tAttrs['name']; // 控件的名字  
90 - if (!$name_attr) {  
91 - throw "必须有名称属性";  
92 - }  
93 -  
94 - // controlAs名字  
95 - var ctrlAs = '$saOrderOptionCtrl';  
96 -  
97 - // TODO:  
98 -  
99 -  
100 -  
101 - return {  
102 - pre: function(scope, element, attr) {  
103 -  
104 - },  
105 -  
106 - post: function(scope, element, attr) {  
107 -  
108 - //--------------------- 监控属性方法 -------------------//  
109 - // 监控字段名字列表  
110 - scope.$watch(  
111 - function() {  
112 - return scope[ctrlAs].columns;  
113 - },  
114 - function(newValue, oldValue) {  
115 - if (!scope[ctrlAs].$$columns_loaded) {  
116 - // TODO:格式判定以后做,假设格式是对的  
117 -  
118 -  
119 - }  
120 -  
121 - scope[ctrlAs].$$columns_loaded = true;  
122 - scope[ctrlAs].$$refresh_selectgroupds();  
123 - },  
124 - true  
125 - );  
126 - // 监控字段排序列表  
127 - scope.$watch(  
128 - function() {  
129 - return scope[ctrlAs].ordercolumns;  
130 - },  
131 - function(newValue, oldValue) {  
132 - if (!scope[ctrlAs].$$ordercolumns_loaded) {  
133 - if (newValue) {  
134 - var aColumns = []; // 排序的字段  
135 - var aDirs = []; // 排序字段对应的排序方向  
136 -  
137 - if (newValue.order) {  
138 - aColumns = newValue.order.split(",");  
139 - }  
140 - if (newValue.direction) {  
141 - aDirs = newValue.direction.split(",");  
142 - }  
143 -  
144 - for (var i = 0; i < aColumns.length; i++) {  
145 - if (i < aDirs.length) {  
146 - scope[ctrlAs].$$selectgroupds.push({  
147 - column: aColumns[i],  
148 - dir: aDirs[i]  
149 - });  
150 - } else {  
151 - scope[ctrlAs].$$selectgroupds.push({  
152 - column: aColumns[i],  
153 - dir: 'ASC'  
154 - });  
155 - }  
156 - }  
157 - }  
158 - }  
159 - scope[ctrlAs].$$ordercolumns_loaded = true;  
160 - scope[ctrlAs].$$refresh_selectgroupds();  
161 -  
162 - },  
163 - true  
164 - );  
165 - }  
166 -  
167 - };  
168 - }  
169 - };  
170 - }  
171 - ] 1 +/**
  2 + * saOrderoption指令,搜索时的排序选项(在搜索时可以使用,通用的)
  3 + * 属性如下:
  4 + * name(必须):控件的名字
  5 + * columns(必须,独立作用域):字段名字列表,格式:[{name:[字段名],desc:[字段描述]}...]
  6 + * ordercolumns(必须,独立作用域):字段排序列表,格式:{order: '字段1,字段2',direction: 'ASC,DESC'}
  7 + */
  8 +angular.module('ScheduleApp').directive(
  9 + 'saOrderoption',
  10 + [
  11 + function() {
  12 + return {
  13 + restrict: 'E',
  14 + templateUrl: '/pages/scheduleApp/module/common/dts2/queryOption/saOrderOptionTemplate.html',
  15 + scope: {
  16 + columns: '=',
  17 + ordercolumns: '='
  18 + },
  19 + controllerAs: '$saOrderOptionCtrl',
  20 + bindToController: true,
  21 + controller: function() {
  22 + var self = this;
  23 +
  24 + // 字段列表是否预载入
  25 + self.$$columns_loaded = false;
  26 + // 字段排序是否预载入
  27 + self.$$ordercolumns_loaded = false;
  28 +
  29 +
  30 + // 每组选项内部数据源
  31 + // 格式:[{column:[选中的字段名],dir:[ASC/DESC]}]
  32 + self.$$selectgroupds = [];
  33 +
  34 + // TODO:选择事件
  35 +
  36 + self.$$select_column_change = function() {
  37 + self.$$refresh_selectgroupds();
  38 + };
  39 +
  40 + self.$$select_dir_change = function() {
  41 + self.$$refresh_selectgroupds();
  42 + };
  43 +
  44 + self.$$add_option_click = function(index) {
  45 + self.$$selectgroupds.splice(index, 0, {
  46 + column: self.columns[0].name,
  47 + dir: "ASC"
  48 + });
  49 + self.$$refresh_selectgroupds();
  50 + };
  51 + self.$$del_option_click = function(index) {
  52 + self.$$selectgroupds.splice(index, 1);
  53 + self.$$refresh_selectgroupds();
  54 + };
  55 +
  56 + // 刷新选项内部数据源
  57 + self.$$refresh_selectgroupds = function() {
  58 + if (!self.$$columns_loaded || !self.$$ordercolumns_loaded || self.columns.length == 0) {
  59 + // 没有载入完成,或者字段列表为空
  60 + return;
  61 + }
  62 +
  63 + if (self.$$selectgroupds.length == 0) { // 默认添加一组排序
  64 + self.$$selectgroupds.push({
  65 + column: self.columns[0].name,
  66 + dir: "ASC"
  67 + });
  68 + }
  69 +
  70 + // 重新计算ordercolumns
  71 +
  72 + var aColumn = [];
  73 + var aDir = [];
  74 + for (var i = 0; i < self.$$selectgroupds.length; i++) {
  75 + aColumn.push(self.$$selectgroupds[i].column);
  76 + aDir.push(self.$$selectgroupds[i].dir);
  77 + }
  78 + if (self.ordercolumns) {
  79 + self.ordercolumns.order = aColumn.join(",");
  80 + self.ordercolumns.direction = aDir.join(",");
  81 + } else {
  82 + self.ordercolumns = {order: aColumn.join(","), direction: aDir.join(",")}
  83 + }
  84 +
  85 + }
  86 + },
  87 + compile: function(tElem, tAttrs) {
  88 + // 获取所有属性,并验证
  89 + var $name_attr = tAttrs['name']; // 控件的名字
  90 + if (!$name_attr) {
  91 + throw "必须有名称属性";
  92 + }
  93 +
  94 + // controlAs名字
  95 + var ctrlAs = '$saOrderOptionCtrl';
  96 +
  97 + // TODO:
  98 +
  99 +
  100 +
  101 + return {
  102 + pre: function(scope, element, attr) {
  103 +
  104 + },
  105 +
  106 + post: function(scope, element, attr) {
  107 +
  108 + //--------------------- 监控属性方法 -------------------//
  109 + // 监控字段名字列表
  110 + scope.$watch(
  111 + function() {
  112 + return scope[ctrlAs].columns;
  113 + },
  114 + function(newValue, oldValue) {
  115 + if (!scope[ctrlAs].$$columns_loaded) {
  116 + // TODO:格式判定以后做,假设格式是对的
  117 +
  118 +
  119 + }
  120 +
  121 + scope[ctrlAs].$$columns_loaded = true;
  122 + scope[ctrlAs].$$refresh_selectgroupds();
  123 + },
  124 + true
  125 + );
  126 + // 监控字段排序列表
  127 + scope.$watch(
  128 + function() {
  129 + return scope[ctrlAs].ordercolumns;
  130 + },
  131 + function(newValue, oldValue) {
  132 + if (!scope[ctrlAs].$$ordercolumns_loaded) {
  133 + if (newValue) {
  134 + var aColumns = []; // 排序的字段
  135 + var aDirs = []; // 排序字段对应的排序方向
  136 +
  137 + if (newValue.order) {
  138 + aColumns = newValue.order.split(",");
  139 + }
  140 + if (newValue.direction) {
  141 + aDirs = newValue.direction.split(",");
  142 + }
  143 +
  144 + for (var i = 0; i < aColumns.length; i++) {
  145 + if (i < aDirs.length) {
  146 + scope[ctrlAs].$$selectgroupds.push({
  147 + column: aColumns[i],
  148 + dir: aDirs[i]
  149 + });
  150 + } else {
  151 + scope[ctrlAs].$$selectgroupds.push({
  152 + column: aColumns[i],
  153 + dir: 'ASC'
  154 + });
  155 + }
  156 + }
  157 + }
  158 + }
  159 + scope[ctrlAs].$$ordercolumns_loaded = true;
  160 + scope[ctrlAs].$$refresh_selectgroupds();
  161 +
  162 + },
  163 + true
  164 + );
  165 + }
  166 +
  167 + };
  168 + }
  169 + };
  170 + }
  171 + ]
172 ); 172 );
173 \ No newline at end of file 173 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/queryOption/saOrderOptionTemplate.html
1 -<style>  
2 - .option_panel {  
3 - height: 100%;  
4 - margin: 0;  
5 - padding: 0;  
6 - }  
7 - .option_panel .detail-wrap {  
8 - padding: 0;  
9 - max-height: 300px;  
10 - border: 1px solid #ddd;  
11 - background: #fafafa;  
12 - border-radius: 10px !important;  
13 - moz-user-select: -moz-none;  
14 - -moz-user-select: none;  
15 - -o-user-select: none;  
16 - -khtml-user-select: none;  
17 - -webkit-user-select: none;  
18 - -ms-user-select: none;  
19 - user-select: none;  
20 - overflow: auto;  
21 - }  
22 -  
23 - .option_panel .detail-wrap > .option {  
24 - margin-top: 5px;  
25 - }  
26 -  
27 - .option_panel .detail-wrap > .option:nth-last-child(1) {  
28 - margin-bottom: 5px;  
29 - }  
30 -  
31 - .option_panel .detail-wrap > .option .option_column {  
32 - padding-left: 3px;  
33 - padding-right: 5px;  
34 - }  
35 - .option_panel .detail-wrap > .option .option_dir {  
36 - padding-left: 0px;  
37 - padding-right: 5px;  
38 - }  
39 - .option_panel .detail-wrap > .option .option_opt {  
40 - width: 70px;  
41 - padding-left: 0px;  
42 - padding-right: 0px;  
43 - }  
44 -  
45 - .option_panel .detail-wrap .option .form-control {  
46 - font-size: 10px;  
47 - }  
48 -  
49 -  
50 - .option_scrollbar::-webkit-scrollbar {  
51 - width: 18px;  
52 - height: 18px;  
53 - }  
54 -  
55 - .option_scrollbar::-webkit-scrollbar-track, ::-webkit-scrollbar-thumb {  
56 - border-radius: 999px;  
57 - border: 5px solid transparent;  
58 - }  
59 -  
60 - .option_scrollbar::-webkit-scrollbar-track {  
61 - box-shadow: 1px 1px 5px rgba(0, 0, 0, .2) inset;  
62 - }  
63 -  
64 - .option_scrollbar::-webkit-scrollbar-thumb {  
65 - min-height: 20px;  
66 - background-clip: content-box;  
67 - box-shadow: 0 0 0 5px rgba(0, 0, 0, .2) inset;  
68 - }  
69 -  
70 - .option_scrollbar::-webkit-scrollbar-corner {  
71 - background: transparent;  
72 - }  
73 -  
74 -</style>  
75 -  
76 -<div>  
77 - <div class="option_panel">  
78 - <div class="detail-wrap option_scrollbar">  
79 -  
80 - <div class="col-md-12 option" ng-repeat="$option in $saOrderOptionCtrl.$$selectgroupds track by $index" ng-init="rowIndex = $index">  
81 - <div class="col-md-5 option_column">  
82 - <select class="form-control aria-invalid="false" ng-model="$option.column" ng-change="$saOrderOptionCtrl.$$select_column_change()">  
83 - <option ng-repeat="$column in $saOrderOptionCtrl.columns track by $index"  
84 - ng-init="colIndex = $index"  
85 - ng-selected="$option.column==$column.name"  
86 - value="{{$column.name}}">  
87 - {{$column.desc}}  
88 - </option>  
89 - </select>  
90 - </div>  
91 - <div class="col-md-3 option_dir">  
92 - <select class="form-control aria-invalid="false" ng-model="$option.dir" ng-change="$saOrderOptionCtrl.$$select_dir_change()">  
93 - <option value="ASC" ng-selected="$option.dir=='ASC'">升序</option>  
94 - <option value="DESC" ng-selected="$option.dir=='DESC'">降序</option>  
95 - </select>  
96 - </div>  
97 - <div class="col-md-3 btn-group option_opt">  
98 - <button type="button" class="btn btn-default" ng-click="$saOrderOptionCtrl.$$add_option_click(rowIndex)">+</button>  
99 - <button type="button" class="btn btn-default" ng-click="$saOrderOptionCtrl.$$del_option_click(rowIndex)">-</button>  
100 - </div>  
101 -  
102 - </div>  
103 -  
104 -  
105 - </div>  
106 -  
107 -  
108 - </div>  
109 - 1 +<style>
  2 + .option_panel {
  3 + height: 100%;
  4 + margin: 0;
  5 + padding: 0;
  6 + }
  7 + .option_panel .detail-wrap {
  8 + padding: 0;
  9 + max-height: 300px;
  10 + border: 1px solid #ddd;
  11 + background: #fafafa;
  12 + border-radius: 10px !important;
  13 + moz-user-select: -moz-none;
  14 + -moz-user-select: none;
  15 + -o-user-select: none;
  16 + -khtml-user-select: none;
  17 + -webkit-user-select: none;
  18 + -ms-user-select: none;
  19 + user-select: none;
  20 + overflow: auto;
  21 + }
  22 +
  23 + .option_panel .detail-wrap > .option {
  24 + margin-top: 5px;
  25 + }
  26 +
  27 + .option_panel .detail-wrap > .option:nth-last-child(1) {
  28 + margin-bottom: 5px;
  29 + }
  30 +
  31 + .option_panel .detail-wrap > .option .option_column {
  32 + padding-left: 3px;
  33 + padding-right: 5px;
  34 + }
  35 + .option_panel .detail-wrap > .option .option_dir {
  36 + padding-left: 0px;
  37 + padding-right: 5px;
  38 + }
  39 + .option_panel .detail-wrap > .option .option_opt {
  40 + width: 70px;
  41 + padding-left: 0px;
  42 + padding-right: 0px;
  43 + }
  44 +
  45 + .option_panel .detail-wrap .option .form-control {
  46 + font-size: 10px;
  47 + }
  48 +
  49 +
  50 + .option_scrollbar::-webkit-scrollbar {
  51 + width: 18px;
  52 + height: 18px;
  53 + }
  54 +
  55 + .option_scrollbar::-webkit-scrollbar-track, ::-webkit-scrollbar-thumb {
  56 + border-radius: 999px;
  57 + border: 5px solid transparent;
  58 + }
  59 +
  60 + .option_scrollbar::-webkit-scrollbar-track {
  61 + box-shadow: 1px 1px 5px rgba(0, 0, 0, .2) inset;
  62 + }
  63 +
  64 + .option_scrollbar::-webkit-scrollbar-thumb {
  65 + min-height: 20px;
  66 + background-clip: content-box;
  67 + box-shadow: 0 0 0 5px rgba(0, 0, 0, .2) inset;
  68 + }
  69 +
  70 + .option_scrollbar::-webkit-scrollbar-corner {
  71 + background: transparent;
  72 + }
  73 +
  74 +</style>
  75 +
  76 +<div>
  77 + <div class="option_panel">
  78 + <div class="detail-wrap option_scrollbar">
  79 +
  80 + <div class="col-md-12 option" ng-repeat="$option in $saOrderOptionCtrl.$$selectgroupds track by $index" ng-init="rowIndex = $index">
  81 + <div class="col-md-5 option_column">
  82 + <select class="form-control aria-invalid="false" ng-model="$option.column" ng-change="$saOrderOptionCtrl.$$select_column_change()">
  83 + <option ng-repeat="$column in $saOrderOptionCtrl.columns track by $index"
  84 + ng-init="colIndex = $index"
  85 + ng-selected="$option.column==$column.name"
  86 + value="{{$column.name}}">
  87 + {{$column.desc}}
  88 + </option>
  89 + </select>
  90 + </div>
  91 + <div class="col-md-3 option_dir">
  92 + <select class="form-control aria-invalid="false" ng-model="$option.dir" ng-change="$saOrderOptionCtrl.$$select_dir_change()">
  93 + <option value="ASC" ng-selected="$option.dir=='ASC'">升序</option>
  94 + <option value="DESC" ng-selected="$option.dir=='DESC'">降序</option>
  95 + </select>
  96 + </div>
  97 + <div class="col-md-3 btn-group option_opt">
  98 + <button type="button" class="btn btn-default" ng-click="$saOrderOptionCtrl.$$add_option_click(rowIndex)">+</button>
  99 + <button type="button" class="btn btn-default" ng-click="$saOrderOptionCtrl.$$del_option_click(rowIndex)">-</button>
  100 + </div>
  101 +
  102 + </div>
  103 +
  104 +
  105 + </div>
  106 +
  107 +
  108 + </div>
  109 +
110 </div> 110 </div>
111 \ No newline at end of file 111 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saSrule.js
1 -/**  
2 - * saSrule指令(非通用指令,只在排班计划form中使用)。  
3 - * 属性如下:  
4 - * name(必须):控件的名字  
5 - * xlid(必须):线路id  
6 - * from(必须):独立作用域-绑定的开始时间属性名  
7 - * to(必须):独立作用域-绑定的结束时间属性名  
8 - * error(必须):独立作用域-绑定的错误描述属性名  
9 - */  
10 -angular.module('ScheduleApp').directive(  
11 - 'saSrule',  
12 - [  
13 - 'SchedulePlanManageService_g',  
14 - function(service) {  
15 - return {  
16 - restrict: 'E',  
17 - templateUrl: '/pages/scheduleApp/module/common/dts2/scheduleplan/saSruleTemplate.html',  
18 - scope: {  
19 - from: '=',  
20 - to: '=',  
21 - xlid: '=',  
22 - error: '='  
23 - },  
24 - controllerAs: '$saSruleCtrl',  
25 - bindToController: true,  
26 - controller: function() {  
27 - var self = this;  
28 -  
29 - // 内部ng-model值,用于和required配对  
30 - self.$$internalmodel = undefined;  
31 -  
32 - // 内部数据源(时刻表的一些信息)  
33 - self.$$count = 0;  
34 - self.$$qyCount = 0;  
35 - self.$$qyErrorCount = 0;  
36 - self.$$errorInfos = [];  
37 -  
38 - },  
39 - compile: function(tElem, tAttrs) {  
40 - // 获取所有属性,并验证  
41 - var $name_attr = tAttrs['name']; // 控件的名字  
42 - if (!$name_attr) {  
43 - throw "必须有名称属性";  
44 - }  
45 -  
46 - // controlAs名字  
47 - var ctrlAs = '$saSruleCtrl';  
48 -  
49 - // 线路id  
50 - var xl_id = undefined;  
51 - // 开始时间  
52 - var from_date = undefined;  
53 - // 结束时间  
54 - var to_date = undefined;  
55 -  
56 - // 内部添加required验证,将所有的错误应用到required验证上去  
57 - tElem.find("div").attr("required", "");  
58 -  
59 - return {  
60 - pre: function(scope, element, attr) {  
61 -  
62 - },  
63 -  
64 - post: function(scope, element, attr) {  
65 - // 属性值  
66 - if ($name_attr) {  
67 - scope[ctrlAs]["$name_attr"] = $name_attr;  
68 - }  
69 -  
70 - // 开始日期open属性,及方法  
71 - scope[ctrlAs].$$fromDateOpen = false;  
72 - scope[ctrlAs].$$fromDate_open = function() {  
73 - scope[ctrlAs].$$fromDateOpen = true;  
74 - };  
75 -  
76 - // 结束日期open属性,及方法  
77 - scope[ctrlAs].$$toDateOpen = false;  
78 - scope[ctrlAs].$$toDate_open = function() {  
79 - scope[ctrlAs].$$toDateOpen = true;  
80 - };  
81 -  
82 - // 内部模型刷新  
83 - scope[ctrlAs].$$internal_model_refresh = function() {  
84 - if (!xl_id) {  
85 - scope[ctrlAs].$$internalmodel = undefined;  
86 - scope[ctrlAs].error = "线路必须选择";  
87 - return;  
88 - }  
89 - if (!from_date) {  
90 - scope[ctrlAs].$$internalmodel = undefined;  
91 - scope[ctrlAs].error = "开始日期必须选择";  
92 - return;  
93 - }  
94 - if (!to_date) {  
95 - scope[ctrlAs].$$internalmodel = undefined;  
96 - scope[ctrlAs].error = "结束日期必须选择";  
97 - return;  
98 - }  
99 - if (from_date > to_date) {  
100 - scope[ctrlAs].$$internalmodel = undefined;  
101 - scope[ctrlAs].error = "开始日期必须在结束日期之前";  
102 - return;  
103 - }  
104 -  
105 - scope[ctrlAs].$$count = 0;  
106 - scope[ctrlAs].$$qyCount = 0;  
107 - scope[ctrlAs].$$qyErrorCount = 0;  
108 - scope[ctrlAs].$$errorInfos = [];  
109 -  
110 - if (scope[ctrlAs].$$qyCount == 0) {  
111 - scope[ctrlAs].$$internalmodel = undefined;  
112 - scope[ctrlAs].error = "无可启用的规则数";  
113 - }  
114 -  
115 - var QClass = service.v_rules;  
116 - QClass.val({xlid: xl_id, from: from_date, to: to_date},  
117 - function(result) {  
118 - scope[ctrlAs].$$count = result.data.count;  
119 - scope[ctrlAs].$$qyCount = result.data.qyCount;  
120 - scope[ctrlAs].$$qyErrorCount = result.data.qyErrorCount;  
121 -  
122 - angular.forEach(result.data.errorInfos, function(obj) {  
123 - scope[ctrlAs].$$errorInfos.push({  
124 - ruleId: obj.ruleId,  
125 - clZbh: obj.clZbh,  
126 - qyrq: moment(obj.qyrq).format("YYYY年MM月DD日"),  
127 - infos: obj.errorDescList.join("")  
128 - });  
129 - });  
130 -  
131 - if (scope[ctrlAs].$$qyErrorCount > 0) {  
132 - scope[ctrlAs].$$internalmodel = undefined;  
133 - scope[ctrlAs].error = "有错误的规则";  
134 - } else {  
135 - scope[ctrlAs].$$internalmodel = "ok";  
136 - scope[ctrlAs].$$errorInfos = [];  
137 - }  
138 - },  
139 - function() {  
140 - scope[ctrlAs].$$internalmodel = undefined;  
141 - scope[ctrlAs].error = "获取规则数据失败!";  
142 - }  
143 - );  
144 -  
145 - scope[ctrlAs].$$internalmodel = "ok";  
146 - };  
147 -  
148 - scope[ctrlAs].$$internal_model_refresh(); // 初始执行  
149 -  
150 - //--------------------- 监控属性方法 -------------------//  
151 - // 监控线路id模型值变化  
152 - scope.$watch(  
153 - function() {  
154 - return scope[ctrlAs].xlid;  
155 - },  
156 - function(newValue, oldValue) {  
157 - xl_id = newValue;  
158 - scope[ctrlAs].$$internal_model_refresh();  
159 - }  
160 - );  
161 -  
162 - // 监控开始时间模型值变化  
163 - scope.$watch(  
164 - function() {  
165 - return scope[ctrlAs].from;  
166 - },  
167 - function(newValue, oldValue) {  
168 - from_date = newValue;  
169 - scope[ctrlAs].$$internal_model_refresh();  
170 - }  
171 - );  
172 - // 监控结束时间模型值变化  
173 - scope.$watch(  
174 - function() {  
175 - return scope[ctrlAs].to;  
176 - },  
177 - function(newValue, oldValue) {  
178 - to_date = newValue;  
179 - scope[ctrlAs].$$internal_model_refresh();  
180 - }  
181 - );  
182 - }  
183 - };  
184 - }  
185 - };  
186 - }  
187 - ] 1 +/**
  2 + * saSrule指令(非通用指令,只在排班计划form中使用)。
  3 + * 属性如下:
  4 + * name(必须):控件的名字
  5 + * xlid(必须):线路id
  6 + * from(必须):独立作用域-绑定的开始时间属性名
  7 + * to(必须):独立作用域-绑定的结束时间属性名
  8 + * error(必须):独立作用域-绑定的错误描述属性名
  9 + */
  10 +angular.module('ScheduleApp').directive(
  11 + 'saSrule',
  12 + [
  13 + 'SchedulePlanManageService_g',
  14 + function(service) {
  15 + return {
  16 + restrict: 'E',
  17 + templateUrl: '/pages/scheduleApp/module/common/dts2/scheduleplan/saSruleTemplate.html',
  18 + scope: {
  19 + from: '=',
  20 + to: '=',
  21 + xlid: '=',
  22 + error: '='
  23 + },
  24 + controllerAs: '$saSruleCtrl',
  25 + bindToController: true,
  26 + controller: function() {
  27 + var self = this;
  28 +
  29 + // 内部ng-model值,用于和required配对
  30 + self.$$internalmodel = undefined;
  31 +
  32 + // 内部数据源(时刻表的一些信息)
  33 + self.$$count = 0;
  34 + self.$$qyCount = 0;
  35 + self.$$qyErrorCount = 0;
  36 + self.$$errorInfos = [];
  37 +
  38 + },
  39 + compile: function(tElem, tAttrs) {
  40 + // 获取所有属性,并验证
  41 + var $name_attr = tAttrs['name']; // 控件的名字
  42 + if (!$name_attr) {
  43 + throw "必须有名称属性";
  44 + }
  45 +
  46 + // controlAs名字
  47 + var ctrlAs = '$saSruleCtrl';
  48 +
  49 + // 线路id
  50 + var xl_id = undefined;
  51 + // 开始时间
  52 + var from_date = undefined;
  53 + // 结束时间
  54 + var to_date = undefined;
  55 +
  56 + // 内部添加required验证,将所有的错误应用到required验证上去
  57 + tElem.find("div").attr("required", "");
  58 +
  59 + return {
  60 + pre: function(scope, element, attr) {
  61 +
  62 + },
  63 +
  64 + post: function(scope, element, attr) {
  65 + // 属性值
  66 + if ($name_attr) {
  67 + scope[ctrlAs]["$name_attr"] = $name_attr;
  68 + }
  69 +
  70 + // 开始日期open属性,及方法
  71 + scope[ctrlAs].$$fromDateOpen = false;
  72 + scope[ctrlAs].$$fromDate_open = function() {
  73 + scope[ctrlAs].$$fromDateOpen = true;
  74 + };
  75 +
  76 + // 结束日期open属性,及方法
  77 + scope[ctrlAs].$$toDateOpen = false;
  78 + scope[ctrlAs].$$toDate_open = function() {
  79 + scope[ctrlAs].$$toDateOpen = true;
  80 + };
  81 +
  82 + // 内部模型刷新
  83 + scope[ctrlAs].$$internal_model_refresh = function() {
  84 + if (!xl_id) {
  85 + scope[ctrlAs].$$internalmodel = undefined;
  86 + scope[ctrlAs].error = "线路必须选择";
  87 + return;
  88 + }
  89 + if (!from_date) {
  90 + scope[ctrlAs].$$internalmodel = undefined;
  91 + scope[ctrlAs].error = "开始日期必须选择";
  92 + return;
  93 + }
  94 + if (!to_date) {
  95 + scope[ctrlAs].$$internalmodel = undefined;
  96 + scope[ctrlAs].error = "结束日期必须选择";
  97 + return;
  98 + }
  99 + if (from_date > to_date) {
  100 + scope[ctrlAs].$$internalmodel = undefined;
  101 + scope[ctrlAs].error = "开始日期必须在结束日期之前";
  102 + return;
  103 + }
  104 +
  105 + scope[ctrlAs].$$count = 0;
  106 + scope[ctrlAs].$$qyCount = 0;
  107 + scope[ctrlAs].$$qyErrorCount = 0;
  108 + scope[ctrlAs].$$errorInfos = [];
  109 +
  110 + if (scope[ctrlAs].$$qyCount == 0) {
  111 + scope[ctrlAs].$$internalmodel = undefined;
  112 + scope[ctrlAs].error = "无可启用的规则数";
  113 + }
  114 +
  115 + var QClass = service.v_rules;
  116 + QClass.val({xlid: xl_id, from: from_date, to: to_date},
  117 + function(result) {
  118 + scope[ctrlAs].$$count = result.data.count;
  119 + scope[ctrlAs].$$qyCount = result.data.qyCount;
  120 + scope[ctrlAs].$$qyErrorCount = result.data.qyErrorCount;
  121 +
  122 + angular.forEach(result.data.errorInfos, function(obj) {
  123 + scope[ctrlAs].$$errorInfos.push({
  124 + ruleId: obj.ruleId,
  125 + clZbh: obj.clZbh,
  126 + qyrq: moment(obj.qyrq).format("YYYY年MM月DD日"),
  127 + infos: obj.errorDescList.join("")
  128 + });
  129 + });
  130 +
  131 + if (scope[ctrlAs].$$qyErrorCount > 0) {
  132 + scope[ctrlAs].$$internalmodel = undefined;
  133 + scope[ctrlAs].error = "有错误的规则";
  134 + } else {
  135 + scope[ctrlAs].$$internalmodel = "ok";
  136 + scope[ctrlAs].$$errorInfos = [];
  137 + }
  138 + },
  139 + function() {
  140 + scope[ctrlAs].$$internalmodel = undefined;
  141 + scope[ctrlAs].error = "获取规则数据失败!";
  142 + }
  143 + );
  144 +
  145 + scope[ctrlAs].$$internalmodel = "ok";
  146 + };
  147 +
  148 + scope[ctrlAs].$$internal_model_refresh(); // 初始执行
  149 +
  150 + //--------------------- 监控属性方法 -------------------//
  151 + // 监控线路id模型值变化
  152 + scope.$watch(
  153 + function() {
  154 + return scope[ctrlAs].xlid;
  155 + },
  156 + function(newValue, oldValue) {
  157 + xl_id = newValue;
  158 + scope[ctrlAs].$$internal_model_refresh();
  159 + }
  160 + );
  161 +
  162 + // 监控开始时间模型值变化
  163 + scope.$watch(
  164 + function() {
  165 + return scope[ctrlAs].from;
  166 + },
  167 + function(newValue, oldValue) {
  168 + from_date = newValue;
  169 + scope[ctrlAs].$$internal_model_refresh();
  170 + }
  171 + );
  172 + // 监控结束时间模型值变化
  173 + scope.$watch(
  174 + function() {
  175 + return scope[ctrlAs].to;
  176 + },
  177 + function(newValue, oldValue) {
  178 + to_date = newValue;
  179 + scope[ctrlAs].$$internal_model_refresh();
  180 + }
  181 + );
  182 + }
  183 + };
  184 + }
  185 + };
  186 + }
  187 + ]
188 ); 188 );
189 \ No newline at end of file 189 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saSruleTemplate.html
1 -<div name="{{$saSruleCtrl.$name_attr}}" ng-model="$saSruleCtrl.$$internalmodel">  
2 - <style>  
3 - .s-rule-select {  
4 - min-height: 180px;  
5 - border: 1px solid #ddd;  
6 - }  
7 - .s-rule-select .s-rule-input {  
8 - margin: 0px 5px 5px 5px;  
9 - padding-top: 7px;  
10 - padding-left: 0;  
11 - }  
12 - .s-rule-select .s-rule-select-cont {  
13 - text-align: left;  
14 - min-height: 100px;  
15 - padding-right: 0px;  
16 - }  
17 - .s-rule-select .s-rule-select-body {  
18 - margin-top: 10px;  
19 - overflow: auto;  
20 - width: auto;  
21 - min-height: 100px;  
22 - }  
23 -  
24 -  
25 - </style>  
26 -  
27 -  
28 - <div class="col-md-12 s-rule-select">  
29 - <div class="col-md-12 s-rule-input">  
30 - <div class="col-md-12">  
31 - 总规则{{$saSruleCtrl.$$count}}条,启用规则{{$saSruleCtrl.$$qyCount}}条,错误规则{{$saSruleCtrl.$$qyErrorCount}}条  
32 - </div>  
33 - </div>  
34 - <div class="col-md-12 s-rule-select-cont">  
35 - <div class="s-rule-select-body">  
36 -  
37 - <div ng-repeat="info in $saSruleCtrl.$$errorInfos track by $index">  
38 - <a ui-sref="scheduleRuleManage_edit({id: info.ruleId})">  
39 - {{info.clZbh}},{{info.qyrq}},{{info.infos}}  
40 - </a>  
41 -  
42 - </div>  
43 -  
44 - </div>  
45 - </div>  
46 - </div>  
47 - 1 +<div name="{{$saSruleCtrl.$name_attr}}" ng-model="$saSruleCtrl.$$internalmodel">
  2 + <style>
  3 + .s-rule-select {
  4 + min-height: 180px;
  5 + border: 1px solid #ddd;
  6 + }
  7 + .s-rule-select .s-rule-input {
  8 + margin: 0px 5px 5px 5px;
  9 + padding-top: 7px;
  10 + padding-left: 0;
  11 + }
  12 + .s-rule-select .s-rule-select-cont {
  13 + text-align: left;
  14 + min-height: 100px;
  15 + padding-right: 0px;
  16 + }
  17 + .s-rule-select .s-rule-select-body {
  18 + margin-top: 10px;
  19 + overflow: auto;
  20 + width: auto;
  21 + min-height: 100px;
  22 + }
  23 +
  24 +
  25 + </style>
  26 +
  27 +
  28 + <div class="col-md-12 s-rule-select">
  29 + <div class="col-md-12 s-rule-input">
  30 + <div class="col-md-12">
  31 + 总规则{{$saSruleCtrl.$$count}}条,启用规则{{$saSruleCtrl.$$qyCount}}条,错误规则{{$saSruleCtrl.$$qyErrorCount}}条
  32 + </div>
  33 + </div>
  34 + <div class="col-md-12 s-rule-select-cont">
  35 + <div class="s-rule-select-body">
  36 +
  37 + <div ng-repeat="info in $saSruleCtrl.$$errorInfos track by $index">
  38 + <a ui-sref="scheduleRuleManage_edit({id: info.ruleId})">
  39 + {{info.clZbh}},{{info.qyrq}},{{info.infos}}
  40 + </a>
  41 +
  42 + </div>
  43 +
  44 + </div>
  45 + </div>
  46 + </div>
  47 +
48 </div> 48 </div>
49 \ No newline at end of file 49 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/busConfig/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/employeeConfig/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/guideboardManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/rerunManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/scheduleRuleManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage2/orderOptionOpen.html
1 -<div class="modal-header">  
2 - <div class="modal-title">  
3 - <h3>  
4 - <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>  
5 - <span class="caption-subject bold uppercase">排序字段选择</span>  
6 - </h3>  
7 - </div>  
8 -</div>  
9 -<div class="modal-body">  
10 - <!--order={{$ctrl.orderColumns.order}}-->  
11 - <!--<br>-->  
12 - <!--direction={{$ctrl.orderColumns.direction}}-->  
13 - <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">  
14 - </sa-Orderoption>  
15 -</div>  
16 -<div class="modal-footer">  
17 - <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button> 1 +<div class="modal-header">
  2 + <div class="modal-title">
  3 + <h3>
  4 + <i class="fa fa-sort-amount-asc" aria-hidden="true"></i>
  5 + <span class="caption-subject bold uppercase">排序字段选择</span>
  6 + </h3>
  7 + </div>
  8 +</div>
  9 +<div class="modal-body">
  10 + <!--order={{$ctrl.orderColumns.order}}-->
  11 + <!--<br>-->
  12 + <!--direction={{$ctrl.orderColumns.direction}}-->
  13 + <sa-Orderoption name="orderOptions" columns="$ctrl.columns" ordercolumns="$ctrl.orderColumns">
  14 + </sa-Orderoption>
  15 +</div>
  16 +<div class="modal-footer">
  17 + <button class="btn btn-primary" ng-click="$ctrl.confirm($ctrl.orderColumns)">确定</button>
18 </div> 18 </div>
19 \ No newline at end of file 19 \ No newline at end of file