|
@@ -16,39 +16,33 @@
|
|
*/
|
|
*/
|
|
package org.springblade.manager.controller;
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
-import com.spire.xls.Workbook;
|
|
|
|
-import com.spire.xls.Worksheet;
|
|
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
-import jodd.util.StringUtil;
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
-import org.jsoup.Jsoup;
|
|
|
|
-import org.jsoup.nodes.Document;
|
|
|
|
-import org.jsoup.nodes.Element;
|
|
|
|
-import org.jsoup.select.Elements;
|
|
|
|
|
|
+
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Query;
|
|
import org.springblade.core.mp.support.Query;
|
|
|
|
|
|
-import org.springblade.core.oss.AliossTemplate;
|
|
|
|
-import org.springblade.core.oss.model.BladeFile;
|
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
|
+import org.springblade.manager.service.IExctabCellService;
|
|
import org.springblade.manager.service.IWbsTreeService;
|
|
import org.springblade.manager.service.IWbsTreeService;
|
|
import org.springblade.manager.vo.*;
|
|
import org.springblade.manager.vo.*;
|
|
|
|
+import org.springblade.manager.wrapper.ExcelTabWrapper;
|
|
|
|
+import org.springblade.resource.feign.IOSSClient;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import org.springblade.manager.entity.ExcelTab;
|
|
import org.springblade.manager.entity.ExcelTab;
|
|
-import org.springblade.manager.wrapper.ExcelTabWrapper;
|
|
|
|
import org.springblade.manager.service.IExcelTabService;
|
|
import org.springblade.manager.service.IExcelTabService;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -63,15 +57,14 @@ import java.util.List;
|
|
@Api(value = "清表基础数据表", tags = "清表基础数据表接口")
|
|
@Api(value = "清表基础数据表", tags = "清表基础数据表接口")
|
|
public class ExcelTabController extends BladeController {
|
|
public class ExcelTabController extends BladeController {
|
|
|
|
|
|
|
|
+ // excel 基本信息表
|
|
private final IExcelTabService excelTabService;
|
|
private final IExcelTabService excelTabService;
|
|
-
|
|
|
|
|
|
+ // wes 基本信息表
|
|
private final IWbsTreeService wbsTreeService;
|
|
private final IWbsTreeService wbsTreeService;
|
|
|
|
+ // excel 解析结构
|
|
|
|
+ private final IExctabCellService exctabCellService;
|
|
|
|
|
|
- private AliossTemplate aliossTemplate;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 对象存储构建类
|
|
|
|
- */
|
|
|
|
|
|
+ private final IOSSClient iossClient;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -175,26 +168,33 @@ public class ExcelTabController extends BladeController {
|
|
@ApiImplicitParam(name = "file", value = "文件源", required = true),
|
|
@ApiImplicitParam(name = "file", value = "文件源", required = true),
|
|
@ApiImplicitParam(name = "nodeId", value = "节点id", required = true)
|
|
@ApiImplicitParam(name = "nodeId", value = "节点id", required = true)
|
|
})
|
|
})
|
|
- public R putFileAttach(@RequestParam MultipartFile file,Long nodeId) {
|
|
|
|
-// ExcelTab detail = excelTabService.getById(nodeId);
|
|
|
|
-// BladeFile bladeFile = aliossTemplate.putFile(file.getOriginalFilename(),file.getInputStream());
|
|
|
|
-// detail.setExtension(bladeFile.getOriginalName());
|
|
|
|
-// detail.setName(bladeFile.getLink());
|
|
|
|
-// detail.setFileType(3); // 表示为清表信息 1 表示祖节点 2 表示为节点信息 3 表示清表
|
|
|
|
-// excelTabService.saveOrUpdate(detail);
|
|
|
|
|
|
+ public R putFileAttach(@RequestParam("file") MultipartFile file, Long nodeId) {
|
|
|
|
+
|
|
|
|
+ ExcelTab detail = excelTabService.getById(nodeId);
|
|
|
|
+ // 删除excel文件
|
|
|
|
+ //R bladeFile = iossClient.addFileInfo(file);
|
|
|
|
+
|
|
|
|
+ R bladeFile = iossClient.addFileInfo(file);
|
|
|
|
+
|
|
|
|
+ System.out.println(bladeFile);
|
|
|
|
+
|
|
|
|
+ /*detail.setExtension(bladeFile.getOriginalName());
|
|
|
|
+ detail.setFileUrl(bladeFile.getLink());
|
|
|
|
+ detail.setFileType(3); // 表示为清表信息 1 表示祖节点 2 表示为节点信息 3 表示清表
|
|
|
|
+ excelTabService.saveOrUpdate(detail);
|
|
|
|
|
|
String thmlUrl = "/Users/hongchuangyanfa/Desktop/ToHtml.html";
|
|
String thmlUrl = "/Users/hongchuangyanfa/Desktop/ToHtml.html";
|
|
// 解析excel
|
|
// 解析excel
|
|
Workbook wb = new Workbook();
|
|
Workbook wb = new Workbook();
|
|
wb.loadFromMHtml(file.getInputStream());
|
|
wb.loadFromMHtml(file.getInputStream());
|
|
|
|
+ wb.loadFromMHtml(file.getInputStream());
|
|
|
|
|
|
//获取工作表
|
|
//获取工作表
|
|
Worksheet sheet = wb.getWorksheets().get(0);
|
|
Worksheet sheet = wb.getWorksheets().get(0);
|
|
- //sheet.saveToHtml("/Users/hongchuangyanfa/JAVA_Project/ToHtml.html");
|
|
|
|
sheet.saveToHtml(thmlUrl);
|
|
sheet.saveToHtml(thmlUrl);
|
|
|
|
|
|
//解析数据
|
|
//解析数据
|
|
- Thread.sleep(1000);
|
|
|
|
|
|
+ Thread.sleep(200);
|
|
String htmlString = readfile(thmlUrl);
|
|
String htmlString = readfile(thmlUrl);
|
|
|
|
|
|
String htmlString2= getBody(htmlString);
|
|
String htmlString2= getBody(htmlString);
|
|
@@ -202,21 +202,31 @@ public class ExcelTabController extends BladeController {
|
|
Document doc = Jsoup.parse(htmlString2);
|
|
Document doc = Jsoup.parse(htmlString2);
|
|
|
|
|
|
Elements trs = doc.select("tr");
|
|
Elements trs = doc.select("tr");
|
|
|
|
+ List<ExctabCell> cellList = new ArrayList<>();
|
|
|
|
|
|
for(int i = 0 ;i < trs.size() ;i++){
|
|
for(int i = 0 ;i < trs.size() ;i++){
|
|
Element tr = trs.get(i);
|
|
Element tr = trs.get(i);
|
|
Elements tds = tr.select("td");
|
|
Elements tds = tr.select("td");
|
|
- for(Element data:tds){
|
|
|
|
- System.out.print("COLSPAN:" +data.attr("COLSPAN")+" ROWSPAN:"+data.attr("ROWSPAN")+" "+data.text());
|
|
|
|
|
|
+ for( int j = 0 ; j < tds.size();j++ ){
|
|
|
|
+ ExctabCell cell = new ExctabCell();
|
|
|
|
+ Element data = tds.get(j);
|
|
|
|
+ int colspan = Integer.parseInt(data.attr("COLSPAN").equals("")?"0":data.attr("COLSPAN"));
|
|
|
|
+ int rowspan = Integer.parseInt(data.attr("ROWSPAN").equals("")?"0":data.attr("ROWSPAN"));
|
|
|
|
+ String textInfo = data.text();
|
|
|
|
+ cell.setExctabId(nodeId);
|
|
|
|
+ cell.setTrIndex(i);
|
|
|
|
+ cell.setTdIndex(j);
|
|
|
|
+ cell.setColIndex(colspan);
|
|
|
|
+ cell.setRowIndex(rowspan);
|
|
|
|
+ cell.setTextInfo(textInfo);
|
|
|
|
+ cellList.add(cell);
|
|
|
|
+ System.out.print("COLSPAN:" +colspan+" ROWSPAN:"+rowspan+" "+textInfo);
|
|
}
|
|
}
|
|
System.out.println();
|
|
System.out.println();
|
|
}
|
|
}
|
|
|
|
|
|
// 保存结构
|
|
// 保存结构
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ exctabCellService.saveOrUpdateBatch(cellList);*/
|
|
return R.success("上传成功");
|
|
return R.success("上传成功");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -281,13 +291,18 @@ public class ExcelTabController extends BladeController {
|
|
@ApiOperation(value = "编辑-保存", notes = "编辑-保存")
|
|
@ApiOperation(value = "编辑-保存", notes = "编辑-保存")
|
|
public R<List<WbsTreeVO>> savaDataInfo(@Valid @RequestBody WbsExclTabParmVO wbsExclTabParmVO, BladeUser bladeUser) {
|
|
public R<List<WbsTreeVO>> savaDataInfo(@Valid @RequestBody WbsExclTabParmVO wbsExclTabParmVO, BladeUser bladeUser) {
|
|
// 保存节点信息
|
|
// 保存节点信息
|
|
-
|
|
|
|
ExcelTab excelTab = new ExcelTab();
|
|
ExcelTab excelTab = new ExcelTab();
|
|
- excelTab.setName(wbsExclTabParmVO.getNodeName());
|
|
|
|
- excelTab.setFileType(2);
|
|
|
|
- excelTab.setParentId(wbsExclTabParmVO.getParentId());
|
|
|
|
- excelTab.setTabType(wbsExclTabParmVO.getTabType());
|
|
|
|
- excelTab.setIsDeleted(0);
|
|
|
|
|
|
+ if(wbsExclTabParmVO.getId()!=null){// 修改
|
|
|
|
+ excelTab = excelTabService.getById(wbsExclTabParmVO.getId());
|
|
|
|
+ excelTab.setName(wbsExclTabParmVO.getNodeName());
|
|
|
|
+ excelTab.setTabType(wbsExclTabParmVO.getTabType());
|
|
|
|
+ }else{ // 新增
|
|
|
|
+ excelTab.setParentId(wbsExclTabParmVO.getParentId());
|
|
|
|
+ excelTab.setTabType(wbsExclTabParmVO.getTabType());
|
|
|
|
+ excelTab.setName(wbsExclTabParmVO.getNodeName());
|
|
|
|
+ excelTab.setIsDeleted(0);
|
|
|
|
+ excelTab.setFileType(2);
|
|
|
|
+ }
|
|
excelTabService.saveOrUpdate(excelTab);
|
|
excelTabService.saveOrUpdate(excelTab);
|
|
return R.success("添加成功!");
|
|
return R.success("添加成功!");
|
|
}
|
|
}
|