Commit b74bcf3f authored by wujipeng's avatar wujipeng
Browse files

init

parents
Pipeline #340 failed with stages
in 0 seconds
/mvnw text eol=lf
*.cmd text eol=crlf
HELP.md
target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.16/apache-maven-3.9.16-bin.zip
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.6</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>pipeline-network</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.15</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.38</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.19.0</version> <!-- 或最新版 -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.7.6</version>
<configuration>
<mainClass>com.example.pipelinenetwork.PipelineNetworkApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.example.pipelinenetwork;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("com.example.pipelinenetwork.mapper")
public class PipelineNetworkApplication {
public static void main(String[] args) {
SpringApplication.run(PipelineNetworkApplication.class, args);
}
}
package com.example.pipelinenetwork.controller;
import com.example.pipelinenetwork.pojo.vo.RoadVO;
import com.example.pipelinenetwork.result.Result;
import com.example.pipelinenetwork.service.DefectService;
import com.example.pipelinenetwork.service.DetectionService;
import com.example.pipelinenetwork.service.RoadService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/road")
public class RoadController {
@Resource
private RoadService roadService;
@Resource
private DetectionService detectionService;
@Resource
private DefectService defectService;
@GetMapping("/match")
public Result<RoadVO> match(
@RequestParam Double lng,
@RequestParam Double lat) {
return Result.success(roadService.match(lng, lat));
}
/**
* 上传Excel文件并生成sql语句
*/
@PostMapping("/import")
public List<String> importRoadData(@RequestParam("file") MultipartFile file) throws Exception {
return roadService.importRoadData(file);
}
}
\ No newline at end of file
package com.example.pipelinenetwork.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.pipelinenetwork.pojo.entity.DefectEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/20 13:52
* @Version: 1.0
*/
@Mapper
public interface DefectMapper extends BaseMapper<DefectEntity> {
}
package com.example.pipelinenetwork.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.pipelinenetwork.pojo.entity.DetectionEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/20 13:58
* @Version: 1.0
*/
@Mapper
public interface DetectionMapper extends BaseMapper<DetectionEntity> {
}
package com.example.pipelinenetwork.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.pipelinenetwork.pojo.entity.RoadEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface RoadMapper extends BaseMapper<RoadEntity> {
/**
* 根据经纬度匹配最近的路段
*/
Map<String, Object> matchNearestRoad(@Param("lng") Double lng, @Param("lat") Double lat);
}
\ No newline at end of file
package com.example.pipelinenetwork.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("defect")
public class DefectEntity {
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 缺陷类型
*/
private String type;
/**
* 缺陷名称
*/
private String name;
/**
* 缺陷等级
*/
private String level;
/**
* 缺陷数量
*/
private Integer num;
}
package com.example.pipelinenetwork.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("detection")
public class DetectionEntity{
@TableId(type = IdType.ASSIGN_ID)
private String id;
/**
* 地区
*/
private String region;
/**
* 报告名称
*/
private String reportName;
/**
* 路名
*/
private String roadName;
/**
* 管道数量
*/
private Integer pipeNum;
/**
* 管道长度
*/
private Double pipeLength;
/**
* 缺陷数量
*/
private Integer defectNum;
}
package com.example.pipelinenetwork.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("road")
public class RoadEntity {
@TableId(type = IdType.AUTO)
private Long id;
private String name;
}
\ No newline at end of file
package com.example.pipelinenetwork.pojo.vo;
import com.example.pipelinenetwork.pojo.entity.RoadEntity;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RoadVO extends RoadEntity {
/**
* 是否匹配到路段
*/
private boolean found;
/**
* 点击位置到路段的距离(单位:米)
*/
private Double distance;
/**
* 经度
*/
private Double lng;
/**
* 纬度
*/
private Double lat;
/**
* 匹配到的路段的坐标列表
*/
private List<List<Double>> coordinates;
}
\ No newline at end of file
package com.example.pipelinenetwork.result;
import lombok.Data;
import java.util.List;
@Data
public class PageResult<T> {
/**
* 响应码
*/
private Integer code;
/**
* 当前页码
*/
private Integer pageNum;
/**
* 每页数量
*/
private Integer pageSize;
/**
* 总页数
*/
private Integer totalPages;
/**
* 总记录数
*/
private Long total;
/**
* 数据列表
*/
private List<T> data;
// 构造方法
public PageResult(Integer pageNum, Integer pageSize, Long total, List<T> data) {
this.code = 200;
this.pageNum = pageNum;
this.pageSize = pageSize;
this.total = total;
this.data = data;
this.totalPages = (int) Math.ceil((double) total / pageSize);
}
}
\ No newline at end of file
package com.example.pipelinenetwork.result;
import lombok.Data;
import java.io.Serializable;
/**
* 统一响应结果封装类
*/
@Data
public class Result<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 响应码
*/
private Integer code;
/**
* 响应消息
*/
private String message;
/**
* 响应数据
*/
private T data;
/**
* 响应时间戳
*/
private Long timestamp;
/**
* 构造方法
*/
private Result() {
this.timestamp = System.currentTimeMillis();
}
/**
* 成功响应
*/
public static <T> Result<T> success() {
return success(null);
}
public static <T> Result<T> success(T data) {
Result<T> result = new Result<>();
result.setCode(200);
result.setMessage("操作成功");
result.setData(data);
return result;
}
public static <T> Result<T> success(T data, String message) {
Result<T> result = new Result<>();
result.setCode(200);
result.setMessage(message);
result.setData(data);
return result;
}
/**
* 失败响应
*/
public static <T> Result<T> error() {
return error(500, "操作失败");
}
public static <T> Result<T> error(String message) {
return error(500, message);
}
public static <T> Result<T> error(Integer code, String message) {
Result<T> result = new Result<>();
result.setCode(code);
result.setMessage(message);
return result;
}
public static <T> Result<T> error(Integer code, String message, T data) {
Result<T> result = new Result<>();
result.setCode(code);
result.setMessage(message);
result.setData(data);
return result;
}
/**
* 通用状态码响应
*/
public static <T> Result<T> of(Integer status, String message, T data) {
Result<T> result = new Result<>();
result.setCode(status);
result.setMessage(message);
result.setData(data);
return result;
}
public static <T> Result<T> of(Integer status, String message) {
return of(status, message, null);
}
/**
* 便捷方法
*/
public static <T> Result<T> ok() {
return success();
}
public static <T> Result<T> ok(T data) {
return success(data);
}
public static <T> Result<T> ok(T data, String message) {
return success(data, message);
}
}
\ No newline at end of file
package com.example.pipelinenetwork.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.pipelinenetwork.pojo.entity.DefectEntity;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/20 13:52
* @Version: 1.0
*/
public interface DefectService extends IService<DefectEntity> {
}
package com.example.pipelinenetwork.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.pipelinenetwork.pojo.entity.DetectionEntity;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/20 13:59
* @Version: 1.0
*/
public interface DetectionService extends IService<DetectionEntity> {
}
package com.example.pipelinenetwork.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.pipelinenetwork.pojo.vo.RoadVO;
import com.example.pipelinenetwork.pojo.entity.RoadEntity;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/20 10:55
* @Version: 1.0
*/
public interface RoadService extends IService<RoadEntity> {
RoadVO match(Double lng, Double lat);
List<String> importRoadData(MultipartFile file) throws Exception;
}
package com.example.pipelinenetwork.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.pipelinenetwork.mapper.DefectMapper;
import com.example.pipelinenetwork.pojo.entity.DefectEntity;
import com.example.pipelinenetwork.service.DefectService;
import org.springframework.stereotype.Service;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/20 13:53
* @Version: 1.0
*/
@Service
public class DefectServiceImpl extends ServiceImpl<DefectMapper, DefectEntity> implements DefectService {
}
package com.example.pipelinenetwork.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.pipelinenetwork.mapper.DetectionMapper;
import com.example.pipelinenetwork.pojo.entity.DetectionEntity;
import com.example.pipelinenetwork.service.DetectionService;
import org.springframework.stereotype.Service;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/7/20 13:59
* @Version: 1.0
*/
@Service
public class DetectionServiceImpl extends ServiceImpl<DetectionMapper, DetectionEntity> implements DetectionService {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment