liding
2 天以前 befc0e5606ab7c913dda0346152a4150d0ee5f79
basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java
@@ -10,10 +10,13 @@
import com.ruoyi.basic.mapper.SupplyMapper;
import com.ruoyi.basic.service.SupplyService;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Objects;
/**
@@ -33,17 +36,29 @@
    @Override
    public IPage<Supply> selectSupplyList(Page page, SupplyDto supplyDto) {
        LambdaQueryWrapper<Supply> queryWrapper = new LambdaQueryWrapper<>();
        // 供应商名称模糊查询
        if (StringUtils.hasText(supplyDto.getSupplierName())) {
            queryWrapper.like(Supply::getSupplierName, supplyDto.getSupplierName());
        // 全局模糊搜索字段
        if (StringUtils.hasText(supplyDto.getSearchAll())) {
            String keyword = supplyDto.getSearchAll();
            queryWrapper.and(wrapper -> wrapper
                    .like(Supply::getSupplierName, keyword)
                    .or()
                    .like(Supply::getTaxpayerId, keyword)
                    .or()
                    .like(Supply::getBusinessAddress, keyword)
            );
        } else {
            // 单独条件查询
            if (StringUtils.hasText(supplyDto.getSupplierName())) {
                queryWrapper.like(Supply::getSupplierName, supplyDto.getSupplierName());
            }
            if (StringUtils.hasText(supplyDto.getTaxpayerId())) {
                queryWrapper.like(Supply::getTaxpayerId, supplyDto.getTaxpayerId());
            }
            if (StringUtils.hasText(supplyDto.getBusinessAddress())) {
                queryWrapper.like(Supply::getBusinessAddress, supplyDto.getBusinessAddress());
            }
        }
        // 纳税人识别号精确查询
        if (StringUtils.hasText(supplyDto.getTaxpayerId())) {
            queryWrapper.eq(Supply::getTaxpayerId, supplyDto.getTaxpayerId());
        }
        // 默认按创建时间倒序排列
        queryWrapper.orderByDesc(Supply::getCreateTime);
        return supplyMapper.selectPage(page, queryWrapper);
    }
@@ -52,6 +67,23 @@
    public int addOrEditSupply(SupplyDto supplyDto) {
        Supply supply = new Supply();
        BeanUtils.copyProperties(supplyDto, supply);
        if (supplyDto.getBids().size() != 3) {
            throw new RuntimeException("请选择经营地址省市区");
        }
        if (supplyDto.getCids().size() != 3) {
            throw new RuntimeException("请选择联系地址省市区");
        }
        supply.setBProvinceId(supplyDto.getBids().get(0));
        supply.setBCityId(supplyDto.getBids().get(1));
        supply.setBDistrictId(supplyDto.getBids().get(2));
        supply.setCProvinceId(supplyDto.getCids().get(0));
        supply.setCCityId(supplyDto.getCids().get(1));
        supply.setCDistrictId(supplyDto.getCids().get(2));
        if (Objects.isNull(supplyDto.getId())) {
            return supplyMapper.insert(supply);
        } else {
@@ -65,13 +97,29 @@
        if (ids == null || ids.length == 0) {
            return 0;
        }
        // 构造更新条件
        UpdateWrapper<Supply> updateWrapper = new UpdateWrapper<>();
        updateWrapper.in("id", ids)
                .set("deleted", 1);  // 设置 deleted 为 1 表示已删除
        // 执行批量逻辑删除
        return supplyMapper.update(null, updateWrapper);
    }
    @Override
    public void supplyExport(HttpServletResponse response, SupplyDto supplyDto) {
        List<Long> ids = supplyDto.getIds();
        List<Supply> list;
        if (ids != null && ids.size() > 0) {
            list = supplyMapper.selectByIds(ids);
        } else {
            list = supplyMapper.selectList(null);
        }
        ExcelUtil<Supply> util = new ExcelUtil<>(Supply.class);
        util.exportExcel(response, list, "供应商数据");
    }
    @Override
    public List<Supply> supplyList() {
        return supplyMapper.selectList(null);
    }
}