|
|
@@ -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;
|
|
|
+ }
|
|
|
}
|