Commit 704582a63dfc0a95eb93baf89c55dfd47c2ec349
1 parent
2baff217
update
Showing
1 changed file
with
11 additions
and
7 deletions
Too many changes to show.
To preserve performance only 1 of 3 files are displayed.
src/main/java/com/bsth/service/schedule/impl/TTInfoDetailServiceImpl.java
| @@ -429,20 +429,23 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | @@ -429,20 +429,23 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | ||
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | // 班次时间验证,正则表达式,格式hh:mm或者hhmm | 431 | // 班次时间验证,正则表达式,格式hh:mm或者hhmm |
| 432 | - String el = "^(([0-1]\\d)|(2[0-4])):[0-5]\\d$"; // hh:mm格式 | ||
| 433 | - String el2 = "^(([0-1]\\d)|(2[0-4]))[0-5]\\d$"; // hhmm格式 | ||
| 434 | - Pattern p = Pattern.compile(el); | ||
| 435 | - Pattern p2 = Pattern.compile(el2); | 432 | + String rex1 = "^([01]?[0-9]|2[0-3]):[0-5][0-9]$"; // hh:mm格式 |
| 433 | + String rex2 = "^([01]?[0-9]|2[0-3]),[0-5][0-9]$"; // hh,mm格式 | ||
| 434 | + String rex3 = "^([01]?[0-9]|2[0-3])[0-5][0-9]$"; // hhmm格式 | ||
| 435 | + Pattern p1 = Pattern.compile(rex1); | ||
| 436 | + Pattern p2 = Pattern.compile(rex2); | ||
| 437 | + Pattern p3 = Pattern.compile(rex3); | ||
| 436 | 438 | ||
| 437 | for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | 439 | for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 |
| 438 | Cell[] bcells = sheet.getRow(i); | 440 | Cell[] bcells = sheet.getRow(i); |
| 439 | for (int j = 1; j < bcells.length; j++) { // 从第2列开始 | 441 | for (int j = 1; j < bcells.length; j++) { // 从第2列开始 |
| 440 | String bcell_con = bcells[j].getContents(); | 442 | String bcell_con = bcells[j].getContents(); |
| 441 | if (StringUtils.isNotEmpty(bcell_con)) { | 443 | if (StringUtils.isNotEmpty(bcell_con)) { |
| 442 | - Matcher m = p.matcher(bcell_con.trim()); | 444 | + Matcher m1 = p1.matcher(bcell_con.trim()); |
| 443 | Matcher m2 = p2.matcher(bcell_con.trim()); | 445 | Matcher m2 = p2.matcher(bcell_con.trim()); |
| 444 | - if ((!m.matches()) && (!m2.matches())) { | ||
| 445 | - throw new Exception(String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hhmm", i + 1, j + 1)); | 446 | + Matcher m3 = p3.matcher(bcell_con.trim()); |
| 447 | + if ((!m1.matches()) && (!m2.matches()) && (!m3.matches())) { | ||
| 448 | + throw new Exception(String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hh,mm或hhmm", i + 1, j + 1)); | ||
| 446 | } | 449 | } |
| 447 | } | 450 | } |
| 448 | } | 451 | } |
| @@ -509,4 +512,5 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | @@ -509,4 +512,5 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im | ||
| 509 | public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) { | 512 | public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) { |
| 510 | return ttInfoDetailRepository.findBcdetails(xlId, ttinfoId, lpId); | 513 | return ttInfoDetailRepository.findBcdetails(xlId, ttinfoId, lpId); |
| 511 | } | 514 | } |
| 515 | + | ||
| 512 | } | 516 | } |