|
@@ -12,6 +12,7 @@ import org.jeecg.modules.system.entity.SysRole;
|
|
import org.jeecg.modules.system.mapper.SysRoleMapper;
|
|
import org.jeecg.modules.system.mapper.SysRoleMapper;
|
|
import org.jeecg.modules.system.mapper.SysUserMapper;
|
|
import org.jeecg.modules.system.mapper.SysUserMapper;
|
|
import org.jeecg.modules.system.service.ISysRoleService;
|
|
import org.jeecg.modules.system.service.ISysRoleService;
|
|
|
|
+import org.jeecg.modules.system.util.ExcelImportHandleUtil;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import java.io.InputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -68,18 +70,24 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result importExcelCheckRoleCode(MultipartFile file, ImportParams params) throws Exception {
|
|
public Result importExcelCheckRoleCode(MultipartFile file, ImportParams params) throws Exception {
|
|
- List<Object> listSysRoles = ExcelImportUtil.importExcel(file.getInputStream(), SysRole.class, params);
|
|
|
|
|
|
+ InputStream inputStream = ExcelImportHandleUtil.fileStreamProcessing(file, 3, 0);
|
|
|
|
+ List<Object> listSysRoles = ExcelImportUtil.importExcel(inputStream, SysRole.class, params);
|
|
|
|
+
|
|
int totalCount = listSysRoles.size();
|
|
int totalCount = listSysRoles.size();
|
|
List<String> errorStrs = new ArrayList<>();
|
|
List<String> errorStrs = new ArrayList<>();
|
|
|
|
|
|
// 去除 listSysRoles 中重复的数据
|
|
// 去除 listSysRoles 中重复的数据
|
|
for (int i = 0; i < listSysRoles.size(); i++) {
|
|
for (int i = 0; i < listSysRoles.size(); i++) {
|
|
- String roleCodeI =((SysRole)listSysRoles.get(i)).getRoleCode();
|
|
|
|
|
|
+ SysRole roleI = (SysRole) listSysRoles.get(i);
|
|
|
|
+ String roleCodeI = roleI.getRoleCode();
|
|
|
|
+ String appIdI = roleI.getAppId();
|
|
for (int j = i + 1; j < listSysRoles.size(); j++) {
|
|
for (int j = i + 1; j < listSysRoles.size(); j++) {
|
|
- String roleCodeJ =((SysRole)listSysRoles.get(j)).getRoleCode();
|
|
|
|
|
|
+ SysRole roleJ = (SysRole) listSysRoles.get(j);
|
|
|
|
+ String roleCodeJ = roleJ.getRoleCode();
|
|
|
|
+ String appIdJ = roleJ.getAppId();
|
|
// 发现重复数据
|
|
// 发现重复数据
|
|
- if (roleCodeI.equals(roleCodeJ)) {
|
|
|
|
- errorStrs.add("第 " + (j + 1) + " 行的 roleCode 值:" + roleCodeI + " 已存在,忽略导入");
|
|
|
|
|
|
+ if (roleCodeI.equals(roleCodeJ) && appIdI.equals(appIdJ)) {
|
|
|
|
+ errorStrs.add("第 " + (j + 1) + " 行的 roleCode 值:" + roleCodeI + " 在同一应用中已存在,忽略导入");
|
|
listSysRoles.remove(j);
|
|
listSysRoles.remove(j);
|
|
break;
|
|
break;
|
|
}
|
|
}
|