refactor: 删除QgisProperties,FeignServiceImpl用@Value注入url
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
package com.gis.xian.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* QGIS 制图服务配置属性
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "qgis")
|
||||
public class QgisProperties {
|
||||
|
||||
/**
|
||||
* QGIS 服务 URL
|
||||
*/
|
||||
private String url;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.gis.xian.service.qgis.base.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.gis.xian.config.QgisProperties;
|
||||
import com.gis.xian.dto.qgis.base.QgisTriggerDTO;
|
||||
import com.gis.xian.service.qgis.base.IFeignService;
|
||||
import com.gis.xian.utils.HttpRequestClientUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -21,23 +21,22 @@ public class FeignServiceImpl implements IFeignService {
|
||||
@Resource
|
||||
private HttpRequestClientUtils restclient;
|
||||
|
||||
@Resource
|
||||
private QgisProperties qgisProperties;
|
||||
@Value("${qgis.url}")
|
||||
private String qgisUrl;
|
||||
|
||||
@Override
|
||||
public void trigger(QgisTriggerDTO triggerDTO) {
|
||||
if (triggerDTO == null || triggerDTO.getSimulationId() == null || triggerDTO.getType() == null) {
|
||||
log.error("触发参数为空,simulationId={}, type={}",
|
||||
triggerDTO != null ? triggerDTO.getSimulationId() : null,
|
||||
triggerDTO != null ? triggerDTO.getType() : null);
|
||||
if (triggerDTO == null || triggerDTO.getSimulationId() == null) {
|
||||
log.error("触发参数为空,simulationId={}",
|
||||
triggerDTO != null ? triggerDTO.getSimulationId() : null);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("触发专题图生成: simulationId={}, type={}", triggerDTO.getSimulationId(), triggerDTO.getType());
|
||||
log.info("触发专题图生成: simulationId={}", triggerDTO.getSimulationId());
|
||||
|
||||
try {
|
||||
ParameterizedTypeReference<String> res = new ParameterizedTypeReference<String>() {};
|
||||
String result = restclient.post(qgisProperties.getUrl(), JSON.toJSON(triggerDTO), res);
|
||||
String result = restclient.post(qgisUrl, JSON.toJSON(triggerDTO), res);
|
||||
log.info("Python 端响应: {}", result);
|
||||
} catch (Exception e) {
|
||||
log.error("调用 Python QGIS 服务失败: {}", e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user