fix: 修复BigDecimal乘法编译错误

This commit is contained in:
Your Name 2026-01-05 23:35:05 +08:00
parent a2fd8a63b0
commit 0f5c77d73a

View File

@ -114,10 +114,10 @@ public class TaskService {
Long firstTypeId = Long.parseLong(typeIds[0].trim());
var firstType = configService.getDemandTypeById(firstTypeId);
int totalScore = firstType.getUnitScore().multiply(BigDecimal.valueOf(task.getQuantity())).intValue();
int totalHours = firstType.getEstimatedHours() != null ? firstType.getEstimatedHours() * task.getQuantity() : 0;
BigDecimal totalHours = firstType.getEstimatedHours() != null ? firstType.getEstimatedHours().multiply(BigDecimal.valueOf(task.getQuantity())) : BigDecimal.ZERO;
task.setScore(totalScore);
task.setEstimatedHours(BigDecimal.valueOf(totalHours));
task.setEstimatedHours(totalHours);
// 兼容性:同时保存第一个类型到task_type_id
task.setTaskTypeId(firstTypeId);
@ -133,10 +133,10 @@ public class TaskService {
// 计算总积分和工时
int totalScore = demandType.getUnitScore().multiply(BigDecimal.valueOf(task.getQuantity())).intValue();
int totalHours = demandType.getEstimatedHours() != null ? demandType.getEstimatedHours() * task.getQuantity() : 0;
BigDecimal totalHours = demandType.getEstimatedHours() != null ? demandType.getEstimatedHours().multiply(BigDecimal.valueOf(task.getQuantity())) : BigDecimal.ZERO;
task.setScore(totalScore);
task.setEstimatedHours(BigDecimal.valueOf(totalHours));
task.setEstimatedHours(totalHours);
// 自动填充taskTypeIds字段
task.setTaskTypeIds(String.valueOf(task.getTaskTypeId()));
@ -255,7 +255,7 @@ public class TaskService {
}
int itemScore = demandType.getUnitScore().multiply(BigDecimal.valueOf(itemDto.getQuantity())).intValue();
double itemHours = demandType.getEstimatedHours() != null ? demandType.getEstimatedHours() * itemDto.getQuantity() : 0;
double itemHours = demandType.getEstimatedHours() != null ? demandType.getEstimatedHours().multiply(BigDecimal.valueOf(itemDto.getQuantity())).doubleValue() : 0;
totalScore += itemScore;
totalHours += itemHours;
@ -395,7 +395,7 @@ public class TaskService {
item.setQuantity(itemDto.getQuantity());
item.setUnitScore(demandType.getUnitScore().intValue());
item.setTotalScore(demandType.getUnitScore().multiply(BigDecimal.valueOf(itemDto.getQuantity())).intValue());
item.setEstimatedHours(BigDecimal.valueOf(demandType.getEstimatedHours() != null ? demandType.getEstimatedHours() * itemDto.getQuantity() : 0));
item.setEstimatedHours(demandType.getEstimatedHours() != null ? demandType.getEstimatedHours().multiply(BigDecimal.valueOf(itemDto.getQuantity())) : BigDecimal.ZERO);
item.setSortOrder(i + 1); // 恢复真实的排序号
item.setProgress(0);