|
@@ -8,11 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
-import com.itextpdf.html2pdf.ConverterProperties;
|
|
|
-import com.itextpdf.html2pdf.resolver.font.DefaultFontProvider;
|
|
|
-import com.itextpdf.io.font.FontProgram;
|
|
|
-import com.itextpdf.io.font.FontProgramFactory;
|
|
|
-import com.itextpdf.layout.font.FontProvider;
|
|
|
+
|
|
|
import com.spire.xls.*;
|
|
|
import com.spire.xls.core.spreadsheet.HTMLOptions;
|
|
|
import io.swagger.annotations.*;
|
|
@@ -1306,8 +1302,14 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
|
|
|
String tabName = wbsTreeContract.getInitTableName();
|
|
|
+
|
|
|
+ // 字段查询 并去掉公式字段
|
|
|
+
|
|
|
+ String colkeys = "SELECT GROUP_CONCAT(e_key) as colkeys from m_wbs_tree a ,m_wbs_form_element b WHERE a.init_table_name = '"+tabName+"' and a.id=b.f_id and b.id not in(SELECT element_id from m_formula c where c.is_deleted=0) ";
|
|
|
+ Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
|
|
|
+ colkeys = stringObjectMap.get("colkeys")+"";
|
|
|
// 复制表数据
|
|
|
- String querySql = "select * from " + tabName + " where p_key_id=" + pkeyId;
|
|
|
+ String querySql = "select "+colkeys+" from " + tabName + " where p_key_id=" + pkeyId;
|
|
|
Map<String, Object> dataMap2 = jdbcTemplate.queryForMap(querySql);
|
|
|
|
|
|
dataMap2.remove("p_key_id");
|
|
@@ -1459,26 +1461,6 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.status(this.excelTabService.removeBussTabInfoById(pkeyid));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置BaseFont
|
|
|
- *
|
|
|
- * @param fontPath 字体路径
|
|
|
- * @return
|
|
|
- */
|
|
|
- private static ConverterProperties creatBaseFont(String fontPath) {
|
|
|
- ConverterProperties properties = new ConverterProperties();
|
|
|
- FontProvider fontProvider = new DefaultFontProvider();
|
|
|
- FontProgram fontProgram;
|
|
|
- try {
|
|
|
- fontProgram = FontProgramFactory.createFont(fontPath);
|
|
|
- fontProvider.addFont(fontProgram);
|
|
|
- properties.setFontProvider(fontProvider);
|
|
|
- } catch (IOException e) {
|
|
|
- System.out.println("creat base font erro");
|
|
|
- }
|
|
|
- return properties;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
@PostMapping("/save_buss_data")
|
|
|
@ApiOperationSupport(order = 13)
|
|
@@ -2054,6 +2036,206 @@ public class ExcelTabController extends BladeController {
|
|
|
return R.data(300, null, "未找到对应的业务数据");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 预览首件PDF
|
|
|
+ */
|
|
|
+ @GetMapping("/get-first-pdf-info")
|
|
|
+ @ApiOperationSupport(order = 28)
|
|
|
+ @ApiOperation(value = "获取首件填报记录")
|
|
|
+ @ApiImplicitParam(name = "firstId", value = "首件列表ID")
|
|
|
+ public R<String> getFirstPdfInfo(String firstId) {
|
|
|
+ if (StringUtils.isNotEmpty(firstId)) {
|
|
|
+ //PDF路径集合
|
|
|
+ List<String> pdfUrls = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取配置的路径
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ //获取数据
|
|
|
+ JSONObject firstJson = this.informationQueryClient.queryFirstBusinessDataByFirstId(firstId);
|
|
|
+ if (firstJson != null) {
|
|
|
+ if (StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) || StringUtils.isNotEmpty(firstJson.getString("pdfUrl"))) {
|
|
|
+ pdfUrls.add(StringUtils.isNotEmpty(firstJson.getString("eVisaPdfUrl")) ? firstJson.getString("eVisaPdfUrl") : firstJson.getString("pdfUrl"));
|
|
|
+ } else {
|
|
|
+ //没有生成拼接的记录,生成
|
|
|
+ //获取html
|
|
|
+ WbsTreeContract tableNode = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, firstJson.getString("tableId")));
|
|
|
+
|
|
|
+ if (tableNode == null) {
|
|
|
+ return R.fail("该数据下无此节点!");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(tableNode.getHtmlUrl())) {
|
|
|
+ return R.fail("请关联清表!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取清表信息
|
|
|
+ ExcelTab excelTab = excelTabService.getById(tableNode.getExcelId());
|
|
|
+ if (excelTab == null) {
|
|
|
+ return R.fail("失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, Object>> businessDataMapList = this.getFirstBusinessData(firstId).getData();
|
|
|
+
|
|
|
+ try {
|
|
|
+ //处理数据
|
|
|
+ for (Map<String, Object> dataMap : businessDataMapList) {
|
|
|
+ // 获取excel流 和 html流
|
|
|
+ Workbook wb = new Workbook();
|
|
|
+ wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
|
|
|
+ //获取工作表
|
|
|
+ Worksheet sheet = wb.getWorksheets().get(0);
|
|
|
+
|
|
|
+ // 数据不为空 &&
|
|
|
+ if (StringUtils.isNotEmpty(tableNode.getHtmlUrl())) {
|
|
|
+ File htmlFile = ResourceUtil.getFile(tableNode.getHtmlUrl());
|
|
|
+ if (htmlFile.exists()) {
|
|
|
+ String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Element table = doc.select("table").first();
|
|
|
+ Elements trs = table.select("tr");
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(dataMap)) {
|
|
|
+ for (String val : dataMap.keySet()) {
|
|
|
+ if (val.indexOf("__") >= 0) {
|
|
|
+ String DataVal[] = val.split("__");
|
|
|
+ String[] xy = DataVal[1].split("_");
|
|
|
+ Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
|
|
|
+
|
|
|
+ if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
+ int x1, y1;
|
|
|
+
|
|
|
+ if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
|
|
|
+ } else {
|
|
|
+ x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+ }
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+ String myData = dataMap.get(val) + "";
|
|
|
+ if (myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) {
|
|
|
+ if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+ myData = myData.replace("[", "").replace("]", "");
|
|
|
+ String[] dataVal = myData.split(",");
|
|
|
+ String Start_dataStr[] = dataVal[0].split("T")[0].split("-");
|
|
|
+ String StartDate = StringUtil.format("{}年{}月{}日", new Object[]{Start_dataStr[0], Start_dataStr[1], Integer.parseInt(Start_dataStr[2]) + 1});
|
|
|
+
|
|
|
+ String end_dataStr[] = dataVal[1].split("T")[0].split("-");
|
|
|
+ String endDate = StringUtil.format("{}年{}月{}日", new Object[]{end_dataStr[0], end_dataStr[1], Integer.parseInt(end_dataStr[2]) + 1});
|
|
|
+
|
|
|
+ if (StartDate.equals(endDate)) {
|
|
|
+ myData = StartDate;
|
|
|
+ } else {
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String dataStr[] = myData.split("T")[0].split("-");
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", new Object[]{dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (myData.indexOf("https") >= 0 && myData.indexOf("aliyuncs") >= 0) {
|
|
|
+ Element element = trs.get(y1).select("td").get(x1);
|
|
|
+ String styles[] = element.attr("style").split(";");
|
|
|
+ int Height = 0;
|
|
|
+ for (String sty : styles) {
|
|
|
+ if (sty.indexOf("height:") >= 0) {
|
|
|
+ Height = Integer.parseInt(sty.replace("height:", "").replace("px", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
|
|
|
+ ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
|
|
|
+ pic.setHeight(Height);
|
|
|
+ sheet.getCellRange(y1, x1).getStyle().setShrinkToFit(true);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+ cellRange.setText(myData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装电签设置
|
|
|
+ QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("type", 2);
|
|
|
+ queryWrapper.eq("tab_id", tableNode.getPKeyId());
|
|
|
+
|
|
|
+ final List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
|
|
|
+ if (textdictInfos != null && !textdictInfos.isEmpty()) {
|
|
|
+ textdictInfos.forEach(e -> {
|
|
|
+ String key = e.getColKey();
|
|
|
+ String keys[] = key.split("__");
|
|
|
+ String[] trtd = keys[1].split("_");
|
|
|
+ Element data = trs.get(Integer.parseInt(trtd[0])).select("td").get(Integer.parseInt(trtd[1]));
|
|
|
+ int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
|
|
|
+ if (x1 == 0) {
|
|
|
+ x1 = 1;
|
|
|
+ }
|
|
|
+ int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
|
|
|
+
|
|
|
+ final CellRange cellRange = sheet.getCellRange(y1, x1);
|
|
|
+
|
|
|
+ cellRange.setText(e.getId() + "");
|
|
|
+ cellRange.getCellStyle().getFont().setColor(Color.white);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Long fileName = SnowFlakeUtil.getId();
|
|
|
+ String onePdfPath = file_path + "/pdf//" + fileName + ".pdf";
|
|
|
+
|
|
|
+ sheet.saveToPdf(onePdfPath);
|
|
|
+
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(fileName + ".pdf", onePdfPath);
|
|
|
+
|
|
|
+ pdfUrls.add(bladeFile.getLink());
|
|
|
+
|
|
|
+ wb.dispose();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pdfUrls.size() > 0) {
|
|
|
+ try {
|
|
|
+ //关联的数据
|
|
|
+ if (StringUtils.isNotEmpty(firstJson.getString("linkMergePdfUrl"))) {
|
|
|
+ pdfUrls.add(firstJson.getString("linkMergePdfUrl"));
|
|
|
+ }
|
|
|
+ //总结报告,暂时无
|
|
|
+
|
|
|
+ //上传
|
|
|
+ String mergePdfPath = file_path + "/pdf//" + firstId + ".pdf";
|
|
|
+ File oldMergePdf = ResourceUtil.getFile(mergePdfPath);
|
|
|
+ if (oldMergePdf.exists()) {
|
|
|
+ oldMergePdf.delete();
|
|
|
+ }
|
|
|
+ //合并
|
|
|
+ FileUtils.mergePdfPublicMethods(pdfUrls, mergePdfPath);
|
|
|
+ //上传
|
|
|
+ BladeFile mergeFile = this.newIOSSClient.uploadFile(firstId + '-' + new Date().getTime() + ".pdf", mergePdfPath);
|
|
|
+
|
|
|
+ //返回
|
|
|
+ return R.data(mergeFile.getLink());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(300, null, "未找到数据");
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/save_log_first_buss_data")
|
|
|
@ApiOperationSupport(order = 29)
|
|
|
@ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存")
|
|
@@ -2118,16 +2300,44 @@ public class ExcelTabController extends BladeController {
|
|
|
|
|
|
public R getFirstExcelHtml() throws Exception {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
- String sql ="SELECT n.p_key_id,excelId from (SELECT p_key_id,(SELECT id from m_excel_tab x where x.alias like '%1542045893564796930%' and x.name =m.full_name) as excelId from m_wbs_tree_private m where m.project_id = '1578599210897772545' and m.type='2' and m.p_key_id!='1578599432939634723' ) n where excelId is not null ";
|
|
|
+ String sql ="SELECT n.p_key_id,excelId from (SELECT p_key_id,(SELECT id from m_excel_tab x where x.alias like '%1542045893564796930%' and parent_id='1559347745306148865' and is_deleted=0 and x.name =m.full_name) as excelId from m_wbs_tree_private m where m.project_id = '1578599210897772545' and m.type='2' ) n where excelId is not null and p_key_id!='1578599433161932807' ";
|
|
|
List<Map<String, Object>> dataInof = jdbcTemplate.queryForList(sql);
|
|
|
System.out.println(dataInof.size());
|
|
|
for (int i = 0; i < dataInof.size(); i++) {
|
|
|
String p_key_id = dataInof.get(i).get("p_key_id") + "";
|
|
|
Long excelId = Long.parseLong(dataInof.get(i).get("excelId") + "");
|
|
|
+ System.out.println(p_key_id+"__"+excelId);
|
|
|
this.saveLinkeTab(excelId, Long.valueOf(p_key_id));
|
|
|
+ // this.saveLinkeTab(, excelId);
|
|
|
System.out.println(i);
|
|
|
}
|
|
|
|
|
|
return R.data("");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单填写 图片添加 并压缩
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @SneakyThrows
|
|
|
+ @PostMapping("/add-buss-imginfo")
|
|
|
+ @ApiOperationSupport(order = 32)
|
|
|
+ @ApiOperation(value = "表单填写图片上传", notes = "表单填写图片上传")
|
|
|
+ public R addBussFile(@RequestParam MultipartFile file) {
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ BladeFile bladeFile=new BladeFile();
|
|
|
+ if(file.getSize()>=1024){
|
|
|
+ String filecode = SnowFlakeUtil.getId() + "";
|
|
|
+ String imgUrl = file_path+"/pdf/"+ filecode+".jpg";
|
|
|
+ FileUtils.CompressImage(imgUrl,file.getInputStream());
|
|
|
+ bladeFile= this.newIOSSClient.uploadFile(file.getOriginalFilename(),imgUrl);
|
|
|
+ File imgFile = ResourceUtil.getFile(imgUrl);
|
|
|
+ imgFile.delete();
|
|
|
+ }else{
|
|
|
+ bladeFile = this.newIOSSClient.uploadFileByInputStream(file);
|
|
|
+ }
|
|
|
+ return R.data(bladeFile);
|
|
|
+ }
|
|
|
+
|
|
|
}
|