Showing
1 changed file
with
16 additions
and
4 deletions
| ... | ... | @@ -25,7 +25,8 @@ import lombok.extern.slf4j.Slf4j; |
| 25 | 25 | @Slf4j |
| 26 | 26 | public class CustomerImportListener extends ExcelImportListener<CustomerImportModel> { |
| 27 | 27 | |
| 28 | - private List<String> checkList = new ArrayList<>(); | |
| 28 | + private final List<String> checkCodeList = new ArrayList<>(); | |
| 29 | + private final List<String> checkNameList = new ArrayList<>(); | |
| 29 | 30 | |
| 30 | 31 | @Override |
| 31 | 32 | protected void doInvoke(CustomerImportModel data, AnalysisContext context) { |
| ... | ... | @@ -38,11 +39,11 @@ public class CustomerImportListener extends ExcelImportListener<CustomerImportMo |
| 38 | 39 | "第" + context.readRowHolder().getRowIndex() |
| 39 | 40 | + "行“编号”必须由字母、数字、“-_.”组成,长度不能超过20位"); |
| 40 | 41 | } |
| 41 | - if (checkList.contains(data.getCode())) { | |
| 42 | + if (checkCodeList.contains(data.getCode())) { | |
| 42 | 43 | throw new DefaultClientException( |
| 43 | - "第" + context.readRowHolder().getRowIndex() + "行“编号”与第" + (checkList.indexOf(data.getCode()) + 1) + "行重复"); | |
| 44 | + "第" + context.readRowHolder().getRowIndex() + "行“编号”与第" + (checkCodeList.indexOf(data.getCode()) + 1) + "行重复"); | |
| 44 | 45 | } |
| 45 | - checkList.add(data.getCode()); | |
| 46 | + checkCodeList.add(data.getCode()); | |
| 46 | 47 | Wrapper<Customer> checkWrapper = Wrappers.lambdaQuery(Customer.class) |
| 47 | 48 | .eq(Customer::getCode, data.getCode()); |
| 48 | 49 | CustomerService customerService = ApplicationUtil.getBean(CustomerService.class); |
| ... | ... | @@ -54,6 +55,17 @@ public class CustomerImportListener extends ExcelImportListener<CustomerImportMo |
| 54 | 55 | throw new DefaultClientException( |
| 55 | 56 | "第" + context.readRowHolder().getRowIndex() + "行“名称”不能为空"); |
| 56 | 57 | } |
| 58 | + if (checkNameList.contains(data.getName())) { | |
| 59 | + throw new DefaultClientException( | |
| 60 | + "第" + context.readRowHolder().getRowIndex() + "行“名称”与第" + (checkNameList.indexOf(data.getName()) + 1) + "行重复"); | |
| 61 | + } | |
| 62 | + checkNameList.add(data.getName()); | |
| 63 | + checkWrapper = Wrappers.lambdaQuery(Customer.class) | |
| 64 | + .eq(Customer::getName, data.getName()); | |
| 65 | + if (customerService.count(checkWrapper) > 0) { | |
| 66 | + throw new DefaultClientException( | |
| 67 | + "第" + context.readRowHolder().getRowIndex() + "行“名称”已存在"); | |
| 68 | + } | |
| 57 | 69 | // if (StringUtil.isBlank(data.getMnemonicCode())) { |
| 58 | 70 | // throw new DefaultClientException( |
| 59 | 71 | // "第" + context.readRowHolder().getRowIndex() + "行“简码”不能为空"); | ... | ... |