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