Browse Source

bug修复:#16987 角色导入时特定模版会出现导入失败问题

ZL 1 day ago
parent
commit
fb068a028e

+ 1 - 1
jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ImportExcelUtil.java

@@ -52,7 +52,7 @@ public class ImportExcelUtil {
                 int lineNumber = i + 1;
                 // 通过索引名判断出错信息
                 if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE_APP_ID)) {
-                    errorMessage.add("第 " + lineNumber + " 行:角色编码已经存在,忽略导入。");
+                    errorMessage.add("第 " + lineNumber + " 行:同应用内角色编码已经存在,忽略导入。");
                 } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) {
                     errorMessage.add("第 " + lineNumber + " 行:任务类名已经存在,忽略导入。");
                 }else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) {

+ 13 - 5
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysRoleServiceImpl.java

@@ -12,6 +12,7 @@ import org.jeecg.modules.system.entity.SysRole;
 import org.jeecg.modules.system.mapper.SysRoleMapper;
 import org.jeecg.modules.system.mapper.SysUserMapper;
 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.entity.ImportParams;
 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.web.multipart.MultipartFile;
 
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -68,18 +70,24 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
 
     @Override
     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();
         List<String> errorStrs = new ArrayList<>();
 
         // 去除 listSysRoles 中重复的数据
         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++) {
-                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);
                     break;
                 }

+ 1 - 1
jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/util/ExcelImportHandleUtil.java

@@ -15,7 +15,7 @@ public class ExcelImportHandleUtil {
      *
      * @param file (上传的文件的对象)
      * @param headerRowsNumber (表头有多少行)
-     * @param sheetIndex  (Sheet索引)
+     * @param SheetIndex  (Sheet索引)
      * @return inputStream (输入流)
      * @throws IOException
      */

+ 2 - 1
jeecgboot-vue3/src/layouts/default/header/components/notify/index.vue

@@ -30,7 +30,6 @@ import { getToken } from '/@/utils/auth';
 import md5 from 'crypto-js/md5';
 
 import SysMessageModal from '/@/views/system/message/components/SysMessageModal.vue';
-import { l } from 'vite/dist/node/types.d-aGj9QkWt';
 
 export default defineComponent({
   components: {
@@ -183,10 +182,12 @@ export default defineComponent({
       // WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
       let url = glob.domainUrl?.replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId;
       connectWebSocket(url);
+      console.log('---初始化websocekt-111111111111111111--');
       onWebSocket(onWebSocketMessage);
     }
 
     function onWebSocketMessage(data) {
+      console.log('---onWebSocketMessage---', data);
       if (data.cmd === 'topic' || data.cmd === 'user') {
         //update-begin-author:taoyan date:2022-7-13 for: VUEN-1674【严重bug】系统通知,为什么必须刷新右上角才提示
         //后台保存数据太慢 前端延迟刷新消息