Procházet zdrojové kódy

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

huangtf před 7 měsíci
rodič
revize
6c719c120f
13 změnil soubory, kde provedl 194 přidání a 8 odebrání
  1. 2 0
      blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java
  2. 26 0
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/ContractMaterialAdjustAddDTO.java
  3. 2 2
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/AttachmentForm.java
  4. 19 1
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjust.java
  5. 4 1
      blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/ContractMaterialAdjustDetail.java
  6. 12 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialAdjustController.java
  7. 11 1
      blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialValidityController.java
  8. 4 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.java
  9. 5 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.xml
  10. 2 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialAdjustService.java
  11. 3 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialValidityService.java
  12. 67 0
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java
  13. 37 3
      blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialValidityServiceImpl.java

+ 2 - 0
blade-gateway/src/main/java/org/springblade/gateway/provider/AuthProvider.java

@@ -60,6 +60,8 @@ public class AuthProvider {
         DEFAULT_SKIP_URL.add("/manager/check-upload");
         DEFAULT_SKIP_URL.add("/error/**");
         DEFAULT_SKIP_URL.add("/assets/**");
+        DEFAULT_SKIP_URL.add("/appVersion/page");
+        DEFAULT_SKIP_URL.add("/appVersionDetail/**");
     }
 
     /**

+ 26 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/ContractMaterialAdjustAddDTO.java

@@ -0,0 +1,26 @@
+package org.springblade.meter.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterialAdjust;
+import org.springblade.meter.entity.ContractMaterialAdjustDetail;
+
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/4/24 10:54
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ContractMaterialAdjustAddDTO extends ContractMaterialAdjust {
+
+    @ApiModelProperty(value = "材料明细集合")
+    private List<ContractMaterialAdjustDetail> details;
+
+    @ApiModelProperty(value = "附件集合")
+    private List<AttachmentForm> files;
+}

+ 2 - 2
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/entity/AttachmentForm.java

@@ -81,10 +81,10 @@ public class AttachmentForm extends BaseEntity {
     private Long selectId;
 
     @ApiModelProperty(value = "文件后缀")
-    private Long fileSuffix;
+    private String fileSuffix;
 
     @ApiModelProperty(value = "文件大小名称")
-    private Long fileSizeName;
+    private String fileSizeName;
 
 
 }

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

@@ -21,9 +21,12 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.core.mp.base.BaseEntity;
+import org.springframework.format.annotation.DateTimeFormat;
 
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.time.LocalDate;
+import java.time.YearMonth;
 
 /**
  * 合同材料表实体类
@@ -42,38 +45,53 @@ public class ContractMaterialAdjust extends BaseEntity {
      * 项目id
      */
     @ApiModelProperty(value = "项目id")
+    @NotNull(message = "请传入项目id!")
     private Long projectId;
     /**
      * 合同段id
      */
     @ApiModelProperty(value = "合同段id")
+    @NotNull(message = "请传入合同段id!")
     private Long contractId;
 
     @ApiModelProperty(value = "合同材料id")
+    @NotNull(message = "请传入合同材料id!")
     private Long contractMaterialId;
 
     @ApiModelProperty(value = "合同计量期id(调差期)")
+    @NotNull(message = "请传入调差期id!")
     private Long contractPeriodId;
 
     @ApiModelProperty(value = "调差月份")
-    private LocalDate adjustMonth;
+    @NotNull(message = "请填写调差月份!")
+    private String adjustMonth;
 
     @ApiModelProperty(value = "材料名称")
+    @NotNull(message = "请传入材料名称!")
     private String materialName;
 
     @ApiModelProperty(value = "材料基准价格")
+    @NotNull(message = "请传入材料基准价格!")
     private BigDecimal materialPrice;
 
+    @ApiModelProperty(value = "价格有效期id")
+    @NotNull(message = "请传入材料价格有效期id!")
+    private Long materialValidityId;
+
     @ApiModelProperty(value = "实时价格id")
+    @NotNull(message = "请传入材料实时价格id!")
     private Long currentPriceId;
 
     @ApiModelProperty(value = "实时价格")
+    @NotNull(message = "请传入材料实时价格!")
     private BigDecimal currentPrice;
 
     @ApiModelProperty(value = "价差幅度,百分比")
