From 40fdcab2eb2c1feb5b3c7e40fa5b8f3da66b8f96 Mon Sep 17 00:00:00 2001 From: mqh <1571896045@qq.com> Date: Thu, 20 Jul 2023 15:34:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E5=85=A5=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tablex/controller/TablexController.java | 38 +++++-------------- .../service/impl/TablexServiceImpl.java | 2 - 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java index cfe2e22..9eb9ff8 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/controller/TablexController.java @@ -300,8 +300,6 @@ public class TablexController extends JeecgController { if (StringUtils.isBlank(originalFilename) || (!originalFilename.endsWith("xls") && !originalFilename.endsWith("xlsx"))) { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件格式不正确"); } @@ -311,20 +309,14 @@ public class TablexController extends JeecgController { params.setHeadRows(1);//表头行数,默认1 params.setNeedSave(true);//是否需要保存上传的Excel,默认为false List list = null; - message.put("status", "读取数据中"); - webSocketUtils.sendMessage(loginUser.getId(), message); try { //读取excel数据 list = ExcelImportUtil.importExcel(file.getInputStream(), TablexVo.class, params); } catch (Exception e) { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件读取失败"); } //判断文件中是否存在数据 if (list == null || list.size() == 0) { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("Excel数据为空"); } @@ -376,16 +368,12 @@ public class TablexController extends JeecgController { String moduleId = voList.get(i).getModuleId(); if (moduleId == null || moduleId.equals("")) { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("对应模块填写不能为空"); } LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Modulex::getId, moduleId); Modulex modulex = modulexService.getOne(queryWrapper); if (modulex == null) { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("对应模块填写错误"); } String modulexId = modulex.getId(); @@ -410,6 +398,10 @@ public class TablexController extends JeecgController { if (verisonStatus.equals("1") || verisonStatus.equals("0")) { //判断版本号 if (voList.get(i).getVerison() != null && !voList.get(i).getVerison().equals("")) { + + message.put("status", "数据校验成功"); + webSocketUtils.sendMessage(loginUser.getId(), message); + tablex.setModuleId(voList.get(i).getModuleId()); tablex.setTableName(voList.get(i).getTableName()); tablex.setTableEnName(voList.get(i).getTableEnName()); @@ -422,47 +414,37 @@ public class TablexController extends JeecgController { tablexList.add(tablex); + message.put("status", "正在上传"); + webSocketUtils.sendMessage(loginUser.getId(), message); + //单条保存到真实表中 tablexService.saveSingleBatch(tablexList, loginUser, message); - } else { - /* message.put("isVisible", "false");*/ + message.put("status", "上传成功"); webSocketUtils.sendMessage(loginUser.getId(), message); + + } else { return Result.error("导入失败,第" + i + 1 + "行的版本号填写错误!"); } } else { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的版本状态填写错误!"); } } else { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的实体状态填写错误!"); } } else { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的英文名称填写错误!"); } } else { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的中文名称填写错误!"); } } else { - /*message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("导入失败,第" + i + 1 + "行的对应模块填写错误!"); } } } catch (Exception e) { - /* message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.error("文件导入失败"); } - /*message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); return Result.ok("文件导入成功!"); } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/service/impl/TablexServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/service/impl/TablexServiceImpl.java index c5779fa..1fad2b0 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/service/impl/TablexServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/tablex/service/impl/TablexServiceImpl.java @@ -48,8 +48,6 @@ public class TablexServiceImpl extends ServiceImpl impleme this.save(tablexList.get(i)); webSocketUtils.sendMessage(loginUser.getId(), message); } catch (InterruptedException e) { - /*message.put("isVisible", "false");*/ - webSocketUtils.sendMessage(loginUser.getId(), message); log.error(e.getMessage(), e); } }