diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java index cb1fd102..ca07f30e 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/PostExcelVO.java @@ -1,7 +1,9 @@ package com.pig4cloud.pig.admin.api.vo; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.pig4cloud.plugin.excel.annotation.ExcelLine; import lombok.Data; import javax.validation.constraints.NotBlank; @@ -21,6 +23,13 @@ public class PostExcelVO implements Serializable { private static final long serialVersionUID = 1L; + /** + * excel 行号 + */ + @ExcelLine + @ExcelIgnore + private Long lineNum; + /** * 主键ID */ diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java index 81da8833..b53e9fc7 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/RoleExcelVO.java @@ -1,7 +1,9 @@ package com.pig4cloud.pig.admin.api.vo; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.pig4cloud.plugin.excel.annotation.ExcelLine; import lombok.Data; import javax.validation.constraints.NotBlank; @@ -20,6 +22,13 @@ public class RoleExcelVO implements Serializable { private static final long serialVersionUID = 1L; + /** + * excel 行号 + */ + @ExcelLine + @ExcelIgnore + private Long lineNum; + /** * 主键ID */ diff --git a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java index 97b0f251..255bffbe 100644 --- a/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java +++ b/pig-upms/pig-upms-api/src/main/java/com/pig4cloud/pig/admin/api/vo/UserExcelVO.java @@ -1,7 +1,9 @@ package com.pig4cloud.pig.admin.api.vo; +import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.pig4cloud.plugin.excel.annotation.ExcelLine; import lombok.Data; import javax.validation.constraints.NotBlank; @@ -20,6 +22,13 @@ public class UserExcelVO implements Serializable { private static final long serialVersionUID = 1L; + /** + * excel 行号 + */ + @ExcelLine + @ExcelIgnore + private Long lineNum; + /** * 主键ID */ diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPostServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPostServiceImpl.java index a9974d2c..b2231106 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPostServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysPostServiceImpl.java @@ -60,8 +60,7 @@ public class SysPostServiceImpl extends ServiceImpl impl List postList = this.list(); // 执行数据插入操作 组装 PostDto - for (int i = 0; i < excelVOList.size(); i++) { - PostExcelVO excel = excelVOList.get(i); + for (PostExcelVO excel : excelVOList) { Set errorMsg = new HashSet<>(); // 检验岗位名称或者岗位编码是否存在 boolean existPost = postList.stream().anyMatch(post -> excel.getPostName().equals(post.getPostName()) @@ -78,7 +77,7 @@ public class SysPostServiceImpl extends ServiceImpl impl } else { // 数据不合法 - errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); + errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg)); } } if (CollUtil.isNotEmpty(errorMessageList)) { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleServiceImpl.java index 0fd56b6e..3d6c9f6f 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysRoleServiceImpl.java @@ -84,8 +84,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl List roleList = this.list(); // 执行数据插入操作 组装 RoleDto - for (int i = 0; i < excelVOList.size(); i++) { - RoleExcelVO excel = excelVOList.get(i); + for (RoleExcelVO excel : excelVOList) { Set errorMsg = new HashSet<>(); // 检验角色名称或者角色编码是否存在 boolean existRole = roleList.stream().anyMatch(sysRole -> excel.getRoleName().equals(sysRole.getRoleName()) @@ -102,7 +101,7 @@ public class SysRoleServiceImpl extends ServiceImpl impl } else { // 数据不合法情况 - errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); + errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg)); } } if (CollUtil.isNotEmpty(errorMessageList)) { diff --git a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java index c7f92e37..38e9757d 100644 --- a/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java +++ b/pig-upms/pig-upms-biz/src/main/java/com/pig4cloud/pig/admin/service/impl/SysUserServiceImpl.java @@ -38,7 +38,6 @@ import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum; import com.pig4cloud.pig.common.core.exception.ErrorCodes; import com.pig4cloud.pig.common.core.util.MsgUtils; import com.pig4cloud.pig.common.core.util.R; -import com.pig4cloud.pig.common.security.util.SecurityUtils; import com.pig4cloud.plugin.excel.vo.ErrorMessage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -278,8 +277,7 @@ public class SysUserServiceImpl extends ServiceImpl impl List postList = sysPostMapper.selectList(Wrappers.emptyWrapper()); // 执行数据插入操作 组装 UserDto - for (int i = 0; i < excelVOList.size(); i++) { - UserExcelVO excel = excelVOList.get(i); + for (UserExcelVO excel : excelVOList) { Set errorMsg = new HashSet<>(); // 校验用户名是否存在 boolean exsitUserName = userList.stream() @@ -322,7 +320,7 @@ public class SysUserServiceImpl extends ServiceImpl impl } else { // 数据不合法情况 - errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); + errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg)); } }