fix: 修复BigDecimal类型运算兼容性问题
This commit is contained in:
parent
39e8b43630
commit
5321ff4afa
@ -113,8 +113,8 @@ public class TaskService {
|
||||
// 计算总积分和工时:取第一个类型的单价
|
||||
Long firstTypeId = Long.parseLong(typeIds[0].trim());
|
||||
var firstType = configService.getDemandTypeById(firstTypeId);
|
||||
int totalScore = firstType.getUnitScore() * task.getQuantity();
|
||||
int totalHours = firstType.getEstimatedHours() * task.getQuantity();
|
||||
int totalScore = firstType.getUnitScore().multiply(BigDecimal.valueOf(task.getQuantity())).intValue();
|
||||
int totalHours = firstType.getEstimatedHours() != null ? firstType.getEstimatedHours() * task.getQuantity() : 0;
|
||||
|
||||
task.setScore(totalScore);
|
||||
task.setEstimatedHours(BigDecimal.valueOf(totalHours));
|
||||
@ -132,8 +132,8 @@ public class TaskService {
|
||||
}
|
||||
|
||||
// 计算总积分和工时
|
||||
int totalScore = demandType.getUnitScore() * task.getQuantity();
|
||||
int totalHours = demandType.getEstimatedHours() * task.getQuantity();
|
||||
int totalScore = demandType.getUnitScore().multiply(BigDecimal.valueOf(task.getQuantity())).intValue();
|
||||
int totalHours = demandType.getEstimatedHours() != null ? demandType.getEstimatedHours() * task.getQuantity() : 0;
|
||||
|
||||
task.setScore(totalScore);
|
||||
task.setEstimatedHours(BigDecimal.valueOf(totalHours));
|
||||
@ -254,8 +254,8 @@ public class TaskService {
|
||||
throw new BusinessException(ResultCode.PARAM_ERROR, "任务类型ID无效: " + itemDto.getTaskTypeId());
|
||||
}
|
||||
|
||||
int itemScore = demandType.getUnitScore() * itemDto.getQuantity();
|
||||
double itemHours = demandType.getEstimatedHours() * itemDto.getQuantity();
|
||||
int itemScore = demandType.getUnitScore().multiply(BigDecimal.valueOf(itemDto.getQuantity())).intValue();
|
||||
double itemHours = demandType.getEstimatedHours() != null ? demandType.getEstimatedHours() * itemDto.getQuantity() : 0;
|
||||
|
||||
totalScore += itemScore;
|
||||
totalHours += itemHours;
|
||||
@ -393,9 +393,9 @@ public class TaskService {
|
||||
item.setGroupNo(itemGroupNo);
|
||||
item.setTaskTypeId(itemDto.getTaskTypeId());
|
||||
item.setQuantity(itemDto.getQuantity());
|
||||
item.setUnitScore(demandType.getUnitScore());
|
||||
item.setTotalScore(demandType.getUnitScore() * itemDto.getQuantity());
|
||||
item.setEstimatedHours(BigDecimal.valueOf(demandType.getEstimatedHours() * 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.setSortOrder(i + 1); // 恢复真实的排序号
|
||||
item.setProgress(0);
|
||||
|
||||
@ -2006,8 +2006,8 @@ public class TaskService {
|
||||
int totalScore = 0;
|
||||
for (TaskUpdateDTO.TaskTypeUpdateDTO taskType : taskTypes) {
|
||||
DemandType demandType = configService.getDemandTypeById(taskType.getTaskTypeId());
|
||||
if (demandType != null) {
|
||||
totalScore += demandType.getUnitScore() * taskType.getQuantity();
|
||||
if (demandType != null && demandType.getUnitScore() != null) {
|
||||
totalScore += demandType.getUnitScore().multiply(BigDecimal.valueOf(taskType.getQuantity())).intValue();
|
||||
}
|
||||
}
|
||||
return totalScore;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user