|
@@ -1,9 +1,11 @@
|
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import com.spire.xls.CellRange;
|
|
|
import com.spire.xls.ExcelPicture;
|
|
|
import com.spire.xls.Workbook;
|
|
|
import com.spire.xls.Worksheet;
|
|
@@ -15,32 +17,35 @@ import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
+import org.springblade.business.feign.InformationQueryClient;
|
|
|
+import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.service.*;
|
|
|
-import org.springblade.manager.unit.FileUtils;
|
|
|
+import org.springblade.manager.utils.FileUtils;
|
|
|
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.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
+import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.HashMap;
|
|
|
+import java.util.*;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -70,6 +75,11 @@ public class FirstController extends BladeController {
|
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ private final InformationQueryClient informationQueryClient;
|
|
|
+
|
|
|
+ private final ITextdictInfoService textdictInfoService;
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 首件表单获取 html页面
|
|
|
*/
|
|
@@ -79,7 +89,7 @@ public class FirstController extends BladeController {
|
|
|
@ApiImplicitParams(value = {
|
|
|
@ApiImplicitParam(name = "contractId", value = "contractId", required = true)
|
|
|
})
|
|
|
- public R getFirstExcelHtml(Long contractId) throws IOException, InterruptedException {
|
|
|
+ public R getFirstExcelHtml(Long contractId) throws IOException {
|
|
|
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getContractId,contractId).eq(WbsTreeContract::getTableType,"111"));
|
|
@@ -118,254 +128,323 @@ public class FirstController extends BladeController {
|
|
|
@ApiImplicitParam(name = "file", value = "file", required = true),
|
|
|
@ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
- public R addBussFile(@RequestParam("file") MultipartFile file, Long pkeyId) {
|
|
|
-
|
|
|
- // 直接删除以前记录
|
|
|
- tableFileService.getBaseMapper().delete(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId,pkeyId).eq(TableFile::getType,3));
|
|
|
-
|
|
|
- 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(3); // 表示首件的附件
|
|
|
- tableFile.setDomainUrl(bladeFile1.getLink());
|
|
|
- tableFile.setIsDeleted(0);
|
|
|
- tableFile.setExtension(fileExtension);
|
|
|
-
|
|
|
- NewBladeFile newBladeFile = new NewBladeFile();
|
|
|
- if(fileExtension.contains("xlsx")){
|
|
|
- newBladeFile = this.commonFileClient.excelToPdf(file);
|
|
|
- tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
|
|
|
- } else if(fileExtension.contains("xls")){
|
|
|
+ public R<JSONObject> addBussFile(@RequestParam("file") MultipartFile file, Long pkeyId) {
|
|
|
+ //上传源文件
|
|
|
+ R<BladeFile> sourceFileList = iossClient.addFileInfo(file);
|
|
|
+ BladeFile sourceFile = sourceFileList.getData();
|
|
|
+ //源文件路径
|
|
|
+ String sourceUrl = sourceFile.getLink();
|
|
|
+ //pdfUrl路径
|
|
|
+ String pdfUrl = "";
|
|
|
+ //文件名称
|
|
|
+ String fileExtension = StringUtils.isNotEmpty(file.getOriginalFilename()) ? file.getOriginalFilename() : FileUtil.getFileExtension(sourceFile.getName());
|
|
|
+
|
|
|
+ NewBladeFile newBladeFile = null;
|
|
|
+ if(fileExtension.contains("pdf")){
|
|
|
+ pdfUrl = sourceUrl;
|
|
|
+ } else if(fileExtension.contains("xls") || fileExtension.contains("xlsx")){
|
|
|
newBladeFile = this.commonFileClient.excelToPdf(file);
|
|
|
- tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
|
|
|
} else if(fileExtension.contains("docx")){
|
|
|
newBladeFile = this.commonFileClient.wordToPdf(file);
|
|
|
- tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
|
|
|
- } else if(fileExtension.contains("png") || file.getOriginalFilename().contains("jpg")){
|
|
|
+ } else if(fileExtension.contains("png") || (StringUtils.isNotEmpty(file.getOriginalFilename()) && file.getOriginalFilename().contains("jpg"))){
|
|
|
newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
|
|
|
- tableFile.setDomainPdfUrl(newBladeFile.getPdfUrl());
|
|
|
- } else if(fileExtension.contains("pdf")){
|
|
|
- tableFile.setDomainPdfUrl(bladeFile1.getLink());
|
|
|
}
|
|
|
- tableFile.setStatus("finished");
|
|
|
- tableFileService.saveOrUpdate(tableFile);
|
|
|
- return R.data(tableFile.getId());
|
|
|
+
|
|
|
+ if(newBladeFile != null){
|
|
|
+ pdfUrl = newBladeFile.getPdfUrl();
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回数据
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("sourceUrl", sourceUrl);
|
|
|
+ result.put("pdfUrl", pdfUrl);
|
|
|
+ result.put("fileName", file.getOriginalFilename());
|
|
|
+
|
|
|
+ return R.data(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/get-first-buss-pdfInfo")
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
- @ApiOperation(value = "首件-pdf预览", notes = "首件-单pdf预览")
|
|
|
- @ApiImplicitParams(value = {
|
|
|
- @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true),
|
|
|
- @ApiImplicitParam(name = "liunkIds", value = "liunkIds", required = true)
|
|
|
- })
|
|
|
- public R getBussPdfInfo(Long pkeyId,String liunkIds) throws Exception {
|
|
|
-
|
|
|
- WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+ @ApiOperation(value = "首件-pdf预览", notes = "首件列表ID")
|
|
|
+ @ApiImplicitParam(name = "firstId", value = "pkeyId", required = true)
|
|
|
+ public R<String> getBussPdfInfo(String firstId) {
|
|
|
+ if(StringUtils.isNotEmpty(firstId)){
|
|
|
+ //PDF路径集合
|
|
|
+ List<String> pdfUrls = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取配置的路径
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ //获取数据
|
|
|
+ JSONObject firstJson = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
|
|
|
+ if(firstJson != null){
|
|
|
+ if(StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) || StringUtils.isNotEmpty(firstJson.getString("pdfUrl"))){
|
|
|
+ pdfUrls.add(StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) ? firstJson.getString("eVisaPdfUrl") : firstJson.getString("pdfUrl"));
|
|
|
+ } else {
|
|
|
+ //没有生成拼接的记录,生成
|
|
|
+ //获取html
|
|
|
+ WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, firstJson.getString("tableId")));
|
|
|
+
|
|
|
+ if(tableNode == null){
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
+ }
|
|
|
|
|
|
- if(wbsTreeContract ==null ){
|
|
|
- return R.fail("该数据下无此节点!");
|
|
|
- }
|
|
|
- if(wbsTreeContract.getHtmlUrl()==null){
|
|
|
- return R.fail("请关联清表!");
|
|
|
- }
|
|
|
+ if(StringUtils.isEmpty(tableNode.getHtmlUrl())){
|
|
|
+ return R.fail("请关联清表!");
|
|
|
+ }
|
|
|
|
|
|
- String pdfPath="/Users/hongchuangyanfa/Desktop/pdf//"+pkeyId+".pdf";
|
|
|
- File tabpdf = ResourceUtil.getFile(pdfPath);
|
|
|
- if(tabpdf.exists()){
|
|
|
- tabpdf.delete();
|
|
|
- }
|
|
|
+ // 获取清表信息
|
|
|
+ ExcelTab excelTab = excelTabService.getById(tableNode.getExcelId());
|
|
|
+ if (excelTab == null) {
|
|
|
+ return R.fail("失败");
|
|
|
+ }
|
|
|
|
|
|
- // 获取清表信息
|
|
|
- ExcelTab excelTab = excelTabService.getById(wbsTreeContract.getExcelId());
|
|
|
-
|
|
|
- Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(pkeyId).getData();
|
|
|
-
|
|
|
- // 获取excel流 和 html流
|
|
|
- Workbook wb = new Workbook();
|
|
|
- wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
- //获取工作表
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
-
|
|
|
- if (DataInfo != null && DataInfo.size() >= 1) {
|
|
|
- File htmlFile = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
- String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
|
|
|
- Document doc = Jsoup.parse(htmlString);
|
|
|
- Element table = doc.select("table").first();
|
|
|
- Elements trs = table.select("tr");
|
|
|
- for(String val : DataInfo.keySet()){
|
|
|
- if(val.indexOf("__")>=0){
|
|
|
- String DataVal[] = val.split("__");
|
|
|
- String[] xy = DataVal[1].split("_");
|
|
|
- Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
|
|
|
- if(data.html().indexOf("x1")>=0&&data.html().indexOf("y1")>=0){
|
|
|
- int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
- if(x1==0){
|
|
|
- x1=1;
|
|
|
- }
|
|
|
- int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
- String myData = DataInfo.get(val)+"";
|
|
|
- if(myData.indexOf("T")>=0 && myData.indexOf("-")>=0){
|
|
|
- if(myData.indexOf(",")>=0 && myData.indexOf("]")>=0){
|
|
|
- myData = myData.replace("[","").replace("]","");
|
|
|
- String[] dataVal = myData.split(",");
|
|
|
- String Start_dataStr[] = dataVal[0].split("T")[0].split("-");
|
|
|
- String StartDate = StringUtil.format("{}年{}月{}日", new Object[]{Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2])+1});
|
|
|
-
|
|
|
- String end_dataStr[] = dataVal[1].split("T")[0].split("-");
|
|
|
- String endDate = StringUtil.format("{}年{}月{}日", new Object[]{end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2])+1});
|
|
|
-
|
|
|
- if(StartDate.equals(endDate)){
|
|
|
- myData = StartDate;
|
|
|
- }else{
|
|
|
- myData = StartDate +"-" +endDate;
|
|
|
+ List<Map<String, Object>> businessDataMapList = this.getFirstBusinessData(firstId).getData();
|
|
|
+
|
|
|
+ try{
|
|
|
+ //处理数据
|
|
|
+ for(Map<String, Object> dataMap : businessDataMapList){
|
|
|
+ // 获取excel流 和 html流
|
|
|
+ Workbook wb = new Workbook();
|
|
|
+ wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
+ //获取工作表
|
|
|
+ Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
+
|
|
|
+ // 数据不为空 &&
|
|
|
+ if (StringUtils.isNotEmpty(tableNode.getHtmlUrl())) {
|
|
|
+ File htmlFile = ResourceUtil.getFile(tableNode.getHtmlUrl());
|
|
|
+ if (htmlFile.exists()) {
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(dataMap)) {
|
|
|
+ for (String val : dataMap.keySet()) {
|
|
|
+ if (val.indexOf("__") >= 0) {
|
|
|
+ String DataVal[] = val.split("__");
|
|
|
+ String[] xy = DataVal[1].split("_");
|
|
|
+ Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
|
|
|
+
|
|
|
+ if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
+ int x1, y1;
|
|
|
+
|
|
|
+ if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
+ } else {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+ }
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+ String myData = dataMap.get(val) + "";
|
|
|
+ if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
+ if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+ myData = myData.replace("[", "").replace("]", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+ String Start_dataStr[] = dataVal[0].split("T")[0].split("-");
|
|
|
+ String StartDate = StringUtil.format("{}年{}月{}日", new Object[]{Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1});
|
|
|
+
|
|
|
+ String end_dataStr[] = dataVal[1].split("T")[0].split("-");
|
|
|
+ String endDate = StringUtil.format("{}年{}月{}日", new Object[]{end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1});
|
|
|
+
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String dataStr[] = myData.split("T")[0].split("-");
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", new Object[]{dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
+ Element element = trs.get(y1).select("td").get(x1);
|
|
|
+ String styles[] = element.attr("style").split(";");
|
|
|
+ int Height = 0;
|
|
|
+ for (String sty : styles) {
|
|
|
+ if (sty.indexOf("height:") >= 0) {
|
|
|
+ Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
+ ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
+ pic.setHeight(Height);
|
|
|
+ sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ cellRange.setText(myData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装电签设置
|
|
|
+ QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("type", 2);
|
|
|
+ queryWrapper.eq("tab_id", tableNode.getPKeyId());
|
|
|
+
|
|
|
+ final List<TextdictInfo> textdictInfos = this.textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
+ if (textdictInfos != null && !textdictInfos.isEmpty()) {
|
|
|
+ textdictInfos.forEach(e -> {
|
|
|
+ String key = e.getColKey();
|
|
|
+ String keys[] = key.split("__");
|
|
|
+ String[] trtd = keys[1].split("_");
|
|
|
+ Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
|
|
|
+ int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+ int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+
|
|
|
+ cellRange.setText(e.getId() + "");
|
|
|
+ cellRange.getCellStyle().getFont().setColor(Color.white);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- }else {
|
|
|
- String dataStr[] = myData.split("T")[0].split("-");
|
|
|
- myData = StringUtil.format("{}年{}月{}日", new Object[]{dataStr[0], dataStr[1], Integer.parseInt(dataStr[2])+1});
|
|
|
}
|
|
|
- }
|
|
|
- https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
|
- if(myData.indexOf("https")>=0 && myData.indexOf("aliyuncs")>=0){
|
|
|
- System.out.println(myData);
|
|
|
|
|
|
- BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData) );
|
|
|
- ExcelPicture pic = sheet.getPictures().add(y1, x1,image);
|
|
|
+ Long fileName = SnowFlakeUtil.getId();
|
|
|
+ String onePdfPath = file_path + "/pdf//" + fileName + ".pdf";
|
|
|
|
|
|
- sheet.getCellRange(y1,x1).getStyle().setShrinkToFit(true);
|
|
|
+ sheet.saveToPdf(onePdfPath);
|
|
|
|
|
|
- }else{
|
|
|
- sheet.getCellRange(y1,x1).setText(myData);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile( fileName + ".pdf", onePdfPath);
|
|
|
|
|
|
- sheet.saveToPdf(pdfPath);
|
|
|
-
|
|
|
- BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
|
|
|
- //
|
|
|
- TableFile tableFile1 = tableFileService.getBaseMapper().selectOne(Wrappers.<TableFile>query().lambda()
|
|
|
- .eq(TableFile::getTabId, pkeyId).eq(TableFile::getType,1));
|
|
|
- if(tableFile1!=null){
|
|
|
- tableFile1.setDomainPdfUrl(bladeFile.getLink());
|
|
|
- tableFileService.saveOrUpdate(tableFile1);
|
|
|
- }else{
|
|
|
- TableFile tableFile = new TableFile();
|
|
|
- String fileExtension = FileUtil.getFileExtension(wbsTreeContract.getFullName()+".pdf");
|
|
|
- tableFile.setTabId(pkeyId+"");
|
|
|
- tableFile.setName(wbsTreeContract.getFullName()+".pdf");
|
|
|
- tableFile.setType(1);
|
|
|
- tableFile.setDomainUrl(bladeFile.getLink());
|
|
|
- tableFile.setIsDeleted(0);
|
|
|
- tableFile.setExtension(fileExtension);
|
|
|
- tableFile.setDomainPdfUrl(bladeFile.getLink());
|
|
|
- tableFileService.saveOrUpdate(tableFile);
|
|
|
- }
|
|
|
+ pdfUrls.add(bladeFile.getLink());
|
|
|
|
|
|
- List<TableFile> tableFileList = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId).eq(TableFile::getIsDeleted,0));
|
|
|
- tableFileList.sort(Comparator.comparing(TableFile::getType));
|
|
|
+ //将封面的pdf修改
|
|
|
+ String updatePdfUrl = "UPDATE u_information_query SET pdf_url = " + bladeFile.getLink() + " WHERE id = " + firstId;
|
|
|
+ this.jdbcTemplate.execute(updatePdfUrl);
|
|
|
|
|
|
+ wb.dispose();
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- List<String> dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl()!=null).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
|
|
|
+ if(pdfUrls.size() > 0){
|
|
|
+ try{
|
|
|
+ //关联的数据
|
|
|
+ if(StringUtils.isNotEmpty(firstJson.getString("linkMergePdfUrl"))){
|
|
|
+ pdfUrls.add(firstJson.getString("linkMergePdfUrl"));
|
|
|
+ }
|
|
|
+ //总结报告,暂时无
|
|
|
|
|
|
- String pdfPath2 = "/Users/hongchuangyanfa/Desktop/pdf//"+pkeyId+"_2.pdf";
|
|
|
+ //上传
|
|
|
+ String mergePdfPath = file_path + "/pdf//" + firstId + ".pdf";
|
|
|
+ File oldMergePdf = ResourceUtil.getFile(mergePdfPath);
|
|
|
+ if (oldMergePdf.exists()) {
|
|
|
+ oldMergePdf.delete();
|
|
|
+ }
|
|
|
+ //合并
|
|
|
+ FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
|
|
|
+ //上传
|
|
|
+ BladeFile mergeFile = this.newIOSSClient.uploadFile(firstId + '-' + new Date().getTime() + ".pdf", mergePdfPath);
|
|
|
|
|
|
- FileUtils.mergePdfPublicMethods(dataListPdf,pdfPath2);
|
|
|
+ //返回
|
|
|
+ return R.data(mergeFile.getLink());
|
|
|
|
|
|
- BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.in("p_key_id",pkeyId);
|
|
|
- updateWrapper.set("pdf_url",bladeFile2.getLink());
|
|
|
- wbsTreeContractService.update(updateWrapper);
|
|
|
- wb.dispose();
|
|
|
- return R.data(bladeFile2.getLink());
|
|
|
+ return R.data(300, null, "未找到数据");
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get-first-buss-dataInfo")
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "获取首件用户保存数据", notes = "获取首件用户保存数据")
|
|
|
@ApiImplicitParams(value = {
|
|
|
- @ApiImplicitParam(name = "pkeyId", value = "pkeyId", required = true)
|
|
|
+ @ApiImplicitParam(name = "firstId", value = "pkeyId", required = true)
|
|
|
})
|
|
|
- public R getBussDataInfo(Long pkeyId) throws FileNotFoundException {
|
|
|
-
|
|
|
- Map<String, Object> reData = new HashMap<>();
|
|
|
-
|
|
|
- WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
- .eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
-
|
|
|
- if(wbsTreeContract ==null ){
|
|
|
- return R.data(reData);
|
|
|
- }
|
|
|
- if(wbsTreeContract.getHtmlUrl()==null){
|
|
|
- return R.data(reData);
|
|
|
- }
|
|
|
- //表单是否存储在
|
|
|
- String tabName = wbsTreeContract.getInitTableName();
|
|
|
- String isExitSql = " select * from information_schema.TABLES where TABLE_NAME='"+tabName+"'";
|
|
|
- List<Map<String, Object>> tablist = jdbcTemplate.queryForList(isExitSql);
|
|
|
- if(tablist==null || tablist.size()<=0){
|
|
|
- return R.fail("无实体表对应");
|
|
|
- }
|
|
|
+ public R<List<Map<String, Object>>> getFirstBusinessData(String firstId) {
|
|
|
+ if(StringUtils.isNotEmpty(firstId)){
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+
|
|
|
+ JSONObject json = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
|
|
|
+ if(json != null){
|
|
|
+ //获取数据所在表格
|
|
|
+ WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, json.getString("tableId")));
|
|
|
+ if(tableNode != null && StringUtils.isNotEmpty(tableNode.getInitTableName())){
|
|
|
+ //获取填报数据
|
|
|
+ List<Map<String, Object>> businessDataMapList = this.jdbcTemplate.queryForList("SELECT * FROM " + tableNode.getInitTableName() + " WHERE group_id = " + json.getString("id"));
|
|
|
+ if(businessDataMapList.size() > 0){
|
|
|
+ for(Map<String, Object> mysqlData : businessDataMapList){
|
|
|
+ //数据结果
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+
|
|
|
+ for (String key : mysqlData.keySet()) {
|
|
|
+ String tabVal = mysqlData.get(key) + "";
|
|
|
+ // 时间段处理
|
|
|
+ if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
+ if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
|
|
|
+ String tabData[] = tabVal.split("_\\^_");
|
|
|
+
|
|
|
+ if (reData.containsKey("pickerKey")) {
|
|
|
+ String pickerKey = reData.get("pickerKey") + "," + key + "__" + tabData[1];
|
|
|
+ reData.put("pickerKey", pickerKey);
|
|
|
+ } else {
|
|
|
+ reData.put("pickerKey", key + "__" + tabData[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = tabData[0];
|
|
|
+ sql = sql.replaceAll("\\[", "['");
|
|
|
+ sql = sql.replaceAll("]", "\']");
|
|
|
+ sql = sql.replaceAll("000Z,", "000Z\',");
|
|
|
+ sql = sql.replaceAll(", 20", ", \'20");
|
|
|
+ sql = sql.replaceAll("'", "");
|
|
|
+ reData.put(key + "__" + tabData[1], sql);
|
|
|
+ } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) { //时间
|
|
|
+
|
|
|
+ String tabData[] = tabVal.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+
|
|
|
+ } else if (tabVal.indexOf("☆") >= 0) {
|
|
|
+ String mysql[] = tabVal.split("☆");
|
|
|
+ for (String data : mysql) {
|
|
|
+ String tabData[] = data.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ }
|
|
|
+ } else if (tabVal.indexOf("_^_") >= 0) {
|
|
|
+ String tabData[] = tabVal.split("_\\^_");
|
|
|
+ reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ } else {
|
|
|
+ reData.put(key, tabVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- String querySql = "select * from "+wbsTreeContract.getInitTableName()+" where p_key_id="+pkeyId ;
|
|
|
- List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
|
|
|
+ reData.remove("p_key_id");
|
|
|
+ reData.remove("classify");
|
|
|
+ reData.remove("contractId");
|
|
|
+ reData.remove("pkeyId");
|
|
|
+ reData.remove("projectId");
|
|
|
|
|
|
- if(dataIn==null||dataIn.size()<=0){
|
|
|
- return R.data(reData);
|
|
|
- }
|
|
|
- Map<String, Object> mysqlData = dataIn.get(0);
|
|
|
-
|
|
|
- //
|
|
|
- for(String key:mysqlData.keySet()) {
|
|
|
- String tabVal = mysqlData.get(key) + "";
|
|
|
- // 时间段处理
|
|
|
- if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
- if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
|
|
|
- String tabData[] = tabVal.split("__");
|
|
|
- if (reData.containsKey("pickerKey")) {
|
|
|
- String pickerKey = reData.get("pickerKey") + "," + tabData[1];
|
|
|
- reData.put("pickerKey", pickerKey);
|
|
|
- } else {
|
|
|
- reData.put("pickerKey", key + "__" + tabData[1]);
|
|
|
- }
|
|
|
+ result.add(reData);
|
|
|
+ }
|
|
|
|
|
|
- String sql = tabData[0];
|
|
|
- sql = sql.replaceAll("\\[", "['");
|
|
|
- sql = sql.replaceAll("]", "\']");
|
|
|
- sql = sql.replaceAll("000Z,", "000Z\',");
|
|
|
- sql = sql.replaceAll(", 20", ", \'20");
|
|
|
- reData.put(key + "__" + tabData[1], sql);
|
|
|
- } else if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z") >= 0) { //时间
|
|
|
-
|
|
|
- String tabData[] = tabVal.split("__");
|
|
|
- reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
-
|
|
|
- } else if (tabVal.indexOf(",") >= 0) {
|
|
|
- String mysql[] = tabVal.split(",");
|
|
|
- for (String data : mysql) {
|
|
|
- String tabData[] = data.split("__");
|
|
|
- reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
+ return R.data(result);
|
|
|
}
|
|
|
- } else if(tabVal.indexOf("__")>=0){
|
|
|
- String tabData[] = tabVal.split("__");
|
|
|
- reData.put(key + "__" + tabData[1], tabData[0]);
|
|
|
- }else{
|
|
|
- reData.put(key, tabVal);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return R.data(reData);
|
|
|
+ return R.data(300, null, "未找到对应的业务数据");
|
|
|
}
|
|
|
|
|
|
}
|