|
|
@@ -179,17 +179,21 @@ public class ZcrmViewCustomerAddressSelServiceImpl extends BaseServiceImpl<ZcrmV
|
|
|
|
|
|
List<String> conditionParts = new ArrayList<>();
|
|
|
for (ZcrmViewCustomerAddressSel item : validItems) {
|
|
|
- // 优化:数据库查询时对字段进行 TRIM(),匹配处理后的数据
|
|
|
conditionParts.add("(Customer_ID = ? " +
|
|
|
- "AND TRIM(Customer_CODE) = ? " +
|
|
|
- "AND TRIM(Contacts) = ? " +
|
|
|
- "AND TRIM(Phone) = ? " +
|
|
|
- "AND TRIM(CustAddress) = ?)");
|
|
|
+ "AND (TRIM(Customer_CODE) = ? OR (TRIM(Customer_CODE) IS NULL AND ? IS NULL)) " +
|
|
|
+ "AND (TRIM(Contacts) = ? OR (TRIM(Contacts) IS NULL AND ? IS NULL)) " +
|
|
|
+ "AND (TRIM(Phone) = ? OR (TRIM(Phone) IS NULL AND ? IS NULL)) " +
|
|
|
+ "AND (TRIM(CustAddress) = ? OR (TRIM(CustAddress) IS NULL AND ? IS NULL)))");
|
|
|
+ // 参数顺序:Customer_ID, 非空值, 空值标记, 非空值, 空值标记...
|
|
|
params.add(item.getCustomerId());
|
|
|
- params.add(item.getCustomerCode().trim());
|
|
|
- params.add(item.getContacts().trim());
|
|
|
- params.add(item.getPhone().trim());
|
|
|
- params.add(item.getCustAddress().trim());
|
|
|
+ params.add(item.getCustomerCode() != null ? item.getCustomerCode().trim() : null);
|
|
|
+ params.add(item.getCustomerCode()); // 用于判断是否为NULL
|
|
|
+ params.add(item.getContacts() != null ? item.getContacts().trim() : null);
|
|
|
+ params.add(item.getContacts());
|
|
|
+ params.add(item.getPhone() != null ? item.getPhone().trim() : null);
|
|
|
+ params.add(item.getPhone());
|
|
|
+ params.add(item.getCustAddress() != null ? item.getCustAddress().trim() : null);
|
|
|
+ params.add(item.getCustAddress());
|
|
|
}
|
|
|
|
|
|
sql.append(String.join(" OR ", conditionParts));
|