forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-10 76f4b32326c77b6a3b6742ab5d72f0b02320b62f
1、小程序提交,根据经纬度查询问题属地
5 files added
7 files modified
465 ■■■■■ changed files
dyh-service/dyh-base/src/main/java/cn/huge/module/sys/dto/QueAddrBaseDTO.java 61 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java 21 ●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/client/api/SysClient.java 10 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/client/api/impl/SysClientImpl.java 23 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/controller/client/SyregionClientController.java 78 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/controller/web/SyRegionWebController.java 18 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/domain/dto/CauseSelectJSDTO.java 4 ●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/domain/dto/RegionSelectJSDTO.java 37 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/domain/dto/RegionSelectSaveDTO.java 27 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/service/SyRegionService.java 33 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/utils/BaiduMapAddrDTO.java 65 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/java/cn/huge/module/utils/BaiduMapUtils.java 88 ●●●● patch | view | raw | blame | history
dyh-service/dyh-base/src/main/java/cn/huge/module/sys/dto/QueAddrBaseDTO.java
New file
@@ -0,0 +1,61 @@
package cn.huge.module.sys.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
 * @title: 问题属地数据传输类
 * @description: 问题属地数据传输类
 * @company:hugeinfo
 * @author: liyj
 * @time: 2024-09-09 14:31:22
 * @version 1.0.0
 */
@Data
public class QueAddrBaseDTO {
    /**
     * 问题属地省
     */
    private String queProv;
    /**
     * 问题属地省名称
     */
    private String queProvName;
    /**
     * 问题属地市
     */
    private String queCity;
    /**
     * 问题属地市名称
     */
    private String queCityName;
    /**
     * 问题属地区
     */
    private String queArea;
    /**
     * 问题属地区名称
     */
    private String queAreaName;
    /**
     * 问题属地街道
     */
    private String queRoad;
    /**
     * 问题属地街道名称
     */
    private String queRoadName;
}
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java
@@ -18,8 +18,10 @@
import cn.huge.module.mediate.constant.CaseBaseConstsEnum;
import cn.huge.module.cust.dto.CtUserDTO;
import cn.huge.module.draft.service.CasedraftInfoService;
import cn.huge.module.mediate.constant.CaseProcessBaseConstsEnum;
import cn.huge.module.mediate.dto.WechatBindCaseDTO;
import cn.huge.module.sys.dto.FileIdTypeInfoBaseDTO;
import cn.huge.module.sys.dto.QueAddrBaseDTO;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -557,9 +559,10 @@
                caseInfo.setLat(pointXY.getLat()+"");
                caseInfo.setLng(pointXY.getLon()+"");
            }
            //todo case_ref生成、case_title生成
            //todo case_title生成
            caseInfo.setCaseRef(utilsClient.createCaseRef());
            // 为了演示先兼容小程序没属地问题,写死属地
            if (caseInfo.getQueProvName() == null) {
            if (ObjectUtils.isEmpty(caseInfo.getQueProv())) {
                caseInfo.setQueProv("19");
                caseInfo.setQueProvName("广东");
                caseInfo.setQueCity("1601");
@@ -569,6 +572,16 @@
                caseInfo.setQueRoad("62857");
                caseInfo.setQueRoadName("新市街道");
                // 根据经纬度查询问题属地
//                QueAddrBaseDTO queAddrBaseDTO = sysClient.getQueAddrByBaiduiLngLat(caseInfo.getLng(), caseInfo.getLat());
//                caseInfo.setQueProv(queAddrBaseDTO.getQueProv());
//                caseInfo.setQueProvName(queAddrBaseDTO.getQueProvName());
//                caseInfo.setQueCity(queAddrBaseDTO.getQueCity());
//                caseInfo.setQueCityName(queAddrBaseDTO.getQueCityName());
//                caseInfo.setQueArea(queAddrBaseDTO.getQueArea());
//                caseInfo.setQueAreaName(queAddrBaseDTO.getQueAreaName());
//                caseInfo.setQueRoad(queAddrBaseDTO.getQueRoad());
//                caseInfo.setQueRoadName(queAddrBaseDTO.getQueRoadName());
            }
            caseInfoUnfold.setId(caseInfo.getId());
            caseInfoUnfold.setCreateTime(nowDate);
@@ -580,10 +593,6 @@
            caseInfo.setPagents(pagents.toString());
            caseInfo.setDefendants(defendants.toString());
            caseInfo.setDagents(dagents.toString());
            caseInfo.setInfoProcess(1);
            caseInfo.setInfoProcessName("待受理");
            caseInfo.setProcess(1);
            caseInfo.setProcessName("来访登记");
            this.saveOrUpdate(caseInfo);
            // 启动工作流-自动调度流程
dyh-service/dyh-mediate/src/main/java/cn/huge/module/client/api/SysClient.java
@@ -65,4 +65,14 @@
     */
    @PostMapping("/api/client/fileRelate/removeFileRelate")
    ReturnBO removeFileRelate(@RequestBody FileTypeTermsDTO fileTypeTermsDTO);
    /**
     * 根据百度地图经纬度获取街道
     * @url {ctx}/api/client/syRegion/getQueAddrByBaiduiLngLat
     * @param lng 经度
     * @param lat 维度
     * @return
     */
    @GetMapping("/api/client/syRegion/getQueAddrByBaiduiLngLat")
    ReturnBO getQueAddrByBaiduiLngLat(@RequestParam(value = "lng") String lng, @RequestParam(value = "lat") String lat);
}
dyh-service/dyh-mediate/src/main/java/cn/huge/module/client/api/impl/SysClientImpl.java
@@ -6,6 +6,7 @@
import cn.huge.base.common.exception.ServiceException;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.module.client.api.SysClient;
import cn.huge.module.cust.dto.CtUserDTO;
import cn.huge.module.sys.dto.*;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -146,4 +147,26 @@
            log.error("service方法[SysClientImpl.removeFileRelate]请求异常:"+e, e);
        }
    }
    /**
     * 根据百度地图经纬度获取街道
     * @url {ctx}/api/client/syRegion/getTownByBaiduiLngLat
     * @param lng 经度
     * @param lat 维度
     * @return
     */
    public QueAddrBaseDTO getQueAddrByBaiduiLngLat(String lng, String lat){
        QueAddrBaseDTO queAddrBaseDTO = new QueAddrBaseDTO();
        try{
            ReturnBO returnBo = sysClient.getQueAddrByBaiduiLngLat(lng, lat);
            if (ReturnConsts.OK == returnBo.getCode()){
                if (ObjectUtils.isNotEmpty(returnBo.getData())){
                    queAddrBaseDTO = objectMapper.convertValue(returnBo.getData(), QueAddrBaseDTO.class);
                }
            }
        }catch (Exception e){
            log.error("service方法[SysClientImpl.getQueAddrByBaiduiLngLat]调用异常:"+e, e);
        }
        return queAddrBaseDTO;
    }
}
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/controller/client/SyregionClientController.java
New file
@@ -0,0 +1,78 @@
package cn.huge.module.kind.controller.client;
import cn.huge.base.common.utils.ObjectUtils;
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.module.kind.domain.po.SyRegion;
import cn.huge.module.kind.service.SyRegionService;
import cn.huge.module.sys.dto.QueAddrBaseDTO;
import cn.huge.module.utils.BaiduMapAddrDTO;
import cn.huge.module.utils.BaiduMapUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
 * @title: 地域表接口api-web端
 * @description: 地域表接口api-web端
 * @company: hugeinfo
 * @author: wangwh
 * @time: 2024-09-04 16:48:57
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/client/syRegion")
public class SyregionClientController {
    @Autowired(required = false)
    private HttpServletRequest request;
    @Autowired
    private SyRegionService service;
    /**
     * 根据百度地图经纬度获取街道
     * @url {ctx}/api/client/syRegion/getQueAddrByBaiduiLngLat
     * @param lng 经度
     * @param lat 维度
     * @return
     */
    @GetMapping("/getQueAddrByBaiduiLngLat")
    public Object getQueAddrByBaiduiLngLat(@RequestParam(value = "lng") String lng, @RequestParam(value = "lat") String lat) {
        try {
            QueAddrBaseDTO syRegionBaseDTO = new QueAddrBaseDTO();
            BaiduMapAddrDTO baiduMapAddrDTO = BaiduMapUtils.getAddrByLngLat(lng, lat, BaiduMapUtils.coordtype_bd09ll);
            if (ObjectUtils.isNotEmpty(baiduMapAddrDTO)) {
                QueryWrapper<SyRegion> syRegionQueryWrapper = new QueryWrapper<>();
                // 查询省
                syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getProvince());
                SyRegion province = service.getOne(syRegionQueryWrapper);
                syRegionBaseDTO.setQueProv(province.getId());
                syRegionBaseDTO.setQueProvName(province.getName());
                // 查询市
                syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getCity());
                SyRegion city = service.getOne(syRegionQueryWrapper);
                syRegionBaseDTO.setQueProv(city.getId());
                syRegionBaseDTO.setQueProvName(city.getName());
                // 查询区
                syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getDistrict());
                SyRegion district = service.getOne(syRegionQueryWrapper);
                syRegionBaseDTO.setQueProv(district.getId());
                syRegionBaseDTO.setQueProvName(district.getName());
                // 查询街道
                syRegionQueryWrapper.eq("name", baiduMapAddrDTO.getTown());
                SyRegion town = service.getOne(syRegionQueryWrapper);
                syRegionBaseDTO.setQueProv(town.getId());
                syRegionBaseDTO.setQueProvName(town.getName());
            }
            return ReturnSucUtils.getRepInfo(syRegionBaseDTO);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
}
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/controller/web/SyRegionWebController.java
@@ -2,6 +2,8 @@
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.module.kind.domain.dto.RegionSelectJSDTO;
import cn.huge.module.kind.domain.dto.RegionSelectSaveDTO;
import cn.huge.module.kind.domain.po.SyRegion;
import cn.huge.module.kind.service.SyRegionService;
import com.google.common.collect.Maps;
@@ -167,4 +169,20 @@
        }
    }
    /**
     * js数据入库
     * @url {ctx}/api/web/syRegion/saveByJS
     * @param regionSelectJSDTO 实体对象
     * @return Object
     */
    @PostMapping("/saveByJS")
    public Object saveByJS(@RequestBody RegionSelectSaveDTO regionSelectJSDTO) {
        try {
            service.webSaveByJSTree(regionSelectJSDTO.getRegionList(), regionSelectJSDTO.getStartLevel());
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
}
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/domain/dto/CauseSelectJSDTO.java
@@ -5,8 +5,8 @@
import java.util.List;
/**
 * @title: 前端下拉框js数据传输类
 * @description: 前端下拉框js数据传输类
 * @title: 前端下拉框js数据传输类-纠纷类型
 * @description: 前端下拉框js数据传输类-纠纷类型
 * @company: hugeinfo
 * @author: liyj
 * @time: 2022-02-23 14:19:43
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/domain/dto/RegionSelectJSDTO.java
New file
@@ -0,0 +1,37 @@
package cn.huge.module.kind.domain.dto;
import lombok.Data;
import java.util.List;
/**
 * @title: 前端下拉框js数据传输类-地域
 * @description: 前端下拉框js数据传输类-地域
 * @company: hugeinfo
 * @author: liyj
 * @time: 2022-02-23 14:19:43
 * @version: 1.0.0
 */
@Data
public class RegionSelectJSDTO {
    /**
     * 名称
     */
    private String label;
    /**
     * 代码
     */
    private String value;
    /**
     * 父级编号,根级默认root
     */
    private String parentId;
    /**
     * 子数组
     */
    private List<RegionSelectJSDTO> children;
}
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/domain/dto/RegionSelectSaveDTO.java
New file
@@ -0,0 +1,27 @@
package cn.huge.module.kind.domain.dto;
import lombok.Data;
import java.util.List;
/**
 * @title: 前端下拉框js数据传输类-地域
 * @description: 前端下拉框js数据传输类-地域
 * @company: hugeinfo
 * @author: liyj
 * @time: 2022-02-23 14:19:43
 * @version: 1.0.0
 */
@Data
public class RegionSelectSaveDTO {
    /**
     * 开始层级
     */
    private int startLevel;
    /**
     * js数据
     */
    private List<RegionSelectJSDTO> regionList;
}
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/service/SyRegionService.java
@@ -5,8 +5,10 @@
import cn.huge.base.common.utils.IdUtils;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import cn.huge.module.kind.dao.mapper.SyRegionMapper;
import cn.huge.module.kind.domain.dto.RegionSelectJSDTO;
import cn.huge.module.kind.domain.po.SyRegion;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
@@ -17,6 +19,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.swing.plaf.synth.Region;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -130,4 +133,34 @@
        }
    }
    /**
     * 递归保存树形结构
     * @param childrenList
     * @param level
     */
    public void webSaveByJSTree(List<RegionSelectJSDTO> childrenList, int level){
        try{
            Date nowDate = new Date();
            for (RegionSelectJSDTO regionSelectJSDTO: childrenList){
                SyRegion region = new SyRegion();
                region.setId(regionSelectJSDTO.getValue());
                region.setKind(level);
                region.setName(regionSelectJSDTO.getLabel());
                region.setLevel(level);
                region.setParentId(regionSelectJSDTO.getParentId());
                region.setCreateTime(nowDate);
                region.setUpdateTime(nowDate);
                this.saveOrUpdate(region);
                if (CollectionUtils.isNotEmpty(regionSelectJSDTO.getChildren())) {
                    this.webSaveByJSTree(regionSelectJSDTO.getChildren(), level + 1);
                }
            }
        }catch (Exception e){
            log.error("[SyRegionService.webSaveByJSTree]调用失败,异常信息:"+e, e);
            throw new ServiceException("SyRegionService.webSaveByJSTree", e);
        }
    }
}
dyh-service/dyh-sys/src/main/java/cn/huge/module/utils/BaiduMapAddrDTO.java
New file
@@ -0,0 +1,65 @@
package cn.huge.module.utils;
import cn.huge.module.sy.domain.po.SyTimeLimit;
import lombok.Data;
/**
 * @title: 百度地图逆地理编码地址对象
 * @description: 百度地图逆地理编码地址对象
 * @company: hugeinfo
 * @author: wangwh
 * @time: 2024-09-04 16:48:57
 * @version: 1.0.0
 * @see SyTimeLimit
 */
