优化这段代码 String checkResult = ""; // 遍历有效数据列表 for (InvoiceCollectImportReq validData : validList) { // 全电发票,无发票代码,号码相同,则为重复发票 // 普票发票号码和发票代码相同,则为重复发票 if ((StringUtils.isBlank(validData.getInvoiceCode()) && StringUtils.isBlank(invoiceCollectImportReq.getInvoiceCode()) && validData.getInvoiceNumber().equals(invoiceCollectImportReq.getInvoiceNumber())) || (StringUtils.isNotBlank(validData.getInvoiceCode()) && StringUtils.isNotBlank(invoiceCollectImportReq.getInvoiceCode()) && validData.getInvoiceCode().equals(invoiceCollectImportReq.getInvoiceCode()) && validData.getInvoiceNumber().equals(invoiceCollectImportReq.getInvoiceNumber()))){ checkResult = "发票重复"; break; } }
时间: 2024-04-21 21:24:10 浏览: 85
layui自定义验证,用ajax查询后台是否有重复数据,form.verify的例子
String checkResult = "";
for (InvoiceCollectImportReq validData : validList) {
boolean isDuplicateInvoice = StringUtils.isBlank(validData.getInvoiceCode())
&& StringUtils.isBlank(invoiceCollectImportReq.getInvoiceCode())
&& validData.getInvoiceNumber().equals(invoiceCollectImportReq.getInvoiceNumber());
boolean isDuplicateGeneralInvoice = StringUtils.isNotBlank(validData.getInvoiceCode())
&& StringUtils.isNotBlank(invoiceCollectImportReq.getInvoiceCode())
&& validData.getInvoiceCode().equals(invoiceCollectImportReq.getInvoiceCode())
&& validData.getInvoiceNumber().equals(invoiceCollectImportReq.getInvoiceNumber());
if (isDuplicateInvoice || isDuplicateGeneralInvoice) {
checkResult = "发票重复";
break;
}
}
阅读全文