|
|
@@ -77,13 +77,17 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
queryWrapper.eq("course_id", id);
|
|
|
queryWrapper.orderByAsc("sort");
|
|
|
List<BCourseTimePo> list = bCourseTimeService.list(queryWrapper);
|
|
|
- bCourseInfoDto.setBCourseTimeList(BeanUtil.copyToList(list, BCourseTimeDto.class));
|
|
|
+ Map<String, List<BCourseTimePo>> map = list.stream().collect(Collectors.groupingBy(BCourseTimePo::getBackType));
|
|
|
+ bCourseInfoDto.setBCourseTimeList(BeanUtil.copyToList(map.get("0"), BCourseTimeDto.class));
|
|
|
+ bCourseInfoDto.setBCourseTimeBackList(BeanUtil.copyToList(map.get("1"), BCourseTimeDto.class));
|
|
|
|
|
|
QueryWrapper<BCoursePrePo> queryWrapper6 = new QueryWrapper<>();
|
|
|
queryWrapper6.eq("course_id", id);
|
|
|
queryWrapper6.orderByAsc("sort");
|
|
|
List<BCoursePrePo> list6 = bCoursePreService.list(queryWrapper6);
|
|
|
- bCourseInfoDto.setBCoursePreList(BeanUtil.copyToList(list6, BCoursePreDto.class));
|
|
|
+ Map<String, List<BCoursePrePo>> map1 = list6.stream().collect(Collectors.groupingBy(BCoursePrePo::getBackType));
|
|
|
+ bCourseInfoDto.setBCoursePreList(BeanUtil.copyToList(map1.get("0"), BCoursePreDto.class));
|
|
|
+ bCourseInfoDto.setBCoursePreBackList(BeanUtil.copyToList(map1.get("1"), BCoursePreDto.class));
|
|
|
|
|
|
QueryWrapper<BCourseStationPo> queryWrapper1 = new QueryWrapper<>();
|
|
|
queryWrapper1.eq("course_id", id);
|
|
|
@@ -165,6 +169,20 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void save(BCourseInfoDto dto){
|
|
|
+ String isBack = dto.getIsBack();
|
|
|
+ if(isBack.equals("1")){
|
|
|
+ List<BCoursePreDto> bCoursePreBackList = dto.getBCoursePreBackList();
|
|
|
+ if(CollectionUtil.isEmpty(bCoursePreBackList)){
|
|
|
+ throw new BusinessException("返程预约不能为空");
|
|
|
+ }
|
|
|
+ List<BCourseTimeDto> bCourseTimeBackList = dto.getBCourseTimeBackList();
|
|
|
+ if(CollectionUtil.isEmpty(bCourseTimeBackList)){
|
|
|
+ throw new BusinessException("返程时刻不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
BCourseInfoPo po = BeanUtil.toBean(dto, BCourseInfoPo.class);
|
|
|
List<BCoursePointDto> mapPointList = dto.getMapPointList();
|
|
|
if(CollectionUtil.isNotEmpty(mapPointList)) {
|
|
|
@@ -182,12 +200,20 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
//处理时刻
|
|
|
List<BCourseTimeDto> bCourseTimeList = dto.getBCourseTimeList();
|
|
|
po.setFirstBusSpace(bCourseTimeList.get(0).getBusSpace());
|
|
|
- List<BCourseTimePo> bCourseTimePoList = handleCourseTime(bCourseTimeList, extInfo, po.getId(), false);
|
|
|
- bCourseTimeService.saveBatch(bCourseTimePoList);
|
|
|
+ List<BCourseTimePo> bCourseTimePoList = handleCourseTime(bCourseTimeList, extInfo, po.getId(), false,"0");
|
|
|
+ //处理时刻返程
|
|
|
+ List<BCourseTimeDto> bCourseTimeBackList = dto.getBCourseTimeBackList();
|
|
|
+ List<BCourseTimePo> bCourseTimePoBackList = handleCourseTime(bCourseTimeBackList, extInfo, po.getId(), false,"1");
|
|
|
+ bCourseTimePoBackList.addAll(bCourseTimePoList);
|
|
|
+ bCourseTimeService.saveBatch(bCourseTimePoBackList);
|
|
|
+
|
|
|
//处理预约时刻
|
|
|
List<BCoursePreDto> bCoursePreList = dto.getBCoursePreList();
|
|
|
- List<BCoursePrePo> bCoursePrePos = handleCoursePre(bCoursePreList, extInfo, po.getId(), false);
|
|
|
- bCoursePreService.saveBatch(bCoursePrePos);
|
|
|
+ List<BCoursePrePo> bCoursePrePos = handleCoursePre(bCoursePreList, extInfo, po.getId(), false,"0");
|
|
|
+ List<BCoursePreDto> bCoursePreBackList = dto.getBCoursePreList();
|
|
|
+ List<BCoursePrePo> bCoursePrePobackList = handleCoursePre(bCoursePreBackList, extInfo, po.getId(), false,"1");
|
|
|
+ bCoursePrePobackList.addAll(bCoursePrePos);
|
|
|
+ bCoursePreService.saveBatch(bCoursePrePobackList);
|
|
|
|
|
|
//处理标志点
|
|
|
List<BCourseStationDto> bCourseStationList = dto.getBCourseStationList();
|
|
|
@@ -250,6 +276,18 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
*/
|
|
|
@Override
|
|
|
public void update(BCourseInfoDto dto){
|
|
|
+ String isBack = dto.getIsBack();
|
|
|
+ if(isBack.equals("1")){
|
|
|
+ List<BCoursePreDto> bCoursePreBackList = dto.getBCoursePreBackList();
|
|
|
+ if(CollectionUtil.isEmpty(bCoursePreBackList)){
|
|
|
+ throw new BusinessException("返程预约不能为空");
|
|
|
+ }
|
|
|
+ List<BCourseTimeDto> bCourseTimeBackList = dto.getBCourseTimeBackList();
|
|
|
+ if(CollectionUtil.isEmpty(bCourseTimeBackList)){
|
|
|
+ throw new BusinessException("返程时刻不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
BCourseInfoPo po = BeanUtil.toBean(dto, BCourseInfoPo.class);
|
|
|
List<BCoursePointDto> mapPointList = dto.getMapPointList();
|
|
|
if(CollectionUtil.isNotEmpty(mapPointList)) {
|
|
|
@@ -264,14 +302,22 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
bCourseTimeService.deleteByCourseId(po.getId());
|
|
|
List<BCourseTimeDto> bCourseTimeList = dto.getBCourseTimeList();
|
|
|
po.setFirstBusSpace(bCourseTimeList.get(0).getBusSpace());
|
|
|
- List<BCourseTimePo> bCourseTimePoList = handleCourseTime(bCourseTimeList, extInfo, po.getId(), false);
|
|
|
- bCourseTimeService.saveBatch(bCourseTimePoList);
|
|
|
+ List<BCourseTimePo> bCourseTimePoList = handleCourseTime(bCourseTimeList, extInfo, po.getId(), false,"0");
|
|
|
+ //处理时刻返程
|
|
|
+ List<BCourseTimeDto> bCourseTimeBackList = dto.getBCourseTimeBackList();
|
|
|
+ List<BCourseTimePo> bCourseTimePoBackList = handleCourseTime(bCourseTimeBackList, extInfo, po.getId(), false,"1");
|
|
|
+ bCourseTimePoBackList.addAll(bCourseTimePoList);
|
|
|
+ bCourseTimeService.saveBatch(bCourseTimePoBackList);
|
|
|
|
|
|
//处理预约时刻
|
|
|
bCoursePreService.deleteByCourseId(po.getId());
|
|
|
List<BCoursePreDto> bCoursePreList = dto.getBCoursePreList();
|
|
|
- List<BCoursePrePo> bCoursePrePos = handleCoursePre(bCoursePreList, extInfo, po.getId(), false);
|
|
|
- bCoursePreService.saveBatch(bCoursePrePos);
|
|
|
+ List<BCoursePrePo> bCoursePrePos = handleCoursePre(bCoursePreList, extInfo, po.getId(), false,"0");
|
|
|
+ List<BCoursePreDto> bCoursePreBackList = dto.getBCoursePreBackList();
|
|
|
+ List<BCoursePrePo> bCoursePrePobackList = handleCoursePre(bCoursePreBackList, extInfo, po.getId(), false,"1");
|
|
|
+ bCoursePrePobackList.addAll(bCoursePrePos);
|
|
|
+ bCoursePreService.saveBatch(bCoursePrePobackList);
|
|
|
+
|
|
|
//处理标志点
|
|
|
bCourseStationService.deleteByCourseId(po.getId());
|
|
|
List<BCourseStationDto> bCourseStationList = dto.getBCourseStationList();
|
|
|
@@ -303,13 +349,16 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
private List<BCourseTimePo> handleCourseTime(List<BCourseTimeDto> timeList,
|
|
|
ExtInfo extInfo,
|
|
|
String courseId,
|
|
|
- Boolean isCreate) {
|
|
|
+ Boolean isCreate,
|
|
|
+ String backType
|
|
|
+ ) {
|
|
|
List<BCourseTimePo> bCourseTimePoList = new ArrayList<>();
|
|
|
for (int i = 0; i < timeList.size(); i++) {
|
|
|
BCourseTimeDto bCourseTimeDto = timeList.get(i);
|
|
|
BCourseTimePo bCourseTimePo = BeanUtil.toBean(bCourseTimeDto, BCourseTimePo.class);
|
|
|
bCourseTimePo.setId(snowflakeUtil.snowflakeId());
|
|
|
bCourseTimePo.setCourseId(courseId);
|
|
|
+ bCourseTimePo.setBackType(backType);
|
|
|
if(isCreate){
|
|
|
bCourseTimePo.setCreateTime(new Date());
|
|
|
bCourseTimePo.setCreatorId(extInfo.getUserId());
|
|
|
@@ -331,13 +380,15 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
private List<BCoursePrePo> handleCoursePre(List<BCoursePreDto> timeList,
|
|
|
ExtInfo extInfo,
|
|
|
String courseId,
|
|
|
- Boolean isCreate) {
|
|
|
+ Boolean isCreate,
|
|
|
+ String backType) {
|
|
|
List<BCoursePrePo> bCoursePrePoList = new ArrayList<>();
|
|
|
for (int i = 0; i < timeList.size(); i++) {
|
|
|
BCoursePreDto bCoursePreDto = timeList.get(i);
|
|
|
BCoursePrePo bCoursePrePo = BeanUtil.toBean(bCoursePreDto, BCoursePrePo.class);
|
|
|
bCoursePrePo.setId(snowflakeUtil.snowflakeId());
|
|
|
bCoursePrePo.setCourseId(courseId);
|
|
|
+ bCoursePrePo.setBackType(backType);
|
|
|
if(isCreate){
|
|
|
bCoursePrePo.setCreateTime(new Date());
|
|
|
bCoursePrePo.setCreatorId(extInfo.getUserId());
|
|
|
@@ -739,7 +790,7 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
* @return 路线详细信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public WCourseDetailDto getCourseDetail(String courseId) {
|
|
|
+ public WCourseDetailDto getCourseDetail(String courseId,String backType) {
|
|
|
WCourseDetailDto detailDto = new WCourseDetailDto();
|
|
|
|
|
|
// 获取路线基本信息
|
|
|
@@ -757,10 +808,16 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
detailDto.setCourseId(courseId);
|
|
|
detailDto.setCourseName(courseInfo.getCourseName());
|
|
|
detailDto.setTicketAmount(courseInfo.getTicketAmount());
|
|
|
+
|
|
|
detailDto.setFirstStationName(courseInfo.getFirstStationName());
|
|
|
detailDto.setLastStationName(courseInfo.getLastStationName());
|
|
|
+ if(StrUtil.isNotBlank(backType) && "1".equals(backType)){
|
|
|
+ detailDto.setFirstStationName(courseInfo.getLastStationName());
|
|
|
+ detailDto.setLastStationName(courseInfo.getFirstStationName());
|
|
|
+ }
|
|
|
detailDto.setMapPicUrl(courseInfo.getMapPicUrl());
|
|
|
detailDto.setCourseType(courseInfo.getCourseType());
|
|
|
+ detailDto.setIsBack(courseInfo.getIsBack());
|
|
|
// 获取路线点位信息
|
|
|
String mapPoint = courseInfo.getMapPoint();
|
|
|
if (StrUtil.isNotBlank(mapPoint)) {
|
|
|
@@ -805,9 +862,10 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
// 获取时间表信息
|
|
|
QueryWrapper<BCourseTimePo> timeWrapper = new QueryWrapper<>();
|
|
|
timeWrapper.eq("course_id", courseId);
|
|
|
+ timeWrapper.eq("back_type", backType);
|
|
|
timeWrapper.orderByAsc("sort");
|
|
|
List<BCourseTimePo> times = bCourseTimeService.list(timeWrapper);
|
|
|
-
|
|
|
+
|
|
|
if (CollectionUtil.isNotEmpty(times)) {
|
|
|
List<WCourseTimeDto> timeList = times.stream()
|
|
|
.map(time -> {
|
|
|
@@ -871,6 +929,7 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
|
|
|
dto2.setId(bCourseInfoPo.getId());
|
|
|
dto2.setName(bCourseInfoPo.getCourseName());
|
|
|
dto2.setType("0");
|
|
|
+ dto2.setIsBack(bCourseInfoPo.getIsBack());
|
|
|
dto2.setFirstStationName(bCourseInfoPo.getFirstStationName());
|
|
|
dto2.setFirstStationId(bCourseInfoPo.getFirstStationId());
|
|
|
dto2.setLastStationName(bCourseInfoPo.getLastStationName());
|