|
@@ -1,24 +1,7 @@
|
|
|
-/*
|
|
|
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
- *
|
|
|
- * Redistribution and use in source and binary forms, with or without
|
|
|
- * modification, are permitted provided that the following conditions are met:
|
|
|
- *
|
|
|
- * Redistributions of source code must retain the above copyright notice,
|
|
|
- * this list of conditions and the following disclaimer.
|
|
|
- * Redistributions in binary form must reproduce the above copyright
|
|
|
- * notice, this list of conditions and the following disclaimer in the
|
|
|
- * documentation and/or other materials provided with the distribution.
|
|
|
- * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
- * contributors may be used to endorse or promote products derived from
|
|
|
- * this software without specific prior written permission.
|
|
|
- * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
- */
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.StopWatch;
|
|
|
import cn.hutool.log.StaticLog;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -27,9 +10,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.mixsmart.utils.ListUtils;
|
|
|
import com.mixsmart.utils.RegexUtils;
|
|
|
-import com.spire.xls.CellRange;
|
|
|
-import com.spire.xls.Workbook;
|
|
|
-import com.spire.xls.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -43,6 +23,7 @@ import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
|
import org.jsoup.select.Elements;
|
|
|
+import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
|
|
|
import org.springblade.business.entity.InformationQuery;
|
|
|
import org.springblade.business.entity.TrialSelfInspectionRecord;
|
|
|
import org.springblade.business.feign.ContractLogClient;
|
|
@@ -90,7 +71,6 @@ import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 清表基础数据表 服务实现类
|
|
@@ -363,7 +343,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
tec.before();
|
|
|
this.formulaService.execute(tec);
|
|
|
tec.after();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
tec.getLog().append("【").append("没有执行任何公式").append("】");
|
|
|
}
|
|
|
stopWatch.stop();
|
|
@@ -376,7 +356,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
"INSERT INTO m_formula_log (id,content) VALUES (" + wtc.getPKeyId() + ", '" + log + "')"
|
|
|
};
|
|
|
this.jdbcTemplate.batchUpdate(sql);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
@@ -1168,7 +1148,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
@Override
|
|
|
public R getBussPdfInfo(Long pkeyId) throws Exception {
|
|
|
- // String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ // String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
String file_path = "/Users/hongchuangyanfa/Desktop/";
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
@@ -1950,8 +1930,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
* 试验 单pdf
|
|
|
*/
|
|
|
@Override
|
|
|
- public String getBussPDFTrial(Long pkeyId, String contractId, Long id, int pageNumber, int pageNumberCount) throws
|
|
|
- Exception {
|
|
|
+ public String getBussPDFTrial(Long pkeyId, String contractId, Long id, int pageNumber, int pageNumberCount, TrialSelfInspectionRecordDTO dto) throws Exception {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
.eq(WbsTreePrivate::getPKeyId, pkeyId));
|
|
@@ -1978,7 +1957,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
//获取数据信息info
|
|
|
List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(id, pkeyId, Long.parseLong(contractId));
|
|
|
- Map<String, Object> DataInfo = bussDataInfoTrial.stream().findAny().orElse(null);
|
|
|
+ Map<String, Object> DataInfo = new HashMap<>();
|
|
|
+ if (bussDataInfoTrial.size() > 0) {
|
|
|
+ DataInfo.putAll(bussDataInfoTrial.stream().findAny().orElse(null));
|
|
|
+ }
|
|
|
|
|
|
org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
@@ -2031,6 +2013,26 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
Element table = doc.select("table").first();
|
|
|
Elements trs = table.select("tr");
|
|
|
+
|
|
|
+ Elements bgHB = doc.select("el-input[placeholder~=报告编号.*]");
|
|
|
+ Elements jlBH = doc.select("el-input[placeholder~=记录编号.*]");
|
|
|
+ if (dto != null) {
|
|
|
+ //报告编号
|
|
|
+ if (bgHB.size() >= 1 && StringUtils.isNotEmpty(dto.getReportNo())) {
|
|
|
+ for (Element element : bgHB) {
|
|
|
+ DataInfo.put(element.attr("keyname"), "NUMBER-" + dto.getReportNo());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //记录编号
|
|
|
+ if (jlBH.size() >= 1 && StringUtils.isNotEmpty(dto.getRecordNo())) {
|
|
|
+ for (Element element : jlBH) {
|
|
|
+ DataInfo.put(element.attr("keyname"), "NUMBER-" + dto.getRecordNo());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
|
for (String val : Objects.requireNonNull(DataInfo).keySet()) {
|
|
|
if (val.contains("__")) {
|
|
@@ -2118,6 +2120,18 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
ObjectUtils.isNotEmpty(cell);
|
|
|
}
|
|
|
}
|
|
|
+ } else if (myData.contains("NUMBER-JL-") || myData.contains("NUMBER-BG-")) {
|
|
|
+ //记录表号、报告单号
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ if (cell != null) {
|
|
|
+ String replace = myData.replace("NUMBER-", "");
|
|
|
+ cell.setCellValue(replace);
|
|
|
+ } else {
|
|
|
+ ObjectUtils.isNotEmpty(cell);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
Row row = sheet.getRow(y1 - 1);
|
|
|
if (row != null) {
|
|
@@ -2156,7 +2170,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Elements tdsx = ytzData.select("td");
|
|
|
if (Integer.parseInt(trtd[1]) < tdsx.size()) {
|
|
|
Element data = ytzData.select("td").get(Integer.parseInt(trtd[1]));
|
|
|
- if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ if (data.html().contains("el-tooltip")) {
|
|
|
data = data.children().get(0);
|
|
|
}
|
|
|
|
|
@@ -2169,7 +2183,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Row row = sheet.getRow(y1 - 1);
|
|
|
if (row != null) {
|
|
|
Cell cell = sheet.getRow(y1 - 1).getCell(x1 - 1);
|
|
|
- if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ if (cell != null) {
|
|
|
short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
Font oldfontAt = workbook.getFontAt(fontIndex);
|
|
|
|
|
@@ -2183,6 +2197,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
newStyle.setFont(redFont);
|
|
|
cell.setCellStyle(newStyle);
|
|
|
cell.setCellValue(e.getId() + "");
|
|
|
+ } else {
|
|
|
+ ObjectUtils.isNotEmpty(cell);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2262,17 +2278,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
*/
|
|
|
@Override
|
|
|
public String getBussPDFSTrial(String nodeId, String tableType, String classify, String contractId, String
|
|
|
- projectId, Long id, String tabIds) throws Exception {
|
|
|
+ projectId, Long id, String tabIds, TrialSelfInspectionRecordDTO dto) throws Exception {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
//获取有权限的表的信息
|
|
|
- String sql = "select p_key_id,html_url,table_type,sort,node_name,create_time from m_wbs_tree_private where is_deleted = 0 and p_key_id in (" + tabIds + ") order by sort,node_name,create_time";
|
|
|
- List<WbsTreePrivate> queryList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ List<WbsTreePrivate> queryList = jdbcTemplate.query("select p_key_id,html_url,table_type,sort,node_name,create_time from m_wbs_tree_private where is_deleted = 0 and p_key_id in (" + tabIds + ") order by sort,node_name,create_time", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
List<String> dataPdfUrls = new ArrayList<>();
|
|
|
|
|
|
//报告单
|
|
|
- List<WbsTreePrivate> reportTable = queryList.stream().filter(f -> f.getTableType() == 2).collect(Collectors.toList());
|
|
|
+ List<WbsTreePrivate> reportTable = queryList.stream().filter(f -> f.getTableType() == 10 || f.getTableType() == 2).collect(Collectors.toList());
|
|
|
//记录表
|
|
|
- List<WbsTreePrivate> recordTable = queryList.stream().filter(f -> f.getTableType() == 1).collect(Collectors.toList());
|
|
|
+ List<WbsTreePrivate> recordTable = queryList.stream().filter(f -> f.getTableType() == 9 || f.getTableType() == 1).collect(Collectors.toList());
|
|
|
|
|
|
if (queryList.size() > 0) {
|
|
|
int reportPageNumber = 1;
|
|
@@ -2282,7 +2297,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//没有excel表单的不生成pdf
|
|
|
if (StringUtils.isNotEmpty(report.getHtmlUrl())) {
|
|
|
//生成报告单pdf
|
|
|
- String bussPdfInfo = this.getBussPDFTrial(report.getPKeyId(), contractId, id, reportPageNumber++, reportPageNumberCount);
|
|
|
+ String bussPdfInfo = this.getBussPDFTrial(report.getPKeyId(), contractId, id, reportPageNumber++, reportPageNumberCount, dto);
|
|
|
if (StringUtils.isNotEmpty(bussPdfInfo)) {
|
|
|
dataPdfUrls.add(bussPdfInfo);
|
|
|
}
|
|
@@ -2297,7 +2312,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//没有excel表单的不生成pdf
|
|
|
if (StringUtils.isNotEmpty(record.getHtmlUrl())) {
|
|
|
//生成记录表pdf
|
|
|
- String bussPdfInfo = this.getBussPDFTrial(record.getPKeyId(), contractId, id, recordPageNumber++, recordPageNumberCount);
|
|
|
+ String bussPdfInfo = this.getBussPDFTrial(record.getPKeyId(), contractId, id, recordPageNumber++, recordPageNumberCount, dto);
|
|
|
if (StringUtils.isNotEmpty(bussPdfInfo)) {
|
|
|
dataPdfUrls.add(bussPdfInfo);
|
|
|
}
|