Commit 7de4f6a2 authored by 周健威's avatar 周健威

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

parents ec83214a da3f7d61
......@@ -75,76 +75,79 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
@RequestMapping(value = "/steward/list", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据城市查询待确认申请列表")
public ObjectRestResponse<List<StewardShuntApply>> stewardList(ListDTO dto) {
public ObjectRestResponse<PageDataVO<StewardShuntApply>> stewardList(ListDTO dto) {
//获取该城市的申请最大和最小时间
//获取该店铺
List<ShuntApply> list = baseBiz.selectByWeekend(w -> {
PageDataVO<ShuntApply> list = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
if(null != dto.getCityCode()) {
w.andEqualTo(ShuntApply::getStartCityCode, dto.getCityCode());
}
w.andEqualTo(ShuntApply::getStatus, STATUS_CRT);
return w;
}, " crt_time desc ");
List<StewardShuntApply> returnList = CollUtil.newArrayList();
Integer companyId = getAdminUserInfo().getCompanyId();
if(CollUtil.isNotEmpty(list)) {
//group by 车型
//List<Integer> modelList = list.parallelStream().map(ShuntApply::getModelId).distinct().collect(Collectors.toList());
//.collect(Collectors.groupingBy(ShuntApply::getModelId));
Map<Integer, List<ShuntApply>> modelMap = list.parallelStream().collect(Collectors.groupingBy(ShuntApply::getModelId));
Long startTime = list.parallelStream().map(ShuntApply::getStartTime).min(Long::compareTo).get();
Long endTime = list.parallelStream().map(ShuntApply::getEndTime).max(Long::compareTo).get();
for (Integer modelId : modelMap.keySet()) {
RentVehicleBookDTO rbd = new RentVehicleBookDTO();
rbd.setModelId(modelId);
rbd.setParkBranchCompanyId(companyId);
rbd.setStartCompanyId(companyId);
rbd.setEndCompanyId(companyId);
rbd.setBookStartDate(DateUtil.date(startTime).toDateStr());
rbd.setBookEndDate(DateUtil.date(endTime).toDateStr());
rbd.setBookStartDateTime(DateUtil.date(startTime).toTimeStr());
rbd.setBookEndDateTime(DateUtil.date(endTime).toTimeStr());
//查询本公司时间段内可用车辆
ObjectRestResponse<PageDataVO<UsableVeicleVO>> usableVehiclePage = vehicleFeign.applyUsableVehicle(rbd);
if(CollUtil.isNotEmpty(usableVehiclePage.getData().getData())) {
modelMap.get(modelId).forEach( shuntApply -> {
List<UsableVeicleVO> vehicles = CollUtil.newArrayList();
usableVehiclePage.getData().getData().forEach(usableVeicleVO -> {
//判断是否预定时间内可租
usableVeicleVO.setAllowRent(SYS_TRUE);
//如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(shuntApply.getStartTime()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(shuntApply.getEndTime()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
if(SYS_TRUE.equals(usableVeicleVO.getAllowRent())) {
vehicles.add(BeanUtil.toBean(usableVeicleVO, UsableVeicleVO.class));
}
});
if(CollUtil.isNotEmpty(vehicles)) {
StewardShuntApply stewardShuntApply = BeanUtil.toBean(shuntApply, StewardShuntApply.class);
stewardShuntApply.setVehicles(vehicles);
stewardShuntApply.setVehicleModel(vehicleFeign.get(modelId).getData());
returnList.add(stewardShuntApply);
}
});
}
}
}
return ObjectRestResponse.succ(returnList);
}, " crt_time desc "), StewardShuntApply.class);
// List<StewardShuntApply> returnList = CollUtil.newArrayList();
//
// Integer companyId = getAdminUserInfo().getCompanyId();
//
// if(CollUtil.isNotEmpty(list)) {
// //group by 车型
// //List<Integer> modelList = list.parallelStream().map(ShuntApply::getModelId).distinct().collect(Collectors.toList());
// //.collect(Collectors.groupingBy(ShuntApply::getModelId));
// Map<Integer, List<ShuntApply>> modelMap = list.parallelStream().collect(Collectors.groupingBy(ShuntApply::getModelId));
//
// Long startTime = list.parallelStream().map(ShuntApply::getStartTime).min(Long::compareTo).get();
// Long endTime = list.parallelStream().map(ShuntApply::getEndTime).max(Long::compareTo).get();
//
// for (Integer modelId : modelMap.keySet()) {
// RentVehicleBookDTO rbd = new RentVehicleBookDTO();
// rbd.setModelId(modelId);
// rbd.setParkBranchCompanyId(companyId);
// rbd.setStartCompanyId(companyId);
// rbd.setEndCompanyId(companyId);
// rbd.setBookStartDate(DateUtil.date(startTime).toDateStr());
// rbd.setBookEndDate(DateUtil.date(endTime).toDateStr());
// rbd.setBookStartDateTime(DateUtil.date(startTime).toTimeStr());
// rbd.setBookEndDateTime(DateUtil.date(endTime).toTimeStr());
// //查询本公司时间段内可用车辆
// ObjectRestResponse<PageDataVO<UsableVeicleVO>> usableVehiclePage = vehicleFeign.applyUsableVehicle(rbd);
//
// if(CollUtil.isNotEmpty(usableVehiclePage.getData().getData())) {
// modelMap.get(modelId).forEach( shuntApply -> {
// List<UsableVeicleVO> vehicles = CollUtil.newArrayList();
//
// usableVehiclePage.getData().getData().forEach(usableVeicleVO -> {
// //判断是否预定时间内可租
// usableVeicleVO.setAllowRent(SYS_TRUE);
// //如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
// if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(shuntApply.getStartTime()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
// usableVeicleVO.setAllowRent(SYS_FALSE);
// }
//
// //如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
// if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(shuntApply.getEndTime()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
// usableVeicleVO.setAllowRent(SYS_FALSE);
// }
// if(SYS_TRUE.equals(usableVeicleVO.getAllowRent())) {
// vehicles.add(BeanUtil.toBean(usableVeicleVO, UsableVeicleVO.class));
// }
// });
//
// if(CollUtil.isNotEmpty(vehicles)) {
// StewardShuntApply stewardShuntApply = BeanUtil.toBean(shuntApply, StewardShuntApply.class);
// stewardShuntApply.setVehicles(vehicles);
// stewardShuntApply.setVehicleModel(vehicleFeign.get(modelId).getData());
// returnList.add(stewardShuntApply);
// }
//
// });
// }
//
// }
//
//
// }
return ObjectRestResponse.succ(list);
}
@RequestMapping(value = "/steward/confirmApply", method = RequestMethod.POST)
......@@ -194,9 +197,46 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
@ResponseBody
@ApiOperation(value = "申请的详情")
public ObjectRestResponse stewardApplyDetail(Integer applyId) {
Integer companyId = getAdminUserInfo().getCompanyId();
ShuntApply shuntApply = baseBiz.selectById(applyId);
ShuntApplyController.ShuntApplyVO shuntApplyVO = BeanUtil.toBean(shuntApply, ShuntApplyController.ShuntApplyVO.class);
StewardShuntApply shuntApplyVO = BeanUtil.toBean(shuntApply, StewardShuntApply.class);
shuntApplyVO.setVehicleModel(vehicleFeign.get(shuntApply.getModelId()).getData());
RentVehicleBookDTO rbd = new RentVehicleBookDTO();
rbd.setModelId(shuntApply.getModelId());
rbd.setParkBranchCompanyId(companyId);
rbd.setStartCompanyId(companyId);
rbd.setEndCompanyId(companyId);
rbd.setBookStartDate(DateUtil.date(shuntApply.getStartTime()).toDateStr());
rbd.setBookEndDate(DateUtil.date(shuntApply.getEndTime()).toDateStr());
rbd.setBookStartDateTime(DateUtil.date(shuntApply.getStartTime()).toTimeStr());
rbd.setBookEndDateTime(DateUtil.date(shuntApply.getEndTime()).toTimeStr());
//查询本公司时间段内可用车辆
ObjectRestResponse<PageDataVO<UsableVeicleVO>> usableVehiclePage = vehicleFeign.applyUsableVehicle(rbd);
if(CollUtil.isNotEmpty(usableVehiclePage.getData().getData())) {
List<UsableVeicleVO> vehicles = CollUtil.newArrayList();
usableVehiclePage.getData().getData().forEach(usableVeicleVO -> {
//判断是否预定时间内可租
usableVeicleVO.setAllowRent(SYS_TRUE);
//如果"必须在这时间后预定" 存在 并且 比预定开始时间 要晚,那么不允许预定
if(null != usableVeicleVO.getToLiftMustAfterDate() && DateUtil.date(shuntApply.getStartTime()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.date(shuntApply.getEndTime()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
if(SYS_TRUE.equals(usableVeicleVO.getAllowRent())) {
vehicles.add(BeanUtil.toBean(usableVeicleVO, UsableVeicleVO.class));
}
});
if(CollUtil.isNotEmpty(vehicles)) {
shuntApplyVO.setVehicles(vehicles);
}
}
return ObjectRestResponse.succ(shuntApplyVO);
}
......@@ -229,7 +269,7 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
}
@Data
public static class ListDTO {
public static class ListDTO extends PageParam {
Integer cityCode;
}
......
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