From befc0e5606ab7c913dda0346152a4150d0ee5f79 Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期五, 06 六月 2025 09:35:59 +0800 Subject: [PATCH] 供应商,客户优化 --- basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java | 75 ++++++++++++++++++++++++++++++------- 1 files changed, 61 insertions(+), 14 deletions(-) diff --git a/basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java b/basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java index d3ee17e..fdf4c45 100644 --- a/basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java +++ b/basic-server/src/main/java/com/ruoyi/basic/service/impl/SupplyServiceImpl.java @@ -4,14 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.basic.dto.SupplyDto; import com.ruoyi.basic.entity.Supply; import com.ruoyi.basic.mapper.SupplyMapper; import com.ruoyi.basic.service.SupplyService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.utils.bean.BeanUtils; -import org.springframework.stereotype.Service; +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; @@ -34,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); } @@ -53,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 { @@ -66,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); + } } -- Gitblit v1.9.3