Commit d3087f12 by 杨林龙

修改导入错误信息提示

1 parent 1216a8cf
......@@ -216,22 +216,30 @@ public class VehicleInfoImportListener extends AnalysisEventListener<VehicleInfo
// 校验组织机构
if (StringUtils.isNullOrEmpty(vi.getOrganizationName())) {
failMsg.add(new VehicleInfoFailExport("组织机构", "必填项"));
}
// 校验组织机构 是否存在
Long userId = userApiService.getUserIdByUsername(vi.getOrganizationName());
if (userId == null) {
failMsg.add(new VehicleInfoFailExport(vi.getOrganizationName(), "该组织机构不存在,请选择用户级别的组织名称"));
} else {
// 校验组织机构 是否存在
Long userId = userApiService.getUserIdByUsername(vi.getOrganizationName());
if (userId == null) {
failMsg.add(new VehicleInfoFailExport(vi.getOrganizationName(), "该组织机构不存在,请选择用户级别的组织名称"));
}
}
// 校验车架号
if (StringUtils.isNullOrEmpty(vi.getVin())) {
failMsg.add(new VehicleInfoFailExport("车架号", "必填项"));
}
// 校验车架号时候存在
if (vinList.contains(vi.getVin())) {
failMsg.add(new VehicleInfoFailExport(vi.getVin(), "车架号已经存在,请勿重复导入"));
} else {
boolean flag = true;
String pattern = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17}$";
boolean matches = vi.getVin().matches(pattern);
if (!matches) {
flag = false;
failMsg.add(new VehicleInfoFailExport(vi.getVin(), "车架号车架号必须是17位数字+字母组合"));
}
// 校验车架号时候存在
if (flag && vinList.contains(vi.getVin())) {
failMsg.add(new VehicleInfoFailExport(vi.getVin(), "车架号已经存在,请勿重复导入"));
}
}
// 校验设备号是否存在
......
......@@ -41,6 +41,8 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
......@@ -2158,4 +2160,16 @@ public class VehicleServiceTest {
deviceService.updateDevice(device);
}
@Test
public void test16(){
String pattern = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17}$";
String line = "1231231234qwe54789";
boolean matches = line.matches(pattern);
if (matches){
System.out.println("matches = " + matches);
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!