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

Merge branch 'base-modify' into dev

parents 0720af48 67920f16
...@@ -41,6 +41,7 @@ import org.springframework.stereotype.Service; ...@@ -41,6 +41,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
...@@ -169,7 +170,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -169,7 +170,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds())); ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds()));
} }
List<AppUserVo> list = userFeign.getByUserIds(ids).getData(); List<AppUserVo> list = userFeign.getByUserIds(ids).getData();
orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? null : list); orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? new ArrayList<>() : list);
} }
//设置保留金 //设置保留金
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
...@@ -259,7 +260,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> { ...@@ -259,7 +260,7 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> {
ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds())); ids.add(Integer.parseInt(orderPageVo.getOrderTourDetail().getTourUserIds()));
} }
List<AppUserVo> list = userFeign.getByUserIds(ids).getData(); List<AppUserVo> list = userFeign.getByUserIds(ids).getData();
orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? null : list); orderPageVo.getOrderTourDetail().setUserVoList(list == null || list.size() <= 0 ? new ArrayList<>() : list);
} }
//设置保留金 //设置保留金
Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData(); Map<String, Dictionary> dictionaryMap = thirdFeign.dictionaryGetAll4Map().getData();
......
...@@ -29,6 +29,7 @@ public enum ResCode { ...@@ -29,6 +29,7 @@ public enum ResCode {
VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE(104003,"车辆未出车"), VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE(104003,"车辆未出车"),
VEHICLE_BOOK_RECORD_IS_NOT_EXIST(104004, "预约记录不存在"), VEHICLE_BOOK_RECORD_IS_NOT_EXIST(104004, "预约记录不存在"),
VEHICLE_UNBOOK_FAIL(104005, "取消预定失败!"),
BRANCH_COMPANY_UNEXIST(105001, "分公司信息不存在"), BRANCH_COMPANY_UNEXIST(105001, "分公司信息不存在"),
BRANCH_COMPANY_STOCK_EXISTED(105002, "分公司股权信息已存在"), BRANCH_COMPANY_STOCK_EXISTED(105002, "分公司股权信息已存在"),
......
...@@ -103,4 +103,9 @@ public class BookVehicleVO { ...@@ -103,4 +103,9 @@ public class BookVehicleVO {
private String upkeepIds; private String upkeepIds;
private String orderNo; private String orderNo;
/**
* 订单状态
*/
private Integer status;
} }
\ No newline at end of file
...@@ -14,9 +14,6 @@ public class CompanyDetail extends BranchCompany { ...@@ -14,9 +14,6 @@ public class CompanyDetail extends BranchCompany {
StringBuilder detailAddrStr = new StringBuilder(""); StringBuilder detailAddrStr = new StringBuilder("");
if(null != this.getSysRegions() && this.getSysRegions().size() > 0) { if(null != this.getSysRegions() && this.getSysRegions().size() > 0) {
for(SysRegion sysRegion : this.getSysRegions()) { for(SysRegion sysRegion : this.getSysRegions()) {
// if(0 != detailAddrStr.length()) {
//
// }
String name = sysRegion.getName() String name = sysRegion.getName()
.replace("省", "") .replace("省", "")
.replace("市", "") .replace("市", "")
...@@ -27,7 +24,9 @@ public class CompanyDetail extends BranchCompany { ...@@ -27,7 +24,9 @@ public class CompanyDetail extends BranchCompany {
} }
} }
} }
if(this.getAddrDetail().contains(detailAddrStr)) {
return this.getAddrDetail();
}
detailAddrStr.append(this.getAddrDetail()); detailAddrStr.append(this.getAddrDetail());
return detailAddrStr.toString(); return detailAddrStr.toString();
} }
......
...@@ -29,4 +29,6 @@ public class QueryVehicleWarningMsgVo { ...@@ -29,4 +29,6 @@ public class QueryVehicleWarningMsgVo {
private Integer page; private Integer page;
private Integer limit; private Integer limit;
private Integer colorType;
} }
...@@ -56,7 +56,7 @@ public class VehicleActiveService { ...@@ -56,7 +56,7 @@ public class VehicleActiveService {
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
} }
if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) { if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
} }
Integer MileageLift=vehicle.getMileageLastUpdate(); Integer MileageLift=vehicle.getMileageLastUpdate();
...@@ -75,8 +75,8 @@ public class VehicleActiveService { ...@@ -75,8 +75,8 @@ public class VehicleActiveService {
int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(), int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(),
VehicleStatus.NORMAL.getCode()); VehicleStatus.NORMAL.getCode());
if (result == 0) { if (!vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_DISABLE.getCode());
} }
//修改预约记录状态 //修改预约记录状态
...@@ -117,10 +117,35 @@ public class VehicleActiveService { ...@@ -117,10 +117,35 @@ public class VehicleActiveService {
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());
} }
}
public String getVehicleStatus(Integer status, String vehicleId) {
StringBuilder stringBuilder = new StringBuilder();
switch (status) {
case 1:
stringBuilder.append("正常运行");
break;
case 2:
stringBuilder.append("维修");
break;
case 3:
stringBuilder.append("报废");
break;
case 4:
stringBuilder.append("出车");
break;
case 5:
stringBuilder.append("保养");
break;
}
List<VehicleBookRecordVo> vehicleBookRecordVos = vehicleBookRecordBiz.selectByVehicleId(vehicleId);
if(vehicleBookRecordVos != null && vehicleBookRecordVos.size() > 0) {
stringBuilder.append("中,使用人:");
stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUsername());
stringBuilder.append(" 使用人电话:");
stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUserPhone());
}
return stringBuilder.toString();
} }
@Transactional @Transactional
...@@ -131,7 +156,7 @@ public class VehicleActiveService { ...@@ -131,7 +156,7 @@ public class VehicleActiveService {
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNEXIST.getCode());
} }
if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) { if (!vehicle.getStatus().equals(VehicleStatus.DEPARTURE.getCode())) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc() + ", 车辆状态是:" + getVehicleStatus(vehicle.getStatus(), vehicle.getId()),
ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode()); ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
} }
Integer Mileagerest = vehicle.getMileageLastUpdate(); Integer Mileagerest = vehicle.getMileageLastUpdate();
......
...@@ -24,10 +24,7 @@ import com.xxfc.platform.vehicle.constant.RedisKey; ...@@ -24,10 +24,7 @@ import com.xxfc.platform.vehicle.constant.RedisKey;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus; import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.constant.VehicleStatus; import com.xxfc.platform.vehicle.constant.VehicleStatus;
import com.xxfc.platform.vehicle.entity.BranchCompany; import com.xxfc.platform.vehicle.entity.*;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleBookInfo;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper; import com.xxfc.platform.vehicle.mapper.BookRecordAccItemMapper;
import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper; import com.xxfc.platform.vehicle.mapper.VehicleBookInfoMapper;
import com.xxfc.platform.vehicle.mapper.VehicleMapper; import com.xxfc.platform.vehicle.mapper.VehicleMapper;
...@@ -343,8 +340,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -343,8 +340,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月 if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH); throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
} }
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
//检查车辆是否可以预定
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){ for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey()); Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){ if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED); throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
} }
...@@ -429,9 +428,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -429,9 +428,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月 if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH); throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
} }
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
//检查车辆是否可以预定 //检查车辆是否可以预定
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){ for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey()); Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){ if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED); throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
} }
...@@ -457,7 +457,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -457,7 +457,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
// //添加预定时间记录 // //添加预定时间记录
VehicleBookRecord newValue = vehicleBookRecordBiz.selectOne(vehicleBookRecord); VehicleBookRecord newValue = vehicleBookRecordBiz.selectOne(vehicleBookRecord);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
for(Map.Entry<String, Integer> entry : map.entrySet()) { for(Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto(); VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId()); vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId());
...@@ -506,15 +505,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -506,15 +505,14 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(),DATE_TIME_FORMATTER); DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(),DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), 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个月 if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH); throw new BaseException(ResultCode.ONLY_BOOK_TWO_MONTH);
} }
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){ for(Map.Entry<String,List<String>> entry:yearMonthAndDate.entrySet()){
Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey()); Boolean rsEach = applyVehicle4EmployeePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){ if(Boolean.FALSE.equals(rsEach)){
throw new BaseException(ResultCode.VEHICLE_IS_BOOKED); throw new BaseException(ResultCode.VEHICLE_IS_BOOKED);
} }
...@@ -527,7 +525,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -527,7 +525,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true)); BeanUtil.copyProperties(bookVehicleVo, vehicleBookRecord, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
vehicleBookRecord.setBookStartDate(startDay.toDate()); vehicleBookRecord.setBookStartDate(startDay.toDate());
vehicleBookRecord.setBookEndDate(endDay.toDate()); vehicleBookRecord.setBookEndDate(endDay.toDate());
vehicleBookRecord.setStatus(VehicleBookRecordStatus.APPROVE.getCode()); vehicleBookRecord.setStatus(bookVehicleVo.getStatus());
vehicleBookRecord.setBookUser(userId); vehicleBookRecord.setBookUser(userId);
vehicleBookRecord.setBookUserName(userName); vehicleBookRecord.setBookUserName(userName);
vehicleBookRecordBiz.save(vehicleBookRecord); vehicleBookRecordBiz.save(vehicleBookRecord);
...@@ -539,14 +537,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -539,14 +537,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
} }
// //添加预定时间记录 // //添加预定时间记录
VehicleBookRecord newValue = vehicleBookRecordBiz.selectOne(vehicleBookRecord);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getBookStartDate(), bookVehicleVo.getBookEndDate());
for(Map.Entry<String, Integer> entry : map.entrySet()) { for(Map.Entry<String, Integer> entry : map.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto(); VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId()); vehicleBookHourInfoDto.setVehicleId(bookVehicleVo.getVehicleId());
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey()); vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setBookedHour(entry.getValue()); vehicleBookHourInfoDto.setBookedHour(entry.getValue());
vehicleBookHourInfoDto.setBookRecordId(newValue.getId());
vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto); vehicleBookHourInfoBiz.save(vehicleBookHourInfoDto);
} }
...@@ -574,7 +569,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -574,7 +569,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
@Transactional @Transactional
public Boolean applyVehicle4EmployeePerMonth(String vehicleId, List<String> bookedDates, String yearMonth){ public Boolean applyVehicle4EmployeePerMonth(String vehicleId, List<String> bookedDates, String yearMonth, Map<String, Integer> hourInfo){
//检查车辆是否有空档 //检查车辆是否有空档
//获得当月预定记录 //获得当月预定记录
VehicleBookInfo vehicleBookInfo = getByVehicleIdAndYearMonth(vehicleId,yearMonth); VehicleBookInfo vehicleBookInfo = getByVehicleIdAndYearMonth(vehicleId,yearMonth);
...@@ -587,14 +582,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -587,14 +582,31 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Map<String,Integer> andOpratorParam = yearMonthAndParam.get(yearMonth); Map<String,Integer> andOpratorParam = yearMonthAndParam.get(yearMonth);
Integer andOperationFactor = andOpratorParam.get("andOperationFactor"); Integer andOperationFactor = andOpratorParam.get("andOperationFactor");
Integer andOperationRs = andOpratorParam.get("andOperationRs"); Integer andOperationRs = andOpratorParam.get("andOperationRs");
if(vehicleBookInfo!=null&&vehicleBookInfo.getBookedDate()!=null && if(vehicleBookInfo != null && vehicleBookInfo.getBookedDate() != null &&
((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){ ((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){
return Boolean.FALSE; //当天已经被预定检查小时是否也被预定
return filterHourInfoBooked(vehicleId, hourInfo);
} }
return Boolean.TRUE; return Boolean.TRUE;
} }
public boolean filterHourInfoBooked(String vehicleId, Map<String, Integer> hourInfo) {
for(Map.Entry<String, Integer> entry : hourInfo.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setVehicleId(vehicleId);
List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto);
if(vehicleBookHourInfos != null && vehicleBookHourInfos.size() >0) {
if((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) == entry.getValue()) { // 已经被预定
log.info(entry.getKey() + "预定的时间段已经被预约!");
return Boolean.FALSE;
}
}
}
return Boolean.TRUE;
}
/** /**
* 批准预定车辆预定 * 批准预定车辆预定
* @param operatorId * @param operatorId
...@@ -616,24 +628,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -616,24 +628,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//转换为相应预定参数 //转换为相应预定参数
BookVehicleVO bookVehicleVo = new BookVehicleVO(); BookVehicleVO bookVehicleVo = new BookVehicleVO();
BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord); BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord);
bookVehicleVo.setBookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setBookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER));
bookVehicleVo.setBookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setBookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
// //审核通过的话,需要修改相关车辆预定记录
// if(VehicleBookRecordStatus.APPROVE.getCode().equals(rsStatus)) {
// Boolean hasSuc = bookedVehicle(bookVehicleVo);
// if(!hasSuc){
// return RestResponse.code(ResCode.VEHICLE_BOOKED_INFO_ALREADY_CHANGED.getCode());
// }
// }
// //如果拒绝预定,删除预定时间记录
// if(VehicleBookRecordStatus.APPLY.getCode().equals(vehicleBookRecord.getStatus())) {
// //删除预定时间记录
// List<String> list = null;
// for( DateTime curDate = new DateTime(vehicleBookRecord.getBookStartDate());curDate.compareTo(new DateTime(vehicleBookRecord.getBookEndDate()))<=0;curDate=curDate.plusDays(1)) {
// list.add(curDate.toString(DEFAULT_DATE_TIME_FORMATTER));
// }
// vehicleBookHourInfoBiz.delete(vehicleBookRecord.getVehicleId(),list);
// }
//成功后修改预定记录状态 //成功后修改预定记录状态
Map<String,Object> updateParam = Maps.newHashMap(); Map<String,Object> updateParam = Maps.newHashMap();
updateParam.put("id",bookRecordId); updateParam.put("id",bookRecordId);
...@@ -682,12 +679,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -682,12 +679,12 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord); BeanUtils.copyProperties(bookVehicleVo,vehicleBookRecord);
bookVehicleVo.setBookStartDate(null); bookVehicleVo.setBookStartDate(null);
bookVehicleVo.setBookEndDate(null); bookVehicleVo.setBookEndDate(null);
bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DEFAULT_DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
//取消预定 //取消预定
Boolean hasSuc = unbookVehicle(bookVehicleVo); Boolean hasSuc = unbookVehicle(bookVehicleVo);
if(!hasSuc){ if(!hasSuc){
return RestResponse.codeAndMessage(ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getCode(), ResCode.VEHICLE_BOOK_RECORD_IS_NOT_EXIST.getDesc()); return RestResponse.codeAndMessage(ResCode.VEHICLE_UNBOOK_FAIL.getCode(), ResCode.VEHICLE_UNBOOK_FAIL.getDesc());
} }
//修改预定状态,写入取消人 //修改预定状态,写入取消人
Map<String,Object> updateParam = Maps.newHashMap(); Map<String,Object> updateParam = Maps.newHashMap();
...@@ -753,7 +750,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -753,7 +750,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public Boolean bookedVehicle( BookVehicleVO bookVehicleVo) throws Exception{ public Boolean bookedVehicle( BookVehicleVO bookVehicleVo) throws Exception{
//提取日期和相应的预定目标日期 //提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER); DateTime startDay =DateTime.parse(bookVehicleVo.getBookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER); DateTime endDay =DateTime.parse(bookVehicleVo.getBookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法 //转换日期范围为列表,并检查是否合法
...@@ -785,11 +781,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -785,11 +781,18 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
vehicleBookInfo.setVehicle(vehicleId); vehicleBookInfo.setVehicle(vehicleId);
vehicleBookInfo.setYearMonth(yearMonth); vehicleBookInfo.setYearMonth(yearMonth);
//检查是否存在相关车辆 //检查是否存在相关车辆
Vehicle param = new Vehicle();
param.setId(vehicleId);
checkIfVehicleExists(vehicleId); checkIfVehicleExists(vehicleId);
Integer orRsOperationFactor = getBitOpratorFactor4Booked(bookedDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果 Integer orRsOperationFactor = getBitOpratorFactor4Booked(bookedDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
vehicleBookInfo.setBookedDate(orRsOperationFactor); vehicleBookInfo.setBookedDate(orRsOperationFactor);
Map<String,Object> map = new HashMap<>();
map.put("vehicle", vehicleId);
map.put("yearMonth", yearMonth);
List<VehicleBookInfo> vehicleBookInfos = vehicleBookInfoMapper.getByVehicleIdAndYearMonth(map);
if(vehicleBookInfos != null && vehicleBookInfos.size() > 0) {
if((vehicleBookInfos.get(0).getBookedDate() & orRsOperationFactor) == orRsOperationFactor) {
return Boolean.TRUE;
}
}
Integer effected = vehicleBookInfoMapper.insertIgnore(vehicleBookInfo); Integer effected = vehicleBookInfoMapper.insertIgnore(vehicleBookInfo);
if(effected == 0){//已存在则需要更新 if(effected == 0){//已存在则需要更新
Map<String,Object> params = Maps.newHashMap(); Map<String,Object> params = Maps.newHashMap();
...@@ -881,17 +884,17 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -881,17 +884,17 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
//提取日期参数,改为每月一份 //提取日期参数,改为每月一份
//提取日期和相应的预定目标日期 //提取日期和相应的预定目标日期
Map<String,List<String>> yearMonthAndDate = Maps.newHashMap(); Map<String,List<String>> yearMonthAndDate = Maps.newHashMap();
DateTime startDay =DateTime.parse(bookVehicleVo.getUnbookStartDate(), DEFAULT_DATE_TIME_FORMATTER); DateTime startDay =DateTime.parse(bookVehicleVo.getUnbookStartDate(), DATE_TIME_FORMATTER);
DateTime endDay =DateTime.parse(bookVehicleVo.getUnbookEndDate(), DEFAULT_DATE_TIME_FORMATTER); DateTime endDay =DateTime.parse(bookVehicleVo.getUnbookEndDate(), DATE_TIME_FORMATTER);
//转换日期范围为列表,并检查是否合法 //转换日期范围为列表,并检查是否合法
uinbookDateList4DatePeriod(yearMonthAndDate,startDay,endDay); uinbookDateList4DatePeriod(yearMonthAndDate,startDay,endDay);
Map<String, Integer> map = vehicleBookHourInfoBiz.getPredictableHours(bookVehicleVo.getUnbookStartDate(), bookVehicleVo.getUnbookEndDate());
if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月 if(yearMonthAndDate.size()>3){//连续的日期最多夸3个月
throw new BaseException(ResultCode.ONLY_UNBOOK_TWO_MONTH); throw new BaseException(ResultCode.ONLY_UNBOOK_TWO_MONTH);
} }
Boolean rs = Boolean.TRUE; 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()); Boolean rsEach = unbookVehiclePerMonth(bookVehicleVo.getVehicleId(),entry.getValue(),entry.getKey(), map);
if(Boolean.FALSE.equals(rsEach)){ if(Boolean.FALSE.equals(rsEach)){
rs = Boolean.FALSE; rs = Boolean.FALSE;
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//手动回滚 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//手动回滚
...@@ -900,8 +903,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -900,8 +903,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return rs; return rs;
} }
@Transactional @Transactional
public Boolean unbookVehiclePerMonth(String vehicleId, List<String> unbookDates, String yearMonth){ public Boolean unbookVehiclePerMonth(String vehicleId, List<String> unbookDates, String yearMonth, Map<String, Integer> hourInfo){
checkIfVehicleExists(vehicleId); checkIfVehicleExists(vehicleId);
Map<String,Object> params = Maps.newHashMap(); Map<String,Object> params = Maps.newHashMap();
params.put("vehicleId",vehicleId); params.put("vehicleId",vehicleId);
...@@ -921,10 +925,34 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -921,10 +925,34 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Integer andRsOperationFactor = getBitOpratorFactor4UnBooked(unbookDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果 Integer andRsOperationFactor = getBitOpratorFactor4UnBooked(unbookDates);//预定的相关或运算因子,当前月份没有预定记录时同时也是结果
params.put("andRsOperationFactor", params.put("andRsOperationFactor",
andRsOperationFactor); andRsOperationFactor);
Integer effected = vehicleBookInfoMapper.updateBookedInfo(params); if(hourInfo.size() == 1) { //取消当天的小时,不取消当天的预定
return effected>0?Boolean.TRUE:Boolean.FALSE; return unbookHourInfo(vehicleId, hourInfo);
} else {
Integer effected = vehicleBookInfoMapper.updateBookedInfo(params);
return unbookHourInfo(vehicleId, hourInfo);
}
} }
public boolean unbookHourInfo(String vehicleId, Map<String, Integer> hourInfo) {
for (Map.Entry<String, Integer> entry : hourInfo.entrySet()) {
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setVehicleId(vehicleId);
List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto);
if (vehicleBookHourInfos != null && vehicleBookHourInfos.size() > 0) {
vehicleBookHourInfos.get(0).setBookedHour((vehicleBookHourInfos.get(0).getBookedHour() & ~entry.getValue()));
int effect = vehicleBookHourInfoBiz.updateByIdRe(vehicleBookHourInfos.get(0));
if (effect < 1) {
return Boolean.FALSE;
} else {
continue;
}
} else {
return Boolean.FALSE;
}
}
return Boolean.TRUE;
}
/** /**
* 获取某月份相应预定日期查询条件 * 获取某月份相应预定日期查询条件
......
...@@ -31,7 +31,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -31,7 +31,7 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd"); public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
public static Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate) { public Map<String, Integer> getPredictableHours(String bookStartDate, String bookEndDate) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = null; Date startDate = null;
Date endDate = null; Date endDate = null;
...@@ -68,12 +68,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -68,12 +68,14 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
endPredictableHour |= 1 << (curentHour); endPredictableHour |= 1 << (curentHour);
} }
} }
if(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour); predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour);
predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour); } else {
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour);
predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour);
}
DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER); DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER); DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
if(endDay.getDayOfMonth() - startDay.getDayOfMonth() >1){ // if(endDay.getDayOfMonth() - startDay.getDayOfMonth() >1){ //
for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) { for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) {
String curDateStr = curDate.toString(DATE_TIME_FORMATTER); String curDateStr = curDate.toString(DATE_TIME_FORMATTER);
...@@ -143,18 +145,9 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -143,18 +145,9 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
} }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception{
String result = Integer.toBinaryString(16777200); int b = 16744448;
String newString = new StringBuilder(result).reverse().toString(); Integer a = b | 31;
int i=newString.length()-result.replace("1", "").length(); System.out.println(a);
System.out.println(i);
Map<String, Integer> map = getPredictableHours("2019-07-28 00:00:00","2019-07-29 00:00:00");
for (Map.Entry<String, Integer> entry : map.entrySet()) {
log.info(entry.getKey());
log.info(entry.getValue() + "");
}
} }
} }
...@@ -299,7 +299,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -299,7 +299,9 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return PageDataVO.pageInfo(vehiclePageInfo); return PageDataVO.pageInfo(vehiclePageInfo);
} }
public List<VehicleBookRecordVo> selectByVehicleId(String vehicleId) {
return mapper.selectByVehicleId(vehicleId);
}
/** /**
......
...@@ -30,7 +30,7 @@ public interface VehicleBookRecordMapper extends Mapper<VehicleBookRecord> { ...@@ -30,7 +30,7 @@ public interface VehicleBookRecordMapper extends Mapper<VehicleBookRecord> {
public List<VehicleRecordInfoVo> getByParam(Map<String, Object> params); public List<VehicleRecordInfoVo> getByParam(Map<String, Object> params);
public List<VehicleBookRecord> getByVehicleId(String vehicleId); public List<VehicleBookRecordVo> selectByVehicleId(String vehicleId);
public List<VehicleBookRecordVo> getBookRecord(VehicleBookRecordQueryVo vehicleBookRecordQueryVo); public List<VehicleBookRecordVo> getBookRecord(VehicleBookRecordQueryVo vehicleBookRecordQueryVo);
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.github.wxiaoqi.security.admin.feign.UserFeign; import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO; 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.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig; import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
...@@ -13,17 +14,16 @@ import com.github.wxiaoqi.security.common.exception.BaseException; ...@@ -13,17 +14,16 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.xxfc.platform.vehicle.biz.VehicleBiz; import com.xxfc.platform.vehicle.biz.*;
import com.xxfc.platform.vehicle.biz.VehicleBookRecordBiz;
import com.xxfc.platform.vehicle.biz.VehiclePlatCataBiz;
import com.xxfc.platform.vehicle.biz.VehicleWarningMsgBiz;
import com.xxfc.platform.vehicle.common.BaseController; import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.common.CustomIllegalParamException; import com.xxfc.platform.vehicle.common.CustomIllegalParamException;
import com.xxfc.platform.vehicle.common.RestResponse; import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.constant.BookType; import com.xxfc.platform.vehicle.constant.BookType;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus; import com.xxfc.platform.vehicle.constant.VehicleBookRecordStatus;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.Vehicle; import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleBookInfo; import com.xxfc.platform.vehicle.entity.VehicleBookInfo;
import com.xxfc.platform.vehicle.entity.VehicleBookRecord; import com.xxfc.platform.vehicle.entity.VehicleBookRecord;
...@@ -46,6 +46,7 @@ import java.util.ArrayList; ...@@ -46,6 +46,7 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP; import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP;
import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME; import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
...@@ -55,7 +56,7 @@ import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME; ...@@ -55,7 +56,7 @@ import static com.xxfc.platform.vehicle.constant.VehicleConstant.USER_APP_NAME;
@Slf4j @Slf4j
@IgnoreClientToken @IgnoreClientToken
@Api(value="车辆管理controller",tags={"车辆管理接口"}) @Api(value="车辆管理controller",tags={"车辆管理接口"})
public class VehicleController extends BaseController<VehicleBiz> { public class VehicleController extends BaseController<VehicleBiz> implements UserRestInterface {
@Autowired @Autowired
private VehicleBookRecordBiz vehicleBookRecordBiz; private VehicleBookRecordBiz vehicleBookRecordBiz;
...@@ -78,7 +79,11 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -78,7 +79,11 @@ public class VehicleController extends BaseController<VehicleBiz> {
@Autowired @Autowired
private VehicleJobHandler vehicleJobHandler; private VehicleJobHandler vehicleJobHandler;
@Autowired
BranchCompanyBiz branchCompanyBiz;
public UserFeign getUserFeign() {
return userFeign;
}
private static Integer MAX_DRIVING_LICENSE_SIZE = 10 * 1024 * 1024;//10M private static Integer MAX_DRIVING_LICENSE_SIZE = 10 * 1024 * 1024;//10M
public static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); public static final DateTimeFormatter DEFAULT_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
...@@ -213,6 +218,7 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -213,6 +218,7 @@ public class VehicleController extends BaseController<VehicleBiz> {
public RestResponse<Integer> applyVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception { public RestResponse<Integer> applyVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception {
Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID()); Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID());
String userName = BaseContextHandler.getName(); String userName = BaseContextHandler.getName();
bookVehicleVo.setStatus(VehicleBookRecordStatus.APPLY.getCode());
baseBiz.applyVehicle(operatorId, bookVehicleVo, userName); baseBiz.applyVehicle(operatorId, bookVehicleVo, userName);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -228,7 +234,8 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -228,7 +234,8 @@ public class VehicleController extends BaseController<VehicleBiz> {
public RestResponse<Integer> applyForVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception { public RestResponse<Integer> applyForVehicle(@RequestBody BookVehicleVO bookVehicleVo) throws Exception {
Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID()); Integer operatorId = Integer.parseInt(BaseContextHandler.getUserID());
String userName = BaseContextHandler.getName(); String userName = BaseContextHandler.getName();
baseBiz.applyForVehicle(operatorId, bookVehicleVo, userName); bookVehicleVo.setStatus(VehicleBookRecordStatus.APPLY.getCode());
baseBiz.applyVehicle(operatorId, bookVehicleVo, userName);
return RestResponse.suc(); return RestResponse.suc();
} }
...@@ -450,6 +457,34 @@ public class VehicleController extends BaseController<VehicleBiz> { ...@@ -450,6 +457,34 @@ public class VehicleController extends BaseController<VehicleBiz> {
@IgnoreClientToken @IgnoreClientToken
@IgnoreUserToken @IgnoreUserToken
public ObjectRestResponse<Map<String, Object>> getVehiclePlanList(VehiclePlanDto vehiclePlanDto) { public ObjectRestResponse<Map<String, Object>> getVehiclePlanList(VehiclePlanDto vehiclePlanDto) {
UserDTO userDTO = getAdminUserInfo();
if(userDTO == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, "token失效");
}
List<Integer> companyList = Lists.newArrayList();
List<BranchCompany> branchCompany = branchCompanyBiz.getListByUser(userDTO);
companyList = branchCompany.stream().map(BranchCompany::getId).collect(Collectors.toList());
if(vehiclePlanDto.getParkBranchCompanyId() != null) {
if(companyList.size() > 0) {
if(companyList.contains(vehiclePlanDto.getParkBranchCompanyId())) {
companyList.clear();
companyList.add(vehiclePlanDto.getParkBranchCompanyId());
} else {
return ObjectRestResponse.succ();
}
}
}
if(vehiclePlanDto.getSubordinateBranch() != null) {
if(companyList.size() > 0) {
if(companyList.contains(vehiclePlanDto.getSubordinateBranch())) {
companyList.clear();
companyList.add(vehiclePlanDto.getSubordinateBranch());
} else {
return ObjectRestResponse.succ();
}
}
}
vehiclePlanDto.setCompanyIds(companyList);
//获取列表 //获取列表
PageDataVO<VehicleAndModelInfoVo> pageDataVO = baseBiz.getAllVehicle(vehiclePlanDto); PageDataVO<VehicleAndModelInfoVo> pageDataVO = baseBiz.getAllVehicle(vehiclePlanDto);
//获取警告信息 //获取警告信息
......
...@@ -367,11 +367,9 @@ ...@@ -367,11 +367,9 @@
</select> </select>
<select id="getByVehicleId" parameterType="java.lang.String" <select id="getByVehicleId" parameterType="java.lang.String"
resultType="com.xxfc.platform.vehicle.pojo.VehicleBookRecordVo"> resultType="com.xxfc.platform.vehicle.pojo.VehicleBookRecordVo">
SELECT v1.*, conv(v2.booked_hour,10,2) startHour,conv(v3.booked_hour,10,2) endHour,bc2.name retCompanyName from vehicle_book_record v1 SELECT v1.*,bc2.name retCompanyName from vehicle_book_record v1
LEFT JOIN vehicle_book_hour_info v2 on v2.book_record_id = v1.id and YEAR(v2.year_month_day) = YEAR(v1.book_start_date) AND MONTH(v2.year_month_day) = MONTH(v1.book_start_date) AND DAY(v2.year_month_day) =DAY(v1.book_start_date) LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
LEFT JOIN vehicle_book_hour_info v3 on v3.book_record_id = v1.id and YEAR(v3.year_month_day) = YEAR(v1.book_end_date) AND MONTH(v3.year_month_day) = MONTH(v1.book_end_date) AND DAY(v3.year_month_day) =DAY(v1.book_end_date) where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2
LEFT JOIN branch_company bc2 on v1.ret_company = bc2.id
where v1.vehicle_id = #{vehicleId} and v1.status BETWEEN 1 and 2 and v1.book_end_date
</select> </select>
<select id="getByParam" parameterType="java.util.Map" resultMap="getVehicleMap"> <select id="getByParam" parameterType="java.util.Map" resultMap="getVehicleMap">
select v1.* from vehicle_book_record v1 select v1.* from vehicle_book_record v1
......
...@@ -380,11 +380,11 @@ ...@@ -380,11 +380,11 @@
<if test="status != null"> <if test="status != null">
and v1.status = #{status} and v1.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v1.subordinate_branch = #{subordinateBranch} v1.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v1.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if> </if>
<if test="zoneId !=null"> <if test="zoneId !=null">
and bc2.zone_id = #{zoneId} and bc2.zone_id = #{zoneId}
...@@ -397,7 +397,7 @@ ...@@ -397,7 +397,7 @@
select v1.*,bc3.name parkCompanyName from vehicle v1 select v1.*,bc3.name parkCompanyName from vehicle v1
LEFT JOIN branch_company bc3 ON v1.park_branch_company_id = bc3.id LEFT JOIN branch_company bc3 ON v1.park_branch_company_id = bc3.id
<where> <where>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v1.number_plate = #{numberPlate} and v1.number_plate = #{numberPlate}
</if> </if>
<if test="companyIds != null and companyIds.size > 0"> <if test="companyIds != null and companyIds.size > 0">
...@@ -455,20 +455,17 @@ ...@@ -455,20 +455,17 @@
<if test="startTime != null"> <if test="startTime != null">
and v1.create_time between #{startTime} and #{endTime} and v1.create_time between #{startTime} and #{endTime}
</if> </if>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v1.number_plate = #{numberPlate} and v1.number_plate = #{numberPlate}
</if> </if>
<if test="status != null"> <if test="status != null">
and v1.status = #{status} and v1.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v1.subordinate_branch = #{subordinateBranch} v1.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v1.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if>
<if test="zoneId !=null">
and bc1.zone_id = #{zoneId}
</if> </if>
</where> </where>
GROUP BY v1.status GROUP BY v1.status
...@@ -480,20 +477,17 @@ ...@@ -480,20 +477,17 @@
<if test="startTime != null"> <if test="startTime != null">
and v2.create_time between #{startTime} and #{endTime} and v2.create_time between #{startTime} and #{endTime}
</if> </if>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v2.number_plate = #{numberPlate} and v2.number_plate = #{numberPlate}
</if> </if>
<if test="status != null"> <if test="status != null">
and v2.status = #{status} and v2.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v2.subordinate_branch = #{subordinateBranch} v2.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v2.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if> </if>
</where> </where>
</select> </select>
......
...@@ -44,20 +44,17 @@ ...@@ -44,20 +44,17 @@
<if test="startTime != null"> <if test="startTime != null">
and w.create_time between #{startTime} and #{endTime} and w.create_time between #{startTime} and #{endTime}
</if> </if>
<if test="numberPlate != null"> <if test="numberPlate != null and numberPlate != ''">
and v.number_plate = #{numberPlate} and v.number_plate = #{numberPlate}
</if> </if>
<if test="status != null"> <if test="status != null">
and v.status = #{status} and v.status = #{status}
</if> </if>
<if test="subordinateBranch != null"> <if test="companyIds != null and companyIds.size > 0">
and v.subordinate_branch = #{subordinateBranch} v.park_branch_company_id in
</if> <foreach collection="companyIds" item="id" open="(" separator="," close=")">
<if test="parkBranchCompanyId != null"> #{id}
and v.park_branch_company_id = #{parkBranchCompanyId} </foreach>
</if>
<if test="zoneId !=null">
and bc2.zone_id = #{zoneId}
</if> </if>
</where> </where>
</select> </select>
...@@ -76,6 +73,12 @@ ...@@ -76,6 +73,12 @@
<if test="numberPlate != null and numberPlate != '' "> <if test="numberPlate != null and numberPlate != '' ">
and number_plate = #{numberPlate} and number_plate = #{numberPlate}
</if> </if>
<if test="type != null">
and type = #{type}
</if>
<if test="colorType != null">
and color_type = #{colorType}
</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
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