Procházet zdrojové kódy

计量系统万盛系统专用

DengLinLang před 1 týdnem
rodič
revize
51b748e5c5

+ 4 - 0
blade-service/blade-manager/pom.xml

@@ -199,6 +199,10 @@
             <version>2.0.24</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+        </dependency>
 
     </dependencies>
     <build>

+ 74 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -16,7 +16,9 @@ import com.mixsmart.utils.FormulaUtils;
 import com.mixsmart.utils.RegexUtils;
 import com.mixsmart.utils.StringUtils;
 import lombok.RequiredArgsConstructor;
+import org.apache.poi.hssf.util.CellReference;
 import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.util.IOUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -44,19 +46,22 @@ import org.springblade.manager.utils.FileUtils;
 import org.springblade.manager.vo.*;
 import org.springblade.meter.entity.InterimPayCertificateItem;
 import org.springblade.meter.feign.CertificateItemClient;
+import org.springblade.resource.feign.CommonFileClient;
 import org.springblade.resource.feign.NewIOSSClient;
+import org.springblade.resource.vo.NewBladeFile;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.constraints.NotNull;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
+import java.io.*;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -109,7 +114,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         private final WbsTreeContractMapper wbsTreeContractMapper;
         private final IFormulaDao formulaDao;
         private final CertificateItemClient certificateItemClient;
-    private final NewIOSSClient newIOSSClient;
+        private final NewIOSSClient newIOSSClient;
+        private final CommonFileClient commonFileClient;
         @Lazy
         @Autowired
         private IExcelTabService excelTabService;
@@ -339,7 +345,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                     });
                     if (itemsMap.size() > 0) {
                         /*表内用同行匹配*/
-                       List<FormData> primary = tec.getFormDataMap().values().stream().filter(FormData::getIsCurrentNodeElement).filter(v -> v.getEName().contains("率") || v.getEName().contains("判")).collect(Collectors.toList());
+                        List<FormData> primary = tec.getFormDataMap().values().stream().filter(FormData::getIsCurrentNodeElement).filter(v -> v.getEName().contains("率") || v.getEName().contains("判")).collect(Collectors.toList());
                         itemsMap.values().forEach(i -> {
                             FormData vf = i.getValue();
                             primary.stream().filter(p -> vf.getMaxRow().equals(p.getMaxRow()) && vf.getTableName().equals(p.getTableName())).forEach(t -> {
@@ -1517,7 +1523,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                     /*处理脚本*/
                     e.getFormula().setFormula(e.getFormula().getNumber());
                 });
-                tec.summary.forEach(e->{
+                tec.summary.forEach(e -> {
                     /*执行公式*/
                     Object data = Expression.parse(e.getFormula().getFormula()).calculate(tec.constantMap);
                     if(data!=null){
@@ -2141,11 +2147,73 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 
     @Override
     public List<ReportResult> execute4(Long contractId, Long periodId, Integer type) {
-
+        //中间支付审核表
+        String url = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/ea6c945827dd2990a9c7b1957fe201c4.XLSX";
+        //获取中间支付审核表的pdfurl
+        ReportResult intermediatePaymentPDF = getIntermediatePaymentPDF(url);
         return null;
     }
 
 
+    /**
+     * 中间支付审核表获取PDFurl
+     *
+     * @param url
+     * @return
+     */
+    public ReportResult getIntermediatePaymentPDF(String url) {
+        InputStream modInput = null;
+        FileInputStream excelFileInput = null;
+        FileOutputStream outputStream = null;
+        Workbook workbook = null;
+        MultipartFile files = null;
+        try {
+            modInput = CommonUtil.getOSSInputStream(url);
+            workbook = WorkbookFactory.create(modInput);
+            Sheet sheet = workbook.getSheetAt(0);
+            //根据坐标获取单元格
+            Cell c5 = getCellByAddress(sheet, "C5");
+            c5.setCellValue("大笨熊二号");
+            String file_path = FileUtils.getSysLocalFileUrl();
+            //String file_path = "C://upload1//";
+            String locationFile = file_path + SnowFlakeUtil.getId() + ".xlsx";
+            outputStream = new FileOutputStream(locationFile);
+            //生成一份新的excel
+            workbook.write(outputStream);
+            //将excel转PDF
+            File excelFile = new File(locationFile);
+            excelFileInput = new FileInputStream(excelFile);
+            files = new MockMultipartFile("file", excelFile.getName(), "text/plain", IOUtils.toByteArray(excelFileInput));
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        NewBladeFile bladeFile = this.commonFileClient.excelToPdf(files);
+        ReportResult reportResult = new ReportResult();
+        CompletableFuture<String> stringCompletableFuture = new CompletableFuture<>();
+        stringCompletableFuture.complete(bladeFile.getLink());
+        reportResult.setPdfOssPath(stringCompletableFuture);
+        return reportResult;
+
+    }
+    //根据单元格地址获取单元格对象
+    private static Cell getCellByAddress(Sheet sheet, String cellAddress) {
+        CellReference cellRef = new CellReference(cellAddress);
+        int rowIndex = cellRef.getRow();
+        int columnIndex = cellRef.getCol();
+
+        Row row = sheet.getRow(rowIndex);
+        if (row == null) {
+            return null; // 行不存在
+        }
+
+        Cell cell = row.getCell(columnIndex);
+        if (cell == null) {
+            return null; // 单元格不存在
+        }
+
+        return cell;
+    }
+
     public void updateRecord(Long id, Map<String, Object> fieldValues,String tableName) {
         StringBuilder sqlBuilder = new StringBuilder("UPDATE "+tableName+" SET ");
         StringBuilder paramsBuilder = new StringBuilder();