|
@@ -38,6 +38,8 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -430,30 +432,50 @@ public class BaseGgpFacilityServiceImpl extends AbstractCrudService<BaseGgpFacil
|
|
|
List<FacilityImportVo> facilityImportVos = ExcelImportUtil.importExcel(multipartFile.getInputStream(),
|
|
|
FacilityImportVo.class, params);
|
|
|
if (CollectionUtils.isNotEmpty(facilityImportVos)){
|
|
|
- int rot=0;
|
|
|
+ int rot=3;
|
|
|
for (FacilityImportVo facilityImportVo:facilityImportVos) {
|
|
|
BaseGgpFacility baseGgpFacility = BeanMapperUtils.map(facilityImportVo, BaseGgpFacility.class);
|
|
|
if (StringUtils.isBlank(baseGgpFacility.getFacilityType())||StringUtils.isBlank(baseGgpFacility.getFacilityName())||StringUtils.isBlank(baseGgpFacility.getAddress())||StringUtils.isBlank(baseGgpFacility.getLatitude())||StringUtils.isBlank(baseGgpFacility.getLongitude())){
|
|
|
- int h=rot+3;
|
|
|
- err="文件导入失败,第"+h+"行数据导入失败,必填字段不能为空";
|
|
|
- throw new BusinessException(err);
|
|
|
+
|
|
|
+ String tmp = ",第"+rot+"行数据导入失败,必填字段不能为空";
|
|
|
+ err = err.concat(tmp);
|
|
|
+ throw new Exception(err);
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(baseGgpFacility.getContactPhone())){
|
|
|
+ if(!validator(baseGgpFacility.getContactPhone())){
|
|
|
+ String tmp = ",请检查第"+rot+"行手机号是否正确";
|
|
|
+ err = err.concat(tmp);
|
|
|
+ throw new Exception(err);
|
|
|
+ }
|
|
|
}
|
|
|
try{
|
|
|
this.add(baseGgpFacility);
|
|
|
}catch (Exception e){
|
|
|
- int h=rot+3;
|
|
|
- err="文件导入失败,第"+h+"行数据导入失败";
|
|
|
- throw new BusinessException(err);
|
|
|
+ String tt = ",第"+rot+"行数据导入失败";
|
|
|
+ err = err.concat(tt);
|
|
|
+ throw new Exception(err);
|
|
|
}
|
|
|
rot++;
|
|
|
}
|
|
|
}else {
|
|
|
- err="文件不能为空";
|
|
|
- throw new BusinessException(err);
|
|
|
+ err = err.concat(",文件不能为空");
|
|
|
+ throw new Exception(err);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- throw new BusinessException(err);
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static boolean validator(String phone) {
|
|
|
+ String regex = "^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[0,1,5,6,7,8,9]))\\d{8}$";
|
|
|
+ if (phone.length() != 11) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ Pattern p = Pattern.compile(regex);
|
|
|
+ Matcher m = p.matcher(phone);
|
|
|
+ boolean isMatch = m.matches();
|
|
|
+ return isMatch;
|
|
|
}
|
|
|
}
|
|
|
|