parent
7e281f26b6
commit
054a51e4f6
|
@ -459,7 +459,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService, CrmCustomerAp
|
|||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class) // 需要 protected 修饰,因为需要在事务中调用
|
||||
protected void putCustomerPool(CrmCustomerDO customer) {
|
||||
public void putCustomerPool(CrmCustomerDO customer) {
|
||||
// 1. 设置负责人为 NULL
|
||||
int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null);
|
||||
if (updateOwnerUserIncr == 0) {
|
||||
|
@ -671,7 +671,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService, CrmCustomerAp
|
|||
createReqVO.setId(null);
|
||||
createReqVO.setMobile(mobile);
|
||||
|
||||
// TODO AN 假如已有会员,需要判断CRM中手机号是否已经存在客户
|
||||
// AN 假如已有会员,需要判断CRM中手机号是否已经存在客户
|
||||
// 如果存在则放弃创建,不更新关联负责人,
|
||||
// 如果不存在则单独创建客户
|
||||
CrmCustomerDO customer = customerMapper.selectByCustomerMobile(mobile);
|
||||
|
|
|
@ -18,5 +18,10 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode POI_REQUEST_ERROR = new ErrorCode(1_050_001_003, "POI 请求失败");
|
||||
|
||||
ErrorCode POI_REQUEST_NO_MEMBER = new ErrorCode(1_050_001_004, "未能获取到登录用户");
|
||||
ErrorCode POI_SAVE_NO_MEMBER = new ErrorCode(1_050_001_005, "POI数据保存未能获取到登录用户");
|
||||
|
||||
ErrorCode POI_Trans_ERROR = new ErrorCode(1_050_001_006, "POI数据转换失败");
|
||||
ErrorCode POI_ID_EMPTY = new ErrorCode(1_050_001_007, "POI_ID为空");
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package cn.iocoder.yudao.module.map.api.poirecord;
|
||||
|
||||
import cn.iocoder.yudao.module.map.mq.message.poirecord.PoiRecordMessage;
|
||||
|
||||
public interface MapPoiRecordApi {
|
||||
void doCreate(PoiRecordMessage message) ;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package cn.iocoder.yudao.module.map.controller.admin.pois.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisBusinessDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisIndoorDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisNaviDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisPhotosDO;
|
||||
import cn.iocoder.yudao.module.map.serializer.PoisIdSerializer;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@JsonSerialize(using = PoisIdSerializer.class)
|
||||
public class PoiTransSaveVO {
|
||||
@Schema(description = "POI名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotEmpty(message = "POI名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "经纬度", requiredMode = Schema.RequiredMode.REQUIRED, example = "116.413232,39.899947")
|
||||
@NotEmpty(message = "经纬度不能为空")
|
||||
private String location;
|
||||
|
||||
@Schema(description = "所属类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "汽车服务;汽车养护/装饰;汽车养护|汽车服务;洗车场;洗车场|汽车维修;汽车维修;汽车维修")
|
||||
@NotEmpty(message = "所属类型不能为空")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "分类编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "010400|010500|030000")
|
||||
@NotEmpty(message = "分类编码不能为空")
|
||||
private String typecode;
|
||||
|
||||
@Schema(description = "省份", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京市")
|
||||
@NotEmpty(message = "省份不能为空")
|
||||
private String pname;
|
||||
|
||||
@Schema(description = "城市", requiredMode = Schema.RequiredMode.REQUIRED, example = "北京市")
|
||||
@NotEmpty(message = "城市不能为空")
|
||||
private String cityName;
|
||||
|
||||
@Schema(description = "区县", requiredMode = Schema.RequiredMode.REQUIRED, example = "东城区")
|
||||
@NotEmpty(message = "区县不能为空")
|
||||
private String adname;
|
||||
|
||||
@Schema(description = "详细地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "宝鼎中心C座B2层(崇文门地铁站D西南口步行480米)")
|
||||
@NotEmpty(message = "详细地址不能为空")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "省份编码", example = "110000")
|
||||
private String pcode;
|
||||
|
||||
@Schema(description = "区域编码", example = "110101")
|
||||
private String adcode;
|
||||
|
||||
@Schema(description = "城市编码", example = "010")
|
||||
private String citycode;
|
||||
|
||||
@Schema(description = "poi唯一标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "B0GUKCE3AI")
|
||||
@NotEmpty(message = "poi唯一标识不能为空")
|
||||
@JsonProperty("id")
|
||||
private String poiId;
|
||||
|
||||
@Schema(description = "高德POI室内信息")
|
||||
private PoisIndoorDO indoor;
|
||||
|
||||
@Schema(description = "高德POI商业信息")
|
||||
private PoisBusinessDO business;
|
||||
|
||||
@Schema(description = "高德POI导航信息")
|
||||
private PoisNaviDO navi;
|
||||
|
||||
@Schema(description = "高德POI图片信息")
|
||||
private List<PoisPhotosDO> photos;
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package cn.iocoder.yudao.module.map.controller.admin.pois.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.map.serializer.PoisIdSerializer;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package cn.iocoder.yudao.module.map.controller.admin.pois.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 高德POI基础信息转换 VO")
|
||||
@Data
|
||||
public class PoisTransVo {
|
||||
|
||||
private List<PoiTransSaveVO> pois;
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -5,4 +5,7 @@ public interface LogRecordConstants {
|
|||
String POI_DATA_REQUEST = "POI数据请求";
|
||||
String POI_DATA_REQUEST_SUCCESS = "POI数据请求成功";
|
||||
String POI_DATA_REQUEST_ERROR = "POI数据请求失败";
|
||||
|
||||
String POI_DATA_SAVE = "POI数据保存";
|
||||
String POI_DATA_SAVE_SUCCESS = "POI数据保存成功";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package cn.iocoder.yudao.module.map.mq.consumer.poirecord;
|
||||
import cn.iocoder.yudao.module.map.api.poirecord.MapPoiRecordApi;
|
||||
import cn.iocoder.yudao.module.map.mq.message.poirecord.PoiRecordMessage;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PoiRecordConsumer {
|
||||
@Resource
|
||||
private MapPoiRecordApi mapPoiRecordApi;
|
||||
|
||||
@EventListener
|
||||
@Async // Spring Event 默认在 Producer 发送的线程,通过 @Async 实现异步
|
||||
public void onMessage(PoiRecordMessage message) {
|
||||
log.info("[onMessage][消息内容({})]", message);
|
||||
mapPoiRecordApi.doCreate(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package cn.iocoder.yudao.module.map.mq.message.poirecord;
|
||||
import lombok.Data;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class PoiRecordMessage {
|
||||
|
||||
/**
|
||||
* 高德返回数据
|
||||
*/
|
||||
private String keywords;
|
||||
private String location;
|
||||
private String region;
|
||||
private String types;
|
||||
private Boolean cityLimit;
|
||||
private Integer pageSize;
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* 地图原始数据
|
||||
*/
|
||||
private String poiData;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package cn.iocoder.yudao.module.map.mq.producer.poirecord;
|
||||
import cn.iocoder.yudao.module.map.mq.message.poirecord.PoiRecordMessage;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* PoiRecord 高德POI相关消息的 Producer
|
||||
*
|
||||
* @author an
|
||||
* @since 2025/3/18 22:16
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PoiRecordProducer {
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
/**
|
||||
* 发送 {@link PoiRecordMessage} 消息
|
||||
*
|
||||
* @param porRecordMessage 消息
|
||||
*/
|
||||
public void sendPoiRecordMessage(PoiRecordMessage porRecordMessage) {
|
||||
applicationContext.publishEvent(porRecordMessage);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package cn.iocoder.yudao.module.map.serializer;
|
||||
|
||||
import cn.iocoder.yudao.module.map.controller.admin.pois.vo.PoiTransSaveVO;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PoisIdSerializer extends JsonSerializer<PoiTransSaveVO> {
|
||||
@Override
|
||||
public void serialize(PoiTransSaveVO PoiTransSaveVO, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
|
||||
jsonGenerator.writeStartObject();
|
||||
jsonGenerator.writeStringField("id", PoiTransSaveVO.getPoiId());
|
||||
jsonGenerator.writeEndObject();
|
||||
}
|
||||
}
|
|
@ -1,11 +1,33 @@
|
|||
package cn.iocoder.yudao.module.map.service.pois;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
||||
import cn.iocoder.yudao.module.map.api.poirecord.MapPoiRecordApi;
|
||||
import cn.iocoder.yudao.module.map.controller.app.lbs.vo.AppMapLbsReqVO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.keywordsearch.KeywordSearchDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.poitypes.PoiTypesDO;
|
||||
import cn.iocoder.yudao.module.map.dal.mysql.keywordsearch.KeywordSearchMapper;
|
||||
import cn.iocoder.yudao.module.map.dal.mysql.poitypes.PoiTypesMapper;
|
||||
import cn.iocoder.yudao.module.map.mq.message.poirecord.PoiRecordMessage;
|
||||
import cn.iocoder.yudao.module.map.mq.producer.poirecord.PoiRecordProducer;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.hankcs.hanlp.HanLP;
|
||||
import com.hankcs.hanlp.seg.common.Term;
|
||||
import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.transaction.annotation.SpringTransactionAnnotationParser;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.map.controller.admin.pois.vo.*;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisIndoorDO;
|
||||
|
@ -13,7 +35,6 @@ import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisBusinessDO;
|
|||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisNaviDO;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.pois.PoisPhotosDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.map.dal.mysql.pois.PoisMapper;
|
||||
|
@ -24,6 +45,16 @@ import cn.iocoder.yudao.module.map.dal.mysql.pois.PoisPhotosMapper;
|
|||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.map.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.map.enums.LogRecordConstants.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 高德POI基础信息 Service 实现类
|
||||
|
@ -32,7 +63,7 @@ import static cn.iocoder.yudao.module.map.enums.ErrorCodeConstants.*;
|
|||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PoisServiceImpl implements PoisService {
|
||||
public class PoisServiceImpl implements PoisService, MapPoiRecordApi {
|
||||
|
||||
@Resource
|
||||
private PoisMapper poisMapper;
|
||||
|
@ -44,6 +75,16 @@ public class PoisServiceImpl implements PoisService {
|
|||
private PoisNaviMapper poisNaviMapper;
|
||||
@Resource
|
||||
private PoisPhotosMapper poisPhotosMapper;
|
||||
@Resource
|
||||
private PoiTypesMapper poiTypesMapper;
|
||||
@Resource
|
||||
private ConfigApi configApi;
|
||||
@Resource
|
||||
private PoiRecordProducer poiRecordProducer;
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
@Resource
|
||||
private KeywordSearchMapper keywordSearchMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -220,4 +261,193 @@ public class PoisServiceImpl implements PoisService {
|
|||
poisPhotosMapper.deleteByPoisId(poisId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 请求高德POI2.0接口获得地图数据
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 搜索记录分页
|
||||
*/
|
||||
@Override
|
||||
@LogRecord(type = POI_DATA, subType = POI_DATA_REQUEST, success = POI_DATA_REQUEST_SUCCESS, bizNo = "{{#loginUser.getId}}")
|
||||
public CommonResult<String> getPoiData(AppMapLbsReqVO pageReqVO) {
|
||||
// 高德地图新POI搜索接口地址
|
||||
String apiUrl = "https://restapi.amap.com/v5/place/text";
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
LogRecordContext.putVariable("loginUser", loginUser);
|
||||
} else {
|
||||
throw exception(POI_REQUEST_NO_MEMBER);
|
||||
}
|
||||
// 高德地图 API Key
|
||||
String apiKey = configApi.getConfigValueByKey("gaode.lbs.key");
|
||||
if (apiKey == null) {
|
||||
throw exception(POIS_KEYS_EXISTS);
|
||||
}
|
||||
// 构建请求参数
|
||||
// keyword 或者 types 二选一必填
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("key", apiKey);
|
||||
|
||||
String new_type_str = "";
|
||||
if (pageReqVO.getIsFocus() == 0) {
|
||||
// 非精准查找需要对输入的关键词进行分词处理,然后在数据库中查询是否归属于poi类型
|
||||
// 使用Hutool的分词工具进行分词处理
|
||||
List<Term> termList = HanLP.segment(pageReqVO.getKeywords());
|
||||
List<String> keywords = new ArrayList<>();
|
||||
for (Term term : termList) {
|
||||
keywords.add(term.word);
|
||||
}
|
||||
if (!keywords.isEmpty()) {
|
||||
List<PoiTypesDO> newtype = poiTypesMapper.selectByWords(keywords);
|
||||
if (!newtype.isEmpty()) {
|
||||
// 使用字符'|'拼接newtype字段
|
||||
new_type_str = newtype.stream()
|
||||
.map(PoiTypesDO::getNewType)
|
||||
.collect(Collectors.joining("|"));
|
||||
}
|
||||
}
|
||||
// 类型都不为空,使用类型进行模糊查询
|
||||
if (!new_type_str.isEmpty()) {
|
||||
params.put("types", new_type_str);
|
||||
} else {
|
||||
params.put("keywords", pageReqVO.getKeywords());
|
||||
}
|
||||
} else {
|
||||
// 精准模式,指定关键词查找
|
||||
if (pageReqVO.getKeywords() != null) {
|
||||
params.put("keywords", pageReqVO.getKeywords());
|
||||
}
|
||||
}
|
||||
// 城市限制
|
||||
if (pageReqVO.getRegion() != null) {
|
||||
// 仅召回 region 对应区域内数据
|
||||
params.put("region", pageReqVO.getRegion());
|
||||
// 指定城市数据召回限制
|
||||
params.put("city_limit", "true");
|
||||
}
|
||||
params.put("show_fields", "children,business,navi,indoor,photos");
|
||||
params.put("page_size", pageReqVO.getPageSize().toString());
|
||||
params.put("page_num", pageReqVO.getPageNo().toString());
|
||||
// 将参数拼接成查询字符串
|
||||
String queryString = params.entrySet().stream()
|
||||
.map(entry -> {
|
||||
// 对参数的键和值进行 URL 编码
|
||||
String encodedKey = java.net.URLEncoder.encode(entry.getKey(), java.nio.charset.StandardCharsets.UTF_8);
|
||||
String encodedValue = java.net.URLEncoder.encode(entry.getValue(), java.nio.charset.StandardCharsets.UTF_8);
|
||||
return encodedKey + "=" + encodedValue;
|
||||
})
|
||||
.collect(Collectors.joining("&"));
|
||||
//打印日志
|
||||
// System.out.println("请求参数:" + queryString);
|
||||
|
||||
// 构建完整的请求 URL
|
||||
String fullUrl = apiUrl + "?" + queryString;
|
||||
|
||||
// 创建 HttpClient 实例
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
|
||||
// 创建 HttpRequest 实例
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create(fullUrl))
|
||||
.GET()
|
||||
.build();
|
||||
CommonResult<String> data = new CommonResult<>();
|
||||
try {
|
||||
// 发送请求并获取响应
|
||||
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
// 处理响应
|
||||
if (response.statusCode() == 200) {
|
||||
String responseBody = response.body();
|
||||
// TODO 添加消息队列,保存到json到对应数据库
|
||||
PoiRecordMessage message = new PoiRecordMessage();
|
||||
message.setTypes(new_type_str);
|
||||
message.setPoiData(responseBody);
|
||||
message.setKeywords(pageReqVO.getKeywords());
|
||||
message.setRegion(pageReqVO.getRegion());
|
||||
message.setCityLimit(true);
|
||||
message.setPoiData(responseBody);
|
||||
message.setPageNum(pageReqVO.getPageNo());
|
||||
message.setPageSize(25);
|
||||
poiRecordProducer.sendPoiRecordMessage(message);
|
||||
// System.out.println("响应体:" + responseBody);
|
||||
return data.setCode(POI_REQUEST_SUCCESS.getCode()).setData(responseBody);
|
||||
} else {
|
||||
// 处理请求失败的情况
|
||||
throw exception(POI_REQUEST_ERROR, response.statusCode());
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
// 处理异常
|
||||
throw exception(POI_REQUEST_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理高德POI2.0接口获得的地图数据
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
// @LogRecord(type = POI_DATA, subType = POI_DATA_SAVE, bizNo = "{{#loginUser.getId}}",
|
||||
// success = POI_DATA_SAVE_SUCCESS)
|
||||
@Override
|
||||
public void doCreate(PoiRecordMessage message) {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
LogRecordContext.putVariable("loginUser", loginUser);
|
||||
} else {
|
||||
throw exception(POI_SAVE_NO_MEMBER);
|
||||
}
|
||||
|
||||
try {
|
||||
String poiData = message.getPoiData();
|
||||
// 简单去除多余的反斜杠
|
||||
poiData = poiData.replace("\\", "");
|
||||
System.out.println("接收数据:" + poiData);
|
||||
|
||||
KeywordSearchDO keywordSearchDO = objectMapper.readValue(poiData, KeywordSearchDO.class);
|
||||
keywordSearchDO.setKeywords(message.getKeywords());
|
||||
keywordSearchDO.setRegion(message.getRegion());
|
||||
keywordSearchDO.setCityLimit(message.getCityLimit());
|
||||
keywordSearchDO.setTypes(message.getTypes());
|
||||
keywordSearchDO.setRegion(message.getRegion());
|
||||
keywordSearchDO.setPageSize(message.getPageSize());
|
||||
keywordSearchDO.setPageNum(message.getPageNum());
|
||||
keywordSearchMapper.insert(keywordSearchDO);
|
||||
// 在插入keywordSearch表后,继续将关联的POI数据进行转换并插入
|
||||
|
||||
PoisTransVo maps = objectMapper.readValue(poiData, PoisTransVo.class);
|
||||
System.out.println("map:");
|
||||
System.out.println(maps);
|
||||
for (PoiTransSaveVO map : maps.getPois()) {
|
||||
System.out.println("PoiTransSaveVO:");
|
||||
System.out.println(map);
|
||||
PoisSaveReqVO poisSaveReqVO = BeanUtils.toBean(map, PoisSaveReqVO.class);
|
||||
System.out.println("poisSaveReqVO:");
|
||||
System.out.println(poisSaveReqVO);
|
||||
poisSaveReqVO.setPoisBusiness(map.getBusiness());
|
||||
poisSaveReqVO.setPoisIndoor(map.getIndoor());
|
||||
poisSaveReqVO.setPoisNavi(map.getNavi());
|
||||
poisSaveReqVO.setKeySearchId(keywordSearchDO.getId());
|
||||
PoisDO pois = BeanUtils.toBean(poisSaveReqVO, PoisDO.class);
|
||||
poisMapper.insert(pois);
|
||||
|
||||
// 插入子表
|
||||
createPoisIndoor(pois.getId(), poisSaveReqVO.getPoisIndoor());
|
||||
createPoisBusiness(pois.getId(), poisSaveReqVO.getPoisBusiness());
|
||||
createPoisNavi(pois.getId(), poisSaveReqVO.getPoisNavi());
|
||||
if (map.getPhotos() != null) {
|
||||
for (PoisPhotosDO photos : map.getPhotos()) {
|
||||
createPoisPhotos(pois.getId(), photos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println(e.getMessage());
|
||||
throw exception(POI_Trans_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package cn.iocoder.yudao.module.map.service.poitypes;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.map.controller.admin.poitypes.vo.*;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.poitypes.PoiTypesDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* POI类型 Service 接口
|
||||
*
|
||||
* @author 安
|
||||
*/
|
||||
public interface PoiTypesService {
|
||||
|
||||
/**
|
||||
* 创建POI类型
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createPoiTypes(@Valid PoiTypesSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新POI类型
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updatePoiTypes(@Valid PoiTypesSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除POI类型
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deletePoiTypes(Long id);
|
||||
|
||||
/**
|
||||
* 获得POI类型
|
||||
*
|
||||
* @param id 编号
|
||||
* @return POI类型
|
||||
*/
|
||||
PoiTypesDO getPoiTypes(Long id);
|
||||
|
||||
/**
|
||||
* 获得POI类型分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return POI类型分页
|
||||
*/
|
||||
PageResult<PoiTypesDO> getPoiTypesPage(PoiTypesPageReqVO pageReqVO);
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package cn.iocoder.yudao.module.map.service.poitypes;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.map.controller.admin.poitypes.vo.*;
|
||||
import cn.iocoder.yudao.module.map.dal.dataobject.poitypes.PoiTypesDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.map.dal.mysql.poitypes.PoiTypesMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.map.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* POI类型 Service 实现类
|
||||
*
|
||||
* @author 安
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class PoiTypesServiceImpl implements PoiTypesService {
|
||||
|
||||
@Resource
|
||||
private PoiTypesMapper poiTypesMapper;
|
||||
|
||||
@Override
|
||||
public Long createPoiTypes(PoiTypesSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
PoiTypesDO poiTypes = BeanUtils.toBean(createReqVO, PoiTypesDO.class);
|
||||
poiTypesMapper.insert(poiTypes);
|
||||
// 返回
|
||||
return poiTypes.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePoiTypes(PoiTypesSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validatePoiTypesExists(updateReqVO.getId());
|
||||
// 更新
|
||||
PoiTypesDO updateObj = BeanUtils.toBean(updateReqVO, PoiTypesDO.class);
|
||||
poiTypesMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePoiTypes(Long id) {
|
||||
// 校验存在
|
||||
validatePoiTypesExists(id);
|
||||
// 删除
|
||||
poiTypesMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validatePoiTypesExists(Long id) {
|
||||
if (poiTypesMapper.selectById(id) == null) {
|
||||
throw exception(POI_TYPES_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PoiTypesDO getPoiTypes(Long id) {
|
||||
return poiTypesMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PoiTypesDO> getPoiTypesPage(PoiTypesPageReqVO pageReqVO) {
|
||||
return poiTypesMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue