Эх сурвалжийг харах

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

huangtf 3 сар өмнө
parent
commit
e0a7026e22
26 өөрчлөгдсөн 504 нэмэгдсэн , 90 устгасан
  1. 6 0
      blade-common/pom.xml
  2. 18 0
      blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java
  3. 14 6
      blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java
  4. 13 1
      blade-ops/blade-resource/src/main/java/org/springblade/resource/feign/CommonFileClientImpl.java
  5. 25 1
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MaterialAdjust.java
  6. 9 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterPeriodInfo.java
  7. 9 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/StartPayForm.java
  8. 59 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterial.java
  9. 61 1
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjust.java
  10. 42 1
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjustDetail.java
  11. 11 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialPrice.java
  12. 1 1
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialValidity.java
  13. 34 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/InterimPayCertificateItem.java
  14. 11 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/InventoryFormMaterial.java
  15. 11 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialVO3.java
  16. 12 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/GetLinkAllFormVO.java
  17. 11 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/GetMaterialCurrentPriceVO.java
  18. 3 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/ImageClassificationFileController.java
  19. 25 34
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorFormat.java
  20. 4 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorInit.java
  21. 100 29
      blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java
  22. 5 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaDaoImpl.java
  23. 4 2
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.xml
  24. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialMapper.xml
  25. 14 4
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java
  26. 1 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialValidityServiceImpl.java

+ 6 - 0
blade-common/pom.xml

@@ -61,6 +61,12 @@
             <version>30.1.1-jre</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.sejda.imageio</groupId>
+            <artifactId>webp-imageio</artifactId>
+            <version>0.1.6</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 18 - 0
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -37,6 +37,7 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
 import com.drew.metadata.MetadataException;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 通用工具类
@@ -626,4 +627,21 @@ public class CommonUtil {
         return url;
     }
 
+    /**
+     *  webp文件转字节数组
+     * @param
+     * @return
+     */
+    public static byte[] webpToPngBytes(InputStream inputStream) {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try {
+            BufferedImage webpImage = ImageIO.read(inputStream);
+            ImageIO.write(webpImage,"png",bos);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return bos.toByteArray();
+    }
+
+
 }

+ 14 - 6
blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java

@@ -19,8 +19,10 @@ package org.springblade.resource.endpoint;
 import io.swagger.annotations.Api;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
+import org.apache.commons.lang.StringUtils;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.oss.model.OssFile;
 import org.springblade.core.secure.annotation.PreAuth;
