添加预测概率
This commit is contained in:
@@ -22,8 +22,8 @@ public class XianHiddenDangerSpotsController extends BaseController{
|
|||||||
return ApiResponse.ok(xianHiddenDangerSpotsService.getBasePoints(disasterType));
|
return ApiResponse.ok(xianHiddenDangerSpotsService.getBasePoints(disasterType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("point-detail/{id}")
|
@GetMapping("point-detail/{id}/{simulationId}")
|
||||||
public ApiResponse<XianHiddenDangerSpotsPointDetailVo> getPointDetailById(@PathVariable String id) {
|
public ApiResponse<XianHiddenDangerSpotsPointDetailVo> getPointDetailById(@PathVariable String id, @PathVariable String simulationId) {
|
||||||
return ApiResponse.ok(xianHiddenDangerSpotsService.getPointDetailById(Long.parseLong(id)));
|
return ApiResponse.ok(xianHiddenDangerSpotsService.getPointDetailById(Long.parseLong(id), Long.parseLong(simulationId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public class XianRiskSpotsController {
|
|||||||
return ApiResponse.ok(xianRiskSpotsService.getBasePoints());
|
return ApiResponse.ok(xianRiskSpotsService.getBasePoints());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("point-detail/{id}")
|
@GetMapping("point-detail/{id}/{simulationId}")
|
||||||
public ApiResponse<XianRiskSpotsPointDetailVo> getPointDetailById(@PathVariable String id) {
|
public ApiResponse<XianRiskSpotsPointDetailVo> getPointDetailById(@PathVariable String id, @PathVariable String simulationId) {
|
||||||
return ApiResponse.ok(xianRiskSpotsService.getPointDetailById(Long.parseLong(id)));
|
return ApiResponse.ok(xianRiskSpotsService.getPointDetailById(Long.parseLong(id), Long.parseLong(simulationId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,221 @@
|
|||||||
|
package com.gis.xian.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推理结果表
|
||||||
|
* @TableName xian_inference_result
|
||||||
|
*/
|
||||||
|
public class XianInferenceResult {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件类型
|
||||||
|
*/
|
||||||
|
private String eventType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发生时间
|
||||||
|
*/
|
||||||
|
private Date occurredTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作类型
|
||||||
|
*/
|
||||||
|
private String operationType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推理结果(JSONB)
|
||||||
|
*/
|
||||||
|
private Object result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 条件(JSONB)
|
||||||
|
*/
|
||||||
|
private Object condition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件路径(JSONB)
|
||||||
|
*/
|
||||||
|
private Object filePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除(0: 未删除, 1: 已删除)
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
|
||||||
|
// 构造方法
|
||||||
|
public XianInferenceResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public XianInferenceResult(Long id, String name, String eventType, Date occurredTime,
|
||||||
|
String operationType, Object result, Object condition,
|
||||||
|
Object filePath, Date createTime, Integer isDelete) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.eventType = eventType;
|
||||||
|
this.occurredTime = occurredTime;
|
||||||
|
this.operationType = operationType;
|
||||||
|
this.result = result;
|
||||||
|
this.condition = condition;
|
||||||
|
this.filePath = filePath;
|
||||||
|
this.createTime = createTime;
|
||||||
|
this.isDelete = isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getter 和 Setter 方法
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEventType() {
|
||||||
|
return eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventType(String eventType) {
|
||||||
|
this.eventType = eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getOccurredTime() {
|
||||||
|
return occurredTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOccurredTime(Date occurredTime) {
|
||||||
|
this.occurredTime = occurredTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperationType() {
|
||||||
|
return operationType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperationType(String operationType) {
|
||||||
|
this.operationType = operationType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(Object result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getCondition() {
|
||||||
|
return condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCondition(Object condition) {
|
||||||
|
this.condition = condition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getFilePath() {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilePath(Object filePath) {
|
||||||
|
this.filePath = filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsDelete() {
|
||||||
|
return isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDelete(Integer isDelete) {
|
||||||
|
this.isDelete = isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (this == that) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (that == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != that.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
XianInferenceResult other = (XianInferenceResult) that;
|
||||||
|
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||||
|
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||||
|
&& (this.getEventType() == null ? other.getEventType() == null : this.getEventType().equals(other.getEventType()))
|
||||||
|
&& (this.getOccurredTime() == null ? other.getOccurredTime() == null : this.getOccurredTime().equals(other.getOccurredTime()))
|
||||||
|
&& (this.getOperationType() == null ? other.getOperationType() == null : this.getOperationType().equals(other.getOperationType()))
|
||||||
|
&& (this.getResult() == null ? other.getResult() == null : this.getResult().equals(other.getResult()))
|
||||||
|
&& (this.getCondition() == null ? other.getCondition() == null : this.getCondition().equals(other.getCondition()))
|
||||||
|
&& (this.getFilePath() == null ? other.getFilePath() == null : this.getFilePath().equals(other.getFilePath()))
|
||||||
|
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||||
|
&& (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||||
|
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||||
|
result = prime * result + ((getEventType() == null) ? 0 : getEventType().hashCode());
|
||||||
|
result = prime * result + ((getOccurredTime() == null) ? 0 : getOccurredTime().hashCode());
|
||||||
|
result = prime * result + ((getOperationType() == null) ? 0 : getOperationType().hashCode());
|
||||||
|
result = prime * result + ((getResult() == null) ? 0 : getResult().hashCode());
|
||||||
|
result = prime * result + ((getCondition() == null) ? 0 : getCondition().hashCode());
|
||||||
|
result = prime * result + ((getFilePath() == null) ? 0 : getFilePath().hashCode());
|
||||||
|
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||||
|
result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(getClass().getSimpleName());
|
||||||
|
sb.append(" [");
|
||||||
|
sb.append("Hash = ").append(hashCode());
|
||||||
|
sb.append(", id=").append(id);
|
||||||
|
sb.append(", name=").append(name);
|
||||||
|
sb.append(", eventType=").append(eventType);
|
||||||
|
sb.append(", occurredTime=").append(occurredTime);
|
||||||
|
sb.append(", operationType=").append(operationType);
|
||||||
|
sb.append(", result=").append(result);
|
||||||
|
sb.append(", condition=").append(condition);
|
||||||
|
sb.append(", filePath=").append(filePath);
|
||||||
|
sb.append(", createTime=").append(createTime);
|
||||||
|
sb.append(", isDelete=").append(isDelete);
|
||||||
|
sb.append("]");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.gis.xian.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wzy
|
||||||
|
* @description 针对表【xian_inference_result(预测结果表)】的数据库操作Mapper
|
||||||
|
* @createDate 2026-06-17 11:58:32
|
||||||
|
* @Entity com.gis.xian.entity.XianInferenceResult
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface XianInferenceResultMapper {
|
||||||
|
/**
|
||||||
|
* 根据id和pointId获取概率
|
||||||
|
* @param id 预测结果id
|
||||||
|
* @param pointId 隐患点/风险点id和类型
|
||||||
|
* @return 预测概率
|
||||||
|
*/
|
||||||
|
String getProbabilityByIdAndPointId(@Param("id") Long id, @Param("pointId") String pointId);
|
||||||
|
}
|
||||||
@@ -17,7 +17,8 @@ public interface XianHiddenDangerSpotsService {
|
|||||||
/**
|
/**
|
||||||
* 根据id获取隐患点详情
|
* 根据id获取隐患点详情
|
||||||
* @param id 隐患点id
|
* @param id 隐患点id
|
||||||
|
* @param simulationId 模拟id
|
||||||
* @return 隐患点详情
|
* @return 隐患点详情
|
||||||
*/
|
*/
|
||||||
XianHiddenDangerSpotsPointDetailVo getPointDetailById(Long id);
|
XianHiddenDangerSpotsPointDetailVo getPointDetailById(Long id, Long simulationId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public interface XianRiskSpotsService {
|
|||||||
/**
|
/**
|
||||||
* 根据id获取风险点详情
|
* 根据id获取风险点详情
|
||||||
* @param id 风险点id
|
* @param id 风险点id
|
||||||
|
* @param simulationId 模拟id
|
||||||
* @return 风险点详情
|
* @return 风险点详情
|
||||||
*/
|
*/
|
||||||
XianRiskSpotsPointDetailVo getPointDetailById(Long id);
|
XianRiskSpotsPointDetailVo getPointDetailById(Long id, Long simulationId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.gis.xian.service.impl;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.gis.xian.entity.XianHiddenDangerSpots;
|
import com.gis.xian.entity.XianHiddenDangerSpots;
|
||||||
|
import com.gis.xian.mapper.XianInferenceResultMapper;
|
||||||
import com.gis.xian.vo.XianHiddenDangerSpotsBasePointVo;
|
import com.gis.xian.vo.XianHiddenDangerSpotsBasePointVo;
|
||||||
import com.gis.xian.vo.XianHiddenDangerSpotsPointDetailVo;
|
import com.gis.xian.vo.XianHiddenDangerSpotsPointDetailVo;
|
||||||
import com.gis.xian.mapper.XianHiddenDangerSpotsMapper;
|
import com.gis.xian.mapper.XianHiddenDangerSpotsMapper;
|
||||||
@@ -22,6 +23,9 @@ public class IXianHiddenDangerSpotsServiceImpl implements XianHiddenDangerSpotsS
|
|||||||
@Resource
|
@Resource
|
||||||
private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper;
|
private XianHiddenDangerSpotsMapper xianHiddenDangerSpotsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private XianInferenceResultMapper xianInferenceResultMapper;
|
||||||
|
|
||||||
@Value("${init.data.base-points.hidden-danger.all}")
|
@Value("${init.data.base-points.hidden-danger.all}")
|
||||||
private String allBasePointsKey;
|
private String allBasePointsKey;
|
||||||
|
|
||||||
@@ -85,7 +89,14 @@ public class IXianHiddenDangerSpotsServiceImpl implements XianHiddenDangerSpotsS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XianHiddenDangerSpotsPointDetailVo getPointDetailById(Long id) {
|
public XianHiddenDangerSpotsPointDetailVo getPointDetailById(Long id, Long simulationId) {
|
||||||
return XianHiddenDangerSpotsPointDetailVo.entity2Vo(xianHiddenDangerSpotsMapper.getPointDetailById(id));
|
XianHiddenDangerSpotsPointDetailVo pointDetail = XianHiddenDangerSpotsPointDetailVo.entity2Vo(xianHiddenDangerSpotsMapper.getPointDetailById(id));
|
||||||
|
|
||||||
|
// 根据模拟id和id获取预测结果
|
||||||
|
if(simulationId != null && simulationId != -1L) {
|
||||||
|
pointDetail.setProbability(xianInferenceResultMapper.getProbabilityByIdAndPointId(simulationId, id + "_1") + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
return pointDetail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.gis.xian.service.impl;
|
package com.gis.xian.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.gis.xian.mapper.XianInferenceResultMapper;
|
||||||
|
import com.gis.xian.vo.XianHiddenDangerSpotsPointDetailVo;
|
||||||
import com.gis.xian.vo.XianRiskSpotsBasePointVo;
|
import com.gis.xian.vo.XianRiskSpotsBasePointVo;
|
||||||
import com.gis.xian.vo.XianRiskSpotsPointDetailVo;
|
import com.gis.xian.vo.XianRiskSpotsPointDetailVo;
|
||||||
import com.gis.xian.mapper.XianRiskSpotsMapper;
|
import com.gis.xian.mapper.XianRiskSpotsMapper;
|
||||||
@@ -21,6 +23,9 @@ public class IXianRiskSpotsServiceImpl implements XianRiskSpotsService {
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private XianInferenceResultMapper xianInferenceResultMapper;
|
||||||
|
|
||||||
@Value("${init.data.base-points.risk}")
|
@Value("${init.data.base-points.risk}")
|
||||||
private String riskPointKey;
|
private String riskPointKey;
|
||||||
|
|
||||||
@@ -39,7 +44,14 @@ public class IXianRiskSpotsServiceImpl implements XianRiskSpotsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XianRiskSpotsPointDetailVo getPointDetailById(Long id) {
|
public XianRiskSpotsPointDetailVo getPointDetailById(Long id, Long simulationId) {
|
||||||
return XianRiskSpotsPointDetailVo.entity2Vo(xianRiskSpotsMapper.getPointDetailById(id));
|
XianRiskSpotsPointDetailVo pointDetail = XianRiskSpotsPointDetailVo.entity2Vo(xianRiskSpotsMapper.getPointDetailById(id));
|
||||||
|
|
||||||
|
// 根据模拟id和id获取预测结果
|
||||||
|
if(simulationId != null && simulationId != -1L) {
|
||||||
|
pointDetail.setProbability(xianInferenceResultMapper.getProbabilityByIdAndPointId(simulationId, id + "_2") + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
return pointDetail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ public class XianHiddenDangerSpotsPointDetailVo {
|
|||||||
*/
|
*/
|
||||||
private String riskGrade;
|
private String riskGrade;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 概率
|
||||||
|
*/
|
||||||
|
private String probability;
|
||||||
|
|
||||||
public static XianHiddenDangerSpotsPointDetailVo entity2Vo(XianHiddenDangerSpots entity) {
|
public static XianHiddenDangerSpotsPointDetailVo entity2Vo(XianHiddenDangerSpots entity) {
|
||||||
XianHiddenDangerSpotsPointDetailVo vo = new XianHiddenDangerSpotsPointDetailVo();
|
XianHiddenDangerSpotsPointDetailVo vo = new XianHiddenDangerSpotsPointDetailVo();
|
||||||
vo.setId(entity.getId());
|
vo.setId(entity.getId());
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ public class XianRiskSpotsPointDetailVo {
|
|||||||
*/
|
*/
|
||||||
private Double lat;
|
private Double lat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 概率
|
||||||
|
*/
|
||||||
|
private String probability;
|
||||||
|
|
||||||
public static XianRiskSpotsPointDetailVo entity2Vo(XianRiskSpots entity) {
|
public static XianRiskSpotsPointDetailVo entity2Vo(XianRiskSpots entity) {
|
||||||
XianRiskSpotsPointDetailVo vo = new XianRiskSpotsPointDetailVo();
|
XianRiskSpotsPointDetailVo vo = new XianRiskSpotsPointDetailVo();
|
||||||
vo.setId(entity.getId());
|
vo.setId(entity.getId());
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.gis.xian.mapper.XianInferenceResultMapper">
|
||||||
|
|
||||||
|
<resultMap id="XianInferenceResultResultMap" type="com.gis.xian.entity.XianInferenceResult">
|
||||||
|
<id property="id" column="id" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<result property="eventType" column="event_type" />
|
||||||
|
<result property="occurredTime" column="occurred_time" />
|
||||||
|
<result property="operationType" column="operation_type" />
|
||||||
|
<result property="result" column="result" />
|
||||||
|
<result property="condition" column="condition" />
|
||||||
|
<result property="filePath" column="file_path" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="isDelete" column="is_delete" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 根据id和pointId获取概率 -->
|
||||||
|
<select id="getProbabilityByIdAndPointId" resultType="java.lang.String">
|
||||||
|
SELECT result->>#{pointId} FROM xian_inference_result
|
||||||
|
<where>
|
||||||
|
id = #{id}
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user