|
@@ -43,8 +43,6 @@ import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.TableInfo;
|
|
|
-import org.springblade.manager.dto.ExcelTabBatchUploadDTO;
|
|
|
-import org.springblade.manager.dto.ExcelTabFileDTO;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.enums.ExecuteType;
|
|
|
import org.springblade.manager.mapper.ExcelTabMapper;
|
|
@@ -3265,43 +3263,43 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
@PostMapping("/batchUploadExcelTab")
|
|
|
@ApiOperationSupport(order = 39)
|
|
|
- @ApiOperation(value = "批量上传清表", notes = "传入ExcelTabBatchUploadDTO")
|
|
|
- public R<Object> batchUploadExcelTab(@RequestBody ExcelTabBatchUploadDTO dto) throws IOException {
|
|
|
- if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
+ @ApiOperation(value = "批量上传清表", notes = "传入id、fileList")
|
|
|
+ public R<Object> batchUploadExcelTab(@RequestParam Long id, @RequestPart("file") MultipartFile[] file) throws IOException {
|
|
|
+ if (ObjectUtil.isEmpty(id)) {
|
|
|
throw new ServiceException("获取节点信息失败");
|
|
|
}
|
|
|
- if (ObjectUtil.isEmpty(dto.getFileList()) || dto.getFileList().size() <= 0) {
|
|
|
+ if (file.length <= 0) {
|
|
|
throw new ServiceException("未获取到需要上传的文件信息");
|
|
|
}
|
|
|
- ExcelTab excelTabParentNode = excelTabService.getBaseMapper().selectById(dto.getId());
|
|
|
+ ExcelTab excelTabParentNode = excelTabService.getBaseMapper().selectById(id);
|
|
|
List<ExcelTab> excelTabs = excelTabService.getBaseMapper().selectList(Wrappers.<ExcelTab>lambdaQuery().select(ExcelTab::getSort).eq(ExcelTab::getParentId, excelTabParentNode.getId()));
|
|
|
Optional<Integer> maxSort = excelTabs.stream().map(ExcelTab::getSort).max(Integer::compare);
|
|
|
int maxValue = 1;
|
|
|
if (maxSort.isPresent()) {
|
|
|
maxValue = maxSort.get();
|
|
|
}
|
|
|
- for (ExcelTabFileDTO fileDTO : dto.getFileList()) {
|
|
|
- if (ObjectUtil.isEmpty(fileDTO.getFileName())) {
|
|
|
+ for (MultipartFile fileDTO : file) {
|
|
|
+ if (ObjectUtil.isEmpty(fileDTO.getOriginalFilename())) {
|
|
|
throw new ServiceException("文件名不能为空");
|
|
|
}
|
|
|
- if (!this.isExcelFormat(fileDTO.getFileName())) {
|
|
|
+ if (!this.isExcelFormat(fileDTO.getOriginalFilename())) {
|
|
|
throw new ServiceException("文件名后缀不是.xlsx或者.xls格式,请重新填写");
|
|
|
}
|
|
|
- if (!this.isExcelFile(fileDTO.getFile())) {
|
|
|
- throw new ServiceException("【" + fileDTO.getFileName() + "】文件不是excel格式文件,上传终止");
|
|
|
+ if (!this.isExcelFile(fileDTO)) {
|
|
|
+ throw new ServiceException("【" + fileDTO.getOriginalFilename() + "】文件不是excel格式文件,上传终止");
|
|
|
}
|
|
|
try {
|
|
|
- R<BladeFile> bladeFile = iossClient.addFileInfo(fileDTO.getFile());
|
|
|
+ R<BladeFile> bladeFile = iossClient.addFileInfo(fileDTO);
|
|
|
if (ObjectUtil.isNotEmpty(bladeFile.getData())) {
|
|
|
//创建节点,并上传excel文件到节点上
|
|
|
ExcelTab excelTabNode = new ExcelTab();
|
|
|
excelTabNode.setId(SnowFlakeUtil.getId());
|
|
|
excelTabNode.setParentId(excelTabParentNode.getId());
|
|
|
excelTabNode.setFileType(excelTabParentNode.getFileType());
|
|
|
- excelTabNode.setName(fileDTO.getFileName().split(".xls")[0]);
|
|
|
+ excelTabNode.setName(fileDTO.getOriginalFilename().split(".xls")[0]);
|
|
|
excelTabNode.setAlias(excelTabParentNode.getAlias() + "," + excelTabParentNode.getId());
|
|
|
excelTabNode.setFileUrl(bladeFile.getData().getLink());
|
|
|
- excelTabNode.setExtension(fileDTO.getFileName());
|
|
|
+ excelTabNode.setExtension(fileDTO.getOriginalFilename());
|
|
|
excelTabNode.setCreateTime(new Date());
|
|
|
excelTabNode.setUpdateTime(new Date());
|
|
|
excelTabNode.setCreateUser(SecureUtil.getUserId());
|
|
@@ -3315,7 +3313,7 @@ public class ExcelTabController extends BladeController {
|
|
|
excelTabService.save(excelTabNode);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- throw new ServiceException("【" + fileDTO.getFileName() + "】文件上传失败,上传终止" + e.getMessage());
|
|
|
+ throw new ServiceException("【" + fileDTO.getOriginalFilename() + "】文件上传失败,上传终止" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
return R.success("操作成功");
|