|
@@ -287,15 +287,14 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "nodeId", value = "节点id", required = true)
|
|
|
})
|
|
|
public R putFileAttach(@RequestParam("file") MultipartFile file, Long nodeId) {
|
|
|
-
|
|
|
String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
-
|
|
|
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";
|
|
|
+ String thmlUrl2 = file_path + filecode + "123.html";
|
|
|
// 解析excel
|
|
|
Workbook wb = new Workbook();
|
|
|
wb.loadFromMHtml(file.getInputStream());
|
|
@@ -305,11 +304,88 @@ public class ExcelTabController extends BladeController {
|
|
|
//获取工作表
|
|
|
Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
sheet.saveToHtml(thmlUrl, options);
|
|
|
+
|
|
|
+ CellRange[] mergedCells = sheet.getMergedCells();
|
|
|
+ Map<String,Map<String,Integer>> xyList = new HashMap<>();
|
|
|
+ int j=0;
|
|
|
+ for (int i=0;i<mergedCells.length;i++){
|
|
|
+ Map<String,Integer> dataMap = new HashMap<>();
|
|
|
+ CellRange mergedCell = mergedCells[i];
|
|
|
+ j = j+1;
|
|
|
+ mergedCell.getComment().getRichText().setText(j+"");
|
|
|
+ mergedCell.setValue(j+"");
|
|
|
+ dataMap.put("x1",mergedCell.getRow());
|
|
|
+ dataMap.put("x2",mergedCell.getLastRow());
|
|
|
+ dataMap.put("y1",mergedCell.getColumn());
|
|
|
+ dataMap.put("y2",mergedCell.getLastColumn());
|
|
|
+ xyList.put(j+"",dataMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ CellRange[] mergedCells2 = sheet.getCells();
|
|
|
+ for (int i=0;i<mergedCells2.length;i++){
|
|
|
+ CellRange mergedCell = mergedCells2[i];
|
|
|
+ String data = mergedCell.getComment().getRichText().getText();
|
|
|
+ if(StringUtils.isEmpty(data)){
|
|
|
+ j = j+1;
|
|
|
+ mergedCell.getComment().getRichText().setText(j+"");
|
|
|
+ mergedCell.setValue(j+"");
|
|
|
+ Map<String,Integer> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("x1",mergedCell.getRow());
|
|
|
+ dataMap.put("x2",mergedCell.getLastRow());
|
|
|
+ dataMap.put("y1",mergedCell.getColumn());
|
|
|
+ dataMap.put("y2",mergedCell.getLastColumn());
|
|
|
+ xyList.put(j+"",dataMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sheet.saveToHtml(thmlUrl2, options);
|
|
|
+
|
|
|
+ // 组装坐标
|
|
|
+ File html1 = new File(thmlUrl); // 原始html
|
|
|
+ File html2 = new File(thmlUrl2); // 坐标html
|
|
|
+ InputStream inputStream1 = new FileInputStream(html1);
|
|
|
+ InputStream inputStream2 = new FileInputStream(html2);
|
|
|
+ String htmlString1 = IoUtil.readToString(inputStream1);
|
|
|
+ String htmlString2 = IoUtil.readToString(inputStream2);
|
|
|
+
|
|
|
+ Document doc1 = Jsoup.parse(htmlString1);
|
|
|
+ Element table1 = doc1.select("table").first();
|
|
|
+ Elements trs1 = table1.select("tr");
|
|
|
+ Document doc2 = Jsoup.parse(htmlString2);
|
|
|
+ Element table2 = doc2.select("table").first();
|
|
|
+ Elements trs2 = table2.select("tr");
|
|
|
+
|
|
|
+ for(int i=0;i<trs1.size();i++){
|
|
|
+ Elements td1 = trs1.get(i).select("td");
|
|
|
+ Elements td2 = trs2.get(i).select("td");
|
|
|
+ for(int x=0;x<td1.size();x++){
|
|
|
+ Element cell1 = td1.get(x);
|
|
|
+ Element cell2 = td2.get(x);
|
|
|
+ String html = cell2.html();
|
|
|
+ if(html.indexOf("div")>=0){
|
|
|
+ html=cell2.children().get(0).html();
|
|
|
+ }
|
|
|
+ Map<String, Integer> xyMap = xyList.get(html);
|
|
|
+ if(xyMap!=null){
|
|
|
+ cell1.attr("x1",xyMap.get("x1")+"");
|
|
|
+ cell1.attr("x2",xyMap.get("x2")+"");
|
|
|
+ cell1.attr("y1",xyMap.get("y1")+"");
|
|
|
+ cell1.attr("y2",xyMap.get("y2")+"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ File writeFile = new File(thmlUrl);
|
|
|
+ FileUtil.writeToFile(writeFile, doc1.html(), Boolean.parseBoolean("UTF-8"));
|
|
|
+
|
|
|
detail.setExtension(file.getOriginalFilename());
|
|
|
detail.setFileUrl(bladeFile1.getLink());
|
|
|
detail.setFileType(3); // 表示为清表信息 1 表示祖节点 2 表示为节点信息 3 表示清表
|
|
|
detail.setHtmlUrl(thmlUrl);
|
|
|
excelTabService.saveOrUpdate(detail);
|
|
|
+
|
|
|
+ if(html2.exists()){
|
|
|
+ html2.delete();
|
|
|
+ }
|
|
|
// 解析html
|
|
|
expailHtmlInfo(thmlUrl, detail.getId());
|
|
|
return R.success("上传成功");
|
|
@@ -454,7 +530,7 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "tabId", value = "表Id", required = true),
|
|
|
})
|
|
|
public R<List<ExceTabTreVO>> saveLinkeTab(Long exceTabId, Long tabId) throws IOException {
|
|
|
- String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
// 关联 私有项目 wbs 数据信息
|
|
|
WbsTreePrivate wbsTree = new WbsTreePrivate();
|
|
|
wbsTree.setPKeyId(tabId);
|
|
@@ -599,7 +675,6 @@ public class ExcelTabController extends BladeController {
|
|
|
//关联清表后 表单名和清表一样
|
|
|
aPrivate.setNodeName(excelTab.getName());
|
|
|
aPrivate.setFullName(excelTab.getName());
|
|
|
-
|
|
|
wbsTreeContractService.updateAllNodeTabById(aPrivate);
|
|
|
}
|
|
|
return R.success("关联成功");
|