chenr 1 hete
szülő
commit
4233a556b6

+ 1 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/FormulaClient.java

@@ -38,5 +38,5 @@ public interface FormulaClient {
 
     //万盛计量专用
     @PostMapping(API_PREFIX + "execute4")
-    List<ReportResult> formulaExecute4(@RequestParam Long contractId, @RequestParam Long periodId,@RequestParam Integer type);
+    List<ReportResult> formulaExecute4(@RequestParam Long contractId, @RequestParam Long periodId,@RequestParam Integer type,@RequestParam Long projectId);
 }

+ 25 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/feign/MiddleMeterApplyClient.java

@@ -0,0 +1,25 @@
+package org.springblade.meter.feign;
+
+import org.springblade.common.constant.LauncherConstant;
+import org.springblade.meter.entity.MiddleMeterApply;
+import org.springblade.meter.vo.MeterInventoryDetailVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.List;
+
+@FeignClient(value = LauncherConstant.APPLICATION_METER_NAME)
+public interface MiddleMeterApplyClient {
+    /**
+     * 接口前缀
+     */
+    String API_PREFIX = "/MiddleMeterApply";
+
+    /**
+     * 保存中期证书项目详情
+     */
+    @PostMapping(API_PREFIX + "/formDetail")
+    List<MeterInventoryDetailVO> formDetail(@RequestBody MiddleMeterApply middleMeterApply);
+
+}

+ 3 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/MeterInventoryDetailVO.java

