Commit ae536326 authored by jiaorz's avatar jiaorz

Merge branch 'master-background-manager'

parents 007f5229 1ec59eec
......@@ -134,6 +134,7 @@ public class VehicleModel implements Serializable {
private Integer hotSign;
@ApiModelProperty(value = "是否删除")
@Column(name = "isdel")
private Integer isdel;
@Column(name = "rent_discount_status")
@ApiModelProperty(value = "租车优惠状态 0--没有优惠;1--会员折扣;2--固定值")
......
......@@ -49,6 +49,11 @@ public class VehiclePageQueryVo {
* 用途类型:租赁房车(1)、展车等,对应关系见车辆常量表
*/
private Integer useType;
/**
* 托管人
*/
private String belongToName;
/**
* 预定目标日期(开始)
*/
......
......@@ -1491,6 +1491,29 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
return count > 0;
}
public Boolean checkVinExist(String vin, String id) {
Example example = new Example(Vehicle.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("vin", vin);
criteria.andEqualTo("isDel",0);
if (StringUtils.isNotEmpty(id)) {
criteria.andNotEqualTo("id", id);
}
int count = mapper.selectCountByExample(example);
return count > 0;
}
public Boolean checkEngineNumExist(String engineNum, String id) {
Example example = new Example(Vehicle.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("engineNum", engineNum);
criteria.andEqualTo("isDel",0);
if (StringUtils.isNotEmpty(id)) {
criteria.andNotEqualTo("id", id);
}
int count = mapper.selectCountByExample(example);
return count > 0;
}
public List<String> findbyPlateNumberAndVehicleCod(String plateNumber,String vehicleCode) {
List<String> vehicleIds = Lists.newArrayList();
......
......@@ -29,7 +29,6 @@ import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
......@@ -195,51 +194,6 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
}
vehicleBookRecordQueryVo.setCompanyIds(companyList);
if (vehicleBookRecordQueryVo.getStatus() != null && vehicleBookRecordQueryVo.getStatus() == 3) { //待出行
vehicleBookRecordQueryVo.setStatus(2);
Query query = new Query(vehicleBookRecordQueryVo);
List<VehicleBookRecordVo> list = mapper.getBookRecordInfo(query.getSuper());
removeStatus3(list);
PageInfo<VehicleBookRecordVo> vehicleBookRecordVoPageInfo = new PageInfo<>(list);
getupKeeps(vehicleBookRecordVoPageInfo.getList());
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO);
}
if (vehicleBookRecordQueryVo.getStatus() != null && vehicleBookRecordQueryVo.getStatus() == 5) { //出行中
vehicleBookRecordQueryVo.setStatus(2);
Query query = new Query(vehicleBookRecordQueryVo);
List<VehicleBookRecordVo> list = mapper.getBookRecordInfo(query.getSuper());
removeStatus5(list);
PageInfo<VehicleBookRecordVo> vehicleBookRecordVoPageInfo = new PageInfo<>(list);
getupKeeps(vehicleBookRecordVoPageInfo.getList());
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO);
}
if (vehicleBookRecordQueryVo.getStatus() != null && vehicleBookRecordQueryVo.getStatus() == 7) { //已完成
vehicleBookRecordQueryVo.setStatus(2);
Query query = new Query(vehicleBookRecordQueryVo);
List<VehicleBookRecordVo> list = mapper.getBookRecordInfo(query.getSuper());
removeStatus7(list);
PageInfo<VehicleBookRecordVo> vehicleBookRecordVoPageInfo = new PageInfo<>(list);
getupKeeps(vehicleBookRecordVoPageInfo.getList());
PageDataVO<VehicleBookRecordVo> vehicleBookRecordVoPageDataVO = PageDataVO.pageInfo(vehicleBookRecordVoPageInfo);
vehicleBookRecordVoPageDataVO.setPageNum(pageNo);
vehicleBookRecordVoPageDataVO.setPageSize(pageSize);
vehicleBookRecordVoPageDataVO.setTotalCount((long) vehicleBookRecordVoPageInfo.getList().size());
vehicleBookRecordVoPageDataVO.setTotalPage((vehicleBookRecordVoPageInfo.getList().size() + pageSize - 1) / pageSize);
vehicleBookRecordVoPageDataVO.setData(getData(vehicleBookRecordVoPageInfo.getList(), pageNo, pageSize));
return RestResponse.suc(vehicleBookRecordVoPageDataVO);
}
Query query = new Query(vehicleBookRecordQueryVo);
PageDataVO<VehicleBookRecordVo> pageDataVO = PageDataVO.pageInfo(query, () -> mapper.getBookRecordInfo(query.getSuper()));
getupKeeps(pageDataVO.getData());
......@@ -259,47 +213,6 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
}
}
}
//筛选未出车的记录
public void removeStatus3(List<VehicleBookRecordVo> list) {
if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
VehicleBookRecordVo vehicleBookRecordVo = iterator.next();
if (vehicleBookRecordVo.getVehicleDepartureLogVo() != null) {
iterator.remove();
}
vehicleBookRecordVo.setState(3);
}
}
}
//筛选已出车未还车记录
public void removeStatus5(List<VehicleBookRecordVo> list) {
if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
VehicleBookRecordVo vehicleBookRecordVo = iterator.next();
if (vehicleBookRecordVo.getVehicleDepartureLogVo() == null || (vehicleBookRecordVo.getVehicleDepartureLogVo() != null && vehicleBookRecordVo.getVehicleDepartureLogVo().getState() ==1)) {
iterator.remove();
}
vehicleBookRecordVo.setState(5);
}
}
}
//筛选已完成记录
public void removeStatus7(List<VehicleBookRecordVo> list) {
if (list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
VehicleBookRecordVo vehicleBookRecordVo = iterator.next();
if (vehicleBookRecordVo.getVehicleDepartureLogVo() == null || (vehicleBookRecordVo.getVehicleDepartureLogVo() != null && vehicleBookRecordVo.getVehicleDepartureLogVo().getState() !=1)) {
iterator.remove();
}
vehicleBookRecordVo.setState(5);
}
}
}
/**
* 获取随身物品
*/
......
......@@ -34,17 +34,17 @@ public class VehicleDepartureService extends BaseBiz<VehicleDepartureLogMapper,
@Autowired
VehicleMapper vehicleMapper;
public PageInfo<VehicleDepartureLogVo> page(String numberPlate,Integer code,Integer zoneId,Integer departureId, String time, Integer page, Integer limit) {
public PageInfo<VehicleDepartureLogVo> page(String numberPlate,Integer code,Integer zoneId,Integer departureId, String startTime,String endTime, Integer page, Integer limit) {
PageHelper.startPage(page, limit);
return new PageInfo<>(mapper.selectVoAll(numberPlate,code,zoneId,departureId,time));
return new PageInfo<>(mapper.selectVoAll(numberPlate,code,zoneId,departureId,startTime, endTime));
}
public PageInfo<VehicleDepartureLogVo> pageNotAllData(String numberPlate,Integer code,Integer zoneId,Integer departureId, String time, Integer page, Integer limit, List<Integer> companyList) {
public PageInfo<VehicleDepartureLogVo> pageNotAllData(String numberPlate,Integer code,Integer zoneId,Integer departureId, String startTime,String endTime, Integer page, Integer limit, List<Integer> companyList) {
PageHelper.startPage(page, limit);
if (companyList == null || companyList.size() == 0) {
companyList = Arrays.asList(-1);
}
return new PageInfo<>(mapper.selectVoAllNotAllData(numberPlate,code,zoneId,departureId,time, companyList));
return new PageInfo<>(mapper.selectVoAllNotAllData(numberPlate,code,zoneId,departureId,startTime, endTime, companyList));
}
public PageInfo<VehicleDepartureLogVo> findByVehicle(String vehicleId, Integer page, Integer limit) {
......
......@@ -20,13 +20,16 @@ public interface VehicleDepartureLogMapper extends BaseMapper<VehicleDepartureLo
@Param("code") Integer code,
@Param("zoneId") Integer zoneId,
@Param("departureId") Integer departureId,
@Param("time") String time);
@Param("startTime") String startTime,
@Param("endTime") String endTime
);
List<VehicleDepartureLogVo> selectVoAllNotAllData(@Param("numberPlate") String numberPlate,
@Param("code") Integer code,
@Param("zoneId") Integer zoneId,
@Param("departureId") Integer departureId,
@Param("time") String time,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("companyList") List<Integer> companyList);
Integer selectMileageByVehicleId(String vehicleId);
......
......@@ -412,7 +412,7 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
companyList.clear();
companyList.add(vehiclePlanDto.getParkBranchCompanyId());
} else {
return ObjectRestResponse.succ();
return ObjectRestResponse.succ(Maps.newHashMap());
}
}
}
......@@ -422,7 +422,7 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
companyList.clear();
companyList.add(vehiclePlanDto.getSubordinateBranch());
} else {
return ObjectRestResponse.succ();
return ObjectRestResponse.succ(Maps.newHashMap());
}
}
}
......@@ -561,6 +561,17 @@ public class VehicleController extends BaseController<VehicleBiz> implements Use
return ObjectRestResponse.succ(exist);
}
@GetMapping("/exist_vin/{vin}")
public ObjectRestResponse<Boolean> checkVinExist(@PathVariable(value = "vin") String vin,@RequestParam(value = "id") String id){
Boolean exist = vehicleBiz.checkVinExist(vin,id);
return ObjectRestResponse.succ(exist);
}
@GetMapping("/exist_engineNum/{engineNum}")
public ObjectRestResponse<Boolean> checkEngineNumExist(@PathVariable(value = "engineNum") String engineNum,@RequestParam(value = "id") String id){
Boolean exist = vehicleBiz.checkEngineNumExist(engineNum,id);
return ObjectRestResponse.succ(exist);
}
@GetMapping("/findVehicleIds")
public List<String> findbyPlateNumberAndVehicleCod(@RequestParam(value = "plateNumber",required = false) String plateNumber,@RequestParam(value = "vehicleCode",required = false) String vehicleCode){
......
......@@ -36,7 +36,7 @@ public class VehicleDepartureController {
/**
* @param numberPlate 车牌
* @param code 车辆编码
* @param time
* @param
* @param departureId 出发分公司id
* @param page
* @param limit
......@@ -45,7 +45,7 @@ public class VehicleDepartureController {
*/
@GetMapping("page")
public RestResponse page(String numberPlate,
@RequestParam(value = "code", required = false) Integer code, String time,
@RequestParam(value = "code", required = false) Integer code, String startTime, String endTime,
@RequestParam(value = "zoneId",required = false) Integer zoneId,
@RequestParam(value = "departureId", required = false) Integer departureId,
Integer page, Integer limit, HttpServletRequest request) {
......@@ -57,15 +57,15 @@ public class VehicleDepartureController {
if (userDTO != null) {
if (userDTO.getDataAll() == 2) {
List<Integer> companyList = vehicleBiz.dataCompany(userDTO.getDataZone(), userDTO.getDataCompany());
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, zoneId,departureId, time, page, limit, companyList));
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, zoneId,departureId, startTime, endTime, page, limit, companyList));
}
}
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, zoneId,departureId, time, page, limit));
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, zoneId,departureId, startTime, endTime, page, limit));
}
@GetMapping("small/page")
@IgnoreUserToken
public RestResponse pageBySmall(String numberPlate, @RequestParam(value = "code", required = false) Integer code, String time, Integer page, Integer limit, Integer uid, HttpServletRequest request) {
public RestResponse pageBySmall(String numberPlate, @RequestParam(value = "code", required = false) Integer code, String startTime, String endTime,Integer page, Integer limit, Integer uid, HttpServletRequest request) {
if (page == null || limit == null) {
page = 1;
limit = 10;
......@@ -74,10 +74,10 @@ public class VehicleDepartureController {
if (userDTO != null) {
if (userDTO.getDataAll() == 2) {
List<Integer> companyList = vehicleBiz.dataCompany(userDTO.getDataZone(), userDTO.getDataCompany());
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, null,null, time, page, limit, companyList));
return RestResponse.data(vehicleDepartureService.pageNotAllData(numberPlate, code, null,null, startTime,endTime, page, limit, companyList));
}
}
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, null,null, time, page, limit));
return RestResponse.suc(vehicleDepartureService.page(numberPlate, code, null,null, startTime,endTime, page, limit));
}
/**
......
......@@ -472,7 +472,7 @@
CONCAT(#{selectedMonth}, "%"))
</if>
<if test="numberPlate != null">
and v3.number_plate = #{numberPlate}
and v3.number_plate like concat('%', #{numberPlate}, '%')
</if>
<if test="bookType != null">
and v1.book_type = #{bookType}
......@@ -490,9 +490,18 @@
#{id}
</foreach>)
</if>
<if test="status != null and status != 0 and status != -1 and status != -2">
<if test="status != null and status != 0 and status != -1 and status != -2 and status != 3 and status != 5 and status != 7">
and v1.status = #{status}
</if>
<if test="status != null and status == 3 ">
and v4.id is null and v1.status = 2
</if>
<if test="status != null and status == 5 ">
and v4.id is not null and v1.status = 2 and v4.state = 0
</if>
<if test="status != null and status == 7 ">
and v4.id is not null and v1.status = 2 and v4.state = 1
</if>
<if test="status != null and status == 0 ">
and v4.state = 0
</if>
......
......@@ -100,18 +100,12 @@
<if test="numberPlate != null and numberPlate != ''">
and vehicle.number_plate = #{numberPlate}
</if>
<if test="time != null and time != ''">
and (vehicle_departure_log.arrival_time >= str_to_date(#{time}, '%Y-%m-%d %H')
or TO_DAYS(vehicle_departure_log.arrival_time)=TO_DAYS(str_to_date(#{time}, '%Y-%m-%d %H'))
or vehicle_departure_log.arrival_time is null
)
<if test="startTime != null and startTime != ''">
and
(
vehicle_departure_log.departure_time &lt;= str_to_date(#{time}, '%Y-%m-%d %H')
or TO_DAYS(vehicle_departure_log.departure_time)=TO_DAYS(str_to_date(#{time}, '%Y-%m-%d %H'))
or vehicle_departure_log.departure_time is null
)
vehicle_departure_log.departure_time &gt;= str_to_date(#{startTime}, '%Y-%m-%d %H')
</if>
<if test="endTime != null and endTime != ''">
and vehicle_departure_log.arrival_time &gt;= str_to_date(#{endTime}, '%Y-%m-%d %H')
</if>
<if test="code!=null">
and vehicle.code=#{code}
......@@ -158,17 +152,17 @@
)
)
</if>
<if test="time != null and time != ''">
and (vehicle_departure_log.arrival_time >= str_to_date(#{time}, '%Y-%m-%d %H')
or TO_DAYS(vehicle_departure_log.arrival_time)=TO_DAYS(str_to_date(#{time}, '%Y-%m-%d %H'))
or vehicle_departure_log.arrival_time is null
)
<if test="startTime != null and startTime != ''">
and
(
vehicle_departure_log.departure_time &lt;= str_to_date(#{time}, '%Y-%m-%d %H')
or TO_DAYS(vehicle_departure_log.departure_time)=TO_DAYS(str_to_date(#{time}, '%Y-%m-%d %H'))
vehicle_departure_log.departure_time &lt;= str_to_date(#{startTime}, '%Y-%m-%d %H')
or TO_DAYS(vehicle_departure_log.departure_time)=TO_DAYS(str_to_date(#{startTime}, '%Y-%m-%d %H'))
or vehicle_departure_log.departure_time is null
)
</if>
<if test="endTime != null and endTime != ''">
and vehicle_departure_log.arrival_time >= str_to_date(#{endTime}, '%Y-%m-%d %H')
or TO_DAYS(vehicle_departure_log.arrival_time)=TO_DAYS(str_to_date(#{endTime}, '%Y-%m-%d %H'))
or vehicle_departure_log.arrival_time is null
</if>
<if test="code!=null">
and vehicle.code=#{code}
......
......@@ -41,11 +41,10 @@
SELECT r.* FROM (
select DISTINCT v.`id`,
v.`code`,
v.`status`,
(CASE WHEN #{status} != null THEN #{status}
ELSE v.status END) status ,
v.number_plate,
v.brand,
-- IFNULL(v.park_branch_company_id,v.expect_destination_branch_company_id) AS subordinate_branch,
-- IFNULL(bc.name,bc1.name) AS subBranchName,
v.park_branch_company_id,
bc.name as parkBranchCompanyName,
v.expect_destination_branch_company_id,
......@@ -80,14 +79,14 @@
left join
vehicle_book_info vbi on v.`id` = vbi.vehicle
</if>
-- LEFT JOIN branch_company bc ON v.park_branch_company_id = bc.id
-- LEFT JOIN branch_company bc1 ON v.expect_destination_branch_company_id = bc1.id
-- 停车分公司
LEFT JOIN branch_company bc ON v.park_branch_company_id = bc.id
-- 目的地分公司
LEFT JOIN branch_company bc1 ON v.expect_destination_branch_company_id = bc1.id
-- 所属分公司
LEFT JOIN branch_company bc2 ON v.subordinate_branch = bc2.id
LEFT JOIN vehicle_book_record v2 on v2.id = (select id from vehicle_book_record where vehicle_id = v.id order by update_time DESC LIMIT 1)
LEFT JOIN vehicle_departure_log v3 on v2.id = v3.book_record_id
where
v.is_del=0
<if test="mRangeDateEnd !=null">
......@@ -114,18 +113,27 @@
<if test="insuranceCompany !=null">
and v.insurance_company = #{insuranceCompany}
</if>
<if test="belongToName !=null and belongToName != ''">
and v.belong_to_name like concat('%',#{belongToName},'%')
</if>
<if test="vin !=null and vin != ''">
and v.vin = #{vin}
</if>
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<if test="code !=null">
and v.code = #{code}
</if>
<if test="status !=null">
<if test="status !=null and status != 6 and status != 7">
and v.status = #{status}
</if>
<if test="status !=null and status == 6">
and v3.id is not NULL and v2.book_type = 3 and v3.state = 0
</if>
<if test="status !=null and status == 7">
and v3.id is not NULL and v2.book_type = 6 and v3.state = 0
</if>
<if test="numberPlate !=null and numberPlate != ''">
and v.number_plate like concat('%',#{numberPlate},'%')
</if>
......@@ -163,7 +171,6 @@
and bc.zone_id=#{zoneId}
</if>
</if>
order by v.code
) r ORDER BY r.parkBranchCompanyName
</select>
......@@ -172,7 +179,8 @@
SELECT r.* FROM (
select DISTINCT v.`id`,
v.`code`,
v.`status`,
(CASE WHEN #{status} != null THEN #{status}
ELSE v.status END) status ,
v.number_plate,
v.brand,
-- IFNULL(v.park_branch_company_id,v.expect_destination_branch_company_id) AS subordinate_branch,
......@@ -217,6 +225,8 @@
LEFT JOIN branch_company bc1 ON v.expect_destination_branch_company_id = bc1.id
-- 所属分公司
LEFT JOIN branch_company bc2 ON v.subordinate_branch = bc2.id
LEFT JOIN vehicle_book_record v2 on v2.id = (select id from vehicle_book_record where vehicle_id = v.id order by update_time DESC LIMIT 1)
LEFT JOIN vehicle_departure_log v3 on v2.id = v3.book_record_id
where
v.is_del=0
<if test="companyList != null">
......@@ -266,18 +276,27 @@
<if test="insuranceCompany !=null">
and v.insurance_company = #{insuranceCompany}
</if>
<if test="belongToName !=null and belongToName != ''">
and v.belong_to_name like concat('%',#{belongToName},'%')
</if>
<if test="vin !=null and vin != ''">
and v.vin = #{vin}
</if>
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<!-- <if test="subordinateBranch !=null">-->
<!-- and v.subordinate_branch = #{subordinateBranch}-->
<!-- </if>-->
<if test="code !=null">
and v.code = #{code}
</if>
<if test="status !=null">
<if test="status !=null and status != 6 and status != 7">
and v.status = #{status}
</if>
<if test="status !=null and status == 6">
and v3.id is not NULL and v2.book_type = 3 and v3.state = 0
</if>
<if test="status !=null and status == 7">
and v3.id is not NULL and v2.book_type = 6 and v3.state = 0
</if>
<if test="numberPlate !=null and numberPlate != ''">
and v.number_plate like concat('%',#{numberPlate},'%')
</if>
......@@ -315,7 +334,6 @@
and bc.zone_id=#{zoneId}
</if>
</if>
order by v.code
) r ORDER BY r.parkBranchCompanyName
</select>
......
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