Commit 85b7a5d6 authored by jiaorz's avatar jiaorz

预订时间处理bug

parent b5632461
......@@ -429,10 +429,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
//提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER);
DateTime startDay = DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
fillDateList4DatePeriod(yearMonthAndDate, startDay, endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
......@@ -469,8 +469,8 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
unbookVehicle(bookVehicleVo);
map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate(), bookVehicleVo.getNotCheckTimeLegal());
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
map = vehicleBookHourInfoBiz.getPredictableHours(startDay.toString(DATE_TIME_FORMATTER), endDay.toString(DATE_TIME_FORMATTER), bookVehicleVo.getNotCheckTimeLegal());
for(Map.Entry<String,List<String>> entry : yearMonthAndDate.entrySet()) {
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
......@@ -529,7 +529,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Integer andOperationFactor = andOpratorParam.get("andOperationFactor");
Integer andOperationRs = andOpratorParam.get("andOperationRs");
if(vehicleBookInfo != null && vehicleBookInfo.getBookedDate() != null &&
((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){//已经被预定
((vehicleBookInfo.getBookedDate() & andOperationFactor) != 0)){//已经被预定
//当天已经被预定检查小时是否也被预定
return filterHourInfoBooked(vehicleId, hourInfo);
}
......@@ -835,7 +835,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
* @param endDay
*/
private void fillDateList4DatePeriod(Map<String,List<String>> yearMonthAndDate,DateTime startDay,DateTime endDay){
for( DateTime curDate = startDay;curDate.compareTo(endDay)<=0;curDate=curDate.plusDays(1)){
for( DateTime curDate = startDay; curDate.compareTo(endDay) <= 0; curDate = curDate.plusDays(1)){
String curDateStr = curDate.toString(DEFAULT_DATE_TIME_FORMATTER);
if(curDateStr.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER))<0){
throw new BaseException(ResultCode.ONLY_BOOK_FROM_TODAY);
......@@ -853,15 +853,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
}
private void uinbookDateList4DatePeriod(Map<String,List<String>> yearMonthAndDate,DateTime startDay,DateTime endDay){
for( DateTime curDate = startDay;curDate.compareTo(endDay)<=0;curDate=curDate.plusDays(1)){
private void unbookDateList4DatePeriod(Map<String,List<String>> yearMonthAndDate,DateTime startDay,DateTime endDay){
for( DateTime curDate = startDay; curDate.compareTo(endDay) <= 0; curDate = curDate.plusDays(1)){
String curDateStr = curDate.toString(DEFAULT_DATE_TIME_FORMATTER);
// if(curDateStr.compareTo(DateTime.now().toString(DEFAULT_DATE_TIME_FORMATTER))<0){
// throw new BaseException("只可以取消当前时间之后的车辆");
// }
String curYearMonth = curDate.toString(YEARMONTH_DATE_TIME_FORMATTER);
if(!yearMonthAndDate.containsKey(curYearMonth)){
yearMonthAndDate.put(curYearMonth,Lists.newArrayList());
yearMonthAndDate.put(curYearMonth, Lists.newArrayList());
}
List<String> curBookedDateList = yearMonthAndDate.get(curYearMonth);
curBookedDateList.add(curDateStr);
......@@ -884,14 +885,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
DateTime startDay =DateTime.parse(bookVehicleVo.getUnbookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getUnbookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法
uinbookDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
unbookDateList4DatePeriod(yearMonthAndDate, DateTime.parse(bookVehicleVo.getUnbookStartDate(), DEFAULT_DATE_TIME_FORMATTER), DateTime.parse(bookVehicleVo.getUnbookEndDate(), DEFAULT_DATE_TIME_FORMATTER));
//原设计为 读取 bookVehicleVo.getNotCheckTimeLegal(), 现在取消/拒绝 true
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getUnbookStartDate(), bookVehicleVo.getUnbookEndDate(), Boolean.TRUE);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
if(yearMonthAndDate.size() > 3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_UNBOOK_TWO_MONTH);
}
Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
for(Map.Entry<String, List<String>> entry : yearMonthAndDate.entrySet()){
Boolean rsEach = unbookVehiclePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){
rs = Boolean.FALSE;
......
......@@ -204,15 +204,15 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
}
// public static void main(String[] args) throws Exception{
// VehicleBookHourInfoBiz vehicleBookHourInfoBiz = new VehicleBookHourInfoBiz();
// Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours("2019-08-26 10:00:00", "2019-08-27 10:00:00", Boolean.TRUE);
// for(Map.Entry<String, Integer> entry : map.entrySet()) {
// System.out.println(entry.getKey());
// System.out.println(entry.getValue());
// }
// Integer a = 7936 & 2047;
// System.out.println(a);
// }
public static void main(String[] args) throws Exception{
VehicleBookHourInfoBiz vehicleBookHourInfoBiz = new VehicleBookHourInfoBiz();
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours("2019-08-26 10:00:00", "2019-08-27 10:00:00", Boolean.TRUE);
for(Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}
Integer a = 215712192 & 33554432;
System.out.println(a);
}
}
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