From 0f5c77d73a016572d1eac14403efb029757de913 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 5 Jan 2026 23:35:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DBigDecimal=E4=B9=98?= =?UTF-8?q?=E6=B3=95=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/designhub/service/TaskService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/com/designhub/service/TaskService.java b/backend/src/main/java/com/designhub/service/TaskService.java index 83bb741..f076b91 100644 --- a/backend/src/main/java/com/designhub/service/TaskService.java +++ b/backend/src/main/java/com/designhub/service/TaskService.java @@ -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);