Commit c7a15132 authored by 周健威's avatar 周健威

添加申请调车

parent 9a80a78a
......@@ -9,7 +9,7 @@ import lombok.Data;
/**
* 调车申请
*
*
* @author libin
* @email 18178966185@163.com
* @date 2020-09-09 14:49:51
......@@ -25,117 +25,127 @@ public class ShuntApply implements Serializable {
public static final int STATUS_CONFIRM = 3;
public static final int STATUS_ORDER = 4;
public static final int STATUS_AUTOCNL = 5;
/**
* 主键
*/
@Id
public static final int STATUS_ERR = 6;
public static final int STATUS_SUCC = 7;
public static final int ORDER_STATUS_TOPAY = 1;
public static final int ORDER_STATUS_PAY = 2;
public static final int ORDER_STATUS_CANCEL = 3;
/**
* 主键
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键")
private Integer id;
/**
* 状态
0--删除
1--创建
2--取消
3--申请成功
*/
@Column(name = "status")
@ApiModelProperty(value = "状态 0--删除 1--创建 2--取消 3--申请成功 ")
private Integer status;
/**
* 创建时间
*/
@Column(name = "crt_time")
private Integer id;
/**
* 状态
0--删除
1--创建
2--取消
3--申请成功
*/
@Column(name = "status")
@ApiModelProperty(value = "状态 0--删除 1--创建 2--取消 3--接单中 4--已下单 5--接单成功 6--接单失败")
private Integer status;
@Column(name = "order_status")
@ApiModelProperty(value = "状态 1--待支付 2--已支付 3--已取消 ")
private Integer orderStatus;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Date crtTime;
/**
* 创建者id
*/
@Column(name = "crt_user")
private Date crtTime;
/**
* 创建者id
*/
@Column(name = "crt_user")
@ApiModelProperty(value = "创建者id")
private String crtUser;
/**
* 用户id
*/
@Column(name = "user_id")
private String crtUser;
/**
* 用户id
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户id")
private Integer userId;
/**
* 更新者id
*/
@Column(name = "upd_user")
private Integer userId;
/**
* 更新者id
*/
@Column(name = "upd_user")
@ApiModelProperty(value = "更新者id")
private String updUser;
/**
* 更新时间
*/
@Column(name = "upd_time")
private String updUser;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Date updTime;
/**
* 开始公司
*/
@Column(name = "start_company_id")
private Date updTime;
/**
* 开始公司
*/
@Column(name = "start_company_id")
@ApiModelProperty(value = "开始公司")
private Integer startCompanyId;
/**
* 结束公司
*/
@Column(name = "end_company_id")
private Integer startCompanyId;
/**
* 结束公司
*/
@Column(name = "end_company_id")
@ApiModelProperty(value = "结束公司")
private Integer endCompanyId;
/**
* 车型id
*/
@Column(name = "model_id")
private Integer endCompanyId;
/**
* 车型id
*/
@Column(name = "model_id")
@ApiModelProperty(value = "车型id")
private Integer modelId;
/**
* 车辆id
*/
@Column(name = "vehicle_id")
private Integer modelId;
/**
* 车辆id
*/
@Column(name = "vehicle_id")
@ApiModelProperty(value = "车辆id")
private String vehicleId;
/**
* 开始时间
*/
@Column(name = "start_time")
private String vehicleId;
/**
* 开始时间
*/
@Column(name = "start_time")
@ApiModelProperty(value = "开始时间")
private Long startTime;
/**
* 结束时间
*/
@Column(name = "end_time")
private Long startTime;
/**
* 结束时间
*/
@Column(name = "end_time")
@ApiModelProperty(value = "结束时间")
private Long endTime;
/**
* 订单id
*/
@Column(name = "order_id")
private Long endTime;
/**
* 订单id
*/
@Column(name = "order_id")
@ApiModelProperty(value = "订单id")
private Integer orderId;
/**
* 订单编号
*/
@Column(name = "order_no")
private Integer orderId;
/**
* 订单编号
*/
@Column(name = "order_no")
@ApiModelProperty(value = "订单编号")
private String orderNo;
private String orderNo;
/**
* 开始公司名称
......@@ -158,4 +168,41 @@ public class ShuntApply implements Serializable {
@ApiModelProperty(value = "超时时间戳", hidden = true )
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;
/**
* 确认申请的后台用户id
*/
@Column(name = "confirm_user_id")
@ApiModelProperty(value = "确认申请的后台用户id", hidden = true )
private Integer confirmUserId;
/**
* 确认申请的公司(门店)id
*/
@Column(name = "confirm_company_id")
@ApiModelProperty(value = "确认申请的公司(门店)id", hidden = true )
private Integer confirmCompanyId;
/**
* 预约记录id
*/
@Column(name = "book_record_id")
@ApiModelProperty(value = "预约记录id", hidden = true )
private Long bookRecordId;
}
......@@ -22,6 +22,12 @@ public class RentVehicleBO extends OrderRentVehicleDetail implements OrderDetail
private BaseOrder order;
private VehicleModel vehicleModel;
private BookVehicleVO bookVehicleVO;
/**
* 是否调车申请下订单
*/
private Integer applyOrderSign = 0;
/**
* 是否使用出租免费天数
*/
......
......@@ -5,6 +5,7 @@ import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFacto
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -23,44 +24,69 @@ public class RabbitDelayConfig {
public static final String ORDER_CANCEL_EXC = "order_cancel_delay_exchange";
public static final String ORDER_CANCEL_QUE = "order_cancel_delay_queue";
public static final String ORDER_CANCEL_KEY = "order_cancel_delay_key";
public static final String APPLY_CANCEL_EXC = "apply_cancel_delay_exchange";
public static final String APPLY_CANCEL_QUE = "apply_cancel_delay_queue";
public static final String APPLY_CANCEL_KEY = "apply_cancel_delay_key";
/**
* 延时队列交换机
* 注意这里的交换机类型:CustomExchange
* @return
*/
@Bean
public CustomExchange delayExchange(){
@Bean(ORDER_CANCEL_EXC)
public CustomExchange orderDelayExchange(){
Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "direct");
return new CustomExchange(ORDER_CANCEL_EXC,"x-delayed-message",true, false, args);
}
/**
* 延时队列交换机
* 注意这里的交换机类型:CustomExchange
* @return
*/
@Bean(APPLY_CANCEL_EXC)
public CustomExchange applyDelayExchange(){
Map<String, Object> args = new HashMap<>();
args.put("x-delayed-type", "direct");
return new CustomExchange(APPLY_CANCEL_EXC,"x-delayed-message",true, false, args);
}
/**
* 延时队列
* @return
*/
@Bean
@Bean(ORDER_CANCEL_QUE)
public Queue delayQueue(){
return new Queue(ORDER_CANCEL_QUE,true);
}
/**
/**
* 延时队列
* @return
*/
@Bean(APPLY_CANCEL_QUE)
public Queue applyDelayQueue(){
return new Queue(APPLY_CANCEL_QUE,true);
}
/**
* 给延时队列绑定交换机
* @return
*/
@Bean
public Binding cfgDelayBinding(Queue cfgDelayQueue, CustomExchange cfgUserDelayExchange){
@Bean("cfgDelayBinding")
public Binding cfgDelayBinding(@Qualifier(ORDER_CANCEL_QUE) Queue cfgDelayQueue, @Qualifier(ORDER_CANCEL_EXC) CustomExchange cfgUserDelayExchange){
return BindingBuilder.bind(cfgDelayQueue).to(cfgUserDelayExchange).with(ORDER_CANCEL_KEY).noargs();
}
// @Bean
// public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory){
// SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
// factory.setConnectionFactory(connectionFactory);
//// factory.setMessageConverter(new Jackson2JsonMessageConverter());
// factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
// return factory;
// }
/**
* 给延时队列绑定交换机
* @return
*/
@Bean("acqDelayBinding")
public Binding acqDelayBinding(@Qualifier(APPLY_CANCEL_QUE) Queue acqDelayQueue, @Qualifier(APPLY_CANCEL_EXC) CustomExchange acqUserDelayExchange){
return BindingBuilder.bind(acqDelayQueue).to(acqUserDelayExchange).with(APPLY_CANCEL_KEY).noargs();
}
}
package com.xxfc.platform.order.mqhandler;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.ShuntApply;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -8,8 +9,8 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import static com.xxfc.platform.order.config.RabbitDelayConfig.ORDER_CANCEL_EXC;
import static com.xxfc.platform.order.config.RabbitDelayConfig.ORDER_CANCEL_KEY;
import static com.xxfc.platform.order.config.RabbitDelayConfig.*;
import static com.xxfc.platform.order.config.RabbitDelayConfig.APPLY_CANCEL_KEY;
/**
* rabbitMq生产者类
......@@ -39,5 +40,23 @@ public class RabbitProduct {
);
log.info("{}ms后执行", delayTime);
}
public void sendApplyDelayMessage(ShuntApply shuntApply, Long delayTime) {
//这里的消息可以是任意对象,无需额外配置,直接传即可
log.info("===============延时队列生产消息====================");
log.info("发送时间:{},发送内容:{}", LocalDateTime.now(), shuntApply.toString());
this.rabbitTemplate.convertAndSend(
APPLY_CANCEL_EXC,
APPLY_CANCEL_KEY,
shuntApply,
message -> {
//注意这里时间可以使long,而且是设置header
message.getMessageProperties().setHeader("x-delay", delayTime);
return message;
}
);
log.info("{}ms后执行", delayTime);
}
}
......@@ -131,7 +131,7 @@ public class AppOrderController extends CommonBaseController implements UserRest
companyIds.clear();
companyIds.add(dto.getStartCompanyId());
} else {
return ObjectRestResponse.succ();
return ObjectRestResponse.succ(new PageDataVO<>());
}
} else {
companyIds.add(dto.getStartCompanyId());
......
......@@ -14,6 +14,7 @@ import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.ShuntApplyBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.ShuntApply;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.AddRentVehicleDTO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
......@@ -25,6 +26,7 @@ import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
import static com.github.wxiaoqi.security.common.vo.PageDataVO.pageInfo;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CNL;
import static com.xxfc.platform.order.entity.ShuntApply.STATUS_CRT;
......@@ -51,13 +53,19 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
@RequestMapping(value = "/addApply", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "申请列表")
@ApiOperation(value = "添加申请")
public ObjectRestResponse addApply(@RequestBody ShuntApply shuntApply) {
//查询列表数据
if (StrUtil.isBlank(getCurrentUserId())) {
throw new BaseException(ResultCode.AJAX_WECHAT_NOTEXIST_CODE);
}
if(null != shuntApply.getStartCompanyId()) {
shuntApply.setStartCityCode(vehicleFeign.getCompanyDetail(shuntApply.getStartCompanyId()).getData().getAddrCity());
}
if(null != shuntApply.getEndCompanyId()) {
shuntApply.setEndCityCode(vehicleFeign.getCompanyDetail(shuntApply.getEndCompanyId()).getData().getAddrCity());
}
shuntApply.setUserId(getCurrentUserIdInt());
shuntApply.setStatus(STATUS_CRT);
return add(shuntApply);
......@@ -125,6 +133,10 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
throw new BaseException(ResultCode.PARAM_ILLEGAL_CODE);
}
if(ShuntApply.STATUS_ORDER == shuntApply.getStatus()) {
throw new BaseException("该申请已下单", ResultCode.PARAM_ILLEGAL_CODE);
}
// BgAddRentDTO bgAddRentDTO = new BgAddRentDTO();
// bgAddRentDTO.setAppUserId(shuntApply.getUserId());
// bgAddRentDTO.setStartTime(shuntApply.getStartTime());
......@@ -147,9 +159,20 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
// setDayNum(orderCalculateBiz.getIncludeDays(shuntApply.getStartTime(), shuntApply.getEndTime()));
// }};
dto.setVehicleId(shuntApply.getVehicleId());
dto.setStartTime(shuntApply.getStartTime());
dto.setEndTime(shuntApply.getEndTime());
dto.setStartCompanyId(shuntApply.getStartCompanyId());
dto.setEndCompanyId(shuntApply.getEndCompanyId());
RentVehicleBO bo = orderRentVehicleBiz.initRentVehicleBO(dto);
bo.setApplyOrderSign(SYS_TRUE);
bo.setAppUserDTO(userFeign.userDetailByToken(BaseContextHandler.getToken()).getData());
orderRentVehicleService.applyCreateOrder(bo, shuntApply.getOrderNo());
baseBiz.updateSelectiveById(new ShuntApply(){{
setId(shuntApply.getId());
setStatus(ShuntApply.STATUS_ORDER);
setOrderStatus(ShuntApply.ORDER_STATUS_TOPAY);
}});
return ObjectRestResponse.succ(bo.getOrder());
}
......@@ -161,6 +184,7 @@ public class ShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApp
@Data
public static class ShuntApplyVO extends ShuntApply {
VehicleModel vehicleModel;
OrderPageVO orderPageVO;
}
@Data
......
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.util.StrUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
......@@ -11,28 +16,40 @@ import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.order.biz.BaseOrderBiz;
import com.xxfc.platform.order.biz.OrderRentVehicleBiz;
import com.xxfc.platform.order.biz.ShuntApplyBiz;
import com.xxfc.platform.order.biz.inner.OrderCalculateBiz;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.ShuntApply;
import com.xxfc.platform.order.mqhandler.RabbitProduct;
import com.xxfc.platform.order.pojo.order.OrderPageVO;
import com.xxfc.platform.order.pojo.order.RentVehicleBO;
import com.xxfc.platform.order.pojo.order.add.BgAddRentDTO;
import com.xxfc.platform.order.rest.ShuntApplyController;
import com.xxfc.platform.order.service.OrderRentVehicleService;
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.pojo.BookVehicleVO;
import com.xxfc.platform.vehicle.pojo.RentVehicleBookDTO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
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_CRT;
@RestController
@RequestMapping("/background/shuntApply")
public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> {
public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntApply> implements UserRestInterface {
@Autowired
......@@ -50,10 +67,42 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
@Autowired
OrderRentVehicleService orderRentVehicleService;
@RequestMapping(value = "/confirmApply", method = RequestMethod.POST)
@Autowired
RabbitProduct rabbitProduct;
@Autowired
BaseOrderBiz baseOrderBiz;
@Override
public UserFeign getUserFeign() {
return this.userFeign;
}
@RequestMapping(value = "/steward/list", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据城市查询待确认申请列表")
public ObjectRestResponse<PageDataVO<StewardShuntApply>> stewardList(ListDTO dto) {
//获取该城市的申请最大和最小时间
//获取该店铺
PageDataVO<StewardShuntApply> 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 "), StewardShuntApply.class);
list.getData().forEach(data -> {
data.setVehicleModel(vehicleFeign.get(data.getModelId()).getData());
});
return ObjectRestResponse.succ(list);
}
@RequestMapping(value = "/steward/confirmApply", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "后台确认申请")
public ObjectRestResponse confirmApply(@RequestBody confirmApplyDTO dto) {
public ObjectRestResponse stewardConfirmApply(@RequestBody ConfirmApplyDTO dto) {
//查询列表数据
if (StrUtil.isBlank(getCurrentUserId())) {
......@@ -72,27 +121,142 @@ public class BgShuntApplyController extends BaseController<ShuntApplyBiz, ShuntA
RentVehicleBO detail = new RentVehicleBO();
detail.setStartTime(shuntApply.getStartTime());
detail.setEndTime(shuntApply.getEndTime());
detail.setVehicleId(shuntApply.getVehicleId());
detail.setVehicleId(dto.getVehicleId());
detail.setModelId(shuntApply.getModelId());
detail.setStartAddr(shuntApply.getStartCompanyName());
detail.setStartCompanyId(shuntApply.getStartCompanyId());
detail.setEndCompanyId(shuntApply.getEndCompanyId());
detail.setOrder(new BaseOrder(){{setNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));}});
detail.setRentFreeDay(SYS_FALSE);
detail.setBookVehicleVO(new BookVehicleVO(){{
setBookStartDate(DateUtil.date(shuntApply.getStartTime()).toDateStr());
setBookEndDate(DateUtil.date(shuntApply.getEndTime()).toDateStr());
setBookStartDateTime(DateUtil.date(shuntApply.getStartTime()).toString());
setBookEndDateTime(DateUtil.date(shuntApply.getEndTime()).toString());
}});
//预约车辆
orderRentVehicleService.acquireVehicle(detail, null , VehicleBookRecordStatus.APPROVE.getCode());
orderRentVehicleService.acquireVehicle(detail, null , null);
shuntApply.setVehicleId(dto.getVehicleId());
shuntApply.setStatus(STATUS_CONFIRM);
shuntApply.setOrderNo(detail.getOrder().getNo());
baseBiz.updateSelectiveById(shuntApply);
shuntApply.setOverTime(DateUtil.offsetHour(DateUtil.date(), 1).getTime());
shuntApply.setConfirmUserId(getAdminUserInfo().getId());
shuntApply.setConfirmCompanyId(getAdminUserInfo().getCompanyId());
shuntApply.setBookRecordId(detail.getBookRecordId());
baseBiz.updateSelectiveByIdRe(shuntApply);
rabbitProduct.sendApplyDelayMessage(baseBiz.selectById(shuntApply.getId()), 1000L * 3601L);
return ObjectRestResponse.succ();
}
@RequestMapping(value = "/steward/applyDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "申请的详情")
public ObjectRestResponse stewardApplyDetail(Integer applyId) {
Integer companyId = getAdminUserInfo().getCompanyId();
ShuntApply shuntApply = baseBiz.selectById(applyId);
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()).toString());
rbd.setBookEndDateTime(DateUtil.date(shuntApply.getEndTime()).toString());
//查询本公司时间段内可用车辆
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);
}
@RequestMapping(value = "/steward/myApplyList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "我的申请")
public ObjectRestResponse myApplyList(PageDTO dto) {
UserDTO userDTO = getAdminUserInfo();
PageDataVO<ShuntApplyController.ShuntApplyVO> pages = PageDataVO.pageInfo(dto.initQuery(), () -> baseBiz.selectByWeekend(w -> {
w.andEqualTo(ShuntApply::getConfirmUserId, userDTO.getId());
if(StrUtil.isNotBlank(dto.getMultiStatus())) {
w.andIn(ShuntApply::getStatus, CollUtil.toList(dto.getMultiStatus().split(",")));
}
return w;
}), ShuntApplyController.ShuntApplyVO.class);
pages.getData().forEach(data -> {
data.setVehicleModel(vehicleFeign.get(data.getModelId()).getData());
if(StrUtil.isNotBlank(data.getOrderNo())) {
Map<String, Object> map = CollUtil.newHashMap();
map.put("no", data.getOrderNo());
List<OrderPageVO> list = baseOrderBiz.pageByParm(map);
if(CollUtil.isNotEmpty(list)) {
data.setOrderPageVO(list.get(0));
}
}
});
return ObjectRestResponse.succ(pages);
}
@Data
public static class confirmApplyDTO {
public static class ConfirmApplyDTO {
Integer applyId;
String vehicleId;
}
@Data
public static class ListDTO extends PageParam {
Integer cityCode;
}
@Data
public static class PageDTO extends PageParam {
String multiStatus;
}
@Data
public static class StewardShuntApply extends ShuntApply {
List<UsableVeicleVO> vehicles;
VehicleModel vehicleModel;
public VehicleModel getVehicleModel() {
return vehicleModel;
}
public void setVehicleModel(VehicleModel vehicleModel) {
this.vehicleModel = vehicleModel;
}
}
}
\ No newline at end of file
......@@ -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.BranComanyLeaderVo;
import com.xxfc.platform.vehicle.pojo.vo.BranchCompanyListVO;
import com.xxfc.platform.vehicle.pojo.vo.UsableVeicleVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
......@@ -246,4 +247,8 @@ public interface VehicleFeign {
@RequestMapping(value = "/vehicleInfo/selectByCompanyIds", method = RequestMethod.GET)
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);
}
package com.xxfc.platform.vehicle.rest;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.biz.*;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.jobhandler.VehicleJobHandler;
import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindAppDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehicleModelCalendarPriceDTO;
import com.xxfc.platform.vehicle.pojo.dto.VehiclePlanDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
@RestController
@RequestMapping("/chw/app/vehicle")
@Slf4j
@IgnoreClientToken
@Api(value="超惠玩车辆controller",tags={"超惠玩车辆接口"})
public class ChwAppVehicleController extends BaseController<VehicleBiz> implements UserRestInterface {
@Autowired
UserFeign userFeign;
@Autowired
VehicleBrandBiz vehicleBrandBiz;
@Autowired
VehicleCategoryBiz vehicleCategoryBiz;
@Override
public UserFeign getUserFeign() {
return userFeign;
}
@ApiOperation("vehicleBrand查询所有")
@RequestMapping(value = "/vehicleBrand/all",method = RequestMethod.GET)
@ResponseBody
@IgnoreUserToken
public List<VehicleBrand> all() {
return vehicleBrandBiz.selectListAll();
}
@ApiOperation("vehicleCategory查询分页")
@RequestMapping(value = "/vehicleCategory/page",method = RequestMethod.GET)
@ResponseBody
@IgnoreUserToken
public TableResultResponse<VehicleCategory> list(@RequestParam Map<String, Object> params){
//查询列表数据
Query query = new Query(params);
return vehicleCategoryBiz.selectPageByQuery(query);
}
}
......@@ -267,6 +267,39 @@ public class RentVehicleController extends BaseController<VehicleBiz> implements
return ObjectRestResponse.succ(pageDataVO);
}
@ApiOperation("调车申请列表-可用车辆查询")
@RequestMapping(value = "/rent/apply/usable-vehicle", method = RequestMethod.POST)
@IgnoreUserToken
public ObjectRestResponse<PageDataVO<UsableVeicleVO>> applyUsableVehicle(@RequestBody RentVehicleBookDTO rbd) {
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