| | |
| | | // 2. 构建查询条件(增强空值安全) |
| | | LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>(); |
| | | String customerName = customer.getCustomerName(); |
| | | String customerType = customer.getCustomerType(); |
| | | Integer customerType = customer.getCustomerType(); |
| | | if (StringUtils.isNotBlank(customerName)) { |
| | | queryWrapper.like(Customer::getCustomerName, customerName); |
| | | } |
| | | if (StringUtils.isNotBlank(customerType)) { |
| | | queryWrapper.like(Customer::getCustomerType, customerType); |
| | | if (customerType != null) { |
| | | queryWrapper.eq(Customer::getCustomerType, customerType); |
| | | } |
| | | |
| | | // 3. 执行分页查询(保留分页元数据) |
| | |
| | | .filter(Objects::nonNull) // 过滤空对象(避免后续操作NPE) |
| | | .peek(c -> { |
| | | // 安全获取字段,避免null值拼接 |
| | | String address = StringUtils.defaultString(c.getCompanyAddress(), ""); |
| | | String phone = StringUtils.defaultString(c.getCompanyPhone(), ""); |
| | | String address = StringUtils.defaultString(c.getCompanyAddress(), "").trim(); |
| | | String phone = StringUtils.defaultString(c.getCompanyPhone(), "").trim(); |
| | | if (StringUtils.isNotEmpty(address) && StringUtils.isNotEmpty(phone)) { |
| | | c.setAddressPhone(address + "(" + phone + ")"); |
| | | |
| | | } else if (StringUtils.isNotEmpty(address)) { |
| | | c.setAddressPhone(address); |
| | | } else if (StringUtils.isNotEmpty(phone)) { |
| | | c.setAddressPhone(phone); |
| | | } else { |
| | | c.setAddressPhone(""); |
| | | } |
| | | // 查询最新的跟进记录 |
| | | CustomerFollowUp followUp = customerFollowUpService.getOne( |
| | | new LambdaQueryWrapper<CustomerFollowUp>() |
| | |
| | | @Override |
| | | public List<Map<String, Object>> customerList(Customer customer) { |
| | | LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber); |
| | | queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber, Customer::getCustomerType); |
| | | |
| | | // 获取原始查询结果 |
| | | List<Map<String, Object>> result = customerMapper.selectMaps(queryWrapper); |