From 2890e81f511020d8f15e64c5d51905bea744eb9c Mon Sep 17 00:00:00 2001 From: cs <673849330@qq,com> Date: Wed, 19 Jan 2022 14:45:39 +0800 Subject: [PATCH] =?UTF-8?q?ar=E9=83=A8=E4=BB=B6=E9=80=86=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=EF=BC=8C=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../applet/biz/mapper/CityGridMapper.java | 3 +- .../biz/mapper/CommunityGridMapper.java | 3 +- .../biz/mapper/ComponentDetailMapper.java | 2 + .../applet/biz/mapper/DyGridMapper.java | 3 +- .../applet/biz/mapper/StreetGridMapper.java | 3 +- .../impl/ComponentDetailServiceImpl.java | 133 +++++++++++++----- .../biz/tencent/map/config/TxMapConfig.java | 28 ++++ .../GeoCoderInterfaceParamRequest.java | 28 ++++ .../map/core/request/GeoCoderRequest.java | 64 +++++++++ .../map/core/response/TencentMapResponse.java | 10 ++ .../map/core/response/TxMapBaseResponse.java | 18 +++ .../map/core/response/TxMapResponse.java | 77 ++++++++++ .../service/geoCoder/GeoCoderInterface.java | 17 +++ .../geoCoder/impl/GeoCoderInterfaceImpl.java | 70 +++++++++ .../vo/PatrolInspectionComponentsSumVo.java | 4 +- .../src/main/resources/application-dev.yml | 4 + .../main/resources/mapper/CityGridMapper.xml | 34 +++-- .../resources/mapper/CommunityGridMapper.xml | 30 ++-- .../mapper/ComponentDetailMapper.xml | 8 ++ .../main/resources/mapper/DyGridMapper.xml | 30 ++-- .../resources/mapper/StreetGridMapper.xml | 27 +++- .../src/test/java/com/hncy/Test.java | 65 ++++++++- 22 files changed, 593 insertions(+), 68 deletions(-) create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/config/TxMapConfig.java create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderInterfaceParamRequest.java create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderRequest.java create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TencentMapResponse.java create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapBaseResponse.java create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapResponse.java create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/GeoCoderInterface.java create mode 100644 service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/impl/GeoCoderInterfaceImpl.java diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CityGridMapper.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CityGridMapper.java index a69872c..5b08511 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CityGridMapper.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CityGridMapper.java @@ -4,6 +4,7 @@ import com.hncy.service.wechat.applet.biz.dto.CountMounthComponentDto; import com.hncy.service.wechat.applet.biz.entity.CityGrid; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hncy.service.wechat.applet.biz.entity.ComponentDetail; +import com.hncy.service.wechat.applet.biz.vo.PatrolInspectionComponentsSumVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -22,7 +23,7 @@ public interface CityGridMapper extends BaseMapper { List selectSumComponentsByMounth(@Param("dscode") String code); - List selectTodayComponentsTypeSum(@Param("dscode") String code); + List selectTodayComponentsTypeSum(@Param("dscode") String code); List selectAllTypesBySupperComponents(@Param("dscode") String code); diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CommunityGridMapper.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CommunityGridMapper.java index dc1c97b..7b1b606 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CommunityGridMapper.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/CommunityGridMapper.java @@ -4,6 +4,7 @@ import com.hncy.service.wechat.applet.biz.dto.CountMounthComponentDto; import com.hncy.service.wechat.applet.biz.entity.CommunityGrid; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hncy.service.wechat.applet.biz.entity.ComponentDetail; +import com.hncy.service.wechat.applet.biz.vo.PatrolInspectionComponentsSumVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -24,7 +25,7 @@ public interface CommunityGridMapper extends BaseMapper { List selectSumComponentsByMounth(@Param("comid") String code); - List selectTodayComponentsTypeSum(@Param("comid") String code); + List selectTodayComponentsTypeSum(@Param("comid") String code); List selectDetailComponents(@Param("comid") String code, @Param("componentCode") String componentCode, @Param("componentName") String componentName); diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/ComponentDetailMapper.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/ComponentDetailMapper.java index c74a456..10c732a 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/ComponentDetailMapper.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/ComponentDetailMapper.java @@ -44,4 +44,6 @@ public interface ComponentDetailMapper extends BaseMapper { ComponentDetail selectByComponentLogo(@Param("componentLogo") String componentLogo); + List selectComponentTypeName(); + } diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/DyGridMapper.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/DyGridMapper.java index ccf860d..00f79ee 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/DyGridMapper.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/DyGridMapper.java @@ -4,6 +4,7 @@ import com.hncy.service.wechat.applet.biz.dto.CountMounthComponentDto; import com.hncy.service.wechat.applet.biz.entity.ComponentDetail; import com.hncy.service.wechat.applet.biz.entity.DyGrid; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hncy.service.wechat.applet.biz.vo.PatrolInspectionComponentsSumVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -24,7 +25,7 @@ public interface DyGridMapper extends BaseMapper { List selectSumComponentsByMounth(@Param("bgcode") String code); - List selectTodayComponentsTypeSum(@Param("bgcode") String code); + List selectTodayComponentsTypeSum(@Param("bgcode") String code); List selectDetailComponents(@Param("bgcode") String code, @Param("componentCode") String componentCode, @Param("componentName") String componentName); diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/StreetGridMapper.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/StreetGridMapper.java index 75b38dd..8c6bf55 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/StreetGridMapper.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/mapper/StreetGridMapper.java @@ -4,6 +4,7 @@ import com.hncy.service.wechat.applet.biz.dto.CountMounthComponentDto; import com.hncy.service.wechat.applet.biz.entity.ComponentDetail; import com.hncy.service.wechat.applet.biz.entity.StreetGrid; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hncy.service.wechat.applet.biz.vo.PatrolInspectionComponentsSumVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -24,7 +25,7 @@ public interface StreetGridMapper extends BaseMapper { List selectSumComponentsByMounth(@Param("streetid") String code); - List selectTodayComponentsTypeSum(@Param("streetid") String code); + List selectTodayComponentsTypeSum(@Param("streetid") String code); List selectDetailComponents(@Param("streetid") String code, @Param("componentCode") String componentCode, @Param("componentName") String componentName); diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/service/impl/ComponentDetailServiceImpl.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/service/impl/ComponentDetailServiceImpl.java index eecc395..d8f0e22 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/service/impl/ComponentDetailServiceImpl.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/service/impl/ComponentDetailServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateTime; import cn.hutool.core.util.ObjectUtil; import com.alibaba.nacos.common.utils.CollectionUtils; +import com.alibaba.nacos.common.utils.StringUtils; import com.hncy.common.dto.ResultBean; import com.hncy.common.exception.custom.BusinessException; import com.hncy.common.exception.custom.LocalBusinessException; @@ -15,6 +16,9 @@ import com.hncy.service.wechat.applet.biz.mapper.*; import com.hncy.service.wechat.applet.biz.service.ComponentDetailService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hncy.service.wechat.applet.biz.service.ComponentsRemoteService; +import com.hncy.service.wechat.applet.biz.tencent.map.core.request.GeoCoderInterfaceParamRequest; +import com.hncy.service.wechat.applet.biz.tencent.map.core.response.TxMapResponse; +import com.hncy.service.wechat.applet.biz.tencent.map.service.geoCoder.GeoCoderInterface; import com.hncy.service.wechat.applet.biz.utils.CoordTransform; import com.hncy.service.wechat.applet.biz.utils.FastdfsClientUtil; import com.hncy.service.wechat.applet.biz.vo.*; @@ -71,6 +75,8 @@ public class ComponentDetailServiceImpl extends ServiceImpl aiScanComponentsVos = new ArrayList<>(); List componentSubsVos = new ArrayList<>(); - double[] doubles = CoordTransform.transformWGS84ToBD09(Double.valueOf(xCode), Double.valueOf(yCode)); +/* double[] doubles = CoordTransform.transformWGS84ToBD09(Double.valueOf(xCode), Double.valueOf(yCode)); String WGS84Lng = null; String WGS84Lat = null; for(int i = 0; i < doubles.length; i++) { WGS84Lng = String.valueOf(doubles[0]); WGS84Lat = String.valueOf(doubles[1]); } - log.info("经度: {}, 以及纬度: {}",WGS84Lng,WGS84Lat); - List componentDetails = componentDetailMapper.judgeAIComponentIsExist(componentTypeName,WGS84Lng,WGS84Lat); + log.info("经度: {}, 以及纬度: {}",WGS84Lng,WGS84Lat);*/ + List componentDetails = componentDetailMapper.judgeAIComponentIsExist(componentTypeName,xCode,yCode); if(CollectionUtil.isEmpty(componentDetails)) { throw new LocalBusinessException(430,componentTypeName); @@ -180,9 +186,48 @@ public class ComponentDetailServiceImpl extends ServiceImpl componentIssuesReports = componentIssuesReportMapper.selectIssueIdByComponentId(componentDetail.getId()); if(CollectionUtil.isNotEmpty(componentIssuesReports)) { componentIssuesReports.stream().forEach(componentIssuesReport -> { @@ -527,43 +572,67 @@ public class ComponentDetailServiceImpl extends ServiceImpl patrolInspectionComponentsSumVos = new ArrayList<>(); switch (type) { case ARInspectionConstants.DISTRICT: - List componentDetailsDistrict = cityGridMapper.selectTodayComponentsTypeSum(code); - Map> mapInDistrict = componentDetailsDistrict.stream().collect(Collectors.groupingBy(ComponentDetail::getComponentTypeName)); - for (String componentTypeName : mapInDistrict.keySet()) { - PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(componentTypeName); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(String.valueOf(mapInDistrict.get(componentTypeName).size())); - patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + List patrolInspectionComponentsSumVoInDistrict = cityGridMapper.selectTodayComponentsTypeSum(code); + if(CollectionUtil.isNotEmpty(patrolInspectionComponentsSumVoInDistrict)) { + patrolInspectionComponentsSumVoInDistrict.stream().forEach(patrolInspectionComponentsSumVo -> { + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); + }else { + List patrolInspectionComponentsTypeNames = componentDetailMapper.selectComponentTypeName(); + patrolInspectionComponentsTypeNames.stream().forEach(patrolInspectionComponentsTypeName ->{ + PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(patrolInspectionComponentsTypeName); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(ARInspectionConstants.ZERO); + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); } break; case ARInspectionConstants.COMMUNITY: - List componentDetailCommunity = communityGridMapper.selectTodayComponentsTypeSum(code); - Map> mapInCommunity = componentDetailCommunity.stream().collect(Collectors.groupingBy(ComponentDetail::getComponentTypeName)); - for (String componentTypeName : mapInCommunity.keySet()) { - PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(componentTypeName); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(String.valueOf(mapInCommunity.get(componentTypeName).size())); - patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + List patrolInspectionComponentsSumVosInCommunity = communityGridMapper.selectTodayComponentsTypeSum(code); + if(CollectionUtil.isNotEmpty(patrolInspectionComponentsSumVosInCommunity)) { + patrolInspectionComponentsSumVosInCommunity.stream().forEach(patrolInspectionComponentsSumVo -> { + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); + }else { + List patrolInspectionComponentsTypeNames = componentDetailMapper.selectComponentTypeName(); + patrolInspectionComponentsTypeNames.stream().forEach(patrolInspectionComponentsTypeName ->{ + PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(patrolInspectionComponentsTypeName); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(ARInspectionConstants.ZERO); + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); } break; case ARInspectionConstants.STREET: - List componentDetailStreet = streetGridMapper.selectTodayComponentsTypeSum(code); - Map> mapInStreet = componentDetailStreet.stream().collect(Collectors.groupingBy(ComponentDetail::getComponentTypeName)); - for (String componentTypeName : mapInStreet.keySet()) { - PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(componentTypeName); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(String.valueOf(mapInStreet.get(componentTypeName).size())); - patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + List patrolInspectionComponentsSumVosInStreet = streetGridMapper.selectTodayComponentsTypeSum(code); + if(CollectionUtil.isNotEmpty(patrolInspectionComponentsSumVosInStreet)) { + patrolInspectionComponentsSumVosInStreet.stream().forEach(patrolInspectionComponentsSumVo -> { + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); + }else { + List patrolInspectionComponentsTypeNames = componentDetailMapper.selectComponentTypeName(); + patrolInspectionComponentsTypeNames.stream().forEach(patrolInspectionComponentsTypeName ->{ + PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(patrolInspectionComponentsTypeName); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(ARInspectionConstants.ZERO); + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); } break; case ARInspectionConstants.GRID: - List componentDetailsDyGrid = dyGridMapper.selectTodayComponentsTypeSum(code); - Map> mapInDyGrid = componentDetailsDyGrid.stream().collect(Collectors.groupingBy(ComponentDetail::getComponentTypeName)); - for (String componentTypeName : mapInDyGrid.keySet()) { - PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(componentTypeName); - patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(String.valueOf(mapInDyGrid.get(componentTypeName).size())); - patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + List patrolInspectionComponentsSumVosInDyGrid = dyGridMapper.selectTodayComponentsTypeSum(code); + if(CollectionUtil.isNotEmpty(patrolInspectionComponentsSumVosInDyGrid)) { + patrolInspectionComponentsSumVosInDyGrid.stream().forEach(patrolInspectionComponentsSumVo -> { + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); + }else { + List patrolInspectionComponentsTypeNames = componentDetailMapper.selectComponentTypeName(); + patrolInspectionComponentsTypeNames.stream().forEach(patrolInspectionComponentsTypeName ->{ + PatrolInspectionComponentsSumVo patrolInspectionComponentsSumVo = new PatrolInspectionComponentsSumVo(); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsTypeName(patrolInspectionComponentsTypeName); + patrolInspectionComponentsSumVo.setPatrolInspectionComponentsSum(ARInspectionConstants.ZERO); + patrolInspectionComponentsSumVos.add(patrolInspectionComponentsSumVo); + }); } break; } diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/config/TxMapConfig.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/config/TxMapConfig.java new file mode 100644 index 0000000..08c3a3e --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/config/TxMapConfig.java @@ -0,0 +1,28 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.config; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * @Author: cs + * @Date: 2022/1/18 18:15 + * + * 腾讯地图配置文件 + */ +@Component +@Data +public class TxMapConfig { + + /** + * key + */ + @Value("${config.tencent.map.key}") + private String key; + /** + * url + */ + @Value("${config.tencent.map.url}") + private String url; + +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderInterfaceParamRequest.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderInterfaceParamRequest.java new file mode 100644 index 0000000..9553ef3 --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderInterfaceParamRequest.java @@ -0,0 +1,28 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.core.request; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * @Author: cs + * @Date: 2022/1/19 9:02 + * + * 逆地址解析接口请求参数 + */ +@Data +public class GeoCoderInterfaceParamRequest { + + /** + * 经度 + */ + @NotNull + private String xCode; + + /** + * 纬度 + */ + @NotNull + private String yCode; + +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderRequest.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderRequest.java new file mode 100644 index 0000000..9326342 --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/request/GeoCoderRequest.java @@ -0,0 +1,64 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.core.request; + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * @Author: cs + * @Date: 2022/1/18 16:34 + * + * 逆地址解析请求参数 + */ +@Data +public class GeoCoderRequest { + + /** + * 经纬度(GCJ02坐标系),格式: + * location=lat<纬度>,lng<经度> + */ + @NotNull + private String location; + + /** + * 是否返回周边地点(POI)列表,可选值: + * 0 不返回(默认) + * 1 返回 + */ + private String get_poi; + + /** + * 周边POI列表控制参数: + * 1 poi_options=address_format=short + * 返回短地址,缺省时返回长地址 + * 2 poi_options=radius=5000 + * 半径,取值范围 1-5000(米) + * 3 poi_options=policy=1/2/3/4/5 + * 控制返回场景, + * policy=1[默认] 以地标+主要的路+近距离POI为主,着力描述当前位置; + * policy=2 到家场景:筛选合适收货的POI,并会细化收货地址,精确到楼栋; + * policy=3 出行场景:过滤掉车辆不易到达的POI(如一些景区内POI),增加道路出入口、交叉口、大区域出入口类POI,排序会根据真实API大用户的用户点击自动优化。 + * policy=4 社交签到场景,针对用户签到的热门 地点进行优先排序。 + * policy=5 位置共享场景,用户经常用于发送位置、位置分享等场景的热门地点优先排序 + * 4 注:policy=1/2/3最多返回10条周边POI,policy=4/5最多返回20条, + */ + private String poi_options; + + /** + * 开发密钥(Key) + */ + @NotNull + private String key; + + /** + * 返回格式:支持JSON/JSONP,默认JSON + */ + private String output; + + /** + * JSONP方式回调函数 + */ + private String callback; + +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TencentMapResponse.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TencentMapResponse.java new file mode 100644 index 0000000..aaa78b2 --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TencentMapResponse.java @@ -0,0 +1,10 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.core.response; + +/** + * @Author: caosu + * @Date: 2021/5/14 + */ +public interface TencentMapResponse { + + boolean isSuccess(); +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapBaseResponse.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapBaseResponse.java new file mode 100644 index 0000000..3a45064 --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapBaseResponse.java @@ -0,0 +1,18 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.core.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @Author: cs + * @Date: 2022/1/18 16:39 + * + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TxMapBaseResponse { + + @JsonProperty("RequestId") + private String RequestId; +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapResponse.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapResponse.java new file mode 100644 index 0000000..13070e1 --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/core/response/TxMapResponse.java @@ -0,0 +1,77 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.core.response; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @Author: cs + * @Date: 2022/1/18 16:45 + * 腾讯地图响应参数 + */ +@Data +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = true) +public class TxMapResponse extends TxMapBaseResponse implements TencentMapResponse { + + + private static final String SUCCESS = "200"; + + /** + * 请求状态码(返回OK代表请求成功) + */ + private String code; + + /** + * 状态码的描述 + */ + private String message; + + /** + * 返回的数据 + */ + private T data; + + @Override + public boolean isSuccess() { + return SUCCESS.equals(code); + } + + public static TxMapResponse success() { + TxMapResponse txMapResponse = new TxMapResponse(); + txMapResponse.code = "0"; + txMapResponse.message = "success"; + return txMapResponse; + } + + public static TxMapResponse fail(String code, String message) { + TxMapResponse txMapResponse = new TxMapResponse(); + txMapResponse.code = code; + txMapResponse.message = message; + return txMapResponse; + } + + public static TxMapResponse success(T data) { + TxMapResponse txMapResponse = new TxMapResponse(); + txMapResponse.code = SUCCESS; + txMapResponse.data = data; + txMapResponse.message = "success"; + return txMapResponse; + } + + public static TxMapResponse success(String code, String message) { + TxMapResponse txMapResponse = new TxMapResponse(); + txMapResponse.code = code; + txMapResponse.message = message; + return txMapResponse; + } + + public static TxMapResponse success(String code, String message, T data) { + TxMapResponse txMapResponse = new TxMapResponse(); + txMapResponse.code = code; + txMapResponse.message = message; + txMapResponse.data = data; + return txMapResponse; + } + +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/GeoCoderInterface.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/GeoCoderInterface.java new file mode 100644 index 0000000..e53d0a6 --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/GeoCoderInterface.java @@ -0,0 +1,17 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.service.geoCoder; + + +import com.hncy.service.wechat.applet.biz.tencent.map.core.request.GeoCoderInterfaceParamRequest; +import com.hncy.service.wechat.applet.biz.tencent.map.core.request.GeoCoderRequest; +import com.hncy.service.wechat.applet.biz.tencent.map.core.response.TxMapResponse; + +/** + * @Author: cs + * @Date: 2022/1/19 8:53 + * + * 地址逆解析接口 + */ +public interface GeoCoderInterface { + + TxMapResponse closeOrder(GeoCoderInterfaceParamRequest geoCoderInterfaceParamRequest) throws Exception; +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/impl/GeoCoderInterfaceImpl.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/impl/GeoCoderInterfaceImpl.java new file mode 100644 index 0000000..156a77f --- /dev/null +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/tencent/map/service/geoCoder/impl/GeoCoderInterfaceImpl.java @@ -0,0 +1,70 @@ +package com.hncy.service.wechat.applet.biz.tencent.map.service.geoCoder.impl; + +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.hncy.jackson.spring.boot.starter.core.JSONObject; +import com.hncy.service.wechat.applet.biz.constants.ARInspectionConstants; +import com.hncy.service.wechat.applet.biz.tencent.map.config.TxMapConfig; +import com.hncy.service.wechat.applet.biz.tencent.map.core.request.GeoCoderInterfaceParamRequest; +import com.hncy.service.wechat.applet.biz.tencent.map.core.request.GeoCoderRequest; +import com.hncy.service.wechat.applet.biz.tencent.map.core.response.TxMapResponse; +import com.hncy.service.wechat.applet.biz.tencent.map.service.geoCoder.GeoCoderInterface; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: cs + * @Date: 2022/1/19 8:55 + */ +@Service +@Slf4j +public class GeoCoderInterfaceImpl implements GeoCoderInterface { + + @Autowired + private TxMapConfig txMapConfig; + + private final String GEO_CODER= "/ws/geocoder/v1"; + + private final String json = "json"; + + private final String FUNCTION1 = "function1"; + private final String POLICY = "policy=2"; + + @Override + public TxMapResponse closeOrder(GeoCoderInterfaceParamRequest geoCoderInterfaceParamRequest) throws Exception { + + String host = txMapConfig.getUrl() + GEO_CODER; + + GeoCoderRequest geoCoderRequest = new GeoCoderRequest(); + geoCoderRequest.setKey(txMapConfig.getKey()); + StringBuffer buffer = new StringBuffer(); + StringBuffer location = buffer.append(geoCoderInterfaceParamRequest.getYCode()).append(",").append(geoCoderInterfaceParamRequest.getXCode()); + geoCoderRequest.setLocation(location.toString()); + geoCoderRequest.setGet_poi(ARInspectionConstants.ZERO); + geoCoderRequest.setPoi_options(POLICY); + geoCoderRequest.setOutput(json); + geoCoderRequest.setCallback(FUNCTION1); + String geoCoderRequestToJSONString = JSONObject.getInstance().toJSONString(geoCoderRequest); + + Map map = new HashMap<>(); + map.put("Content-Type", "application/json;charset=UTF-8"); + map.put("Connection", "keep-alive"); + + HttpResponse httpRequest = HttpRequest.get(host).addHeaders(map).body(geoCoderRequestToJSONString).setReadTimeout(3000).setConnectionTimeout(3000).execute(); + String bodyToJSON = JSONObject.getInstance().toJSONString(httpRequest.body()); + Map jsonToMap = (Map) JSON.parse(bodyToJSON); + Integer status = Integer.parseInt(jsonToMap.get("status").toString()); + Map result = (Map) JSON.parse(jsonToMap.get("result").toString()); + if(0 == status) { + String address = result.get("address"); + return TxMapResponse.success(address); + }else { + return TxMapResponse.fail(jsonToMap.get("status").toString(),jsonToMap.get("message").toString()); + } + } +} diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/vo/PatrolInspectionComponentsSumVo.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/vo/PatrolInspectionComponentsSumVo.java index 7a81771..ef9d1a1 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/vo/PatrolInspectionComponentsSumVo.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/java/com/hncy/service/wechat/applet/biz/vo/PatrolInspectionComponentsSumVo.java @@ -18,9 +18,9 @@ import lombok.NoArgsConstructor; public class PatrolInspectionComponentsSumVo { @ApiModelProperty(value = "巡检部件类别名字") - private String PatrolInspectionComponentsTypeName; + private String patrolInspectionComponentsTypeName; @ApiModelProperty(value = "每类巡检部件类别的总数") - private String PatrolInspectionComponentsSum; + private String patrolInspectionComponentsSum; } diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/application-dev.yml b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/application-dev.yml index 5c56736..881f05e 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/application-dev.yml +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/application-dev.yml @@ -35,6 +35,10 @@ spring: password: hncy@123 config: + tencent: + map: + key: QP4BZ-GQQLU-HDTVE-BJKQA-YDXEF-73B65 + url: https://apis.map.qq.com auth: applet: app-id: wxdfc87bf791f77464 diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CityGridMapper.xml b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CityGridMapper.xml index e24b3ea..dc9a868 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CityGridMapper.xml +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CityGridMapper.xml @@ -19,6 +19,13 @@ + + + + + + + dscode, dsname, shape, bd_shape, gd_shape, area, perimeter, shape_leng, shape_area @@ -29,6 +36,7 @@ WHERE Contains(c.shape , ST_GeomFromText(concat('Point(', t.x_code, ' ', t.y_code , ')'))) AND t.deleted = '0' AND c.dscode = #{dscode} + AND t.component_logo IS NOT NULL - + + diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CommunityGridMapper.xml b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CommunityGridMapper.xml index 5c5d290..c261a9f 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CommunityGridMapper.xml +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/CommunityGridMapper.xml @@ -19,6 +19,11 @@ + + + + + comid, comname, shape, bd_shape, gd_shape, area, perimeter, shape_leng, shape_area, dscode, dsname, streetid, streetname @@ -37,6 +42,7 @@ WHERE Contains(c.shape , ST_GeomFromText(concat('Point(', t.x_code, ' ', t.y_code , ')'))) AND t.deleted = '0' AND c.comid = #{comid} + AND t.component_logo IS NOT NULL - + diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/ComponentDetailMapper.xml b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/ComponentDetailMapper.xml index 27bed58..da50417 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/ComponentDetailMapper.xml +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/ComponentDetailMapper.xml @@ -111,17 +111,20 @@ SELECT COUNT(*) FROM component_detail WHERE DATEDIFF (patrol_inspection_time, NOW()) = 0 AND create_by = #{collectorOpenId} + AND component_logo IS NOT NULL + diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/DyGridMapper.xml b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/DyGridMapper.xml index aed4400..797a600 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/DyGridMapper.xml +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/DyGridMapper.xml @@ -20,6 +20,11 @@ + + + + + bgcode, shape, bd_shape, gd_shape, area, perimeter, shape_leng, shape_area, dscode, dsname, streetid, streetname, comid, comname @@ -38,6 +43,7 @@ WHERE Contains(d.shape , ST_GeomFromText(concat('Point(', t.x_code, ' ', t.y_code , ')'))) AND t.deleted = '0' AND d.bgcode = #{bgcode} + AND t.component_logo IS NOT NULL - + diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/StreetGridMapper.xml b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/StreetGridMapper.xml index db77e0f..97ab478 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/StreetGridMapper.xml +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/main/resources/mapper/StreetGridMapper.xml @@ -17,6 +17,11 @@ + + + + + streetid, streetname, shape, bd_shape, gd_shape, area, perimeter, shape_leng, shape_area, dscode, dsname @@ -35,6 +40,7 @@ WHERE Contains(s.shape , ST_GeomFromText(concat('Point(', t.x_code, ' ', t.y_code , ')'))) AND t.deleted = '0' AND s.streetid = #{streetid} + AND t.component_logo IS NOT NULL - + AND t.component_logo IS NOT NULL + --> + diff --git a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/test/java/com/hncy/Test.java b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/test/java/com/hncy/Test.java index 65b4f7e..72029ef 100644 --- a/service-biz/service-wechat-applet/service-wechat-applet-biz/src/test/java/com/hncy/Test.java +++ b/service-biz/service-wechat-applet/service-wechat-applet-biz/src/test/java/com/hncy/Test.java @@ -1,19 +1,23 @@ package com.hncy; -import com.hncy.service.wechat.applet.biz.ArxjWxAppletApplication; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.hncy.jackson.spring.boot.starter.core.JSONObject; import com.hncy.service.wechat.applet.biz.mapper.CityGridMapper; import com.hncy.service.wechat.applet.biz.mapper.CommunityGridMapper; import com.hncy.service.wechat.applet.biz.mapper.DyGridMapper; import com.hncy.service.wechat.applet.biz.mapper.StreetGridMapper; +import com.hncy.service.wechat.applet.biz.tencent.map.core.request.GeoCoderInterfaceParamRequest; +import com.hncy.service.wechat.applet.biz.tencent.map.core.request.GeoCoderRequest; import com.hncy.service.wechat.applet.biz.utils.CoordTransform; import com.hncy.service.wechat.applet.biz.vo.ComponentLocation; -import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /*@SpringBootTest(classes = ArxjWxAppletApplication.class) @RunWith(SpringRunner.class)*/ @@ -28,6 +32,8 @@ public class Test { @Autowired private DyGridMapper dyGridMapper; + private final String GEO_CODER= "/ws/geocoder/v1"; + @org.junit.Test public void ToBaiDu() { double x = 103.84864995148352; @@ -72,4 +78,55 @@ public class Test { System.out.println(JQscore); } + @org.junit.Test + public void geoTest() throws Exception { + String xCode = "104.07376798060986"; + String yCode = "30.55524478797796"; + String WGS84Lng = null; + String WGS84Lat = null; + //百度转gcj-02 + double[] doubles = CoordTransform.transformBD09ToGCJ02(Double.valueOf(xCode), Double.valueOf(yCode)); + for(int i = 0; i < doubles.length; i++) { + WGS84Lng = String.valueOf(doubles[0]); + WGS84Lat = String.valueOf(doubles[1]); + } + + GeoCoderInterfaceParamRequest geoCoderInterfaceParamRequest = new GeoCoderInterfaceParamRequest(); + geoCoderInterfaceParamRequest.setXCode(WGS84Lng); + geoCoderInterfaceParamRequest.setYCode(WGS84Lat); + + String host = "https://apis.map.qq.com" + GEO_CODER; + + GeoCoderRequest geoCoderRequest = new GeoCoderRequest(); + geoCoderRequest.setKey("QP4BZ-GQQLU-HDTVE-BJKQA-YDXEF-73B65"); + StringBuffer buffer = new StringBuffer(); + StringBuffer location = buffer.append(geoCoderInterfaceParamRequest.getYCode()).append(",").append(geoCoderInterfaceParamRequest.getXCode()); + geoCoderRequest.setLocation(location.toString()); + geoCoderRequest.setGet_poi("0"); + geoCoderRequest.setPoi_options("policy=2"); + geoCoderRequest.setOutput("json"); + geoCoderRequest.setCallback("function1"); + String geoCoderRequestToJSONString = JSONObject.getInstance().toJSONString(geoCoderRequest); + + + Map map = new HashMap<>(); + map.put("Content-Type", "application/json;charset=UTF-8"); + map.put("Connection", "keep-alive"); + + HttpResponse httpRequest = HttpRequest.get(host).addHeaders(map).body(geoCoderRequestToJSONString).setReadTimeout(3000).setConnectionTimeout(3000).execute(); + String bodyToJSON = JSONObject.getInstance().toJSONString(httpRequest.body()); + System.out.println(bodyToJSON); + + Map jsonToMap = (Map) JSON.parse(bodyToJSON); + Integer status = Integer.parseInt(jsonToMap.get("status").toString()); + Map result = (Map) JSON.parse(jsonToMap.get("result").toString()); + if(0 == status) { + String address = result.get("address"); + System.out.println(address); + }else { + System.out.println(jsonToMap.get("status")); + } + } + + } -- GitLab