@@ -43,6 +45,7 @@ import java.awt.*;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.security.SecureRandom;
 import java.text.DecimalFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -200,11 +203,7 @@ public class OssEndpoint {
      */
     @SneakyThrows
     @PostMapping("/upload-file")
-    public synchronized R<NewBladeFile> uploadFile(@RequestParam MultipartFile file) {
-        //上传原图
-        ByteArrayInputStream inputStream = new ByteArrayInputStream(file.getBytes());
-        BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), inputStream);
-
+    public  R<NewBladeFile> uploadFile(@RequestParam MultipartFile file) {
         //处理PDF文件
         NewBladeFile newBladeFile = new NewBladeFile();
         if (Objects.requireNonNull(file.getOriginalFilename()).contains("xlsx")) {
@@ -219,7 +218,16 @@ public class OssEndpoint {
         } else if (file.getOriginalFilename().contains("png") || file.getOriginalFilename().contains("jpg")) {
             newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
 
-        } else if (file.getOriginalFilename().contains("pdf") || file.getOriginalFilename().contains("PDF")) {
+        }else  if (file.getOriginalFilename().contains("pdf") || file.getOriginalFilename().contains("PDF")) {
+            newBladeFile.setPdfUrl("7");
+        }
+        if (newBladeFile == null || StringUtils.isBlank(newBladeFile.getPdfUrl())){
+            throw  new ServiceException("图片转换PDF失败");
+        }
+        //上传原图
+        ByteArrayInputStream inputStream = new ByteArrayInputStream(file.getBytes());
+        BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), inputStream);
+        if (file.getOriginalFilename().contains("pdf") || file.getOriginalFilename().contains("PDF")) {
             //获取PDF文件
             PDDocument document = PDDocument.load(file.getInputStream());
             //获取文件页数

+ 13 - 1
blade-ops/blade-resource/src/main/java/org/springblade/resource/feign/CommonFileClientImpl.java

@@ -4,6 +4,7 @@ import com.aspose.cells.SaveFormat;
 import com.aspose.words.DocumentBuilder;
 import com.itextpdf.text.Image;
 import com.itextpdf.text.Rectangle;
+import com.itextpdf.text.Utilities;
 import com.itextpdf.text.pdf.PdfWriter;
 import lombok.AllArgsConstructor;
 import org.apache.pdfbox.pdmodel.PDDocument;
@@ -18,6 +19,10 @@ import org.springblade.resource.vo.NewBladeFile;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.FileImageInputStream;
+import java.awt.image.BufferedImage;
 import java.io.*;
 import java.util.List;
 import java.util.Objects;
@@ -45,7 +50,12 @@ public class CommonFileClientImpl implements CommonFileClient {
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             PdfWriter.getInstance(document, bos);
             document.open();
-            Image image = Image.getInstance(this.InputStreamToBytes(file.getInputStream()));
+            byte[] bytes = IoUtil.readToByteArray(file.getInputStream());
+            if (bytes[0] == 82 && bytes[1] == 73 && bytes[2] == 70){
+                bytes = CommonUtil.webpToPngBytes(file.getInputStream());
+            }
+            Image image = Image.getInstance(bytes);
+
             // 设置页面宽高与图片一致
             document.setPageSize(new Rectangle(image.getScaledWidth(), image.getScaledHeight()));
             // 图片居中(感觉没啥用)
@@ -78,6 +88,8 @@ public class CommonFileClientImpl implements CommonFileClient {
         return newBladeFile;
     }
 
+
+
     /**
      * 获取字节数组
      */

+ 25 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MaterialAdjust.java

@@ -15,8 +15,32 @@ public class MaterialAdjust {
     private String materialName;
     /**调差金额*/
     private BigDecimal adjustMoney;
+    /**调差金额*/
+    private BigDecimal adjustTotal;
+    /**调差金额*/
+    private BigDecimal materialPrice;
+    /**调差金额*/
+    private BigDecimal currentPrice;
+    /**调差金额*/
+    private String unit;
     /**中期计量期Id*/
-    private Long       periodId;
+    private Long      periodId;
     /**计量期排序*/
     private Integer   sort;
+
+    public void setAdjustMoney(BigDecimal adjustMoney) {
+        this.adjustMoney = adjustMoney.stripTrailingZeros();
+    }
+
+    public void setAdjustTotal(BigDecimal adjustTotal) {
+        this.adjustTotal = adjustTotal.stripTrailingZeros();
+    }
+
+    public void setMaterialPrice(BigDecimal materialPrice) {
+        this.materialPrice = materialPrice.stripTrailingZeros();
+    }
+
+    public void setCurrentPrice(BigDecimal currentPrice) {
+        this.currentPrice = currentPrice.stripTrailingZeros();
+    }
 }

+ 9 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterPeriodInfo.java

@@ -88,6 +88,15 @@ public class MeterPeriodInfo implements  DataModel{
     /**动员预付关联*/
     private String materialIds;
 
+    /**计量期年*/
+    private Integer periodYear;
+    /**计量期月*/
+    private Integer periodMonth;
+
+    public  Integer getYearMonthInt(){
+        return this.periodYear*100+this.periodMonth;
+    }
+
     public String getStartDateStr() {
         return BaseUtils.toDateStr(startDate);
     }

+ 9 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/StartPayForm.java

@@ -1,6 +1,7 @@
 package org.springblade.manager.vo;
 
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
 import lombok.Data;
 
 import java.time.LocalDate;
@@ -32,4 +33,12 @@ public class StartPayForm {
     /**业务日期*/
     private LocalDate busDate;
 
+    /**计量期年*/
+    private Integer periodYear;
+    /**计量期月*/
+    private Integer periodMonth;
+
+    public  Integer getYearMonthInt(){
+        return this.periodYear*100+this.periodMonth;
+    }
 }

+ 59 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterial.java

@@ -90,4 +90,63 @@ public class ContractMaterial extends BaseEntity {
     @ApiModelProperty(value = "材料总和抵扣率")
     private BigDecimal deductionRatio;
 
+    public BigDecimal getPrice() {
+        if (price == null){
+            return null;
+        }else {
+            return new BigDecimal(price.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setPrice(BigDecimal price) {
+        this.price = new BigDecimal(price.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getWastageRatio() {
+        if (wastageRatio == null){
+            return null;
+        }else {
+            return new BigDecimal(wastageRatio.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setWastageRatio(BigDecimal wastageRatio) {
+        this.wastageRatio = new BigDecimal(wastageRatio.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getQuotaRatio() {
+        if (quotaRatio == null){
+            return null;
+        }else {
+            return new BigDecimal(quotaRatio.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setQuotaRatio(BigDecimal quotaRatio) {
+        this.quotaRatio = new BigDecimal(quotaRatio.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getOwnerRatio() {
+        if (ownerRatio == null){
+            return null;
+        }else {
+            return new BigDecimal(ownerRatio.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setOwnerRatio(BigDecimal ownerRatio) {
+        this.ownerRatio = new BigDecimal(ownerRatio.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getDeductionRatio() {
+        if (deductionRatio == null){
+            return null;
+        }else {
+            return new BigDecimal(deductionRatio.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setDeductionRatio(BigDecimal deductionRatio) {
+        this.deductionRatio = new BigDecimal(deductionRatio.stripTrailingZeros().toPlainString());
+    }
 }

+ 61 - 1
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjust.java

@@ -29,7 +29,7 @@ import java.time.LocalDate;
 import java.time.YearMonth;
 
 /**
- * 合同材料表实体类
+ * 合同材料调差表实体类
  *
  * @author BladeX
  * @since 2023-11-29
@@ -110,7 +110,67 @@ public class ContractMaterialAdjust extends BaseEntity {
     @ApiModelProperty(value = "调差计算式")
     private String adjustCalculation;
 
+    //因为计量期审批通过之后可以随意撤回,目前此字段毫无意义,审批状态取合同计量期实时状态
     @ApiModelProperty(value = "审批状态:0未完成1已完成(此处根据计量期状态)")
     private Integer approveStatus;
 
+    public BigDecimal getCurrentPrice() {
+        if (currentPrice == null){
+            return null;
+        }else {
+            return new BigDecimal(currentPrice.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setCurrentPrice(BigDecimal currentPrice) {
+        this.currentPrice = new BigDecimal(currentPrice.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getMaterialPrice() {
+        if (materialPrice == null){
+            return null;
+        }else {
+            return new BigDecimal(materialPrice.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setMaterialPrice(BigDecimal materialPrice) {
+        this.materialPrice = new BigDecimal(materialPrice.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getRangePriceRatio() {
+        if (rangePriceRatio == null){
+            return null;
+        }else {
+            return new BigDecimal(rangePriceRatio.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setRangePriceRatio(BigDecimal rangePriceRatio) {
+        this.rangePriceRatio = new BigDecimal(rangePriceRatio.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getAdjustTotal() {
+        if (adjustTotal == null){
+            return null;
+        }else {
+            return new BigDecimal(adjustTotal.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setAdjustTotal(BigDecimal adjustTotal) {
+        this.adjustTotal = new BigDecimal(adjustTotal.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getAdjustMoney() {
+        if (adjustMoney == null){
+            return null;
+        }else {
+            return new BigDecimal(adjustMoney.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setAdjustMoney(BigDecimal adjustMoney) {
+        this.adjustMoney =  new BigDecimal(adjustMoney.stripTrailingZeros().toPlainString());
+    }
 }

+ 42 - 1
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjustDetail.java

@@ -81,11 +81,52 @@ public class ContractMaterialAdjustDetail extends BaseEntity {
     @ApiModelProperty(value = "调差数量")
     private BigDecimal adjustTotal;
 
+    public BigDecimal getChangeTotal() {
+        if (changeTotal == null){
+            return null;
+        }else {
+            return new BigDecimal(changeTotal.stripTrailingZeros().toPlainString());
+        }
+
+    }
+
+    public void setChangeTotal(BigDecimal changeTotal) {
+        this.changeTotal = new BigDecimal(changeTotal.stripTrailingZeros().toPlainString());
+    }
+
+    public BigDecimal getAdjustFactor() {
+        if (adjustFactor == null){
+            return null;
+        }else {
+            return new BigDecimal(adjustFactor.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setAdjustFactor(BigDecimal adjustFactor) {
+        this.adjustFactor = new BigDecimal(adjustFactor.stripTrailingZeros().toPlainString());
+    }
+
     public BigDecimal getMeterTotal() {
-        return new BigDecimal(meterTotal.stripTrailingZeros().toPlainString());
+        if (meterTotal == null){
+            return null;
+        }else {
+            return new BigDecimal(meterTotal.stripTrailingZeros().toPlainString());
+        }
     }
 
     public void setMeterTotal(BigDecimal meterTotal) {
         this.meterTotal = new BigDecimal(meterTotal.stripTrailingZeros().toPlainString());
     }
+
+    public BigDecimal getAdjustTotal() {
+        if (adjustTotal == null){
+            return null;
+        }else {
+            return new BigDecimal(adjustTotal.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setAdjustTotal(BigDecimal adjustTotal) {
+        this.adjustTotal =  new BigDecimal(adjustTotal.stripTrailingZeros().toPlainString());
+    }
 }

+ 11 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialPrice.java

@@ -58,4 +58,15 @@ public class ContractMaterialPrice extends BaseEntity {
     @ApiModelProperty(value = "实时单价")
     private BigDecimal currentPrice;
 
+    public BigDecimal getCurrentPrice() {
+        if (currentPrice == null){
+            return null;
+        }else {
+            return new BigDecimal(currentPrice.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setCurrentPrice(BigDecimal currentPrice) {
+        this.currentPrice =  new BigDecimal(currentPrice.stripTrailingZeros().toPlainString());
+    }
 }

+ 1 - 1
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialValidity.java

@@ -26,7 +26,7 @@ import java.math.BigDecimal;
 import java.time.LocalDate;
 
 /**
- * 合同材料表实体类
+ * 材料价格有效期表实体类
  *
  * @author BladeX
  * @since 2023-11-29

+ 34 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/InterimPayCertificateItem.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import org.apache.commons.lang.StringUtils;
 import org.springblade.core.mp.base.BaseEntity;
 
 /**
@@ -46,4 +47,37 @@ public class InterimPayCertificateItem extends BaseEntity {
     private Integer noApply;
     @ApiModelProperty(value = "顺序")
     private Integer sort;
+
+    public void setContractAmount(String contractAmount) {
+        this.contractAmount = checked(contractAmount);
+    }
+
+    public void setRevisedTotal(String revisedTotal) {
+        this.revisedTotal = checked(revisedTotal);
+    }
+
+    public void setRevisedAmount(String revisedAmount) {
+        this.revisedAmount = checked(revisedAmount);
+    }
+
+    public void setCurrentPeriodEndPay(String currentPeriodEndPay) {
+        this.currentPeriodEndPay = checked(currentPeriodEndPay);
+    }
+
+    public void setPreviousPeriodEndPay(String previousPeriodEndPay) {
+        this.previousPeriodEndPay = checked(previousPeriodEndPay);
+    }
+
+    public void setCurrentPeriodPay(String currentPeriodPay) {
+        this.currentPeriodPay = checked(currentPeriodPay);
+    }
+
+    public String checked(String str){
+        if(str!=null){
+            if("0".equals(str)){
+                str="";
+            }
+        }
+        return str;
+    }
 }

+ 11 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/InventoryFormMaterial.java

@@ -58,4 +58,15 @@ public class InventoryFormMaterial extends BaseEntity {
     @ApiModelProperty(value = "调差系数")
     private BigDecimal adjustFactor;
 
+    public BigDecimal getAdjustFactor() {
+        if (adjustFactor == null){
+            return null;
+        }else {
+            return new BigDecimal(adjustFactor.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setAdjustFactor(BigDecimal adjustFactor) {
+        this.adjustFactor = new BigDecimal(adjustFactor.stripTrailingZeros().toPlainString());
+    }
 }

+ 11 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/ContractMaterialVO3.java

@@ -48,4 +48,15 @@ public class ContractMaterialVO3 {
 	@ApiModelProperty(value = "单价")
 	private BigDecimal price;
 
+	public BigDecimal getPrice() {
+		if (price == null){
+			return null;
+		}else {
+			return new BigDecimal(price.stripTrailingZeros().toPlainString());
+		}
+	}
+
+	public void setPrice(BigDecimal price) {
+		this.price = new BigDecimal(price.stripTrailingZeros().toPlainString());
+	}
 }

+ 12 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/GetLinkAllFormVO.java

@@ -31,4 +31,16 @@ public class GetLinkAllFormVO {
 
     @ApiModelProperty(value = "是否被引用0否1是,被引用后不允许取消")
     private Integer isQuote;
+
+    public BigDecimal getAdjustFactor() {
+        if (adjustFactor == null){
+            return null;
+        }else {
+            return new BigDecimal(adjustFactor.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setAdjustFactor(BigDecimal adjustFactor) {
+        this.adjustFactor = new BigDecimal(adjustFactor.stripTrailingZeros().toPlainString());
+    }
 }

+ 11 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/vo/GetMaterialCurrentPriceVO.java

@@ -41,4 +41,15 @@ public class GetMaterialCurrentPriceVO {
     @ApiModelProperty(value = "结束日期")
     private LocalDate endDate;
 
+    public BigDecimal getCurrentPrice() {
+        if (currentPrice == null){
+            return null;
+        }else {
+            return new BigDecimal(currentPrice.stripTrailingZeros().toPlainString());
+        }
+    }
+
+    public void setCurrentPrice(BigDecimal currentPrice) {
+        this.currentPrice = new BigDecimal(currentPrice.stripTrailingZeros().toPlainString());
+    }
 }

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/ImageClassificationFileController.java

@@ -232,6 +232,9 @@ public class ImageClassificationFileController extends BladeController {
 
                                                 //获取文件流
                                                 byte[] bytes = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(urls.get(i)));
+                                                if (bytes[0] == 82 && bytes[1] == 73 && bytes[2] == 70){
+                                                    bytes = CommonUtil.webpToPngBytes(CommonUtil.getOSSInputStream(urls.get(i)));
+                                                }
 
                                                 //压缩文件大小
                                                 byte[] byteNew = FileUtils.compressImage(bytes);

+ 25 - 34
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorFormat.java

@@ -12,6 +12,7 @@ import org.springblade.manager.entity.Formula;
 
 import java.util.*;
 import java.util.function.BiFunction;
+import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
@@ -26,6 +27,21 @@ public class ExecutorFormat extends FormulaExecutor {
     public ExecutorFormat(TableElementConverter tec) {
         super(tec);
     }
+    List<String> initTableNames = Arrays.asList("m_20240222101436_1760488226289614848");
+    List<String> elementCodes = Arrays.asList("排除的元素code");
+    private Predicate<FormData> zeroSkipPd=fd->{
+         for(String tn:initTableNames){
+             if(tn.equals(fd.getTableName())){
+                 return false;
+             }
+         }
+        for(String tn:elementCodes){
+            if(tn.equals(fd.getCode())){
+                return false;
+            }
+        }
+      return true;
+    };
 
     @Override
     public void handle() {
@@ -45,12 +61,13 @@ public class ExecutorFormat extends FormulaExecutor {
                     }
                 }
                 /*0不显示*/
-               fd.getValues().forEach(ed->{
-                   if(BaseUtils.isZero(ed.getValue())){
-                       ed.setValue(StringPool.EMPTY);
-                   }
-               });
-
+                if(zeroSkipPd.test(fd)) {
+                    fd.getValues().forEach(ed -> {
+                        if (BaseUtils.isZero(ed.getValue())) {
+                            ed.setValue(StringPool.EMPTY);
+                        }
+                    });
+                }
             }
         }
         /*合并单元格*/
@@ -60,6 +77,8 @@ public class ExecutorFormat extends FormulaExecutor {
     }
 
 
+
+
     private void  biColumnMerge(String col1, String col2, String tableName, BiFunction<ElementData,ElementData,String> coordsFc){
         FormulaUtils.beRelyFrom(tec.formDataMap,col1).findFirst().ifPresent(c1->{
             FormulaUtils.beRelyFrom(tec.formDataMap,col2).findFirst().ifPresent(c2->{
@@ -105,34 +124,6 @@ public class ExecutorFormat extends FormulaExecutor {
         /*2-17 小计合计*/
         biColumnMerge("MtAiv:key_1","MtAiv:key_2","m_20240222101754_1760489057181237248",coordsFc217);
 
-        /*FormData qdh= FormulaUtils.elementFindByCode(tec.formDataMap,"m_20240325154016_1772166597482381312:key_1").orElse(null);
-        FormData xm= FormulaUtils.elementFindByCode(tec.formDataMap,"m_20240325154016_1772166597482381312:key_13").orElse(null);
-        if(qdh!=null&&xm!=null){
-            List<ElementData> la = qdh.getValues();
-            List<ElementData> lb = xm.getValues();
-            if(la.size()>0&&lb.size()>0){
-               Set<String> mergeSet= IntStream.range(0, Math.min(la.size(),lb.size())).boxed().map(i->{
-                    ElementData ea=la.get(i);
-                    ElementData eb=lb.get(i);
-                    String a= ea.stringValue();
-                    *//*StringUtils.isNotEmpty(eb.getValue())&&eb.getValue().toString().contains("暂")*//*
-                    if(a!=null&&!a.matches("^\\d+.+")||StringUtils.isNotEmpty(eb.getValue())&&eb.getValue().toString().contains("暂")){
-                        if(StringUtils.isNotEmpty(eb.getValue())&&eb.getValue().toString().contains("暂")) {
-                            ea.setValue(eb.getValue());
-                            eb.setValue("");
-                        }
-                        return  ea.getIndex()+"@"+ea.getX()+"@"+ea.getY()+"@"+(eb.getX()+1)+"@"+eb.getY();
-                    }
-                    return StringPool.EMPTY;
-                }).filter(s->!StringPool.EMPTY.equals(s)).collect(Collectors.toSet());
-                if(mergeSet.size()>0){
-                    Set<String> set=tec.getMergeCellMaps().computeIfAbsent("m_20240325154016_1772166597482381312", k->new HashSet<>());
-                    set.addAll(mergeSet);
-                }
-            }
-        }*/
-
-
     }
 
 

+ 4 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorInit.java

@@ -86,11 +86,11 @@ public class ExecutorInit extends FormulaExecutor {
         //dataModel2FormData(baseInfo);
     }
     private MeterPeriodInfo addPeriodInfo(){
+        /*加载合同材料、材料清单*/
+        tec.meterInfo.setMaterialsAll(materialFormFc.apply(tec.getContractId()));
         if(MeterType.MATERIAL.equals(tec.getMeterType())||MeterType.START.equals(tec.getMeterType())||MeterType.START_JL.equals(tec.getMeterType())){
             /*加载计量期信息*/
             tec.periodInfo=meterPeriodFc.apply(tec.getReportId());
-            /*加载合同材料、材料清单*/
-            tec.meterInfo.setMaterialsAll(materialFormFc.apply(tec.getContractId()));
         }else if(MeterType.INTERIM.equals(tec.getMeterType())||MeterType.INTERIM_JL.equals(tec.getMeterType())){
             /*计量期*/
             periodInfo();;
@@ -217,15 +217,15 @@ public class ExecutorInit extends FormulaExecutor {
 
     private void materialAdjust(){
         List<MaterialAdjust> materialAdjustList = materialAdjustFc.apply(tec.getContractId());
+        LinkedHashMap<Integer,List<MaterialAdjust>>materialAdjustListMap = new LinkedHashMap<>();
         if(materialAdjustList.size()>0){
             LinkedHashMap<Integer,List<MaterialAdjust>> tmp = materialAdjustList.stream().collect(Collectors.groupingBy(MaterialAdjust::getSort,LinkedHashMap::new,Collectors.toList()));
             int sort = tec.periodInfo.getSort();
-            LinkedHashMap<Integer,List<MaterialAdjust>>materialAdjustListMap = new LinkedHashMap<>();
             materialAdjustListMap.put(MeterInfo.PRE,materialAdjustPick.apply(tmp,kv->kv.getKey()<sort));
             materialAdjustListMap.put(MeterInfo.CUR,materialAdjustPick.apply(tmp,kv->kv.getKey()==sort));
             materialAdjustListMap.put(MeterInfo.END,materialAdjustPick.apply(tmp,kv->kv.getKey()<=sort));
-            tec.meterInfo.setMaterialAdjustListMap(materialAdjustListMap);
         }
+        tec.meterInfo.setMaterialAdjustListMap(materialAdjustListMap);
     }
 
 

+ 100 - 29
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -232,6 +232,7 @@ public class ExecutorMeter extends FormulaExecutor {
             this.specialList.add(new MaterialSp());
             this.specialList.add(new MaterialsArrivalSp());
         }else if(MeterType.INTERIM.equals(tec.getMeterType())){
+            this.specialList.add(new MaterialInterimSp());
             /*材料*/
             this.specialList.add(new MaterialsArrivalSp());
             /*中期支付证书*/
@@ -466,7 +467,11 @@ public class ExecutorMeter extends FormulaExecutor {
         public void parse() {
             builderFormDatas(MaterialPriceDifferential.class);
             /*本期材料*/
-            materials=tec.meterInfo.getMaterialsAll().stream().filter(e->tec.getPeriodId().equals(e.getPeriodId())).collect(Collectors.toList());
+            if(MeterType.INTERIM.equals(tec.getMeterType())){
+                materials=tec.meterInfo.getMaterialsAll();
+            }else{
+                materials=tec.meterInfo.getMaterialsAll().stream().filter(e->tec.getPeriodId().equals(e.getPeriodId())).collect(Collectors.toList());
+            }
             if(materials.size()>0){
                 dataList.addAll(materials.stream().map(e->{
                     MaterialPriceDifferential mpd = new MaterialPriceDifferential();
@@ -480,7 +485,9 @@ public class ExecutorMeter extends FormulaExecutor {
                     mpd.setAmountBase(multiFc.apply(e.getPriceBase(),e.getMeterAmount()));
                     mpd.setPriceSpread(subtractFc.apply(mpd.getPrice(),mpd.getPriceBase()));
                     mpd.setTotal(subtractFc.apply(mpd.getAmount(),mpd.getAmountBase()));
-                    mpd.setCertificate(e.getCertificate());
+                    if(!MeterType.INTERIM.equals(tec.getMeterType())) {
+                        mpd.setCertificate(e.getCertificate());
+                    }
                     mpd.setMaterialArriveNumber(e.getMaterialArriveNumber());
                     return mpd;
                  }
@@ -496,6 +503,50 @@ public class ExecutorMeter extends FormulaExecutor {
     }
     @Data
     @EqualsAndHashCode(callSuper = true)
+    public  class MaterialInterimSp extends   BaseSpecial<MaterialPriceDifferential> implements Special{
+        /*永久性工程材料差价金额一览表*/
+        @Override
+        public boolean ready() {
+            return MeterInfo.MB_ZJ.equals(tec.getMeterInfo().getTemplate());
+        }
+
+        @Override
+        public void parse() {
+            builderFormDatas(MaterialPriceDifferential.class);
+            /*本期材料*/
+            List<MaterialAdjust> materialAdjustList=tec.meterInfo.getMaterialAdjustListMap().get(MeterInfo.CUR);
+            if(materialAdjustList!=null&&materialAdjustList.size()>0){
+                /*期号*/
+                String qh="";
+                if(tec.periodInfo.getPayNumber()!=null) {
+                   qh=tec.periodInfo.getPayNumber().split("-")[1];
+                }
+                for(MaterialAdjust mad:materialAdjustList){
+                    MaterialPriceDifferential mpd = new MaterialPriceDifferential();
+                    mpd.setPeriodNumber(qh);
+                    mpd.setName(mad.getMaterialName());
+                    mpd.setUnit(mad.getUnit());
+                    mpd.setQuantity(mad.getAdjustTotal().toPlainString());
+                    mpd.setPriceBase(mad.getMaterialPrice().toPlainString());
+                    mpd.setPrice(mad.getCurrentPrice().toPlainString());
+                    mpd.setAmount(StringUtils.number2String(multiFc.apply(mpd.getPrice(),mpd.getQuantity()),0));
+                    mpd.setAmountBase(StringUtils.number2String(multiFc.apply(mpd.getPriceBase(),mpd.getQuantity()),0));
+                    mpd.setPriceSpread(subtractFc.apply(mpd.getPrice(),mpd.getPriceBase()));
+                    mpd.setTotal(StringUtils.number2String(mad.getAdjustMoney().toPlainString(),0));
+                    mpd.setMaterialArriveNumber(tec.periodInfo.getPayNumber());
+                    dataList.add(mpd);
+                }
+            }
+            /*每页合计*/
+            FormulaUtils.elementFindByKey(fdm,"key_14").ifPresent(fd->{
+                List<  List<MaterialPriceDifferential> > list =BaseUtils.splitList(dataList,capacity);
+                elementWriter.write(fd,list.stream().map(l->l.stream().map(MaterialPriceDifferential::getTotal).mapToDouble(Double::parseDouble).sum()).collect(Collectors.toList()));
+            });
+            putOut(MaterialPriceDifferential.class);
+        }
+    }
+    @Data
+    @EqualsAndHashCode(callSuper = true)
     public  class SupervisionCertificateSp extends   BaseSpecial<SupervisionCertificate> implements Special{
 
         private final LinkedHashMap<String,String> itemNamesMap=new LinkedHashMap<>();
@@ -811,7 +862,7 @@ public class ExecutorMeter extends FormulaExecutor {
                    hj.setQuantity(v.stream().map(e->BaseUtils.str2BigDecimal(e.getQuantity())).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString());
                    hj.setAmount(v.stream().map(e->BaseUtils.str2BigDecimal(e.getAmount())).reduce(BigDecimal.ZERO,BigDecimal::add).toPlainString());
                    hj.setTotal(divideFc.apply(multiFc.apply(hj.getAmount(),ratio),"100"));
-                   materialSum=hj.getTotal();
+                   materialSum=StringUtils.number2String(hj.getTotal(),0);
                    tmp.add(hj);
                    dataList.addAll(tmp);
                });
@@ -1026,9 +1077,9 @@ public class ExecutorMeter extends FormulaExecutor {
                      /*材料调差*/
                      if(materialAdjustMap!=null) {
                          Function<Integer, String> countFc = category -> materialAdjustMap.get(category).stream().map(MaterialAdjust::getAdjustMoney).reduce(BigDecimal.ZERO, BigDecimal::add).toPlainString();
-                         jgtz.setPreviousPeriodEndPay(countFc.apply(MeterInfo.PRE));
-                         jgtz.setCurrentPeriodPay(countFc.apply(MeterInfo.CUR));
-                         jgtz.setCurrentPeriodEndPay(countFc.apply(MeterInfo.END));
+                         jgtz.setPreviousPeriodEndPay(StringUtils.number2String(countFc.apply(MeterInfo.PRE),0));
+                         jgtz.setCurrentPeriodPay(StringUtils.number2String(countFc.apply(MeterInfo.CUR),0));
+                         jgtz.setCurrentPeriodEndPay(StringUtils.number2String(countFc.apply(MeterInfo.END),0));
                      }
                      payItemZj.add(jgtz);
                      InterimPaymentCertificate hj = new InterimPaymentCertificate("合计",true);
@@ -1046,8 +1097,10 @@ public class ExecutorMeter extends FormulaExecutor {
                      InterimPaymentCertificate startPay =new InterimPaymentCertificate("动员预付款");
                      startPay.setContractAmount(StringUtils.handleNull(tec.meterInfo.getBaseInfo().getDyTotalAmount()));
                      if(tec.meterInfo.getStartPayFormAll()!=null){
+                         /*中期计量第一期之前的*/
                         List<StartPayForm> startPayForm = tec.getMeterInfo().getStartPayFormAll();
                         if(startPayForm.size()>0){
+                            InterimPayCertificateItem preStart = previousMap.get("动员预付款");
                             if(StringUtils.isNotEmpty(tec.getPeriodInfo().getStartIds())) {
                                 String[] startIds = tec.getPeriodInfo().getStartIds().split(",");
                                 if (Arrays.stream(startIds).anyMatch(BaseUtils::isNumber)) {
@@ -1061,19 +1114,26 @@ public class ExecutorMeter extends FormulaExecutor {
                                         return false;
                                     }).collect(Collectors.toList());
                                     if (Func.isNotEmpty(list)) {
-                                        StartPayForm relate = list.get(list.size() - 1);
-                                        BigDecimal pre = startPayForm.stream().filter(s -> s.getPeriodSort() <= relate.getPeriodSort()).map(s -> BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO, BigDecimal::add);
+                                        StartPayForm relate = list.get(0);
+                                       /* BigDecimal pre = startPayForm.stream().filter(s -> s.getPeriodSort() <relate.getPeriodSort()).map(s -> BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO, BigDecimal::add);*/
                                         BigDecimal cur = list.stream().map(s -> BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO, BigDecimal::add);
                                         startPay.setCurrentPeriodPay(cur.toPlainString());
-                                        startPay.setPreviousPeriodEndPay(pre.toPlainString());
+                                        if(preStart!=null) {
+                                            /*获取上期末支付*/
+                                            startPay.setPreviousPeriodEndPay(preStart.getPreviousPeriodEndPay());
+                                        }
                                         startPay.setCurrentPeriodEndPay(addFc.apply(startPay.getCurrentPeriodPay(), startPay.getPreviousPeriodEndPay()));
                                     }
                                 }
                             }else{
-                                InterimPayCertificateItem preStart = previousMap.get("动员预付款");
                                 if(preStart!=null) {
                                     startPay.setPreviousPeriodEndPay(preStart.getCurrentPeriodEndPay());
                                     startPay.setCurrentPeriodEndPay(preStart.getCurrentPeriodEndPay());
+                                }else{
+                                    /*不存在上期,则认为是第一期,需要根据计量期时间筛选*/
+                                    BigDecimal first = startPayForm.stream().filter(s->s.getYearMonthInt()<=tec.periodInfo.getYearMonthInt()).map(s -> BaseUtils.str2BigDecimal(s.getMeterMoney())).reduce(BigDecimal.ZERO, BigDecimal::add);
+                                    startPay.setPreviousPeriodEndPay(first.toPlainString());
+                                    startPay.setCurrentPeriodEndPay(first.toPlainString());
                                 }
                             }
                         }
@@ -1192,23 +1252,31 @@ public class ExecutorMeter extends FormulaExecutor {
                      /*分行合计列,合计的时候需要计入手填部分*/
                      fieldGetSet(x->!x.getIsSummary(),InterimPaymentCertificate::getInvertState);
                      InterimPaymentCertificate finalBlj = blj;
-                     dataList.stream().filter(e-> "计".equals(e.getChapterSeq())).findFirst().ifPresent(t->{
-                         finalBlj.setCurrentPeriodPay(multiFc.apply(t.getCurrentPeriodPay(),"0.1"));
+                     dataList.stream().filter(e-> "计".equals(e.getChapterSeq())).findFirst().ifPresent(t->{
+                         finalBlj.setCurrentPeriodPay(StringUtils.number2String(multiFc.apply(t.getCurrentPeriodPay(),"0.1"),0));
                          if(BaseUtils.obj2DoubleZero(t.getPreviousPeriodEndPay())>0) {
-                             finalBlj.setPreviousPeriodEndPay(multiFc.apply(t.getPreviousPeriodEndPay(), "0.1"));
+                             finalBlj.setPreviousPeriodEndPay(StringUtils.number2String(multiFc.apply(t.getPreviousPeriodEndPay(), "0.1"),0));
                          }
-                         finalBlj.setCurrentPeriodEndPay(multiFc.apply(t.getCurrentPeriodEndPay(),"0.1"));
+                         finalBlj.setCurrentPeriodEndPay(addFc.apply(finalBlj.getCurrentPeriodPay(),finalBlj.getPreviousPeriodEndPay()));
                          dataList.stream().filter(e-> "实际支付".equals(e.getChapterSeq())).findFirst().ifPresent(w->{
-                             w.setCurrentPeriodPay(subtractFc.apply(w.getCurrentPeriodPay(),finalBlj.getCurrentPeriodPay()));
+                             w.setCurrentPeriodPay(StringUtils.number2String(subtractFc.apply(w.getCurrentPeriodPay(),finalBlj.getCurrentPeriodPay()),0));
                              if(BaseUtils.obj2DoubleZero(t.getPreviousPeriodEndPay())>0) {
-                                 w.setPreviousPeriodEndPay(subtractFc.apply(w.getPreviousPeriodEndPay(), finalBlj.getPreviousPeriodEndPay()));
+                                 w.setPreviousPeriodEndPay(StringUtils.number2String(subtractFc.apply(w.getPreviousPeriodEndPay(), finalBlj.getPreviousPeriodEndPay()),0));
                              }
-                             w.setCurrentPeriodEndPay(subtractFc.apply(w.getCurrentPeriodEndPay(),finalBlj.getCurrentPeriodEndPay()));
+                             w.setCurrentPeriodEndPay(StringUtils.number2String(subtractFc.apply(w.getCurrentPeriodEndPay(),finalBlj.getCurrentPeriodEndPay()),0));
+                         });
+                         itemList.stream().filter(item->"保留金".equals(item.getChapterSeq())).findFirst().ifPresent(w->{
+                             w.setPreviousPeriodEndPay(finalBlj.getPreviousPeriodEndPay());
+                             w.setCurrentPeriodPay(finalBlj.getCurrentPeriodPay());
+                             w.setCurrentPeriodEndPay(finalBlj.getCurrentPeriodEndPay());
                          });
                      });
                      if(peerMap.size()>0) {
                          /*等合计项目计算完毕,再赋值*/
                          peerMap.forEach((sc, item) -> {
+                             if("合计".equals(item.getChapterSeq())){
+                                 item.setContractAmount(sc.getContractAmount());
+                             }
                              item.setPreviousPeriodEndPay(sc.getPreviousPeriodEndPay());
                              item.setCurrentPeriodPay(sc.getCurrentPeriodPay());
                              item.setCurrentPeriodEndPay(sc.getCurrentPeriodEndPay());
@@ -1217,6 +1285,9 @@ public class ExecutorMeter extends FormulaExecutor {
                      /*排序*/
                      List<String> indexSort =dataList.stream().map(InterimPaymentCertificate::getChapterSeq).collect(Collectors.toList());
                      itemList.forEach(e->{
+                         e.setContractAmount(StringUtils.number2String(e.getContractAmount(),0));
+                         e.setRevisedTotal(StringUtils.number2String(e.getRevisedTotal(),0));
+                         e.setRevisedAmount(StringUtils.number2String(e.getRevisedAmount(),0));
                          e.setCertificateId(tec.getReportId());
                          e.setSort(indexSort.indexOf(e.getChapterSeq()));
                      });
@@ -1385,7 +1456,7 @@ public class ExecutorMeter extends FormulaExecutor {
             /**变更数量*/
             private Integer changeTotal =0;
             /**完成数量*/
-            private Double completed=0D;
+            private BigDecimal completed=BigDecimal.ZERO;
             /**单价*/
             private String price;
 /*            本次完成数量
@@ -1410,7 +1481,7 @@ public class ExecutorMeter extends FormulaExecutor {
                     this.unit = p.getUnit();
                     this.contractTotal=p.getContractTotal();
                     this.changeTotal = p.getChangeTotal();
-                    this.completed =p.getCompleted();
+                    this.completed =BaseUtils.str2BigDecimal(p.getCompleted());
                     this.contractMoney =new BigDecimal(p.getContractMoney());
                     this.changeMoney =new BigDecimal(p.getChangeMoney());
                     this.money=p.getMoneyAsBigDecimal();
@@ -1423,7 +1494,7 @@ public class ExecutorMeter extends FormulaExecutor {
                     this.itemName=next.itemName;
                 }
                 /*本期完成*/
-                this.completed =next.completed+this.completed;;
+                this.completed =next.completed.add(this.completed);;
                 this.money=this.money.add(next.money);
                 return this;
             }
@@ -1432,7 +1503,7 @@ public class ExecutorMeter extends FormulaExecutor {
             public Summary merge(Summary previous){
                  if(previous!=null){
                      this.currentPeriodEndPay=this.money.add(previous.money);
-                     this.completed=this.completed+previous.completed;
+                     this.completed=this.completed.add(previous.completed);
                  }
                 return this;
             }
@@ -1478,12 +1549,12 @@ public class ExecutorMeter extends FormulaExecutor {
                 sis.setPrice(itf.getBidPrice());
                 if(cur!=null&&cur.getContractMoney()!=null) {
                     FormulaUtils.getScale(cur.getUnit()).ifPresent(scale->{
-                        cur.setCompleted(BaseUtils.str2BigDecimal(cur.getCompleted()).setScale(scale,RoundingMode.HALF_UP).doubleValue());
+                        cur.setCompleted(BaseUtils.str2BigDecimal(cur.getCompleted()).setScale(scale,RoundingMode.HALF_UP));
                         cur.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(cur.getPrice(),cur.getCompleted().toString())).setScale(0,RoundingMode.HALF_UP));
                         if (pre != null) {
-                            pre.setCompleted(BaseUtils.str2BigDecimal(pre.getCompleted()).setScale(scale,RoundingMode.HALF_UP).doubleValue());
+                            pre.setCompleted(BaseUtils.str2BigDecimal(pre.getCompleted()).setScale(scale,RoundingMode.HALF_UP));
                             pre.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(pre.getPrice(),pre.getCompleted().toString())).setScale(0,RoundingMode.HALF_UP));
-                            end.setCompleted(BaseUtils.str2BigDecimal(addFc.apply(cur.getCompleted().toString(),pre.getCompleted().toString())).setScale(scale,RoundingMode.HALF_UP).doubleValue());
+                            end.setCompleted(BaseUtils.str2BigDecimal(addFc.apply(cur.getCompleted().toString(),pre.getCompleted().toString())).setScale(scale,RoundingMode.HALF_UP));
                             end.setMoney(BaseUtils.str2BigDecimal(multiFc.apply(end.getPrice(),end.getCompleted().toString())).setScale(0,RoundingMode.HALF_UP));
                         }else {
                             end.setCompleted(cur.getCompleted());
@@ -1491,13 +1562,13 @@ public class ExecutorMeter extends FormulaExecutor {
                         }
                     });
                     sis.setCurrentPeriodPay(cur.getMoney().toPlainString());
-                    sis.setCurrentPeriodCompleted(cur.getCompleted().toString());
+                    sis.setCurrentPeriodCompleted(cur.getCompleted().toPlainString());
                     if (pre != null) {
-                        sis.setPreviousPeriodPay(pre.getMoney().toString());
-                        sis.setPreviousPeriodCompleted(pre.getCompleted().toString());
+                        sis.setPreviousPeriodPay(pre.getMoney().toPlainString());
+                        sis.setPreviousPeriodCompleted(pre.getCompleted().toPlainString());
                     }
-                    sis.setCompleted(end.getCompleted().toString());
-                    sis.setCurrentPeriodEndPay(end.getMoney().toString());
+                    sis.setCompleted(end.getCompleted().toPlainString());
+                    sis.setCurrentPeriodEndPay(end.getMoney().toPlainString());
                     sis.setPayRatio(ratioFc.apply(sis.getCurrentPeriodEndPay(), sis.getChangeMoney()));
                 }
                 totalList.add(sis);

+ 5 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaDaoImpl.java

@@ -134,7 +134,7 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long, List<StartPayForm>> getStayPayFormFc() {
         return  contractId->{
-            String sql="select  a.file_names file_name,a.calculate_formula,a.apply_cause,a.pay_date, a.meter_money meterMoney,a.business_date bus_date ,b.id meterPeriodId,b.sort periodSort from s_start_pay_meter_form a join s_meter_period b on a.meter_period_id =b.id  where  a.is_deleted =0  and a.contract_id="+contractId;
+            String sql="select  a.file_names file_name,a.calculate_formula,a.apply_cause,a.pay_date, a.meter_money meterMoney,a.business_date bus_date ,b.id meterPeriodId,b.sort periodSort ,b.period_year,b.period_month from s_start_pay_meter_form a join s_meter_period b on a.meter_period_id =b.id  where  a.is_deleted =0  and a.contract_id="+contractId;
             return getEntityList(sql,StartPayForm.class);
         };
     }
@@ -151,7 +151,7 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long, List<MeterPeriodInfo>> getInterimMeterPeriodAllFc() {
           return contractId->{
-            String sql="select a.id,a.pay_number,a.start_date,b.end_date, a.period_number periodNumber,a.sort ,b.print_date formPrintDate ,b.pay_money curTotal,b.id reportId,b.start_date,b.end_date,b.start_period_ids start_ids ,b.material_period_ids material_ids  from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and  b.is_deleted=0 and b.contract_id="+contractId+" order by a.sort";
+            String sql="select a.period_year ,a.period_month, a.id,a.pay_number,a.start_date,b.end_date, a.period_number periodNumber,a.sort ,b.print_date formPrintDate ,b.pay_money curTotal,b.id reportId,b.start_date,b.end_date,b.start_period_ids start_ids ,b.material_period_ids material_ids  from  s_contract_meter_period a join s_interim_pay_certificate b on a.id=b.contract_period_id where a.is_deleted=0 and  b.is_deleted=0 and b.contract_id="+contractId+" order by a.sort";
             return   getEntityList(sql,MeterPeriodInfo.class);
         };
     }
@@ -225,8 +225,9 @@ public class FormulaDaoImpl implements IFormulaDao {
     @Override
     public Function<Long, List<MaterialAdjust>> getMaterialAdjustFc() {
         return  contractId->{
-            String sql="select a.adjust_money,a.material_name,b.id periodId,b.sort from s_contract_material_adjust a join  s_contract_meter_period b on a.meter_period_id=  b.id  " +
-                    "where a.contract_id="+contractId+" and a.is_deleted=0";
+            String sql="select a.material_name ,a.material_price,a.current_price,a.adjust_money ,a.adjust_total,b.id periodId,b.sort,c.unit " +
+                    "from s_contract_material_adjust a join  s_contract_meter_period b on a.meter_period_id=  b.id  join s_contract_material c on a.contract_material_id =c.id  " +
+                    " where a.contract_id="+contractId+" and a.is_deleted=0";
             return getEntityList(sql,MaterialAdjust.class);
         };
     }

+ 4 - 2
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialAdjustMapper.xml

@@ -17,8 +17,10 @@
         </foreach>
     </select>
     <select id="page2" resultType="org.springblade.meter.vo.ContractMaterialAdjustVO">
-        select *,if(approve_status = 0,'未完成','已完成') as approveStatusName
-        from s_contract_material_adjust
+        select *,
+               (select approve_status from s_contract_meter_period scmp
+                        where scmp.id = scma.meter_period_id)as approveStatus
+        from s_contract_material_adjust scma
         where contract_id = #{dto.contractId} and is_deleted = 0
         <if test="dto.contractPeriodId != null and dto.contractPeriodId != ''">
             and contract_period_id = #{dto.contractPeriodId}

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

@@ -73,7 +73,7 @@
                         <if test="dto.id != null">
                             and cma.id != #{dto.id}
                         </if>
-                                                                                       )
+                        )
     </select>
 
 

+ 14 - 4
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java

@@ -188,6 +188,7 @@ public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractM
     }
 
     @Override
+    @Transactional
     public void delete(Long id) {
         //获取调差信息,判断是否已经审批
         ContractMaterialAdjust adjust = this.getById(id);
@@ -203,6 +204,8 @@ public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractM
             throw new ServiceException("删除失败,当前计量期不是未上报状态");
         }
         this.removeById(id);
+        adjustDetailService.remove(new LambdaQueryWrapper<ContractMaterialAdjustDetail>()
+                .eq(ContractMaterialAdjustDetail::getMaterialAdjustId,id));
 
     }
 
@@ -229,6 +232,7 @@ public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractM
      * 生成材料调差计算式
      */
     private void buildCalculation(ContractMaterialAdjustAddDTO dto,BigDecimal adjustTotal,ContractMaterialAdjust adjust){
+        adjust.setAdjustTotal(adjustTotal);
         //获取材料信息,用于调差范围
         ContractMaterial material= baseMapper.getMaterialInfo(dto.getContractMaterialId());
         if (material == null){
@@ -240,22 +244,28 @@ public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractM
         StringBuilder str = new StringBuilder("调差价格依据于:"+dto.getMaterialName()+
                 "("+validity.getStartDate().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+"至"+
                 validity.getEndDate().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+")\n");
+        /** 如果价差幅度小于调差限额,则调差金额为0*/
+        if (dto.getRangePriceRatio().abs().compareTo(material.getQuotaRatio()) < 0){
+            String st = "调差公式(标准):调差金额=0,"+dto.getRangePriceRatio()+"% <= ±"+material.getQuotaRatio()+"%";
+            adjust.setAdjustMoney(BigDecimal.ZERO);
+            adjust.setAdjustCalculation(st);
+            return ;
+        }
         BigDecimal adjustMoney = BigDecimal.ZERO;
         BigDecimal price = dto.getMaterialPrice();
         BigDecimal currentPrice = dto.getCurrentPrice();
         if (price.compareTo(currentPrice) == 1){
             //市场价低于基准价
             adjustMoney = adjustTotal.multiply(currentPrice.subtract((price.multiply(new BigDecimal(1).subtract(material.getQuotaRatio().multiply(new BigDecimal("0.01"))))))).multiply(new BigDecimal("1.09")).setScale(2, RoundingMode.HALF_UP);
-            str.append("调差公式(标准):调增金额=调差数量×[市场价-基准价×(1-风险幅度差%)]×(1+合同增值税税率)\n");
+            str.append("调差公式(标准)调增金额=调差数量×[市场价-基准价×(1-风险幅度差%)]×(1+合同增值税税率)\n");
             str.append("调差公式(计算):"+adjustMoney+"="+adjustTotal+"*["+currentPrice+"-"+price+"*(1-"+material.getQuotaRatio()+"%)]*(1+9.0/100)");
         }else {
             //市场价高于基准价
             adjustMoney = adjustTotal.multiply(currentPrice.subtract((price.multiply(new BigDecimal(1).add(material.getQuotaRatio().multiply(new BigDecimal("0.01"))))))).multiply(new BigDecimal("1.09")).setScale(2, RoundingMode.HALF_UP);
-            str.append("调差公式(标准):调增金额=调差数量×[市场价-基准价×(1+风险幅度差%)]×(1+合同增值税税率)\n");
+            str.append("调差公式(标准)调增金额=调差数量×[市场价-基准价×(1+风险幅度差%)]×(1+合同增值税税率)\n");
             str.append("调差公式(计算):"+adjustMoney+"="+adjustTotal+"*["+currentPrice+"-"+price+"*(1+"+material.getQuotaRatio()+"%)]*(1+9.0/100)");
         }
-        adjust.setAdjustMoney(adjustMoney);
-        adjust.setAdjustTotal(adjustTotal);
+        adjust.setAdjustMoney(adjustMoney.setScale(0,RoundingMode.HALF_UP));
         adjust.setAdjustCalculation(str.toString());
     }
 }

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialValidityServiceImpl.java

@@ -168,7 +168,7 @@ public class ContractMaterialValidityServiceImpl extends BaseServiceImpl<Contrac
         }
         Map<String, Object> map = new HashMap<>();
         BigDecimal decimal = currentPrice.subtract(price).multiply(new BigDecimal(100)).divide(price, 2, RoundingMode.DOWN);
-        map.put("rangePriceRatio",decimal);
+        map.put("rangePriceRatio",decimal.stripTrailingZeros().toPlainString());
         map.put("adjustCalculation",str.toString());
         if (decimal.compareTo(quotaRatio.negate()) == 1 && decimal.compareTo(quotaRatio) == -1){
             map.put("isAdjust",0);