From 2a9c3934bb093c978a54a1c3e220e6a120855e77 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 09 一月 2026 15:11:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/jtwy' into jtwy
---
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java | 42 ++++++++++++++++++++++++++++++++++++++----
1 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
index afc1c30..f24a2d2 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,10 +12,17 @@
import com.ruoyi.basic.service.ICustomerService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.pojo.SalesLedger;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List;
@@ -33,6 +41,7 @@
@AllArgsConstructor
@Slf4j
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements ICustomerService {
+ private final SalesLedgerMapper salesLedgerMapper;
private CustomerMapper customerMapper;
/**
@@ -65,8 +74,12 @@
// 2. 鏋勫缓鏌ヨ鏉′欢锛堝寮虹┖鍊煎畨鍏級
LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
String customerName = customer.getCustomerName();
+ String customerType = customer.getCustomerType();
if (StringUtils.isNotBlank(customerName)) {
queryWrapper.like(Customer::getCustomerName, customerName);
+ }
+ if (StringUtils.isNotBlank(customerType)) {
+ queryWrapper.like(Customer::getCustomerType, customerType);
}
// 3. 鎵ц鍒嗛〉鏌ヨ锛堜繚鐣欏垎椤靛厓鏁版嵁锛�
@@ -98,8 +111,8 @@
@Override
public int insertCustomer(Customer customer) {
LoginUser loginUser = SecurityUtils.getLoginUser();
- Integer tenantId = loginUser.getTenantId();
- customer.setTenantId(Long.valueOf(tenantId));
+ Long tenantId = loginUser.getTenantId();
+ customer.setTenantId(tenantId);
return customerMapper.insert(customer);
}
@@ -112,8 +125,8 @@
@Override
public int updateCustomer(Customer customer) {
LoginUser loginUser = SecurityUtils.getLoginUser();
- Integer tenantId = loginUser.getTenantId();
- customer.setTenantId(Long.valueOf(tenantId));
+ Long tenantId = loginUser.getTenantId();
+ customer.setTenantId(tenantId);
return customerMapper.updateById(customer);
}
@@ -126,6 +139,10 @@
@Override
public int deleteCustomerByIds(Long[] ids) {
List<Long> idList = Arrays.asList(ids);
+ List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(new QueryWrapper<SalesLedger>().lambda().in(SalesLedger::getCustomerId, idList));
+ if (!salesLedgers.isEmpty()) {
+ throw new RuntimeException("瀹㈡埛妗f涓嬫湁閿�鍞悎鍚岋紝璇峰厛鍒犻櫎閿�鍞悎鍚�");
+ }
return customerMapper.deleteBatchIds(idList);
}
@@ -142,6 +159,23 @@
}
@Override
+ public AjaxResult importData(MultipartFile file) {
+ try {
+ ExcelUtil<Customer> util = new ExcelUtil<Customer>(Customer.class);
+ List<Customer> userList = util.importExcel(file.getInputStream());
+ if(CollectionUtils.isEmpty(userList)){
+ return AjaxResult.warn("妯℃澘閿欒鎴栧鍏ユ暟鎹负绌�");
+ }
+ this.saveOrUpdateBatch(userList);
+ return AjaxResult.success(true);
+ }catch (Exception e){
+ e.printStackTrace();
+ return AjaxResult.error("瀵煎叆澶辫触");
+ }
+
+ }
+
+ @Override
public List<Map<String, Object>> customerList(Customer customer) {
LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber);
--
Gitblit v1.9.3