From e41884a4ce0e0bfa38a708b633285e4a58cca2c3 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 17 Jun 2022 18:41:03 +0800
Subject: [PATCH] 修改人员导入的方法
---
src/main/java/org/springblade/modules/securitypaper/service/impl/SecurityPaperServiceImpl.java | 229 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 127 insertions(+), 102 deletions(-)
diff --git a/src/main/java/org/springblade/modules/securitypaper/service/impl/SecurityPaperServiceImpl.java b/src/main/java/org/springblade/modules/securitypaper/service/impl/SecurityPaperServiceImpl.java
index b10c015..d360e30 100644
--- a/src/main/java/org/springblade/modules/securitypaper/service/impl/SecurityPaperServiceImpl.java
+++ b/src/main/java/org/springblade/modules/securitypaper/service/impl/SecurityPaperServiceImpl.java
@@ -10,6 +10,7 @@
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.modules.FTP.Result;
+import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.securitypaper.entity.SecurityPaper;
import org.springblade.modules.securitypaper.excel.SecurityPaperExcel;
import org.springblade.modules.securitypaper.mapper.SecurityPaperMapper;
@@ -38,6 +39,121 @@
private final RedisTemplate redisTemplate;
+// /**
+// * 导入保安员证数据
+// * @param data
+// * @param isCovered
+// * @param deptId
+// */
+// @Override
+// public void importSecurityPaper(List<SecurityPaperExcel> data, Boolean isCovered, String deptId) {
+// //需要推送内网的保安员信息集合
+// List<User> userList = new ArrayList<>();
+// //年龄不符的保安员信息存入集合
+// List<String> cardErrorList = new ArrayList<>();
+// boolean flag = false;
+// for (SecurityPaperExcel paperExcel : data) {
+// User user = Objects.requireNonNull(BeanUtil.copy(paperExcel, User.class));
+// //设置部门id
+// String deptIds = userDeptService.selectIn(user.getDeptId());
+// if (null!=deptIds && !deptIds.equals("")) {
+// user.setDeptId(deptIds);
+// }else {
+// //如果deptIds 为空,则说明还没有改公司
+// throw new ServiceException("导入失败!公司名:["+user.getDeptId()+"]不存在!");
+// }
+//
+// //身份证校验
+// if (null==user.getCardid() || user.getCardid().equals("")){
+// throw new ServiceException("导入失败!身份证号码不能为空!");
+// }
+// //身份证住址校验
+// if (null==user.getRegistered() || user.getRegistered().equals("")){
+// throw new ServiceException("导入失败!身份证住址不能为空!");
+// }
+// if (null!=user.getCardid() && !user.getCardid().equals("")){
+// //去除所有空格
+// String cardid = user.getCardid().replaceAll(" ", "");
+// //校验
+// boolean b = IdCardNoUtil.checkIdCardNo(cardid);
+// if(b){
+// user.setCardid(cardid);
+// }else {
+// flag = true;
+// cardErrorList.add(user.getCardid());
+//// throw new ServiceException("导入失败!身份证号码[ "+user.getCardid()+" ]不正确,请核对!");
+// continue;
+// }
+// }
+//
+// // 设置租户ID
+// user.setTenantId("000000");
+// //默认在职
+// user.setStatus(1);
+// user.setIsDeleted(0);
+// //分配保安角色
+// user.setRoleId("1412226235153731586");
+//
+// //默认设置未持证
+// user.setHold("2");
+//
+// //性别
+// if (IdCardNoUtil.getSex(paperExcel.getCardid()).equals("男")) {
+// user.setSex(1);
+// }else {
+// user.setSex(2);
+// }
+//
+// //设置账号
+// String realName = user.getRealName();
+// String cardid = user.getCardid();
+// user.setAccount(realName.substring(0,1)+cardid.substring(cardid.length()-4));
+// //加密
+// user.setPassword(DigestUtil.encrypt(user.getCardid().substring(user.getCardid().length() - 6)));
+// user.setCreateTime(new Date());
+// user.setUpdateTime(new Date());
+// user.setDispatch("1");
+// //待审查
+// user.setExaminationType("2");
+//
+// //推送内网的数据
+// User user0 = Objects.requireNonNull(BeanUtil.copy(user,User.class));
+//
+// //生成随机数
+// String uuid = UUID.randomUUID().toString();
+// //将 user 存入 redis
+// redisTemplate.opsForValue().set(uuid, JSON.toJSONString(user));
+// //user0 临时设置uuid 到 reason_for_leav 离职原因字段
+// user0.setReasonForLeav(uuid);
+// //加入集合
+// userList.add(user0);
+// }
+//
+// //用户批量插入
+// if (userList.size()>0) {
+// //生成随机数
+// String uuid = UUID.randomUUID().toString();
+// //数据推送
+// Map<String, Object> map = new HashMap<>(1);
+// map.put(uuid, userList);
+// myAsyncService.FTPSecurityPaperAndUserImport(map);
+// }
+//
+// //如果所有数据导入有一个异常
+// StringBuilder errorBuilder = new StringBuilder();
+// if (flag){
+// String errorAccount = StringUtils.join(cardErrorList, "\\\n");
+// errorBuilder.append("用户:[" + errorAccount + "]导入失败!身份证号码不正确,请核对!");
+// }
+//
+// //抛出异常
+// if (errorBuilder.length()>0){
+// throw new ServiceException(errorBuilder.toString());
+// }
+//
+// }
+//
+
/**
* 导入保安员证数据
* @param data
@@ -46,109 +162,18 @@
*/
@Override
public void importSecurityPaper(List<SecurityPaperExcel> data, Boolean isCovered, String deptId) {
- //需要推送内网的保安员信息集合
- List<User> userList = new ArrayList<>();
- //年龄不符的保安员信息存入集合
- List<String> cardErrorList = new ArrayList<>();
- boolean flag = false;
- for (SecurityPaperExcel paperExcel : data) {
- User user = Objects.requireNonNull(BeanUtil.copy(paperExcel, User.class));
- //设置部门id
- String deptIds = userDeptService.selectIn(user.getDeptId());
- if (null!=deptIds && !deptIds.equals("")) {
- user.setDeptId(deptIds);
- }else {
- //如果deptIds 为空,则说明还没有改公司
- throw new ServiceException("导入失败!公司名:["+user.getDeptId()+"]不存在!");
+ if (data.size()>0){
+ for (SecurityPaperExcel securityPaperExcel : data) {
+ //去内网生成保安证编号,由内网生成,无需返回
+ //数据推送
+ Map<String, Object> map = new HashMap<>(1);
+ ExamScore examScore = new ExamScore();
+ examScore.setUserId(securityPaperExcel.getId());
+ examScore.setExamId("0");
+ examScore.setApplyId(0L);
+ map.put("key",examScore);
+ myAsyncService.FTPSecurityNumberBit(map);
}
-
- //身份证校验
- if (null==user.getCardid() || user.getCardid().equals("")){
- throw new ServiceException("导入失败!身份证号码不能为空!");
- }
- //身份证住址校验
- if (null==user.getRegistered() || user.getRegistered().equals("")){
- throw new ServiceException("导入失败!身份证住址不能为空!");
- }
- if (null!=user.getCardid() && !user.getCardid().equals("")){
- //去除所有空格
- String cardid = user.getCardid().replaceAll(" ", "");
- //校验
- boolean b = IdCardNoUtil.checkIdCardNo(cardid);
- if(b){
- user.setCardid(cardid);
- }else {
- flag = true;
- cardErrorList.add(user.getCardid());
-// throw new ServiceException("导入失败!身份证号码[ "+user.getCardid()+" ]不正确,请核对!");
- continue;
- }
- }
-
- // 设置租户ID
- user.setTenantId("000000");
- //默认在职
- user.setStatus(1);
- user.setIsDeleted(0);
- //分配保安角色
- user.setRoleId("1412226235153731586");
-
- //默认设置未持证
- user.setHold("2");
-
- //性别
- if (IdCardNoUtil.getSex(paperExcel.getCardid()).equals("男")) {
- user.setSex(1);
- }else {
- user.setSex(2);
- }
-
- //设置账号
- String realName = user.getRealName();
- String cardid = user.getCardid();
- user.setAccount(realName.substring(0,1)+cardid.substring(cardid.length()-4));
- //加密
- user.setPassword(DigestUtil.encrypt(user.getCardid().substring(user.getCardid().length() - 6)));
- user.setCreateTime(new Date());
- user.setUpdateTime(new Date());
- user.setDispatch("1");
- //待审查
- user.setExaminationType("2");
-
- //推送内网的数据
- User user0 = Objects.requireNonNull(BeanUtil.copy(user,User.class));
-
- //生成随机数
- String uuid = UUID.randomUUID().toString();
- //将 user 存入 redis
- redisTemplate.opsForValue().set(uuid, JSON.toJSONString(user));
- //user0 临时设置uuid 到 reason_for_leav 离职原因字段
- user0.setReasonForLeav(uuid);
- //加入集合
- userList.add(user0);
}
-
- //用户批量插入
- if (userList.size()>0) {
- //生成随机数
- String uuid = UUID.randomUUID().toString();
- //数据推送
- Map<String, Object> map = new HashMap<>(1);
- map.put(uuid, userList);
- myAsyncService.FTPSecurityPaperAndUserImport(map);
- }
-
- //如果所有数据导入有一个异常
- StringBuilder errorBuilder = new StringBuilder();
- if (flag){
- String errorAccount = StringUtils.join(cardErrorList, "\\\n");
- errorBuilder.append("用户:[" + errorAccount + "]导入失败!身份证号码不正确,请核对!");
- }
-
- //抛出异常
- if (errorBuilder.length()>0){
- throw new ServiceException(errorBuilder.toString());
- }
-
}
}
--
Gitblit v1.9.3