接口开发
This commit is contained in:
parent
39d4f2b90b
commit
e4d07ab792
|
|
@ -77,8 +77,53 @@
|
|||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-main</artifactId>
|
||||
<version>25.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-epsg-hsql</artifactId>
|
||||
<version>25.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.locationtech.proj4j</groupId>
|
||||
<artifactId>proj4j</artifactId>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.geotools</groupId>
|
||||
<artifactId>gt-referencing</artifactId>
|
||||
<version>25.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.locationtech.jts</groupId>
|
||||
<artifactId>jts-core</artifactId>
|
||||
<version>1.18.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<!-- 阿里云仓库(优先使用) -->
|
||||
<repository>
|
||||
<id>aliyun</id>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
</repository>
|
||||
<!-- GeoTools 官方仓库 -->
|
||||
<repository>
|
||||
<id>osgeo</id>
|
||||
<name>OSGeo Release Repository</name>
|
||||
<url>https://repo.osgeo.org/repository/release/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class DxfClient {
|
|||
// File dxfFile = new File("F:\\workFile\\fangliang\\中期测试例241220.dxf"); // 请替换为你的 DXF 文件路径
|
||||
File dxfFile = new File(url); // 请替换为你的 DXF 文件路径
|
||||
// 测试:获取图层信息
|
||||
System.out.println("📌 正在获取图层信息...");
|
||||
System.out.println("正在获取图层信息...");
|
||||
String layerJson = getLayers(dxfFile);
|
||||
System.out.println("图层信息返回结果:");
|
||||
return layerJson;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.bonus.common.core.page.TableDataInfo;
|
|||
import com.bonus.common.utils.StringUtils;
|
||||
import com.bonus.waterdesign.domain.*;
|
||||
import com.bonus.waterdesign.service.ModelService;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -26,34 +28,33 @@ public class ModelController extends BaseController {
|
|||
/**
|
||||
* 获取模型列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('model:list')")7
|
||||
@PreAuthorize("@ss.hasPermi('model:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ProjectVo model)
|
||||
{
|
||||
List<ProjectTree> list = modelService.list(model);
|
||||
List<ProjectVo> list = modelService.list(model);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 新增模型
|
||||
*/
|
||||
@PostMapping("/addModel")
|
||||
public AjaxResult addModel(@RequestBody Model model)
|
||||
{
|
||||
return toAjax(modelService.addModel(model));
|
||||
public AjaxResult addModel(@RequestBody Model model) {
|
||||
return toAjax(modelService.addModel(model));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody PeojectNodes node) {
|
||||
return toAjax(modelService.add(node));
|
||||
}
|
||||
|
||||
@PostMapping("/openView")
|
||||
public AjaxResult openView(@RequestBody PeojectNodes node) {
|
||||
public AjaxResult openView(@RequestBody PeojectNodes node) throws FactoryException, TransformException {
|
||||
//获取所有的节点信息
|
||||
List<CadData> list =modelService.openView(node);
|
||||
List<CadData> list = modelService.openView(node);
|
||||
//返回list信息给前台
|
||||
return AjaxResult.success(list);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,11 @@ public class ProjectController extends BaseController {
|
|||
/**
|
||||
* 获取项目列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('project:list')")
|
||||
// @PreAuthorize("@ss.hasPermi('project:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Project project) {
|
||||
startPage();
|
||||
project.setCreateBy(getUserId().toString());
|
||||
List<Project> list = projectService.selectProjectList(project);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
|
@ -43,7 +44,7 @@ public class ProjectController extends BaseController {
|
|||
/**
|
||||
* 获取项目下拉框
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('project:list')")
|
||||
// @PreAuthorize("@ss.hasPermi('project:list')")
|
||||
@GetMapping("/SelectList")
|
||||
public AjaxResult SelectList(ProjectSelect projectSelect) {
|
||||
List<ProjectSelect> list = projectService.selectProjectList1(projectSelect);
|
||||
|
|
@ -51,7 +52,7 @@ public class ProjectController extends BaseController {
|
|||
}
|
||||
|
||||
@Log(title = "项目管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('project:export')")
|
||||
// @PreAuthorize("@ss.hasPermi('project:export')")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Project post) {
|
||||
List<Project> list = projectService.selectProjectList(post);
|
||||
|
|
@ -62,7 +63,7 @@ public class ProjectController extends BaseController {
|
|||
/**
|
||||
* 根据岗位编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('project:query')")
|
||||
// @PreAuthorize("@ss.hasPermi('project:query')")
|
||||
@GetMapping(value = "/{proId}")
|
||||
public AjaxResult getInfo(@PathVariable Long proId) {
|
||||
return success(projectService.selectProjectById(proId));
|
||||
|
|
@ -71,35 +72,35 @@ public class ProjectController extends BaseController {
|
|||
/**
|
||||
* 新增项目
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('project:add')")
|
||||
// @PreAuthorize("@ss.hasPermi('project:add')")
|
||||
@Log(title = "项目管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody Project project) {
|
||||
if (!projectService.checkProjectNameUnique(project)) {
|
||||
return error("新增项目'" + project.getProName() + "'失败,项目名称已存在");
|
||||
}
|
||||
project.setCreateBy(getUsername());
|
||||
project.setCreateBy(getUserId().toString());
|
||||
return toAjax(projectService.insertProject(project));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('project:edit')")
|
||||
// @PreAuthorize("@ss.hasPermi('project:edit')")
|
||||
@Log(title = "项目管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody Project project) {
|
||||
if (!projectService.checkProjectNameUnique(project)) {
|
||||
return error("修改项目'" + project.getProName() + "'失败,项目名称已存在");
|
||||
}
|
||||
project.setUpdateBy(getUsername());
|
||||
project.setUpdateBy(getUserId().toString());
|
||||
return toAjax(projectService.updateProject(project));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('project:remove')")
|
||||
// @PreAuthorize("@ss.hasPermi('project:remove')")
|
||||
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{proId}")
|
||||
public AjaxResult remove(@PathVariable Long proId) {
|
||||
|
|
@ -109,7 +110,7 @@ public class ProjectController extends BaseController {
|
|||
/**
|
||||
* 新增项目团队人员
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('projectUser:add')")
|
||||
// @PreAuthorize("@ss.hasPermi('projectUser:add')")
|
||||
@Log(title = "项目管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/addProjectUser")
|
||||
public AjaxResult addProjectUser(@Validated @RequestBody ProjectUser projectUser) {
|
||||
|
|
@ -122,7 +123,7 @@ public class ProjectController extends BaseController {
|
|||
/**
|
||||
* 删除项目团队人员
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('projectUser:del')")
|
||||
// @PreAuthorize("@ss.hasPermi('projectUser:del')")
|
||||
@Log(title = "项目管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/delProjectUser")
|
||||
public AjaxResult delProjectUser(@Validated @RequestBody ProjectUser projectUser) {
|
||||
|
|
@ -132,7 +133,7 @@ public class ProjectController extends BaseController {
|
|||
/**
|
||||
* 获取项目团队人员列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('projectUser:list')")
|
||||
// @PreAuthorize("@ss.hasPermi('projectUser:list')")
|
||||
@GetMapping("/projectUserList")
|
||||
public TableDataInfo projectUserList(ProjectUser projectUser) {
|
||||
startPage();
|
||||
|
|
|
|||
|
|
@ -18,4 +18,7 @@ public class ProjectSelect {
|
|||
private String id;
|
||||
|
||||
private String name;
|
||||
private Integer nodeCount;
|
||||
private String lon;
|
||||
private String lat;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.bonus.waterdesign.service;
|
||||
|
||||
import com.bonus.waterdesign.domain.*;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModelService {
|
||||
List<ProjectTree> list(ProjectVo model);
|
||||
List<ProjectVo> list(ProjectVo model);
|
||||
|
||||
int addModel(Model model);
|
||||
|
||||
|
|
@ -15,5 +17,5 @@ public interface ModelService {
|
|||
|
||||
boolean update(PeojectNodes node);
|
||||
|
||||
List<CadData> openView(PeojectNodes node);
|
||||
List<CadData> openView(PeojectNodes node) throws FactoryException, TransformException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
package com.bonus.waterdesign.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.common.utils.StringUtils;
|
||||
import com.bonus.waterdesign.domain.*;
|
||||
import com.bonus.waterdesign.mapper.ModelMapper;
|
||||
import com.bonus.waterdesign.mapper.ProjectMapper;
|
||||
import com.bonus.waterdesign.service.ModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.locationtech.proj4j.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 马三炮
|
||||
|
|
@ -28,11 +30,12 @@ public class ModelServiceImpl implements ModelService {
|
|||
private ProjectMapper projectMapper;
|
||||
|
||||
@Override
|
||||
public List<ProjectTree> list(ProjectVo model) {
|
||||
public List<ProjectVo> list(ProjectVo model) {
|
||||
List<ProjectVo> list = modelMapper.list(model);
|
||||
List<ProjectTree> projectTrees = buildProjectTree(list);
|
||||
return projectTrees;
|
||||
// List<ProjectTree> projectTrees = buildProjectTree(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ProjectTree> buildProjectTree(List<ProjectVo> flatList) {
|
||||
// 1. 按项目分组
|
||||
Map<String, ProjectTree> projectMap = new LinkedHashMap<>();
|
||||
|
|
@ -57,7 +60,7 @@ public class ModelServiceImpl implements ModelService {
|
|||
String projectId = vo.getProjectId();
|
||||
if (!projectMap.containsKey(projectId)) {
|
||||
ProjectTree project = new ProjectTree();
|
||||
project.setNodeCount(vo.getNodeCount()+"");
|
||||
project.setNodeCount(vo.getNodeCount() + "");
|
||||
project.setProjectId(projectId);
|
||||
project.setLevelName(vo.getLevelName());
|
||||
project.setModelUrl(vo.getModelUrl());
|
||||
|
|
@ -114,7 +117,7 @@ public class ModelServiceImpl implements ModelService {
|
|||
}
|
||||
}
|
||||
}
|
||||
return i ;
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -136,6 +139,87 @@ public class ModelServiceImpl implements ModelService {
|
|||
|
||||
@Override
|
||||
public List<CadData> openView(PeojectNodes node) {
|
||||
return modelMapper.openView(node);
|
||||
List<CadData> cadData = modelMapper.openView(node);
|
||||
try {
|
||||
CRSFactory crsFactory = new CRSFactory();
|
||||
CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
|
||||
|
||||
// 定义坐标系(CGCS2000 GK Zone 20 → WGS84)
|
||||
CoordinateReferenceSystem gkZone20 = crsFactory.createFromParameters("EPSG:4498",
|
||||
"+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs");
|
||||
CoordinateReferenceSystem wgs84 = crsFactory.createFromName("EPSG:4326");
|
||||
|
||||
CoordinateTransform transform = ctFactory.createTransform(gkZone20, wgs84);
|
||||
|
||||
for (CadData cadDatum : cadData) {
|
||||
String geometry = cadDatum.getGeometry();
|
||||
JSONObject jsonObject = JSON.parseObject(geometry);
|
||||
if (jsonObject.get("type").equals("LINE")) {
|
||||
JSONArray startArray = jsonObject.getJSONArray("start");
|
||||
JSONArray endArray = jsonObject.getJSONArray("end");
|
||||
// 获取第一个元素(X坐标)
|
||||
double x = startArray.getDouble(0);
|
||||
// 获取第二个元素(Y坐标)
|
||||
double y = startArray.getDouble(1);
|
||||
// 获取第一个元素(X坐标)
|
||||
double x1 = endArray.getDouble(0);
|
||||
// 获取第二个元素(Y坐标)
|
||||
double y1 = endArray.getDouble(1);
|
||||
|
||||
// 原始坐标
|
||||
ProjCoordinate startGk = new ProjCoordinate(x, y);
|
||||
ProjCoordinate endGk = new ProjCoordinate(x1, y1);
|
||||
|
||||
// 转换
|
||||
ProjCoordinate startWgs84 = new ProjCoordinate();
|
||||
ProjCoordinate endWgs84 = new ProjCoordinate();
|
||||
transform.transform(startGk, startWgs84);
|
||||
transform.transform(endGk, endWgs84);
|
||||
|
||||
startArray.set(0, startWgs84.x);
|
||||
startArray.set(1, startWgs84.y);
|
||||
endArray.set(0, endWgs84.x);
|
||||
endArray.set(1, endWgs84.y);
|
||||
cadDatum.setGeometry(jsonObject.toString());
|
||||
}
|
||||
if (jsonObject.get("type").equals("LWPOLYLINE")) {
|
||||
JSONArray pointsArray = jsonObject.getJSONArray("points");
|
||||
for (int i = 0; i < pointsArray.size(); i++) {
|
||||
JSONArray point = pointsArray.getJSONArray(i);
|
||||
double x = point.getDouble(0);
|
||||
double y = point.getDouble(1);
|
||||
|
||||
// 原始坐标
|
||||
ProjCoordinate pointstGk = new ProjCoordinate(x, y);
|
||||
|
||||
// 转换
|
||||
ProjCoordinate pointstGkWgs84 = new ProjCoordinate();
|
||||
transform.transform(pointstGk, pointstGkWgs84);
|
||||
|
||||
point.set(0, pointstGkWgs84.x);
|
||||
point.set(1, pointstGkWgs84.y);
|
||||
}
|
||||
cadDatum.setGeometry(jsonObject.toString());
|
||||
}
|
||||
if (jsonObject.get("type").equals("CIRCLE")) {
|
||||
JSONArray centerArray = jsonObject.getJSONArray("center");
|
||||
// 获取第一个元素(X坐标)
|
||||
double x = centerArray.getDouble(0);
|
||||
// 获取第二个元素(Y坐标)
|
||||
double y = centerArray.getDouble(1);
|
||||
// 原始坐标
|
||||
ProjCoordinate startGk = new ProjCoordinate(x, y);
|
||||
ProjCoordinate startWgs84 = new ProjCoordinate();
|
||||
transform.transform(startGk, startWgs84);
|
||||
centerArray.set(0, startWgs84.x);
|
||||
centerArray.set(1, startWgs84.y);
|
||||
cadDatum.setGeometry(jsonObject.toString());
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return cadData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
<if test="proName != null and proName != ''">node_name,</if>
|
||||
<if test="level != null and level != ''">level,</if>
|
||||
<if test="nodeCount != null and nodeCount != ''">node_count,</if>
|
||||
create_time
|
||||
</trim>
|
||||
VALUES
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
@ -48,6 +49,7 @@
|
|||
<if test="proName != null and proName != ''">#{proName},</if>
|
||||
<if test="level != null and level != ''">#{level},</if>
|
||||
<if test="nodeCount != null and nodeCount != ''">#{nodeCount},</if>
|
||||
sysdate()
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -108,22 +110,20 @@
|
|||
p.id AS project_id,
|
||||
p.pro_name,
|
||||
p.level,
|
||||
p.lon,
|
||||
p.lat,
|
||||
c.config_name,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM sys_level_node n
|
||||
WHERE n.config_id = c.config_id
|
||||
) AS node_count,
|
||||
c.level AS node_count,
|
||||
n.id as node_id,
|
||||
n.node_name,
|
||||
n.level AS node_level,
|
||||
n.node_count AS node_count_detail,
|
||||
m.model_url
|
||||
|
||||
FROM tb_project p
|
||||
LEFT JOIN sys_level_config c ON p.level = c.config_id
|
||||
LEFT JOIN project_node n ON p.id = n.project_id AND n.del_flag = '0'
|
||||
LEFT JOIN (
|
||||
FROM project_node n
|
||||
LEFT JOIN tb_project p ON p.id = n.project_id AND n.del_flag = '0'
|
||||
LEFT JOIN sys_level_config c ON p.level = c.config_id
|
||||
LEFT JOIN (
|
||||
SELECT t1.*
|
||||
FROM tb_model t1
|
||||
INNER JOIN (
|
||||
|
|
@ -137,6 +137,7 @@
|
|||
<if test="projectId != null and projectId != ''">
|
||||
AND p.id = #{projectId}
|
||||
</if>
|
||||
order by n.create_time
|
||||
</select>
|
||||
<select id="openView" resultType="com.bonus.waterdesign.domain.CadData">
|
||||
SELECT
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
tp.unit_name,
|
||||
tp.user_name,
|
||||
tp.pro_location,
|
||||
tp.lon,
|
||||
tp.lat,
|
||||
tp.remark,
|
||||
sc.config_name
|
||||
LEVEL
|
||||
|
|
@ -42,6 +44,9 @@
|
|||
|
||||
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
|
||||
<include refid="selectProject"/>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
AND tp.create_user = #{createBy}
|
||||
</if>
|
||||
<if test="proName != null and proName != ''">
|
||||
AND pro_name like concat('%', #{proName}, '%')
|
||||
</if>
|
||||
|
|
@ -90,7 +95,10 @@
|
|||
<select id="selectProjectList1" resultType="com.bonus.waterdesign.domain.ProjectSelect">
|
||||
SELECT
|
||||
tp.id,
|
||||
tp.pro_name name
|
||||
tp.pro_name as name,
|
||||
tp.lon,
|
||||
tp.lat,
|
||||
sc.level as nodeCount
|
||||
FROM
|
||||
tb_project tp
|
||||
LEFT JOIN sys_level_config sc ON sc.config_id = tp.LEVEL
|
||||
|
|
|
|||
Loading…
Reference in New Issue