Commit 12ab2d8de4020f40104c09bd4a54b60e365fed4f

Authored by 徐烜
1 parent 55bc42ec

时刻表数据带线路版本v2

1、修改导入时的判定,全部要带版本,选择当前也要差当前版本号
2、修改导入时的判定逻辑,带线路版本,excel里站点名使用正则表达式->{数字}过滤,站点名不用like用eq
3、修改导入ktr,站点名过滤的正则表达式修改为 /->\d+/g,明细数据插入时带版本
4、修改导出ktr,站点名后加->{数字}
5、修改导入ktr的文件名,并修改相应的配置类
6、修改相关的前端页面及js

Too many changes to show.

To preserve performance only 7 of 14 files are displayed.

src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController.java
... ... @@ -32,30 +32,18 @@ public class TTInfoDetailController extends BController<TTInfoDetail, Long> {
32 32 * @param sheetname sheet名字
33 33 * @param lineid 线路id
34 34 * @param linename 线路名称
  35 + * @param lineversion 线路版本
35 36 * @return
36 37 */
37 38 @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST)
38 39 public Map<String, Object> validate_sheet(
39   - String filename, String sheetname, Integer lineid, String linename,
40   - Integer zdlytype, Integer zdlyversion) {
  40 + String filename, String sheetname, Integer lineid, String linename, Integer lineversion) {
41 41 Map<String, Object> rtn = new HashMap<>();
42 42 try {
43   - if (zdlytype == null) {
44   - throw new Exception("请选择路由版本类型");
45   - } else {
46   - if (zdlytype == 1) {
47   - ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename, null);
48   - } else if (zdlytype == 2) {
49   - if (zdlyversion == null || zdlyversion == -1) {
50   - throw new Exception("请选择具体版本");
51   - } else {
52   - ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename, zdlyversion);
53   - }
54   - } else {
55   - throw new Exception("未知路由版本类型");
56   - }
  43 + if (lineversion == null) {
  44 + throw new Exception("线路版本未知");
57 45 }
58   -
  46 + ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename, lineversion);
59 47 rtn.put("status", ResponseCode.SUCCESS);
60 48 } catch (Exception exp) {
61 49 rtn.put("status", ResponseCode.ERROR);
... ...
src/main/java/com/bsth/service/schedule/TTInfoDetailService.java
... ... @@ -34,14 +34,14 @@ public interface TTInfoDetailService extends BService&lt;TTInfoDetail, Long&gt; {
34 34 * @param filename excel文件全路径名
35 35 * @param sheetname sheet名字
36 36 * @param lineid 线路id
37   - * @param zdlyversion 站点路由版本
  37 + * @param lineversion 线路版本
38 38 */
39 39 void validateExcelSheet(
40 40 String filename,
41 41 String sheetname,
42 42 Integer lineid,
43 43 String linename,
44   - Integer zdlyversion) throws ScheduleException;
  44 + Integer lineversion) throws ScheduleException;
45 45  
46 46 /**
47 47 * 验证关联的线路标准信息(以后放到规则引擎里去做)。
... ...
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
... ... @@ -72,6 +72,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
72 72 try {
73 73 LOGGER.info("//---------------- 导入时刻表明细 start... ----------------//");
74 74  
  75 + if (params.get("lineversion") == null) {
  76 + throw new Exception("线路版本未知");
  77 + }
  78 +
75 79 String filename = file.getAbsolutePath(); // xls xlsx 文件名
76 80 String sheetname = String.valueOf(params.get("sheetname")); // sheet名字
77 81 Long ttid = Long.valueOf(String.valueOf(params.get("ttid"))); // 时刻表id
... ... @@ -79,7 +83,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
79 83 Integer lineid = Integer.valueOf(String.valueOf(params.get("lineinfo"))); // 线路标准id
80 84 String xlname = String.valueOf(params.get("xlname")); // 线路名字
81 85 String ttname = String.valueOf(params.get("ttname")); // 时刻表名字
82   - Integer zdlyversion = params.get("zdlyversion") == null ? null : Integer.valueOf(params.get("zdlyversion").toString());
  86 + Integer lineversion = Integer.valueOf(params.get("lineversion").toString());
83 87  
84 88 LOGGER.info("参数1, xls文件名={},sheet名字={}", filename, sheetname);
85 89 LOGGER.info("参数2, 线路id={},线路名字={}", xlid, xlname);
... ... @@ -149,30 +153,27 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
149 153  
150 154 // 创建ktr转换所需参数
151 155 Map<String, Object> ktrParms = new HashMap<>();
152   - File ktrFile = new File(this.getClass().getResource(
  156 + // 元数据ktr
  157 + File mktrFile = new File(this.getClass().getResource(
153 158 dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI());
154   -// File ktrFile2 = new File(this.getClass().getResource(
155   -// dataToolsProperties.getTtinfodetailDatainputktr()).toURI());
156   - File ktrFile2 = new File(this.getClass().getResource(
157   - dataToolsProperties.getTtinfodetailDatainputktr2()).toURI());
158   - File ktrFile2_ls = new File(this.getClass().getResource(
159   - dataToolsProperties.getTtinfodetailDatainputktr2ls()).toURI());
  159 + // 实际数据ktr
  160 + File ktrFile2_version = new File(this.getClass().getResource(
  161 + dataToolsProperties.getTtinfodetailDatainputktr2version()).toURI());
160 162  
161 163 // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径
162   - ktrParms.put("transpath", ktrFile.getAbsolutePath());
  164 + ktrParms.put("transpath", mktrFile.getAbsolutePath());
163 165 ktrParms.put("filepath", fileCal.getAbsolutePath());
164 166 ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir());
165 167  
166 168 // 附加参数
167   - ktrParms.put("injectktrfile", zdlyversion == null || zdlyversion == -1 ?
168   - ktrFile2.getAbsolutePath() : ktrFile2_ls.getAbsolutePath()); // 注入元数据的ktr文件
  169 + ktrParms.put("injectktrfile", ktrFile2_version.getAbsolutePath()); // 注入元数据的ktr文件
169 170 ktrParms.put("sheetname", sheetname); // sheet工作区的名字
170 171 ktrParms.put("lineinfoid", lineid); // 线路标准id
171 172 ktrParms.put("xlname", xlname); // 线路名称
172 173 ktrParms.put("xlid", xlid); // 线路id
173 174 ktrParms.put("ttinfoname", ttname); // 时刻表名称
174 175 ktrParms.put("ttid", ttid.intValue()); // 时刻表id
175   - ktrParms.put("zdlyversion", zdlyversion); // 站点路由版本
  176 + ktrParms.put("lineversion", lineversion); // 站点路由版本
176 177 ktrParms.put("excelfieldnames", StringUtils.join(columnames.toArray(), ",")); // 时刻表excel输入字段名,以逗号连接
177 178 columnames.remove(0);
178 179 ktrParms.put("normalizefieldnames", StringUtils.join(columnames.toArray(), ",")); // 数据范式化字段名,以逗号连接
... ...
src/main/java/com/bsth/service/schedule/impl/TTInfoDetailServiceImpl.java
... ... @@ -146,7 +146,7 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
146 146 }
147 147  
148 148 @Override
149   - public void validateExcelSheet(String filename, String sheetname, Integer lineid, String linename, Integer zdlyversion) throws ScheduleException {
  149 + public void validateExcelSheet(String filename, String sheetname, Integer lineid, String linename, Integer lineversion) throws ScheduleException {
150 150 try {
151 151 File file = new File(filename);
152 152 Workbook workbook;
... ... @@ -178,7 +178,10 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
178 178 } else {
179 179 // 正则表达式去除右侧数字
180 180 // cell_con = cell_con.replaceAll("[\\d+]", "");
181   - cell_con = cell_con.replaceAll("(\\d+)$", "");
  181 +// cell_con = cell_con.replaceAll("(\\d+)$", "");
  182 +
  183 + // 如果站名中有类似->{数字},使用正则表达式过滤掉
  184 + cell_con = cell_con.replaceAll("(->\\d+)", "");
182 185  
183 186 if (i == 0) { // 第一列必须是路牌2个字
184 187 if (!"路牌".equals(cell_con.trim())) {
... ... @@ -189,35 +192,20 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
189 192 (!"进场".equals(cell_con.trim()))) {
190 193 Map<String, Object> p1 = new HashMap<>();
191 194 p1.put("line.id_eq", lineid);
192   - p1.put("stationName_like", cell_con.trim() + "%"); // 使用模糊匹配
193   - p1.put("stationMark_eq", "B");
  195 + p1.put("stationName_eq", cell_con.trim());
  196 + p1.put("stationMark_eq", "B"); // 起点站
194 197 p1.put("destroy_eq", 0); // 未撤销
195   -
196   -
197   - // TODO:这里要修改(起点站有启用撤销的标志的)
198   -
199   - if (zdlyversion == null) {
200   - List<StationRoute> stationRouteList = (List<StationRoute>) stationRouteService.list(p1);
201   - if (CollectionUtils.isEmpty(stationRouteList)) {
202   - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中不是起点站", i + 1, cell_con.trim(), linename));
203   - } else if (stationRouteList.size() > 1) {
204   - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中上下行都是起点站", i + 1, cell_con.trim(), linename));
205   - } else if (StringUtils.isEmpty(stationRouteList.get(0).getStationCode())) {
206   - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中没有站点编码", i + 1, cell_con.trim(), linename));
207   - }
208   - } else {
209   - p1.put("versions_eq", zdlyversion);
210   - List<LsStationRoute> lsStationRoutes = (List<LsStationRoute>) stationRouteService.list_ls(p1);
211   - if (CollectionUtils.isEmpty(lsStationRoutes)) {
212   - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中不是起点站", i + 1, cell_con.trim(), linename));
213   - } else if (lsStationRoutes.size() > 1) {
214   - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中上下行都是起点站", i + 1, cell_con.trim(), linename));
215   - } else if (StringUtils.isEmpty(lsStationRoutes.get(0).getStationCode())) {
216   - throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中没有站点编码", i + 1, cell_con.trim(), linename));
217   - }
  198 + p1.put("versions_eq", lineversion); // 带线路版本
  199 +
  200 + List<LsStationRoute> lsStationRoutes = (List<LsStationRoute>) stationRouteService.list_ls(p1);
  201 + if (CollectionUtils.isEmpty(lsStationRoutes)) {
  202 + throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中不是起点站", i + 1, cell_con.trim(), linename));
  203 + } else if (lsStationRoutes.size() > 1) {
  204 + throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中上下行都是起点站", i + 1, cell_con.trim(), linename));
  205 + } else if (StringUtils.isEmpty(lsStationRoutes.get(0).getStationCode())) {
  206 + throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中没有站点编码", i + 1, cell_con.trim(), linename));
218 207 }
219 208  
220   -
221 209 }
222 210  
223 211 }
... ...
src/main/java/com/bsth/service/schedule/utils/DataToolsProperties.java
... ... @@ -75,12 +75,12 @@ public class DataToolsProperties {
75 75 /** 时刻表明细信息导入 */
76 76 @NotNull
77 77 private String ttinfodetailDatainputktr;
78   - /** 时刻表明细信息导入 */
  78 + /** 时刻表明细信息导入2 */
79 79 @NotNull
80 80 private String ttinfodetailDatainputktr2;
81   - /** 时刻表明细信息导入 */
  81 + /** 时刻表明细信息导入2(带版本) */
82 82 @NotNull
83   - private String ttinfodetailDatainputktr2ls;
  83 + private String ttinfodetailDatainputktr2version;
84 84 /** 排班规则信息导入 */
85 85 @NotNull
86 86 private String scheduleruleDatainputktr;
... ... @@ -314,12 +314,12 @@ public class DataToolsProperties {
314 314 this.carsconfigDataoutputktr = carsconfigDataoutputktr;
315 315 }
316 316  
317   - public String getTtinfodetailDatainputktr2ls() {
318   - return ttinfodetailDatainputktr2ls;
  317 + public String getTtinfodetailDatainputktr2version() {
  318 + return ttinfodetailDatainputktr2version;
319 319 }
320 320  
321   - public void setTtinfodetailDatainputktr2ls(String ttinfodetailDatainputktr2ls) {
322   - this.ttinfodetailDatainputktr2ls = ttinfodetailDatainputktr2ls;
  321 + public void setTtinfodetailDatainputktr2version(String ttinfodetailDatainputktr2version) {
  322 + this.ttinfodetailDatainputktr2version = ttinfodetailDatainputktr2version;
323 323 }
324 324  
325 325 public String getEmployeesconfigDataoutputktr() {
... ...
src/main/resources/datatools/config-dev.properties
... ... @@ -39,8 +39,8 @@ datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr
39 39 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr
40 40 # 时刻表明细信息导入2
41 41 datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr
42   -# 时刻表明细信息导入2_ls
43   -datatools.ttinfodetail_datainputktr2ls=/datatools/ktrs/ttinfodetailDataInput2_ls.ktr
  42 +# 时刻表明细信息导入2(版本化)
  43 +datatools.ttinfodetail_datainputktr2version=/datatools/ktrs/ttinfodetailDataInput2_version.ktr
44 44  
45 45 # 车辆配置信息导入
46 46 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr
... ...
src/main/resources/datatools/config-prod.properties
... ... @@ -40,8 +40,8 @@ datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr
40 40 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr
41 41 # 时刻表明细信息导入2
42 42 datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr
43   -# 时刻表明细信息导入2_ls
44   -datatools.ttinfodetail_datainputktr2ls=/datatools/ktrs/ttinfodetailDataInput2_ls.ktr
  43 +# 时刻表明细信息导入2(版本化)
  44 +datatools.ttinfodetail_datainputktr2version=/datatools/ktrs/ttinfodetailDataInput2_version.ktr
45 45  
46 46 # 车辆配置信息导入
47 47 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr
... ...