| | |
| | | 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; |
| | |
| | | i = annualMaintenanceRecordMapper.updateById(annualMaintenanceRecord); |
| | | } |
| | | if (i > 0){ |
| | | |
| | | batchSaveRecordUser(isAdd, annualMaintenanceRecord.getId(), annualMaintenanceRecordUsers, annualMaintenanceRecord.getDelRecordUserIds()); |
| | | return CommonResult.success(); |
| | | } |
| | | return CommonResult.failed(); |
| | |
| | | .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)){ |
| | |
| | | .in(AnnualMaintenanceRecordUser::getId, delRecordUserIds) |
| | | ); |
| | | if (update <= 0){ |
| | | throw new RuntimeException("删除年度基础设施维护记录人员失败"); |
| | | throw new ApiException("删除年度基础设施维护记录人员失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | }); |
| | | int insert = annualMaintenanceRecordUserMapper.batchInsert(annualMaintenanceRecordUsers); |
| | | if (insert <= 0){ |
| | | throw new RuntimeException("保存年度基础设施维护记录人员失败"); |
| | | throw new ApiException("保存年度基础设施维护记录人员失败"); |
| | | } |
| | | }else { |
| | | List<AnnualMaintenanceRecordUser> addUser = annualMaintenanceRecordUsers.stream() |
| | |
| | | user.setCreateTime(LocalDateTime.now()); |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | }); |
| | | int insert = annualMaintenanceRecordUserMapper.batchInsert(annualMaintenanceRecordUsers); |
| | | int insert = annualMaintenanceRecordUserMapper.batchInsert(addUser); |
| | | if (insert <= 0){ |
| | | throw new RuntimeException("保存年度基础设施维护记录人员失败"); |
| | | throw new ApiException("保存年度基础设施维护记录人员失败"); |
| | | } |
| | | } |
| | | |
| | | List<AnnualMaintenanceRecordUser> updateUser = annualMaintenanceRecordUsers.stream() |
| | | .filter(user -> null == user.getId()) |
| | | .filter(user -> null != user.getId()) |
| | | .collect(Collectors.toList()); |
| | | if (ObjectUtils.isNotEmpty(updateUser)){ |
| | | updateUser.forEach(user -> { |
| | |
| | | }); |
| | | int update = annualMaintenanceRecordUserMapper.batchUpdate(updateUser); |
| | | if (update <= 0){ |
| | | throw new RuntimeException("保存年度基础设施维护记录人员失败"); |
| | | throw new ApiException("保存年度基础设施维护记录人员失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | LambdaQueryWrapper<AnnualMaintenanceRecordUser> eq = new LambdaQueryWrapper<AnnualMaintenanceRecordUser>().eq(AnnualMaintenanceRecordUser::getAnnualMaintenanceRecordId, id); |
| | | int update1 = annualMaintenanceRecordUserMapper.update(annualMaintenanceRecordUser, eq); |
| | | if (update1 <= 0){ |
| | | throw new RuntimeException("删除年度基础设施维护计划人员失败"); |
| | | } |
| | | // if (update1 <= 0){ |
| | | // throw new RuntimeException("删除年度基础设施维护计划人员失败"); |
| | | // } |
| | | return CommonResult.success(); |
| | | } |
| | | return CommonResult.failed(); |