| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.community.convenient.ConvenientElevatingPointDTO; |
| | | import com.panzhihua.common.model.dtos.community.convenient.ConvenientMerchantDTO; |
| | | import com.panzhihua.common.model.dtos.community.convenient.PageConvenientElevatingPointDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.convenient.ConvenientElevatingPointVO; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ConvenientElevatingPointDAO; |
| | | import com.panzhihua.service_community.dao.ConvenientMerchantDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ConvenientElevatingPointDO; |
| | | import com.panzhihua.service_community.model.dos.ConvenientMerchantDO; |
| | | import com.panzhihua.service_community.model.dos.ConvenientServiceCategoryDO; |
| | | import com.panzhihua.service_community.service.ConvenientElevatingPointService; |
| | | import com.panzhihua.service_community.util.MapDistance; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | | import static org.apache.commons.lang3.StringUtils.isNotBlank; |
| | | |
| | | /** |
| | | * @ClassName: ConvenientElevatingPointServiceImpl |
| | |
| | | public class ConvenientElevatingPointServiceImpl extends ServiceImpl<ConvenientElevatingPointDAO, ConvenientElevatingPointDO> implements ConvenientElevatingPointService { |
| | | @Resource |
| | | private ComActDAO comActDAO; |
| | | @Resource |
| | | private ConvenientMerchantDAO convenientMerchantDAO; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param pageConvenientElevatingPointDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 新增 |
| | | * |
| | | * @param convenientElevatingPointDTO |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改 |
| | | * |
| | | * @param convenientElevatingPointDTO |
| | | * @return |
| | | */ |
| | |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = this.baseMapper.selectById(pointId); |
| | | return R.ok(convenientElevatingPointDO); |
| | | } |
| | | |
| | | public R findPointByMerchantId(Long merchantId, String lat, String lng) { |
| | | ConvenientMerchantDO convenientMerchantDO = convenientMerchantDAO.selectById(merchantId); |
| | | //服务最远距离 km |
| | | Integer serviceRange = convenientMerchantDO.getServiceRange(); |
| | | |
| | | Map<Object, Object> around = MapDistance.getAround(convenientMerchantDO.getLat(), convenientMerchantDO.getLon(), serviceRange * 1000 + ""); |
| | | String maxLat = around.get("maxLat").toString(); |
| | | String minLat = around.get("minLat").toString(); |
| | | String minLng = around.get("minLng").toString(); |
| | | String maxLng = around.get("maxLng").toString(); |
| | | List<ConvenientElevatingPointDO> convenientElevatingPointDOS = this.baseMapper.selectList( |
| | | new LambdaQueryWrapper<ConvenientElevatingPointDO>() |
| | | .ge(ConvenientElevatingPointDO::getLat, minLng) |
| | | .le(ConvenientElevatingPointDO::getLat, maxLng) |
| | | .ge(ConvenientElevatingPointDO::getLon, minLat) |
| | | .le(ConvenientElevatingPointDO::getLon, maxLat)); |
| | | List<ConvenientElevatingPointVO> convenientElevatingPointVOS = new ArrayList<>(); |
| | | convenientElevatingPointDOS.forEach(f -> { |
| | | ConvenientElevatingPointVO convenientElevatingPointVO = new ConvenientElevatingPointVO(); |
| | | BeanUtils.copyProperties(f, convenientElevatingPointVO); |
| | | Double distance = MapDistance.distanceOfTwoPoints(lng, lat, f.getLon(), f.getLat()); |
| | | convenientElevatingPointVO.setDistance(distance); |
| | | convenientElevatingPointVOS.add(convenientElevatingPointVO); |
| | | }); |
| | | return R.ok(convenientElevatingPointVOS); |
| | | |
| | | } |
| | | } |