fix
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
package com.cool.store.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: GeoMapUtil
|
||||
* @Description:
|
||||
* @date 2024-04-23 11:26
|
||||
*/
|
||||
public class GeoMapUtil {
|
||||
|
||||
private static final String AMAP_API_URL = "https://restapi.amap.com/v3/geocode/regeo";
|
||||
private static final String API_KEY = "bdf789122b56e8fd3d4a4410800382a6"; // 替换为你的高德地图API密钥
|
||||
|
||||
public static void main(String[] args) {
|
||||
AddressInfo addressInfo = reverseGeoCoding("30.41875", "120.2985");
|
||||
System.out.println(JSONObject.toJSONString(addressInfo));
|
||||
System.out.println(JSONObject.toJSONString(reverseGeoCoding("30.41", "120.29")));
|
||||
System.out.println(JSONObject.toJSONString(reverseGeoCoding("30.42", "120.30")));
|
||||
System.out.println(JSONObject.toJSONString(reverseGeoCoding("30.4", "120.2")));
|
||||
System.out.println(JSONObject.toJSONString(reverseGeoCoding("30.5", "120.3")));
|
||||
System.out.println(JSONObject.toJSONString(reverseGeoCoding("30.419", "120.299")));
|
||||
}
|
||||
|
||||
public static AddressInfo reverseGeoCoding(String latitude, String longitude) {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
URL url = new URL(AMAP_API_URL + "?location=" + longitude + "," + latitude + "&output=json&key=" + API_KEY);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.connect();
|
||||
if(connection.getResponseCode() == HttpURLConnection.HTTP_OK){
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuilder content = new StringBuilder();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(content.toString());
|
||||
// 提取并构建AddressInfo对象
|
||||
AddressInfo addressInfo = extractAddressInfo(jsonObject.getJSONObject("regeocode"));
|
||||
return addressInfo;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error occurred while making the request: " + e.getMessage());
|
||||
}finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static AddressInfo extractAddressInfo(JSONObject geoJson) {
|
||||
JSONObject addressComponent = geoJson.getJSONObject("addressComponent");
|
||||
// 根据实际响应结构解析省市区街道信息,此处仅为示例
|
||||
String province = (String) addressComponent.get("province");
|
||||
String city = (String) addressComponent.get("city");
|
||||
String district = (String) addressComponent.get("district");
|
||||
String township = (String) addressComponent.get("township");
|
||||
String address = geoJson.getString("formatted_address");
|
||||
return new AddressInfo(province, city, district, township, address);
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class AddressInfo {
|
||||
private String province;
|
||||
private String city;
|
||||
private String district;
|
||||
private String township;
|
||||
private String address;
|
||||
|
||||
public AddressInfo(String province, String city, String district, String township, String address) {
|
||||
this.province = province;
|
||||
this.city = city;
|
||||
this.district = district;
|
||||
this.township = township;
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -574,9 +574,6 @@ public class PointDetailInfoDO {
|
||||
if(Objects.isNull(this.dayTrader) || Objects.isNull(this.profitRate) || Objects.isNull(this.monthProfitRate)){
|
||||
return false;
|
||||
}
|
||||
if(Objects.isNull(this.deliveryRate) || Objects.isNull(this.deliveryFee)){
|
||||
return false;
|
||||
}
|
||||
if(Objects.isNull(this.brandUseFee) || Objects.isNull(this.brandUseRate)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface PointService {
|
||||
* @param shopPointDetailRequest
|
||||
* @return
|
||||
*/
|
||||
Integer updatePointDetailInfo(UpdatePointDetailRequest shopPointDetailRequest);
|
||||
Long updatePointDetailInfo(UpdatePointDetailRequest shopPointDetailRequest);
|
||||
|
||||
/**
|
||||
* 生成铺位评估报告
|
||||
|
||||
@@ -123,12 +123,13 @@ public class PointServiceImpl implements PointService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Integer updatePointDetailInfo(UpdatePointDetailRequest shopPointDetailRequest) {
|
||||
public Long updatePointDetailInfo(UpdatePointDetailRequest shopPointDetailRequest) {
|
||||
PointInfoDO shopPointInfo = UpdatePointDetailRequest.convertPointDO(shopPointDetailRequest);
|
||||
PointDetailInfoDO shopPoint = UpdatePointDetailRequest.convertDO(shopPointDetailRequest);
|
||||
shopPointInfo.setPointScore(shopPoint.getTotalPointScore());
|
||||
pointInfoDAO.updatePointInfo(shopPointInfo);
|
||||
return pointDetailInfoDAO.updatePointDetailInfo(shopPoint);
|
||||
pointDetailInfoDAO.updatePointDetailInfo(shopPoint);
|
||||
return shopPointDetailRequest.getPointId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -476,6 +477,9 @@ public class PointServiceImpl implements PointService {
|
||||
request.setRegionIds(regionService.getSubRegionIdsByRegionIds(request.getRegionIds()));
|
||||
}
|
||||
}
|
||||
if(Objects.nonNull(request.getPointStatus()) && PointStatusEnum.POINT_STATUS_3.getCode().equals(request.getPointStatus())){
|
||||
request.setPointStatus(PointStatusEnum.POINT_STATUS_4.getCode());
|
||||
}
|
||||
List<PointPageVO> resultList = new ArrayList();
|
||||
Page<PointInfoDO> pointPage = pointInfoDAO.getTeamPointPage(request);
|
||||
if(Objects.nonNull(pointPage) && CollectionUtils.isNotEmpty(pointPage.getResult())){
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PointController {
|
||||
|
||||
@ApiOperation("完善铺位")
|
||||
@PostMapping("/update")
|
||||
public ResponseResult<Integer> updatePointDetailInfo(@RequestBody @Validated UpdatePointDetailRequest shopPointDetailRequest) {
|
||||
public ResponseResult<Long> updatePointDetailInfo(@RequestBody @Validated UpdatePointDetailRequest shopPointDetailRequest) {
|
||||
return ResponseResult.success(pointService.updatePointDetailInfo(shopPointDetailRequest));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user