| | |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.persistence.criteria.CriteriaBuilder; |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public Result updateGasWarnUser(UpdateGasWarnUserReqDTO reqDto) { |
| | | if (reqDto == null || reqDto.getId() == null) |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空"); |
| | |
| | | GasWarnUser gasWarnUser = gasWarnUserRepository.findByUserIdAndStatus(reqDto.getUserId(), DeleteStatusEnum.DELECT_NO.getStatus()); |
| | | if (gasWarnUser != null && !reqDto.getUserId().equals(gasWarnUser.getUserId())) |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "预警通知人员已存在"); |
| | | BeanUtils.copyProperties(reqDto, gasWarnUser); |
| | | gasWarnUser.setGmtModified(LocalDateTime.now()); |
| | | gasWarnUser.setLastmodifiedby(getCurrentUser().getRealName()); |
| | | GasWarnUser save = gasWarnUserRepository.save(gasWarnUser); |
| | | GasWarnUser gasWarnUserById = gasWarnUserRepository.findByIdAndStatus(reqDto.getId(), DeleteStatusEnum.DELECT_NO.getStatus()); |
| | | BeanUtils.copyProperties(reqDto, gasWarnUserById); |
| | | gasWarnUserById.setGmtModified(LocalDateTime.now()); |
| | | gasWarnUserById.setLastmodifiedby(getCurrentUser().getRealName()); |
| | | GasWarnUser save = gasWarnUserRepository.save(gasWarnUserById); |
| | | if (save == null) |
| | | throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(), "预警通知人员更新失败"); |
| | | }finally { |
| | |
| | | searchResult.setTotal(pageResult.getTotalElements()); |
| | | searchResult.setPages(pageResult.getTotalPages()); |
| | | if (!CollectionUtils.isEmpty(pageResult.getContent())){ |
| | | List<FindGasWarnUserPageRespDTO> respDTOS = new ArrayList<>(); |
| | | BeanUtils.copyProperties(pageResult.getContent(),respDTOS); |
| | | searchResult.setData(respDTOS); |
| | | List<FindGasWarnUserPageRespDTO> collect = pageResult.getContent().stream().map(gasWarnUser -> { |
| | | FindGasWarnUserPageRespDTO dto = new FindGasWarnUserPageRespDTO(); |
| | | BeanUtils.copyProperties(gasWarnUser, dto); |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | searchResult.setData(collect); |
| | | } |
| | | return searchResult; |
| | | } |