Commit 54816dbc authored by jiaorz's avatar jiaorz

修改租車訂單地址,修改车辆预定时添加订单号

parent 5bbf3acc
......@@ -208,7 +208,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public RestResponse add(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception{
if(addOrUpdateVehicleVoList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("添加的车辆数量过多!");
throw new BaseException("添加的车辆数量过多!");
}
for(AddOrUpdateVehicleVo addOrUpdateVehicleVo:addOrUpdateVehicleVoList) {
......@@ -217,7 +217,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
if (addOrUpdateVehicleVo.getParkBranchCompanyId()==null) {
throw new CustomIllegalParamException("停靠公司不能为空");
throw new BaseException("停靠公司不能为空");
}
vehicle.setId(UUID.randomUUID().toString());
......@@ -251,7 +251,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
// }
if(addOrUpdateVehicleVo.getNumberPlate() == null){
throw new CustomIllegalParamException("车牌不能为空");
throw new BaseException("车牌不能为空");
}
List<Vehicle> vehicles = mapper.lockByCode(addOrUpdateVehicleVo);
return vehicles;
......@@ -265,14 +265,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional
public RestResponse update(List<AddOrUpdateVehicleVo> addOrUpdateVehicleVoList) throws Exception{
if(addOrUpdateVehicleVoList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("exceed max batch size");
throw new BaseException("exceed max batch size");
}
for(AddOrUpdateVehicleVo addOrUpdateVehicleVo:addOrUpdateVehicleVoList){
Vehicle vehicle = new Vehicle();
BeanUtilsBean.getInstance().copyProperties(vehicle, addOrUpdateVehicleVo);
if (addOrUpdateVehicleVo.getParkBranchCompanyId()==null) {
throw new CustomIllegalParamException("Stop at branch office cannot be empty");
throw new BaseException("Stop at branch office cannot be empty");
}
//悲观锁,检查是否已存在车牌或编码
......@@ -305,7 +305,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
*/
public RestResponse discard(List<String> idList){
if(idList.size()>MAX_BATCH_SIZE_VEHICLE){
throw new CustomIllegalParamException("exceed max batch size");
throw new BaseException("exceed max batch size");
}
Map<String,Object> params = Maps.newHashMap();
params.put("idList",idList);
......@@ -337,7 +337,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" you can only within 2 month");
throw new BaseException(" you can only within 2 month");
}
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
......@@ -419,7 +419,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(" 只可以预约两个月内的车辆");
}
//检查车辆是否可以预定
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -503,7 +503,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(" 只可以预约两个月内的车辆");
}
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey());
......@@ -599,10 +599,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(bookRecordId);
//申请记录验证
if(vehicleBookRecord == null){
throw new CustomIllegalParamException(" invalid book record");
throw new BaseException(" invalid book record");
}
if(!VehicleBookRecordStatus.APPLY.getCode().equals(vehicleBookRecord.getStatus())){
return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode());
if(VehicleBookRecordStatus.APPROVE.getCode().equals(vehicleBookRecord.getStatus())){
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getDesc(), ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode());
}
//转换为相应预定参数
BookVehicleVO bookVehicleVo = new BookVehicleVO();
......@@ -655,7 +655,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(bookRecordId);
//申请记录验证
if(vehicleBookRecord == null){
throw new CustomIllegalParamException(" invalid book record");
throw new BaseException(" invalid book record");
}
//已通过审核的可以取消预定
if(!VehicleBookRecordStatus.APPROVE.getCode().equals(vehicleBookRecord.getStatus())){
......@@ -743,7 +743,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(" 只可以预约两个月内的车辆");
}
Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -781,7 +781,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params.put("yearMonth",yearMonth);
//加入更新条件
if(CollectionUtils.isEmpty(bookedDates)){
throw new CustomIllegalParamException(" there are no day to book");
throw new BaseException(" there are no day to book");
}
Map<String,List<String>> yearMonthAndDate = new HashMap<>();
yearMonthAndDate.put(vehicleBookInfo.getYearMonth(),bookedDates);
......@@ -822,7 +822,26 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
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 CustomIllegalParamException("只可以取消当前时间之后的车辆");
throw new BaseException("只可以取消当前时间之后的车辆");
}
String curYearMonth = curDate.toString(YEARMONTH_DATE_TIME_FORMATTER);
if(!yearMonthAndDate.containsKey(curYearMonth)){
yearMonthAndDate.put(curYearMonth,Lists.newArrayList());
}
List<String> curBookedDateList = yearMonthAndDate.get(curYearMonth);
curBookedDateList.add(curDateStr);
}
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(" 只可以预约两个月内的车辆");
}
}
private void uinbookDateList4DatePeriod(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)){
......@@ -833,7 +852,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(" 只可以预约两个月内的车辆");
}
}
......@@ -849,10 +868,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
DateTime startDay =DateTime.parse(bookVehicleVo.getUnbookStartDate(), DEFAULT_DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getUnbookEndDate(), DEFAULT_DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法
fillDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
uinbookDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new CustomIllegalParamException(" 只可以预约两个月内的车辆");
throw new BaseException(" 只可以预约两个月内的车辆");
}
Boolean rs = Boolean.TRUE;
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
......@@ -873,7 +892,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
params.put("yearMonth",yearMonth);
//加入更新条件
if(CollectionUtils.isEmpty(unbookDates)){
throw new CustomIllegalParamException(" 车辆不可预定");
throw new BaseException(" 车辆不可预定");
}
Map<String,List<String>> yearMonthAndDate = new HashMap<>();
yearMonthAndDate.put(yearMonth,unbookDates);
......@@ -900,7 +919,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public void fillBookedDateSearchParam(Map<String, Object> params,
Map<String,List<String>> yearMonthAndDate,Map<String,List<String>> yearMonthAndDateNotBooked){
if(MapUtils.isEmpty(yearMonthAndDate)&&MapUtils.isEmpty(yearMonthAndDateNotBooked)){//没有预定信息查询条件
throw new CustomIllegalParamException("没有预订信息!");
throw new BaseException("没有预订信息!");
}
Map<String,Map<String,Integer>> yearMonthAndParam = new HashMap<>();
......@@ -945,7 +964,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
}
for (String dateStr:entry.getValue()) {//已预定作为条件,该位与1作与运算必定为1
if(bookedYearMonth.contains(dateStr)){
throw new CustomIllegalParamException("同一天既作为未预定查询条件又作为已预定查询条件");
throw new BaseException("同一天既作为未预定查询条件又作为已预定查询条件");
}
DateTime dateTime = DateTime.parse(dateStr, DEFAULT_DATE_TIME_FORMATTER);
//仅对应位为1的整形值
......@@ -1034,10 +1053,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,List<String>> yearMonthAndDateNotBooked = new HashMap<>();//未预定年月 - 未预定日期列表
classifyByYearMonth(notBookedDates,yearMonthAndDateNotBooked,allYearMonth);
if(allYearMonth.size()>0 && params.get("subordinateBranch") == null){
throw new CustomIllegalParamException(" <subordinateBranch> must included in params while using <bookedInfo> param. ");
throw new BaseException(" <subordinateBranch> must included in params while using <bookedInfo> param. ");
}
if(allYearMonth.size()>MAX_MONTH_COUNT_BOOKED_INFO_QUERY){
throw new CustomIllegalParamException(" only 3 month can be included <bookedInfo> param.");
throw new BaseException(" only 3 month can be included <bookedInfo> param.");
}
//加入预定信息查询条件
fillBookedDateSearchParam(params,yearMonthAndDate,yearMonthAndDateNotBooked);
......@@ -1133,7 +1152,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,List<String>> yearMonthAndDateNotBooked = new HashMap<>();//需比较未预定的年月 - 未预定日期列表 "2019-08-29"...."2019-09-04",
classifyByYearMonth(notBookedDates,yearMonthAndDateNotBooked,allYearMonth);
if(allYearMonth.size()>MAX_MONTH_COUNT_BOOKED_INFO_QUERY){
throw new CustomIllegalParamException(" only 3 month can be included <bookedInfo> param.");
throw new BaseException(" only 3 month can be included <bookedInfo> param.");
}
//加入预定信息查询条件
......@@ -1159,7 +1178,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,List<String>> yearMonthAndDateNotBooked = new HashMap<>();//未预定年月 - 未预定日期列表
classifyByYearMonth(notBookedDates,yearMonthAndDateNotBooked,allYearMonth);
if(allYearMonth.size()>MAX_MONTH_COUNT_BOOKED_INFO_QUERY){
throw new CustomIllegalParamException(" only 3 month can be included <bookedInfo> param.");
throw new BaseException(" only 3 month can be included <bookedInfo> param.");
}
//加入预定信息查询条件
fillBookedDateSearchParam(params,yearMonthAndDate,yearMonthAndDateNotBooked);
......
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