+    @NotNull(message = "请传入价差幅度!")
     private BigDecimal rangePriceRatio;
 
     @ApiModelProperty(value = "材料数量")
+    @NotNull(message = "请填写材料数量!")
     private BigDecimal materialTotal;
 
     @ApiModelProperty(value = "调差金额")

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

@@ -49,6 +49,9 @@ public class ContractMaterialAdjustDetail extends BaseEntity {
     @ApiModelProperty(value = "合同段id")
     private Long contractId;
 
+    @ApiModelProperty(value = "材料调差单id")
+    private Long materialAdjustId;
+
     @ApiModelProperty(value = "合同材料id")
     private Long contractMaterialId;
 
@@ -56,7 +59,7 @@ public class ContractMaterialAdjustDetail extends BaseEntity {
     private Long middleMeterId;
 
     @ApiModelProperty(value = "计量单编号")
-    private Long meterNumber;
+    private String meterNumber;
 
     @ApiModelProperty(value = "合同工程清单id")
     private Long contractFormId;

+ 12 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMaterialAdjustController.java

@@ -27,8 +27,11 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.meter.dto.ContractMaterialAdjustAddDTO;
 import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterial;
 import org.springblade.meter.service.IAttachmentFormService;
+import org.springblade.meter.service.IContractMaterialAdjustService;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -45,5 +48,14 @@ import javax.validation.Valid;
 @Api(value = "材料调差", tags = "材料调差接口")
 public class ContractMaterialAdjustController extends BladeController {
 
+    private final IContractMaterialAdjustService adjustService;
+
+    @PostMapping("/add")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "新增", notes = "传入材料调差单")
+    public R submit(@Valid @RequestBody ContractMaterialAdjustAddDTO dto) {
+        adjustService.add(dto);
+        return R.success("新增成功");
+    }
 	
 }

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

@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.validation.Valid;
 import java.time.YearMonth;
 import java.util.List;
+import java.util.Map;
 
 /**
  *
@@ -85,6 +86,15 @@ public class ContractMaterialValidityController extends BladeController {
 		return R.data(list);
 	}
 
+	@GetMapping("/get-material-range-price")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "材料调差-选择实时价格-确认", notes = "实时价格id,返回价差幅度与是否允许调差")
+	public R<Map<String,Object>> getMaterialRangePrice(Long priceId) {
+		Map<String,Object> map = validityService.getMaterialRangePrice(priceId);
+		return R.data(map);
+	}
+
+
+
 
-	
 }

+ 4 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.java

@@ -19,11 +19,13 @@ package org.springblade.meter.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterial;
 import org.springblade.meter.entity.ContractMaterialValidity;
 import org.springblade.meter.vo.ContractMaterialVO3;
 import org.springblade.meter.vo.ContractMaterialValidityVO;
 import org.springblade.meter.vo.GetMaterialCurrentPriceVO;
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.YearMonth;
 import java.util.List;
@@ -47,4 +49,6 @@ public interface ContractMaterialValidityMapper extends BaseMapper<ContractMater
     List<ContractMaterialVO3> detail(@Param("id") Long id);
 
     List<GetMaterialCurrentPriceVO> getMaterialCurrentPrice(@Param("contractId") Long contractId,@Param("materialId") Long materialId,@Param("yearMonth") YearMonth yearMonth);
+
+    ContractMaterial getMaterial(@Param("id") Long materialId);
 }

+ 5 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/mapper/ContractMaterialValidityMapper.xml

@@ -35,4 +35,9 @@
         </if>
         order by end_date desc
     </select>
+    <select id="getMaterial" resultType="org.springblade.meter.entity.ContractMaterial">
+        select * from s_contract_material where id = #{id}
+    </select>
+
+
 </mapper>

+ 2 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialAdjustService.java

@@ -17,6 +17,7 @@
 package org.springblade.meter.service;
 
 import org.springblade.core.mp.base.BaseService;
+import org.springblade.meter.dto.ContractMaterialAdjustAddDTO;
 import org.springblade.meter.entity.AttachmentForm;
 import org.springblade.meter.entity.ContractMaterialAdjust;
 
@@ -31,4 +32,5 @@ import java.util.Set;
 public interface IContractMaterialAdjustService extends BaseService<ContractMaterialAdjust> {
 
 
+    void add(ContractMaterialAdjustAddDTO dto);
 }

+ 3 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IContractMaterialValidityService.java

@@ -26,6 +26,7 @@ import org.springblade.meter.vo.GetMaterialCurrentPriceVO;
 
 import java.time.YearMonth;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -44,4 +45,6 @@ public interface IContractMaterialValidityService extends BaseService<ContractMa
     List<ContractMaterialVO3> detail(Long id);
 
     List<GetMaterialCurrentPriceVO> getMaterialCurrentPrice(Long contractId, Long materialId, YearMonth yearMonth);
+
+    Map<String, Object> getMaterialRangePrice( Long priceId);
 }

+ 67 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/ContractMaterialAdjustServiceImpl.java

@@ -16,15 +16,28 @@
  */
 package org.springblade.meter.service.impl;
 
+import lombok.AllArgsConstructor;
+import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.meter.dto.ContractMaterialAdjustAddDTO;
 import org.springblade.meter.entity.AttachmentForm;
 import org.springblade.meter.entity.ContractMaterialAdjust;
+import org.springblade.meter.entity.ContractMaterialAdjustDetail;
+import org.springblade.meter.entity.ContractMaterialValidity;
 import org.springblade.meter.mapper.AttachmentFormMapper;
 import org.springblade.meter.mapper.ContractMaterialAdjustMapper;
 import org.springblade.meter.service.IAttachmentFormService;
+import org.springblade.meter.service.IContractMaterialAdjustDetailService;
 import org.springblade.meter.service.IContractMaterialAdjustService;
+import org.springblade.meter.service.IContractMaterialValidityService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -34,7 +47,61 @@ import java.util.Set;
  * @since 2023-11-29
  */
 @Service
+@AllArgsConstructor
 public class ContractMaterialAdjustServiceImpl extends BaseServiceImpl<ContractMaterialAdjustMapper, ContractMaterialAdjust> implements IContractMaterialAdjustService {
 
+    private final IContractMaterialValidityService validityService;
 
+    private final IContractMaterialAdjustDetailService adjustDetailService;
+
+    private final IAttachmentFormService attachmentFormService;
+
+    @Override
+    @Transactional
+    public void add(ContractMaterialAdjustAddDTO dto) {
+        //获取材料有效期
+        ContractMaterialValidity validity = validityService.getById(dto.getMaterialValidityId());
+        /*保存材料调差单*/
+        ContractMaterialAdjust adjust = new ContractMaterialAdjust();
+        BeanUtils.copyProperties(dto,adjust);
+        adjust.setId(SnowFlakeUtil.getId());
+        //计算调差金额,生成计算式
+        StringBuilder str = new StringBuilder("调差价格依据于:"+dto.getMaterialName()+
+                "("+validity.getStartDate().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+"至"+
+                validity.getEndDate().format(DateTimeFormatter.ofPattern("yyyyMMdd"))+")\n");
+        BigDecimal adjustMoney;
+        BigDecimal price = dto.getMaterialPrice();
+        BigDecimal currentPrice = dto.getCurrentPrice();
+        if (price.compareTo(currentPrice) == 1){
+            //市场价低于基准价
+            adjustMoney = dto.getMaterialTotal().multiply(currentPrice.subtract((price.multiply(new BigDecimal(1).add(dto.getRangePriceRatio().abs().divide(new BigDecimal(100))))))).multiply(new BigDecimal(1.09)).setScale(2, RoundingMode.DOWN);
+            str.append("调差公式(标准):调增金额=调差数量×[市场价-基准价×(1-风险幅度差%)]×(1+合同增值税税率)\n");
+            str.append("调差公式(计算):"+adjustMoney+"="+dto.getMaterialTotal()+"*["+currentPrice+"-"+price+"*(1+"+dto.getRangePriceRatio().abs()+"%)]*(1+9.0/100)");
+        }else {
+            //市场价高于基准价
+            adjustMoney = dto.getMaterialTotal().multiply(currentPrice.subtract((price.multiply(new BigDecimal(1).add(dto.getRangePriceRatio().divide(new BigDecimal(100))))))).multiply(new BigDecimal(1.09)).setScale(2, RoundingMode.DOWN);
+            str.append("调差公式(标准):调增金额=调差数量×[市场价-基准价×(1+风险幅度差%)]×(1+合同增值税税率)\n");
+            str.append("调差公式(计算):"+adjustMoney+"="+dto.getMaterialTotal()+"*["+currentPrice+"-"+price+"*(1-"+dto.getRangePriceRatio()+"%)]*(1+9.0/100)");
+        }
+        adjust.setAdjustMoney(adjustMoney);
+        adjust.setAdjustCalculation(str.toString());
+        this.save(adjust);
+
+        /*保存材料明细*/
+        List<ContractMaterialAdjustDetail> details = dto.getDetails();
+        if (details.size() != 0){
+            for (ContractMaterialAdjustDetail detail : details) {
+                detail.setMaterialAdjustId(adjust.getId());
+            }
+            adjustDetailService.saveBatch(details);
+        }
+        /*保存附件信息*/
+        List<AttachmentForm> files = dto.getFiles();
+        if (files.size() != 0){
+            for (AttachmentForm file : files) {
+                file.setMasterId(adjust.getId());
+            }
+            attachmentFormService.saveBatch(files);
+        }
+    }
 }

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

@@ -24,9 +24,11 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.meter.dto.ContractMaterialValidityDTO;
 import org.springblade.meter.entity.AttachmentForm;
+import org.springblade.meter.entity.ContractMaterial;
 import org.springblade.meter.entity.ContractMaterialPrice;
 import org.springblade.meter.entity.ContractMaterialValidity;
 import org.springblade.meter.mapper.AttachmentFormMapper;
+import org.springblade.meter.mapper.ContractMaterialMapper;
 import org.springblade.meter.mapper.ContractMaterialValidityMapper;
 import org.springblade.meter.service.IAttachmentFormService;
 import org.springblade.meter.service.IContractMaterialPriceService;
@@ -38,11 +40,11 @@ import org.springblade.meter.vo.GetMaterialCurrentPriceVO;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.YearMonth;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 附件表 服务实现类
@@ -57,6 +59,7 @@ public class ContractMaterialValidityServiceImpl extends BaseServiceImpl<Contrac
     private final IContractMaterialPriceService priceService;
 
 
+
     @Override
     public List<ContractMaterialValidityVO> list2(Long projectId,Long contractId) {
         //获取合同下所有数据
@@ -133,11 +136,42 @@ public class ContractMaterialValidityServiceImpl extends BaseServiceImpl<Contrac
         return vos;
     }
 
+    @Override
+    public Map<String, Object> getMaterialRangePrice( Long priceId) {
+        //获取材料实时价格
+        ContractMaterialPrice validity = priceService.getById(priceId);
+        BigDecimal currentPrice = validity.getCurrentPrice();
+        //获取材料价格
+        ContractMaterial material = baseMapper.getMaterial(validity.getContractMaterialId());
+        BigDecimal price = material.getPrice();
+        if (currentPrice == null || price == null || currentPrice.compareTo(BigDecimal.ZERO) == 0 || price.compareTo(BigDecimal.ZERO) == 0 ){
+            throw new ServiceException("基础价格或者实时价格不能为空,不能为0");
+        }
+        //校验调差限额
+        BigDecimal quotaRatio = material.getQuotaRatio();
+        if (quotaRatio == null){
+            throw new ServiceException("材料未设置调差限额");
+        }
+        //计算比例
+        Map<String, Object> map = new HashMap<>();
+        BigDecimal decimal = currentPrice.subtract(price).multiply(new BigDecimal(100)).divide(price, 2, RoundingMode.DOWN);
+        map.put("rangePriceRatio",decimal);
+        if (decimal.compareTo(quotaRatio.negate()) == 1 && decimal.compareTo(quotaRatio) == -1){
+            map.put("isAdjust",0);
+        }else {
+            map.put("isAdjust",1);
+        }
+        return map;
+    }
+
     @NotNull
     private static List<ContractMaterialPrice> getContractMaterialPrices(ContractMaterialValidityDTO dto, ContractMaterialValidity validity) {
         List<ContractMaterialValidityDTO.Material> list = dto.getMaterials();
         List<ContractMaterialPrice> priceList = new ArrayList<>();
         for (ContractMaterialValidityDTO.Material material : list) {
+            if (material.getPrice() == null || material.getPrice().compareTo(BigDecimal.ZERO) == 0){
+                throw new ServiceException("价格不能为空和0");
+            }
             ContractMaterialPrice price = new ContractMaterialPrice();
             price.setProjectId(dto.getProjectId());
             price.setContractId(dto.getContractId());