|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -1673,7 +1674,7 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
|
|
|
/***
|
|
|
- * 覆盖上传
|
|
|
+ * 覆盖上传- (修改为上传导入模板)
|
|
|
*/
|
|
|
|
|
|
@SneakyThrows
|
|
@@ -1685,32 +1686,54 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "nodeId", value = "节点id", required = true)
|
|
|
})
|
|
|
public R putCoverFileAttach(@RequestParam("file") MultipartFile file, Long nodeId) {
|
|
|
-
|
|
|
- String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
-
|
|
|
ExcelTab detail = excelTabService.getById(nodeId);
|
|
|
// 上传excel文件
|
|
|
R<BladeFile> bladeFile = iossClient.addFileInfo(file);
|
|
|
BladeFile bladeFile1 = bladeFile.getData();
|
|
|
- String filecode = SnowFlakeUtil.getId() + "";
|
|
|
- String thmlUrl = file_path + filecode + ".html";
|
|
|
- // 解析excel
|
|
|
- Workbook wb = new Workbook();
|
|
|
- wb.loadFromMHtml(file.getInputStream());
|
|
|
- //获取工作表
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
- sheet.saveToHtml(thmlUrl);
|
|
|
-
|
|
|
- detail.setExtension(bladeFile1.getOriginalName());
|
|
|
- detail.setFileUrl(bladeFile1.getLink());
|
|
|
- detail.setFileType(3); // 表示为清表信息 1 表示祖节点 2 表示为节点信息 3 表示清表
|
|
|
- detail.setHtmlUrl(thmlUrl);
|
|
|
+ detail.setTemplateExtension(bladeFile1.getOriginalName());
|
|
|
+ detail.setTemplateFileUrl(bladeFile1.getLink());
|
|
|
excelTabService.saveOrUpdate(detail);
|
|
|
- // 解析html
|
|
|
- expailHtmlInfo(thmlUrl, detail.getId());
|
|
|
return R.success("上传成功");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除模板
|
|
|
+ */
|
|
|
+ @PostMapping("/delete-template")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "删除模板", notes = "传入excelTab")
|
|
|
+ public R deleteTemplate(@Valid @RequestBody ExcelTab excelTab) {
|
|
|
+ ExcelTab tab = excelTabService.getById(excelTab.getId());
|
|
|
+ if (tab.getTemplateFileUrl() == null || tab.getTemplateExtension() == null) {
|
|
|
+ return R.fail("请上传清表");
|
|
|
+ }
|
|
|
+ return R.status(excelTabService.update(new LambdaUpdateWrapper<ExcelTab>()
|
|
|
+ .set(ExcelTab::getTemplateExtension,null)
|
|
|
+ .set(ExcelTab::getTemplateFileUrl,null)
|
|
|
+ .eq(ExcelTab::getId,excelTab.getId())));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模版下载
|
|
|
+ */
|
|
|
+ @GetMapping("/down-template-file")
|
|
|
+ @ApiOperationSupport(order = 31)
|
|
|
+ @ApiOperation(value = "下载模板数据")
|
|
|
+ @ApiImplicitParam(name = "fileId", value = "fileId")
|
|
|
+ public void downTemplateFile(HttpServletResponse response, String fileId) throws Exception {
|
|
|
+ ExcelTab excelTab = excelTabService.getById(fileId);
|
|
|
+ String fileName = URLEncoder.encode(excelTab.getName(), Charsets.UTF_8.name());
|
|
|
+ InputStream redio = CommonUtil.getOSSInputStream(excelTab.getTemplateFileUrl());
|
|
|
+ byte[] buffer = IoUtil.readToByteArray(redio);
|
|
|
+ OutputStream toClient = new BufferedOutputStream(response.getOutputStream());
|
|
|
+ response.setContentType("application/vnd.ms-excel");
|
|
|
+ response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
+ toClient.write(buffer);
|
|
|
+ toClient.flush();
|
|
|
+ toClient.close();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 日志预览
|
|
|
*/
|