Browse Source

用户导入修改

anderx 2 years ago
parent
commit
ebd25bc378

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -455,7 +455,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
                             throw new ServiceException(String.format("项目[%s]不存在",p.getProjectName()));
                         }
                     }else {
-                        throw new ServiceException(String.format("新增必须知道打卡项目"));
+                        throw new ServiceException(String.format("新增必须知道打卡项目编号"));
                     }
                     p.setProcessStatus(2);
                     projectStaffRecordMapper.insertSelective(p);

+ 11 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ruoyi.system.service.impl;
 
+import java.sql.SQLException;
+import java.sql.SQLIntegrityConstraintViolationException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -552,6 +554,8 @@ public class SysUserServiceImpl implements ISysUserService
                         SysDept sysDept = deptService.selectByDepName(user.getDeptName(), company);
                         if (sysDept ==null){
                             throw  new ServiceException("部门数据异常,找不到部门");
+                        }else {
+                            user.setDeptId(sysDept.getDeptId());
                         }
                     }
                     userMapper.insertUser(user);
@@ -584,6 +588,8 @@ public class SysUserServiceImpl implements ISysUserService
                         SysDept sysDept = deptService.selectByDepName(user.getDeptName(), company);
                         if (sysDept ==null){
                             throw  new ServiceException("部门数据异常,找不到部门");
+                        }else {
+                            user.setDeptId(sysDept.getDeptId());
                         }
                     }
                     if (user.getRoleName()!=null&&!user.getRoleName().equals(u.getRoleName())){
@@ -613,7 +619,11 @@ public class SysUserServiceImpl implements ISysUserService
             {
                 failureNum++;
                 String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
-//                failureMsg.append(msg + e.getMessage());
+                if (e instanceof ServiceException){
+                    failureMsg.append(msg + e.getMessage());
+                }else if (e instanceof SQLException){
+                    failureMsg.append("数据异常");
+                }
                 log.error(msg, e);
             }
         }