|
@@ -16,25 +16,40 @@
|
|
|
*/
|
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import io.swagger.annotations.ApiParam;
|
|
|
+import com.spire.xls.Workbook;
|
|
|
+import com.spire.xls.Worksheet;
|
|
|
+import io.swagger.annotations.*;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import jodd.util.StringUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
+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.Query;
|
|
|
+
|
|
|
+import org.springblade.core.oss.AliossTemplate;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.service.IWbsTreeService;
|
|
|
+import org.springblade.manager.vo.*;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springblade.manager.entity.ExcelTab;
|
|
|
-import org.springblade.manager.vo.ExcelTabVO;
|
|
|
import org.springblade.manager.wrapper.ExcelTabWrapper;
|
|
|
import org.springblade.manager.service.IExcelTabService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 清表基础数据表 控制器
|
|
@@ -50,6 +65,15 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
private final IExcelTabService excelTabService;
|
|
|
|
|
|
+ private final IWbsTreeService wbsTreeService;
|
|
|
+
|
|
|
+ private AliossTemplate aliossTemplate;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对象存储构建类
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
@@ -125,5 +149,174 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.status(excelTabService.deleteLogic(Func.toLongList(ids)));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清表模版树
|
|
|
+ */
|
|
|
+ @GetMapping("/tab-lazytree")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "清表清表树形结构", notes = "清表清表树形结构")
|
|
|
+ public R<List<ExceTabTreVO>> tabLazyTree(Long modeId, BladeUser bladeUser) {
|
|
|
+ List<ExceTabTreVO> tree = excelTabService.tabLazyTree( bladeUser.getTenantId(), modeId);
|
|
|
+ return R.data(tree);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传文件
|
|
|
+ *
|
|
|
+ * @param file 文件
|
|
|
+ * @return ObjectStat
|
|
|
+ */
|
|
|
+ @SneakyThrows
|
|
|
+ @PostMapping("/put-file-attach")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperation(value = "清表上传", notes = "清表上传")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "file", value = "文件源", 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);
|
|
|
+
|
|
|
+ String thmlUrl = "/Users/hongchuangyanfa/Desktop/ToHtml.html";
|
|
|
+ // 解析excel
|
|
|
+ Workbook wb = new Workbook();
|
|
|
+ wb.loadFromMHtml(file.getInputStream());
|
|
|
+
|
|
|
+ //获取工作表
|
|
|
+ Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
+ //sheet.saveToHtml("/Users/hongchuangyanfa/JAVA_Project/ToHtml.html");
|
|
|
+ sheet.saveToHtml(thmlUrl);
|
|
|
+
|
|
|
+ //解析数据
|
|
|
+ Thread.sleep(1000);
|
|
|
+ String htmlString = readfile(thmlUrl);
|
|
|
+
|
|
|
+ String htmlString2= getBody(htmlString);
|
|
|
+
|
|
|
+ Document doc = Jsoup.parse(htmlString2);
|
|
|
+
|
|
|
+ Elements trs = doc.select("tr");
|
|
|
+
|
|
|
+ for(int i = 0 ;i < trs.size() ;i++){
|
|
|
+ Element tr = trs.get(i);
|
|
|
+ Elements tds = tr.select("td");
|
|
|
+ for(Element data:tds){
|
|
|
+ System.out.print("COLSPAN:" +data.attr("COLSPAN")+" ROWSPAN:"+data.attr("ROWSPAN")+" "+data.text());
|
|
|
+ }
|
|
|
+ System.out.println();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存结构
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return R.success("上传成功");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清表编辑 wbs 下拉框选择
|
|
|
+ */
|
|
|
+ @GetMapping("/getWbsTypeList")
|
|
|
+ @ApiOperationSupport(order = 10)
|
|
|
+ @ApiOperation(value = "清表编辑 wbs 下拉框选择", notes = "传入excelTab")
|
|
|
+ public R getWbsTypeList() {
|
|
|
+ List<ExcelTabWbsTypeVO> wbsTypeList= excelTabService.getWbsTypeList();
|
|
|
+ return R.data(wbsTypeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清表编辑 - 下拉框 树节点
|
|
|
+ */
|
|
|
+ @GetMapping("/lazy-tree")
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
+ @ApiOperation(value = "懒加载节点树形结构", notes = "传入wbsId,parentId,请求头token")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(name = "wbsId", value = "wbsId", required = true),
|
|
|
+ @ApiImplicitParam(name = "parentId", value = "父级id", required = true),
|
|
|
+ @ApiImplicitParam(name = "wbsType", value = "type", required = true)
|
|
|
+ })
|
|
|
+ public R<List<WbsTreeVO>> getLazyTreeById(String wbsId, Long parentId, BladeUser bladeUser, Integer wbsType) {
|
|
|
+ if(wbsType==1){
|
|
|
+ List<WbsTreeVO> tree = excelTabService.lazyTree(wbsId, Func.toStrWithEmpty(null, bladeUser.getTenantId()), parentId);
|
|
|
+ if (tree != null && tree.size() > 0) {
|
|
|
+ return R.data(tree);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.fail(200, "未查询到信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询当前节点下所有表单(根据节点ID查询当前表单)
|
|
|
+ */
|
|
|
+ @GetMapping("/selectByNodeTable")
|
|
|
+ @ApiOperationSupport(order = 12)
|
|
|
+ @ApiOperation(value = "查询当前节点下所有表单", notes = "传入父节点id")
|
|
|
+ public R<List<WbsNodeTableVO>> selectByNodeTable(@ApiParam(value = "树节点Id", required = true) @RequestParam String id,
|
|
|
+ @ApiParam(value = "wbsType", required = true) @RequestParam Integer wbsType) {
|
|
|
+ if(wbsType==1){
|
|
|
+ List<WbsNodeTableVO> rs = wbsTreeService.selectByNodeTable(id);
|
|
|
+ if (!("").equals(rs) && rs.size() > 0) {
|
|
|
+ return R.data(rs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail(200, "未查询到数据");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清表编辑 - 下拉框 树节点
|
|
|
+ */
|
|
|
+ @PostMapping("/sava-dataInfo")
|
|
|
+ @ApiOperationSupport(order = 13)
|
|
|
+ @ApiOperation(value = "编辑-保存", notes = "编辑-保存")
|
|
|
+ public R<List<WbsTreeVO>> savaDataInfo(@Valid @RequestBody WbsExclTabParmVO wbsExclTabParmVO, BladeUser bladeUser) {
|
|
|
+ // 保存节点信息
|
|
|
+
|
|
|
+ ExcelTab excelTab = new ExcelTab();
|
|
|
+ excelTab.setName(wbsExclTabParmVO.getNodeName());
|
|
|
+ excelTab.setFileType(2);
|
|
|
+ excelTab.setParentId(wbsExclTabParmVO.getParentId());
|
|
|
+ excelTab.setTabType(wbsExclTabParmVO.getTabType());
|
|
|
+ excelTab.setIsDeleted(0);
|
|
|
+ excelTabService.saveOrUpdate(excelTab);
|
|
|
+ return R.success("添加成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String readfile(String filePath){
|
|
|
+ File file = new File(filePath);
|
|
|
+ InputStream input = null;
|
|
|
+ try {
|
|
|
+ input = new FileInputStream(file);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ byte[] bytes = new byte[1024];
|
|
|
+ try {
|
|
|
+ for(int n ; (n = input.read(bytes))!=-1 ; ){
|
|
|
+ buffer.append(new String(bytes,0,n,"UTF-8"));
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return buffer.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getBody(String val) {
|
|
|
+ String start = "<body>";
|
|
|
+ String end = "</body>";
|
|
|
+ int s = val.indexOf(start) + start.length();
|
|
|
+ int e = val.indexOf(end);
|
|
|
+ return val.substring(s, e);
|
|
|
+ }
|
|
|
}
|