修改金额精度问题

This commit is contained in:
2025-09-11 15:26:07 +08:00
parent 9fbc9dbc45
commit 1e33027d4f
17 changed files with 65 additions and 52 deletions

View File

@ -221,7 +221,7 @@ public class BusBiddingLimitListServiceImpl extends ServiceImpl<BusBiddingLimitL
// 如果是叶子节点,计算 price = quantity * unitPrice
if (node.getChildren().isEmpty()) {
if (node.getQuantity() != null && node.getUnitPrice() != null) {
node.setPrice(node.getQuantity().multiply(node.getUnitPrice()));
node.setPrice(node.getQuantity().multiply(node.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
} else {
node.setPrice(BigDecimal.ZERO); // 默认值
}

View File

@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.temporal.TemporalAdjusters;
@ -115,7 +116,7 @@ public class MoneyBigScreenController {
.last("limit 1")
);
if (contract != null && contract.getPayRatio() != null) {
actualAmount = actualAmount.add(projectMonthlyAmountMap.get(projectId).multiply(contract.getPayRatio()).divide(HUNDRED));
actualAmount = actualAmount.add(projectMonthlyAmountMap.get(projectId).multiply(contract.getPayRatio()).divide(HUNDRED).setScale(4, RoundingMode.HALF_UP));
}
}
@ -170,7 +171,7 @@ public class MoneyBigScreenController {
);
if (contract != null && contract.getPayRatio() != null) {
actualAmount = actualAmount.add(projectAmountMap.get(contractCode).multiply(contract.getPayRatio()).divide(HUNDRED));
actualAmount = actualAmount.add(projectAmountMap.get(contractCode).multiply(contract.getPayRatio()).setScale(4, RoundingMode.HALF_UP).divide(HUNDRED));
}
}
@ -351,7 +352,7 @@ public class MoneyBigScreenController {
.last("limit 1")
);
if (contract != null && contract.getPayRatio() != null) {
incomeAmount = incomeAmount.add(incomeGroupedByProject.get(projectId).multiply(contract.getPayRatio()).divide(HUNDRED));
incomeAmount = incomeAmount.add(incomeGroupedByProject.get(projectId).multiply(contract.getPayRatio()).setScale(4, RoundingMode.HALF_UP).divide(HUNDRED));
}
}
@ -381,7 +382,7 @@ public class MoneyBigScreenController {
);
if (contract != null && contract.getPayRatio() != null) {
expensesAmount = expensesAmount.add(expenseGroupedByContract.get(contractCode).multiply(contract.getPayRatio()).divide(HUNDRED));
expensesAmount = expensesAmount.add(expenseGroupedByContract.get(contractCode).multiply(contract.getPayRatio()).setScale(4, RoundingMode.HALF_UP).divide(HUNDRED));
}
}
@ -449,7 +450,7 @@ public class MoneyBigScreenController {
.last("limit 1")
);
if (contract != null && contract.getPayRatio() != null) {
incomeAmount = incomeAmount.add(incomeGroupedByProject.get(projectId).multiply(contract.getPayRatio()).divide(HUNDRED));
incomeAmount = incomeAmount.add(incomeGroupedByProject.get(projectId).multiply(contract.getPayRatio()).setScale(4, RoundingMode.HALF_UP).divide(HUNDRED));
}
}
@ -479,7 +480,7 @@ public class MoneyBigScreenController {
);
if (contract != null && contract.getPayRatio() != null) {
expensesAmount = expensesAmount.add(expenseGroupedByContract.get(contractCode).multiply(contract.getPayRatio()).divide(HUNDRED));
expensesAmount = expensesAmount.add(expenseGroupedByContract.get(contractCode).multiply(contract.getPayRatio()).setScale(4, RoundingMode.HALF_UP).divide(HUNDRED));
}
}

View File

@ -36,6 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -248,10 +249,10 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl<FacBoxTransformerM
progressCategory.setTotal(BigDecimal.valueOf(total));
// 如果单价不为 0 则计算产值
if (ownerPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
if (constructionPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setOwnerOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setOwnerOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
}
boolean result = progressCategoryService.updateBatchById(progressCategoryList);
@ -309,11 +310,11 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl<FacBoxTransformerM
progressCategory.setOwnerOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getOwnerPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
progressCategory.setConstructionOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getConstructionPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);

View File

@ -36,6 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -248,10 +249,10 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
progressCategory.setTotal(BigDecimal.valueOf(total));
// 如果单价不为 0 则计算产值
if (ownerPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
if (constructionPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setConstructionOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setConstructionOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
}
boolean result = progressCategoryService.updateBatchById(progressCategoryList);
@ -309,11 +310,11 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
progressCategory.setOwnerOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getOwnerPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
progressCategory.setConstructionOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getConstructionPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);

