refactor: 删除QgisProperties,FeignServiceImpl用@Value注入url

This commit is contained in:
wzy-warehouse
2026-06-18 18:04:08 +08:00
parent 16b0206318
commit 175cbc0b43
2 changed files with 8 additions and 28 deletions
@@ -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; package com.gis.xian.service.qgis.base.impl;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.gis.xian.config.QgisProperties;
import com.gis.xian.dto.qgis.base.QgisTriggerDTO; import com.gis.xian.dto.qgis.base.QgisTriggerDTO;
import com.gis.xian.service.qgis.base.IFeignService; import com.gis.xian.service.qgis.base.IFeignService;
import com.gis.xian.utils.HttpRequestClientUtils; import com.gis.xian.utils.HttpRequestClientUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -21,23 +21,22 @@ public class FeignServiceImpl implements IFeignService {
@Resource @Resource
private HttpRequestClientUtils restclient; private HttpRequestClientUtils restclient;
@Resource @Value("${qgis.url}")
private QgisProperties qgisProperties; private String qgisUrl;
@Override @Override
public void trigger(QgisTriggerDTO triggerDTO) { public void trigger(QgisTriggerDTO triggerDTO) {
if (triggerDTO == null || triggerDTO.getSimulationId() == null || triggerDTO.getType() == null) { if (triggerDTO == null || triggerDTO.getSimulationId() == null) {
log.error("触发参数为空,simulationId={}, type={}", log.error("触发参数为空,simulationId={}",
triggerDTO != null ? triggerDTO.getSimulationId() : null, triggerDTO != null ? triggerDTO.getSimulationId() : null);
triggerDTO != null ? triggerDTO.getType() : null);
return; return;
} }
log.info("触发专题图生成: simulationId={}, type={}", triggerDTO.getSimulationId(), triggerDTO.getType()); log.info("触发专题图生成: simulationId={}", triggerDTO.getSimulationId());
try { try {
ParameterizedTypeReference<String> res = new ParameterizedTypeReference<String>() {}; 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); log.info("Python 端响应: {}", result);
} catch (Exception e) { } catch (Exception e) {
log.error("调用 Python QGIS 服务失败: {}", e.getMessage(), e); log.error("调用 Python QGIS 服务失败: {}", e.getMessage(), e);