feat: 1:二维码统计明细 2:航线规划
This commit is contained in:
+10
@@ -3,6 +3,7 @@ package com.central.device.controller;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.dto.BoatRouteCreateDTO;
|
||||
import com.central.device.model.dto.BoatRouteDisplayUpdateDTO;
|
||||
import com.central.device.model.dto.BoatRouteUpdateDTO;
|
||||
import com.central.device.model.vo.BoatRouteDetailVO;
|
||||
import com.central.device.model.vo.BoatRouteListVO;
|
||||
@@ -130,4 +131,13 @@ public class BoatRouteController {
|
||||
boatRouteService.publishRoute(routeId);
|
||||
return Result.succeed(null, "发布成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "按设备批量更新航线模型显示状态")
|
||||
@PutMapping("/display/device/{deviceSn}")
|
||||
public Result<Void> updateShowInModelByDeviceSn(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn,
|
||||
@RequestBody @Validated BoatRouteDisplayUpdateDTO dto) {
|
||||
boatRouteService.updateShowInModelByDeviceSn(deviceSn, dto.getRouteIds());
|
||||
return Result.succeed(null, "航线模型显示状态更新成功");
|
||||
}
|
||||
}
|
||||
|
||||
+22
-1
@@ -1,8 +1,10 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.entity.WaterBoundary;
|
||||
import com.central.device.model.dto.PointDTO;
|
||||
import com.central.device.model.dto.WaterBoundaryCreateDTO;
|
||||
import com.central.device.model.dto.WaterBoundaryDisplayUpdateDTO;
|
||||
import com.central.device.model.vo.BoundaryCheckResultVO;
|
||||
import com.central.device.model.vo.WaterBoundaryVO;
|
||||
import com.central.device.service.IWaterBoundaryService;
|
||||
@@ -40,16 +42,18 @@ public class WaterBoundaryController {
|
||||
@GetMapping("/{boundaryId}")
|
||||
public Result<WaterBoundaryVO> getBoundaryDetail(
|
||||
@Parameter(description = "边界ID") @PathVariable String boundaryId) {
|
||||
var boundary = waterBoundaryService.getByBoundaryId(boundaryId);
|
||||
WaterBoundary boundary = waterBoundaryService.getByBoundaryId(boundaryId);
|
||||
if (boundary == null) {
|
||||
return Result.failed("边界不存在");
|
||||
}
|
||||
WaterBoundaryVO vo = new WaterBoundaryVO();
|
||||
vo.setBoundaryId(boundary.getBoundaryId());
|
||||
vo.setBoundaryName(boundary.getBoundaryName());
|
||||
vo.setDeviceSn(boundary.getDeviceSn());
|
||||
vo.setScenicId(boundary.getScenicId());
|
||||
vo.setBoundaryType(boundary.getBoundaryType());
|
||||
vo.setPolygonData(boundary.getPolygonData());
|
||||
vo.setShowInModel(boundary.getShowInModel());
|
||||
vo.setStatus(boundary.getStatus());
|
||||
vo.setCreateTime(boundary.getCreateTime());
|
||||
return Result.succeed(vo);
|
||||
@@ -63,6 +67,14 @@ public class WaterBoundaryController {
|
||||
return Result.succeed(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取设备边界列表")
|
||||
@GetMapping("/list/device/{deviceSn}")
|
||||
public Result<List<WaterBoundaryVO>> listByDeviceSn(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn) {
|
||||
List<WaterBoundaryVO> list = waterBoundaryService.listByDeviceSn(deviceSn);
|
||||
return Result.succeed(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "检测点是否在边界内")
|
||||
@GetMapping("/check/point")
|
||||
public Result<Boolean> checkPoint(
|
||||
@@ -107,4 +119,13 @@ public class WaterBoundaryController {
|
||||
waterBoundaryService.deleteBoundary(boundaryId);
|
||||
return Result.succeed(null, "删除成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "按设备批量更新标绘显示状态")
|
||||
@PutMapping("/display/device/{deviceSn}")
|
||||
public Result<Void> updateShowInModelByDeviceSn(
|
||||
@Parameter(description = "设备SN") @PathVariable String deviceSn,
|
||||
@RequestBody @Validated WaterBoundaryDisplayUpdateDTO dto) {
|
||||
waterBoundaryService.updateShowInModelByDeviceSn(deviceSn, dto.getBoundaryIds());
|
||||
return Result.succeed(null, "标绘显示状态更新成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,12 @@ public class BoatRoute implements Serializable {
|
||||
@TableField("boundary_polygon")
|
||||
private String boundaryPolygon;
|
||||
|
||||
/**
|
||||
* 规划水域边界ID
|
||||
*/
|
||||
@TableField("boundary_id")
|
||||
private String boundaryId;
|
||||
|
||||
/**
|
||||
* 起点坐标(lng,lat)
|
||||
*/
|
||||
@@ -149,6 +155,12 @@ public class BoatRoute implements Serializable {
|
||||
@TableField("is_template")
|
||||
private Boolean isTemplate;
|
||||
|
||||
/**
|
||||
* 是否在模型中显示航线:0-否,1-是
|
||||
*/
|
||||
@TableField("show_in_model")
|
||||
private Integer showInModel;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -39,6 +39,12 @@ public class WaterBoundary implements Serializable {
|
||||
@TableField("boundary_name")
|
||||
private String boundaryName;
|
||||
|
||||
/**
|
||||
* 绑定设备SN
|
||||
*/
|
||||
@TableField("device_sn")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 所属景区ID
|
||||
*/
|
||||
@@ -91,6 +97,12 @@ public class WaterBoundary implements Serializable {
|
||||
@TableField("model_id")
|
||||
private String modelId;
|
||||
|
||||
/**
|
||||
* 是否在模型中显示标绘:0-否,1-是
|
||||
*/
|
||||
@TableField("show_in_model")
|
||||
private Integer showInModel;
|
||||
|
||||
// ========== 状态 ==========
|
||||
|
||||
/**
|
||||
|
||||
+21
@@ -101,4 +101,25 @@ public interface BoatRouteMapper extends BaseMapper<BoatRoute> {
|
||||
* @return 影响行数
|
||||
*/
|
||||
int setTemplate(@Param("routeId") String routeId, @Param("isTemplate") Boolean isTemplate);
|
||||
|
||||
/**
|
||||
* 根据设备SN重置“模型中显示航线”状态(全部不显示)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param tenantId 租户ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int resetShowInModelByDeviceSn(@Param("deviceSn") String deviceSn, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 根据设备SN批量设置“模型中显示航线”状态(指定ID集合显示)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param tenantId 租户ID
|
||||
* @param routeIds 需要显示的航线ID列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int setShowInModelByRouteIds(@Param("deviceSn") String deviceSn,
|
||||
@Param("tenantId") String tenantId,
|
||||
@Param("routeIds") List<String> routeIds);
|
||||
}
|
||||
|
||||
+30
@@ -24,6 +24,15 @@ public interface WaterBoundaryMapper extends BaseMapper<WaterBoundary> {
|
||||
*/
|
||||
WaterBoundary selectByBoundaryId(@Param("boundaryId") String boundaryId);
|
||||
|
||||
/**
|
||||
* 根据设备SN查询边界列表
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param tenantId 租户ID
|
||||
* @return 边界列表
|
||||
*/
|
||||
List<WaterBoundary> selectByDeviceSn(@Param("deviceSn") String deviceSn, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 根据景区ID查询边界列表
|
||||
*
|
||||
@@ -54,6 +63,27 @@ public interface WaterBoundaryMapper extends BaseMapper<WaterBoundary> {
|
||||
*/
|
||||
int updateStatus(@Param("boundaryId") String boundaryId, @Param("status") Integer status);
|
||||
|
||||
/**
|
||||
* 根据设备SN重置显示标绘状态(全部不显示)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param tenantId 租户ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int resetShowInModelByDeviceSn(@Param("deviceSn") String deviceSn, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 根据设备SN批量设置显示标绘状态(指定ID集合显示)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param tenantId 租户ID
|
||||
* @param boundaryIds 需要显示的边界ID列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int setShowInModelByBoundaryIds(@Param("deviceSn") String deviceSn,
|
||||
@Param("tenantId") String tenantId,
|
||||
@Param("boundaryIds") List<String> boundaryIds);
|
||||
|
||||
/**
|
||||
* 根据3D模型ID查询关联边界
|
||||
*
|
||||
|
||||
+3
@@ -49,6 +49,9 @@ public class BoatRouteCreateDTO {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否在模型中显示航线:0-否,1-是(可选,默认0)", example = "0")
|
||||
private Integer showInModel = 0;
|
||||
|
||||
@Schema(description = "航点列表", required = true)
|
||||
@NotEmpty(message = "航点不能为空")
|
||||
private List<BoatWaypointDTO> waypoints;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.device.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 无人船航线“模型中显示”状态更新DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-08
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "无人船航线模型显示状态更新请求")
|
||||
public class BoatRouteDisplayUpdateDTO {
|
||||
|
||||
@Schema(description = "需要在模型中显示的航线ID列表(传空数组表示全隐)")
|
||||
@NotNull(message = "routeIds不能为空(可传空数组)")
|
||||
private List<String> routeIds;
|
||||
}
|
||||
|
||||
+6
@@ -37,6 +37,12 @@ public class BoatRouteUpdateDTO {
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "是否在模型中显示航线:0-否,1-是(可选)", example = "1")
|
||||
private Integer showInModel;
|
||||
|
||||
@Schema(description = "规划水域边界ID(可选,修改规划水域时传)")
|
||||
private String boundaryId;
|
||||
|
||||
@Schema(description = "航点列表(如果提供则更新所有航点)")
|
||||
private List<BoatWaypointDTO> waypoints;
|
||||
}
|
||||
|
||||
+8
-3
@@ -2,7 +2,6 @@ package com.central.device.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -21,8 +20,11 @@ public class WaterBoundaryCreateDTO {
|
||||
@NotBlank(message = "边界名称不能为空")
|
||||
private String boundaryName;
|
||||
|
||||
@Schema(description = "所属景区ID", required = true)
|
||||
@NotNull(message = "景区ID不能为空")
|
||||
@Schema(description = "绑定设备SN", required = true)
|
||||
@NotBlank(message = "设备SN不能为空")
|
||||
private String deviceSn;
|
||||
|
||||
@Schema(description = "所属景区ID(可选)")
|
||||
private Long scenicId;
|
||||
|
||||
@Schema(description = "边界类型:navigable-可航行,obstacle-障碍物,restricted-禁行区")
|
||||
@@ -43,4 +45,7 @@ public class WaterBoundaryCreateDTO {
|
||||
|
||||
@Schema(description = "关联3D模型ID")
|
||||
private String modelId;
|
||||
|
||||
@Schema(description = "是否在模型中显示标绘:0-否,1-是(可选,默认1)")
|
||||
private Integer showInModel = 1;
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.central.device.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 水域边界标绘显示状态更新DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2026-01-07
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "水域边界标绘显示状态更新请求")
|
||||
public class WaterBoundaryDisplayUpdateDTO {
|
||||
|
||||
@Schema(description = "需要在模型中显示的边界ID列表(传空数组表示全隐)")
|
||||
@NotNull(message = "boundaryIds不能为空(可传空数组)")
|
||||
private List<String> boundaryIds;
|
||||
}
|
||||
|
||||
+6
@@ -74,6 +74,12 @@ public class BoatRouteDetailVO {
|
||||
@Schema(description = "是否为模板")
|
||||
private Boolean isTemplate;
|
||||
|
||||
@Schema(description = "是否在模型中显示航线:0-否,1-是")
|
||||
private Integer showInModel;
|
||||
|
||||
@Schema(description = "规划水域边界ID")
|
||||
private String boundaryId;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
+6
@@ -49,6 +49,12 @@ public class BoatRouteListVO {
|
||||
@Schema(description = "是否为模板")
|
||||
private Boolean isTemplate;
|
||||
|
||||
@Schema(description = "是否在模型中显示航线:0-否,1-是")
|
||||
private Integer showInModel;
|
||||
|
||||
@Schema(description = "规划水域边界ID")
|
||||
private String boundaryId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
+6
@@ -22,6 +22,9 @@ public class WaterBoundaryVO {
|
||||
@Schema(description = "边界名称")
|
||||
private String boundaryName;
|
||||
|
||||
@Schema(description = "绑定设备SN")
|
||||
private String deviceSn;
|
||||
|
||||
@Schema(description = "所属景区ID")
|
||||
private Long scenicId;
|
||||
|
||||
@@ -43,6 +46,9 @@ public class WaterBoundaryVO {
|
||||
@Schema(description = "来源类型")
|
||||
private String sourceType;
|
||||
|
||||
@Schema(description = "是否在模型中显示标绘:0-否,1-是")
|
||||
private Integer showInModel;
|
||||
|
||||
@Schema(description = "状态:0-禁用,1-启用")
|
||||
private Integer status;
|
||||
|
||||
|
||||
+8
@@ -130,4 +130,12 @@ public interface IBoatRouteService extends IService<BoatRoute> {
|
||||
* @param routeId 航线ID
|
||||
*/
|
||||
void publishRoute(String routeId);
|
||||
|
||||
/**
|
||||
* 按设备批量更新“模型中显示航线”状态(未包含的航线会被置为不显示)
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param routeIds 需要显示的航线ID列表
|
||||
*/
|
||||
void updateShowInModelByDeviceSn(String deviceSn, List<String> routeIds);
|
||||
}
|
||||
|
||||
+16
@@ -33,6 +33,14 @@ public interface IWaterBoundaryService extends IService<WaterBoundary> {
|
||||
*/
|
||||
WaterBoundary getByBoundaryId(String boundaryId);
|
||||
|
||||
/**
|
||||
* 获取设备水域边界列表
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @return 边界列表
|
||||
*/
|
||||
List<WaterBoundaryVO> listByDeviceSn(String deviceSn);
|
||||
|
||||
/**
|
||||
* 获取景区水域边界列表
|
||||
*
|
||||
@@ -83,4 +91,12 @@ public interface IWaterBoundaryService extends IService<WaterBoundary> {
|
||||
* @param boundaryId 边界ID
|
||||
*/
|
||||
void deleteBoundary(String boundaryId);
|
||||
|
||||
/**
|
||||
* 按设备维度批量更新“模型中显示标绘”状态:未包含的边界会被置为不显示
|
||||
*
|
||||
* @param deviceSn 设备SN
|
||||
* @param boundaryIds 需要显示的边界ID列表(空列表表示全隐)
|
||||
*/
|
||||
void updateShowInModelByDeviceSn(String deviceSn, List<String> boundaryIds);
|
||||
}
|
||||
|
||||
+37
-3
@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -58,10 +59,12 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
route.setLoopCount(dto.getLoopCount());
|
||||
route.setReturnMode(dto.getReturnMode());
|
||||
route.setSafeDistance(dto.getSafeDistance());
|
||||
route.setBoundaryId(dto.getBoundaryId());
|
||||
route.setRemark(dto.getRemark());
|
||||
route.setTenantId(LoginUserContextHolder.getCurrentTenantId());
|
||||
route.setStatus(BoatRoute.RouteStatus.DRAFT.getCode());
|
||||
route.setIsTemplate(false);
|
||||
route.setShowInModel(dto.getShowInModel() != null ? dto.getShowInModel() : 0);
|
||||
|
||||
// 2. 计算航线统计信息
|
||||
List<BoatWaypointDTO> waypoints = dto.getWaypoints();
|
||||
@@ -167,6 +170,12 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
if (dto.getRemark() != null) {
|
||||
route.setRemark(dto.getRemark());
|
||||
}
|
||||
if (dto.getShowInModel() != null) {
|
||||
route.setShowInModel(dto.getShowInModel());
|
||||
}
|
||||
if (StrUtil.isNotBlank(dto.getBoundaryId())) {
|
||||
route.setBoundaryId(StrUtil.trim(dto.getBoundaryId()));
|
||||
}
|
||||
|
||||
// 如果提供了航点则更新航点
|
||||
if (dto.getWaypoints() != null && !dto.getWaypoints().isEmpty()) {
|
||||
@@ -193,6 +202,29 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
log.info("航线更新成功: routeId={}", routeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateShowInModelByDeviceSn(String deviceSn, List<String> routeIds) {
|
||||
String sn = StrUtil.trimToEmpty(deviceSn);
|
||||
if (StrUtil.isBlank(sn)) {
|
||||
throw new BusinessException("设备SN不能为空");
|
||||
}
|
||||
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
List<String> ids = routeIds == null ? Collections.emptyList() : routeIds.stream()
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.map(StrUtil::trim)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
baseMapper.resetShowInModelByDeviceSn(sn, tenantId);
|
||||
if (!ids.isEmpty()) {
|
||||
baseMapper.setShowInModelByRouteIds(sn, tenantId, ids);
|
||||
}
|
||||
|
||||
log.info("更新无人船航线模型显示状态成功: deviceSn={}, showCount={}", sn, ids.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatRouteDetailVO getRouteDetail(String routeId) {
|
||||
BoatRoute route = getByRouteId(routeId);
|
||||
@@ -335,9 +367,11 @@ public class BoatRouteServiceImpl extends ServiceImpl<BoatRouteMapper, BoatRoute
|
||||
throw new BusinessException("执行中的航线不能删除");
|
||||
}
|
||||
|
||||
// 逻辑删除航线
|
||||
route.setDeleted(1);
|
||||
this.updateById(route);
|
||||
// 逻辑删除航线:使用 MyBatis-Plus @TableLogic,避免手动更新字段在拦截器/策略下不生效
|
||||
boolean removed = this.removeById(route.getId());
|
||||
if (!removed) {
|
||||
throw new BusinessException("删除失败(未找到可删除的航线记录)");
|
||||
}
|
||||
|
||||
// 删除航点
|
||||
waypointMapper.deleteByRouteId(routeId);
|
||||
|
||||
+41
@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -45,6 +46,7 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
WaterBoundary boundary = new WaterBoundary();
|
||||
boundary.setBoundaryId(UUID.randomUUID().toString().replace("-", ""));
|
||||
boundary.setBoundaryName(dto.getBoundaryName());
|
||||
boundary.setDeviceSn(dto.getDeviceSn());
|
||||
boundary.setScenicId(dto.getScenicId());
|
||||
boundary.setBoundaryType(dto.getBoundaryType());
|
||||
boundary.setPolygonData(dto.getPolygonData());
|
||||
@@ -52,6 +54,7 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
boundary.setArea(dto.getArea());
|
||||
boundary.setSourceType(dto.getSourceType() != null ? dto.getSourceType() : WaterBoundary.SourceType.MANUAL.getCode());
|
||||
boundary.setModelId(dto.getModelId());
|
||||
boundary.setShowInModel(dto.getShowInModel() != null ? dto.getShowInModel() : 1);
|
||||
boundary.setTenantId(LoginUserContextHolder.getCurrentTenantId());
|
||||
boundary.setStatus(1); // 启用状态
|
||||
|
||||
@@ -66,6 +69,20 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
return baseMapper.selectByBoundaryId(boundaryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WaterBoundaryVO> listByDeviceSn(String deviceSn) {
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
List<WaterBoundary> boundaries = baseMapper.selectByDeviceSn(deviceSn, tenantId);
|
||||
return boundaries.stream()
|
||||
.map(b -> {
|
||||
WaterBoundaryVO vo = BeanUtil.copyProperties(b, WaterBoundaryVO.class);
|
||||
vo.setStatusDesc(b.getStatus() == 1 ? "启用" : "禁用");
|
||||
vo.setBoundaryTypeDesc(WaterBoundary.BoundaryType.fromCode(b.getBoundaryType()).getDesc());
|
||||
return vo;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WaterBoundaryVO> listByScenicId(Long scenicId) {
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
@@ -173,6 +190,30 @@ public class WaterBoundaryServiceImpl extends ServiceImpl<WaterBoundaryMapper, W
|
||||
log.info("水域边界删除成功: boundaryId={}", boundaryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateShowInModelByDeviceSn(String deviceSn, List<String> boundaryIds) {
|
||||
String sn = StrUtil.trimToEmpty(deviceSn);
|
||||
if (StrUtil.isBlank(sn)) {
|
||||
throw new BusinessException("设备SN不能为空");
|
||||
}
|
||||
|
||||
String tenantId = LoginUserContextHolder.getCurrentTenantId();
|
||||
List<String> ids = boundaryIds == null ? Collections.emptyList() : boundaryIds.stream()
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.map(StrUtil::trim)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 先全量重置为不显示,再批量置为显示(保证“选择几个就保存几个”)
|
||||
baseMapper.resetShowInModelByDeviceSn(sn, tenantId);
|
||||
if (!ids.isEmpty()) {
|
||||
baseMapper.setShowInModelByBoundaryIds(sn, tenantId, ids);
|
||||
}
|
||||
|
||||
log.info("更新水域边界标绘显示状态成功: deviceSn={}, showCount={}", sn, ids.size());
|
||||
}
|
||||
|
||||
// ========== 私有方法 ==========
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<result column="total_duration" property="totalDuration" />
|
||||
<result column="cruise_speed" property="cruiseSpeed" />
|
||||
<result column="boundary_polygon" property="boundaryPolygon" />
|
||||
<result column="boundary_id" property="boundaryId" />
|
||||
<result column="start_point" property="startPoint" />
|
||||
<result column="end_point" property="endPoint" />
|
||||
<result column="loop_enabled" property="loopEnabled" />
|
||||
@@ -24,6 +25,7 @@
|
||||
<result column="safe_distance" property="safeDistance" />
|
||||
<result column="status" property="status" />
|
||||
<result column="is_template" property="isTemplate" />
|
||||
<result column="show_in_model" property="showInModel" />
|
||||
<result column="remark" property="remark" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
@@ -108,4 +110,28 @@
|
||||
WHERE route_id = #{routeId}
|
||||
</update>
|
||||
|
||||
<!-- 根据设备SN重置“模型中显示航线”状态(全部不显示) -->
|
||||
<update id="resetShowInModelByDeviceSn">
|
||||
UPDATE boat_route
|
||||
SET show_in_model = 0,
|
||||
update_time = NOW()
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据设备SN批量设置“模型中显示航线”状态(指定ID集合显示) -->
|
||||
<update id="setShowInModelByRouteIds">
|
||||
UPDATE boat_route
|
||||
SET show_in_model = 1,
|
||||
update_time = NOW()
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
AND route_id IN
|
||||
<foreach collection="routeIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<id column="id" property="id" />
|
||||
<result column="boundary_id" property="boundaryId" />
|
||||
<result column="boundary_name" property="boundaryName" />
|
||||
<result column="device_sn" property="deviceSn" />
|
||||
<result column="scenic_id" property="scenicId" />
|
||||
<result column="tenant_id" property="tenantId" />
|
||||
<result column="boundary_type" property="boundaryType" />
|
||||
@@ -15,6 +16,7 @@
|
||||
<result column="area" property="area" />
|
||||
<result column="source_type" property="sourceType" />
|
||||
<result column="model_id" property="modelId" />
|
||||
<result column="show_in_model" property="showInModel" />
|
||||
<result column="status" property="status" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
@@ -28,6 +30,16 @@
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据设备SN查询边界列表 -->
|
||||
<select id="selectByDeviceSn" resultMap="BaseResultMap">
|
||||
SELECT * FROM water_boundary
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
AND status = 1
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据景区ID查询边界列表 -->
|
||||
<select id="selectByScenicId" resultMap="BaseResultMap">
|
||||
SELECT * FROM water_boundary
|
||||
@@ -57,6 +69,30 @@
|
||||
WHERE boundary_id = #{boundaryId}
|
||||
</update>
|
||||
|
||||
<!-- 根据设备SN重置显示标绘状态(全部不显示) -->
|
||||
<update id="resetShowInModelByDeviceSn">
|
||||
UPDATE water_boundary
|
||||
SET show_in_model = 0,
|
||||
update_time = NOW()
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
</update>
|
||||
|
||||
<!-- 根据设备SN批量设置显示标绘状态(指定ID集合显示) -->
|
||||
<update id="setShowInModelByBoundaryIds">
|
||||
UPDATE water_boundary
|
||||
SET show_in_model = 1,
|
||||
update_time = NOW()
|
||||
WHERE device_sn = #{deviceSn}
|
||||
AND tenant_id = #{tenantId}
|
||||
AND deleted = 0
|
||||
AND boundary_id IN
|
||||
<foreach collection="boundaryIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 根据3D模型ID查询关联边界 -->
|
||||
<select id="selectByModelId" resultMap="BaseResultMap">
|
||||
SELECT * FROM water_boundary
|
||||
|
||||
@@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS `boat_route` (
|
||||
|
||||
-- 航线边界
|
||||
`boundary_polygon` text COMMENT '水域边界多边形(GeoJSON)',
|
||||
`boundary_id` varchar(64) DEFAULT NULL COMMENT '规划水域边界ID',
|
||||
`start_point` varchar(128) COMMENT '起点坐标(lng,lat)',
|
||||
`end_point` varchar(128) COMMENT '终点坐标(lng,lat)',
|
||||
|
||||
@@ -34,6 +35,7 @@ CREATE TABLE IF NOT EXISTS `boat_route` (
|
||||
-- 状态字段
|
||||
`status` tinyint DEFAULT 0 COMMENT '状态:0-草稿,1-已发布,2-执行中,3-已完成',
|
||||
`is_template` tinyint DEFAULT 0 COMMENT '是否为模板:0-否,1-是',
|
||||
`show_in_model` tinyint DEFAULT 0 COMMENT '是否在模型中显示航线:0-否,1-是',
|
||||
`remark` varchar(512) DEFAULT NULL COMMENT '备注',
|
||||
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
@@ -49,6 +51,14 @@ CREATE TABLE IF NOT EXISTS `boat_route` (
|
||||
KEY `idx_status` (`status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='无人船航线表';
|
||||
|
||||
-- 兼容已存在表:补充“模型中显示航线”字段(若已存在可忽略)
|
||||
-- ALTER TABLE `boat_route`
|
||||
-- ADD COLUMN `show_in_model` tinyint DEFAULT 0 COMMENT '是否在模型中显示航线:0-否,1-是' AFTER `is_template`;
|
||||
|
||||
-- 兼容已存在表:补充“规划水域边界ID”字段(若已存在可忽略)
|
||||
-- ALTER TABLE `boat_route`
|
||||
-- ADD COLUMN `boundary_id` varchar(64) DEFAULT NULL COMMENT '规划水域边界ID' AFTER `boundary_polygon`;
|
||||
|
||||
-- 2. 无人船航点表
|
||||
CREATE TABLE IF NOT EXISTS `boat_waypoint` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
@@ -121,7 +131,8 @@ CREATE TABLE IF NOT EXISTS `water_boundary` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`boundary_id` varchar(64) NOT NULL COMMENT '边界唯一标识',
|
||||
`boundary_name` varchar(128) NOT NULL COMMENT '边界名称',
|
||||
`scenic_id` bigint NOT NULL COMMENT '所属景区ID',
|
||||
`device_sn` varchar(64) DEFAULT NULL COMMENT '绑定设备SN',
|
||||
`scenic_id` bigint DEFAULT NULL COMMENT '所属景区ID(可选)',
|
||||
`tenant_id` varchar(64) NOT NULL COMMENT '租户ID',
|
||||
|
||||
-- 边界数据
|
||||
@@ -133,6 +144,7 @@ CREATE TABLE IF NOT EXISTS `water_boundary` (
|
||||
-- 来源
|
||||
`source_type` varchar(32) DEFAULT 'manual' COMMENT '来源:manual-手动绘制,model-模型识别,import-导入',
|
||||
`model_id` varchar(64) DEFAULT NULL COMMENT '关联3D模型ID',
|
||||
`show_in_model` tinyint DEFAULT 0 COMMENT '是否在模型中显示标绘:0-否,1-是',
|
||||
|
||||
`status` tinyint DEFAULT 1 COMMENT '状态:0-禁用,1-启用',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
@@ -141,6 +153,7 @@ CREATE TABLE IF NOT EXISTS `water_boundary` (
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_boundary_id` (`boundary_id`),
|
||||
KEY `idx_device_sn` (`device_sn`),
|
||||
KEY `idx_scenic_id` (`scenic_id`),
|
||||
KEY `idx_tenant_id` (`tenant_id`),
|
||||
KEY `idx_boundary_type` (`boundary_type`)
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
-- ====================================================================
|
||||
-- 水域边界表结构升级:增加 device_sn,并放宽 scenic_id 非空约束
|
||||
-- 创建日期: 2026-01-06
|
||||
-- 说明:用于已有环境的增量升级(请按需执行)
|
||||
-- ====================================================================
|
||||
|
||||
-- 1) 增加 device_sn 字段(如已存在可忽略报错或自行判断)
|
||||
ALTER TABLE `water_boundary`
|
||||
ADD COLUMN `device_sn` varchar(64) DEFAULT NULL COMMENT '绑定设备SN' AFTER `boundary_name`;
|
||||
|
||||
-- 2) scenic_id 改为可空(如后续不再使用 scenic_id)
|
||||
ALTER TABLE `water_boundary`
|
||||
MODIFY COLUMN `scenic_id` bigint DEFAULT NULL COMMENT '所属景区ID(可选)';
|
||||
|
||||
-- 3) 增加索引
|
||||
CREATE INDEX `idx_device_sn` ON `water_boundary` (`device_sn`);
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
-- 为水域边界增加“是否在模型中显示标绘”字段(用于图层管理持久化)
|
||||
ALTER TABLE `water_boundary`
|
||||
ADD COLUMN `show_in_model` tinyint DEFAULT 0 COMMENT '是否在模型中显示标绘:0-否,1-是' AFTER `model_id`;
|
||||
|
||||
CREATE INDEX `idx_show_in_model` ON `water_boundary` (`show_in_model`);
|
||||
+97
-1
@@ -1,6 +1,8 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.constant.CommonConstant;
|
||||
import com.central.common.context.LoginUserContextHolder;
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
@@ -10,7 +12,6 @@ import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.model.SysUser;
|
||||
import com.central.log.annotation.AuditLog;
|
||||
import com.central.order.constants.OrderStatusConstants;
|
||||
import com.central.order.enums.CommonStatus;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
import com.central.order.feign.DeviceCenterService;
|
||||
@@ -1515,4 +1516,99 @@ public class OrderController {
|
||||
return Result.failed("获取订单信息异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "二维码订单统计查询")
|
||||
@Parameters({
|
||||
@Parameter(name = "tenantId", description = "租户ID", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "includeChildren", description = "是否包含下级租户", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "qrcodeName", description = "二维码名称", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "codeId", description = "二维码Code", in = ParameterIn.QUERY),
|
||||
@Parameter(name = "tourismId", description = "景区ID", in = ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/qrcode/order/statistics")
|
||||
public Result getQrcodeOrderStatistics(@RequestParam Map<String, Object> params) {
|
||||
log.info("查询二维码订单统计,params: {}", params);
|
||||
try {
|
||||
Map<String, Object> result = orderService.getQrcodeOrderStatistics(params);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("查询二维码订单统计异常", e);
|
||||
return Result.failed("查询失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "根据二维码ID查询订单列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page", description = "分页起始位置", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "limit", description = "分页结束位置", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "codeId", description = "二维码ID", required = true, in = ParameterIn.PATH)
|
||||
})
|
||||
@GetMapping("/qrcode/{codeId}/orders")
|
||||
public PageResult getOrdersByCodeId(
|
||||
@PathVariable("codeId") String codeId,
|
||||
@RequestParam Map<String, Object> params) {
|
||||
log.info("=== 根据二维码ID查询订单列表 ===");
|
||||
log.info("codeId: {}, params: {}", codeId, params);
|
||||
|
||||
try {
|
||||
// 直接用QueryWrapper查询,不走findList(避免tourismIds过滤)
|
||||
Integer pageNum = Integer.parseInt(params.getOrDefault("page", "1").toString());
|
||||
Integer pageSize = Integer.parseInt(params.getOrDefault("limit", "10").toString());
|
||||
|
||||
Page<Order> page = new Page<>(pageNum, pageSize);
|
||||
QueryWrapper<Order> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("code_id", codeId);
|
||||
wrapper.eq("is_del", 0);
|
||||
wrapper.eq("order_status", 3);
|
||||
|
||||
// 时间过滤 - 时间戳转Date
|
||||
Object payTimeStartObj = params.get("payTimeStart");
|
||||
Object payTimeEndObj = params.get("payTimeEnd");
|
||||
log.info("时间参数: payTimeStart={}, payTimeEnd={}", payTimeStartObj, payTimeEndObj);
|
||||
|
||||
if (payTimeStartObj != null && !payTimeStartObj.toString().isEmpty()) {
|
||||
long ts = Long.parseLong(payTimeStartObj.toString());
|
||||
Date startDate = new Date(ts);
|
||||
log.info("开始时间转换: timestamp={} -> date={}", ts, startDate);
|
||||
wrapper.ge("pay_time", startDate);
|
||||
}
|
||||
if (payTimeEndObj != null && !payTimeEndObj.toString().isEmpty()) {
|
||||
long ts = Long.parseLong(payTimeEndObj.toString());
|
||||
Date endDate = new Date(ts);
|
||||
log.info("结束时间转换: timestamp={} -> date={}", ts, endDate);
|
||||
wrapper.le("pay_time", endDate);
|
||||
}
|
||||
|
||||
wrapper.orderByDesc("create_time");
|
||||
|
||||
// 先查询不带时间条件的总数,用于调试
|
||||
QueryWrapper<Order> debugWrapper = new QueryWrapper<>();
|
||||
debugWrapper.eq("code_id", codeId);
|
||||
debugWrapper.eq("is_del", 0);
|
||||
debugWrapper.eq("order_status", 3);
|
||||
long totalWithoutTime = orderService.count(debugWrapper);
|
||||
log.info("不带时间条件的订单总数: {}", totalWithoutTime);
|
||||
|
||||
Page<Order> result = orderService.page(page, wrapper);
|
||||
|
||||
log.info("查询结果: 总数={}, 当前页数量={}", result.getTotal(), result.getRecords().size());
|
||||
|
||||
// 打印前几条订单的pay_time,用于调试
|
||||
if (!result.getRecords().isEmpty()) {
|
||||
for (int i = 0; i < Math.min(3, result.getRecords().size()); i++) {
|
||||
Order o = result.getRecords().get(i);
|
||||
log.info("订单[{}]: orderNo={}, pay_time={}", i, o.getOrderNo(), o.getPayTime());
|
||||
}
|
||||
}
|
||||
|
||||
return PageResult.<Order>builder()
|
||||
.data(result.getRecords())
|
||||
.resp_code(0)
|
||||
.count(result.getTotal())
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
log.error("根据二维码ID查询订单列表异常", e);
|
||||
return new PageResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,5 +96,12 @@ public interface IOrderService extends ISuperService<Order> {
|
||||
Long getUnCompleteOrderCount(String deviceSn);
|
||||
|
||||
Order getNextQueueOrder(Long tourismId, Long currentOrderId);
|
||||
|
||||
/**
|
||||
* 二维码订单统计查询
|
||||
* @param params 查询参数(tenantId, includeChildren, qrcodeName, codeId, tourismId)
|
||||
* @return 统计结果(tourismList: 景区列表,每个景区包含qrcodeList: 二维码统计列表)
|
||||
*/
|
||||
Map<String, Object> getQrcodeOrderStatistics(Map<String, Object> params);
|
||||
}
|
||||
|
||||
|
||||
+280
-4
@@ -28,10 +28,7 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -425,4 +422,283 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
||||
return baseMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getQrcodeOrderStatistics(Map<String, Object> params) {
|
||||
|
||||
String qrcodeName = MapUtils.getString(params, "qrcodeName");
|
||||
String codeId = MapUtils.getString(params, "codeId");
|
||||
Long tourismId = MapUtils.getLong(params, "tourismId");
|
||||
|
||||
// 分页参数
|
||||
Integer page = MapUtils.getInteger(params, "page", 1);
|
||||
Integer limit = MapUtils.getInteger(params, "limit", 10);
|
||||
|
||||
// 支付时间查询条件 - 处理可能是字符串的情况
|
||||
Date payTimeStart = null;
|
||||
Date payTimeEnd = null;
|
||||
|
||||
Object payTimeStartObj = params.get("payTimeStart");
|
||||
Object payTimeEndObj = params.get("payTimeEnd");
|
||||
|
||||
try {
|
||||
if (payTimeStartObj instanceof Date) {
|
||||
payTimeStart = (Date) payTimeStartObj;
|
||||
} else if (payTimeStartObj instanceof Long) {
|
||||
payTimeStart = new Date((Long) payTimeStartObj);
|
||||
} else if (payTimeStartObj instanceof Integer) {
|
||||
payTimeStart = new Date(((Integer) payTimeStartObj).longValue());
|
||||
} else if (payTimeStartObj instanceof String) {
|
||||
String timeStr = (String) payTimeStartObj;
|
||||
// 尝试解析为时间戳
|
||||
try {
|
||||
long timestamp = Long.parseLong(timeStr);
|
||||
payTimeStart = new Date(timestamp);
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果不是时间戳,尝试按日期格式解析
|
||||
payTimeStart = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(timeStr);
|
||||
}
|
||||
}
|
||||
|
||||
if (payTimeEndObj instanceof Date) {
|
||||
payTimeEnd = (Date) payTimeEndObj;
|
||||
} else if (payTimeEndObj instanceof Long) {
|
||||
payTimeEnd = new Date((Long) payTimeEndObj);
|
||||
} else if (payTimeEndObj instanceof Integer) {
|
||||
payTimeEnd = new Date(((Integer) payTimeEndObj).longValue());
|
||||
} else if (payTimeEndObj instanceof String) {
|
||||
String timeStr = (String) payTimeEndObj;
|
||||
// 尝试解析为时间戳
|
||||
try {
|
||||
long timestamp = Long.parseLong(timeStr);
|
||||
payTimeEnd = new Date(timestamp);
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果不是时间戳,尝试按日期格式解析
|
||||
payTimeEnd = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(timeStr);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("解析支付时间失败", e);
|
||||
}
|
||||
|
||||
// 如果没有传支付时间,默认查询当天
|
||||
if (payTimeStart == null) {
|
||||
payTimeStart = DateUtils.getStartOfDay(new Date());
|
||||
}
|
||||
if (payTimeEnd == null) {
|
||||
payTimeEnd = DateUtils.getEndOfDay(new Date());
|
||||
}
|
||||
|
||||
// 1. 获取租户ID(参考景区管理的查询逻辑)
|
||||
String anchor = MapUtils.getString(params, "tenantId");
|
||||
try {
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||
if (anchor == null || anchor.isEmpty()) {
|
||||
anchor = com.central.common.context.LoginUserContextHolder.getCurrentTenantId();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log.error("获取当前登录用户租户失败");
|
||||
}
|
||||
|
||||
// 2. 获取当前租户及所有子租户ID列表
|
||||
List<String> tenantIds = userCenterService.getSonTenantIds(anchor);
|
||||
|
||||
// 3. 统计总数(不受时间和其他筛选条件影响)
|
||||
Date startOfToday = DateUtils.getStartOfDay(new Date());
|
||||
Date endOfToday = DateUtils.getEndOfDay(new Date());
|
||||
|
||||
// 3.1 统计景区总数(不受tourismId等筛选条件影响)
|
||||
QueryWrapper<Tourism> totalTourismWrapper = new QueryWrapper<>();
|
||||
if (tenantIds != null && !tenantIds.isEmpty()) {
|
||||
totalTourismWrapper.in("tenant_id", tenantIds);
|
||||
}
|
||||
totalTourismWrapper.eq("is_del", 0);
|
||||
long totalTourismCount = tourismMapper.selectCount(totalTourismWrapper);
|
||||
|
||||
// 3.2 查询该租户下所有景区ID
|
||||
List<Long> allTourismIds = tourismMapper.selectList(totalTourismWrapper)
|
||||
.stream().map(Tourism::getId).collect(java.util.stream.Collectors.toList());
|
||||
|
||||
// 3.3 统计二维码总数(不受qrcodeName、codeId筛选条件影响)
|
||||
int totalQrcodeCount = 0;
|
||||
if (!allTourismIds.isEmpty()) {
|
||||
QueryWrapper<QrCode> totalQrcodeWrapper = new QueryWrapper<>();
|
||||
totalQrcodeWrapper.in("tourism_id", allTourismIds);
|
||||
totalQrcodeWrapper.eq("is_del", 0);
|
||||
totalQrcodeCount = qrCodeMapper.selectCount(totalQrcodeWrapper).intValue();
|
||||
}
|
||||
|
||||
// 3.4 统计订单总数(不受时间限制,只统计完成状态的订单)
|
||||
long totalOrderCount = 0;
|
||||
long todayOrderCount = 0;
|
||||
if (!allTourismIds.isEmpty()) {
|
||||
// 查询该租户下所有二维码的codeId
|
||||
QueryWrapper<QrCode> allQrcodeWrapper = new QueryWrapper<>();
|
||||
allQrcodeWrapper.in("tourism_id", allTourismIds);
|
||||
allQrcodeWrapper.eq("is_del", 0);
|
||||
List<String> allCodeIds = qrCodeMapper.selectList(allQrcodeWrapper)
|
||||
.stream().map(QrCode::getCodeId).collect(java.util.stream.Collectors.toList());
|
||||
log.info("二维码codeId列表: {}", allCodeIds);
|
||||
|
||||
if (!allCodeIds.isEmpty()) {
|
||||
// 统计所有完成订单数(状态3,不受时间限制)
|
||||
QueryWrapper<Order> totalOrderWrapper = new QueryWrapper<>();
|
||||
totalOrderWrapper.in("code_id", allCodeIds);
|
||||
totalOrderWrapper.eq("is_del", 0);
|
||||
totalOrderWrapper.eq("order_status", 3);
|
||||
totalOrderCount = baseMapper.selectCount(totalOrderWrapper);
|
||||
|
||||
// 统计今日完成订单数(状态3,按pay_time统计)
|
||||
QueryWrapper<Order> todayOrderWrapper = new QueryWrapper<>();
|
||||
todayOrderWrapper.in("code_id", allCodeIds);
|
||||
todayOrderWrapper.eq("is_del", 0);
|
||||
todayOrderWrapper.eq("order_status", 3);
|
||||
todayOrderWrapper.between("pay_time", startOfToday, endOfToday);
|
||||
todayOrderCount = baseMapper.selectCount(todayOrderWrapper);
|
||||
} else {
|
||||
log.warn("二维码codeId列表为空,无法统计订单");
|
||||
}
|
||||
} else {
|
||||
log.warn("景区ID列表为空,无法统计二维码和订单");
|
||||
}
|
||||
|
||||
// 4. 如果有二维码筛选条件,先找到匹配的二维码所属的景区ID
|
||||
Set<Long> filteredTourismIds = null;
|
||||
if ((codeId != null && !codeId.isEmpty()) || (qrcodeName != null && !qrcodeName.isEmpty())) {
|
||||
QueryWrapper<QrCode> filterQrCodeWrapper = new QueryWrapper<>();
|
||||
filterQrCodeWrapper.in("tourism_id", allTourismIds);
|
||||
filterQrCodeWrapper.eq("is_del", 0);
|
||||
if (qrcodeName != null && !qrcodeName.isEmpty()) {
|
||||
filterQrCodeWrapper.like("name", qrcodeName);
|
||||
}
|
||||
if (codeId != null && !codeId.isEmpty()) {
|
||||
filterQrCodeWrapper.like("code_id", codeId);
|
||||
}
|
||||
List<QrCode> filteredQrCodes = qrCodeMapper.selectList(filterQrCodeWrapper);
|
||||
filteredTourismIds = filteredQrCodes.stream()
|
||||
.map(QrCode::getTourismId)
|
||||
.collect(java.util.stream.Collectors.toSet());
|
||||
}
|
||||
|
||||
// 5. 根据租户ID列表查询景区列表(带分页,用于展示)
|
||||
Page<Tourism> tourismPage = new Page<>(page, limit);
|
||||
QueryWrapper<Tourism> tourismWrapper = new QueryWrapper<>();
|
||||
if (tenantIds != null && !tenantIds.isEmpty()) {
|
||||
tourismWrapper.in("tenant_id", tenantIds);
|
||||
}
|
||||
if (tourismId != null) {
|
||||
tourismWrapper.eq("id", tourismId);
|
||||
}
|
||||
// 如果有二维码筛选条件,只查这些景区
|
||||
if (filteredTourismIds != null) {
|
||||
if (filteredTourismIds.isEmpty()) {
|
||||
// 没有匹配的二维码,直接返回空结果
|
||||
Map<String, Object> result = new java.util.HashMap<>();
|
||||
result.put("tourismList", new java.util.ArrayList<>());
|
||||
result.put("totalTourismCount", totalTourismCount);
|
||||
result.put("totalQrcodeCount", totalQrcodeCount);
|
||||
result.put("totalOrderCount", totalOrderCount);
|
||||
result.put("todayOrderCount", todayOrderCount);
|
||||
result.put("payTimeStart", payTimeStart);
|
||||
result.put("payTimeEnd", payTimeEnd);
|
||||
result.put("page", page);
|
||||
result.put("limit", limit);
|
||||
result.put("hasMore", false);
|
||||
return result;
|
||||
}
|
||||
tourismWrapper.in("id", filteredTourismIds);
|
||||
}
|
||||
tourismWrapper.eq("is_del", 0);
|
||||
// 景区倒序排列
|
||||
tourismWrapper.orderByDesc("id");
|
||||
tourismPage = tourismMapper.selectPage(tourismPage, tourismWrapper);
|
||||
|
||||
List<Tourism> tourismList = tourismPage.getRecords();
|
||||
|
||||
// 6. 遍历景区,查询二维码和订单统计(用于展示详细列表)
|
||||
List<Map<String, Object>> tourismDataList = new java.util.ArrayList<>();
|
||||
for (Tourism tourism : tourismList) {
|
||||
// 查询该景区的二维码列表
|
||||
QueryWrapper<QrCode> qrCodeWrapper = new QueryWrapper<>();
|
||||
qrCodeWrapper.eq("tourism_id", tourism.getId());
|
||||
qrCodeWrapper.eq("is_del", 0);
|
||||
|
||||
// 根据条件筛选二维码
|
||||
if (qrcodeName != null && !qrcodeName.isEmpty()) {
|
||||
qrCodeWrapper.like("name", qrcodeName);
|
||||
}
|
||||
if (codeId != null && !codeId.isEmpty()) {
|
||||
qrCodeWrapper.like("code_id", codeId);
|
||||
}
|
||||
|
||||
List<QrCode> qrCodeList = qrCodeMapper.selectList(qrCodeWrapper);
|
||||
|
||||
if (qrCodeList.isEmpty()) {
|
||||
continue; // 如果该景区没有符合条件的二维码,跳过
|
||||
}
|
||||
|
||||
List<Map<String, Object>> qrcodeDataList = new java.util.ArrayList<>();
|
||||
long tourismOrderCount = 0;
|
||||
|
||||
for (QrCode qrCode : qrCodeList) {
|
||||
// 统计该二维码的订单数量(状态为3,pay_time在时间范围内)
|
||||
QueryWrapper<Order> orderWrapper = new QueryWrapper<>();
|
||||
orderWrapper.eq("code_id", qrCode.getCodeId());
|
||||
orderWrapper.eq("is_del", 0);
|
||||
orderWrapper.eq("order_status", 3);
|
||||
orderWrapper.between("pay_time", payTimeStart, payTimeEnd);
|
||||
Long orderCount = baseMapper.selectCount(orderWrapper);
|
||||
|
||||
// 统计该二维码今日订单数量(状态为3)
|
||||
QueryWrapper<Order> todayOrderWrapper = new QueryWrapper<>();
|
||||
todayOrderWrapper.eq("code_id", qrCode.getCodeId());
|
||||
todayOrderWrapper.eq("is_del", 0);
|
||||
todayOrderWrapper.eq("order_status", 3);
|
||||
todayOrderWrapper.between("pay_time", startOfToday, endOfToday);
|
||||
Long todayCount = baseMapper.selectCount(todayOrderWrapper);
|
||||
|
||||
Map<String, Object> qrcodeData = new java.util.HashMap<>();
|
||||
qrcodeData.put("id", qrCode.getId());
|
||||
qrcodeData.put("qrcodeId", qrCode.getCodeId());
|
||||
qrcodeData.put("qrcodeName", qrCode.getName());
|
||||
qrcodeData.put("qrcodeCode", qrCode.getCodeId());
|
||||
qrcodeData.put("orderCount", orderCount);
|
||||
qrcodeData.put("todayOrderCount", todayCount);
|
||||
qrcodeData.put("viewUrl", fileCenterService.getViewUrlByPath(qrCode.getFilePath()));
|
||||
qrcodeData.put("status", qrCode.getStatus());
|
||||
qrcodeData.put("price", qrCode.getPrice());
|
||||
qrcodeData.put("deviceSn", qrCode.getDeviceSn());
|
||||
|
||||
qrcodeDataList.add(qrcodeData);
|
||||
tourismOrderCount += orderCount;
|
||||
}
|
||||
|
||||
Map<String, Object> tourismData = new java.util.HashMap<>();
|
||||
tourismData.put("tourismId", tourism.getId());
|
||||
tourismData.put("tourismName", tourism.getTourismName());
|
||||
tourismData.put("tourismAddress", tourism.getTourismAddress());
|
||||
tourismData.put("orderCount", tourismOrderCount);
|
||||
tourismData.put("qrcodeCount", qrCodeList.size());
|
||||
tourismData.put("qrcodeList", qrcodeDataList);
|
||||
|
||||
tourismDataList.add(tourismData);
|
||||
}
|
||||
|
||||
// 6. 组装返回结果
|
||||
Map<String, Object> result = new java.util.HashMap<>();
|
||||
result.put("tourismList", tourismDataList);
|
||||
result.put("totalTourismCount", totalTourismCount);
|
||||
result.put("totalQrcodeCount", totalQrcodeCount);
|
||||
result.put("totalOrderCount", totalOrderCount);
|
||||
result.put("todayOrderCount", todayOrderCount);
|
||||
result.put("payTimeStart", payTimeStart);
|
||||
result.put("payTimeEnd", payTimeEnd);
|
||||
result.put("page", page);
|
||||
result.put("limit", limit);
|
||||
result.put("hasMore", tourismPage.getCurrent() < tourismPage.getPages()); // 是否还有更多数据
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
AND o.mobile LIKE CONCAT('%', #{p.mobile}, '%')
|
||||
</if>
|
||||
|
||||
<!-- 时间范围(与仪表盘统计口径一致) -->
|
||||
<!-- 时间范围(统计和列表统一用pay_time) -->
|
||||
<if test="p.startTime != null and p.startTime != ''">
|
||||
AND o.create_time >= #{p.startTime}
|
||||
AND o.pay_time >= #{p.startTime}
|
||||
</if>
|
||||
<if test="p.endTime != null and p.endTime != ''">
|
||||
AND o.create_time <= #{p.endTime}
|
||||
AND o.pay_time <= #{p.endTime}
|
||||
</if>
|
||||
|
||||
<!-- 景区集合过滤(由租户+子孙→景区ID集合的去重结果提供) -->
|
||||
|
||||
Reference in New Issue
Block a user