From b0be631d7800b2a35c4dfeb9332877946e361829 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: Tue, 28 Apr 2026 17:18:56 +0800
Subject: [PATCH] 新增功能
---
multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceRecordServiceImpl.java | 31 ++++++++++++++++++-------------
1 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceRecordServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceRecordServiceImpl.java
index 5152f50..544cf1c 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceRecordServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/AnnualMaintenanceRecordServiceImpl.java
@@ -3,9 +3,11 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
import com.gkhy.exam.common.constant.UserConstant;
+import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.PageUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.system.domain.AnnualMaintenanceRecord;
@@ -13,7 +15,6 @@
import com.gkhy.exam.system.mapper.AnnualMaintenanceRecordMapper;
import com.gkhy.exam.system.mapper.AnnualMaintenanceRecordUserMapper;
import com.gkhy.exam.system.service.AnnualMaintenanceRecordService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -78,19 +79,23 @@
.map(AnnualMaintenanceRecordUser::getUserId)
.collect(Collectors.toSet());
if (userIdSet.size() != filteredUsers.size()){
- throw new RuntimeException("年度基础设施维护记录操作管理人员重复");
+ throw new ApiException("年度基础设施维护记录操作管理人员重复");
}
+ //维修员
List<AnnualMaintenanceRecordUser> fixUsers = annualMaintenanceRecordUsers.stream()
.filter(user -> 2 == user.getUserType())
.collect(Collectors.toList());
- Set<Long> fixUserIdSet = fixUsers.stream()
- .map(AnnualMaintenanceRecordUser::getUserId)
- .collect(Collectors.toSet());
- if (fixUserIdSet.size() != fixUsers.size()){
- throw new RuntimeException("年度基础设施维护记录人员重复");
+ if (!ObjectUtils.isEmpty(fixUsers)){
+ Set<Long> fixUserIdSet = fixUsers.stream()
+ .map(AnnualMaintenanceRecordUser::getUserId)
+ .collect(Collectors.toSet());
+ if (fixUserIdSet.size() != fixUsers.size()){
+ throw new ApiException("年度基础设施维护记录人员重复");
+ }
}
- if (ObjectUtils.isEmpty(filteredUsers) || ObjectUtils.isEmpty(fixUsers)){
- throw new RuntimeException("年度基础设施维护记录人员或操作管理人员不能为空");
+
+ if (ObjectUtils.isEmpty(filteredUsers) ){
+ throw new ApiException("年度基础设施维护记录操作管理人员不能为空");
}
if (ObjectUtils.isNotEmpty(delRecordUserIds)){
@@ -101,7 +106,7 @@
.in(AnnualMaintenanceRecordUser::getId, delRecordUserIds)
);
if (update <= 0){
- throw new RuntimeException("删除年度基础设施维护记录人员失败");
+ throw new ApiException("删除年度基础设施维护记录人员失败");
}
}
@@ -114,7 +119,7 @@
});
int insert = annualMaintenanceRecordUserMapper.batchInsert(annualMaintenanceRecordUsers);
if (insert <= 0){
- throw new RuntimeException("保存年度基础设施维护记录人员失败");
+ throw new ApiException("保存年度基础设施维护记录人员失败");
}
}else {
List<AnnualMaintenanceRecordUser> addUser = annualMaintenanceRecordUsers.stream()
@@ -128,7 +133,7 @@
});
int insert = annualMaintenanceRecordUserMapper.batchInsert(addUser);
if (insert <= 0){
- throw new RuntimeException("保存年度基础设施维护记录人员失败");
+ throw new ApiException("保存年度基础设施维护记录人员失败");
}
}
@@ -142,7 +147,7 @@
});
int update = annualMaintenanceRecordUserMapper.batchUpdate(updateUser);
if (update <= 0){
- throw new RuntimeException("保存年度基础设施维护记录人员失败");
+ throw new ApiException("保存年度基础设施维护记录人员失败");
}
}
--
Gitblit v1.9.2