Commit 1563642f authored by 周健威's avatar 周健威

Merge branch 'master-vehicle-price' into dev-tiande

parents f5c4bb84 d5850af5
......@@ -361,6 +361,30 @@ public class OrderRentVehicleDetail implements Serializable {
@ApiModelProperty(value = "原结束时间")
private Long metaEndTime;
@Column(name = "start_branch_id")
@ApiModelProperty(value = "出发隶属的企业id")
private Integer startBranchId;
@Column(name = "end_branch_id")
@ApiModelProperty(value = "结束隶属的企业id")
private Integer endBranchId;
@Column(name = "actual_end_branch_id")
@ApiModelProperty(value = "实际结束隶属的企业id")
private Integer actualEndBranchId;
@Column(name = "actual_end_company_id")
@ApiModelProperty(value = "实际结束公司id")
private Integer actualEndCompanyId;
@Column(name = "vehicle_branch_id")
@ApiModelProperty(value = "车辆隶属企业id")
private Integer vehicleBranchId;
@Column(name = "vehicle_company_id")
@ApiModelProperty(value = "车辆公司(门店)id")
private Integer vehicleCompanyId;
public Long getEndTime() {
return endTime;
}
......
......@@ -125,6 +125,10 @@ public class OrderRentVehicleService extends AbstractOrderHandle<OrderRentVehicl
}
}
}
//设置新增字段
//开始公司(门店)
// if(null != bo.getStartCompanyId())
}
public void initDictionary() {
......
......@@ -116,6 +116,14 @@ public class RentVehicleBookDTO extends PageParam {
@ApiModelProperty(hidden = true)
Integer useType = 1;
/**
* 是否根据预订记录(相交叉)查询
* 原(大于预约结束时间,小于预约开始时间的预约记录)
* 相交叉(大于预约开始时间,小于预约结束时间的预约记录)
*/
@ApiModelProperty(hidden = true)
Boolean recordIntersection;
public void setBookStartDate(String bookStartDate) {
this.bookStartDate = bookStartDate;
//首次设置
......
......@@ -2,10 +2,12 @@ package com.xxfc.platform.vehicle.pojo;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class UsableVehicleModelVO {
......@@ -22,4 +24,7 @@ public class UsableVehicleModelVO {
@ApiModelProperty(value = "是否有车")
Integer hasVehicle;
@ApiModelProperty(value = "可用车辆信息")
List<UsableVeicleVO> usableVeicleVOList;
}
\ No newline at end of file
......@@ -59,6 +59,25 @@ public class UsableVeicleDTO extends PageParam {
@ApiModelProperty(hidden = true)
Boolean yearNo4Where;
/**
* 是否根据预订记录(相交叉)查询
* 原(大于预约结束时间,小于预约开始时间的预约记录)
* 相交叉(大于预约开始时间,小于预约结束时间的预约记录)
*/
@ApiModelProperty(hidden = true)
Boolean recordIntersection;
/**
* 价格开始日期
*/
String priceStartDate;
/**
* 价格结束日期
*/
String priceEndDate;
// @ApiModelProperty(hidden = true)
// Integer withoutRecordWhere = 1;
......
package com.xxfc.platform.vehicle.pojo.vo;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import lombok.Data;
import javax.persistence.Column;
import java.util.Date;
import java.util.List;
@Data
public class UsableVeicleVO extends Vehicle {
@Column(name = "to_lift_company_id")
private Integer toLiftCompanyId;
@Column(name = "to_lift_must_after_date")
private Date toLiftMustAfterDate;
@Column(name = "to_return_company_id")
private Integer toReturnCompanyId;
@Column(name = "to_return_must_before_date")
private Date toReturnMustBeforeDate;
private Integer allowRent;
private List<VehicleModelCalendarPriceDTO> priceDTOS;
}
......@@ -32,6 +32,7 @@ import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.BeanUtilsBean;
......@@ -1250,7 +1251,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return params;
}
public PageDataVO<Vehicle> searchUsableVehicle(RentVehicleBookDTO dto) {
public PageDataVO<UsableVeicleVO> searchUsableVehicle(RentVehicleBookDTO dto) {
//设置-1表示查询所有的车 由于null json序列化不会赋值过来
if(-1 == dto.getUseType()) {
dto.setUseType(null);
......@@ -1288,8 +1289,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
fillBookedDateSearchParam(params, yearMonthAndDate, yearMonthAndDateNotBooked);
PageHelper.startPage(dto.getPage(), dto.getLimit());
List<Vehicle> lists = mapper.searchUsableVehicle(params);
PageInfo<Vehicle> usableVehicleInfo = new PageInfo<>(lists);
List<UsableVeicleVO> lists = mapper.searchUsableVehicle(params);
PageInfo<UsableVeicleVO> usableVehicleInfo = new PageInfo<>(lists);
return PageDataVO.pageInfo(usableVehicleInfo);
}
......
......@@ -162,6 +162,10 @@ public class VehicleHolidayPriceInfoBiz extends BaseBiz<VehicleHolidayPriceInfoM
setVehicleId(vehicleId);
}});
if(null == vehicleCommonPriceInfo) {
return CollUtil.newArrayList();
}
//Date currentDate = DateUtil.beginOfDay(DateUtil.parse(startDate));
for(cn.hutool.core.date.DateTime currentDate = DateUtil.beginOfDay(DateUtil.parse(startDate));
(currentDate.isAfterOrEquals(beginOfStartDate) && currentDate.isBeforeOrEquals(endOfStartDate));
......
......@@ -3,6 +3,7 @@ package com.xxfc.platform.vehicle.mapper;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;
import tk.mybatis.mapper.common.Mapper;
......@@ -37,7 +38,7 @@ public interface VehicleMapper extends Mapper<Vehicle> {
List<UsableVehicleModelVO> searchUsableModel(Map<String, Object> params);
List<Vehicle> searchUsableVehicle(Map<String, Object> params);
List<UsableVeicleVO> searchUsableVehicle(Map<String, Object> params);
List<VehicleCountVo> countVehicleByParam(VehiclePlanDto vehiclePlanDto);
......
......@@ -13,6 +13,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleHolidayPriceInfoBiz;
import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.RestResponse;
......@@ -23,6 +24,8 @@ import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import com.xxfc.platform.vehicle.pojo.vo.VehicleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
......@@ -58,6 +61,9 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
@Autowired
VehicleBiz vehicleBiz;
@Autowired
VehicleHolidayPriceInfoBiz vehicleHolidayPriceInfoBiz;
public UserFeign getUserFeign() {
return userFeign;
}
......@@ -125,11 +131,13 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
if (StringUtils.isNotBlank(dto.getCatasStr())) {
dto.setCatas(vehiclePlatCataBiz.groupCatasByParent(dto.getCatasStr()));
}
//设置显示是否有车
dto.setYearNo4Where(Boolean.TRUE);
//设置显示是否有车(通过把时间与位比较从where移动到select)
//dto.setYearNo4Where(Boolean.TRUE);
//匹配相交叉的预约记录
dto.setRecordIntersection(Boolean.TRUE);
PageDataVO<UsableVehicleModelVO> uvmvpdvs = vehicleBiz.searchUsableModel(dto);
// if(CollUtil.isNotEmpty(uvmvpdvs.getData())){
// uvmvpdvs.getData().forEach(data -> {
if(CollUtil.isNotEmpty(uvmvpdvs.getData())){
uvmvpdvs.getData().forEach(data -> {
// if(StrUtil.isNotBlank(data.getVehicleIds())) {
// String[] strs = StrUtil.split(data.getVehicleIds(), ",");
// List<Vehicle> vehicleList = vehicleBiz.selectByWeekend(w -> {
......@@ -140,8 +148,44 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
// baseBiz
// });
// }
// });
// }
RentVehicleBookDTO rbd = new RentVehicleBookDTO();
rbd.setModelId(data.getVehicleModel().getId());
rbd.setLimit(20);
rbd.setPage(1);
rbd.setParkBranchCompanyId(dto.getStartCompanyId());
rbd.setStartCompanyId(dto.getStartCompanyId());
rbd.setEndCompanyId(dto.getEndCompanyId());
rbd.setBookStartDate(dto.getStartDate());
rbd.setBookEndDate(dto.getEndDate());
rbd.setRecordIntersection(Boolean.TRUE);
rbd.setBookStartDateTime(dto.getStartDateTime());
rbd.setBookEndDateTime(dto.getEndDateTime());
//查询可车辆信息
PageDataVO<UsableVeicleVO> pageDataVO = vehicleBiz.searchUsableVehicle(rbd);
if(CollUtil.isNotEmpty(pageDataVO.getData())) {
for (UsableVeicleVO usableVeicleVO : pageDataVO.getData()) {
//判断是否预定时间内可租
usableVeicleVO.setAllowRent(SYS_TRUE);
//如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(dto.getStartDateTamp()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(dto.getEndDateTamp()).isBeforeOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
String priceStartDateStr = StrUtil.isNotBlank(dto.getPriceStartDate())? dto.getPriceStartDate(): dto.getStartDate();
String priceEndDateStr = StrUtil.isNotBlank(dto.getPriceEndDate())? dto.getPriceEndDate(): dto.getEndDate();
usableVeicleVO.setPriceDTOS(vehicleHolidayPriceInfoBiz.getSynthesizePrice(usableVeicleVO.getId(), priceStartDateStr, priceEndDateStr, null, usableVeicleVO.getSubordinateBranch()));
}
data.setUsableVeicleVOList(pageDataVO.getData());
}
});
}
return ObjectRestResponse.succ(uvmvpdvs);
}
......@@ -160,7 +204,7 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
if (StringUtils.isNotBlank(dto.getCatasStr())) {
dto.setCatas(vehiclePlatCataBiz.groupCatasByParent(dto.getCatasStr()));
}
//设置显示是否有车
//设置显示是否有车(通过把时间与位比较从where移动到select)
dto.setYearNo4Where(Boolean.TRUE);
//dto.setUseType(null);
return ObjectRestResponse.succ(vehicleBiz.searchUsableModelBackStage(dto));
......@@ -209,7 +253,7 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
dto.setStartCompanyId(dto.getLiftCompany());
dto.setEndCompanyId(dto.getEndCompanyId());
//查询可车辆信息
PageDataVO<Vehicle> pageDataVO = vehicleBiz.searchUsableVehicle(dto);
PageDataVO<UsableVeicleVO> pageDataVO = vehicleBiz.searchUsableVehicle(dto);
if (pageDataVO.getData().size() <= 0 && (dto.getMemberUse() == null || dto.getMemberUse().equals(VehicleMemberType.NO.getCode()))) {
throw new BaseException(ResultCode.NOTEXIST_CODE, new HashSet<String>(){{
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleHolidayPriceInfoBiz;
import com.xxfc.platform.vehicle.entity.VehicleHolidayPriceInfo;
......@@ -51,7 +52,7 @@ public class VehicleHolidayPriceInfoController extends BaseController<VehicleHol
@GetMapping(value = "multiCalendarPrice")
@IgnoreUserToken
public ObjectRestResponse<List<VehicleVO>> multiCalendarPrice(String vehicleIds, String startDate, String endDate, Integer companyId) {
public ObjectRestResponse<List<VehicleVO>> multiCalendarPrice(String startDate, String endDate, Integer companyId) {
Integer userId = Integer.valueOf(getCurrentUserId());
List<VehicleVO> vehicleVOS = CollUtil.newArrayList();
......
......@@ -158,6 +158,9 @@
</if>
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<if test=" yearMonthAndParam !=null ">
<!-- 包含 vbi:车辆预约信息 -->
<!-- vbi年月相等 或者 年月为空-->
<!-- booked_date 与换算 判断是否有重叠 日期-->
<foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation">
and
( (vbi.`year_month` = #{yearMonth} or vbi.`year_month` is null) and
......@@ -327,6 +330,9 @@
</if>
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<if test=" yearMonthAndParam !=null ">
<!-- 包含 vbi:车辆预约信息 -->
<!-- vbi年月相等 或者 年月为空-->
<!-- booked_date 与换算 判断是否有重叠 日期-->
<foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation">
and
( (vbi.`year_month` = #{yearMonth} or vbi.`year_month` is null) and
......@@ -470,6 +476,9 @@
</if>
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<if test=" yearMonthAndParam !=null ">
<!-- 包含 vbi:车辆预约信息 -->
<!-- vbi年月相等 或者 年月为空-->
<!-- booked_date 与换算 判断是否有重叠 日期-->
<foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation">
and
( (vbi.`year_month` = #{yearMonth} or vbi.`year_month` is null) and
......@@ -604,6 +613,9 @@
</if>
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
<if test=" yearMonthAndParam !=null ">
<!-- 包含 vbi:车辆预约信息 -->
<!-- vbi年月相等 或者 年月为空-->
<!-- booked_date 与换算 判断是否有重叠 日期-->
<foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation">
and
( (vbi.`year_month` = #{yearMonth} or vbi.`year_month` is null) and
......@@ -892,7 +904,8 @@
<select id="searchUsableModel" parameterType="java.util.Map"
resultMap="searchUsableModelMap">
(select distinct vm.id as model_id, bc.id as company_id, group_concat(v.id) as vehicle_ids
(select distinct vm.id as model_id, bc.id as company_id
<!-- , group_concat(v.id) as vehicle_ids -->
<if test=" catas != null ">
,GROUP_CONCAT(vc.cata_id) as catas
</if>
......@@ -975,7 +988,7 @@
</select>
<select id="searchUsableVehicle" parameterType="java.util.Map"
resultType="com.xxfc.platform.vehicle.entity.Vehicle">
resultType="com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO">
select v.*
<if test="lon != null and lat != null">
,st_distance_sphere(point(#{lon}, #{lat}), point(bc.longitude, bc.latitude)) as distance
......@@ -983,6 +996,13 @@
<!-- <if test=" yearMonthAndParam !=null ">-->
<!-- ,ifnull(vbi.booked_date,0) as booked_date-->
<!-- </if>-->
<if test="startCompanyId != null and endCompanyId != null and recordIntersection != null and recordIntersection == true">
<!-- 显示 配对 开始时间结束时间 -->
, abr.to_lift_company as to_lift_company_id
, abr.to_lift_must_after_date
, abr.to_return_company as to_return_company_id
, abr.to_return_must_before_date
</if>
<include refid="searchUsableSql"/>
<if test="memberUse != null and memberUse>0">
and (v.member_use = 1 or v.member_use = #{memberUse})
......@@ -994,6 +1014,7 @@
</select>
<!-- 查询可用车辆/车型 的公用 from 和 where 部分条件 -->
<!-- 包含 vbi: -->
<sql id="searchUsableSql">
from vehicle v
<if test=" yearMonthAndParam !=null ">
......@@ -1013,10 +1034,21 @@
left join vehicle_model vm on v.model_id = vm.id
left join branch_company bc on v.park_branch_company_id = bc.id
<if test="startCompanyId != null and endCompanyId != null ">
<!--
* 原(大于预约结束时间,小于预约开始时间的预约记录)
* 相交叉(大于预约开始时间,小于预约结束时间的预约记录)
-->
<if test="recordIntersection == null ">
left join (
<include refid="aroundBookRecord"></include>
) abr on v.`id` = abr.vehicle_id
</if>
<if test="recordIntersection != null and recordIntersection == true">
left join (
<include refid="aroundBookRecordIntersection"></include>
) abr on v.`id` = abr.vehicle_id
</if>
</if>
<if test=" catas != null ">
left join vehicle_cata vc on vm.id = vc.vehicle_model_id
</if>
......@@ -1031,7 +1063,7 @@
<if test="startCompanyId != null and endCompanyId != null ">
<if test="withoutRecordWhere == null">
and (
(abr.to_lift_company is null or abr.to_lift_company = #{startCompanyId})
(IFNULL(abr.to_lift_company, v.park_branch_company_id) = #{startCompanyId})
and
(abr.to_return_company is null or abr.to_return_company = #{endCompanyId})
)
......@@ -1060,6 +1092,9 @@
</sql>
<!-- 时间参数循环 -->
<!-- 包含 vbi:车辆预约信息 -->
<!-- vbi年月相等 或者 年月为空-->
<!-- booked_date 与换算 判断是否有重叠 日期-->
<sql id = "yearMonthAndParamSql">
<!-- 若需根据预定日期条件查询,针对换为位操作 -->
( (vbi.`year_month` = #{yearMonth} or vbi.`year_month` is null) and
......@@ -1069,23 +1104,51 @@
</sql>
<!-- 前后被预定的情况 -->
<!-- 大于预约结束时间,小于预约开始时间的预约记录) -->
<sql id = "aroundBookRecord">
select sevbr.*
, vbre.ret_company as to_lift_company
, sevbr.max_book_end_date as to_lift_must_after_date
, vbrs.lift_company as to_return_company
, sevbr.min_book_start_date as to_return_must_before_date
from
<!--
查询开始时间 前面的最后一条 预约记录
查询结束时间 后面的第一条 预约记录
添加比较actual_start_date 和 actual_end_date-->
<!-- sevbr表:车辆联表预约记录,统计获得预约开始时间前最大预约记录时间、、预约结束时间后最小预约记录时间,过滤掉status != 4 and status != 6,和 -->
(select vehicle_id
, max(if(IFNULL(actual_end_date, book_end_date) &lt; #{startDateExtend}, IFNULL(actual_end_date,book_end_date), null)) as max_book_end_date
, min(if(IFNULL(actual_start_date, book_start_date) &gt; #{endDateExtend}, IFNULL(actual_start_date, book_start_date), null)) as min_book_start_date
from vehicle_book_record where status != 4 and status != 6 group by vehicle_id) sevbr
left join vehicle_book_record vbre
on sevbr.vehicle_id = vbre.vehicle_id and sevbr.max_book_end_date = vbre.book_end_date and vbre.status != 4 and vbre.status != 6
on sevbr.vehicle_id = vbre.vehicle_id and sevbr.max_book_end_date = IFNULL(vbre.actual_end_date, vbre.book_end_date) and vbre.status != 4 and vbre.status != 6
left join vehicle_book_record vbrs
on sevbr.vehicle_id = vbrs.vehicle_id and sevbr.min_book_start_date = IFNULL(vbrs.actual_start_date, vbrs.book_start_date) and vbrs.status != 4 and vbrs.status != 6
</sql>
<!-- 前后被预定的情况(相交叉) -->
<!-- (大于预约开始时间,小于预约结束时间的预约记录) -->
<sql id = "aroundBookRecordIntersection">
select sevbr.*
, vbre.ret_company as to_lift_company
, sevbr.max_book_end_date as to_lift_must_after_date
, vbrs.lift_company as to_return_company
, sevbr.min_book_start_date as to_return_must_before_date
from
<!--
查询【结束】时间 前面的最后一条 预约记录
查询【开始】时间 后面的第一条 预约记录
添加比较actual_start_date 和 actual_end_date-->
<!-- sevbr表:车辆联表预约记录,统计获得预约开始时间前最大预约记录时间、、预约结束时间后最小预约记录时间,过滤掉status != 4 and status != 6,和 -->
(select vehicle_id
, max(if(IFNULL(actual_end_date, book_end_date) &lt; #{endDateExtend}, IFNULL(actual_end_date,book_end_date), null)) as max_book_end_date
, min(if(IFNULL(actual_start_date, book_start_date) &gt; #{startDateExtend}, IFNULL(actual_start_date, book_start_date), null)) as min_book_start_date
from vehicle_book_record where status != 4 and status != 6 group by vehicle_id) sevbr
left join vehicle_book_record vbre
on sevbr.vehicle_id = vbre.vehicle_id and sevbr.max_book_end_date = IFNULL(vbre.actual_end_date, vbre.book_end_date) and vbre.status != 4 and vbre.status != 6
left join vehicle_book_record vbrs
on sevbr.vehicle_id = vbrs.vehicle_id and sevbr.min_book_start_date = vbrs.book_start_date and vbrs.status != 4 and vbrs.status != 6
on sevbr.vehicle_id = vbrs.vehicle_id and sevbr.min_book_start_date = IFNULL(vbrs.actual_start_date, vbrs.book_start_date) and vbrs.status != 4 and vbrs.status != 6
</sql>
</mapper>
\ No newline at end of file
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