|
@@ -6,6 +6,14 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
+import com.itextpdf.html2pdf.ConverterProperties;
|
|
|
|
+import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
|
|
|
|
+import com.itextpdf.io.font.FontProgram;
|
|
|
|
+import com.itextpdf.io.font.FontProgramFactory;
|
|
|
|
+import com.itextpdf.kernel.geom.PageSize;
|
|
|
|
+import com.itextpdf.kernel.pdf.PdfDocument;
|
|
|
|
+import com.itextpdf.kernel.pdf.PdfWriter;
|
|
|
|
+import com.itextpdf.layout.font.FontProvider;
|
|
import com.spire.xls.Workbook;
|
|
import com.spire.xls.Workbook;
|
|
import com.spire.xls.Worksheet;
|
|
import com.spire.xls.Worksheet;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
@@ -1002,9 +1010,7 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
|
- * 清表生成html
|
|
|
|
- */
|
|
|
|
|
|
+
|
|
@GetMapping("/get-buss-dataInfo")
|
|
@GetMapping("/get-buss-dataInfo")
|
|
@ApiOperationSupport(order = 17)
|
|
@ApiOperationSupport(order = 17)
|
|
@ApiOperation(value = "获取用户保存数据", notes = "获取用户保存数据")
|
|
@ApiOperation(value = "获取用户保存数据", notes = "获取用户保存数据")
|
|
@@ -1026,6 +1032,10 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
String querySql = "select * from "+wbsTreeContract.getInitTableName()+" where p_key_id="+pkeyId ;
|
|
String querySql = "select * from "+wbsTreeContract.getInitTableName()+" where p_key_id="+pkeyId ;
|
|
List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
|
+
|
|
|
|
+ if(dataIn==null){
|
|
|
|
+ return R.fail("请填写数据!");
|
|
|
|
+ }
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
|
|
|
|
|
|
|
@@ -1068,5 +1078,168 @@ public class ExcelTabController extends BladeController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ @GetMapping("/get-buss-pdfInfo")
|
|
|
|
+ @ApiOperationSupport(order = 18)
|
|
|
|
+ @ApiOperation(value = "单表pdf预览", notes = "单表pdf预览")
|
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
|
+ @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
|
+ })
|
|
|
|
+ public R getBussPdfInfo(Long pkeyId) throws FileNotFoundException {
|
|
|
|
+ String fontPath ="/Users/hongchuangyanfa/tool/simhei.ttf";
|
|
|
|
+ ConverterProperties properties = creatBaseFont(fontPath);
|
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
|
+
|
|
|
|
+ if(wbsTreeContract ==null ){
|
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
|
+ }
|
|
|
|
+ if(wbsTreeContract.getHtmlUrl()==null){
|
|
|
|
+ return R.fail("请关联清表!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String querySql = "select * from "+wbsTreeContract.getInitTableName()+" where p_key_id="+pkeyId ;
|
|
|
|
+ List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
|
+ Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
|
+
|
|
|
|
+ File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(file1));
|
|
|
|
+ // 样式集合
|
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
|
+ //解析
|
|
|
|
+ Element table = doc.select("table").first();
|
|
|
|
+ Elements trs = table.select("tr");
|
|
|
|
+ for(int i = 0 ;i <=trs.size()-1 ;i++) {
|
|
|
|
+ Element tr = trs.get(i);
|
|
|
|
+ Elements tds = tr.select("td");
|
|
|
|
+ for (int j = 0; j < tds.size(); j++) {
|
|
|
|
+ Element data = tds.get(j);
|
|
|
|
+ if(data.html().indexOf("keyname")>=0){
|
|
|
|
+ String keyData = data.children().get(0).attr("keyname");
|
|
|
|
+ String[] key = keyData.split("__");
|
|
|
|
+ String myData = mysqlData.get(key[0])+"";
|
|
|
|
+ System.out.println(myData);
|
|
|
|
+ if(StringUtils.isNotEmpty(myData)&& !myData.equals("null")){
|
|
|
|
+ if(myData.indexOf(",")>=0){
|
|
|
|
+ String [] dataVal = myData.split(",");
|
|
|
|
+ for(String val:dataVal){
|
|
|
|
+ if(key[1].equals(val.split("__")[1])){
|
|
|
|
+ data.empty().append(val.split("__")[0]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ data.empty().append(myData);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String pdfPath="/Users/hongchuangyanfa/Desktop/pdf//"+pkeyId+".pdf";
|
|
|
|
+ File pdffile = ResourceUtil.getFile(pdfPath);
|
|
|
|
+ PdfWriter writer = new PdfWriter(pdffile);
|
|
|
|
+ com.itextpdf.kernel.pdf.PdfDocument pdf = new PdfDocument(writer);
|
|
|
|
+ PageSize pageSize = new PageSize(795,842);
|
|
|
|
+ pdf.setDefaultPageSize(pageSize);
|
|
|
|
+
|
|
|
|
+ UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.in("p_key_id",pkeyId);
|
|
|
|
+ updateWrapper.set("pdf_url",pdfPath);
|
|
|
|
+
|
|
|
|
+ wbsTreeContractService.update(updateWrapper);
|
|
|
|
+ return R.data(pdfPath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/cope-buss-tab")
|
|
|
|
+ @ApiOperationSupport(order = 19)
|
|
|
|
+ @ApiOperation(value = "表单复制", notes = "表单复制")
|
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
|
+ @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
|
+ })
|
|
|
|
+ public R copeBussTab(Long pkeyId) throws FileNotFoundException {
|
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
|
+ long valStr = SnowFlakeUtil.getId();
|
|
|
|
+ wbsTreeContract.setPKeyId(pkeyId);
|
|
|
|
+ wbsTreeContractService.save(wbsTreeContract);
|
|
|
|
+ return R.data("成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 上传文件
|
|
|
|
+ *
|
|
|
|
+ * @param file 文件
|
|
|
|
+ * @return ObjectStat
|
|
|
|
+ */
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ @PostMapping("/add-buss-file")
|
|
|
|
+ @ApiOperationSupport(order = 20)
|
|
|
|
+ @ApiOperation(value = "附件上传", notes = "附件上传")
|
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
|
+ @ApiImplicitParam(name = "file", value = "file", required = true),
|
|
|
|
+ @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
|
+ })
|
|
|
|
+ public R addBussFile(@RequestParam("file") MultipartFile file, Long pkeyId) {
|
|
|
|
+ // 删除excel文件
|
|
|
|
+ R<BladeFile> bladeFile = iossClient.addFileInfo(file);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return R.data("成功!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/show-buss-tab")
|
|
|
|
+ @ApiOperationSupport(order = 21)
|
|
|
|
+ @ApiOperation(value = "隐藏表单", notes = "隐藏表单")
|
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
|
+ @ApiImplicitParam(name = "pkeyId", value = "主键id", required = true),
|
|
|
|
+ @ApiImplicitParam(name = "status", value = "状态(1显示 2隐藏)", required = true)
|
|
|
|
+ })
|
|
|
|
+ public R showBussTab(Long pkeyId,int status) throws FileNotFoundException {
|
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
|
+ UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.in("p_key_id",pkeyId);
|
|
|
|
+ updateWrapper.set("is_buss_show",status);
|
|
|
|
+ wbsTreeContractService.update(updateWrapper);
|
|
|
|
+ return R.data("成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @GetMapping("/get-buss-pdfs")
|
|
|
|
+ @ApiOperationSupport(order = 21)
|
|
|
|
+ @ApiOperation(value = "多表预览", notes = "多表预览")
|
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
|
+ @ApiImplicitParam(name = "nodeId", value = "当前节点Id", required = true),
|
|
|
|
+ @ApiImplicitParam(name = "classify", value = "填报的类型(施工或监理)", required = true),
|
|
|
|
+ @ApiImplicitParam(name = "contractId", value = "合同段Id", required = true)
|
|
|
|
+ })
|
|
|
|
+ public R getBussPdfs(Long nodeId,String classify,long contractId) throws FileNotFoundException {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return R.data("成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 设置BaseFont
|
|
|
|
+ * @param fontPath 字体路径
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private static ConverterProperties creatBaseFont(String fontPath) {
|
|
|
|
+ ConverterProperties properties = new ConverterProperties();
|
|
|
|
+ FontProvider fontProvider = new DefaultFontProvider();
|
|
|
|
+ FontProgram fontProgram;
|
|
|
|
+ try {
|
|
|
|
+ fontProgram = FontProgramFactory.createFont(fontPath);
|
|
|
|
+ fontProvider.addFont(fontProgram);
|
|
|
|
+ properties.setFontProvider(fontProvider);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ // log.error("creat base font erro" , e );
|
|
|
|
+ System.out.println("creat base font erro");
|
|
|
|
+ }
|
|
|
|
+ return properties;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|