Browse Source

no message

zy 7 months ago
parent
commit
397ed53341

+ 6 - 0
bus-biz/src/main/java/bus/service/BBusInfoService.java

@@ -3,6 +3,7 @@ package bus.service;
 import bus.model.dto.*;
 import bus.model.dto.page.BBusInfoPageDto;
 import bus.model.dto.req.BTrackLocalReqDto;
+import bus.model.dto.req.BusPointReqDto;
 import bus.model.po.BBusInfoPo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -84,4 +85,9 @@ public interface BBusInfoService extends IService<BBusInfoPo> {
      * @return
      */
     List<BBusInfoPo> getAllPoint();
+
+    /**
+     * 根据车辆id获取车辆经纬度信息
+     */
+    List<BBusInfoDto> getPointByBusId(BusPointReqDto busPointReqDto);
 }

+ 2 - 0
bus-biz/src/main/java/bus/service/BCourseInfoService.java

@@ -85,4 +85,6 @@ public interface BCourseInfoService extends IService<BCourseInfoPo> {
      * @return
      */
     List<WCourseInfoByTypeDto> getMapAllCourse();
+
+     WCourseDetailDto getCourseDetail(String courseId) ;
 }

+ 20 - 3
bus-biz/src/main/java/bus/service/impl/BBusInfoServiceImpl.java

@@ -4,6 +4,7 @@ import bus.model.SnowflakeUtil;
 import bus.model.dto.*;
 import bus.model.dto.page.BBusInfoPageDto;
 import bus.model.dto.req.BTrackLocalReqDto;
+import bus.model.dto.req.BusPointReqDto;
 import bus.model.po.*;
 import bus.mapper.BBusInfoMapper;
 
@@ -232,6 +233,8 @@ public class BBusInfoServiceImpl extends ServiceImpl<BBusInfoMapper,BBusInfoPo>
         trackByBusDto.setDriverPhone(busInfo.getDriverPhone());
         trackByBusDto.setStatus(busInfo.getStatus());
         trackByBusDto.setCourseName(courseInfo.getCourseName());
+        trackByBusDto.setLocalLatitude(busInfo.getLocalLatitude());
+        trackByBusDto.setLocalLongitude(busInfo.getLocalLongitude());
         // TODO: 这里需要集成实时定位服务来获取车辆的当前位置信息
         dto.setBBusTrackByBusDto(trackByBusDto);
 
@@ -418,6 +421,20 @@ public class BBusInfoServiceImpl extends ServiceImpl<BBusInfoMapper,BBusInfoPo>
         return bBusInfoPos;
     }
 
+    /**
+     * 根据车辆id获取车辆经纬度信息
+     *
+     * @param busPointReqDto
+     */
+    @Override
+    public List<BBusInfoDto> getPointByBusId(BusPointReqDto busPointReqDto) {
+        QueryWrapper<BBusInfoPo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("bus_id",busPointReqDto.getBusIdList());
+        List<BBusInfoPo> bBusInfoPos = bBusInfoMapper.selectList(queryWrapper);
+        List<BBusInfoDto> bBusInfoDtos = BeanUtil.copyToList(bBusInfoPos, BBusInfoDto.class);
+        return bBusInfoDtos;
+    }
+
     /**
      * 找出最近的站点
      */
@@ -450,11 +467,11 @@ public class BBusInfoServiceImpl extends ServiceImpl<BBusInfoMapper,BBusInfoPo>
         QueryWrapper<BCourseBusPo> queryWrapper = new QueryWrapper();
         queryWrapper.eq("bus_id", busId);
         queryWrapper.eq("is_delete", 0);
