0
0

APP/小程序用户设备绑定

This commit is contained in:
2025-07-05 15:55:46 +08:00
parent 5322e84a92
commit ad82ab5fca
18 changed files with 376 additions and 98 deletions

View File

@ -29,7 +29,6 @@ import java.util.*;
@Slf4j
public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportDTO> {
// 存储图片数据的映射
private final Map<Integer, byte[]> rowImageMap = new HashMap<>();
@ -48,6 +47,7 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
this.params = params;
}
public ImportResult getImportResult() {
ImportResult result = new ImportResult();
result.setSuccessCount(successCount);
@ -151,23 +151,26 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
Device device = rowDeviceMap.get(rowIndex);
DeviceExcelImportDTO originalDto = rowDtoMap.get(rowIndex);
try {
DeviceQueryCriteria criteria = new DeviceQueryCriteria();
criteria.setDeviceMac(device.getDeviceMac());
criteria.setTenantId(params.getTenantId());
List<Device> deviceList = params.getDeviceMapper().findAll(criteria);
if (!deviceList.isEmpty()) {
throw new RuntimeException("设备MAC重复");
}
device.setTenantId(params.getTenantId());
// DeviceQueryCriteria criteria = new DeviceQueryCriteria();
// criteria.setDeviceMac(device.getDeviceMac());
// criteria.setTenantId(params.getTenantId());
// List<Device> deviceList = params.getDeviceMapper().findAll(criteria);
// if (!deviceList.isEmpty()) {
// throw new RuntimeException("设备MAC重复");
// }
// device.setTenantId(params.getTenantId());
// 设备类型
QueryWrapper<DeviceType> wrapper = new QueryWrapper<>();
wrapper.eq("type_name", device.getTypeName());
wrapper.eq("customer_id", params.getUserId());
// wrapper.eq("customer_id", params.getUserId());
List<DeviceType> deviceTypes = params.getDeviceTypeMapper().selectList(wrapper);
if (CollectionUtil.isNotEmpty(deviceTypes)) {
device.setDeviceType(deviceTypes.get(0).getId());
}
device.setCurrentOwnerId(loginUser.getUserId());
device.setOriginalOwnerId(loginUser.getUserId());
device.setCreateByName(loginUser.getNickname());
params.getDeviceService().save(device);
successCount++;
log.info("行 {} 数据插入成功", rowIndex);