修复:一级需求部门任务在草稿状态下可以不填写子任务
This commit is contained in:
parent
b4f9f7a47f
commit
3974b2eb24
@ -1725,8 +1725,12 @@ public class TaskService {
|
||||
throw new BusinessException(ResultCode.PARAM_ERROR, "流水线模式必须是 sequential 或 parallel");
|
||||
}
|
||||
|
||||
// 验证子任务列表
|
||||
if (dto.getItems() == null || dto.getItems().isEmpty()) {
|
||||
// 验证子任务列表(一级需求部门任务在草稿状态下可以不填写子任务)
|
||||
boolean isPrimaryTaskInDraft = existTask.getIsPrimaryTask() != null
|
||||
&& existTask.getIsPrimaryTask() == 1
|
||||
&& "draft".equals(existTask.getApprovalStatus());
|
||||
|
||||
if ((dto.getItems() == null || dto.getItems().isEmpty()) && !isPrimaryTaskInDraft) {
|
||||
throw new BusinessException(ResultCode.PARAM_ERROR, "流水线任务至少需要一个子任务");
|
||||
}
|
||||
|
||||
@ -1734,6 +1738,9 @@ public class TaskService {
|
||||
BigDecimal totalScoreDecimal = BigDecimal.ZERO;
|
||||
double totalHours = 0;
|
||||
int totalQuantity = 0;
|
||||
|
||||
// 如果有子任务才计算
|
||||
if (dto.getItems() != null && !dto.getItems().isEmpty()) {
|
||||
for (com.designhub.dto.PipelineTaskDTO.TaskItemDTO itemDto : dto.getItems()) {
|
||||
var demandType = configService.getDemandTypeById(itemDto.getTaskTypeId());
|
||||
if (demandType == null) {
|
||||
@ -1748,14 +1755,15 @@ public class TaskService {
|
||||
totalHours += itemHours;
|
||||
totalQuantity += itemDto.getQuantity();
|
||||
}
|
||||
} // 结束 if (dto.getItems() != null && !dto.getItems().isEmpty())
|
||||
|
||||
// 保留2位小数
|
||||
totalScoreDecimal = totalScoreDecimal.setScale(2, java.math.RoundingMode.HALF_UP);
|
||||
int totalScoreInt = totalScoreDecimal.intValue(); // 用于积分检查
|
||||
|
||||
// 检查部门积分是否充足(管理员跳过积分检查)
|
||||
// 检查部门积分是否充足(管理员跳过积分检查,一级需求部门草稿任务跳过)
|
||||
User user = userService.getUserById(userId);
|
||||
if (!isAdmin && user.getDeptId() != null) {
|
||||
if (!isAdmin && !isPrimaryTaskInDraft && user.getDeptId() != null) {
|
||||
if (!teamScorePoolService.checkBalance(user.getDeptId(), totalScoreInt)) {
|
||||
throw new BusinessException(ResultCode.INSUFFICIENT_SCORE, "部门积分余额不足");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user