Commit 808529e9 by 李小龙

fixbug:用户导入

parent b49aee2a
...@@ -58,11 +58,15 @@ public class ExcelErrorVo implements Serializable { ...@@ -58,11 +58,15 @@ public class ExcelErrorVo implements Serializable {
} }
} }
public static void exists(Map<String, String> emailMap,String value, List<ExcelErrorVo> errorVoList, int i, String title){ public static void exists(Map<String, String> emailMap,String key, List<ExcelErrorVo> errorVoList, int i, String title){
if (StringUtils.isBlank(key)){
return;
}
String value = emailMap.get(key);
if(StringUtils.isNotBlank(value)){ if(StringUtils.isNotBlank(value)){
errorVoList.add(new ExcelErrorVo(i,title,"数据重复")); errorVoList.add(new ExcelErrorVo(i,title,"数据重复"));
}else { }else {
emailMap.put(value,"system"); emailMap.put(key,"system");
} }
} }
} }
...@@ -1090,7 +1090,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -1090,7 +1090,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
userLambdaQueryWrapper.select(PlatUser::getMobile, PlatUser::getEmail, BaseEntity::getId); userLambdaQueryWrapper.select(PlatUser::getMobile, PlatUser::getEmail, BaseEntity::getId);
List<PlatUser> userList = this.list(userLambdaQueryWrapper); List<PlatUser> userList = this.list(userLambdaQueryWrapper);
Map<String, String> mobileMap = userList.stream().collect(Collectors.toMap(PlatUser::getMobile, BaseEntity::getId, (a, b) -> a)); Map<String, String> mobileMap = userList.stream().collect(Collectors.toMap(PlatUser::getMobile, BaseEntity::getId, (a, b) -> a));
Map<String, String> emailMap = userList.stream().collect(Collectors.toMap(PlatUser::getEmail, BaseEntity::getId, (a, b) -> a)); Map<String, String> emailMap = userList.stream().filter(vo->StringUtils.isNotBlank(vo.getEmail())).collect(Collectors.toMap(PlatUser::getEmail, BaseEntity::getId, (a, b) -> a));
return ExcelValidatorUtil.validateMain(3, platUserImportDTOS, list -> { return ExcelValidatorUtil.validateMain(3, platUserImportDTOS, list -> {
List<ExcelErrorVo> errorVoList = new ArrayList<>(); List<ExcelErrorVo> errorVoList = new ArrayList<>();
...@@ -1104,8 +1104,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser> ...@@ -1104,8 +1104,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
PlatOrg platOrg = Optional.ofNullable(orgNameMap.get(dto.getOrgName())).orElse(new PlatOrg()); PlatOrg platOrg = Optional.ofNullable(orgNameMap.get(dto.getOrgName())).orElse(new PlatOrg());
ExcelErrorVo.notExists(platOrg.getId(), errorVoList, start + i, "*所属组织"); ExcelErrorVo.notExists(platOrg.getId(), errorVoList, start + i, "*所属组织");
ExcelErrorVo.notExists(roleNameMap.get(dto.getRoleName()), errorVoList, start + i, "*角色"); ExcelErrorVo.notExists(roleNameMap.get(dto.getRoleName()), errorVoList, start + i, "*角色");
ExcelErrorVo.exists(mobileMap, mobileMap.get(dto.getMobile()), errorVoList, start + i, "手机号*"); ExcelErrorVo.exists(mobileMap, dto.getMobile(), errorVoList, start + i, "手机号*");
ExcelErrorVo.exists(emailMap, emailMap.get(dto.getEmail()), errorVoList, start + i, "邮箱"); ExcelErrorVo.exists(emailMap, dto.getEmail(), errorVoList, start + i, "邮箱");
} }
if (errorVoList.isEmpty()) { if (errorVoList.isEmpty()) {
List<PlatUser> platUsers = new ArrayList<>(); List<PlatUser> platUsers = new ArrayList<>();
......
...@@ -16,7 +16,6 @@ import com.makeit.service.platform.device.PlatDeviceService; ...@@ -16,7 +16,6 @@ import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.saas.PlatTenantService; import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil; import com.makeit.utils.DeviceCacheUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -67,13 +66,11 @@ public class IotSyncTask { ...@@ -67,13 +66,11 @@ public class IotSyncTask {
} }
//查询iot设备 //查询iot设备
List<DeviceInstanceEntity> iotDeviceList = iotOrgService.getOrgDevice(iotOrgId); List<DeviceInstanceEntity> iotDeviceList = iotOrgService.getOrgDevice(iotOrgId);
if (CollectionUtils.isEmpty(iotDeviceList)) {
continue;
}
//查询平台设备 //查询平台设备
Set<String> iotDeviceIdSet = iotDeviceList.stream().map(DeviceInstanceEntity::getId).collect(Collectors.toSet()); Set<String> iotDeviceIdSet = iotDeviceList.stream().map(DeviceInstanceEntity::getId).collect(Collectors.toSet());
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<PlatDevice>().eq(BaseBusEntity::getTenantId, platTenant.getId()) LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<PlatDevice>().eq(BaseBusEntity::getTenantId, platTenant.getId())
.in(PlatDevice::getOriDeviceId, iotDeviceIdSet); .in(PlatDevice::getOriDeviceId, iotDeviceIdSet);
iotDeviceIdSet.add("-1");
//删除设备 //删除设备
LambdaQueryWrapper<PlatDevice> removeQw = new LambdaQueryWrapper<PlatDevice>().notIn(PlatDevice::getOriDeviceId, iotDeviceIdSet) LambdaQueryWrapper<PlatDevice> removeQw = new LambdaQueryWrapper<PlatDevice>().notIn(PlatDevice::getOriDeviceId, iotDeviceIdSet)
.eq(BaseBusEntity::getTenantId, platTenant.getId()); .eq(BaseBusEntity::getTenantId, platTenant.getId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment