|
|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
+import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
|
import com.xjrsoft.module.base.dto.WhitelistManagementPageDto;
|
|
|
import com.xjrsoft.module.base.entity.TreeNode;
|
|
|
@@ -19,8 +21,10 @@ import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -105,4 +109,48 @@ public class WhitelistManagementServiceImpl extends MPJBaseServiceImpl<Whitelist
|
|
|
redisUtil.set(GlobalConstant.WHITE_MANAGEMENT_CACHE_KEY, map);
|
|
|
log.info("XJRSOFT: 加载所有学生电信开卡用户缓存结束");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean importData(List<WhitelistManagementPageVo> savedDataList) {
|
|
|
+ List<WhitelistManagement> whitelistManagements = new ArrayList<>();
|
|
|
+ List<String> errorLogs = new ArrayList<>();
|
|
|
+
|
|
|
+ for (WhitelistManagementPageVo vo : savedDataList) {
|
|
|
+ try {
|
|
|
+ if (this.checkExist(vo.getCredentialNumber())) continue;
|
|
|
+
|
|
|
+ String name = this.GetName(vo.getName()).toString();
|
|
|
+ String credentialNumber = this.GetCredentialNumber(vo.getCredentialNumber()).toString();
|
|
|
+ Long userId = this.getUserId(credentialNumber);
|
|
|
+ Long phone = this.GetPhone(Long.parseLong(vo.getPhone().toString()));
|
|
|
+
|
|
|
+ if (!name.isEmpty() && !credentialNumber.isEmpty() && !phone.toString().isEmpty()) {
|
|
|
+ WhitelistManagement whitelistManagement = new WhitelistManagement();
|
|
|
+ whitelistManagement.setCreateDate(new Date());
|
|
|
+ whitelistManagement.setDeleteMark(0);
|
|
|
+ whitelistManagement.setEnabledMark(0);
|
|
|
+ whitelistManagement.setUserId(userId);
|
|
|
+ whitelistManagement.setName(name);
|
|
|
+ whitelistManagement.setCredentialNumber(credentialNumber);
|
|
|
+ whitelistManagement.setPhone(phone);
|
|
|
+ whitelistManagements.add(whitelistManagement);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ errorLogs.add(String.format("[意外错误(检查输入的是否正确且存在,输入错误可能返回 null)] 姓名: %s, 身份证: %s, 手机号: %s - 错误信息:%s", vo.getName(), vo.getCredentialNumber(), vo.getPhone(), e.getMessage()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Boolean result = this.saveBatch(whitelistManagements);
|
|
|
+ if(result){
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ this.loadCaches();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (!errorLogs.isEmpty()) {
|
|
|
+ String detailedMessage = String.format("[导入完成但存在问题(检查输入的是否正确且存在,输入错误可能返回 null)] ", String.join("; ", errorLogs));
|
|
|
+ throw new MyException(detailedMessage);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|