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,30 +32,18 @@ public class TTInfoDetailController extends BController<TTInfoDetail, Long> {
32 * @param sheetname sheet名字 32 * @param sheetname sheet名字
33 * @param lineid 线路id 33 * @param lineid 线路id
34 * @param linename 线路名称 34 * @param linename 线路名称
  35 + * @param lineversion 线路版本
35 * @return 36 * @return
36 */ 37 */
37 @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST) 38 @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST)
38 public Map<String, Object> validate_sheet( 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 Map<String, Object> rtn = new HashMap<>(); 41 Map<String, Object> rtn = new HashMap<>();
42 try { 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 rtn.put("status", ResponseCode.SUCCESS); 47 rtn.put("status", ResponseCode.SUCCESS);
60 } catch (Exception exp) { 48 } catch (Exception exp) {
61 rtn.put("status", ResponseCode.ERROR); 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,14 +34,14 @@ public interface TTInfoDetailService extends BService&lt;TTInfoDetail, Long&gt; {
34 * @param filename excel文件全路径名 34 * @param filename excel文件全路径名
35 * @param sheetname sheet名字 35 * @param sheetname sheet名字
36 * @param lineid 线路id 36 * @param lineid 线路id
37 - * @param zdlyversion 站点路由版本 37 + * @param lineversion 线路版本
38 */ 38 */
39 void validateExcelSheet( 39 void validateExcelSheet(
40 String filename, 40 String filename,
41 String sheetname, 41 String sheetname,
42 Integer lineid, 42 Integer lineid,
43 String linename, 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,6 +72,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
72 try { 72 try {
73 LOGGER.info("//---------------- 导入时刻表明细 start... ----------------//"); 73 LOGGER.info("//---------------- 导入时刻表明细 start... ----------------//");
74 74
  75 + if (params.get("lineversion") == null) {
  76 + throw new Exception("线路版本未知");
  77 + }
  78 +
75 String filename = file.getAbsolutePath(); // xls xlsx 文件名 79 String filename = file.getAbsolutePath(); // xls xlsx 文件名
76 String sheetname = String.valueOf(params.get("sheetname")); // sheet名字 80 String sheetname = String.valueOf(params.get("sheetname")); // sheet名字
77 Long ttid = Long.valueOf(String.valueOf(params.get("ttid"))); // 时刻表id 81 Long ttid = Long.valueOf(String.valueOf(params.get("ttid"))); // 时刻表id
@@ -79,7 +83,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail @@ -79,7 +83,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
79 Integer lineid = Integer.valueOf(String.valueOf(params.get("lineinfo"))); // 线路标准id 83 Integer lineid = Integer.valueOf(String.valueOf(params.get("lineinfo"))); // 线路标准id
80 String xlname = String.valueOf(params.get("xlname")); // 线路名字 84 String xlname = String.valueOf(params.get("xlname")); // 线路名字
81 String ttname = String.valueOf(params.get("ttname")); // 时刻表名字 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 LOGGER.info("参数1, xls文件名={},sheet名字={}", filename, sheetname); 88 LOGGER.info("参数1, xls文件名={},sheet名字={}", filename, sheetname);
85 LOGGER.info("参数2, 线路id={},线路名字={}", xlid, xlname); 89 LOGGER.info("参数2, 线路id={},线路名字={}", xlid, xlname);
@@ -149,30 +153,27 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail @@ -149,30 +153,27 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
149 153
150 // 创建ktr转换所需参数 154 // 创建ktr转换所需参数
151 Map<String, Object> ktrParms = new HashMap<>(); 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 dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI()); 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 // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 163 // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径
162 - ktrParms.put("transpath", ktrFile.getAbsolutePath()); 164 + ktrParms.put("transpath", mktrFile.getAbsolutePath());
163 ktrParms.put("filepath", fileCal.getAbsolutePath()); 165 ktrParms.put("filepath", fileCal.getAbsolutePath());
164 ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); 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 ktrParms.put("sheetname", sheetname); // sheet工作区的名字 170 ktrParms.put("sheetname", sheetname); // sheet工作区的名字
170 ktrParms.put("lineinfoid", lineid); // 线路标准id 171 ktrParms.put("lineinfoid", lineid); // 线路标准id
171 ktrParms.put("xlname", xlname); // 线路名称 172 ktrParms.put("xlname", xlname); // 线路名称
172 ktrParms.put("xlid", xlid); // 线路id 173 ktrParms.put("xlid", xlid); // 线路id
173 ktrParms.put("ttinfoname", ttname); // 时刻表名称 174 ktrParms.put("ttinfoname", ttname); // 时刻表名称
174 ktrParms.put("ttid", ttid.intValue()); // 时刻表id 175 ktrParms.put("ttid", ttid.intValue()); // 时刻表id
175 - ktrParms.put("zdlyversion", zdlyversion); // 站点路由版本 176 + ktrParms.put("lineversion", lineversion); // 站点路由版本
176 ktrParms.put("excelfieldnames", StringUtils.join(columnames.toArray(), ",")); // 时刻表excel输入字段名,以逗号连接 177 ktrParms.put("excelfieldnames", StringUtils.join(columnames.toArray(), ",")); // 时刻表excel输入字段名,以逗号连接
177 columnames.remove(0); 178 columnames.remove(0);
178 ktrParms.put("normalizefieldnames", StringUtils.join(columnames.toArray(), ",")); // 数据范式化字段名,以逗号连接 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,7 +146,7 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
146 } 146 }
147 147
148 @Override 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 try { 150 try {
151 File file = new File(filename); 151 File file = new File(filename);
152 Workbook workbook; 152 Workbook workbook;
@@ -178,7 +178,10 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im @@ -178,7 +178,10 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
178 } else { 178 } else {
179 // 正则表达式去除右侧数字 179 // 正则表达式去除右侧数字
180 // cell_con = cell_con.replaceAll("[\\d+]", ""); 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 if (i == 0) { // 第一列必须是路牌2个字 186 if (i == 0) { // 第一列必须是路牌2个字
184 if (!"路牌".equals(cell_con.trim())) { 187 if (!"路牌".equals(cell_con.trim())) {
@@ -189,35 +192,20 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im @@ -189,35 +192,20 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
189 (!"进场".equals(cell_con.trim()))) { 192 (!"进场".equals(cell_con.trim()))) {
190 Map<String, Object> p1 = new HashMap<>(); 193 Map<String, Object> p1 = new HashMap<>();
191 p1.put("line.id_eq", lineid); 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 p1.put("destroy_eq", 0); // 未撤销 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,12 +75,12 @@ public class DataToolsProperties {
75 /** 时刻表明细信息导入 */ 75 /** 时刻表明细信息导入 */
76 @NotNull 76 @NotNull
77 private String ttinfodetailDatainputktr; 77 private String ttinfodetailDatainputktr;
78 - /** 时刻表明细信息导入 */ 78 + /** 时刻表明细信息导入2 */
79 @NotNull 79 @NotNull
80 private String ttinfodetailDatainputktr2; 80 private String ttinfodetailDatainputktr2;
81 - /** 时刻表明细信息导入 */ 81 + /** 时刻表明细信息导入2(带版本) */
82 @NotNull 82 @NotNull
83 - private String ttinfodetailDatainputktr2ls; 83 + private String ttinfodetailDatainputktr2version;
84 /** 排班规则信息导入 */ 84 /** 排班规则信息导入 */
85 @NotNull 85 @NotNull
86 private String scheduleruleDatainputktr; 86 private String scheduleruleDatainputktr;
@@ -314,12 +314,12 @@ public class DataToolsProperties { @@ -314,12 +314,12 @@ public class DataToolsProperties {
314 this.carsconfigDataoutputktr = carsconfigDataoutputktr; 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 public String getEmployeesconfigDataoutputktr() { 325 public String getEmployeesconfigDataoutputktr() {
src/main/resources/datatools/config-dev.properties
@@ -39,8 +39,8 @@ datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr @@ -39,8 +39,8 @@ datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr
39 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr 39 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr
40 # 时刻表明细信息导入2 40 # 时刻表明细信息导入2
41 datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr 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 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr 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,8 +40,8 @@ datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr
40 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr 40 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr
41 # 时刻表明细信息导入2 41 # 时刻表明细信息导入2
42 datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr 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 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr 47 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr