Commit 08c48da6 authored by jiaorz's avatar jiaorz

添加还车取消当天预定限制

parent 2f8fb67a
...@@ -9,6 +9,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode; ...@@ -9,6 +9,7 @@ import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.entity.*; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.mapper.*; import com.xxfc.platform.vehicle.mapper.*;
import com.xxfc.platform.vehicle.pojo.*; import com.xxfc.platform.vehicle.pojo.*;
import com.xxfc.platform.vehicle.util.DateUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
...@@ -198,14 +199,6 @@ public class VehicleActiveService { ...@@ -198,14 +199,6 @@ public class VehicleActiveService {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getDesc(),
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
} }
// if (StringUtils.isBlank(arrivalVo.getRecycleMan()) || StringUtils.isBlank(arrivalVo.getRecycleManTel())) {
// throw new BaseException(ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getDesc(),
// ResCode.CHECKUSER_AND_PHONE_NOT_NULL.getCode());
// }
// if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// }
Integer MileageRest = vehicle.getMileageLastUpdate(); Integer MileageRest = vehicle.getMileageLastUpdate();
Integer MileageRest1 = arrivalVo.getMileage(); Integer MileageRest1 = arrivalVo.getMileage();
if (MileageRest1 == null) { if (MileageRest1 == null) {
...@@ -217,6 +210,9 @@ public class VehicleActiveService { ...@@ -217,6 +210,9 @@ public class VehicleActiveService {
if (arrivalVo.getBookRecordId() != null) { if (arrivalVo.getBookRecordId() != null) {
vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId()); vehicleBookRecord = vehicleBookRecordBiz.selectById(arrivalVo.getBookRecordId());
updateBookRecordStatus(vehicleBookRecord, 2); updateBookRecordStatus(vehicleBookRecord, 2);
} else {
throw new BaseException(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc(),
ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode());
} }
// 写入车辆公里数,还车分公司id // 写入车辆公里数,还车分公司id
vehicle.setMileageLastUpdate(MileageRest1); vehicle.setMileageLastUpdate(MileageRest1);
...@@ -239,12 +235,15 @@ public class VehicleActiveService { ...@@ -239,12 +235,15 @@ public class VehicleActiveService {
} }
if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态 if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态
vehicle.setStatus(VehicleStatus.NORMAL.getCode()); vehicle.setStatus(VehicleStatus.NORMAL.getCode());
// if (result == 0) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// }
} }
vehicleMapper.updateByPrimaryKeySelective(vehicle); vehicleMapper.updateByPrimaryKeySelective(vehicle);
//添加收车成功,后面有当天预定的记录时,取消当天的预定
Map<String, Object> map = new HashMap<>();
map.put("startTime", DateUtils.getStartOfDay());
map.put("endTime", DateUtils.getEndOfDay());
map.put("status", 1);
map.put("vehicleId", vehicleBookRecord.getVehicleId());
vehicleBookRecordBiz.selectAllBookRecord(map);
DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate()); DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate());
DateTime actualArrivalDate = new DateTime(new Date()); DateTime actualArrivalDate = new DateTime(new Date());
//提前还车处理 //提前还车处理
...@@ -295,23 +294,6 @@ public class VehicleActiveService { ...@@ -295,23 +294,6 @@ public class VehicleActiveService {
activeLog.setEndTime(new Date()); activeLog.setEndTime(new Date());
activeLog.setUpdateTime(new Date()); activeLog.setUpdateTime(new Date());
vehicleActiveLogMapper.updateByPrimaryKeySelective(activeLog); vehicleActiveLogMapper.updateByPrimaryKeySelective(activeLog);
//取消预定时间 bookInfo和bookRecord
// BookVehicleVO bookVehicleVo = new BookVehicleVO();
// BeanUtils.copyProperties(vehicleBookRecord, bookVehicleVo);
// bookVehicleVo.setNotCheckTimeLegal(Boolean.TRUE);
// bookVehicleVo.setBookStartDate(null);
// bookVehicleVo.setBookEndDate(null);
// bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER));
// bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
// try {
// Boolean hasSuc = vehicleBiz.unbookVehicle(bookVehicleVo);
// if(!hasSuc){
// throw new BaseException(ResCode.VEHICLE_UNBOOK_FAIL.getDesc(), ResCode.VEHICLE_UNBOOK_FAIL.getCode());
// }
// } catch ( Exception e) {
// log.error(e.getMessage(), e);;
// }
} else { } else {
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(), throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getDesc(),
ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode()); ResCode.VEHICLE_BOOKED_RECORD_MILEAGE_CHANGED.getCode());
......
...@@ -491,12 +491,17 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -491,12 +491,17 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
} }
public ObjectRestResponse<List<VehicleBookRecordVo>> selectAllBookRecord(Map<String, Object> param) {
return ObjectRestResponse.succ(mapper.selectAllBookRecord(param));
}
public ObjectRestResponse<List<VehicleBookRecordVo>> selectAllBookRecord(Date startTime, Date endTime, Integer status) { public ObjectRestResponse<List<VehicleBookRecordVo>> selectAllBookRecord(Date startTime, Date endTime, Integer status) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("startTime", startTime); map.put("startTime", startTime);
map.put("endTime", endTime); map.put("endTime", endTime);
map.put("status", status); map.put("status", status);
return ObjectRestResponse.succ(mapper.selectAllBookRecord(map)); return selectAllBookRecord(map);
} }
/** /**
......
package com.xxfc.platform.vehicle.util; package com.xxfc.platform.vehicle.util;
import org.joda.time.DateTime;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Date; import java.util.Date;
...@@ -19,4 +21,43 @@ public class DateUtils { ...@@ -19,4 +21,43 @@ public class DateUtils {
public static Date localDateToDate(LocalDate localDate) { public static Date localDateToDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
/**
* 获取当天的开始时间
* @return
*/
public static long getStartOfDay() {
return getStartOfDay(new Date());
}
/**
* 获取某天的开始时间
* @param date
* @return
*/
public static long getStartOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime startOfDay = dateTime.withTimeAtStartOfDay();
return startOfDay.getMillis();
}
/**
* 获取当天的结束时间
* @return
*/
public static long getEndOfDay() {
return getEndOfDay(new Date());
}
/**
* 获取某天的结束时间
* @param date
* @return
*/
public static long getEndOfDay(Date date) {
DateTime dateTime = new DateTime(date);
DateTime endOfDay = dateTime.millisOfDay().withMaximumValue();
return endOfDay.getMillis();
}
} }
...@@ -554,8 +554,13 @@ ...@@ -554,8 +554,13 @@
<if test="startTime != null and status == 2"> <if test="startTime != null and status == 2">
and v1.book_end_date between #{startTime} and #{endTime} and v1.book_end_date between #{startTime} and #{endTime}
</if> </if>
<if test="vehicleId != null and vehicleId != ''">
and v1.vehicle_id = #{vehicleId}
</if>
</select> </select>
<!--获取所有已取消的预定记录--> <!--获取所有已取消的预定记录-->
<select id="selectAllCancelBookRecord" resultMap="searchBookRecord" parameterType="Map"> <select id="selectAllCancelBookRecord" resultMap="searchBookRecord" parameterType="Map">
select v1.* from vehicle_book_record v1 select v1.* from vehicle_book_record v1
......
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