From d4020168658efdee89a633083cd9c14b06c4d863 Mon Sep 17 00:00:00 2001 From: zhangf <1603559716@qq.com> Date: 星期三, 11 九月 2024 17:09:10 +0800 Subject: [PATCH] 修改消息推送时间间隔 --- src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java index 8678626..6eadae7 100644 --- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/RegionServiceImpl.java @@ -12,6 +12,7 @@ import com.gkhy.fourierSpecialGasMonitor.entity.RegionLngLat; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindRegionPageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.req.*; +import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionByIdLngLatRespDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionByIdRespDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionLngLatPageRespDTO; import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindRegionPageRespDTO; @@ -135,12 +136,18 @@ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空"); Region region = regionRepository.findByIdAndStatus(id, DeleteStatusEnum.DELECT_NO.getStatus()); if (region != null){ + FindRegionByIdRespDTO findRegionByIdRespDTO = new FindRegionByIdRespDTO(); + BeanUtils.copyProperties(region,findRegionByIdRespDTO); List<RegionLngLat> regionLngLats = region.getRegionLngLats(); if (!CollectionUtils.isEmpty(regionLngLats)){ - List<FindRegionByIdRespDTO> respDTOS = new ArrayList<>(); - BeanUtils.copyProperties(regionLngLats,respDTOS); - success.setData(respDTOS); + List<FindRegionByIdLngLatRespDTO> collect = regionLngLats.stream().map(regionLngLat -> { + FindRegionByIdLngLatRespDTO findRegionByIdLngLatRespDTO = new FindRegionByIdLngLatRespDTO(); + BeanUtils.copyProperties(regionLngLat, findRegionByIdLngLatRespDTO); + return findRegionByIdLngLatRespDTO; + }).collect(Collectors.toList()); + findRegionByIdRespDTO.setLngLatRespDTOS(collect); } + success.setData(findRegionByIdRespDTO); } return success; } @@ -159,7 +166,7 @@ if (searchParams != null && !StringUtils.isBlank(searchParams.getName())){ predicateList.add(criteriaBuilder.like(root.get("name").as(String.class),"%"+searchParams.getName()+"%")); } - predicateList.add(criteriaBuilder.equal(root.get("deleteStatus").as(Byte.class), DeleteStatusEnum.DELECT_NO.getStatus())); + predicateList.add(criteriaBuilder.equal(root.get("status").as(Byte.class), DeleteStatusEnum.DELECT_NO.getStatus())); return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); } }; @@ -174,9 +181,14 @@ List<FindRegionPageRespDTO> dtos = pageResult.getContent().stream().map(region -> { FindRegionPageRespDTO dto = new FindRegionPageRespDTO(); BeanUtils.copyProperties(region, dto); - List<FindRegionLngLatPageRespDTO> regionLngLatPageRespDTOS = new ArrayList<>(); - BeanUtils.copyProperties(region.getRegionLngLats(), regionLngLatPageRespDTOS); - dto.setRegionLngLats(regionLngLatPageRespDTOS); + if (!CollectionUtils.isEmpty(region.getRegionLngLats())) { + List<FindRegionLngLatPageRespDTO> collect = region.getRegionLngLats().stream().map(regionLngLat -> { + FindRegionLngLatPageRespDTO findRegionLngLatPageRespDTO = new FindRegionLngLatPageRespDTO(); + BeanUtils.copyProperties(regionLngLat, findRegionLngLatPageRespDTO); + return findRegionLngLatPageRespDTO; + }).collect(Collectors.toList()); + dto.setRegionLngLats(collect); + } return dto; }).collect(Collectors.toList()); searchResult.setData(dtos); @@ -188,8 +200,11 @@ @Transactional public Result updateRegion(UpdateRegionReqDTO reqDto) { User currentUser = getCurrentUser(); - if (reqDto == null) + if (reqDto == null || reqDto.getId() == null) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"参数不能为空"); + Region region = regionRepository.findByIdAndStatus(reqDto.getId(), DeleteStatusEnum.DELECT_NO.getStatus()); + if (region == null) + throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"区域不存在"); if (StringUtils.isBlank(reqDto.getName())) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"区域名称为空"); if (StringUtils.isBlank(reqDto.getColor())) @@ -201,10 +216,12 @@ Region regionold = findByNameAndStatus(reqDto.getName()); if (regionold != null && !regionold.getId().equals(reqDto.getId())) throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(), "区域名称已存在"); - regionold.setName(reqDto.getName()); - regionold.setColor(reqDto.getColor()); - regionold.setLastmodifiedby(currentUser.getRealName()); - regionold.setGmtModified(LocalDateTime.now()); + region.setName(reqDto.getName()); + region.setColor(reqDto.getColor()); + region.setLastmodifiedby(currentUser.getRealName()); + region.setGmtModified(LocalDateTime.now()); + if (regionRepository.save(region) == null) + throw new BusinessException(this.getClass(), ResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"区域保存失败"); regionLngLatRepository.deleteAllByRegionId(reqDto.getId()); List<UpdateRegionLngLatReqDTO> regionLngLats = reqDto.getRegionLngLats(); List<RegionLngLat> collect = regionLngLats.stream().map(regionLngLat -> { -- Gitblit v1.9.2