From 7f3f23d57a92b4c1a79c2629562936c81beae8ca Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 11 Nov 2021 12:02:43 +0800
Subject: [PATCH] 组织机构数修改,用户指纹上传修改
---
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java | 121 +++++++++++++++++++++++++++++++---------
1 files changed, 93 insertions(+), 28 deletions(-)
diff --git a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
index c780473..c53ae9b 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -43,6 +43,8 @@
import org.springblade.modules.dispatcher.vo.DispatcherVO;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.information.service.IInformationService;
+import org.springblade.modules.jurisdiction.entity.Jurisdiction;
+import org.springblade.modules.jurisdiction.service.JurisdictionService;
import org.springblade.modules.system.entity.*;
import org.springblade.modules.system.excel.QrCodeExcel;
import org.springblade.modules.system.excel.SecurityExcel;
@@ -81,6 +83,7 @@
private final BladeTenantProperties tenantProperties;
private final IInformationService iInformationService;
private final IDeptService deptService;
+ private final JurisdictionService jurisdictionService;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -381,35 +384,39 @@
return deleteLogic(Func.toLongList(userIds));
}
+ /**
+ * 用户民警的导入
+ * @param data
+ * @param isCovered
+ * @param deptId
+ */
@Override
// @Transactional(rollbackFor = Exception.class) 去除事务回滚
public void importUser(List<UserExcel> data, Boolean isCovered,String deptId) {
- //将不能导入的保安员账号存起来
+ //将不能导入的账号存起来
List<String> errorList = new ArrayList<>();
- //将需要新增的保安员信息存入集合
- List<User> insertList = new ArrayList<>();
- //将需要更新的保安员信息存入集合
- List<User> updateList = new ArrayList<>();
//导入状态,默认为true ,如果有一个出现问题则为 false
AtomicBoolean status = new AtomicBoolean(true);
data.forEach(userExcel -> {
User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class));
//设置部门id
String deptIds = userDeptService.selectIn(user.getDeptId());
- if (null!=deptIds && !deptIds.equals("")) {
- if (null != deptId && !deptId.equals("")) {
- if (!deptId.equals(deptIds)) {
- throw new ServiceException("导入失败!不能导入不是本公司的保安员数据!");
- }
- }
- user.setDeptId(deptIds);
- }else {
- //如果deptIds 为空,则说明还没有改公司
- throw new ServiceException("导入失败!公司名:["+user.getDeptId()+"]不存在!");
- }
+// if (null!=deptIds && !deptIds.equals("")) {
+// if (null != deptId && !deptId.equals("")) {
+// if (!deptId.equals(deptIds)) {
+// throw new ServiceException("导入失败!不能导入不是当前辖区(机构)的数据!");
+// }
+// }
+// user.setDeptId(deptIds);
+// }else {
+// //如果deptIds 为空,则说明还没有改公司
+// throw new ServiceException("导入失败!机构名:["+user.getDeptId()+"]不存在!");
+// }
+ user.setDeptId(deptIds);
//判断当前用户是否已在本单位,如果是的更新数据
User user1 = new User();
- user1.setAccount(user.getCardid());
+ user1.setAccount(user.getDeptId());
+// user1.setAccount(user.getCode());
user1.setIsDeleted(0);
user1.setStatus(1);
User user2 = this.getOne(Condition.getQueryWrapper(user1));
@@ -419,9 +426,15 @@
user.setTenantId("000000");
//默认在职
user.setStatus(1);
- //分配保安角色
+ user.setIsDeleted(0);
+ user.setCreateTime(new Date());
+ user.setUpdateTime(new Date());
+ //设置账号
+ user.setAccount(userExcel.getDeptId());
+ //user.setAccount(user.getCode());
+ //分配角色
Role role = new Role();
- role.setRoleAlias("保安");
+ role.setRoleAlias("公安管理员");
Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
user.setRoleId(oneRole.getId().toString());
//性别
@@ -434,18 +447,52 @@
}
}
- //设置账号
- user.setAccount(user.getCardid());
+ //获取辖区的数据
+ Jurisdiction jurisdiction = new Jurisdiction();
+ jurisdiction.setDeptName(userExcel.getDeptId());
+ Jurisdiction one = jurisdictionService.getOne(Condition.getQueryWrapper(jurisdiction));
+ user.setJurisdiction(one.getId().toString());
+
+
//获取默认密码配置
- user.setPassword(user.getCardid().substring(user.getCardid().length() - 6));
-// user.setPassword(ParamCache.getValue(DEFAULT_PARAM_PASSWORD));
+ user.setPassword("123456");
+// user.setPassword(user.getCode());
+ //加密
+ if (Func.isNotEmpty(user.getPassword())) {
+ user.setPassword(DigestUtil.encrypt(user.getPassword()));
+ }
+ Integer userCount = baseMapper.selectCountAccount(user.getAccount());
+ if (userCount > 0 && Func.isEmpty(user.getId())) {
+ throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount()));
+ }
//新增
- this.submit(user);
+ this.save(user);
+ //内网同步
+ String s = "insert into blade_user(" +
+ "id,tenant_id,code,account,password,real_name,phone,sex,role_id,dept_id," +
+ "create_time,update_time,cardid,status,is_deleted,jurisdiction) " +
+ "values(" + "'" + user.getId() + "'" + "," +
+ "'" + user.getTenantId() + "'" + "," +
+ "'" + user.getCode() + "'" + "," +
+ "'" + user.getAccount() + "'" + "," +
+ "'" + user.getPassword() + "'" + "," +
+ "'" + user.getRealName() + "'" + "," +
+ "'" + user.getPhone() + "'" + "," +
+ "'" + user.getSex() + "'" + "," +
+ "'" + user.getRoleId() + "'" +
+ "," + "'" + user.getDeptId() + "'" +
+ "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getCreateTime()) + "'" +
+ "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" +
+ "," + "'" + user.getCardid() + "'" +
+ "," + "'" + user.getStatus() + "'" +
+ "," + "'" + user.getIsDeleted() + "'" +
+ "," + "'" + user.getJurisdiction() + "'"
+ + ")";
+ FtpUtil.sqlFileUpload(s);
}else {
//匹配组织机构是否一致,如果不一致
if(!user2.getDeptId().equals(user.getDeptId())){
Dept dept = deptService.getById(user2.getDeptId());
-// throw new ServiceException("用户:"+"["+user.getCardid()+"]"+"已在其他单位存在!");
status.set(false);
//加入集合
errorList.add(user.getCardid());
@@ -454,11 +501,29 @@
}else {
//如果是一致,则更新用户数据
//更新用户数据
+ user2.setUpdateTime(new Date());
+ if (null!=user.getPhone() && !user.getPhone().equals("")){
+ user2.setPhone(user.getPhone());
+ }
+ if (null!=user.getRealName() && !user.getRealName().equals("")){
+ user2.setRealName(user.getRealName());
+ }
+ if (null!=user.getCardid() && !user.getCardid().equals("")){
+ user2.setCardid(user.getCardid());
+ }
+ if (null!=user.getCode() && !user.getCode().equals("")){
+ user2.setCode(user.getCode());
+ user2.setAccount(user.getCode());
+ }
+ user2.setAccount(userExcel.getDeptId());
this.updateById(user2);
String s1 =
- "update blade_user set hold = " + "'" + user2.getHold() + "'"
- + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'"
- + ",registered = " + "'" + user2.getRegistered() + "'"
+ "update blade_user set account = " + "'" + user2.getAccount() + "'"
+ + ",code = " + "'" + user2.getCode() + "'"
+ + ",real_name = " + "'" + user2.getRealName() + "'"
+ + ",phone = " + "'" + user2.getPhone() + "'"
+ + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user2.getUpdateTime()) + "'"
+ + ",cardid = " + "'" + user2.getCardid() + "'"
+ " " + "where id = " + "'" + user2.getId() + "'";
FtpUtil.sqlFileUpload(s1);
}
--
Gitblit v1.9.3