Pārlūkot izejas kodu

Merge branch 'master' of http://39.108.216.210:3000/zhuwei/bladex

huangtf 1 nedēļu atpakaļ
vecāks
revīzija
9310461530

+ 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>

+ 72 - 4
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;
@@ -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();

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

@@ -3670,8 +3670,8 @@ public class TaskController extends BladeController {
         /*分为新增和更新*/
         /*如果数据没有变化,则各表的PDF可以不用更新*/
         ExecutionTime executionTime = new ExecutionTime();
-        List<ReportResult> reportResults=new ArrayList<>();
-        if(ObjectUtil.isNotEmpty(report.getPeriodId())&&report.getProjectId().equals(1801141597643997184L)){
+        List<ReportResult> reportResults;
+        if(ObjectUtil.isNotEmpty(report.getProjectId())&&report.getProjectId().equals(1764484458576179201L)){
              reportResults=formulaClient.formulaExecute4(report.getContractId(),report.getId(),report.getType());
         }else{
              reportResults = formulaClient.formulaExecute3(report.getContractId(), report.getId(), report.getType());
@@ -4264,6 +4264,7 @@ public class TaskController extends BladeController {
         }
         report.setContractId(Long.parseLong(map.get("contract_id").toString()));
         report.setPeriodId(Long.parseLong(map.get("period_id").toString()));
+        report.setProjectId(Long.parseLong(map.get("project_id").toString()));
 
         return report;
     }