|
@@ -24,9 +24,11 @@ import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.meter.dto.ContractMaterialValidityDTO;
|
|
import org.springblade.meter.dto.ContractMaterialValidityDTO;
|
|
import org.springblade.meter.entity.AttachmentForm;
|
|
import org.springblade.meter.entity.AttachmentForm;
|
|
|
|
+import org.springblade.meter.entity.ContractMaterial;
|
|
import org.springblade.meter.entity.ContractMaterialPrice;
|
|
import org.springblade.meter.entity.ContractMaterialPrice;
|
|
import org.springblade.meter.entity.ContractMaterialValidity;
|
|
import org.springblade.meter.entity.ContractMaterialValidity;
|
|
import org.springblade.meter.mapper.AttachmentFormMapper;
|
|
import org.springblade.meter.mapper.AttachmentFormMapper;
|
|
|
|
+import org.springblade.meter.mapper.ContractMaterialMapper;
|
|
import org.springblade.meter.mapper.ContractMaterialValidityMapper;
|
|
import org.springblade.meter.mapper.ContractMaterialValidityMapper;
|
|
import org.springblade.meter.service.IAttachmentFormService;
|
|
import org.springblade.meter.service.IAttachmentFormService;
|
|
import org.springblade.meter.service.IContractMaterialPriceService;
|
|
import org.springblade.meter.service.IContractMaterialPriceService;
|
|
@@ -38,11 +40,11 @@ import org.springblade.meter.vo.GetMaterialCurrentPriceVO;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.RoundingMode;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.YearMonth;
|
|
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;
|
|
private final IContractMaterialPriceService priceService;
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<ContractMaterialValidityVO> list2(Long projectId,Long contractId) {
|
|
public List<ContractMaterialValidityVO> list2(Long projectId,Long contractId) {
|
|
//获取合同下所有数据
|
|
//获取合同下所有数据
|
|
@@ -133,11 +136,42 @@ public class ContractMaterialValidityServiceImpl extends BaseServiceImpl<Contrac
|
|
return vos;
|
|
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
|
|
@NotNull
|
|
private static List<ContractMaterialPrice> getContractMaterialPrices(ContractMaterialValidityDTO dto, ContractMaterialValidity validity) {
|
|
private static List<ContractMaterialPrice> getContractMaterialPrices(ContractMaterialValidityDTO dto, ContractMaterialValidity validity) {
|
|
List<ContractMaterialValidityDTO.Material> list = dto.getMaterials();
|
|
List<ContractMaterialValidityDTO.Material> list = dto.getMaterials();
|
|
List<ContractMaterialPrice> priceList = new ArrayList<>();
|
|
List<ContractMaterialPrice> priceList = new ArrayList<>();
|
|
for (ContractMaterialValidityDTO.Material material : list) {
|
|
for (ContractMaterialValidityDTO.Material material : list) {
|
|
|
|
+ if (material.getPrice() == null || material.getPrice().compareTo(BigDecimal.ZERO) == 0){
|
|
|
|
+ throw new ServiceException("价格不能为空和0");
|
|
|
|
+ }
|
|
ContractMaterialPrice price = new ContractMaterialPrice();
|
|
ContractMaterialPrice price = new ContractMaterialPrice();
|
|
price.setProjectId(dto.getProjectId());
|
|
price.setProjectId(dto.getProjectId());
|
|
price.setContractId(dto.getContractId());
|
|
price.setContractId(dto.getContractId());
|