@@ -39,6 +39,9 @@ public class MeterInventoryDetailVO {
     @ApiModelProperty(value = "清单名称")
     private String formName;
 
+    @ApiModelProperty(value = "单位")
+    private String unit;
+
     @ApiModelProperty(value = "单价")
     private BigDecimal currentPrice;
 

+ 36 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/MeterInventoryVO1.java

@@ -0,0 +1,36 @@
+package org.springblade.meter.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 清单支付报表对象
+ */
+@Data
+public class MeterInventoryVO1 {
+    @ApiModelProperty(value = "id")
+    private Long id;
+
+    @ApiModelProperty(value = "清单编号")
+    private String formNumber;
+
+    @ApiModelProperty(value = "清单名称")
+    private String formName;
+
+    @ApiModelProperty(value = "单位")
+    private String unit;
+
+    @ApiModelProperty(value = "原合同工程量")
+    private BigDecimal currentTotal;
+
+    @ApiModelProperty(value = "原合同单价")
+    private BigDecimal currentMeterPrice;
+
+    @ApiModelProperty(value = "原合同金额")
+    private BigDecimal currentMeterMoney;
+
+    private BigDecimal
+
+}

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/FormulaClientImpl.java

@@ -73,8 +73,8 @@ public class FormulaClientImpl implements FormulaClient {
     }
 
     @Override
-    public List<ReportResult> formulaExecute4(Long contractId, Long periodId, Integer type) {
-        return service.execute4(contractId,periodId,type);
+    public List<ReportResult> formulaExecute4(Long contractId, Long periodId, Integer type,Long projectId) {
+        return service.execute4(contractId,periodId,type,projectId);
     }
 
 

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IFormulaService.java

@@ -100,5 +100,5 @@ public interface IFormulaService extends BaseService<Formula> {
     R<Object> syncWorkDate(@NotNull(message = "节点ID不能为空") Long nodeId);
 
     /** 万盛计量专用统计数据*/
-    List<ReportResult> execute4(Long contractId, Long periodId, Integer type);
+    List<ReportResult> execute4(Long contractId, Long periodId, Integer type,Long projectId);
 }

+ 152 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -44,8 +44,14 @@ import org.springblade.manager.mapper.WbsTreePrivateMapper;
 import org.springblade.manager.service.*;
 import org.springblade.manager.utils.FileUtils;
 import org.springblade.manager.vo.*;
+import org.springblade.meter.entity.ContractMeterPeriod;
 import org.springblade.meter.entity.InterimPayCertificateItem;
+import org.springblade.meter.entity.MiddleMeterApply;
 import org.springblade.meter.feign.CertificateItemClient;
+import org.springblade.meter.feign.MiddleMeterApplyClient;
+import org.springblade.meter.vo.MeterInventoryDetailVO;
+import org.springblade.meter.vo.MeterInventoryVO;
+import org.springblade.meter.vo.MeterInventoryVO1;
 import org.springblade.resource.feign.CommonFileClient;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.resource.vo.NewBladeFile;
@@ -118,6 +124,9 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         private final CommonFileClient commonFileClient;
         @Lazy
         @Autowired
+        private final MiddleMeterApplyClient middleMeterApplyClient;
+        @Lazy
+        @Autowired
         private IExcelTabService excelTabService;
 
     @Override
@@ -2146,11 +2155,26 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     }
 
     @Override
-    public List<ReportResult> execute4(Long contractId, Long periodId, Integer type) {
+    public List<ReportResult> execute4(Long contractId, Long periodId, Integer type,Long projectId) {
+        //判断计算的是哪一期。
+        String sql="Select * from s_contract_meter_period where contract_id="+contractId+" and is_deleted=0"+" order by start_date";
+        List<ContractMeterPeriod> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ContractMeterPeriod.class));
         //中间支付审核表
-        String url = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/ea6c945827dd2990a9c7b1957fe201c4.XLSX";
+        String url1 = "https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/ea6c945827dd2990a9c7b1957fe201c4.XLSX";
+        //中间计量支付申请表
+        String url4="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240828/bff82dd0a1b7394f5fdab1322a3e6023.XLSX";
+        //工程支付月报
+        String url5="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20240903/c8a5b424eace6c26b2edf9b9b33f088a.XLSX";
+        //清单支付报表
+        String url6="https://blade-oss-chongqing.oss-cn-shenzhen.aliyuncs.com//upload/20241120/e168f024c8055362664a276ad3721cb7.XLSX";
         //获取中间支付审核表的pdfurl
-        ReportResult intermediatePaymentPDF = getIntermediatePaymentPDF(url);
+        //ReportResult intermediatePaymentPDF = getIntermediatePaymentPDF(url1);
+        //获取中间支付申请表pdfUrl
+        //ReportResult intermediateApplyPDF=getIntermediateApplyPDF(url4);
+        //获取工程支付月报pdfUrl
+        //ReportResult monthlyReportPDF=getMonthlyReportPDF(url5);
+        //获取清单支付报表PDF
+        ReportResult inventoryPayReportPDF=getInventoryPayReportPDF(url6,contractId,periodId,projectId,list);
         return null;
     }
 
@@ -2195,6 +2219,131 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         return reportResult;
 
     }
