Ver código fonte

Merge branch 'master' of http://47.110.251.215:3000/java_org/bladex

huangtf 2 anos atrás
pai
commit
d5cdc40f19

+ 5 - 5
blade-ops/blade-swagger/src/main/resources/application-dev.yml

@@ -2,20 +2,20 @@ knife4j:
   cloud:
     routes:
       - name: 用户管理
-        uri: 127.0.0.1
+        uri: 127.0.0.1:8090
         location: /blade-user/v2/api-docs
       - name: 授权模块
-        uri: 127.0.0.1
+        uri: 127.0.0.1:8090
         location: /blade-auth/v2/api-docs
       #      - name: 工作台模块
       #        uri: 127.0.0.1
       #        location: /blade-desk/v2/api-docs
       - name: 系统模块
-        uri: 127.0.0.1
+        uri: 127.0.0.1:8090
         location: /blade-system/v2/api-docs
       - name: 后台接口
-        uri: 127.0.0.1
+        uri: 127.0.0.1:8090
         location: /blade-manager/v2/api-docs
       - name: 业务接口
-        uri: 127.0.0.1
+        uri: 127.0.0.1:8090
         location: /blade-business/v2/api-docs

+ 12 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/entity/ExcelTab.java

@@ -106,4 +106,16 @@ public class ExcelTab extends BaseEntity {
 	@ApiModelProperty(value = "排序")
 	private Integer sort;
 
+	/**
+	 * 模板名
+	 */
+	@ApiModelProperty(value = "排序")
+	private String templateExtension;
+
+	/**
+	 * 模板文件路径
+	 */
+	@ApiModelProperty(value = "html路径")
+	private String templateFileUrl;
+
 }

+ 42 - 19
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -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();
+    }
+
     /**
      * 日志预览
      */