|
@@ -0,0 +1,923 @@
|
|
|
+package org.springblade.land.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.util.IOUtils;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
+import org.jsoup.select.Elements;
|
|
|
+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.mp.support.Query;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
+import org.springblade.land.dto.PolicyInfoDTO;
|
|
|
+import org.springblade.land.dto.PolicyInfoSearchDTO;
|
|
|
+import org.springblade.land.entity.*;
|
|
|
+import org.springblade.land.mapper.CompensationInfoMapper;
|
|
|
+import org.springblade.land.mapper.PolicyInfoMapper;
|
|
|
+import org.springblade.land.service.*;
|
|
|
+import org.springblade.land.utils.FileUtils;
|
|
|
+import org.springblade.land.vo.TableDataVO;
|
|
|
+import org.springblade.manager.entity.*;
|
|
|
+import org.springblade.manager.vo.AppWbsTreeContractVO;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
+import org.springblade.system.cache.ParamCache;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+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 java.io.*;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInfoMapper, CompensationInfo> implements ICompensationInfoService {
|
|
|
+
|
|
|
+ private final IAgreementLinkTableService linkTableService;
|
|
|
+
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ private DataSourceTransactionManager transactionManager1;
|
|
|
+
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
+
|
|
|
+ private final IRegionTreeInfoService treeInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取补偿表单
|
|
|
+ * @param projectId
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<WbsTreePrivate> getTables(Long projectId, Integer nodeType ) {
|
|
|
+ return baseMapper.getTables(projectId,nodeType);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 协议表单 获取html接口
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R getExcelHtmlByBuss(Long pkeyId,Integer type) throws Exception {
|
|
|
+ //获取表单信息
|
|
|
+ String fileUrl = "";
|
|
|
+ Long projectId = null;
|
|
|
+ if (type == 1) {
|
|
|
+ WbsTreePrivate wbsTreePrivate = baseMapper.getWbsPrivateTable(pkeyId);
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
+ }
|
|
|
+ if (wbsTreePrivate.getHtmlUrl() == null) {
|
|
|
+ return R.fail("暂无表单!");
|
|
|
+ }
|
|
|
+ fileUrl = wbsTreePrivate.getHtmlUrl();
|
|
|
+ projectId = Long.parseLong(wbsTreePrivate.getProjectId());
|
|
|
+ }else if (type == 2){
|
|
|
+ AgreementLinkTable table = linkTableService.getById(pkeyId);
|
|
|
+ fileUrl = table.getHtmlUrl();
|
|
|
+ projectId = table.getProjectId();
|
|
|
+ }
|
|
|
+// fileUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html";
|
|
|
+ InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
|
|
|
+
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
+ htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
+
|
|
|
+
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ // 添加标题显示
|
|
|
+ ProjectInfo projectInfo = baseMapper.getProjectInfo(projectId);
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+ for (int i = 1; i < 6; i++) {
|
|
|
+ Element tr = trs.get(i);
|
|
|
+ Elements tds = tr.select("td");
|
|
|
+ for (int j = 0; j < tds.size(); j++) {
|
|
|
+ Element data = tds.get(j);
|
|
|
+ String style = data.attr("style");
|
|
|
+ if (style.indexOf("font-size") >= 0) {
|
|
|
+ int fontsize = Integer.parseInt(style.substring(style.indexOf("font-size:") + 10, style.indexOf(".0pt")));
|
|
|
+ if (StringUtils.isNotEmpty(data.text()) && fontsize >= 14) {
|
|
|
+ trs.get(i - 1).select("td").get(0).text(projectInfo.getProjectName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ fileInputStream.close();
|
|
|
+ return R.data(table + "");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 协议表单 获取坐标位置
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R getHtmlBussCols(Long pkeyId,Integer type) throws Exception {
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
+ //获取表单信息
|
|
|
+ String fileUrl = "";
|
|
|
+ if (type == 1) {
|
|
|
+ WbsTreePrivate wbsTreePrivate = baseMapper.getWbsPrivateTable(pkeyId);
|
|
|
+ if (wbsTreePrivate == null) {
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
+ }
|
|
|
+ if (wbsTreePrivate.getHtmlUrl() == null) {
|
|
|
+ return R.fail("暂无表单!");
|
|
|
+ }
|
|
|
+ fileUrl = wbsTreePrivate.getHtmlUrl();
|
|
|
+ }else if (type == 2){
|
|
|
+ AgreementLinkTable table = linkTableService.getById(pkeyId);
|
|
|
+ fileUrl = table.getHtmlUrl();
|
|
|
+ }
|
|
|
+
|
|
|
+// fileUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html";
|
|
|
+ File file1 = ResourceUtil.getFile(fileUrl);
|
|
|
+ InputStream fileInputStream = null;
|
|
|
+ if (file1.exists()) {
|
|
|
+ fileInputStream = new FileInputStream(file1);
|
|
|
+ } else {
|
|
|
+ String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
|
|
|
+ fileInputStream = CommonUtil.getOSSInputStream(path);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ // 解析 style
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+
|
|
|
+ List<List<String>> redata = new ArrayList<>();
|
|
|
+ for (int i = 0; i < trs.size(); i++) {
|
|
|
+ Element tr = trs.get(i);
|
|
|
+ Elements tds = tr.select("td");
|
|
|
+ List<String> tdList = new ArrayList<>();
|
|
|
+ for (int j = 0; j < tds.size(); j++) {
|
|
|
+ Element element = tds.get(j);
|
|
|
+ if (element.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ element = element.children().get(0);
|
|
|
+ }
|
|
|
+ if (element.children().size() >= 1) {
|
|
|
+ String keyname = element.children().get(0).attr("keyname");
|
|
|
+ if (StringUtils.isNotEmpty(keyname)) {
|
|
|
+ tdList.add(keyname);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tdList != null && tdList.size() >= 1) {
|
|
|
+ redata.add(tdList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String[][] res = new String[redata.size()][]; // 存放转换结果的 二维数组
|
|
|
+ for (int i = 0; i < res.length; i++) { // 转换方法
|
|
|
+ res[i] = redata.get(i).toArray(new String[redata.get(i).size()]);
|
|
|
+ }
|
|
|
+ return R.data(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 协议表单获取用户保存数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R getBussDataInfo(Long linkId) {
|
|
|
+ //当前是新增没有数据
|
|
|
+ if (linkId == null){
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+ //获取表单数据
|
|
|
+ List<Map<String, Object>> mapList = baseMapper.getBussDataInfo(linkId);
|
|
|
+ //表单没有保存过
|
|
|
+ if (mapList == null || mapList.size() == 0){
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
+ reData = mapList.stream().collect(
|
|
|
+ Collectors.toMap(map1 -> (String) map1.get("tableKey"),
|
|
|
+ map2 -> map2.get("tableValue")));
|
|
|
+ return R.data(reData);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户保存接口
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public R saveBussData(JSONObject dataInfo) throws Exception {
|
|
|
+ JSONArray dataArray = new JSONArray();
|
|
|
+ if (dataInfo.containsKey("dataInfo")) { //节点保存
|
|
|
+ JSONObject jsonObject = dataInfo.getJSONObject("dataInfo");
|
|
|
+ dataArray = jsonObject.getJSONArray("orderList");
|
|
|
+ } else { //单个保存
|
|
|
+ dataArray.add(dataInfo);
|
|
|
+ }
|
|
|
+ JSONObject tableInfo1 = dataArray.getJSONObject(0);
|
|
|
+ Long id = tableInfo1.getLong("agreementId");
|
|
|
+ Long projectId = tableInfo1.getLong("projectId");
|
|
|
+ Long areaId = tableInfo1.getLong("areaId");
|
|
|
+ Integer nodeType = tableInfo1.getInteger("nodeType");
|
|
|
+ Boolean isUpdate = true;
|
|
|
+ List<AgreementLinkTable> linkTables = new ArrayList<>();
|
|
|
+ //中间表tableId与dataId的映射
|
|
|
+ Map<Long,Long> map = new HashMap<>();
|
|
|
+ //中间表tableId与linkId的映射
|
|
|
+ Map<Long,Long> map2 = new HashMap<>();
|
|
|
+ if (id == null){
|
|
|
+ Long agreeId = SnowFlakeUtil.getId();
|
|
|
+ isUpdate = false;
|
|
|
+ //新增建立协议与表单映射,新增复制时会直接在复制接口创建
|
|
|
+ List<WbsTreePrivate> tables = baseMapper.getTables(projectId, nodeType);
|
|
|
+ linkTables = tables.stream().map(l -> {
|
|
|
+ AgreementLinkTable table = new AgreementLinkTable();
|
|
|
+ table.setTableId(Long.parseLong(l.getInitTableId()));
|
|
|
+ table.setProjectId(projectId);
|
|
|
+ table.setTableDataId(SnowFlakeUtil.getId());
|
|
|
+ table.setId(SnowFlakeUtil.getId());
|
|
|
+ table.setAgreementId(agreeId);
|
|
|
+ table.setPrivateId(l.getId());
|
|
|
+ table.setSort(l.getSort());
|
|
|
+ table.setExcelId(l.getExcelId());
|
|
|
+ table.setHtmlUrl(l.getHtmlUrl());
|
|
|
+ table.setTableName(l.getNodeName());
|
|
|
+ map.put(table.getTableId(),table.getTableDataId());
|
|
|
+ map2.put(table.getTableId(),table.getId());
|
|
|
+ return table;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ linkTableService.saveBatch(linkTables);
|
|
|
+ id = agreeId;
|
|
|
+ }else {
|
|
|
+ //获取表单id与数据id的映射
|
|
|
+ linkTables = linkTableService.getByAgreementId(id);
|
|
|
+ linkTables.stream().forEach(l->map.put(l.getTableId(),l.getTableDataId()));
|
|
|
+ }
|
|
|
+ for (int i=0; i<dataArray.size();i++) {
|
|
|
+ JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
+ if (isUpdate){
|
|
|
+ //是修改,就先去删除原来保存的数据
|
|
|
+ baseMapper.deleteOldData(jsonObject.getLong("linkId"));
|
|
|
+ }else {
|
|
|
+ //新增时没有linkId,需要手动设置
|
|
|
+ jsonObject.put("linkId",map2.get(jsonObject.getLong("tableId")));
|
|
|
+ }
|
|
|
+ this.SaveOneTabInfo(jsonObject);
|
|
|
+ }
|
|
|
+ //合并PDF
|
|
|
+ this.mergePdfs(id);
|
|
|
+ //地类补偿金额
|
|
|
+ BigDecimal b1 = new BigDecimal(0);
|
|
|
+ //青苗
|
|
|
+ BigDecimal b2 = new BigDecimal(0);
|
|
|
+ //地面附着物
|
|
|
+ BigDecimal b3 = new BigDecimal(0);
|
|
|
+ //计算统计值
|
|
|
+ List<WbsFormElement> elementList = baseMapper.getTableElement(linkTables.stream().map(l -> l.getTableId()).collect(Collectors.toList()));
|
|
|
+ CompensationInfo info = new CompensationInfo();
|
|
|
+ info.setId(id);
|
|
|
+ //获取当前节点名称
|
|
|
+ RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
|
|
|
+ info.setNumber(treeInfo.getAreaName()+"默认编号");
|
|
|
+ info.setAreaId(areaId);
|
|
|
+ info.setProjectId(projectId);
|
|
|
+ info.setType(nodeType);
|
|
|
+ if (elementList == null || elementList.size() == 0){
|
|
|
+ info.setName("未找到用户名称");
|
|
|
+ info.setLandMoney(b1);
|
|
|
+ info.setCropsMoney(b2);
|
|
|
+ info.setAllMoney(b3);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ //获取所有表单填报值
|
|
|
+ List<TableDataVO> list = baseMapper.getBussDataInfoByDataIds(linkTables.stream().map(l -> l.getTableDataId()).collect(Collectors.toList()));
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ //按照表单分组
|
|
|
+ Map<Long, List<TableDataVO>> listMap = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(TableDataVO::getPKeyId));
|
|
|
+ for (WbsFormElement element : elementList) {
|
|
|
+ //获取统计字段
|
|
|
+ String fId = element.getFId();
|
|
|
+ String eKey = element.getEKey();
|
|
|
+ Integer dict = element.getDynamicDict();
|
|
|
+ Long dataId = map.get(Long.parseLong(fId));
|
|
|
+ if (listMap.get(dataId) != null && listMap.get(dataId).size() > 0){
|
|
|
+ //当前表单有保存数据,统计值
|
|
|
+ List<TableDataVO> dataVOS = listMap.get(dataId);
|
|
|
+ try {
|
|
|
+ for (TableDataVO dataVO : dataVOS) {
|
|
|
+ if (dataVO.getTabKey().contains(eKey)) {
|
|
|
+ if (dict.equals(1)){
|
|
|
+ b1 = b1.add(new BigDecimal(dataVO.getTabVal()));
|
|
|
+ }else if (dict.equals(2)){
|
|
|
+ b2 = b2.add(new BigDecimal(dataVO.getTabVal()));
|
|
|
+ }else if (dict.equals(3)){
|
|
|
+ b3 = b3.add(new BigDecimal(dataVO.getTabVal()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new ServiceException("金额字段不能包含其他字符,请重新填写");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ info.setName("默认值");
|
|
|
+ info.setLandMoney(b1);
|
|
|
+ info.setCropsMoney(b2.add(b3));
|
|
|
+ info.setAllMoney(info.getLandMoney().add(info.getCropsMoney()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存协议信息
|
|
|
+ if (isUpdate){
|
|
|
+ this.updateById(info);
|
|
|
+ }else {
|
|
|
+ this.save(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data("保存成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getBussPdfDataInfo(Long agreementId, Long tableId) {
|
|
|
+ AgreementLinkTable one = linkTableService.getOne(new LambdaQueryWrapper<AgreementLinkTable>()
|
|
|
+ .eq(AgreementLinkTable::getAgreementId, agreementId)
|
|
|
+ .eq(AgreementLinkTable::getTableDataId, tableId));
|
|
|
+ if (one == null){
|
|
|
+ throw new ServiceException("未查询到表单,请联系管理员");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(one.getPdfUrl())){
|
|
|
+ throw new ServiceException("当前表单还未生成PDF");
|
|
|
+ }
|
|
|
+ return R.data(one.getPdfUrl());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改时获取表单
|
|
|
+ * @param agreementId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<AgreementLinkTable> updateGetTables(Long agreementId) {
|
|
|
+ return baseMapper.getTablesByUpdate(agreementId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存单表
|
|
|
+ public void SaveOneTabInfo(JSONObject tableInfo) throws Exception {
|
|
|
+ System.out.println("---------="+new Date().toLocaleString());
|
|
|
+ Long linkId = tableInfo.getLong("linkId");
|
|
|
+
|
|
|
+ tableInfo.fluentRemove("contractId")
|
|
|
+ .fluentRemove("pkeyId")
|
|
|
+ .fluentRemove("p_key_id")
|
|
|
+ .fluentRemove("projectId")
|
|
|
+ .fluentRemove("classify")
|
|
|
+ .fluentRemove("pickerKey")
|
|
|
+ .fluentRemove("id")
|
|
|
+ .fluentRemove("isFirst")
|
|
|
+ .fluentRemove("firstNodeId")
|
|
|
+ .fluentRemove("isTheLog")
|
|
|
+ .fluentRemove("theLogId")
|
|
|
+ .fluentRemove("linkTabIds")
|
|
|
+ .fluentRemove("recordTime")
|
|
|
+ .fluentRemove("businessId")
|
|
|
+ .fluentRemove("sourceUrl")
|
|
|
+ .fluentRemove("pdfUrl")
|
|
|
+ .fluentRemove("firstFileName")
|
|
|
+ .fluentRemove("");
|
|
|
+
|
|
|
+ // 获取excel 对象
|
|
|
+ AgreementLinkTable linkTable = linkTableService.getById(linkId);
|
|
|
+
|
|
|
+ ExcelTab excelTab = baseMapper.getExcelTab(linkTable.getExcelId());
|
|
|
+
|
|
|
+ //获取excel流 和 html流
|
|
|
+ InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
|
|
|
+
|
|
|
+ System.out.println("---------2="+new Date().toLocaleString());
|
|
|
+ Workbook workbook=null;
|
|
|
+ int index = excelTab.getFileUrl().lastIndexOf(".");
|
|
|
+ String suffix = excelTab.getFileUrl().substring(index);
|
|
|
+
|
|
|
+ if (".xls".equals(suffix)) {
|
|
|
+ workbook = new HSSFWorkbook(exceInp);
|
|
|
+ } else if (".xlsx".equals(suffix)) {
|
|
|
+ workbook = new XSSFWorkbook(exceInp);
|
|
|
+ }
|
|
|
+ //获取工作表
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ String sqll = " insert into table_data_info (id, p_key_id, tab_key,key_val) values (?, ?, ?,?) ";
|
|
|
+ List<Object[]> list = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(linkTable.getHtmlUrl())) {
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(linkTable.getHtmlUrl());
|
|
|
+// InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html");
|
|
|
+ String htmlString = IoUtil.readToString(inputStreamByUrl);
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ if (ObjectUtil.isNotEmpty(tableInfo)) {
|
|
|
+ for(String key : tableInfo.keySet()){
|
|
|
+ if(key.contains("key")&&key.contains("__")){
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ list.add(new Object[]{id,linkTable.getTableDataId(),key,tableInfo.getString(key)});
|
|
|
+
|
|
|
+ Elements datas = doc.getElementsByAttributeValue("keyname", key);
|
|
|
+ Element data = null;
|
|
|
+ if (datas.size() >= 1) {
|
|
|
+ data = datas.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data != null) {
|
|
|
+ if (data.hasAttr("x1") && data.hasAttr("y1")) {
|
|
|
+ int x1 = 0;
|
|
|
+ int x2 = 0;
|
|
|
+ int y1 = 0;
|
|
|
+ int y2 = 0;
|
|
|
+
|
|
|
+ x1 = Integer.parseInt(data.attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.attr("y1"));
|
|
|
+
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ String myData = tableInfo.get(key) + "";
|
|
|
+ if ((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 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日");
|
|
|
+
|
|
|
+ if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+
|
|
|
+ myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+ Date Start_dataStr = new Date();
|
|
|
+ Date end_dataStr = new Date();
|
|
|
+ try {
|
|
|
+ if(myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0){
|
|
|
+ Start_dataStr = sdf.parse(dataVal[0]);
|
|
|
+ end_dataStr = sdf.parse(dataVal[1]);
|
|
|
+ }else{
|
|
|
+ Start_dataStr = formatStr.parse(dataVal[0]);
|
|
|
+ end_dataStr = formatStr.parse(dataVal[1]);
|
|
|
+ }
|
|
|
+ }catch (ParseException e){
|
|
|
+ throw new ServiceException("日期绑定错误");
|
|
|
+ }
|
|
|
+ String StartDate = formatStr.format(Start_dataStr);
|
|
|
+ String endDate = formatStr.format(end_dataStr);
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] dataStr = myData.split("T")[0].split("-");
|
|
|
+ if (dataStr.length == 3) {
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (myData.indexOf("lang.String") >= 0) {
|
|
|
+ Object obj = tableInfo.get(key);
|
|
|
+ if (obj instanceof String[]) {
|
|
|
+ String[] dataDate = (String[]) obj;
|
|
|
+ if ((dataDate[0].trim()).equals((dataDate[1].trim()))) {
|
|
|
+ myData = dataDate[0];
|
|
|
+ } else {
|
|
|
+ myData = dataDate[0] + "-" + dataDate[1].trim();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.tagName().equals("hc-form-checkbox-group")) {
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ String exceVal = cell.getStringCellValue().replaceAll(" ", "");
|
|
|
+ //如果有□ 代表 自动生成 如果没有 代表后期添加 需要显示html 中的值
|
|
|
+ if (exceVal.indexOf("□") >= 0) {
|
|
|
+ if (myData.equals("1")) {
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
+ cell.setCellValue(exceVal.replace("□", "\u2611"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String dataJson = data.attr(":objs");
|
|
|
+ if (StringUtils.isNotEmpty(dataJson)) {
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(dataJson);
|
|
|
+ List<Integer> idList = Func.toIntList(myData);
|
|
|
+ int indexx = 0;
|
|
|
+ if (idList.get(0) >= 1) {
|
|
|
+ indexx = idList.get(0) - 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ String dataInfo = jsonArray.getJSONObject(indexx).getString("name");
|
|
|
+ for (int inx = 1; inx < idList.size(); inx++) {
|
|
|
+ int valIndex = idList.get(inx) - 1;
|
|
|
+ dataInfo = dataInfo + "," + jsonArray.getJSONObject(valIndex).getString("name");
|
|
|
+ }
|
|
|
+ cell.setCellValue(dataInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
+ cell.setCellValue(myData);
|
|
|
+ }
|
|
|
+ boolean wrap = Optional.ofNullable(cell).map(Cell::getCellStyle).map(CellStyle::getWrapText).orElse(true);
|
|
|
+ if (!wrap) {
|
|
|
+ cell.getCellStyle().setShrinkToFit(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
+ try {
|
|
|
+ //新增
|
|
|
+ jdbcTemplate.batchUpdate(sqll, list);
|
|
|
+ //提交事务
|
|
|
+ transactionManager1.commit(transactionStatus);
|
|
|
+ } catch (Exception e) {
|
|
|
+ //回滚
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
+ throw new RuntimeException("字段过长,新增失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+
|
|
|
+ String pdfPath = file_path + "/pdf//" + linkId + ".pdf";
|
|
|
+ String excelPath = file_path + "/pdf//" + linkId + ".xlsx";
|
|
|
+
|
|
|
+ File tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
+ if (tabPdf.exists()) {
|
|
|
+ tabPdf.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //输出流
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
+ workbook.write(outputStream);
|
|
|
+ FileUtils.excelToPdf(excelPath,pdfPath);
|
|
|
+
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(linkId + ".pdf", pdfPath);
|
|
|
+ String fileUrl = bladeFile.getLink();
|
|
|
+ UpdateWrapper<AgreementLinkTable> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("agreement_id", linkTable.getAgreementId());
|
|
|
+ updateWrapper.eq("table_data_id", linkTable.getTableDataId());
|
|
|
+ updateWrapper.set("pdf_url", fileUrl);
|
|
|
+ linkTableService.update(updateWrapper);
|
|
|
+ tabPdf.delete();
|
|
|
+ ResourceUtil.getFile(excelPath);
|
|
|
+ //关闭流
|
|
|
+ IoUtil.closeQuietly(outputStream);
|
|
|
+ IoUtil.closeQuietly(exceInp);
|
|
|
+ }
|
|
|
+
|
|
|
+ //事务
|
|
|
+ public TransactionStatus beginTransaction(DataSourceTransactionManager transactionManager) {
|
|
|
+ DefaultTransactionDefinition def = new DefaultTransactionDefinition();//事务定义类
|
|
|
+ def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
|
|
+ return transactionManager.getTransaction(def);
|
|
|
+ }
|
|
|
+
|
|
|
+ //合并pdf
|
|
|
+ public void mergePdfs(Long agreementId) throws Exception {
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ //获取协议所有的表单
|
|
|
+ List<AgreementLinkTable> list = linkTableService.list(new LambdaQueryWrapper<AgreementLinkTable>()
|
|
|
+ .eq(AgreementLinkTable::getAgreementId, agreementId));
|
|
|
+ for (AgreementLinkTable table : list) {
|
|
|
+ if (StringUtils.isNotEmpty(table.getPdfUrl())) {
|
|
|
+ data.add(table.getPdfUrl());
|
|
|
+ } else {
|
|
|
+ R bussPdfInfo = this.getBussPdfInfo(table.getId());
|
|
|
+ if (bussPdfInfo.getCode() == 200) {
|
|
|
+ if (StringUtils.isNotBlank(bussPdfInfo.getData() + "")) {
|
|
|
+ data.add(bussPdfInfo.getData() + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String listPdf = file_path + "/pdf/" + agreementId + ".pdf";
|
|
|
+ File tabpdf2 = ResourceUtil.getFile(listPdf);
|
|
|
+ if (tabpdf2.exists()) {
|
|
|
+ tabpdf2.delete();
|
|
|
+ }
|
|
|
+ if (data.size() >= 1) {
|
|
|
+ //资料填报原始pdf合并
|
|
|
+ FileUtils.mergePdfPublicMethods(data, listPdf);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(agreementId + ".pdf", listPdf);
|
|
|
+ CompensationInfo info = new CompensationInfo();
|
|
|
+ info.setId(agreementId);
|
|
|
+ info.setMergePdfUrl(bladeFile.getLink());
|
|
|
+ this.updateById(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取单个PDF,传入映射表主键
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public R getBussPdfInfo(Long id) throws Exception {
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+
|
|
|
+ AgreementLinkTable linkTable = linkTableService.getById(id);
|
|
|
+
|
|
|
+ if (linkTable == null) {
|
|
|
+ return R.fail("未获取到该表单的信息");
|
|
|
+ }
|
|
|
+ if (linkTable.getHtmlUrl() == null) {
|
|
|
+ return R.fail("htmlUrl is null");
|
|
|
+ }
|
|
|
+
|
|
|
+ String pdfPath = file_path + "/pdf//" + id + ".pdf";
|
|
|
+ String excelPath = file_path + "/pdf//" + id + ".xlsx";
|
|
|
+
|
|
|
+ File tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
+ if (tabPdf.exists()) {
|
|
|
+ tabPdf.delete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取清表信息
|
|
|
+ ExcelTab excelTab = baseMapper.getExcelTab(linkTable.getExcelId());
|
|
|
+ if (excelTab == null) {
|
|
|
+ return R.fail("未获取到清表信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(id).getData();
|
|
|
+
|
|
|
+ //获取excel流 和 html流
|
|
|
+ InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
|
|
|
+
|
|
|
+ Workbook workbook=null;
|
|
|
+ int index = excelTab.getFileUrl().lastIndexOf(".");
|
|
|
+ String suffix = excelTab.getFileUrl().substring(index);
|
|
|
+
|
|
|
+ if (".xls".equals(suffix)) {
|
|
|
+ workbook = new HSSFWorkbook(exceInp);
|
|
|
+ } else if (".xlsx".equals(suffix)) {
|
|
|
+ workbook = new XSSFWorkbook(exceInp);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取工作表
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
+
|
|
|
+ //标题添加
|
|
|
+ ProjectInfo projectInfo = baseMapper.getProjectInfo(linkTable.getProjectId());
|
|
|
+
|
|
|
+ int all = 0;
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ CellRangeAddress mergedCell = sheet.getMergedRegion(i);
|
|
|
+ int xx = mergedCell.getNumberOfCells();
|
|
|
+ if (xx >= all) {
|
|
|
+ all = xx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ CellRangeAddress mergedCell = sheet.getMergedRegion(i);
|
|
|
+ int xx = mergedCell.getNumberOfCells() + 2;
|
|
|
+ if (xx >= all) {
|
|
|
+ int fisRow = mergedCell.getFirstRow();
|
|
|
+ int firsrCol = mergedCell.getFirstColumn();
|
|
|
+
|
|
|
+ Cell cell = sheet.getRow(fisRow).getCell(firsrCol);
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+
|
|
|
+ Font oldfontAt = workbook.getFontAt(fontIndex);
|
|
|
+
|
|
|
+ Font redFont = workbook.createFont();
|
|
|
+ redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
|
|
|
+ redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
|
+
|
|
|
+ CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
+ newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
+ if (StringUtils.isEmpty(cell.getStringCellValue()) && fisRow <= 8) {
|
|
|
+
|
|
|
+ String title = projectInfo.getProjectName();
|
|
|
+ if (title.length() >= 30) {
|
|
|
+ sheet.getRow(fisRow).setHeight((short) 900);
|
|
|
+ newStyle.setWrapText(true);
|
|
|
+ }
|
|
|
+ redFont.setBold(true);
|
|
|
+ newStyle.setFont(redFont);
|
|
|
+ cell.setCellStyle(newStyle);
|
|
|
+ cell.setCellValue(title);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据不为空
|
|
|
+ if (StringUtils.isNotEmpty(linkTable.getHtmlUrl())) {
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(linkTable.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(inputStreamByUrl);
|
|
|
+
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+ if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
|
+ for (String val : DataInfo.keySet()) {
|
|
|
+ Elements datas = doc.getElementsByAttributeValue("keyname", val);
|
|
|
+ Element data = null;
|
|
|
+ if (datas.size() >= 1) {
|
|
|
+ data = datas.get(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data != null) {
|
|
|
+ if (data.hasAttr("x1") && data.hasAttr("y1")) {
|
|
|
+ int x1 = 0;
|
|
|
+ int x2 = 0;
|
|
|
+ int y1 = 0;
|
|
|
+ int y2 = 0;
|
|
|
+
|
|
|
+ x1 = Integer.parseInt(data.attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.attr("y1"));
|
|
|
+
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ String myData = DataInfo.get(val) + "";
|
|
|
+ if ((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 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日");
|
|
|
+
|
|
|
+ if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+
|
|
|
+ myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+ Date Start_dataStr = new Date();
|
|
|
+ Date end_dataStr = new Date();
|
|
|
+ try {
|
|
|
+ if(myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0){
|
|
|
+ Start_dataStr = sdf.parse(dataVal[0]);
|
|
|
+ end_dataStr = sdf.parse(dataVal[1]);
|
|
|
+ }else{
|
|
|
+ Start_dataStr = formatStr.parse(dataVal[0]);
|
|
|
+ end_dataStr = formatStr.parse(dataVal[1]);
|
|
|
+ }
|
|
|
+ }catch (ParseException e){
|
|
|
+ throw new ServiceException("日期绑定错误");
|
|
|
+ }
|
|
|
+ String StartDate = formatStr.format(Start_dataStr);
|
|
|
+ String endDate = formatStr.format(end_dataStr);
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] dataStr = myData.split("T")[0].split("-");
|
|
|
+ if (dataStr.length == 3) {
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (myData.indexOf("lang.String") >= 0) {
|
|
|
+ Object obj = DataInfo.get(val);
|
|
|
+ if (obj instanceof String[]) {
|
|
|
+ String[] dataDate = (String[]) obj;
|
|
|
+ if ((dataDate[0].trim()).equals((dataDate[1].trim()))) {
|
|
|
+ myData = dataDate[0];
|
|
|
+ } else {
|
|
|
+ myData = dataDate[0] + "-" + dataDate[1].trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.tagName().equals("hc-form-checkbox-group")) {
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ String exceVal = cell.getStringCellValue().replaceAll(" ", "");
|
|
|
+ //如果有□ 代表 自动生成 如果没有 代表后期添加 需要显示html 中的值
|
|
|
+ if (exceVal.indexOf("□") >= 0) {
|
|
|
+ if (myData.equals("1")) {
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
+ cell.setCellValue(exceVal.replace("□", "\u2611"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String dataJson = data.attr(":objs");
|
|
|
+ if (StringUtils.isNotEmpty(dataJson)) {
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(dataJson);
|
|
|
+ List<Integer> idList = Func.toIntList(myData);
|
|
|
+ int indexx = 0;
|
|
|
+ if (idList.get(0) >= 1) {
|
|
|
+ indexx = idList.get(0) - 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ String dataInfo = jsonArray.getJSONObject(indexx).getString("name");
|
|
|
+ for (int inx = 1; inx < idList.size(); inx++) {
|
|
|
+ int valIndex = idList.get(inx) - 1;
|
|
|
+ dataInfo = dataInfo + "," + jsonArray.getJSONObject(valIndex).getString("name");
|
|
|
+ }
|
|
|
+ cell.setCellValue(dataInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
+ cell.setCellValue(myData);
|
|
|
+ }
|
|
|
+ boolean wrap = Optional.ofNullable(cell).map(Cell::getCellStyle).map(CellStyle::getWrapText).orElse(true);
|
|
|
+ if (!wrap) {
|
|
|
+ cell.getCellStyle().setShrinkToFit(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //输出流
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
+ workbook.write(outputStream);
|
|
|
+ FileUtils.excelToPdf(excelPath,pdfPath);
|
|
|
+
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(id + ".pdf", pdfPath);
|
|
|
+
|
|
|
+ UpdateWrapper<AgreementLinkTable> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.eq("id", id);
|
|
|
+ updateWrapper.set("pdf_url", bladeFile.getLink());
|
|
|
+ linkTableService.update(updateWrapper);
|
|
|
+
|
|
|
+ //关闭流
|
|
|
+ IoUtil.closeQuietly(outputStream);
|
|
|
+ IoUtil.closeQuietly(exceInp);
|
|
|
+
|
|
|
+ return R.data(bladeFile.getLink());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|