+
+    /**
+     * 中间支付申请表获取pdfUrl CR1
+     * @param url
+     * @return
+     */
+    public ReportResult getIntermediateApplyPDF(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;
+    }
+
+    /**
+     * 工程支付月报获取pdfUrl  CR2
+     * @param url
+     * @return
+     */
+    public ReportResult getMonthlyReportPDF(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;
+    }
+
+    /**
+     * 清单支付报表获取PDF CR3
+     * @param url
+     * @return
+     */
+    public ReportResult getInventoryPayReportPDF(String url,Long contractId, Long periodId, Long projectId,List<ContractMeterPeriod> list){
+        MiddleMeterApply middleMeterApply=new MiddleMeterApply();
+        middleMeterApply.setContractId(contractId);
+        middleMeterApply.setContractPeriodId(periodId);
+        middleMeterApply.setProjectId(projectId);
+        //本期清单明细
+        List<MeterInventoryDetailVO> formDetail=middleMeterApplyClient.formDetail(middleMeterApply);
+        //上期清单明细
+        List<MeterInventoryDetailVO> oldFormDetail=new ArrayList<>();
+        if(list.size()>0){
+          OptionalInt index=IntStream.range(0, list.size())
+                .filter(i -> list.get(i).getId().equals(periodId))
+                .findFirst();
+              //i大于0 说明需要计算上一期的
+            if(index.isPresent()){
+                int i = index.getAsInt();
+                if(i>0){
+                  MiddleMeterApply oldMiddleMeterApply=new MiddleMeterApply();
+                  oldMiddleMeterApply.setProjectId(projectId);
+                  oldMiddleMeterApply.setContractId(contractId);
+                  oldMiddleMeterApply.setContractPeriodId(periodId);
+                  oldFormDetail=middleMeterApplyClient.formDetail(oldMiddleMeterApply);
+                }
+            }
+        }
+        //上期且需要变化的清单明细
+        List<MeterInventoryDetailVO> changeFormDetail=new ArrayList<>();
+        if(oldFormDetail.size()>0){
+            for (MeterInventoryDetailVO vo : oldFormDetail) {
+                for (MeterInventoryDetailVO vo1 : formDetail) {
+                    if(vo.getFormNumber().equals(vo1.getFormNumber())){
+                        changeFormDetail.add(vo);
+                    }
+                }
+            }
+        }
+        //清单支付报表对象
+        MeterInventoryVO1  vo=new MeterInventoryVO1();
+        return null;
+    }
     //根据单元格地址获取单元格对象
     private static Cell getCellByAddress(Sheet sheet, String cellAddress) {
         CellReference cellRef = new CellReference(cellAddress);

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

@@ -3672,7 +3672,7 @@ public class TaskController extends BladeController {
         ExecutionTime executionTime = new ExecutionTime();
         List<ReportResult> reportResults;
         if(ObjectUtil.isNotEmpty(report.getProjectId())&&report.getProjectId().equals(1764484458576179201L)){
-             reportResults=formulaClient.formulaExecute4(report.getContractId(),report.getId(),report.getType());
+             reportResults=formulaClient.formulaExecute4(report.getContractId(),report.getPeriodId(),report.getType(),report.getProjectId());
         }else{
              reportResults = formulaClient.formulaExecute3(report.getContractId(), report.getId(), report.getType());
         executionTime.info("公式执行");

+ 21 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/feign/MiddleMeterApplyClientImpl.java

@@ -0,0 +1,21 @@
+package org.springblade.meter.feign;
+
+import lombok.AllArgsConstructor;
+import org.springblade.meter.entity.MiddleMeterApply;
+import org.springblade.meter.service.IMiddleMeterApplyService;
+import org.springblade.meter.vo.MeterInventoryDetailVO;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Collections;
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+public class MiddleMeterApplyClientImpl implements  MiddleMeterApplyClient{
+
+    private final IMiddleMeterApplyService middleMeterApplyService;
+    @Override
+    public List<MeterInventoryDetailVO> formDetail(MiddleMeterApply middleMeterApply) {
+        return middleMeterApplyService.formDetail(middleMeterApply);
+    }
+}

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/MiddleMeterApplyMapper.xml

@@ -150,7 +150,7 @@
 
     </select>
     <select id="meterPeriodAllForm" resultType="org.springblade.meter.vo.MeterInventoryDetailVO">
-        SELECT cif.id,ifa.meter_number,cif.form_number,cif.form_name,cif.current_price,cif.change_total,ifa.current_meter_total,ifa.current_meter_money,ifa.contract_form_id,
+        SELECT cif.id,ifa.meter_number,cif.form_number,cif.form_name,,cif.unit,cif.current_price,cif.change_total,ifa.current_meter_total,ifa.current_meter_money,ifa.contract_form_id,
                (select period_number from s_contract_meter_period cmp where cmp.id = ifa.contract_period_id) as meterPeriodName,
                 (select engineer_divide from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) as engineerDivide,
                CASE when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 0 then '未上报' when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 1 then '待审批' when (select approve_status from s_middle_meter_apply mma where mma.id = ifa.middle_meter_id) = 2 then '已审批'