取消qgis子包,service提到顶层,trigger添加type参数

This commit is contained in:
wzy-warehouse
2026-06-18 20:34:14 +08:00
parent ec1549330a
commit bc5b6fe50a
3 changed files with 16 additions and 15 deletions
@@ -1,13 +1,13 @@
package com.gis.xian.controller; package com.gis.xian.controller;
import com.gis.xian.service.qgis.base.IFeignService; import com.gis.xian.service.IFeignService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
/** /**
* QGIS 专题图触发接口 * 专题图触发接口
* 统一入口,接收 simulationId,调用 Python 端处理 * 统一入口,接收 simulationId 和 type,调用 Python 端处理
*/ */
@Slf4j @Slf4j
@RestController @RestController
@@ -18,8 +18,8 @@ public class QgisController {
private IFeignService feignService; private IFeignService feignService;
@PostMapping("/qgis/trigger") @PostMapping("/qgis/trigger")
public void trigger(@RequestParam String simulationId) { public void trigger(@RequestParam String simulationId, @RequestParam String type) {
log.info("收到专题图触发请求: simulationId={}", simulationId); log.info("收到专题图触发请求: simulationId={}, type={}", simulationId, type);
feignService.trigger(simulationId); feignService.trigger(simulationId, type);
} }
} }
@@ -1,7 +1,7 @@
package com.gis.xian.service.qgis.base; package com.gis.xian.service;
/** /**
* 统一专题图触发接口 * 专题图触发接口
* 只负责调用 Python 不返回结果 * 只负责调用 Python 不返回结果
*/ */
public interface IFeignService { public interface IFeignService {
@@ -9,6 +9,7 @@ public interface IFeignService {
/** /**
* 触发专题图生成 * 触发专题图生成
* @param simulationId 模拟ID * @param simulationId 模拟ID
* @param type 灾害类型earthquake / rain
*/ */
void trigger(String simulationId); void trigger(String simulationId, String type);
} }
@@ -1,6 +1,6 @@
package com.gis.xian.service.qgis.base.impl; package com.gis.xian.service.impl;
import com.gis.xian.service.qgis.base.IFeignService; import com.gis.xian.service.IFeignService;
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.beans.factory.annotation.Value;
@@ -11,7 +11,7 @@ import org.springframework.web.client.RestClient;
import java.util.Map; import java.util.Map;
/** /**
* 统一专题图触发服务 * 专题图触发服务
* 只负责调用 Python QGIS 服务不处理计算和存库 * 只负责调用 Python QGIS 服务不处理计算和存库
*/ */
@Slf4j @Slf4j
@@ -25,20 +25,20 @@ public class FeignServiceImpl implements IFeignService {
private String qgisUrl; private String qgisUrl;
@Override @Override
public void trigger(String simulationId) { public void trigger(String simulationId, String type) {
if (simulationId == null || simulationId.isBlank()) { if (simulationId == null || simulationId.isBlank()) {
log.error("触发参数为空,simulationId={}", simulationId); log.error("触发参数为空,simulationId={}", simulationId);
return; return;
} }
log.info("触发专题图生成: simulationId={}", simulationId); log.info("触发专题图生成: simulationId={}, type={}", simulationId, type);
try { try {
RestClient client = restClientBuilder.build(); RestClient client = restClientBuilder.build();
String result = client.post() String result = client.post()
.uri(qgisUrl) .uri(qgisUrl)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.body(Map.of("simulationId", simulationId)) .body(Map.of("simulationId", simulationId, "type", type))
.retrieve() .retrieve()
.body(String.class); .body(String.class);
log.info("Python 端响应: {}", result); log.info("Python 端响应: {}", result);