View File

@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@ -178,11 +179,11 @@ public class FacPhotovoltaicPanelColumnServiceImpl extends ServiceImpl<FacPhotov
progressCategory.setOwnerOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getOwnerPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
progressCategory.setConstructionOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getConstructionPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);

View File

@ -43,6 +43,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Function;
@ -494,10 +495,10 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
progressCategory.setTotal(BigDecimal.valueOf(total));
// 如果单价不为 0 则计算产值
if (ownerPrice != null && ownerPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
if (constructionPrice != null && constructionPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setConstructionOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setConstructionOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
}
boolean result = progressCategoryService.updateBatchById(progressCategoryList);

View File

@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@ -178,11 +179,11 @@ public class FacPhotovoltaicPanelPointServiceImpl extends ServiceImpl<FacPhotovo
progressCategory.setOwnerOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getOwnerPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
progressCategory.setConstructionOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getConstructionPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);

View File

@ -46,6 +46,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Function;
@ -387,10 +388,10 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
progressCategory.setTotal(BigDecimal.valueOf(total));
// 如果单价不为 0 则计算产值
if (ownerPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setOwnerOutputValue(ownerPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
if (constructionPrice.compareTo(BigDecimal.ZERO) != 0) {
progressCategory.setConstructionOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)));
progressCategory.setConstructionOutputValue(constructionPrice.multiply(BigDecimal.valueOf(total)).setScale(4, RoundingMode.HALF_UP));
}
}
boolean result = progressCategoryService.updateBatchById(progressCategoryList);
@ -525,11 +526,11 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
progressCategory.setOwnerOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getOwnerPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
progressCategory.setConstructionOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getConstructionPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);

View File

@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;
@ -178,11 +179,11 @@ public class FacPhotovoltaicPanelSupportServiceImpl extends ServiceImpl<FacPhoto
progressCategory.setOwnerOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getOwnerPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
progressCategory.setConstructionOutputValue(total.multiply(
Optional.ofNullable(progressCategory.getConstructionPrice())
.orElse(BigDecimal.ZERO)
));
).setScale(4, RoundingMode.HALF_UP));
boolean result = progressCategoryService.updateById(progressCategory);
if (!result) {
throw new ServiceException("更新进度失败,数据库异常", HttpStatus.ERROR);

View File

@ -25,6 +25,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
@ -258,7 +259,7 @@ public class OutTableController extends BaseController {
BigDecimal purchaseValue = BigDecimal.ZERO;
for (BusProcurement busProcurement : busProcurements) {
if(busProcurement != null && busProcurement.getAcceptedQuantity() != null && busProcurement.getUnitPrice() != null){
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()));
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
}
}
@ -330,7 +331,7 @@ public class OutTableController extends BaseController {
BigDecimal purchaseValue = BigDecimal.ZERO;
for (BusProcurement busProcurement : busProcurements) {
if(busProcurement != null && busProcurement.getAcceptedQuantity() != null && busProcurement.getUnitPrice() != null){
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()));
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
}
}
@ -439,7 +440,7 @@ public class OutTableController extends BaseController {
BigDecimal accumulatedCompletionValue = BigDecimal.ZERO;
for (BusProcurement busProcurement : busProcurements) {
if(busProcurement != null && busProcurement.getAcceptedQuantity() != null && busProcurement.getUnitPrice() != null){
accumulatedCompletionValue = accumulatedCompletionValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()));
accumulatedCompletionValue = accumulatedCompletionValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
}
}
@ -453,7 +454,7 @@ public class OutTableController extends BaseController {
BigDecimal monthCompletionValue = BigDecimal.ZERO;
for (BusProcurement busProcurement : busProcurements1) {
monthCompletionValue = monthCompletionValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()));
monthCompletionValue = monthCompletionValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
}
vo.setMonthCompletionValue(monthCompletionValue);
@ -547,7 +548,7 @@ public class OutTableController extends BaseController {
BigDecimal purchaseValue = BigDecimal.ZERO;
for (BusProcurement busProcurement : busProcurements) {
if(busProcurement != null && busProcurement.getAcceptedQuantity() != null && busProcurement.getUnitPrice() != null){
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()));
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
}
}
@ -563,7 +564,7 @@ public class OutTableController extends BaseController {
BigDecimal subPurchaseValue = BigDecimal.ZERO;
for (BusProcurement busProcurement : busProcurements1) {
if(busProcurement != null && busProcurement.getAcceptedQuantity() != null && busProcurement.getUnitPrice() != null){
subPurchaseValue = subPurchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()));
subPurchaseValue = subPurchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
}
}

