chore: opt duplicate customer import

This commit is contained in:
Donghuang 2022-11-26 21:33:57 +08:00
parent 79809ab774
commit 587b9c633f

View File

@ -105,15 +105,22 @@ public class CustomerYearToDateSaleServiceSupport
return;
}
val customer = customerMapper.find(
val customers = customerMapper.list(
new Search(Customer.ID2, customerId2)
.eq(Customer.NAME, customerName));
if (customer == null) {
if (customers.isEmpty()) {
log.warn("No customer [{}] found, ignore.", customerName);
return;
}
if (customers.size() > 1) {
log.warn("Duplicate customers [{}] found, error.", customers);
throw new IllegalStateException(
"Duplicate customer found, id [" + customerId2 + "] name [" + customerName + "]");
}
val customer = customers.iterator().next();
val customerId = customer.getId();
customerYtdSale.setCustomerId(customerId);
customerYtdSale.setYear(StringUtils.trim(record.get(3)));