chenr 7 months ago
parent
commit
87588369d2

+ 95 - 63
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -2237,64 +2237,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             return R.data("同步成功");
         }
     }
-   public void dianqian(String htmlUrl,Sheet sheet, Workbook workbook ) {
-       try {
-           InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(htmlUrl);
-//            InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1693464012966068224.html");
-           String htmlString = IoUtil.readToString(inputStreamByUrl);
-           Document doc = Jsoup.parse(htmlString);
-           Element table = doc.select("table").first();
-           // 组装电签设置
-           Elements dqids = table.getElementsByAttribute("dqid");
-           for (Element element : dqids) {
-               String dqid = element.attr("dqid");
-               Elements x11 = element.getElementsByAttribute("x1");
-               if (x11 != null && x11.size() >= 1) {
-                   Element element1 = x11.get(x11.size() - 1);
-                   int x1 = Func.toInt(element1.attr("x1"));
-                   int y1 = Func.toInt(element1.attr("y1"));
-                   Row row = sheet.getRow(y1 - 1);
-                   if (row != null) {
-                       Cell cell = row.getCell(x1 - 1);
-                       if (cell != null || Func.isNotEmpty(cell)) {
-//                           short fontIndex = cell.getCellStyle().getFontIndex();
-//                           Font oldfontAt = workbook.getFontAt(fontIndex);
-//                           Font redFont = workbook.createFont();
-//                           redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
-//                           redFont.setFontHeightInPoints(Short.valueOf("1"));//设置字体大小
-//                           redFont.setFontName(oldfontAt.getFontName());//设置字体
-//                           String CellValue = cell.getStringCellValue().trim();
-//                           CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
-//                           newStyle.cloneStyleFrom(cell.getCellStyle());
-//                           newStyle.setFont(redFont);
-//                           newStyle.setShrinkToFit(true);
-//                           cell.setCellStyle(newStyle);
-//                           String value=CellValue+dqid;
-//                           cell.setCellValue(value);
 
-                           // 获取单元格的现有值
-                           String existingValue = cell.getStringCellValue();
-                           // 创建一个新的副文本字符串
-                           RichTextString richTextString = workbook.getCreationHelper().createRichTextString(existingValue + dqid);
-                           // 设置原有部分的字体
-                           Font originalFont = workbook.createFont();
-                           originalFont.setColor(IndexedColors.BLACK.getIndex());
-                           richTextString.applyFont(0, existingValue.length(), originalFont);
-                           // 设置新增部分的字体
-                           Font newFont = workbook.createFont();
-                           newFont.setColor(IndexedColors.WHITE.getIndex());
-                           newFont.setFontHeightInPoints(Short.valueOf("1"));
-                           richTextString.applyFont(existingValue.length(), existingValue.length() + dqid.length(), newFont);
-                           // 将副文本字符串设置到单元格
-                           cell.setCellValue(richTextString);
-                       }
-                   }
-               }
-           }
-       } catch (Exception e) {
-
-       }
-   }
     @Override
     public List<ReportResult> execute4(Long reportId,Long contractId, Long periodId, Integer type,Long projectId) throws FileNotFoundException, IllegalAccessException {
         //获取当前合同段保证金比例
@@ -2378,7 +2321,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         ReportResult monthlyReportPDF=getMonthlyReportPDF(url5,reportId,contractId,periodId,projectId,list,redisId,htmlUrl5);
         monthlyReportPDF.setPkeyId(1816648920839749645L);
         //获取中间支付申请表pdfUrl
-        ReportResult intermediateApplyPDF=getIntermediateApplyPDF(url4,periodId,projectId,htmlUrl4,projectName);
+        ReportResult intermediateApplyPDF=getIntermediateApplyPDF(url4,periodId,projectId,htmlUrl4,projectName,contractId);
         intermediateApplyPDF.setPkeyId(1816648920839749644L);
         reportResults.add(CoverOfMidtermPaymentReportPDF);
         reportResults.add(intermediatePaymentPDF);
@@ -2449,8 +2392,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                 c10.setCellValue(contractInfo.getContractorUnitName());
             }
                dianqian(htmlUrl,sheet,workbook);
-
-
+               //dianqianTime(htmlUrl,sheet,workbook,1816648920839749640L,periodId,contractId);
             for (Sheet sheet1 : workbook) {
                 for (Row row : sheet1) {
                     // 遍历所有单元格
@@ -2462,7 +2404,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                     }
                 }
             }
-
             String file_path = FileUtils.getSysLocalFileUrl();
             String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
             outputStream = new FileOutputStream(locationFile);
@@ -2482,6 +2423,92 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         reportResult.setName("中期支付报表封面");
         return reportResult;
     }
