Commit 530baae6 authored by 周健威's avatar 周健威

修改热门检索

parent 1a93d8ac
...@@ -111,6 +111,8 @@ public class VehicleModel implements Serializable { ...@@ -111,6 +111,8 @@ public class VehicleModel implements Serializable {
@Column(name = "score") @Column(name = "score")
@ApiModelProperty(value = "评分") @ApiModelProperty(value = "评分")
private Integer score; private Integer score;
@Column(name = "热度标记,1--热门;2--非热门")
@ApiModelProperty(value = "热度标记,1--热门;2--非热门")
Integer hotSign;
} }
package com.xxfc.platform.vehicle.pojo;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
@Data
public class HotVeicleDTO extends PageParam {
@ApiModelProperty("城市")
Integer addrCity;
@ApiModelProperty("经度")
Double lon;
@ApiModelProperty("纬度")
Double lat;
@ApiModelProperty(hidden = true)
Integer hotSign;
}
\ No newline at end of file
...@@ -39,9 +39,6 @@ public class UsableVeicleDTO extends PageParam { ...@@ -39,9 +39,6 @@ public class UsableVeicleDTO extends PageParam {
@ApiModelProperty(value = "分类列表", hidden = true) @ApiModelProperty(value = "分类列表", hidden = true)
Map<Integer, List<VehiclePlatCata>> catas; Map<Integer, List<VehiclePlatCata>> catas;
// @ApiModelProperty(value = "一级分类列表", hidden = true)
// Map<Integer, List<VehiclePlatCata>> pCatas;
public void setStartDateTamp(Long startDateTamp) { public void setStartDateTamp(Long startDateTamp) {
this.startDateTamp = startDateTamp; this.startDateTamp = startDateTamp;
this.startDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8))); this.startDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)));
......
package com.xxfc.platform.vehicle.biz; package com.xxfc.platform.vehicle.biz;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
...@@ -838,6 +839,19 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -838,6 +839,19 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
public PageDataVO<UsableVehicleModelVO> searchUsableModel(UsableVeicleDTO dto){ public PageDataVO<UsableVehicleModelVO> searchUsableModel(UsableVeicleDTO dto){
Map<String, Object> params = BeanUtil.beanToMap(dto); Map<String, Object> params = BeanUtil.beanToMap(dto);
if(StrUtil.isNotBlank(dto.getStartDate()) && StrUtil.isNotBlank(dto.getEndDate())) {
initBookSearchParam(dto, params);
}
return PageDataVO.pageInfo(dto.getPage(), dto.getLimit(), () -> mapper.searchUsableModel(params));
}
public PageDataVO<UsableVehicleModelVO> hotModel(HotVeicleDTO dto){
dto.setHotSign(1);
Map<String, Object> params = BeanUtil.beanToMap(dto);
return PageDataVO.pageInfo(dto.getPage(), dto.getLimit(), () -> mapper.searchUsableModel(params));
}
private void initBookSearchParam(UsableVeicleDTO dto, Map<String, Object> params) {
List<String> notBookedDates = Lists.newArrayList(); List<String> notBookedDates = Lists.newArrayList();
if(StringUtils.isNotBlank(dto.getStartDate())&& if(StringUtils.isNotBlank(dto.getStartDate())&&
StringUtils.isNotBlank(dto.getEndDate())) { StringUtils.isNotBlank(dto.getEndDate())) {
...@@ -847,8 +861,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -847,8 +861,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月) //若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
if(CollectionUtils.isEmpty(notBookedDates)){ if(CollectionUtils.isEmpty(notBookedDates)){
//return; throw new BaseException(ResultCode.NOTEXIST_CODE);
} }
//筛选出查询条件所在月份 //筛选出查询条件所在月份
Set<String> allYearMonth = new HashSet<>();//记录所有年月 Set<String> allYearMonth = new HashSet<>();//记录所有年月
Map<String,List<String>> yearMonthAndDate = new HashMap<>();//预定年月 - 预定日期列表 Map<String,List<String>> yearMonthAndDate = new HashMap<>();//预定年月 - 预定日期列表
...@@ -857,13 +872,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> { ...@@ -857,13 +872,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> {
if(allYearMonth.size()>MAX_MONTH_COUNT_BOOKED_INFO_QUERY){ if(allYearMonth.size()>MAX_MONTH_COUNT_BOOKED_INFO_QUERY){
throw new CustomIllegalParamException(" only 3 month can be included <bookedInfo> param."); throw new CustomIllegalParamException(" only 3 month can be included <bookedInfo> param.");
} }
//加入预定信息查询条件 //加入预定信息查询条件
fillBookedDateSearchParam(params,yearMonthAndDate,yearMonthAndDateNotBooked); fillBookedDateSearchParam(params,yearMonthAndDate,yearMonthAndDateNotBooked);
PageHelper.startPage(dto.getPage(), dto.getLimit());
List<UsableVehicleModelVO> lists = mapper.searchUsableModel(params);
PageInfo<UsableVehicleModelVO> usableVehicleInfo = new PageInfo<>(lists);
return PageDataVO.pageInfo(usableVehicleInfo);
} }
public PageDataVO<Vehicle> searchUsableVehicle(RentVehicleBookDTO dto){ public PageDataVO<Vehicle> searchUsableVehicle(RentVehicleBookDTO dto){
......
...@@ -299,6 +299,19 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -299,6 +299,19 @@ public class VehicleController extends BaseController<VehicleBiz> {
return new ObjectRestResponse<>().data(vehicleBiz.searchUsableModel(dto)).rel(true); return new ObjectRestResponse<>().data(vehicleBiz.searchUsableModel(dto)).rel(true);
} }
/**
* 热门车型
*
* @param dto
* @return
*/
@ApiOperation("热门车型")
@RequestMapping(value = "/rent/hot-vehicle", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVehicleModelVO>> hotVehicle(HotVeicleDTO dto) throws Exception {
return ObjectRestResponse.succ(vehicleBiz.hotModel(dto));
}
/** /**
* 租车触发的申请预定车辆 * 租车触发的申请预定车辆
* *
...@@ -329,4 +342,5 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -329,4 +342,5 @@ public class VehicleController extends BaseController<VehicleBiz> {
return ObjectRestResponse.succ(bookVehicleVo.getVehicle()); return ObjectRestResponse.succ(bookVehicleVo.getVehicle());
} }
} }
...@@ -322,6 +322,9 @@ ...@@ -322,6 +322,9 @@
<if test=" addrCity != null "> <if test=" addrCity != null ">
and bc.addr_city = #{addrCity} and bc.addr_city = #{addrCity}
</if> </if>
<if test=" hotSign != null ">
and vm.hot_sign = #{hotSign}
</if>
</where> </where>
</sql> </sql>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment