重构QGIS层:删除dto/entity/mapper,统一为单参数Controller直调Python
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
package com.gis.xian.controller;
|
||||
|
||||
import com.gis.xian.domain.ApiResponse;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeTriggerDTO;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeQuery;
|
||||
import com.gis.xian.service.qgis.earthquake.IEarthquakeEventService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: QGIS地震事件触发
|
||||
* @date 2026/5/25 下午3:12
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/open")
|
||||
public class DZEqEventController {
|
||||
@Resource
|
||||
private IEarthquakeEventService IEarthquakeEventService;
|
||||
|
||||
@PostMapping("/eq/trigger")
|
||||
public ApiResponse<EarthquakeQuery> trigger(@RequestBody @Validated EarthquakeTriggerDTO trigger) {
|
||||
EarthquakeQuery query = IEarthquakeEventService.trigger(trigger);
|
||||
return ApiResponse.ok(query);
|
||||
}
|
||||
|
||||
@PostMapping("/eq/delete/{Id}")
|
||||
public ApiResponse<Boolean> delete(@PathVariable Long Id) {
|
||||
Boolean deleted = IEarthquakeEventService.deletedById(Id);
|
||||
return ApiResponse.ok(deleted);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gis.xian.controller;
|
||||
|
||||
import com.gis.xian.service.qgis.base.IFeignService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* QGIS 专题图触发接口
|
||||
* 统一入口,只接收 simulationId,调用 Python 端处理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/open")
|
||||
public class QgisController {
|
||||
|
||||
@Resource
|
||||
private IFeignService feignService;
|
||||
|
||||
@PostMapping("/qgis/trigger")
|
||||
public void trigger(@RequestParam String simulationId) {
|
||||
log.info("收到专题图触发请求: simulationId={}", simulationId);
|
||||
feignService.trigger(simulationId);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.gis.xian.controller;
|
||||
|
||||
import com.gis.xian.domain.ApiResponse;
|
||||
import com.gis.xian.dto.qgis.rain.RainTriggerDTO;
|
||||
import com.gis.xian.dto.qgis.rain.RainQuery;
|
||||
import com.gis.xian.service.qgis.rain.IREventService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 暴雨事件控制类
|
||||
* @date 2026/6/8 下午4:36
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/open")
|
||||
public class REventController {
|
||||
|
||||
@Resource
|
||||
private IREventService irEventService;
|
||||
|
||||
@PostMapping("/rs/trigger")
|
||||
public ApiResponse<RainQuery> trigger(@RequestBody @Validated RainTriggerDTO trigger) {
|
||||
RainQuery query = irEventService.trigger(trigger);
|
||||
return ApiResponse.ok(query);
|
||||
}
|
||||
|
||||
@PostMapping("/rs/delete/{Id}")
|
||||
public ApiResponse<Boolean> delete(@PathVariable Long Id) {
|
||||
Boolean deleted = irEventService.deletedById(Id);
|
||||
return ApiResponse.ok(deleted);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.gis.xian.dto.qgis.base;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一专题图触发请求
|
||||
* 只传递 simulationId,Python 端根据 ID 自行查库决定模板和类型
|
||||
*/
|
||||
@Data
|
||||
public class QgisTriggerDTO {
|
||||
|
||||
/**
|
||||
* 模拟ID(事件唯一标识)
|
||||
*/
|
||||
private String simulationId;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.gis.xian.dto.qgis.earthquake;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震信息触发类
|
||||
* @date 2026/5/25 下午5:19
|
||||
*/
|
||||
@Data
|
||||
public class EarthquakeCenterDTO {
|
||||
|
||||
private String event;
|
||||
private LocalDateTime eqTime;
|
||||
private Double longitude;
|
||||
private Double latitude;
|
||||
private String eqAddr;
|
||||
private Double eqMagnitude;
|
||||
private Double eqDepth;
|
||||
private String eqFullName;
|
||||
private String eqName;
|
||||
private String eqType;
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.gis.xian.dto.qgis.earthquake;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震请求参数
|
||||
* @date 2026/5/25 下午4:48
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EarthquakeQuery {
|
||||
|
||||
private String event;
|
||||
private String eqQueueId;
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.gis.xian.dto.qgis.earthquake;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震触发DTO类
|
||||
* @date 2026/5/25 下午4:52
|
||||
*/
|
||||
@Data
|
||||
public class EarthquakeTriggerDTO {
|
||||
|
||||
private String eqName; // 地震名称
|
||||
|
||||
private String eqAddr; // 震发地点
|
||||
|
||||
private LocalDateTime eqTime; // 震发时间
|
||||
|
||||
private Double longitude; // 经度
|
||||
|
||||
private Double latitude; // 纬度
|
||||
|
||||
private Double eqDepth; // 震源深度
|
||||
|
||||
private Double eqMagnitude; // 震级
|
||||
|
||||
private String eqFullName; // 地震全称
|
||||
|
||||
private String eqType; // 地震类型(T:测试,Z:正式,Y:演练)
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gis.xian.dto.qgis.rain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 暴雨信息
|
||||
* @date 2026/6/8 下午4:49
|
||||
*/
|
||||
@Data
|
||||
public class RainEventDTO {
|
||||
|
||||
private String rainId;
|
||||
private String rainQueueId;
|
||||
private String disasterName;
|
||||
private String position;
|
||||
private LocalDateTime occurrenceTime;
|
||||
private String rainfall;
|
||||
private String duration;
|
||||
private Geometry geom; //经纬度
|
||||
private Double longitude;
|
||||
private Double latitude;
|
||||
private String rainType;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.gis.xian.dto.qgis.rain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 暴雨参数
|
||||
* @date 2026/6/8 下午4:43
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RainQuery {
|
||||
|
||||
private String rainId;
|
||||
private String rainQueueId;
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.gis.xian.dto.qgis.rain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: RTriggerDTO
|
||||
* @date 2026/6/8 下午4:44
|
||||
*/
|
||||
@Data
|
||||
public class RainTriggerDTO {
|
||||
|
||||
private String position; // 区县
|
||||
private double longitude; // 经度
|
||||
private double latitude; // 纬度
|
||||
private String rainfall; // 降雨量
|
||||
private String duration; // 已持续时间
|
||||
private String rainType; // 暴雨类型
|
||||
private LocalDateTime occurrenceTime; // 发生时间
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.gis.xian.entity.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.gis.xian.config.typehandler.GeometryTypeHandler;
|
||||
import lombok.Data;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震信息震中点
|
||||
* @date 2026/5/25 下午5:16
|
||||
*/
|
||||
@Data
|
||||
@TableName("dzxx.dz_gis_center")
|
||||
public class EarthquakeCenter {
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long Id;
|
||||
|
||||
@TableField(value = "geom", typeHandler = GeometryTypeHandler.class)
|
||||
private Geometry geom;
|
||||
|
||||
@TableField("event")
|
||||
private String event;
|
||||
|
||||
@TableField("eq_time")
|
||||
private LocalDateTime eqTime;
|
||||
|
||||
@TableField("eq_addr")
|
||||
private String eqAddr;
|
||||
|
||||
@TableField("longitude")
|
||||
private Double longitude;
|
||||
|
||||
@TableField("latitude")
|
||||
private Double latitude;
|
||||
|
||||
@TableField("eq_magnitude")
|
||||
private Double eqMagnitude;
|
||||
|
||||
@TableField("eq_depth")
|
||||
private Double eqDepth;
|
||||
|
||||
@TableField("eq_full_name")
|
||||
private String eqFullName;
|
||||
|
||||
@TableField("eq_name")
|
||||
private String eqName;
|
||||
|
||||
@TableField("eq_type")
|
||||
private String eqType;
|
||||
|
||||
@TableField("eq_addr_code")
|
||||
private String eqAddrCode;
|
||||
|
||||
@TableField("town_code")
|
||||
private String townCode;
|
||||
|
||||
@TableLogic
|
||||
@TableField("del_flag")
|
||||
private Integer delFlag = 0;
|
||||
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT_UPDATE)
|
||||
private String createBy;
|
||||
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.gis.xian.entity.qgis.earthquake;
|
||||
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震事件表
|
||||
* @date 2026/5/25 下午3:24
|
||||
*/
|
||||
@Data
|
||||
@TableName("public.dz_eqevent")
|
||||
public class EarthquakeEvent {
|
||||
|
||||
@TableId(value = "id",type = IdType.ASSIGN_ID)
|
||||
private Long Id;
|
||||
@TableField("event")
|
||||
private String event;
|
||||
@TableField("eq_time")
|
||||
private LocalDateTime eqTime;
|
||||
@TableField("eq_addr")
|
||||
private String eqAddr;
|
||||
@TableField("longitude")
|
||||
private Double longitude;
|
||||
@TableField("latitude")
|
||||
private Double latitude;
|
||||
@TableField("eq_magnitude")
|
||||
private Double eqMagnitude;
|
||||
@TableField("eq_depth")
|
||||
private Double eqDepth;
|
||||
@TableField("eq_full_name")
|
||||
private String eqFullName;
|
||||
@TableField("eq_name")
|
||||
private String eqName;
|
||||
@TableField("eq_type")
|
||||
private String eqType;
|
||||
@TableField("eq_addr_code")
|
||||
private String eqAddrCode;
|
||||
@TableField("town_code")
|
||||
private String townCode;
|
||||
@TableField("distance")
|
||||
private Double distance;
|
||||
@TableField("region")
|
||||
private Integer region;
|
||||
@TableField("damage_type")
|
||||
private Integer damageType;
|
||||
@TableField("direction")
|
||||
private Double direction;
|
||||
@TableLogic
|
||||
@TableField("del_flag")
|
||||
private Integer delFlag = 0;
|
||||
@TableField(value = "create_by",fill = FieldFill.INSERT_UPDATE)
|
||||
private String createBy;
|
||||
@TableField(value = "create_time",fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime createTime;
|
||||
@TableField(value = "create_dept",fill = FieldFill.INSERT_UPDATE)
|
||||
private String createDept;
|
||||
@TableField(value = "update_by",fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
@TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
@TableField("xyjb")
|
||||
private String xyjb; // 相应级别
|
||||
@TableField("source")
|
||||
private Integer source;
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.gis.xian.entity.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震评估表
|
||||
* @date 2026/5/25 下午6:01
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("public.dz_eqqueue")
|
||||
public class EarthquakeQueue {
|
||||
|
||||
@TableField(value = "id")
|
||||
private String id; // eqqueueid
|
||||
@TableField("event")
|
||||
private String event;
|
||||
@TableField("batch")
|
||||
private Integer batch;
|
||||
@TableField("type")
|
||||
private Integer type;
|
||||
@TableField("state")
|
||||
private Integer state; //评估状态(0未开始,1正在计算,2正常完成,3人工停止,4超时或异常结束, 5不计算)
|
||||
@TableField("mode")
|
||||
private Integer mode = 1; // 执行方式(0地震参数 1影响场)
|
||||
@TableField("begin_time")
|
||||
private LocalDateTime beginTime;
|
||||
@TableField("end_time")
|
||||
private LocalDateTime endTime;
|
||||
@TableField("progress")
|
||||
private Double progress;
|
||||
@TableLogic
|
||||
@TableField(value = "del_flag", fill = FieldFill.INSERT_UPDATE)
|
||||
private Integer delFlag;
|
||||
@TableField(value = "create_by", fill = FieldFill.INSERT_UPDATE)
|
||||
private String createBy;
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime createTime;
|
||||
@TableField(value = "create_dept", fill = FieldFill.INSERT_UPDATE)
|
||||
private Integer createDept;
|
||||
@TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
@Version
|
||||
@TableField(value = "version", fill = FieldFill.INSERT_UPDATE)
|
||||
private Integer version; // 版本号
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.gis.xian.entity.qgis.rain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.gis.xian.config.typehandler.GeometryTypeHandler;
|
||||
import lombok.Data;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 暴雨事件表
|
||||
* @date 2026/6/8 下午4:38
|
||||
*/
|
||||
@Data
|
||||
@TableName("public.r_event")
|
||||
public class RainEvent {
|
||||
|
||||
@TableId
|
||||
@TableField("id")
|
||||
private Long Id;
|
||||
@TableField("rain_id")
|
||||
private String rainId;
|
||||
@TableField("rain_queue_id")
|
||||
private String rainQueueId;
|
||||
@TableField("disaster_name")
|
||||
private String disasterName;
|
||||
@TableField("position")
|
||||
private String position;
|
||||
@TableField("occurrence_time")
|
||||
private LocalDateTime occurrenceTime;
|
||||
@TableField("rainfall")
|
||||
private String rainfall;
|
||||
@TableField("duration")
|
||||
private String duration;
|
||||
@TableField(value = "geom", typeHandler = GeometryTypeHandler.class)
|
||||
private Geometry geom; //经纬度
|
||||
@TableField("longitude")
|
||||
private Double longitude;
|
||||
@TableField("latitude")
|
||||
private Double latitude;
|
||||
@TableField("rain_type")
|
||||
private String rainType;
|
||||
@TableField(value = "create_time",fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime createTime;
|
||||
@TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
@TableField("is_deleted")
|
||||
private Integer delFlag = 0;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gis.xian.mapper.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeCenter;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震事件
|
||||
* @date 2026/5/25 下午5:21
|
||||
*/
|
||||
@Mapper
|
||||
public interface EarthquakeCenterMapper extends BaseMapper<EarthquakeCenter> {
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gis.xian.mapper.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeEvent;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震事件表
|
||||
* @date 2026/5/25 下午5:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface EarthquakeEventMapper extends BaseMapper<EarthquakeEvent> {
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gis.xian.mapper.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeQueue;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震评估表
|
||||
* @date 2026/5/25 下午6:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface EarthquakeQueueMapper extends BaseMapper<EarthquakeQueue> {
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gis.xian.mapper.qgis.rain;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gis.xian.entity.qgis.rain.RainEvent;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: REventMapper
|
||||
* @date 2026/6/8 下午6:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface RainEventMapper extends BaseMapper<RainEvent> {
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gis.xian.service.qgis.base;
|
||||
|
||||
import com.gis.xian.dto.qgis.base.QgisTriggerDTO;
|
||||
|
||||
/**
|
||||
* 统一专题图触发接口
|
||||
* 只负责调用 Python 端,不返回结果
|
||||
@@ -10,7 +8,7 @@ public interface IFeignService {
|
||||
|
||||
/**
|
||||
* 触发专题图生成
|
||||
* @param triggerDTO 包含 simulationId 和 type
|
||||
* @param simulationId 模拟ID
|
||||
*/
|
||||
void trigger(QgisTriggerDTO triggerDTO);
|
||||
void trigger(String simulationId);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gis.xian.service.qgis.base.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.gis.xian.dto.qgis.base.QgisTriggerDTO;
|
||||
import com.gis.xian.service.qgis.base.IFeignService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -10,6 +8,8 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 统一专题图触发服务
|
||||
* 只负责调用 Python QGIS 服务,不处理计算和存库
|
||||
@@ -25,21 +25,20 @@ public class FeignServiceImpl implements IFeignService {
|
||||
private String qgisUrl;
|
||||
|
||||
@Override
|
||||
public void trigger(QgisTriggerDTO triggerDTO) {
|
||||
if (triggerDTO == null || triggerDTO.getSimulationId() == null) {
|
||||
log.error("触发参数为空,simulationId={}",
|
||||
triggerDTO != null ? triggerDTO.getSimulationId() : null);
|
||||
public void trigger(String simulationId) {
|
||||
if (simulationId == null || simulationId.isBlank()) {
|
||||
log.error("触发参数为空,simulationId={}", simulationId);
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("触发专题图生成: simulationId={}", triggerDTO.getSimulationId());
|
||||
log.info("触发专题图生成: simulationId={}", simulationId);
|
||||
|
||||
try {
|
||||
RestClient client = restClientBuilder.build();
|
||||
String result = client.post()
|
||||
.uri(qgisUrl)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body(JSON.toJSON(triggerDTO))
|
||||
.body(Map.of("simulationId", simulationId))
|
||||
.retrieve()
|
||||
.body(String.class);
|
||||
log.info("Python 端响应: {}", result);
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.gis.xian.service.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gis.xian.config.DataSource;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeTriggerDTO;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeEvent;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeQuery;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: QGIS地震事件触发
|
||||
* @date 2026/5/25 下午3:23
|
||||
*/
|
||||
@DataSource("slave1")
|
||||
public interface IEarthquakeEventService extends IService<EarthquakeEvent> {
|
||||
|
||||
// 地震触发
|
||||
public EarthquakeQuery trigger(EarthquakeTriggerDTO trigger);
|
||||
|
||||
// 删除地震事件
|
||||
public Boolean deletedById(Long Id);
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.gis.xian.service.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gis.xian.config.DataSource;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeCenterDTO;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeCenter;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震信息
|
||||
* @date 2026/5/25 下午5:01
|
||||
*/
|
||||
@DataSource("slave1")
|
||||
public interface IEarthquakeInformationCenterService extends IService<EarthquakeCenter> {
|
||||
|
||||
// 地震触发
|
||||
public void handle(EarthquakeCenterDTO trigger);
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.gis.xian.service.qgis.earthquake;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeQueue;
|
||||
|
||||
/**
|
||||
* 地震评估队列服务
|
||||
* 只负责触发 Python 端生成专题图
|
||||
*/
|
||||
public interface IEarthquakeQueueService extends IService<EarthquakeQueue> {
|
||||
|
||||
/**
|
||||
* 触发专题图生成
|
||||
* @param simulationId 模拟ID
|
||||
*/
|
||||
void trigger(String simulationId);
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package com.gis.xian.service.qgis.earthquake.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gis.xian.config.DataSource;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeCenterDTO;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeTriggerDTO;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeEvent;
|
||||
import com.gis.xian.mapper.qgis.earthquake.EarthquakeEventMapper;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeQuery;
|
||||
import com.gis.xian.service.qgis.earthquake.IEarthquakeInformationCenterService;
|
||||
import com.gis.xian.service.ex.ParmaException;
|
||||
import com.gis.xian.service.ex.ServeException;
|
||||
import com.gis.xian.service.qgis.earthquake.IEarthquakeEventService;
|
||||
import com.gis.xian.service.qgis.earthquake.IEarthquakeQueueService;
|
||||
import com.gis.xian.utils.BaseUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 地震事件服务
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@DataSource("slave1")
|
||||
public class EarthquakeEventServiceImpl extends ServiceImpl<EarthquakeEventMapper, EarthquakeEvent>
|
||||
implements IEarthquakeEventService {
|
||||
|
||||
@Resource
|
||||
private IEarthquakeInformationCenterService informationCenterService;
|
||||
@Resource
|
||||
private IEarthquakeQueueService queueService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public EarthquakeQuery trigger(EarthquakeTriggerDTO trigger) {
|
||||
log.info("地震参数:{}", trigger);
|
||||
if (trigger == null) {
|
||||
throw new ParmaException("参数有误,请重新传入!");
|
||||
}
|
||||
|
||||
String code = BaseUtils.generationCode(trigger.getEqTime());
|
||||
|
||||
try {
|
||||
EarthquakeCenterDTO dzxx = new EarthquakeCenterDTO();
|
||||
BeanUtils.copyProperties(trigger, dzxx);
|
||||
dzxx.setEvent(code);
|
||||
log.info("地震专题图编码:{}", code);
|
||||
informationCenterService.handle(dzxx);
|
||||
EarthquakeEvent dzeq = new EarthquakeEvent();
|
||||
BeanUtils.copyProperties(dzxx, dzeq);
|
||||
save(dzeq);
|
||||
log.info("地震基本信息已存库...");
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
throw new ServeException("地震业务出错!");
|
||||
}
|
||||
|
||||
String batch = BaseUtils.generationBatchCode(code);
|
||||
queueService.trigger(code);
|
||||
return new EarthquakeQuery(code, batch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deletedById(Long Id) {
|
||||
if (Id == null) {
|
||||
throw new ParmaException("参数有误,请重新传入!");
|
||||
}
|
||||
LambdaQueryWrapper<EarthquakeEvent> lambdaQuery = Wrappers.lambdaQuery(EarthquakeEvent.class);
|
||||
lambdaQuery.eq(EarthquakeEvent::getId, Id);
|
||||
return this.baseMapper.delete(lambdaQuery) > 0;
|
||||
}
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package com.gis.xian.service.qgis.earthquake.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gis.xian.config.DataSource;
|
||||
import com.gis.xian.dto.qgis.earthquake.EarthquakeCenterDTO;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeCenter;
|
||||
import com.gis.xian.mapper.qgis.earthquake.EarthquakeCenterMapper;
|
||||
import com.gis.xian.service.qgis.earthquake.IEarthquakeInformationCenterService;
|
||||
import com.gis.xian.service.ex.ParmaException;
|
||||
import com.gis.xian.service.ex.ServiceException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.GeometryFactory;
|
||||
import org.locationtech.jts.geom.Point;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 地震事件
|
||||
* @date 2026/5/25 下午5:21
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@DataSource("slave1")
|
||||
public class EarthquakeInformationCenterServiceImpl extends ServiceImpl<EarthquakeCenterMapper, EarthquakeCenter> implements IEarthquakeInformationCenterService {
|
||||
|
||||
// 地震触发
|
||||
@Override
|
||||
public void handle(EarthquakeCenterDTO dzxxdto) {
|
||||
// 抛出异常
|
||||
if (dzxxdto == null) {
|
||||
throw new ParmaException("参数有误,请重新传入!");
|
||||
}
|
||||
|
||||
try {
|
||||
EarthquakeCenter dzxx = new EarthquakeCenter();
|
||||
BeanUtils.copyProperties(dzxxdto, dzxx);
|
||||
// 处理空间数据
|
||||
GeometryFactory geometryFactory = new GeometryFactory();
|
||||
Point point = geometryFactory.createPoint(new Coordinate(
|
||||
dzxxdto.getLongitude(), dzxxdto.getLatitude()
|
||||
));
|
||||
dzxx.setGeom(point);
|
||||
dzxx.getGeom().setSRID(4490);
|
||||
// 存库
|
||||
save(dzxx);
|
||||
log.info("震中位置信息已存库...");
|
||||
} catch (Exception ex) {
|
||||
log.error("地震触发:震中位置信息保存失败!", ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
throw new ServiceException("地震业务出错!");
|
||||
}
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.gis.xian.service.qgis.earthquake.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gis.xian.config.DataSource;
|
||||
import com.gis.xian.dto.qgis.base.QgisTriggerDTO;
|
||||
import com.gis.xian.entity.qgis.earthquake.EarthquakeQueue;
|
||||
import com.gis.xian.mapper.qgis.earthquake.EarthquakeQueueMapper;
|
||||
import com.gis.xian.service.qgis.base.IFeignService;
|
||||
import com.gis.xian.service.qgis.earthquake.IEarthquakeQueueService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 地震评估队列服务
|
||||
* 只负责触发 Python 端生成专题图
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@DataSource("slave1")
|
||||
public class EarthquakeQueueServiceImpl extends ServiceImpl<EarthquakeQueueMapper, EarthquakeQueue>
|
||||
implements IEarthquakeQueueService {
|
||||
|
||||
@Resource
|
||||
private IFeignService feignService;
|
||||
|
||||
@Override
|
||||
public void trigger(String simulationId) {
|
||||
log.info("触发专题图生成: simulationId={}", simulationId);
|
||||
QgisTriggerDTO triggerDTO = new QgisTriggerDTO();
|
||||
triggerDTO.setSimulationId(simulationId);
|
||||
feignService.trigger(triggerDTO);
|
||||
log.info("专题图触发完成: simulationId={}", simulationId);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.gis.xian.service.qgis.rain;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gis.xian.config.DataSource;
|
||||
import com.gis.xian.dto.qgis.rain.RainTriggerDTO;
|
||||
import com.gis.xian.entity.qgis.rain.RainEvent;
|
||||
import com.gis.xian.dto.qgis.rain.RainQuery;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: IREventService
|
||||
* @date 2026/6/8 下午6:01
|
||||
*/
|
||||
@DataSource("slave1")
|
||||
public interface IREventService extends IService<RainEvent> {
|
||||
// 暴雨触发
|
||||
public RainQuery trigger(RainTriggerDTO trigger);
|
||||
|
||||
// 删除暴雨事件
|
||||
public Boolean deletedById(Long Id);
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.gis.xian.service.qgis.rain.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gis.xian.config.DataSource;
|
||||
import com.gis.xian.dto.qgis.rain.RainEventDTO;
|
||||
import com.gis.xian.dto.qgis.rain.RainTriggerDTO;
|
||||
import com.gis.xian.entity.qgis.rain.RainEvent;
|
||||
import com.gis.xian.mapper.qgis.rain.RainEventMapper;
|
||||
import com.gis.xian.dto.qgis.rain.RainQuery;
|
||||
import com.gis.xian.service.ex.ParmaException;
|
||||
import com.gis.xian.service.ex.ServeException;
|
||||
import com.gis.xian.service.ex.ServiceException;
|
||||
import com.gis.xian.service.qgis.earthquake.IEarthquakeQueueService;
|
||||
import com.gis.xian.service.qgis.rain.IREventService;
|
||||
import com.gis.xian.utils.BaseUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.GeometryFactory;
|
||||
import org.locationtech.jts.geom.Point;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 暴雨事件服务
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@DataSource("slave1")
|
||||
public class RainEventServiceImpl extends ServiceImpl<RainEventMapper, RainEvent> implements IREventService {
|
||||
|
||||
@Resource
|
||||
private IEarthquakeQueueService queueService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public RainQuery trigger(RainTriggerDTO trigger) {
|
||||
log.info("暴雨参数:{}", trigger);
|
||||
if (trigger == null) {
|
||||
throw new ParmaException("参数有误,请重新传入!");
|
||||
}
|
||||
|
||||
String code = BaseUtils.generationRainCode(trigger.getOccurrenceTime());
|
||||
|
||||
try {
|
||||
RainEventDTO eventdto = new RainEventDTO();
|
||||
BeanUtils.copyProperties(trigger, eventdto);
|
||||
eventdto.setRainId(code);
|
||||
log.info("暴雨专题图编码:{}", code);
|
||||
handle(eventdto);
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
throw new ServeException("暴雨业务出错!");
|
||||
}
|
||||
|
||||
String batch = BaseUtils.generationBatchCode(code);
|
||||
queueService.trigger(code);
|
||||
return new RainQuery(code, batch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deletedById(Long Id) {
|
||||
if (Id == null) {
|
||||
throw new ParmaException("参数有误,请重新传入!");
|
||||
}
|
||||
LambdaQueryWrapper<RainEvent> lambdaQuery = Wrappers.lambdaQuery(RainEvent.class);
|
||||
lambdaQuery.eq(RainEvent::getId, Id);
|
||||
return this.baseMapper.delete(lambdaQuery) > 0;
|
||||
}
|
||||
|
||||
private void handle(RainEventDTO eventdto) {
|
||||
if (eventdto == null) {
|
||||
throw new ParmaException("参数有误,请重新传入!");
|
||||
}
|
||||
try {
|
||||
RainEvent revent = new RainEvent();
|
||||
BeanUtils.copyProperties(eventdto, revent);
|
||||
GeometryFactory geometryFactory = new GeometryFactory();
|
||||
Point point = geometryFactory.createPoint(new Coordinate(
|
||||
eventdto.getLongitude(), eventdto.getLatitude()
|
||||
));
|
||||
revent.setGeom(point);
|
||||
revent.getGeom().setSRID(4490);
|
||||
save(revent);
|
||||
log.info("暴雨基本信息已存库...");
|
||||
} catch (Exception ex) {
|
||||
log.error("暴雨触发:暴雨基本信息保存失败!", ex.getMessage());
|
||||
throw new ServiceException("暴雨业务出错!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.gis.xian.utils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @author zzw
|
||||
* @description: 基本工具类
|
||||
* @date 2026/5/25 下午6:06
|
||||
*/
|
||||
public class BaseUtils {
|
||||
// 生成一个带时间戳的地震编码
|
||||
public static String generationCode(LocalDateTime time) {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
String timestamp = time.format(formatter);
|
||||
String code = "T" + timestamp + "511800";
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
public static String formatTime(LocalDateTime time, boolean top) {
|
||||
// true 三要素 false 落款)
|
||||
if (top) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时 mm分");
|
||||
String timestamp = time.format(formatter);
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
|
||||
String timestamp = time.format(formatter);
|
||||
return timestamp;
|
||||
|
||||
}
|
||||
|
||||
// 首次生成批次编码
|
||||
public static String generationBatchCode(String code) {
|
||||
return code + "01";
|
||||
}
|
||||
|
||||
// 修改地震批次编码
|
||||
public static String editBatchCode(String code) {
|
||||
|
||||
String prefix = code.substring(0, code.length() - 2);
|
||||
String last = code.substring(code.length() - 2);
|
||||
return prefix + Integer.parseInt(last) + 1;
|
||||
}
|
||||
|
||||
// 生成一个带时间戳的暴雨编码
|
||||
public static String generationRainCode(LocalDateTime time) {
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
String timestamp = time.format(formatter);
|
||||
String code = "R" + timestamp + "511800";
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
// 计算评估进度 0:地震、1:暴雨
|
||||
public static double compute(int finish, int type) {
|
||||
if (type == 0) {
|
||||
return (double) finish / 20 * 100;
|
||||
}
|
||||
return (double) finish / 15 * 100;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user