|
|
@@ -30,6 +30,7 @@ import com.xunmei.system.api.dto.SysPlanOrgDTO;
|
|
|
import com.xunmei.system.mapper.SysOrgMapper;
|
|
|
import com.xunmei.system.service.*;
|
|
|
import com.xunmei.system.util.UserExport;
|
|
|
+import com.xunmei.system.util.UserImport;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -511,8 +512,8 @@ public class SysUserController extends BaseController {
|
|
|
AtomicInteger xh = new AtomicInteger();
|
|
|
xh.getAndIncrement();
|
|
|
list.forEach(e -> {
|
|
|
- if (e.getIsManager() == null) {
|
|
|
- e.setIsManager("N");
|
|
|
+ if (e.getIsManage() == null) {
|
|
|
+ e.setIsManage("N");
|
|
|
}
|
|
|
e.setXh(String.valueOf(xh.getAndIncrement()));
|
|
|
});
|
|
|
@@ -548,13 +549,13 @@ public class SysUserController extends BaseController {
|
|
|
if (ObjectUtil.isEmpty(list)) {
|
|
|
throw new RuntimeException("导出数据为空!");
|
|
|
}
|
|
|
- list = list.stream().filter(e -> "Y".equals(e.getIsManager())).collect(Collectors.toList());
|
|
|
+ list = list.stream().filter(e -> "Y".equals(e.getIsManage())).collect(Collectors.toList());
|
|
|
|
|
|
AtomicInteger xh = new AtomicInteger();
|
|
|
xh.getAndIncrement();
|
|
|
list.forEach(e -> {
|
|
|
- if (e.getIsManager() == null) {
|
|
|
- e.setIsManager("N");
|
|
|
+ if (e.getIsManage() == null) {
|
|
|
+ e.setIsManage("N");
|
|
|
}
|
|
|
e.setXh(String.valueOf(xh.getAndIncrement()));
|
|
|
});
|
|
|
@@ -586,12 +587,12 @@ public class SysUserController extends BaseController {
|
|
|
@PostMapping("/importData")
|
|
|
@Transactional(rollbackFor = {RuntimeException.class, Exception.class})
|
|
|
public AjaxResult importData(MultipartFile file, boolean updateSupport) {
|
|
|
- List<UserExport> list = new ArrayList<>();
|
|
|
+ List<UserImport> list = new ArrayList<>();
|
|
|
// 读取excel
|
|
|
- EasyExcel.read(multipartFileToFile(file), UserExport.class, new AnalysisEventListener<UserExport>() {
|
|
|
+ EasyExcel.read(multipartFileToFile(file), UserImport.class, new AnalysisEventListener<UserImport>() {
|
|
|
// 每解析一行数据,该方法会被调用一次
|
|
|
@Override
|
|
|
- public void invoke(UserExport user, AnalysisContext analysisContext) {
|
|
|
+ public void invoke(UserImport user, AnalysisContext analysisContext) {
|
|
|
// System.out.println("解析数据为:" + user.toString());
|
|
|
if (user.getName() != null) {
|
|
|
list.add(user);
|
|
|
@@ -602,18 +603,20 @@ public class SysUserController extends BaseController {
|
|
|
@Override
|
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
|
// System.out.println("解析完成...");
|
|
|
- List<String> names = list.stream().map(UserExport::getName).collect(Collectors.toList());
|
|
|
+ List<String> names = list.stream().map(UserImport::getName).collect(Collectors.toList());
|
|
|
List<String> exist = userService.selectCountByNames(names);
|
|
|
if (exist.size() > 0) {
|
|
|
throw new RuntimeException("用户" + exist + "已存在");
|
|
|
}
|
|
|
// 将解析的数据保存到数据库
|
|
|
- for (UserExport u : list) {
|
|
|
+ for (UserImport u : list) {
|
|
|
//构建基础user对象
|
|
|
SysUser user = new SysUser();
|
|
|
BeanUtils.copyProperties(u, user);
|
|
|
user.setDeleted(0);
|
|
|
- user.setIsLock("启用".equals(u.getIsLock()) ? "1" : "0");
|
|
|
+ user.setIsLock("正常".equals(u.getIsLock()) ? "1" : "0");
|
|
|
+ user.setIsManage("是".equals(u.getIsManage()) ? "Y" : null);
|
|
|
+ user.setGender("男".equals(u.getGender()) ? "0" : "1");
|
|
|
SysOrg org = orgMapper.selectOne(new LambdaQueryWrapper<SysOrg>().eq(SysOrg::getShortName, u.getOrgName()).eq(SysOrg::getDeleted, 0));
|
|
|
if (org == null) {
|
|
|
throw new RuntimeException("机构" + u.getOrgName() + "不存在");
|