|
@@ -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;
|
|
@@ -90,7 +106,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
private final InformationQueryClient informationQueryClient;
|
|
|
private final IWbsTreeContractService wbsTreeContractService;
|
|
|
private final IFormulaService formulaService;
|
|
|
- private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataSourceTransactionManager transactionManager1;
|
|
|
private final IWbsParamService wbsParamService;
|
|
|
private final IWbsTreePrivateService wbsTreePrivateService;
|
|
|
private final ContractLogClient contractLogClient;
|
|
@@ -493,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;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -686,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)) {
|
|
@@ -704,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();
|
|
@@ -735,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();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//获取节点
|
|
@@ -931,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("_\\^_");
|
|
|
|
|
@@ -1015,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));
|
|
@@ -1044,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());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1081,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"));
|
|
@@ -1092,12 +1154,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
if (x1 == 0) {
|
|
|
x1 = 1;
|
|
|
- }
|
|
|
+ }*/
|
|
|
String myData = DataInfo.get(val) + "";
|
|
|
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("'", "");
|
|
@@ -1120,34 +1182,26 @@ 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));
|
|
|
+ InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
|
+ byte[] bytes = IOUtils.toByteArray(imageIn);
|
|
|
+ // 这里根据实际需求选择图片类型
|
|
|
+ int pictureIdx = workbook.addPicture(bytes,6);
|
|
|
|
|
|
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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ } 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);
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
|
|
|
if (colspan >= 1) {
|
|
|
for (int i = x1 - 1; i < x1 + colspan - 1; i++) {
|
|
@@ -1158,20 +1212,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1196,16 +1236,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);
|
|
|
//
|
|
@@ -1247,13 +1298,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<>();
|
|
@@ -1287,6 +1346,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 试验 获取填报信息
|
|
|
*/
|
|
@@ -1483,11 +1545,14 @@ 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"));
|
|
|
+ y2 = Integer.parseInt(data.children().get(0).children().get(0).attr("y2"));
|
|
|
} else {
|
|
|
x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ x2 = Integer.parseInt(data.children().get(0).attr("x2"));
|
|
|
y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+ y2 = Integer.parseInt(data.children().get(0).attr("y2"));
|
|
|
}
|
|
|
- if (x1 == 0) {
|
|
|
+ /*if (x1 == 0) {
|
|
|
x1 = 1;
|
|
|
}
|
|
|
String myData = DataInfo.get(val) + "";
|
|
@@ -1515,10 +1580,19 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
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;
|
|
|
+ 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) );
|
|
|
|
|
|
if (rowspan == 0) {
|
|
|
String dataInfo = trs.get(y1).attr("height");
|
|
@@ -1542,14 +1616,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ cell.setCellValue(myData);
|
|
|
|
|
|
ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
pic.setAutoSize(true);
|