|
@@ -1435,9 +1435,15 @@ public class ExcelTabController extends BladeController {
|
|
|
@ApiImplicitParam(name = "contractId", value = "合同段Id", required = true)
|
|
|
})
|
|
|
public R getpdfs(String nodeId, String classify, String contractId, String projectId) {
|
|
|
- String sql = "select pdf_url from u_information_query where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
|
|
|
+ String sql = "select pdf_url, e_visa_pdf_url from u_information_query where classify='" + classify + "' and wbs_id='" + nodeId + "' and contract_id ='" + contractId + "' ";
|
|
|
Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(sql);
|
|
|
- return R.data(stringObjectMap.get("pdf_url"));
|
|
|
+ Object pdfUrl = stringObjectMap.get("pdf_url");
|
|
|
+ if(stringObjectMap.get("e_visa_pdf_url") != null){
|
|
|
+ //优先使用电签的PDF
|
|
|
+ pdfUrl = stringObjectMap.get("e_visa_pdf_url");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(pdfUrl);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -2048,206 +2054,6 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.data(300, null, "未找到对应的业务数据");
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 预览首件PDF
|
|
|
- */
|
|
|
- @GetMapping("/get-first-pdf-info")
|
|
|
- @ApiOperationSupport(order = 28)
|
|
|
- @ApiOperation(value = "获取首件填报记录")
|
|
|
- @ApiImplicitParam(name = "firstId", value = "首件列表ID")
|
|
|
- public R<String> getFirstPdfInfo(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 (StringUtils.isEmpty(tableNode.getHtmlUrl())) {
|
|
|
- return R.fail("请关联清表!");
|
|
|
- }
|
|
|
-
|
|
|
- // 获取清表信息
|
|
|
- ExcelTab excelTab = excelTabService.getById(tableNode.getExcelId());
|
|
|
- if (excelTab == null) {
|
|
|
- return R.fail("失败");
|
|
|
- }
|
|
|
-
|
|
|
- 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 = 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);
|
|
|
-
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Long fileName = SnowFlakeUtil.getId();
|
|
|
- String onePdfPath = file_path + "/pdf//" + fileName + ".pdf";
|
|
|
-
|
|
|
- sheet.saveToPdf(onePdfPath);
|
|
|
-
|
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", onePdfPath);
|
|
|
-
|
|
|
- pdfUrls.add(bladeFile.getLink());
|
|
|
-
|
|
|
- wb.dispose();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (pdfUrls.size() > 0) {
|
|
|
- try {
|
|
|
- //关联的数据
|
|
|
- if (StringUtils.isNotEmpty(firstJson.getString("linkMergePdfUrl"))) {
|
|
|
- pdfUrls.add(firstJson.getString("linkMergePdfUrl"));
|
|
|
- }
|
|
|
- //总结报告,暂时无
|
|
|
-
|
|
|
- //上传
|
|
|
- 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);
|
|
|
-
|
|
|
- //返回
|
|
|
- return R.data(mergeFile.getLink());
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return R.data(300, null, "未找到数据");
|
|
|
- }
|
|
|
-
|
|
|
@PostMapping("/save_log_first_buss_data")
|
|
|
@ApiOperationSupport(order = 29)
|
|
|
@ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存")
|