1
0

分页查询客户

This commit is contained in:
2025-07-03 10:08:09 +08:00
parent fe6de8f5bc
commit abe9dc2fe8
13 changed files with 305 additions and 4 deletions

View File

@ -101,6 +101,12 @@
<artifactId>fys-common-sse</artifactId>
</dependency>
<!-- 客户管理模块 -->
<dependency>
<groupId>com.fuyuanshen</groupId>
<artifactId>fys-customer</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>

View File

@ -38,6 +38,9 @@ public class Device extends TenantEntity {
@Schema(name = "客户号")
private Long customerId;
@Schema(name = "所属客户")
private String customerName;
/**
* 当前所有者
* current_owner_id
@ -52,8 +55,6 @@ public class Device extends TenantEntity {
@Schema(name = "原始所有者(创建者)")
private Long originalOwnerId;
@Schema(name = "所属客户")
private String customerName;
/*@Schema( name = "设备编号")
private String deviceNo;*/

View File

@ -17,6 +17,8 @@ import com.fuyuanshen.equipment.domain.vo.CustomerVo;
import com.fuyuanshen.equipment.mapper.DeviceMapper;
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
import com.fuyuanshen.equipment.service.DeviceService;
import com.fuyuanshen.fyscustomer.domain.Customer;
import com.fuyuanshen.fyscustomer.mapper.CustomerMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@ -49,6 +51,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
private final DeviceMapper deviceMapper;
private final DeviceTypeMapper deviceTypeMapper;
private final CustomerMapper customerMapper;
/**
* 分页查询设备
@ -219,7 +223,40 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public void assignCustomer(CustomerVo customerVo) {
List<Long> deviceIds = customerVo.getDeviceIds();
Long customerId = customerVo.getCustomerId();
Customer customer = customerMapper.queryCustomerById(customerId, LoginHelper.getLoginUser().getPid());
if (customer == null) {
throw new RuntimeException("待分配的客户不存在!!!");
}
List<Long> invalidIds = new ArrayList<>();
List<Device> devices = new ArrayList<>();
for (Long id : deviceIds) {
Device device = deviceMapper.selectById(id);
if (device == null || !Objects.equals(device.getCurrentOwnerId(), LoginHelper.getUserId())) {
invalidIds.add(id);
continue;
}
device.setCustomerId(customerId);
device.setCustomerName(customer.getNickName());
devices.add(device);
}
if (!invalidIds.isEmpty()) {
throw new RuntimeException("以下设备无法分配ID 不存在或无权限): " + invalidIds);
}
devices.forEach((device) -> {
deviceMapper.updateById(device);
device.setId( null);
device.setCurrentOwnerId(customerId);
deviceMapper.insert( device);
});
}
public void assign(List<Long> deviceIds) {
}