View File

@ -33,6 +33,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@ -145,11 +146,11 @@ public class OutConstructionValueServiceImpl extends ServiceImpl<OutConstruction
PgsProgressCategory progressCategory = pgsProgressCategoryService.getById(bo.getProgressCategoryId());
if (progressCategory != null) {
if ("1".equals(progressCategory.getUnitType())) {
add.setOutValue(progressCategory.getConstructionPrice().multiply(BigDecimal.valueOf(bo.getArtificialNum())));
add.setOwnerValue(progressCategory.getOwnerPrice().multiply(BigDecimal.valueOf(bo.getArtificialNum())));
add.setOutValue(progressCategory.getConstructionPrice().multiply(BigDecimal.valueOf(bo.getArtificialNum())).setScale(4, RoundingMode.HALF_UP));
add.setOwnerValue(progressCategory.getOwnerPrice().multiply(BigDecimal.valueOf(bo.getArtificialNum())).setScale(4, RoundingMode.HALF_UP));
} else if ("2".equals(progressCategory.getUnitType())) {
add.setOwnerValue(progressCategory.getOwnerPrice().multiply(BigDecimal.valueOf(bo.getUavNum()).divide(new BigDecimal("100"))));
add.setOutValue(progressCategory.getConstructionPrice().multiply(BigDecimal.valueOf(bo.getUavNum()).divide(new BigDecimal("100"))));
add.setOwnerValue(progressCategory.getOwnerPrice().multiply(BigDecimal.valueOf(bo.getUavNum()).divide(new BigDecimal("100"))).setScale(4, RoundingMode.HALF_UP));
add.setOutValue(progressCategory.getConstructionPrice().multiply(BigDecimal.valueOf(bo.getUavNum()).divide(new BigDecimal("100"))).setScale(4, RoundingMode.HALF_UP));
}
}

View File

@ -38,6 +38,7 @@ import org.dromara.out.mapper.OutMonthPlanMapper;
import org.dromara.out.service.IOutMonthPlanService;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
@ -377,7 +378,7 @@ public class OutMonthPlanServiceImpl extends ServiceImpl<OutMonthPlanMapper, Out
BigDecimal purchaseValue = BigDecimal.ZERO;
for (BusProcurement busProcurement : busProcurements) {
if (busProcurement != null && busProcurement.getAcceptedQuantity() != null && busProcurement.getUnitPrice() != null) {
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()));
purchaseValue = purchaseValue.add(busProcurement.getAcceptedQuantity().multiply(busProcurement.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
}
}

View File

@ -29,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -222,10 +223,10 @@ public class PgsProgressCategoryController extends BaseController {
BigDecimal total = pgsProgressCategory.getTotal();
if (total != null && total.compareTo(BigDecimal.ZERO) != 0) {
if (ownerPrice != null && ownerPrice.compareTo(BigDecimal.ZERO) != 0) {
pgsProgressCategory.setOwnerOutputValue(ownerPrice.multiply(total));
pgsProgressCategory.setOwnerOutputValue(ownerPrice.multiply(total).setScale(4, RoundingMode.HALF_UP));
}
if (constructionPrice != null && constructionPrice.compareTo(BigDecimal.ZERO) != 0) {
pgsProgressCategory.setConstructionOutputValue(constructionPrice.multiply(total));
pgsProgressCategory.setConstructionOutputValue(constructionPrice.multiply(total).setScale(4, RoundingMode.HALF_UP));
}
}

View File

@ -378,10 +378,10 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
}
// 计算产值
if (ownerPrice != null && total != null && ownerPrice.compareTo(BigDecimal.ZERO) >= 0 && total.compareTo(BigDecimal.ZERO) >= 0) {
progressCategory.setOwnerOutputValue(ownerPrice.multiply(total));
progressCategory.setOwnerOutputValue(ownerPrice.multiply(total).setScale(4, RoundingMode.HALF_UP));
}
if (constructionPrice != null && total != null && constructionPrice.compareTo(BigDecimal.ZERO) >= 0 && total.compareTo(BigDecimal.ZERO) >= 0) {
progressCategory.setConstructionOutputValue(constructionPrice.multiply(total));
progressCategory.setConstructionOutputValue(constructionPrice.multiply(total).setScale(4, RoundingMode.HALF_UP));
}
if (StringUtils.isNotBlank(workType) && PgsProgressCategoryConstant.WORK_TYPE_LIST.contains(workType)) {
List<PgsProgressCategory> progressCategoryList = this.lambdaQuery()
@ -457,8 +457,8 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
if (unitType.equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue()) ||
progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.PERCENTAGE.getValue())) {
progressCategory.setTotal(req.getTotal());
ownerOutputValue = req.getTotal().multiply(ownerPrice);
constructionOutputValue = req.getTotal().multiply(constructionPrice);
ownerOutputValue = req.getTotal().multiply(ownerPrice).setScale(4, RoundingMode.HALF_UP);
constructionOutputValue = req.getTotal().multiply(constructionPrice).setScale(4, RoundingMode.HALF_UP);
} else if (((unitType.equals(PgsProgressUnitTypeEnum.NUMBER.getValue())) ||
(progressCategory.getUnitType().equals(PgsProgressUnitTypeEnum.NUMBER.getValue())))
&& progressCategory.getWorkType() != null) {
@ -466,8 +466,8 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("请导入分项工程数量后再添加单价", HttpStatus.BAD_REQUEST);
}
ownerOutputValue = total.multiply(ownerPrice);
constructionOutputValue = total.multiply(constructionPrice);
ownerOutputValue = total.multiply(ownerPrice).setScale(4, RoundingMode.HALF_UP);
constructionOutputValue = total.multiply(constructionPrice).setScale(4, RoundingMode.HALF_UP);
} else {
BigDecimal total = req.getTotal();
if (total == null || total.compareTo(BigDecimal.ZERO) <= 0) {
@ -477,8 +477,8 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
throw new ServiceException("请输入分项工程数量", HttpStatus.BAD_REQUEST);
}
progressCategory.setTotal(total);
ownerOutputValue = total.multiply(ownerPrice);
constructionOutputValue = total.multiply(constructionPrice);
ownerOutputValue = total.multiply(ownerPrice).setScale(4, RoundingMode.HALF_UP);
constructionOutputValue = total.multiply(constructionPrice).setScale(4, RoundingMode.HALF_UP);
}
// 填入数据
progressCategory.setName(req.getName());

View File

@ -48,6 +48,7 @@ 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.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@ -926,8 +927,8 @@ public class PgsProgressPlanDetailServiceImpl extends ServiceImpl<PgsProgressPla
// 计算产值
BigDecimal constructionPrice = category.getConstructionPrice();
BigDecimal ownerPrice = category.getOwnerPrice();
value.setOutValue(constructionPrice.multiply(BigDecimal.valueOf(artificialNum)).add(constructionPrice.multiply(BigDecimal.valueOf(uavNum))));
value.setOwnerValue(ownerPrice.multiply(BigDecimal.valueOf(artificialNum)).add(ownerPrice.multiply(BigDecimal.valueOf(uavNum))));
value.setOutValue(constructionPrice.multiply(BigDecimal.valueOf(artificialNum)).setScale(4, RoundingMode.HALF_UP).add(constructionPrice.multiply(BigDecimal.valueOf(uavNum)).setScale(4, RoundingMode.HALF_UP)));
value.setOwnerValue(ownerPrice.multiply(BigDecimal.valueOf(artificialNum)).setScale(4, RoundingMode.HALF_UP).add(ownerPrice.multiply(BigDecimal.valueOf(uavNum)).setScale(4, RoundingMode.HALF_UP)));
saveList.add(value);
}
// 保存数据

View File

@ -362,7 +362,7 @@ public class BusBillofquantitiesLimitListServiceImpl extends ServiceImpl<BusBill
// 如果是叶子节点,计算 price = quantity * unitPrice
if (node.getChildren().isEmpty()) {
if (node.getQuantity() != null && node.getUnitPrice() != null) {
node.setPrice(node.getQuantity().multiply(node.getUnitPrice()));
node.setPrice(node.getQuantity().multiply(node.getUnitPrice()).setScale(4, RoundingMode.HALF_UP));
} else {
node.setPrice(BigDecimal.ZERO); // 默认值
}

View File

@ -164,7 +164,7 @@ public class BusSegmentedIndicatorPlanningServiceImpl extends ServiceImpl<BusSeg
private void validEntityBeforeSave(BusSegmentedIndicatorPlanning entity) {
//TODO 做一些数据校验,如唯一约束
String dictName = entity.getDictName();
BigDecimal contractPrice = entity.getPrice().multiply(new BigDecimal("10000"));
BigDecimal contractPrice = entity.getPrice().multiply(new BigDecimal("10000")).setScale(4, RoundingMode.HALF_UP);
switch (dictName) {
case "1" -> {
if (contractPrice.compareTo(BigDecimal.valueOf(100000000)) > 0) {