|
@@ -27,9 +27,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.mixsmart.utils.ListUtils;
|
|
|
import com.spire.xls.*;
|
|
|
+import com.spire.xls.CellRange;
|
|
|
+import com.spire.xls.Workbook;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.Font;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.util.IOUtils;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
@@ -43,6 +50,7 @@ import org.springblade.business.vo.SaveContractLogVO;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.common.vo.DataVO;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
@@ -50,6 +58,7 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
+import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.manager.bean.TableInfo;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.formula.KeyMapper;
|
|
@@ -60,15 +69,22 @@ import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.TransactionDefinition;
|
|
|
+import org.springframework.transaction.TransactionStatus;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.awt.*;
|
|
|
+import java.awt.Color;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
import java.io.*;
|
|
|
import java.net.URL;
|
|
@@ -87,37 +103,26 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTab> implements IExcelTabService {
|
|
|
|
|
|
- //客户端资料查询接口
|
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
- // 元素信息表-
|
|
|
private final IWbsTreeContractService wbsTreeContractService;
|
|
|
-
|
|
|
private final IFormulaService formulaService;
|
|
|
- private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- private final IWbsParamService wbsParamService;
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DataSourceTransactionManager transactionManager1;
|
|
|
+ private final IWbsParamService wbsParamService;
|
|
|
private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
-
|
|
|
private final ContractLogClient contractLogClient;
|
|
|
-
|
|
|
- // 表单字典信息表
|
|
|
private final ITextdictInfoService textdictInfoService;
|
|
|
-
|
|
|
- // Oss接口
|
|
|
private final NewIOSSClient newIOSSClient;
|
|
|
- // 表单附件信息
|
|
|
private final ITableFileService tableFileService;
|
|
|
-
|
|
|
- // 合同端信息
|
|
|
private final IContractInfoService contractInfoService;
|
|
|
-
|
|
|
private final IProjectInfoService projectInfoService;
|
|
|
-
|
|
|
- // 用户操作日志信息
|
|
|
private final OperationLogClient operationLogClient;
|
|
|
-
|
|
|
private final TrialSelfInspectionRecordClient inspectionRecordClient;
|
|
|
+ private final TableInfoServiceImpl tableInfoService;
|
|
|
|
|
|
@Override
|
|
|
public IPage<ExcelTabVO> selectExcelTabPage(IPage<ExcelTabVO> page, ExcelTabVO excelTab) {
|
|
@@ -509,73 +514,50 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
/**
|
|
|
* 在线excel 编辑回调
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
*/
|
|
|
@Override
|
|
|
- public void callbackSave(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
|
- PrintWriter writer = response.getWriter();
|
|
|
- String body = "";
|
|
|
- try {
|
|
|
- Scanner scanner = new Scanner(request.getInputStream());
|
|
|
- scanner.useDelimiter("\\A");
|
|
|
- body = scanner.hasNext() ? scanner.next() : "";
|
|
|
- scanner.close();
|
|
|
- } catch (Exception ex) {
|
|
|
- writer.write("get request.getInputStream error:" + ex.getMessage());
|
|
|
- return;
|
|
|
- }
|
|
|
- if (body.isEmpty()) {
|
|
|
- writer.write("empty request.getInputStream");
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject jsonObj = JSON.parseObject(body);
|
|
|
- System.out.println("回调参数对象 =====》》》 " + jsonObj);
|
|
|
- int status = (Integer) jsonObj.get("status");
|
|
|
+ public ExcelEditCallback callbackSave(ExcelEditCallback callback) {
|
|
|
+ ExcelEditCallback editCallback = new ExcelEditCallback();
|
|
|
+ editCallback.setError(0); //初始化返回值
|
|
|
+ int status = callback.getStatus();
|
|
|
int saved = 0;
|
|
|
//status=6,表示点击保存按钮 2 关闭保存
|
|
|
if (status == 3 || status == 6) //MustSave, Corrupted
|
|
|
{
|
|
|
//获取url
|
|
|
- String downloadUri = (String) jsonObj.get("url");
|
|
|
+ String downloadUri = callback.getUrl();
|
|
|
downloadUri = downloadUri.replaceAll("amp;", "");
|
|
|
try {
|
|
|
//获取onlyOffice缓存中的文件流
|
|
|
- String fileName = request.getParameter("fileName");
|
|
|
- System.out.println("====下载的文件名:" + fileName);
|
|
|
URL url = new URL(downloadUri);
|
|
|
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
|
|
|
- InputStream stream = connection.getInputStream();
|
|
|
- if (stream == null) {
|
|
|
- throw new Exception("Stream is null");
|
|
|
+ InputStream inputStream = connection.getInputStream();
|
|
|
+ if (inputStream == null) {
|
|
|
+ throw new Exception("文件为空");
|
|
|
}
|
|
|
- Long tabId = jsonObj.getLong("key");
|
|
|
+ Long tabId = callback.getKey();
|
|
|
if (tabId == null) {
|
|
|
- throw new Exception("key不能为空");
|
|
|
+ throw new Exception("excel为空");
|
|
|
}
|
|
|
//获取数据库信息
|
|
|
ExcelTab excelTab = baseMapper.selectById(tabId);
|
|
|
-
|
|
|
//上传新文件到文件服务器
|
|
|
- byte[] officeByte = IoUtil.readToByteArray(stream);
|
|
|
- BladeFile bladeFile = newIOSSClient.updateFile(officeByte, excelTab.getName());
|
|
|
-
|
|
|
+ byte[] officeByte = IoUtil.readToByteArray(inputStream);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.updateFile(officeByte, excelTab.getExtension());
|
|
|
//修改本地数据信息
|
|
|
- excelTab.setHtmlUrl(bladeFile.getLink());
|
|
|
+ excelTab.setFileUrl(bladeFile.getLink());
|
|
|
//获取文件大小
|
|
|
int size = connection.getContentLength() / 1024 / 1024; //单位M
|
|
|
excelTab.setAttachSize(Long.parseLong(size + ""));
|
|
|
+ excelTab.setStatus(3);
|
|
|
baseMapper.updateById(excelTab);
|
|
|
connection.disconnect();
|
|
|
- //根据文件编号删除文件服务器的文件
|
|
|
-
|
|
|
- } catch (Exception ex) {
|
|
|
- saved = 1;
|
|
|
- ex.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ editCallback.setError(1);
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
- writer.write("{\"error\":" + saved + "}");
|
|
|
+ return editCallback;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -590,66 +572,72 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
if (linkProcessList == null) {
|
|
|
linkProcessList = new ArrayList<>();
|
|
|
}
|
|
|
-
|
|
|
//获取数据所在数据表名
|
|
|
- WbsTreeContract table = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
+ WbsTreeContract contractNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
.eq(WbsTreeContract::getContractId, tableInfoList.get(0).getContractId())
|
|
|
.eq(WbsTreeContract::getTableType, 111));
|
|
|
- if (table == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- String tableName = table.getInitTableName();
|
|
|
- if (StringUtils.isEmpty(tableName)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- //获取首件记录ID
|
|
|
- String firstId = tableInfoList.get(0).getFirstId();
|
|
|
- if (StringUtils.isNotEmpty(firstId)) {
|
|
|
- //删除掉旧数据
|
|
|
- this.jdbcTemplate.execute("DELETE FROM " + tableName + " WHERE group_id = " + firstId);
|
|
|
- } else {
|
|
|
- firstId = SnowFlakeUtil.getId() + "";
|
|
|
- }
|
|
|
+ if (ObjectUtil.isNotEmpty(contractNode)) {
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
+ .eq(WbsTreePrivate::getId, contractNode.getId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, contractNode.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getWbsId, contractNode.getWbsId())
|
|
|
+ .eq(WbsTreePrivate::getTableType, 111)
|
|
|
+ );
|
|
|
+ if (StringUtils.isNotEmpty(wbsTreePrivate.getInitTableName())) {
|
|
|
+ if (StringUtils.isNotEmpty(wbsTreePrivate.getInitTableId())) {
|
|
|
+ org.springblade.manager.entity.TableInfo table = tableInfoService.getBaseMapper().selectById(wbsTreePrivate.getInitTableId());
|
|
|
+ if (ObjectUtil.isNotEmpty(table)) {
|
|
|
+ //获取首件记录ID
|
|
|
+ String firstId = tableInfoList.get(0).getFirstId();
|
|
|
+ if (StringUtils.isNotEmpty(firstId)) {
|
|
|
+ //删除掉旧数据
|
|
|
+ this.jdbcTemplate.execute("DELETE FROM " + table.getTabEnName() + " WHERE group_id = " + firstId);
|
|
|
+ } else {
|
|
|
+ firstId = SnowFlakeUtil.getId() + "";
|
|
|
+ }
|
|
|
|
|
|
- //获取上传的文件相关
|
|
|
- String sourceUrl = tableInfoList.get(0).getSourceUrl(),
|
|
|
- pdfUrl = tableInfoList.get(0).getPdfUrl(),
|
|
|
- firstFileName = tableInfoList.get(0).getFirstFileName();
|
|
|
+ //获取上传的文件相关
|
|
|
+ String sourceUrl = tableInfoList.get(0).getSourceUrl(),
|
|
|
+ pdfUrl = tableInfoList.get(0).getPdfUrl(),
|
|
|
+ firstFileName = tableInfoList.get(0).getFirstFileName();
|
|
|
|
|
|
- //新增数据
|
|
|
- for (TableInfo tableInfo : tableInfoList) {
|
|
|
- //获取字段信息
|
|
|
- LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
+ //新增数据
|
|
|
+ for (TableInfo tableInfo : tableInfoList) {
|
|
|
+ //获取字段信息
|
|
|
+ LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
|
|
|
|
- //拼接SQL
|
|
|
- StringBuilder sql = new StringBuilder("INSERT INTO " + tableName),
|
|
|
- keySql = new StringBuilder("id, group_id"),
|
|
|
- valSql = new StringBuilder("" + SnowFlakeUtil.getId() + ", " + firstId);
|
|
|
+ //拼接SQL
|
|
|
+ StringBuilder sql = new StringBuilder("INSERT INTO " + table.getTabEnName()),
|
|
|
+ keySql = new StringBuilder("id, group_id"),
|
|
|
+ valSql = new StringBuilder("" + SnowFlakeUtil.getId() + ", " + firstId);
|
|
|
|
|
|
- for (String key : dataMap2.keySet()) {
|
|
|
- keySql.append(", ").append(key);
|
|
|
- valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
- }
|
|
|
+ for (String key : dataMap2.keySet()) {
|
|
|
+ keySql.append(", ").append(key);
|
|
|
+ valSql.append(", '").append(dataMap2.get(key)).append("'");
|
|
|
+ }
|
|
|
|
|
|
- sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
+ sql.append("(").append(keySql).append(")").append(" values(").append(valSql).append(")");
|
|
|
|
|
|
- //新增数据
|
|
|
- try {
|
|
|
- this.jdbcTemplate.execute(sql.toString());
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ //新增数据
|
|
|
+ try {
|
|
|
+ this.jdbcTemplate.execute(sql.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //获取文件题名
|
|
|
- String fileTitleNames = this.getFileTitleNames(firstNodeId);
|
|
|
+ //获取文件题名
|
|
|
+ String fileTitleNames = this.getFileTitleNames(firstNodeId);
|
|
|
|
|
|
- try {
|
|
|
- //新增或修改首件记录
|
|
|
- return this.informationQueryClient.saveOrUpdateInformationQueryData(firstNodeId, table.getPKeyId() + "", firstId, StringUtils.isNotEmpty(fileTitleNames) ? fileTitleNames : "首件文件名称为空", Integer.parseInt(tableInfoList.get(0).getClassify()), 2, "true", sourceUrl, pdfUrl, firstFileName, linkProcessList);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ try {
|
|
|
+ //新增或修改首件记录
|
|
|
+ return this.informationQueryClient.saveOrUpdateInformationQueryData(firstNodeId, contractNode.getPKeyId() + "", firstId, StringUtils.isNotEmpty(fileTitleNames) ? fileTitleNames : "首件文件名称为空", Integer.parseInt(tableInfoList.get(0).getClassify()), 2, "true", sourceUrl, pdfUrl, firstFileName, linkProcessList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -667,7 +655,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
WbsTreePrivate firstNode = wbsTreePrivates.stream().filter(f -> f.getNodeType().equals(111)).findAny().orElse(null);
|
|
|
|
|
|
- List<WbsTreePrivate> collect1 = wbsTreePrivates.stream().filter(f -> f.getNodeType().equals(1)).collect(Collectors.toList());
|
|
|
+ List<WbsTreePrivate> collect1 = wbsTreePrivates.stream().filter(f -> f.getNodeType().equals(1) && f.getParentId() != 0L).collect(Collectors.toList());
|
|
|
|
|
|
List<WbsTreePrivate> collect4 = wbsTreePrivates.stream().filter(f -> f.getNodeType().equals(4)).collect(Collectors.toList());
|
|
|
|
|
@@ -678,7 +666,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
assert firstNode != null;
|
|
|
if (firstNode.getAncestors().contains(obj1.getId().toString())) {
|
|
|
fileTitleNames.append(obj1.getNodeName());
|
|
|
- break;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -697,8 +684,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public TransactionStatus beginTransaction(DataSourceTransactionManager transactionManager){
|
|
|
+ DefaultTransactionDefinition def = new DefaultTransactionDefinition();//事务定义类
|
|
|
+ def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
|
|
+ TransactionStatus status = transactionManager.getTransaction(def);// 返回事务对象
|
|
|
+ return status;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
- @Transactional
|
|
|
public R saveOrUpdateInfo(List<TableInfo> tableInfoList) {
|
|
|
|
|
|
if (ListUtils.isNotEmpty(tableInfoList)) {
|
|
@@ -715,7 +710,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
String tabName = wbsTreeContract.getInitTableName();
|
|
|
// 判读修改还是 添加
|
|
|
String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId();
|
|
|
- jdbcTemplate.execute(delSql);
|
|
|
+
|
|
|
|
|
|
String sqlInfo = "";
|
|
|
LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
|
|
@@ -746,7 +741,16 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
updateWrapper.in("p_key_id", tableInfo.getPkeyId());
|
|
|
updateWrapper.set("is_tab_pdf", 2);
|
|
|
wbsTreeContractService.update(updateWrapper);
|
|
|
- jdbcTemplate.execute(sqlInfo);
|
|
|
+
|
|
|
+ TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute(delSql);
|
|
|
+ jdbcTemplate.execute(sqlInfo);
|
|
|
+ transactionManager1.commit(transactionStatus);
|
|
|
+ }catch (Exception e){
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//获取节点
|
|
@@ -942,7 +946,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
for (String key : mysqlData.keySet()) {
|
|
|
String tabVal = mysqlData.get(key) + "";
|
|
|
// 时间段处理
|
|
|
- if (StringUtils.isNotEmpty(tabVal) && !tabVal.equals("null")) {
|
|
|
+ if (StringUtils.isNotEmpty(tabVal) && tabVal.indexOf("null")<0) {
|
|
|
if (tabVal.indexOf("T") >= 0 && tabVal.indexOf(".000Z]") >= 0) {
|
|
|
String[] tabData = tabVal.split("_\\^_");
|
|
|
|
|
@@ -1026,7 +1030,8 @@ 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/";//ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
@@ -1055,20 +1060,63 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(pkeyId).getData();
|
|
|
|
|
|
// 获取excel流 和 html流
|
|
|
- Workbook wb = new Workbook();
|
|
|
- wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
+ InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
|
|
|
+ org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(exceInp);
|
|
|
+
|
|
|
//获取工作表
|
|
|
- Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+
|
|
|
// 标题添加
|
|
|
ProjectInfo projectInfo = projectInfoService.getById(wbsTreeContract.getProjectId());
|
|
|
- CellRange[] columns = sheet.getMergedCells();
|
|
|
- for (int i = 0; i < columns.length; i++) {
|
|
|
- CellRange cellRange = columns[i];
|
|
|
- System.out.println(cellRange.getStyle().getFont().getSize());
|
|
|
- if (cellRange.getStyle().getFont().getSize() >= 14) {
|
|
|
- cellRange.setText(projectInfo.getProjectName());
|
|
|
- cellRange.getStyle().getFont().setSize(20);
|
|
|
- break;
|
|
|
+
|
|
|
+ int all = sheet.getRow(0).getLastCellNum();
|
|
|
+ int mergedCellCnt = sheet.getNumMergedRegions();
|
|
|
+ List<Map<String,Integer>> titleList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < mergedCellCnt-1; i++) {
|
|
|
+ CellRangeAddress mergedCell = sheet.getMergedRegion(i);
|
|
|
+ int xx =mergedCell.getNumberOfCells();
|
|
|
+ if(xx==all){
|
|
|
+ int fisRow = mergedCell.getFirstRow();
|
|
|
+ int firsrCol = mergedCell.getFirstColumn();
|
|
|
+ Cell cell = sheet.getRow(fisRow).getCell(firsrCol);
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
+ short fontHeightInPoints = fontAt.getFontHeightInPoints();
|
|
|
+ if(fontHeightInPoints>=14){
|
|
|
+ Map<String,Integer> titleMap = new HashMap<>();
|
|
|
+ titleMap.put("index",i);
|
|
|
+ titleMap.put("x",firsrCol);
|
|
|
+ titleMap.put("y",fisRow);
|
|
|
+ String data = cell.getStringCellValue();
|
|
|
+ if(StringUtils.isNotEmpty(data)){
|
|
|
+ titleMap.put("val",2);
|
|
|
+ }else{
|
|
|
+ titleMap.put("val",1);
|
|
|
+ }
|
|
|
+ titleList.add(titleMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加标题
|
|
|
+ System.out.println(titleList.size());
|
|
|
+ if(titleList!=null){
|
|
|
+ if(titleList.size()==1){
|
|
|
+ Map<String,Integer> titData = titleList.get(0);
|
|
|
+ if(titData.get("val")==1){
|
|
|
+ Cell cell = sheet.getRow(titData.get("y")).getCell(titData.get("x"));
|
|
|
+ cell.setCellValue(projectInfo.getProjectName());
|
|
|
+ }
|
|
|
+ }else if(titleList.size()>=2){
|
|
|
+ for(int i=0;i<titleList.size();i++){
|
|
|
+ Map<String,Integer> titData = titleList.get(i);
|
|
|
+ if(titData.get("val")==2){
|
|
|
+ Map<String,Integer> titData2 = titleList.get(i-1);
|
|
|
+ Cell cell = sheet.getRow(titData2.get("y")).getCell(titData2.get("x"));
|
|
|
+ cell.setCellValue(projectInfo.getProjectName());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1092,10 +1140,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
int x1 = 0;
|
|
|
+ int x2 = 0;
|
|
|
int y1 = 0;
|
|
|
+ int y2 = 0;
|
|
|
|
|
|
if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
+ x2 = Integer.parseInt(data.children().get(0).children().get(0).attr("x2"));
|
|
|
y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
} else {
|
|
|
x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
@@ -1108,7 +1159,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
|
sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
|
|
|
- SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM-dd");
|
|
|
+ SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
|
|
|
myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
@@ -1131,58 +1182,37 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
//https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
|
if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
|
|
|
- BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
-
|
|
|
- int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
|
|
|
- int rowspan = data.attr("ROWSPAN").equals("") ? 0 : Integer.parseInt(data.attr("ROWSPAN"));
|
|
|
- int picHeight = 0;
|
|
|
- int picWidth = 0;
|
|
|
-
|
|
|
- if (rowspan == 0) {
|
|
|
- String dataInfo = trs.get(y1).attr("height");
|
|
|
- if (StringUtils.isEmpty(dataInfo)) {
|
|
|
- Element firstTd = trs.get(y1 - 1).children().get(0);
|
|
|
- String[] heg = firstTd.attr("style").split(";");
|
|
|
- for (String str : heg) {
|
|
|
- if (str.indexOf("height:") >= 0) {
|
|
|
- picHeight = Integer.parseInt(str.split(":")[1].replaceAll("px", ""));
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- picHeight = Integer.parseInt(dataInfo);
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int i = y1; i <= (y1 + rowspan); i++) { // 跨列处理
|
|
|
- String dataInfo = trs.get(i).attr("height");
|
|
|
- if (StringUtils.isNotEmpty(dataInfo)) {
|
|
|
- picHeight += Integer.parseInt(dataInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (colspan >= 1) {
|
|
|
- for (int i = x1 - 1; i < x1 + colspan - 1; i++) {
|
|
|
- String dataInfo = cols.get(i).attr("width").replaceAll("px", "");
|
|
|
- if (StringUtils.isNotEmpty(dataInfo)) {
|
|
|
- picWidth += Integer.parseInt(dataInfo);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
|
+ byte[] bytes = IOUtils.toByteArray(imageIn);
|
|
|
+ // 这里根据实际需求选择图片类型
|
|
|
+ int pictureIdx = workbook.addPicture(bytes,6);
|
|
|
+
|
|
|
+ CreationHelper helper = workbook.getCreationHelper();
|
|
|
+ ClientAnchor anchor = helper.createClientAnchor();
|
|
|
+ anchor.setCol1(x1); // param1是列号
|
|
|
+ anchor.setCol2(x2);
|
|
|
+ anchor.setRow1(y1); // param2是行号
|
|
|
+ anchor.setRow2(y2); // param2是行号
|
|
|
+ //
|
|
|
+ Drawing drawing = sheet.createDrawingPatriarch();
|
|
|
+ anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
|
|
|
+ // 插入图片
|
|
|
+ Picture pict = drawing.createPicture(anchor, pictureIdx); // 调整图片占单元格百分比的大小,1.0就是100%
|
|
|
+ pict.resize(1,1);
|
|
|
+ FileUtils.imageOrientation(sheet, anchor, new DataVO(x1-1, y1-1) );
|
|
|
+
|
|
|
+ } else if(myData.equals("1") && data.html().indexOf("hc-form-checkbox-group")>=0){
|
|
|
+ Cell cell = sheet.getRow(y1-1).getCell(x1-1);
|
|
|
+ String exceVal = cell.getStringCellValue().replaceAll(" ","");
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
+ cell.setCellValue(exceVal.replace("□","\u2611"));
|
|
|
+ }else {
|
|
|
+ Cell cell = sheet.getRow(y1-1).getCell(x1-1);
|
|
|
+ cell.setCellValue(myData);
|
|
|
|
|
|
- ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
- pic.setAutoSize(true);
|
|
|
- pic.setWidth(picWidth - 10);
|
|
|
|
|
|
- System.out.println(sheet.get(y1, x1).getRowHeight());
|
|
|
- System.out.println(sheet.get(y1, x1).getRows());
|
|
|
- pic.setHeight(picHeight);
|
|
|
- pic.setLeft(5);
|
|
|
- } else {
|
|
|
- CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
- cellRange.getCellStyle().getExcelFont().setFontName("EUDC");
|
|
|
- cellRange.setText(myData);
|
|
|
- System.out.println(cellRange.getStyle().getFont().getFontName());
|
|
|
- System.out.println("后" + cellRange.getText());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1207,16 +1237,27 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
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);
|
|
|
-
|
|
|
+ Cell cell = sheet.getRow(y1-1).getCell(x1-1);
|
|
|
+ cell.setCellValue(e.getId() + "");
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font oldfontAt = workbook.getFontAt(fontIndex);
|
|
|
+
|
|
|
+ Font redFont = workbook.createFont();
|
|
|
+ redFont.setColor(IndexedColors.WHITE.getIndex());
|
|
|
+ redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());
|
|
|
+ redFont.setFontName(oldfontAt.getFontName());
|
|
|
+ CellStyle cellStyle = workbook.createCellStyle();
|
|
|
+ cellStyle.setFont(redFont);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- wb.saveToFile(excelPath, ExcelVersion.Version2010);
|
|
|
+ // wb.saveToFile(excelPath, ExcelVersion.Version2010);
|
|
|
+ //输出流
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
+ workbook.write(outputStream);
|
|
|
FileUtils.excelToPdf(excelPath, pdfPath);
|
|
|
BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
|
|
|
//
|
|
@@ -1258,13 +1299,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
updateWrapper.in("p_key_id", pkeyId + "");
|
|
|
updateWrapper.set("pdf_url", bladeFile2.getLink());
|
|
|
wbsTreeContractService.update(updateWrapper);
|
|
|
- wb.dispose();
|
|
|
+
|
|
|
+ if (outputStream != null) {
|
|
|
+ IoUtil.closeQuietly(outputStream);
|
|
|
+ }
|
|
|
+ if (exceInp != null) {
|
|
|
+ IoUtil.closeQuietly(exceInp);
|
|
|
+ }
|
|
|
+
|
|
|
return R.data(bladeFile2.getLink());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void getBussPdfs(String nodeId, String classify, String contractId, String projectId) 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/" ;//ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
// 获取有权限的节点信息
|
|
|
List<AppWbsTreeContractVO> wbsTreeContractList = wbsTreeContractService.searchNodeAllTable(nodeId, classify, contractId, projectId);
|
|
|
List<String> data = new ArrayList<>();
|
|
@@ -1298,6 +1347,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 试验 获取填报信息
|
|
|
*/
|
|
@@ -1494,6 +1546,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
if (data.html().contains("el-tooltip")) {
|
|
|
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"));
|