| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.date.LocalDateTimeUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | |
| | | // 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(), ""); |
| | | c.setAddressPhone(address + "(" + phone + ")"); |
| | | |
| | | 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>() |
| | |
| | | |
| | | if (followUp != null) { |
| | | c.setFollowUpLevel(followUp.getFollowUpLevel()); |
| | | c.setFollowUpTime(followUp.getFollowUpTime()); |
| | | c.setFollowUpTime( |
| | | Date.from( |
| | | followUp.getFollowUpTime().atZone(ZoneId.systemDefault()).toInstant() |
| | | ) |
| | | ); |
| | | } |
| | | }) |
| | | .collect(Collectors.toList()); |
| | |
| | | @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); |