From 757a9971c0d5a550c4e67511b0a11b0dc6226023 Mon Sep 17 00:00:00 2001 From: itcast Date: Thu, 20 Jul 2023 18:04:06 +0800 Subject: [PATCH] Changes --- .../fieldx/controller/FieldxController.java | 27 +++++++++++++++++-- .../src/main/resources/application-dev.yml | 4 +-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java index b290aba..74850b8 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/fieldx/controller/FieldxController.java @@ -18,8 +18,10 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.fieldx.dto.ExcelInfo; import org.jeecg.modules.fieldx.entity.Fieldx; import org.jeecg.modules.fieldx.entity.Fieldx222; @@ -34,6 +36,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.tablex.entity.Tablex; import org.jeecg.modules.tablex.service.ITablexService; import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.modules.tablex.ws.WebSocketUtils; import org.jsoup.helper.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -60,6 +63,8 @@ public class FieldxController extends JeecgController { private ITablexService tablexService; @Autowired private IFieldx222Service fieldx222Service; + @Autowired + private WebSocketUtils webSocketUtils; /** * 分页列表查询 @@ -290,12 +295,18 @@ public class FieldxController extends JeecgController { /** * 通过excel导入数据 * - * @param request - * @param response * @return */ @PostMapping("/importExcel") public Result importExcel(@RequestPart MultipartFile file) throws Exception { + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + + Map message = new HashMap<>(); + message.put("isVisible", "true"); + message.put("uploaded", "0"); + message.put("status", "判断文件结构"); + webSocketUtils.sendMessage(loginUser.getId(), message); + if (file == null) { return Result.error("文件上传失败"); } @@ -314,6 +325,8 @@ public class FieldxController extends JeecgController { workbook = new XSSFWorkbook(inputStream); } //读取表 + message.put("status", "数据预读入"); + webSocketUtils.sendMessage(loginUser.getId(), message); List list = new ArrayList<>(); //获取excel的所有页 int numberofSheets= workbook.getNumberOfSheets(); @@ -393,11 +406,17 @@ public class FieldxController extends JeecgController { } } + message.put("status", "数据预读入成功"); + webSocketUtils.sendMessage(loginUser.getId(), message); + + message.put("status", "正在上传"); + webSocketUtils.sendMessage(loginUser.getId(), message); fieldx222Service.saveBatch(list); List list222 = fieldx222Service.list(); fieldx222Service.remove(null); if(list222==null) return Result.error("文件上传失败"); + List list1= list222.stream().map((item)->{ Fieldx fieldx=new Fieldx(); String id=item.getId(); @@ -424,7 +443,11 @@ public class FieldxController extends JeecgController { fieldx.setRule(item.getRull()); return fieldx; }).collect(Collectors.toList()); + + //将中间表数据导入数据库 fieldxService.saveBatch(list1); + message.put("status", "上传成功"); + webSocketUtils.sendMessage(loginUser.getId(), message); return Result.OK("文件上传成功"); } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml b/jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml index d113636..a6b061a 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml +++ b/jeecg-boot/jeecg-boot-module-system/src/main/resources/application-dev.yml @@ -137,9 +137,9 @@ spring: # driver-class-name: com.mysql.cj.jdbc.Driver # 多数据源配置 #multi-datasource1: - url: jdbc:mysql://182.92.169.222:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://127.0.0.1:3306/project_management?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root - password: ycwl2022. + password: root driver-class-name: com.mysql.cj.jdbc.Driver #redis 配置 redis: