|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import com.itextpdf.html2pdf.ConverterProperties;
|
|
|
+import com.itextpdf.html2pdf.HtmlConverter;
|
|
|
import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
|
|
|
import com.itextpdf.io.font.FontProgram;
|
|
|
import com.itextpdf.io.font.FontProgramFactory;
|
|
@@ -40,7 +41,10 @@ import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.manager.wrapper.ExcelTabWrapper;
|
|
|
+import org.springblade.resource.feign.CommonFileClient;
|
|
|
import org.springblade.resource.feign.IOSSClient;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
+import org.springblade.resource.vo.NewBladeFile;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
@@ -52,10 +56,7 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -80,6 +81,8 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
private final IOSSClient iossClient;
|
|
|
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
+
|
|
|
// 私有项目wbs
|
|
|
private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
|
|
@@ -99,6 +102,12 @@ public class ExcelTabController extends BladeController {
|
|
|
//客户端资料查询接口
|
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
|
|
|
+ // 表单附件信息
|
|
|
+ private final ITableFileService tableFileService;
|
|
|
+
|
|
|
+ // pdf转换
|
|
|
+ private final CommonFileClient commonFileClient;
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
@@ -286,14 +295,17 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "wbsType", value = "type", required = true)
|
|
|
})
|
|
|
public R<List<WbsTreeVO>> getLazyTreeById(String wbsId, Long parentId, BladeUser bladeUser, Integer wbsType) {
|
|
|
- if(wbsType==1){
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
- if(wbsType==2){
|
|
|
-
|
|
|
+ if(wbsType==2){ // 私有项目wbs 树
|
|
|
+ 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, "未查询到信息");
|
|
@@ -1033,7 +1045,7 @@ public class ExcelTabController extends BladeController {
|
|
|
String querySql = "select * from "+wbsTreeContract.getInitTableName()+" where p_key_id="+pkeyId ;
|
|
|
List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
|
|
|
- if(dataIn==null){
|
|
|
+ if(dataIn==null||dataIn.size()<=0){
|
|
|
return R.fail("请填写数据!");
|
|
|
}
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
@@ -1084,7 +1096,7 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParams(value = {
|
|
|
@ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
- public R getBussPdfInfo(Long pkeyId) throws FileNotFoundException {
|
|
|
+ public R getBussPdfInfo(Long pkeyId) throws IOException {
|
|
|
String fontPath ="/Users/hongchuangyanfa/tool/simhei.ttf";
|
|
|
ConverterProperties properties = creatBaseFont(fontPath);
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
@@ -1099,6 +1111,9 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
String querySql = "select * from "+wbsTreeContract.getInitTableName()+" where p_key_id="+pkeyId ;
|
|
|
List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
+ if(dataIn==null){
|
|
|
+ return R.fail("请填写数据!");
|
|
|
+ }
|
|
|
Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
|
|
|
File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
@@ -1141,12 +1156,15 @@ public class ExcelTabController extends BladeController {
|
|
|
PageSize pageSize = new PageSize(795,842);
|
|
|
pdf.setDefaultPageSize(pageSize);
|
|
|
|
|
|
+ HtmlConverter.convertToPdf(doc.html(),writer,properties);
|
|
|
+
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
|
|
|
UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.in("p_key_id",pkeyId);
|
|
|
- updateWrapper.set("pdf_url",pdfPath);
|
|
|
+ updateWrapper.set("pdf_url",bladeFile.getLink());
|
|
|
|
|
|
wbsTreeContractService.update(updateWrapper);
|
|
|
- return R.data(pdfPath);
|
|
|
+ return R.data(bladeFile.getLink());
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1159,8 +1177,18 @@ public class ExcelTabController extends BladeController {
|
|
|
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);
|
|
|
+ List<WbsTreeContract> wbsTreeContractList = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getId,wbsTreeContract.getId()).eq(WbsTreeContract::getContractId,wbsTreeContract.getContractId()));
|
|
|
+ long newPkId = SnowFlakeUtil.getId();
|
|
|
+ Long id = wbsTreeContract.getId();
|
|
|
+ wbsTreeContract.setPKeyId(newPkId);
|
|
|
+ wbsTreeContract.setCreateTime(new Date());
|
|
|
+ String deptName = wbsTreeContract.getDeptName();
|
|
|
+ if(deptName.indexOf("__")>=0){
|
|
|
+ deptName = deptName.split("__")[0]+"__"+wbsTreeContractList.size();
|
|
|
+ }else{
|
|
|
+ deptName = deptName +"__"+wbsTreeContractList.size();
|
|
|
+ }
|
|
|
+ wbsTreeContract.setDeptName(deptName);
|
|
|
wbsTreeContractService.save(wbsTreeContract);
|
|
|
return R.data("成功");
|
|
|
}
|
|
@@ -1181,11 +1209,40 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
public R addBussFile(@RequestParam("file") MultipartFile file, Long pkeyId) {
|
|
|
- // 删除excel文件
|
|
|
+
|
|
|
R<BladeFile> bladeFile = iossClient.addFileInfo(file);
|
|
|
+ BladeFile bladeFile1 = bladeFile.getData();
|
|
|
+ TableFile tableFile = new TableFile();
|
|
|
+ String fileExtension = FileUtil.getFileExtension(bladeFile1.getName());
|
|
|
+ tableFile.setTabId(pkeyId+"");
|
|
|
+ tableFile.setName(file.getOriginalFilename());
|
|
|
+ tableFile.setType(2);
|
|
|
+ tableFile.setDomainUrl(bladeFile1.getLink());
|
|
|
+ tableFile.setIsDeleted(0);
|
|
|
+ tableFile.setExtension(fileExtension);
|
|
|
|
|
|
|
|
|
- return R.data("成功!");
|
|
|
+ NewBladeFile newBladeFile = new NewBladeFile();
|
|
|
+ if(fileExtension.contains("xlsx")){
|
|
|
+ newBladeFile = this.commonFileClient.excelToPdf(file);
|
|
|
+
|
|
|
+ } else if(fileExtension.contains("xls")){
|
|
|
+ newBladeFile = this.commonFileClient.excelToPdf(file);
|
|
|
+
|
|
|
+ } else if(fileExtension.contains("docx")){
|
|
|
+ newBladeFile = this.commonFileClient.wordToPdf(file);
|
|
|
+
|
|
|
+ } else if(fileExtension.contains("png") || file.getOriginalFilename().contains("jpg")){
|
|
|
+ newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
|
|
|
+
|
|
|
+ } else if(fileExtension.contains("pdf")){
|
|
|
+ tableFile.setDomainPdfUrl(bladeFile1.getLink());
|
|
|
+ }
|
|
|
+ tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
|
|
|
+ tableFile.setStatus("finished");
|
|
|
+ tableFileService.save(tableFile);
|
|
|
+
|
|
|
+ return R.data(tableFile.getId());
|
|
|
}
|
|
|
|
|
|
@GetMapping("/show-buss-tab")
|