From 5321ff4afa370fe67d5182eac8219961f39d6f2c Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 5 Jan 2026 18:41:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DBigDecimal=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=BF=90=E7=AE=97=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/designhub/service/TaskService.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/com/designhub/service/TaskService.java b/backend/src/main/java/com/designhub/service/TaskService.java index 85936e3..83bb741 100644 --- a/backend/src/main/java/com/designhub/service/TaskService.java +++ b/backend/src/main/java/com/designhub/service/TaskService.java @@ -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;