Commit 326697dd authored by 周健威's avatar 周健威

调车相关

parent 87b2a9a1
package com.github.wxiaoqi.security.common.vo; package com.github.wxiaoqi.security.common.vo;
import com.github.wxiaoqi.security.common.util.Query;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -10,5 +11,7 @@ public class PageParam { ...@@ -10,5 +11,7 @@ public class PageParam {
@ApiModelProperty("每页限制") @ApiModelProperty("每页限制")
Integer limit; Integer limit;
public Query initQuery() {
return new Query(this);
}
} }
...@@ -158,4 +158,18 @@ public class ShuntApply implements Serializable { ...@@ -158,4 +158,18 @@ public class ShuntApply implements Serializable {
@ApiModelProperty(value = "超时时间戳", hidden = true ) @ApiModelProperty(value = "超时时间戳", hidden = true )
private Long overTime; private Long overTime;
/**
* 开始城市编码
*/
@Column(name = "start_city_code")
@ApiModelProperty(value = "开始城市编码")
private Integer startCityCode;
/**
* 结束城市编码
*/
@Column(name = "end_city_code")
@ApiModelProperty(value = "结束城市编码", hidden = true )
private Integer endCityCode;
} }
...@@ -51,7 +51,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp ...@@ -51,7 +51,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
@RequestMapping(value = "/addApply", method = RequestMethod.POST) @RequestMapping(value = "/addApply", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "申请列表") @ApiOperation(value = "添加申请")
public ObjectRestResponse addApply(@RequestBody ShuntApply shuntApply) { public ObjectRestResponse addApply(@RequestBody ShuntApply shuntApply) {
//查询列表数据 //查询列表数据
......
package com.xxfc.platform.order.rest.background; package com.xxfc.platform.order.rest.background;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.context.BaseContextHandler; import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.exception.BaseException; import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.OrderUtil; import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.github.wxiaoqi.security.common.vo.PageParam; import com.github.wxiaoqi.security.common.vo.PageParam;
...@@ -19,22 +20,29 @@ import com.xxfc.platform.order.entity.BaseOrder; ...@@ -19,22 +20,29 @@ import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.ShuntApply; import com.xxfc.platform.order.entity.ShuntApply;
import com.xxfc.platform.order.mqhandler.RabbitProduct; import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.order.RentVehicleBO; import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
import com.xxfc.platform.order.service.OrderRentVehicleService; import com.xxfc.platform.order.service.OrderRentVehicleService;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus; import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.VehicleModel;
import com.xxfc.platform.vehicle.feign.VehicleFeign; import com.xxfc.platform.vehicle.feign.VehicleFeign;
import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import org.jsoup.helper.DataUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CONFIRM; import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CONFIRM;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT; import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT;
@RestController @RestController
@RequestMapping("/background/shuntApply") @RequestMapping("/background/shuntApply")
public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> { public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> implements UserRestInterface {
@Autowired @Autowired
...@@ -55,10 +63,89 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA ...@@ -55,10 +63,89 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
@Autowired @Autowired
RabbitProduct rabbitProduct; RabbitProduct rabbitProduct;
@RequestMapping(value = "/confirmApply", method = RequestMethod.POST) @Override
public UserFeign getUserFeign() {
return this.userFeign;
}
@RequestMapping(value = "/steward/list", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据城市查询待确认申请列表")
public ObjectRestResponse<List<StewardShuntApply>> stewardList(ListDTO dto) {
//获取该城市的申请最大和最小时间
//获取该店铺
List<ShuntApply> list = baseBiz.selectByWeekend(w -> {
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);
returnList.add(stewardShuntApply);
}
});
}
}
}
return ObjectRestResponse.succ(returnList);
}
@RequestMapping(value = "/steward/confirmApply", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "后台确认申请") @ApiOperation(value = "后台确认申请")
public ObjectRestResponse confirmApply(@RequestBody confirmApplyDTO dto) { public ObjectRestResponse stewardConfirmApply(@RequestBody ConfirmApplyDTO dto) {
//查询列表数据 //查询列表数据
if (StrUtil.isBlank(getCurrentUserId())) { if (StrUtil.isBlank(getCurrentUserId())) {
...@@ -99,8 +186,18 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA ...@@ -99,8 +186,18 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
} }
@Data @Data
public static class confirmApplyDTO { public static class ConfirmApplyDTO {
Integer applyId; Integer applyId;
String vehicleId; String vehicleId;
} }
@Data
public static class ListDTO {
Integer cityCode;
}
@Data
public static class StewardShuntApply extends ShuntApply {
List<UsableVeicleVO> vehicles;
}
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO; ...@@ -13,6 +13,7 @@ import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo; import com.xxfc.platform.vehicle.pojo.vo.AccompanyingItemVo;
import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo; import com.xxfc.platform.vehicle.pojo.vo.BranComanyLeaderVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO; import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -243,4 +244,7 @@ public interface VehicleFeign { ...@@ -243,4 +244,7 @@ public interface VehicleFeign {
@RequestMapping(value = "/vehicleInfo/selectByCompanyIds", method = RequestMethod.GET) @RequestMapping(value = "/vehicleInfo/selectByCompanyIds", method = RequestMethod.GET)
public ObjectRestResponse<List<Vehicle>> vehicleSelectByCompanyIds(@RequestParam("companyIds") String companyIds); public ObjectRestResponse<List<Vehicle>> vehicleSelectByCompanyIds(@RequestParam("companyIds") String companyIds);
@RequestMapping(value = "/vehicleInfo/rent/apply/usable-vehicle", method = RequestMethod.POST)
public ObjectRestResponse<PageDataVO<UsableVeicleVO>> applyUsableVehicle(@RequestBody RentVehicleBookDTO rbd);
} }
...@@ -195,6 +195,47 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements ...@@ -195,6 +195,47 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
return ObjectRestResponse.succ(uvmvpdvs); return ObjectRestResponse.succ(uvmvpdvs);
} }
@ApiOperation("调车申请列表-可用车辆查询")
@RequestMapping(value = "/rent/apply/usable-vehicle", method = RequestMethod.POST)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVeicleVO>> applyUsableVehicle(@RequestBody RentVehicleBookDTO rbd) {
// rbd.setModelId(data.getVehicleModel().getId());
// rbd.setParkBranchCompanyId(dto.getStartCompanyId());
// rbd.setStartCompanyId(dto.getStartCompanyId());
// rbd.setEndCompanyId(dto.getEndCompanyId());
// rbd.setBookStartDate(dto.getStartDate());
// rbd.setBookEndDate(dto.getEndDate());
// rbd.setBookStartDateTime(dto.getStartDateTime());
// rbd.setBookEndDateTime(dto.getEndDateTime());
rbd.setRecordIntersection(Boolean.TRUE);
rbd.setLimit(100);
rbd.setPage(1);
rbd.setYearNo4Where(Boolean.TRUE);
//查询可车辆信息
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.parse(rbd.getBookStartDateTime()).isBeforeOrEquals(usableVeicleVO.getToLiftMustAfterDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
//如果"必须在这时间前预定" 存在 并且 比预定结束时间 要早,那么不允许预定
if(null != usableVeicleVO.getToReturnMustBeforeDate() && DateUtil.parse(rbd.getBookEndDateTime()).isAfterOrEquals(usableVeicleVO.getToReturnMustBeforeDate())) {
usableVeicleVO.setAllowRent(SYS_FALSE);
}
}
}
return ObjectRestResponse.succ(pageDataVO);
}
/** /**
* 后台查询可用车辆(车型) * 后台查询可用车辆(车型)
* *
......
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