Commit a89fb725 authored by libin's avatar libin

Merge remote-tracking branch 'origin/dev' into dev

parents e2008d2c 0e1f8e85
......@@ -214,7 +214,7 @@ BOOKED_FAILED_CODE = 4007
4007=车辆预定失败,请重试!
ONLY_BOOK_FROM_TODAY = 4008
4008=预定时间不能小于当前时间
4008=取消或预定时间不能小于当前时间
ADD_VEHICLE_FAIL = 4009
4009 = 添加车辆失败,请重试
......
......@@ -181,6 +181,24 @@ public class BackStageOrderController extends CommonBaseController implements Us
dto.setEndTime(new Date().getTime());
}
}
UserDTO userDTO = getAdminUserInfo();
if (userDTO == null) {
return ObjectRestResponse.succ(new PageDataVO<>());
}
List<BranchCompany> branchCompanies = vehicleFeign.companyAll(userDTO.getDataAll(), userDTO.getDataCompany(), userDTO.getDataZone());
List<Integer> companyIds = branchCompanies.stream().map(BranchCompany::getId).collect(Collectors.toList());
if(dto.getStartCompanyId() != null) {
if(companyIds.size() > 0) {
if(companyIds.contains(dto.getStartCompanyId())) {
companyIds.clear();
companyIds.add(dto.getStartCompanyId());
} else {
return ObjectRestResponse.succ();
}
} else {
companyIds.add(dto.getStartCompanyId());
}
}
Query query = new Query(dto);
PageDataVO<OrderPageVO> pageDataVO = PageDataVO.pageInfo(query, () -> baseOrderBiz.getRentVehicle(query.getSuper()));
for (OrderPageVO orderPageVO : pageDataVO.getData()) {
......
......@@ -192,8 +192,12 @@
<if test="startTime != null and (status == 5 || status == 6 || status == -1)">
and r.end_time between #{startTime} and #{endTime}
</if>
<if test="startCompanyId != null">
and r.start_company_id = #{startCompanyId}
<if test="companyIds != null and companyIds.size > 0">
and r.start_company_id in
<foreach collection="companyIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="status == 4">
order by r.start_time
......
......@@ -603,14 +603,15 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
*/
@Transactional
public RestResponse<Integer> reviewVehicleBooking(Integer operatorId, Long bookRecordId,Integer rsStatus,String userName) throws Exception{
try {
//获取相关申请记录
VehicleBookRecord vehicleBookRecord = vehicleBookRecordBiz.selectById(bookRecordId);
//申请记录验证
if(vehicleBookRecord == null){
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc());
}
if(!VehicleBookRecordStatus.APPLY.getCode().equals(vehicleBookRecord.getStatus())){
return RestResponse.code(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode());
if(VehicleBookRecordStatus.APPROVE.getCode().equals(vehicleBookRecord.getStatus())){
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getCode(), ResCode.VEHICLE_BOOKED_RECORD_ALREADY_CHANGED.getDesc());
}
//转换为相应预定参数
BookVehicleVO bookVehicleVo = new BookVehicleVO();
......@@ -649,9 +650,16 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
bookVehicleVo.setUnbookStartDate(bookVehicleVo.getBookStartDate());
bookVehicleVo.setUnbookEndDate(bookVehicleVo.getBookEndDate());
Boolean hasSuc = unbookVehicle(bookVehicleVo);
}
if(hasSuc) {
return RestResponse.suc();
}
}
} catch (Exception e) {
e.printStackTrace();
return RestResponse.codeAndMessage(1325, e.getMessage());
}
return RestResponse.codeAndMessage(1325, "取消预定失败");
}
/**
* 取消预定
......@@ -840,6 +848,25 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
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)){
yearMonthAndDate.put(curYearMonth,Lists.newArrayList());
}
List<String> curBookedDateList = yearMonthAndDate.get(curYearMonth);
curBookedDateList.add(curDateStr);
}
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
}
......@@ -850,14 +877,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
* @return
*/
@Transactional
public Boolean unbookVehicle(BookVehicleVO bookVehicleVo){
public Boolean unbookVehicle(BookVehicleVO bookVehicleVo) throws Exception{
//提取日期参数,改为每月一份
//提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
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 BaseException(ResultCode.ONLY_UNBOOK_TWO_MONTH);
......@@ -1142,7 +1169,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.");
}
//加入预定信息查询条件
......@@ -1168,7 +1195,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);
......
......@@ -272,7 +272,7 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
if(params.get("selectedMonth") != null) {
String selectedMonth = (String)params.get("selectedMonth");
if(StringUtils.isBlank(selectedMonth)){
throw new BaseException("no month selected ");
throw new BaseException(" no month selected ");
}
DateTime selectedMonthDate = DateTime.parse(selectedMonth,YEARMONTH_DATE_TIME_FORMATTER);
if(selectedMonthDate.compareTo(DateTime.now().plusMonths(-1).withDayOfMonth(1).withMillisOfDay(0)) < 0){
......
......@@ -9,16 +9,12 @@ import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.common.VehicleBaseController;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;
import com.xxfc.platform.vehicle.pojo.*;
import lombok.Data;
import com.xxfc.platform.vehicle.pojo.Cascade;
import com.xxfc.platform.vehicle.pojo.CataVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import sun.java2d.pipe.AATextRenderer;
import java.util.Arrays;
@RestController
@RequestMapping("/cata")
......@@ -225,7 +221,7 @@ public class VehicleCataController extends VehicleBaseController<VehiclePlatCata
return RestResponse.data(baseBiz.getByPage(vehiclePageQueryVo));
} catch (JSONException ex) {
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
} catch (CustomIllegalParamException ex) {
} catch (BaseException ex) {
return RestResponse.code(ResCode.INVALID_REST_REQ_PARAM.getCode());
}
}*/
......
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