@Data
public class BaiduMapAddrDTO {
    /**
     * 识别地址
     */
    String formattedAddress;
    /**
     * 国家
     */
    String country;
    /**
     * 省
     */
    String province;
    /**
     * 市
     */
    String city;
    /**
     * 区
     */
    String district;
    /**
     * 街道
     */
    String town;
    /**
     * 路
     */
    String street;
    /**
     * 路
     */
    String streetNumber;
    /**
     * 拼接地址
     */
    String addr;
}
dyh-service/dyh-sys/src/main/java/cn/huge/module/utils/BaiduMapUtils.java
@@ -3,6 +3,7 @@
import cn.huge.base.common.utils.HttpClientUtils;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
@@ -14,20 +15,32 @@
 * @time: 2021-11-05 16:51:48
 * @version: 1.0.0
 */
@Slf4j
public class BaiduMapUtils {
    public static void main(String[] args) {
        getAddrByLngLat("113.26315561512126", "23.205265046387627", coordtype_bd09ll);
    }
    /**
     * 坐标类型,目前支持的坐标类型包括:bd09ll(百度经纬度坐标)、bd09mc(百度米制坐标)、gcj02ll(国测局经纬度坐标,仅限中国)、wgs84ll( GPS经纬度)
     */
    public static final String coordtype_bd09ll = "bd09ll";
    public static final String coordtype_bd09mc = "bd09mc";
    public static final String coordtype_gcj02ll = "gcj02ll";
    public static final String coordtype_wgs84ll = "wgs84ll";
    /**
     * 百度APi参数
     */
    private static final String ak = "roXW0LCjo6P9EnCZgG3O1cBlMzvyapwY";
    private static final String output = "json";
    private static final String callback = "showLocation";
    private static final String geocodingUrl = "http://api.map.baidu.com/geocoding/v3/";
    private static final String reverseUrl = "http://api.map.baidu.com/reverse_geocoding/v3/";
    // 李泳江个人账号:15602261488
    private static final String ak = "roXW0LCjo6P9EnCZgG3O1cBlMzvyapwY";
    // 王文豪个人账号
//    private static final String ak = "FhiGsV7BFaHGhGy2IeyPq7GuOiFroQ4o";
    /**
     * 根据详细地址获取坐标值
@@ -35,13 +48,9 @@
     * @param city 城市
     * @return JSONObject
     */
    public static JSONObject getCoordinateByAddr(String address, String city) {
        Map<String, String> parameters = Maps.newHashMap();
        parameters.put("ak", ak);
        parameters.put("address", address);
        parameters.put("city", city);
        parameters.put("output", output);
        String json = HttpClientUtils.httpGet(geocodingUrl, parameters, null);
    public static JSONObject getLngLatByAddr(String address, String city) {
        String url = geocodingUrl+"?ak="+ak+"&output="+output+"&address="+address+"&city="+city;
        String json = HttpClientUtils.httpGet(url, null, null);
        JSONObject data = JSONObject.parseObject(json);
        JSONObject data1=JSONObject.parseObject(data.getString("result"));
@@ -52,25 +61,56 @@
    /**
     * 根据坐标获取详细地址
     * @param lat 经度
     * @param lng 维度
     * @param lng 经度
     * @param lat 维度
     * @param coordtype 坐标类型,目前支持的坐标类型包括:bd09ll(百度经纬度坐标)、bd09mc(百度米制坐标)、gcj02ll(国测局经纬度坐标,仅限中国)、wgs84ll( GPS经纬度)
     * @return String
     */
    public static String getAddressByCoordinate(String lat, String lng, String coordtype) {
        Map<String, String> parameters = Maps.newHashMap();
        parameters.put("location", lat + "," + lng);
        parameters.put("coordtype", coordtype);
        parameters.put("ak", ak);
        parameters.put("output", output);
        String json = HttpClientUtils.httpGet(reverseUrl, parameters, null);
    public static BaiduMapAddrDTO getAddrByLngLat(String lng, String lat, String coordtype) {
        BaiduMapAddrDTO baiduMapAddrDTO = new BaiduMapAddrDTO();
        try{
            String location = lat + "," + lng;
            String url = reverseUrl+"?ak="+ak+"&output="+output+"&location="+location+"&coordtype="+coordtype;
            String json = HttpClientUtils.httpGet(url, null, null);
        JSONObject data = JSONObject.parseObject(json);
        JSONObject data1=JSONObject.parseObject(data.getString("result"));
        JSONObject data2=JSONObject.parseObject(data1.getString("addressComponent"));
        String district =data2.getString("district");
        System.out.println(district);
        return district;
            JSONObject data = JSONObject.parseObject(json);
            JSONObject data1 =JSONObject.parseObject(data.getString("result"));
            // 识别地址
            String formattedAddress = data1.getString("formatted_address");
            System.out.println("识别地址:"+formattedAddress);
            // 解析地址组成部分
            JSONObject addressComponent=JSONObject.parseObject(data1.getString("addressComponent"));
            // 国家
            String country = addressComponent.getString("country");
            // 省
            String province = addressComponent.getString("province");
            // 市
            String city = addressComponent.getString("city");
            // 区
            String district = addressComponent.getString("district");
            // 街道
            String town = addressComponent.getString("town");
            // 路
            String street = addressComponent.getString("street");
            // 号
            String streetNumber = addressComponent.getString("street_number");
            // 拼接地址
            String addr = country+province+city+district+town+street+streetNumber;
            System.out.println("拼接地址:"+addr);
            baiduMapAddrDTO.setFormattedAddress(formattedAddress);
            baiduMapAddrDTO.setCountry(country);
            baiduMapAddrDTO.setProvince(province);
            baiduMapAddrDTO.setCity(city);
            baiduMapAddrDTO.setDistrict(district);
            baiduMapAddrDTO.setTown(town);
            baiduMapAddrDTO.setStreet(street);
            baiduMapAddrDTO.setStreetNumber(streetNumber);
            baiduMapAddrDTO.setAddr(addr);
        }catch (Exception e){
            log.error("[BaiduMapUtils.getAddrByLngLat]调用失败,异常信息:"+e, e);
        }
        return baiduMapAddrDTO;
    }
}