zhouy 7 месяцев назад
Родитель
Сommit
e8ea2661dc

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

@@ -23,7 +23,7 @@ public interface BCourseInfoService extends IService<BCourseInfoPo> {
      * @param id
      * @return
      */
-    BCourseInfoDto getDetailById(String id);
+    BCourseInfoDto getDetailById(String id );
 
     BCourseInfoPo getDetail(String id);
 	/**
@@ -91,7 +91,7 @@ public interface BCourseInfoService extends IService<BCourseInfoPo> {
      */
     List<WCourseInfoByTypeDto> getMapAllCourse();
 
-     WCourseDetailDto getCourseDetail(String courseId) ;
+     WCourseDetailDto getCourseDetail(String courseId,String backType) ;
 
 
     List<WBusInfoDto> getCourseBusByCourseId(String courseId);

+ 1 - 1
bus-biz/src/main/java/bus/service/BCoursePreService.java

@@ -24,7 +24,7 @@ public interface BCoursePreService extends IService<BCoursePrePo> {
      * 预约时刻详情
      * @return
      */
-    BCoursePreTypeDto getDetailPre(String type,String courseId);
+    BCoursePreTypeDto getDetailPre(String type,String courseId,String backType);
 
 
     /**

+ 73 - 14
bus-biz/src/main/java/bus/service/impl/BCourseInfoServiceImpl.java

@@ -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());

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

@@ -56,12 +56,15 @@ public class BCoursePreServiceImpl extends ServiceImpl<BCoursePreMapper, BCourse
     private SnowflakeUtil snowflakeUtil;
 
     @Override
-    public BCoursePreTypeDto getDetailPre(String type,String courseId) {
+    public BCoursePreTypeDto getDetailPre(String type,String courseId,String backType) {
         ExtInfo extInfo = CurrentUserHolder.get();
         String userId = extInfo.getUserId();
         QueryWrapper<BCoursePrePo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("course_id", courseId);
+        queryWrapper.eq("backType", backType);
+
         List<BCoursePrePo> list = this.bCoursePreMapper.selectList(queryWrapper);
+        //根据当天 星期6 星期天
         Map<String,List<BCoursePrePo>> map = list.stream().collect(Collectors.groupingBy(BCoursePrePo::getType, Collectors.toList()));
         BCoursePreTypeDto typeDto = new BCoursePreTypeDto();
         for (Map.Entry<String, List<BCoursePrePo>> entry : map.entrySet()) {
@@ -80,6 +83,7 @@ public class BCoursePreServiceImpl extends ServiceImpl<BCoursePreMapper, BCourse
         statDto.setStartDate(DateUtil.parse(today, "yyyy-MM-dd"));
         statDto.setEndDate(DateUtil.parse(sunday, "yyyy-MM-dd"));
         statDto.setType(type);
+
         statDto.setCourseId(courseId);
         // 查询各时间段预约数量
         List<BUserPreCountVo> bUserPreCountVos = bUserPreMapper.countByDateAndType(statDto);

+ 2 - 0
bus-biz/src/main/resources/mapper/BCourseInfoMapper.xml

@@ -114,6 +114,7 @@
         r.last_station_name as lastStationName,
         r.first_bus_space as firstBusSpace,
         r.area as area,
+        r.is_back as isBack,
         r.map_point as mapPoint,
         rs.station_id as stationId
         FROM
@@ -143,6 +144,7 @@
         r.last_station_name as lastStationName,
         r.first_bus_space as firstBusSpace,
         r.area as area,
+        r.is_back as isBack,
         r.map_point as mapPoint,
         rs.station_id as stationId
         FROM

+ 13 - 0
bus-common/src/main/java/bus/model/dto/BCourseInfoDto.java

@@ -22,6 +22,7 @@ public class BCourseInfoDto{
     @ApiModelProperty("id")
     private String id;
     @ApiModelProperty("线路名称")
+    @NotBlank(message = "线路名称不能为空")
     private String courseName;
     @ApiModelProperty("线路编号")
     private String courseCode;
@@ -51,11 +52,20 @@ public class BCourseInfoDto{
     private BigDecimal ticketAmount;
     @ApiModelProperty("路线状态 0正常 1维护 2禁用")
     private String status;
+    @ApiModelProperty("是否往返 1是 0否")
+    @NotBlank(message = "是否往返不能为空")
+    private String isBack;
+
+    @ApiModelProperty("1收藏 0未收藏")
+    private String isCollect = "0";
 
     @ApiModelProperty("时刻LIST")
     @NotEmpty(message = "时刻列表不能为空")
     List<BCourseTimeDto> bCourseTimeList;
 
+    @ApiModelProperty("返程时刻LIST")
+    List<BCourseTimeDto> bCourseTimeBackList;
+
     @ApiModelProperty("标志点LIST")
     @NotEmpty(message = "标志点列表不能为空")
     List<BCourseStationDto> bCourseStationList;
@@ -68,5 +78,8 @@ public class BCourseInfoDto{
     @NotEmpty(message = "预约时刻不能为空")
     List<BCoursePreDto> bCoursePreList;
 
+    @ApiModelProperty("返程预约时刻LIST")
+    List<BCoursePreDto> bCoursePreBackList;
+
 
 }

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

@@ -13,6 +13,7 @@ public class BUserPreStatDto {
     private Date endDate;
      //0当日 1周6 2周日
     private String type;
+    private String backType;
 
     private String  courseId;
 

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

@@ -14,6 +14,7 @@ public class FindResultDto {
     private String name;
     @ApiModelProperty("详细地址")
     private String detailAddress;
+    private String isBack;
 
     @ApiModelProperty("经度")
     private BigDecimal longitude;

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

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

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

@@ -19,6 +19,7 @@ public class WCourseDetailDto {
      * 路线名称
      */
     private String courseName;
+    private String isBack;
 
     private String   courseType;
 
@@ -54,6 +55,11 @@ public class WCourseDetailDto {
      * 时间表
      */
     private List<WCourseTimeDto> times;
+
+    /**
+     * 时间表
+     */
+    private List<WCourseTimeDto> backTimes;
     /**
      * 车辆
      */

+ 2 - 0
bus-common/src/main/java/bus/model/dto/WCourseInfoByTypeDto.java

@@ -23,6 +23,8 @@ public class WCourseInfoByTypeDto {
     private String courseCode;
     @ApiModelProperty("地图快照")
     private String mapPicUrl;
+    @ApiModelProperty("是否返程 0否 1是")
+    private String isBack;
     @ApiModelProperty("首个站点名称")
     private String firstStationName;
     @ApiModelProperty("首个站点id")

+ 2 - 0
bus-common/src/main/java/bus/model/po/BCourseInfoPo.java

@@ -23,6 +23,8 @@ public class BCourseInfoPo{
     private String courseName;
     private String courseCode;
     private String courseType;
+    @ApiModelProperty("是否往返 0否 1是")
+    private String isBack;
     @ApiModelProperty("地图快照")
     private String mapPicUrl;
     @ApiModelProperty("路线点")

+ 1 - 0
bus-common/src/main/java/bus/model/po/BCoursePrePo.java

@@ -21,6 +21,7 @@ public class BCoursePrePo{
     private String courseId;
     private String preTime;
     private String type;
+    private String backType;
     private Integer sort;
     private String remark;
     private Date createTime;

+ 1 - 0
bus-common/src/main/java/bus/model/po/BCourseTimePo.java

@@ -22,6 +22,7 @@ public class BCourseTimePo{
     private String busSpace;
     private Integer sort;
     private String type;
+    private String backType;// 1返程 0单层
     private String remark;
     private Date createTime;
     private Date updateTime;

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

@@ -26,6 +26,8 @@ public class BCourseInfoVo extends AbstractBaseVO{
     private String courseCode;
     @ApiModelProperty("线路类型 0单层专线,1闭环专线")
     private String courseType;
+    @ApiModelProperty("是否往返 0否 1是")
+    private String isBack;
     @ApiModelProperty("路线状态 0正常 1维护 2禁用")
     private String status;
     @ApiModelProperty("区")

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

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

+ 2 - 2
bus-web/src/main/java/bus/controller/biz/BCoursePreController.java

@@ -44,8 +44,8 @@ public class BCoursePreController implements BaseController {
      */
      @ApiOperation("预约时刻详情")
      @GetMapping(value = "getDetailPre")
-     public BCoursePreTypeDto getDetailPre(@RequestParam String type,@RequestParam String courseId){
-         return bCoursePreService.getDetailPre(type,courseId);
+     public BCoursePreTypeDto getDetailPre(@RequestParam String type,@RequestParam String courseId,@RequestParam String backType){
+         return bCoursePreService.getDetailPre(type,courseId,backType);
      }
 
     /**