-        BCourseBusPo courseBus = (BCourseBusPo)this.bCourseBusService.getOne(queryWrapper);
-        if (courseBus == null) {
+        List<BCourseBusPo> list1 = bCourseBusService.list(queryWrapper);
+        if (CollectionUtil.isEmpty(list1)) {
             throw new BusinessException("该车辆未分配路线");
         } else {
-            String courseId = courseBus.getCourseId();
+            String courseId = list1.get(0).getCourseId();
             BCourseInfoPo byId = (BCourseInfoPo)this.bCourseInfoService.getById(courseId);
             if (byId == null) {
                 throw new BusinessException("该路线不存在");

+ 120 - 1
bus-biz/src/main/java/bus/service/impl/BCourseInfoServiceImpl.java

@@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.orcas.common.sso.model.ExtInfo;
 import com.orcas.iso.config.common.user.CurrentUserHolder;
+import com.qzwisdom.qzframework.core.tool.exception.BusinessException;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.BeanUtils;
@@ -51,6 +52,8 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
     private BCourseBusService bCourseBusService;
     @Resource
     private BBusInfoService bBusInfoService;
+    @Resource
+    private BUserCourseService bUserCourseService;
 
 	/**
      * 详情
@@ -189,6 +192,13 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
 
         //处理车辆
         List<BCourseBusDto> bCourseBusList = dto.getBCourseBusList();
+        List<String> busId = bCourseBusList.stream().map(BCourseBusDto::getBusId).collect(Collectors.toList());
+        QueryWrapper<BCourseBusPo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("bus_id", busId);
+        List<BCourseBusPo> list = bCourseBusService.list(queryWrapper);
+        if(CollectionUtil.isNotEmpty(list)){
+            throw new BusinessException("存在车辆已被绑定");
+        }
         List<BCourseBusPo> bCourseBusPos = handleCourseBus(bCourseBusList, extInfo, po.getId(), true);
         bCourseBusService.saveBatch(bCourseBusPos);
         this.bCourseInfoMapper.insert(po);
@@ -240,6 +250,15 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
         //处理车辆
         bCourseBusService.deleteByCourseId(po.getId());
         List<BCourseBusDto> bCourseBusList = dto.getBCourseBusList();
+        List<String> busId = bCourseBusList.stream().map(BCourseBusDto::getBusId).collect(Collectors.toList());
+        QueryWrapper<BCourseBusPo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("bus_id", busId);
+        queryWrapper.ne("id",dto.getId());
+        List<BCourseBusPo> list = bCourseBusService.list(queryWrapper);
+        if(CollectionUtil.isNotEmpty(list)){
+            throw new BusinessException("存在车辆已被绑定");
+        }
+
         List<BCourseBusPo> bCourseBusPos = handleCourseBus(bCourseBusList, extInfo, po.getId(), false);
         bCourseBusService.saveBatch(bCourseBusPos);
         this.bCourseInfoMapper.updateById(po);
@@ -402,7 +421,7 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
                 trackInfo.setLastStationName(courseInfo.getLastStationName());
                 trackInfo.setFirstBusSpace(courseInfo.getFirstBusSpace());
                 trackInfo.setTicketAmount(courseInfo.getTicketAmount());
-                
+                trackInfo.setMapPicUrl(courseInfo.getMapPicUrl());
                 // 处理路线站点信息
                 List<BCoursePointDto> stationInfoList = courseInfo.getMapPointList();
                 trackInfo.setClist(stationInfoList);
@@ -642,4 +661,104 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
             return dto;
         }).collect(Collectors.toList());
     }
+
+    /**
+     * 获取路线详细信息,包括路线基本信息、站点、时间表等
+     * @param courseId 路线ID
+     * @return 路线详细信息
+     */
+    @Override
+    public WCourseDetailDto getCourseDetail(String courseId) {
+        WCourseDetailDto detailDto = new WCourseDetailDto();
+        
+        // 获取路线基本信息
+        BCourseInfoPo courseInfo = this.getById(courseId);
+        if (courseInfo == null) {
+            return null;
+        }
+        QueryWrapper<BUserCoursePo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("course_id",courseId);
+        List<BUserCoursePo> list = bUserCourseService.list(queryWrapper);
+        if(CollectionUtil.isNotEmpty(list)){
+            detailDto.setIsCollect("1");
+        }
+        // 设置基本信息
+        detailDto.setCourseId(courseId);
+        detailDto.setCourseName(courseInfo.getCourseName());
+        detailDto.setTicketAmount(courseInfo.getTicketAmount());
+        detailDto.setFirstStationName(courseInfo.getFirstStationName());
+        detailDto.setLastStationName(courseInfo.getLastStationName());
+        detailDto.setMapPicUrl(courseInfo.getMapPicUrl());
+        // 获取路线点位信息
+        String mapPoint = courseInfo.getMapPoint();
+        if (StrUtil.isNotBlank(mapPoint)) {
+            List<BCoursePointDto> routePoints = JSONUtil.toList(mapPoint, BCoursePointDto.class);
+            detailDto.setRoutePoints(routePoints);
+        }
+        
+        // 获取站点信息
+        QueryWrapper<BCourseStationPo> stationWrapper = new QueryWrapper<>();
+        stationWrapper.eq("course_id", courseId);
+        stationWrapper.orderByAsc("sort");
+        List<BCourseStationPo> stations = bCourseStationService.list(stationWrapper);
+        
+        if (CollectionUtil.isNotEmpty(stations)) {
+            List<String> stationIds = stations.stream()
+                .map(BCourseStationPo::getStationId)
+                .collect(Collectors.toList());
+                
+            // 获取站点详细信息
+            Map<String, BStationInfoPo> stationMap = bStationInfoService.listByIds(stationIds)
+                .stream()
+                .collect(Collectors.toMap(BStationInfoPo::getId, station -> station));
+                
+            List<WCourseStationDto> stationList = new ArrayList<>();
+            for (BCourseStationPo station : stations) {
+                BStationInfoPo stationInfo = stationMap.get(station.getStationId());
+                if (stationInfo != null) {
+                    WCourseStationDto stationDto = new WCourseStationDto();
+                    stationDto.setStationId(stationInfo.getId());
+                    stationDto.setStationName(stationInfo.getName());
+                    stationDto.setStationType(stationInfo.getStationType());
+                    stationDto.setLatitude(stationInfo.getLatitude());
+                    stationDto.setLongitude(stationInfo.getLongitude());
+                    stationDto.setSort(station.getSort());
+                    stationDto.setType(station.getType()); // 0:起点 1:途经点 2:终点
+                    stationList.add(stationDto);
+                }
+            }
+            detailDto.setStations(stationList);
+        }
+        
+        // 获取时间表信息
+        QueryWrapper<BCourseTimePo> timeWrapper = new QueryWrapper<>();
+        timeWrapper.eq("course_id", courseId);
+        timeWrapper.orderByAsc("sort");
+        List<BCourseTimePo> times = bCourseTimeService.list(timeWrapper);
+        
+        if (CollectionUtil.isNotEmpty(times)) {
+            List<WCourseTimeDto> timeList = times.stream()
+                .map(time -> {
+                    WCourseTimeDto timeDto = new WCourseTimeDto();
+                    timeDto.setBusSpace(time.getBusSpace());
+                    timeDto.setType(time.getType()); // 0:首班车 1:其他班次
+                    return timeDto;
+                })
+                .collect(Collectors.toList());
+            detailDto.setTimes(timeList);
+        }
+        QueryWrapper<BCourseBusPo> queryWrapper3 = new QueryWrapper<>();
+        queryWrapper3.eq("course_id", courseId);
+        queryWrapper3.orderByAsc("sort");
+        List<BCourseBusPo> list3 = bCourseBusService.list(queryWrapper3);
+        if(CollectionUtil.isNotEmpty(list3)) {
+            List<String> busIds = list3.stream().map(BCourseBusPo::getBusId).collect(Collectors.toList());
+            QueryWrapper<BBusInfoPo> queryWrapper4 = new QueryWrapper<>();
+            queryWrapper4.in("id", busIds);
+            List<BBusInfoPo> list4 = bBusInfoService.list(queryWrapper4);
+            List<WBusInfoDto> wBusInfoDtos = BeanUtil.copyToList(list4, WBusInfoDto.class);
+            detailDto.setBuses(wBusInfoDtos);
+        }
+        return detailDto;
+    }
 }

+ 1 - 1
bus-biz/src/main/java/bus/service/impl/BUserCourseServiceImpl.java

@@ -68,7 +68,7 @@ public class BUserCourseServiceImpl extends ServiceImpl<BUserCourseMapper,BUserC
         po.setUserId(extInfo.getUserId());
         po.setCourseId(dto.getCourseId());
         po.setTop("0");
-        po.setTop(snowflakeUtil.snowflakeId());
+        po.setId(snowflakeUtil.snowflakeId());
         this.bUserCourseMapper.insert(po);
     }
 

+ 38 - 0
bus-common/src/main/java/bus/model/dto/WBusInfoDto.java

@@ -0,0 +1,38 @@
+package bus.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+* @Program: bus
+* @Description: 描述
+* @Author: zy
+* @Date: 2025-03-01 09:44:24
+**/
+@Data
+public class WBusInfoDto {
+    @ApiModelProperty("id")
+    private String id;
+    @ApiModelProperty("车辆名称")
+    //@NotBlank(message = "车辆名称不能为空")
+    private String busName;
+    @ApiModelProperty("车牌号")
+    @NotBlank(message = "车牌号不能为空")
+    private String busNo;
+    @ApiModelProperty("车辆类型")
+    private String busType;
+    @ApiModelProperty("车辆图片")
+    private String busUrl;
+    @ApiModelProperty("驾驶员姓名")
+    @NotBlank(message = "驾驶员姓名不能为空")
+    private String driverName;
+    @ApiModelProperty("驾驶员号码")
+    @NotBlank(message = "驾驶员号码不能为空")
+    private String driverPhone;
+    @ApiModelProperty("车辆状态 0禁用 1维护 2正常")
+    private String status;
+
+
+}

+ 1 - 0
bus-common/src/main/java/bus/model/dto/WBusTrackInfoDto.java

@@ -18,6 +18,7 @@ public class WBusTrackInfoDto {
     private String courseId;
     @ApiModelProperty("线路名称")
     private String courseName;
+    private String mapPicUrl;
     @ApiModelProperty("出发站点名称")
     private String firstStationName;
     @ApiModelProperty("最后站点名称")

+ 59 - 0
bus-common/src/main/java/bus/model/dto/WCourseDetailDto.java

@@ -0,0 +1,59 @@
+package bus.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 路线详情DTO
+ */
+@Data
+public class WCourseDetailDto {
+    /**
+     * 路线ID
+     */
+    private String courseId;
+
+    /**
+     * 路线名称
+     */
+    private String courseName;
+
+    /**
+     * 票价
+     */
+    private BigDecimal ticketAmount;
+
+    /**
+     * 起点站名称
+     */
+    private String firstStationName;
+
+    /**
+     * 终点站名称
+     */
+    private String lastStationName;
+    private String mapPicUrl;
+
+    @ApiModelProperty("1收藏 0未收藏")
+    private String isCollect = "0";
+    /**
+     * 路线点位列表
+     */
+    private List<BCoursePointDto> routePoints;
+
+    /**
+     * 站点列表
+     */
+    private List<WCourseStationDto> stations;
+
+    /**
+     * 时间表
+     */
+    private List<WCourseTimeDto> times;
+    /**
+     * 车辆
+     */
+    private List<WBusInfoDto> buses;
+}

+ 46 - 0
bus-common/src/main/java/bus/model/dto/WCourseStationDto.java

@@ -0,0 +1,46 @@
+package bus.model.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 站点信息DTO
+ */
+@Data
+public class WCourseStationDto {
+    /**
+     * 站点ID
+     */
+    private String stationId;
+
+    /**
+     * 站点名称
+     */
+    private String stationName;
+
+    /**
+     * 站点类型
+     */
+    private String stationType;
+
+    /**
+     * 纬度
+     */
+    private BigDecimal latitude;
+
+    /**
+     * 经度
+     */
+    private BigDecimal longitude;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 类型(0:起点 1:途经点 2:终点)
+     */
+    private String type;
+}

+ 24 - 0
bus-common/src/main/java/bus/model/dto/WCourseTimeDto.java

@@ -0,0 +1,24 @@
+package bus.model.dto;
+
+import lombok.Data;
+
+/**
+ * 时间表DTO
+ */
+@Data
+public class WCourseTimeDto {
+    /**
+     * 发车时间
+     */
+    private String startTime;
+
+    /**
+     * 发车间隔(分钟)
+     */
+    private String busSpace;
+
+    /**
+     * 类型(0:首班车 1:其他班次)
+     */
+    private String type;
+}

+ 10 - 0
bus-common/src/main/java/bus/model/dto/req/BusPointReqDto.java

@@ -0,0 +1,10 @@
+package bus.model.dto.req;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class BusPointReqDto {
+    private List<String> busIdList;
+}

+ 1 - 0
bus-common/src/main/java/bus/model/vo/BCourseInfoVo.java

@@ -42,4 +42,5 @@ public class BCourseInfoVo extends AbstractBaseVO{
     private String firstBusSpace;
     @ApiModelProperty("路线点")
     private String mapPoint;
+    private String mapPicUrl;
 }

+ 11 - 0
bus-web/src/main/java/bus/controller/biz/BBusTrackController.java

@@ -5,6 +5,7 @@ import bus.model.dto.BBusTrackInfoDto;
 import bus.model.dto.BBusTrackTreeDto;
 import bus.model.dto.BTrackStationDto;
 import bus.model.dto.page.BBusInfoPageDto;
+import bus.model.dto.req.BusPointReqDto;
 import bus.model.po.BBusInfoPo;
 import bus.service.BBusInfoService;
 import com.github.pagehelper.PageHelper;
@@ -77,4 +78,14 @@ public class BBusTrackController implements BaseController {
         List<BBusInfoPo> allPoint = bBusInfoService.getAllPoint();
         return allPoint;
     }
+
+    /**
+     * 根据车辆id获取车辆经纬度信息
+     */
+    @ApiOperation("根据车辆id获取车辆经纬度信息")
+    @PostMapping(value = "getPointByBusId")
+    List<BBusInfoDto> getPointByBusId(@RequestBody BusPointReqDto busPointReqDto){
+        List<BBusInfoDto> pointByBusId = bBusInfoService.getPointByBusId(busPointReqDto);
+        return pointByBusId;
+    }
 }

+ 6 - 0
bus-web/src/main/java/bus/controller/biz/BCourseInfoController.java

@@ -131,4 +131,10 @@ public class BCourseInfoController implements BaseController {
         return bCourseInfoService.getNearbyRoutes(nearbyRoutesDto);
     }
 
+    @ApiOperation("小程序路线详情")
+    @GetMapping(value = "getCourseDetail")
+    WCourseDetailDto getCourseDetail(@RequestParam String courseId) {
+        WCourseDetailDto courseDetail = bCourseInfoService.getCourseDetail(courseId);
+        return courseDetail;
+    }
 }

+ 1 - 1
bus-web/src/main/java/bus/controller/biz/BUserCourseController.java

@@ -50,7 +50,7 @@ public class BUserCourseController implements BaseController {
         return bUserCourseService.getMyCourse();
     }
 
-    @DeleteMapping("/delete")
+    @PostMapping("/delete")
     @ApiOperation(value = "取消收藏")
     public void delete(@RequestParam String courseId) {
         bUserCourseService.delete(courseId);