Commit e077437d6cb056ecbb6db0ed84f41b59efbd9b31

Authored by 房远帅
2 parents 4687a2ee 9edd446d

Merge branch 'master_0929' into master_after20

@@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils; @@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
30 30
31 import java.time.LocalDate; 31 import java.time.LocalDate;
32 import java.time.format.DateTimeFormatter; 32 import java.time.format.DateTimeFormatter;
  33 +import java.time.format.DateTimeParseException;
33 import java.util.Arrays; 34 import java.util.Arrays;
34 import java.util.List; 35 import java.util.List;
35 import java.util.Objects; 36 import java.util.Objects;
@@ -78,6 +79,18 @@ public class ContractFrameworkImportListener extends ExcelImportListener<Contrac @@ -78,6 +79,18 @@ public class ContractFrameworkImportListener extends ExcelImportListener<Contrac
78 if (null == data.getValidityTime()) { 79 if (null == data.getValidityTime()) {
79 throw new DefaultClientException( 80 throw new DefaultClientException(
80 "第" + context.readRowHolder().getRowIndex() + "行授时截止日期不可为空"); 81 "第" + context.readRowHolder().getRowIndex() + "行授时截止日期不可为空");
  82 + } else {
  83 + String dateStr = data.getValidityTime().trim();
  84 + try {
  85 + LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  86 + } catch (DateTimeParseException e) {
  87 + try {
  88 + LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
  89 + } catch (DateTimeParseException ex) {
  90 + throw new DefaultClientException(
  91 + "第" + context.readRowHolder().getRowIndex() + "行授时截止日期格式错误!");
  92 + }
  93 + }
81 } 94 }
82 95
83 if (StringUtils.isBlank(data.getMaterialTypeName())) { 96 if (StringUtils.isBlank(data.getMaterialTypeName())) {
@@ -129,7 +142,19 @@ public class ContractFrameworkImportListener extends ExcelImportListener<Contrac @@ -129,7 +142,19 @@ public class ContractFrameworkImportListener extends ExcelImportListener<Contrac
129 ContractFrameworkImportModel data = datas.get(i); 142 ContractFrameworkImportModel data = datas.get(i);
130 CreateContractFrameworkVo createContractFrameworkVo = new CreateContractFrameworkVo(); 143 CreateContractFrameworkVo createContractFrameworkVo = new CreateContractFrameworkVo();
131 createContractFrameworkVo.setCode(yearTwoDigit + data.getCompany() + deptCode + code); 144 createContractFrameworkVo.setCode(yearTwoDigit + data.getCompany() + deptCode + code);
132 - createContractFrameworkVo.setValidityTime(DateUtil.toLocalDate(data.getValidityTime())); 145 + String dateStr = data.getValidityTime().trim();
  146 + try {
  147 + LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
  148 + createContractFrameworkVo.setValidityTime(date);
  149 + } catch (DateTimeParseException e) {
  150 + try {
  151 + LocalDate date = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
  152 + createContractFrameworkVo.setValidityTime(date);
  153 + } catch (DateTimeParseException ex) {
  154 + throw new DefaultClientException(
  155 + "第" + context.readRowHolder().getRowIndex() + "行授时截止日期格式错误!");
  156 + }
  157 + }
133 createContractFrameworkVo.setHasFrameworkAgreement(data.getHasFrameworkAgreement()); 158 createContractFrameworkVo.setHasFrameworkAgreement(data.getHasFrameworkAgreement());
134 createContractFrameworkVo.setCompany(data.getCompany()); 159 createContractFrameworkVo.setCompany(data.getCompany());
135 createContractFrameworkVo.setCustomerId(data.getCustomerId()); 160 createContractFrameworkVo.setCustomerId(data.getCustomerId());
@@ -63,8 +63,7 @@ public class ContractFrameworkImportModel implements ExcelModel { @@ -63,8 +63,7 @@ public class ContractFrameworkImportModel implements ExcelModel {
63 * 授时截止日期 63 * 授时截止日期
64 */ 64 */
65 @ExcelRequired 65 @ExcelRequired
66 - @DateTimeFormat(StringPool.DATE_PATTERN)  
67 @ExcelProperty("授时截止日期") 66 @ExcelProperty("授时截止日期")
68 - private Date validityTime; 67 + private String validityTime;
69 68
70 } 69 }