feat:添加无人船航线管理页面

This commit is contained in:
2026-04-22 19:29:47 +08:00
parent bb2bb80fd1
commit 61a08f04c2
15 changed files with 1084 additions and 57 deletions
@@ -13,13 +13,23 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.List;
/**
* 无人船航线管理Controller
* 无人船航线管理 Controller
*
* @author dzc
* @date 2026-01-05
@@ -56,6 +66,21 @@ public class BoatRouteController {
return Result.succeed(detail);
}
@Operation(summary = "分页查询无人船航线列表")
@GetMapping("/page")
public Result<Page<BoatRouteListVO>> pageRoutes(
@Parameter(description = "航线名称") @RequestParam(required = false) String routeName,
@Parameter(description = "设备SN") @RequestParam(required = false) String deviceSn,
@Parameter(description = "创建开始时间") @RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
@Parameter(description = "创建结束时间") @RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime,
@Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer page,
@Parameter(description = "每页数量") @RequestParam(defaultValue = "10") Integer size) {
Page<BoatRouteListVO> pageResult = boatRouteService.pageRoutes(routeName, deviceSn, startTime, endTime, page, size);
return Result.succeed(pageResult);
}
@Operation(summary = "获取设备绑定的航线列表")
@GetMapping("/list/device/{deviceSn}")
public Result<List<BoatRouteListVO>> listByDeviceSn(
@@ -9,6 +9,7 @@ import com.central.device.model.vo.BoatRouteDetailVO;
import com.central.device.model.vo.BoatRouteListVO;
import com.central.device.model.vo.RouteValidateResultVO;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -69,6 +70,20 @@ public interface IBoatRouteService extends IService<BoatRoute> {
*/
Page<BoatRouteListVO> listByScenicId(Long scenicId, Integer page, Integer size);
/**
* 分页查询无人船航线列表
*
* @param routeName 航线名称
* @param deviceSn 设备SN
* @param startTime 创建开始时间
* @param endTime 创建结束时间
* @param page 页码
* @param size 每页数量
* @return 航线分页列表
*/
Page<BoatRouteListVO> pageRoutes(String routeName, String deviceSn, LocalDateTime startTime, LocalDateTime endTime,
Integer page, Integer size);
/**
* 绑定航线到设备
*
@@ -35,6 +35,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -314,6 +315,34 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
return resultPage;
}
@Override
public Page<BoatRouteListVO> pageRoutes(String routeName, String deviceSn, LocalDateTime startTime,
LocalDateTime endTime, Integer page, Integer size) {
String anchor = LoginUserContextHolder.getCurrentTenantId();
try {
if (anchor == null || anchor.isEmpty()) {
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
}
} catch (Exception ignored) {
log.error("获取当前登录用户租户失败");
}
Page<BoatRoute> pageParam = new Page<>(page, size);
LambdaQueryWrapper<BoatRoute> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(anchor != null && !anchor.isEmpty(), BoatRoute::getTenantId, anchor)
.eq(BoatRoute::getDeleted, 0)
.like(StrUtil.isNotBlank(routeName), BoatRoute::getRouteName, StrUtil.trim(routeName))
.like(StrUtil.isNotBlank(deviceSn), BoatRoute::getDeviceSn, StrUtil.trim(deviceSn))
.ge(startTime != null, BoatRoute::getCreateTime, startTime)
.le(endTime != null, BoatRoute::getCreateTime, endTime)
.orderByDesc(BoatRoute::getCreateTime);
Page<BoatRoute> routePage = this.page(pageParam, wrapper);
Page<BoatRouteListVO> resultPage = new Page<>(page, size, routePage.getTotal());
resultPage.setRecords(convertToListVO(routePage.getRecords()));
return resultPage;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void bindToDevice(String routeId, String deviceSn) {
@@ -1,8 +1,8 @@
{
"routeId": "c928a113c4c2489883c41a038f0c7959",
"routeName": "Manual Route 2026/4/12 1:1:58",
"deviceSn": "SHIP-V1-00001",
"deviceName": "Koi Fish Agent",
"deviceSn": "12345678",
"deviceName": "锦鲤一号",
"scenicId": 1,
"waypointCount": 75,
"totalDistance": 1157,
@@ -0,0 +1,93 @@
{
"routeId": "33415e9578a74c59a16a5d2d3fee492c",
"routeName": "Manual Test Route 2026/4/6 16:16:59",
"deviceSn": "12345678",
"deviceName": "锦鲤一号",
"scenicId": 1,
"waypointCount": 5,
"totalDistance": 320.65,
"totalDuration": 1603,
"cruiseSpeed": 0.2,
"loopEnabled": false,
"loopCount": 1,
"returnMode": "origin",
"safeDistance": 5,
"startPoint": "121.89807344122099,30.87373280450406",
"endPoint": "121.8984168707936,30.873953677640834",
"status": 1,
"statusDesc": "Local Draft",
"waypoints": [
{
"waypointId": "289feeecdd554c3989759a584c777c09",
"waypointIndex": 0,
"longitude": 121.89807344122099,
"latitude": 30.87373280450406,
"speed": 2,
"stayDuration": 0,
"headingAngle": 49,
"turnMode": "smooth",
"isKeyPoint": false,
"pointName": "起点",
"actions": null,
"remark": null
},
{
"waypointId": "e1b7444d7d4942e2886b05f6b76f8392",
"waypointIndex": 1,
"longitude": 121.89865297403038,
"latitude": 30.874119329720497,
"speed": 2,
"stayDuration": 0,
"headingAngle": 49,
"turnMode": "smooth",
"isKeyPoint": false,
"pointName": "航点1",
"actions": null,
"remark": null
},
{
"waypointId": "ab214e90d4f6495d85abfeae791a6b53",
"waypointIndex": 2,
"longitude": 121.89949003611937,
"latitude": 30.874809529580364,
"speed": 2,
"stayDuration": 0,
"headingAngle": 49,
"turnMode": "smooth",
"isKeyPoint": false,
"pointName": "航点2",
"actions": null,
"remark": null
},
{
"waypointId": "e54c7b84314643538e9648d738a88ef7",
"waypointIndex": 3,
"longitude": 121.89906077613658,
"latitude": 30.874478239874847,
"speed": 2,
"stayDuration": 0,
"headingAngle": 233,
"turnMode": "smooth",
"isKeyPoint": false,
"pointName": "航点3",
"actions": null,
"remark": null
},
{
"waypointId": "2454526441a54e989fa4739c01510c18",
"waypointIndex": 4,
"longitude": 121.8984168707936,
"latitude": 30.873953677640834,
"speed": 2,
"stayDuration": 0,
"headingAngle": null,
"turnMode": "smooth",
"isKeyPoint": false,
"pointName": "终点",
"actions": null,
"remark": null
}
],
"createTime": "2026-04-06 08:16:59",
"updateTime": "2026-04-06 08:16:59"
}