+    public void dianqian(String htmlUrl,Sheet sheet, Workbook workbook ) {
+        try {
+            InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(htmlUrl);
+            String htmlString = IoUtil.readToString(inputStreamByUrl);
+            Document doc = Jsoup.parse(htmlString);
+            Element table = doc.select("table").first();
+            // 组装电签设置
+            Elements dqids = table.getElementsByAttribute("dqid");
+            for (Element element : dqids) {
+                String dqid = element.attr("dqid");
+                Elements x11 = element.getElementsByAttribute("x1");
+                if (x11 != null && x11.size() >= 1) {
+                    Element element1 = x11.get(x11.size() - 1);
+                    int x1 = Func.toInt(element1.attr("x1"));
+                    int y1 = Func.toInt(element1.attr("y1"));
+                    Row row = sheet.getRow(y1 - 1);
+                    if (row != null) {
+                        Cell cell = row.getCell(x1 - 1);
+                        if (cell != null || Func.isNotEmpty(cell)) {
+//                           short fontIndex = cell.getCellStyle().getFontIndex();
+//                           Font oldfontAt = workbook.getFontAt(fontIndex);
+//                           Font redFont = workbook.createFont();
+//                           redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
+//                           redFont.setFontHeightInPoints(Short.valueOf("1"));//设置字体大小
+//                           redFont.setFontName(oldfontAt.getFontName());//设置字体
+//                           String CellValue = cell.getStringCellValue().trim();
+//                           CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+//                           newStyle.cloneStyleFrom(cell.getCellStyle());
+//                           newStyle.setFont(redFont);
+//                           newStyle.setShrinkToFit(true);
+//                           cell.setCellStyle(newStyle);
+//                           String value=CellValue+dqid;
+//                           cell.setCellValue(value);
+
+                            // 获取单元格的现有值
+                            String existingValue = cell.getStringCellValue();
+                            if(StringUtils.isNotEmpty(existingValue)&&!existingValue.equals("")){
+                                existingValue=existingValue+"*";
+                            }
+                            // 创建一个新的副文本字符串
+                            RichTextString richTextString = workbook.getCreationHelper().createRichTextString(existingValue + dqid);
+                            // 设置原有部分的字体
+                            Font originalFont = workbook.createFont();
+                            originalFont.setColor(IndexedColors.BLACK.getIndex());
+                            richTextString.applyFont(0, existingValue.length(), originalFont);
+                            // 设置新增部分的字体
+                            Font newFont = workbook.createFont();
+                            newFont.setColor(IndexedColors.WHITE.getIndex());
+                            newFont.setFontHeightInPoints(Short.valueOf("1"));
+                            richTextString.applyFont(existingValue.length()-1, existingValue.length() + dqid.length(), newFont);
+                            // 将副文本字符串设置到单元格
+                            cell.setCellValue(richTextString);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+
+        }
+    }
+    private void dianqianTime(String htmlUrl, Sheet sheet, Workbook workbook,Long pkeyId,Long perId,Long contractId) {
+        String timeSql = "SELECT DISTINCT a.time_col_key,DATE_FORMAT(c.create_time, '%Y年%m月%d日') as create_time from m_textdict_info a ,m_project_assignment_user b,u_task_parallel c ,u_task d  where a.sig_role_id=b.role_id and b.user_id=c.task_user and c.process_instance_id=d.process_instance_id and  b.contract_id="+contractId+" and LENGTH(a.time_col_key)>=2 " +
+            "and d.form_data_id="+perId+" and a.tab_id="+pkeyId+"";
+        List<Map<String, Object>> maps = jdbcTemplate.queryForList(timeSql);
+        if(maps!=null && maps.size()>=1){
+            InputStream inputStreamByUrl = null;
+            try {
+                inputStreamByUrl = FileUtils.getInputStreamByUrl(htmlUrl);
+                String htmlString = IoUtil.readToString(inputStreamByUrl);
+                org.jsoup.nodes.Document doc = Jsoup.parse(htmlString);
+                Element table = doc.select("table").first();
+                for (Map<String, Object> da :maps){
+                    Elements elements = table.getElementsByAttributeValue("keyname", da.get("time_col_key")+"");
+                    for (Element element :elements){
+                        if(element.hasAttr("y1") && element.hasAttr("x1")){
+                            String keky = element.attr("y1")+"_"+element.attr("x1");
+                            String time = da.get("create_time")+"";
+
+                        }
+                    }
+                }
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
 
 
     private ContractInfo getContractInfo(Long contractId) {
@@ -2575,6 +2602,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             c3.setCellValue(projectName);
 
             dianqian(htmlUrl,sheet,workbook);
+            //dianqianTime(htmlUrl,sheet,workbook,1L,periodId,contractId);
             for (Sheet sheet1 : workbook) {
                 for (Row row : sheet1) {
                     // 遍历所有单元格
@@ -2881,6 +2909,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             Cell a2 = getCellByAddress(sheet, "A2");
             a2.setCellValue(projectName);
             dianqian(htmlUrl,sheet,workbook);
+            //dianqianTime(htmlUrl,sheet,workbook,1L,periodId,contractId);
             for (Sheet sheet1 : workbook) {
                 for (Row row : sheet1) {
                     // 遍历所有单元格
@@ -3171,6 +3200,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             Cell a1 = getCellByAddress(sheet, "A1");
             a1.setCellValue(projectName);
             dianqian(htmlUrl,sheet,workbook);
+            //dianqianTime(htmlUrl,sheet,workbook,1L,periodId,contractId);
             for (Sheet sheet1 : workbook) {
                 for (Row row : sheet1) {
                     // 遍历所有单元格
@@ -3311,7 +3341,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
      * @param url
      * @return
      */
-    public ReportResult getIntermediateApplyPDF(String url,Long periodId,Long projectId,String htmlUrl,String projectName){
+    public ReportResult getIntermediateApplyPDF(String url,Long periodId,Long projectId,String htmlUrl,String projectName,Long contractId){
 
         InputStream modInput = null;
         FileInputStream excelFileInput = null;
@@ -3323,6 +3353,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             workbook = WorkbookFactory.create(modInput);
             Sheet sheet = workbook.getSheetAt(0);
             dianqian(htmlUrl,sheet,workbook);
+            //dianqianTime(htmlUrl,sheet,workbook,1L,periodId,contractId);
             Cell c3=getCellByAddress(sheet,"C3");
             c3.setCellValue(projectName);
             Cell d5=getCellByAddress(sheet,"D5");
@@ -3832,6 +3863,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                 }
             }
             dianqian(htmlUrl,sheet,workbook);
+            //dianqianTime(htmlUrl,sheet,workbook,1L,periodId,contractId);
             String file_path = FileUtils.getSysLocalFileUrl();
             String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
             outputStream = new FileOutputStream(locationFile);
@@ -4223,7 +4255,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                                     l4.setCellValue(contractInfo.getSupervisionUnitName());
                                 }
                                   dianqian(htmlUrl,sheet,workbook);
-
+                                  //dianqianTime(htmlUrl,sheet,workbook,1L,periodId,contractId);
                         String file_path = FileUtils.getSysLocalFileUrl();
                         String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
                         outputStream = new FileOutputStream(locationFile);

+ 3 - 3
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/TaskController.java

@@ -3900,7 +3900,7 @@ public class TaskController extends BladeController {
     }
 
     /*中期支付证书报表、开工、材料手册报表*/
-    public R<String> generateReportsPdf(Report report, Integer taskType) throws FileNotFoundException, IllegalAccessException {
+    public R<String> generateReportsPdf(Report report, Integer taskType) throws FileNotFoundException, IllegalAccessException, ExecutionException, InterruptedException {
         /*报表记录新增或者重算的时候会调用当前方法,生成PDF*/
         /*保存两类PDF,一每种表独立一份用于浏览,二合成表用于电签*/
         /*数据完全独立互不影响,可以并发生成,预估PDF的总大小来决定是否全部在内存中生成PDF*/
@@ -3940,6 +3940,7 @@ public class TaskController extends BladeController {
             if (taskType != 10) {
                 addSignTaskBatch(report);
             }
+
             return R.data(rawPdfUrL);
         }else{
             reportResults = formulaClient.formulaExecute3(report.getContractId(), report.getId(), report.getType(),report.getPeriodId(),report.getProjectId());
@@ -4021,7 +4022,6 @@ public class TaskController extends BladeController {
                 StringBuffer sb = new StringBuffer();
                 reportResults.parallelStream().forEach(rs -> {
                     try {
-
                         byte[] excelByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(rs.getExcelUrl()));
                         PdfReader reader = null;
                         Document doc = new Document();
@@ -4051,7 +4051,7 @@ public class TaskController extends BladeController {
                                 Sheet sheet = workbook.getSheetAt(0);
                                 sheet.setForceFormulaRecalculation(true);
                                 // 添加签字时间
-                               /* dataMap = setDQTimeInfo(dataMap, rs.getPkeyId(), report.getContractId(), report.getPeriodId(), rs.getUrl());*/
+                               /*dataMap = setDQTimeInfo(dataMap, rs.getPkeyId(), report.getContractId(), report.getPeriodId(), rs.getUrl());*/
                                 if (Func.isNotEmpty(dataMap)) {
                                     for (String keys : dataMap.keySet()) {
                                         if(keys.indexOf(";")>=0 && keys.indexOf("_")>=0){