Commit 871a6a22 authored by huangcb's avatar huangcb

承运商接口:查询指定承运商的司机与车辆绑定列表

parent ad81287d
......@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.driver.controller;
import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.module.driver.form.CarrierForm;
import com.esv.freight.customer.module.driver.form.DriverQueryForm;
import com.esv.freight.customer.module.driver.form.DriverVehicleForm;
import com.esv.freight.customer.module.driver.service.DriverVehicleService;
......@@ -90,4 +91,16 @@ public class DriverVehicleController {
public EResponse checkBind(@RequestBody @Validated(ValidatorCheckBind.class) DriverVehicleForm form) throws EException {
return EResponse.ok(driverVehicleService.checkBind(form));
}
/**
* description 查询指定承运商的司机与车辆绑定列表
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/06 11:22
**/
@PostMapping("/listByCarrier")
public EResponse listByCarrier(@RequestBody CarrierForm form) throws EException {
return EResponse.ok(driverVehicleService.getDriverVehicle4Carrier(form.getId()));
}
}
package com.esv.freight.customer.module.driver.dto;
import lombok.Data;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.dto.DriverVehicleDto
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/06 10:06
* @version:1.0
*/
@Data
public class DriverVehicleDto {
/**
* 承运商帐号ID
*/
private Long carrierId;
/**
* 承运商类别(字典表):1-企业承运人、2-个体承运人
*/
private Integer carrierType;
/**
* 承运商名称
*/
private String carrierFullName;
/**
* 承运商联系人
*/
private String carrierContactor;
/**
* 司机ID
*/
private String driverId;
/**
* 司机(帐号)手机号
*/
private String driverAccount;
/**
* 司机帐号状态:1-正常、2-停用
*/
private String driverAccountStatus;
/**
* 司机帐号创建来源:1-平台创建、2-自行注册
*/
private String driverSourceType;
/**
* 司机帐号审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private String driverAuditStatus;
/**
* 司机姓名
*/
private String driverName;
/**
* 车辆ID
*/
private String vehicleId;
/**
* 车辆状态:1-正常、2-停用
*/
private String vehicleStatus;
/**
* 车辆审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private String vehicleAuditStatus;
/**
* 车辆创建来源:1-平台创建、2-司机创建
*/
private String vehicleSourceType;
/**
* 车辆车牌号
*/
private String vehicleLicenseNumber;
}
package com.esv.freight.customer.module.driver.form;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.form.CarrierForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/06 11:11
* @version:1.0
*/
@Data
public class CarrierForm {
private Long id;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.driver.service;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.module.driver.form.DriverVehicleForm;
import com.esv.freight.customer.module.driver.vo.CarrierDriverVehicleVO;
import com.esv.freight.customer.module.driver.vo.DriverVehicleListVO;
import com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity;
......@@ -63,4 +64,13 @@ public interface DriverVehicleService {
**/
JSONObject checkBind(DriverVehicleForm form);
/**
* description 查询指定承运商的司机与车辆绑定列表
* param [carrierId]
* return java.util.List<com.esv.freight.customer.module.driver.dto.DriverVehicleDto>
* author Administrator
* createTime 2020/05/06 11:14
**/
List<CarrierDriverVehicleVO> getDriverVehicle4Carrier(Long carrierId);
}
......@@ -8,10 +8,13 @@ import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.module.carrier.CarrierConstants;
import com.esv.freight.customer.module.driver.DriverConstants;
import com.esv.freight.customer.module.driver.dto.DriverDetailDto;
import com.esv.freight.customer.module.driver.dto.DriverVehicleDto;
import com.esv.freight.customer.module.driver.entity.DriverAccountEntity;
import com.esv.freight.customer.module.driver.form.DriverVehicleForm;
import com.esv.freight.customer.module.driver.service.DriverAccountService;
import com.esv.freight.customer.module.driver.service.DriverVehicleService;
import com.esv.freight.customer.module.driver.vo.CarrierDriverBindVehicleVO;
import com.esv.freight.customer.module.driver.vo.CarrierDriverVehicleVO;
import com.esv.freight.customer.module.driver.vo.DriverDetailVO;
import com.esv.freight.customer.module.driver.vo.DriverVehicleListVO;
import com.esv.freight.customer.module.vehicle.VehicleConstants;
......@@ -24,6 +27,7 @@ import com.esv.freight.customer.module.vehicle.vo.VehicleDetailVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -207,4 +211,40 @@ public class DriverVehicleServiceImpl implements DriverVehicleService {
return data;
}
@Override
public List<CarrierDriverVehicleVO> getDriverVehicle4Carrier(Long carrierId) {
List<DriverVehicleDto> dtoList = this.vehicleDriverService.getDriverVehicle4Carrier(carrierId);
List<CarrierDriverVehicleVO> voList = new ArrayList<>();
List<CarrierDriverBindVehicleVO> driverVehicleList;
CarrierDriverVehicleVO vo;
for (int i = 0; i < dtoList.size(); i++) {
DriverVehicleDto dto = dtoList.get(i);
CarrierDriverBindVehicleVO bindVO = new CarrierDriverBindVehicleVO();
BeanUtils.copyProperties(dto, bindVO);
// 判断是否同一个承运商
if (0 != voList.size() && voList.get(voList.size() - 1).getCarrierId().equals(dto.getCarrierId())) {
vo = voList.get(voList.size() - 1);
driverVehicleList = vo.getDriverVehicle();
driverVehicleList.add(bindVO);
vo.setDriverVehicle(driverVehicleList);
} else {
driverVehicleList = new ArrayList<>();
vo = new CarrierDriverVehicleVO();
vo.setCarrierId(dto.getCarrierId());
if (CarrierConstants.CARRIER_TYPE_COMPANY.equals(dto.getCarrierType())) {
vo.setCarrierName(dto.getCarrierFullName());
} else {
vo.setCarrierName(dto.getCarrierContactor());
}
driverVehicleList.add(bindVO);
vo.setDriverVehicle(driverVehicleList);
voList.add(vo);
}
}
return voList;
}
}
package com.esv.freight.customer.module.driver.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.vo.CarrierDriverVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/06 11:15
* @version:1.0
*/
@Data
public class CarrierDriverBindVehicleVO {
/**
* 司机ID
*/
private String driverId;
/**
* 司机(帐号)手机号
*/
private String driverAccount;
/**
* 司机帐号状态:1-正常、2-停用
*/
private String driverAccountStatus;
/**
* 司机帐号创建来源:1-平台创建、2-自行注册
*/
private String driverSourceType;
/**
* 司机帐号审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private String driverAuditStatus;
/**
* 司机姓名
*/
private String driverName;
/**
* 车辆ID
*/
private String vehicleId;
/**
* 车辆状态:1-正常、2-停用
*/
private String vehicleStatus;
/**
* 车辆审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private String vehicleAuditStatus;
/**
* 车辆创建来源:1-平台创建、2-司机创建
*/
private String vehicleSourceType;
/**
* 车辆车牌号
*/
private String vehicleLicenseNumber;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.driver.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.driver.vo.CarrierDriverVehicleVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/06 11:15
* @version:1.0
*/
@Data
public class CarrierDriverVehicleVO {
/**
* 承运商帐号ID
*/
private Long carrierId;
/**
* 承运商名称
*/
private String carrierName;
/**
* 绑定的司机与车辆信息
*/
List<CarrierDriverBindVehicleVO> driverVehicle;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.vehicle.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.freight.customer.module.driver.dto.DriverVehicleDto;
import com.esv.freight.customer.module.driver.vo.DriverVehicleListVO;
import com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity;
import org.apache.ibatis.annotations.Mapper;
......@@ -25,5 +26,14 @@ public interface VehicleDriverDao extends BaseMapper<VehicleDriverEntity> {
* createTime 2020/04/29 17:54
**/
List<DriverVehicleListVO> selectDriverBindVehicleList(Long driverId);
/**
* description 查询指定承运商的司机与车辆绑定列表
* param [carrierId]
* return java.util.List<com.esv.freight.customer.module.driver.dto.DriverVehicleDto>
* author Administrator
* createTime 2020/05/06 11:08
**/
List<DriverVehicleDto> selectDriverVehicle4Carrier(Long carrierId);
}
package com.esv.freight.customer.module.vehicle.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.driver.dto.DriverVehicleDto;
import com.esv.freight.customer.module.driver.vo.DriverVehicleListVO;
import com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity;
......@@ -24,5 +25,14 @@ public interface VehicleDriverService extends IService<VehicleDriverEntity> {
**/
List<DriverVehicleListVO> getDriverBindVehicleList(Long driverId);
/**
* description 查询指定承运商的司机与车辆绑定列表
* param [carrierId]
* return java.util.List<com.esv.freight.customer.module.driver.dto.DriverVehicleDto>
* author Administrator
* createTime 2020/05/06 11:09
**/
List<DriverVehicleDto> getDriverVehicle4Carrier(Long carrierId);
}
package com.esv.freight.customer.module.vehicle.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.module.driver.dto.DriverVehicleDto;
import com.esv.freight.customer.module.driver.vo.DriverVehicleListVO;
import com.esv.freight.customer.module.vehicle.dao.VehicleDriverDao;
import com.esv.freight.customer.module.vehicle.entity.VehicleDriverEntity;
......@@ -18,4 +19,8 @@ public class VehicleDriverServiceImpl extends ServiceImpl<VehicleDriverDao, Vehi
return this.baseMapper.selectDriverBindVehicleList(driverId);
}
@Override
public List<DriverVehicleDto> getDriverVehicle4Carrier(Long carrierId) {
return this.baseMapper.selectDriverVehicle4Carrier(carrierId);
}
}
\ No newline at end of file
......@@ -105,4 +105,96 @@ error-message:
account-address:
1001: 无效的货主ID
1002: 无效的发货地址ID
1003: 无效的收货地址ID
\ No newline at end of file
1003: 无效的收货地址ID
carrier:
account:
add:
1001: 帐号已存在
1002: 道路运输经营许可证号已存在
1003: 统一社会信用代码已存在
1004: 承运商名称已存在
edit:
1001: 无效的帐号ID
1002: 道路运输经营许可证号已存在
1003: 统一社会信用代码已存在
1004: 承运商名称已存在
detail:
1001: 无效的帐号ID
vehicle:
add:
1001: 无效的承运商ID
1002: 车牌号已存在
1003: 行驶证档案编号已存在
1004: 道路运输证号已存在
edit:
1001: 无效的车辆ID
1002: 车牌号已存在
1003: 行驶证档案编号已存在
1004: 道路运输证号已存在
detail:
1001: 无效的车辆ID
audit:
1001: 无效的车辆ID
1002: 车辆已审核通过
audit-list:
1001: 无效的车辆ID
block:
1001: 无效的车辆ID
1002: 车辆已停用
unblock:
1001: 无效的车辆ID
1002: 车辆已启用
driver:
add:
1001: 账号已存在
1002: 身份证号码已存在
1003: 驾驶证号码已存在
1004: 从业资格证号已存在
1005: 无效的承运商ID
edit:
1001: 无效的账号ID
1002: 身份证号码已存在
1003: 驾驶证号码已存在
1004: 从业资格证号已存在
detail:
1001: 无效的账号ID
detail-by-account:
1001: 无效的账号
audit:
1001: 无效的账号ID
1002: 帐号已审核通过
block:
1001: 无效的账号ID
1002: 帐号已停用
unblock:
1001: 无效的账号ID
1002: 帐号已启用
register:
1001: 帐号已存在
1002: 无效的承运商ID​
audit-history:
1001: 无效的账号ID
vehicle-list:
1001: 无效的司机ID
1002: 该司机未绑定车辆
vehicle-bind:
1001: 无效的司机ID
1002: 司机帐号已停用
1003: 司机帐号未审核通过
1010: 无效的车辆ID
1011: 车辆已停用
1012: 车辆未审核通过
1020: 司机与车辆所属承运商不一致
1021: 重复绑定
vehicle-unbind:
1001: 无效的司机ID
1010: 无效的车辆ID
1020: 车辆与司机未绑定
1021: 司机自主绑定的车辆,平台不可解绑
account-check:
1001: 无效的手机号
1002: 密码错误
vehicle-check-bind:
1001: 司机与车辆未绑定
1002: 无效的司机ID
1003: 无效的车辆ID
\ No newline at end of file
......@@ -26,4 +26,25 @@
order by b.selected desc
</select>
<!-- 查询指定承运商的司机与车辆绑定列表 -->
<select id="selectDriverVehicle4Carrier" parameterType="java.lang.Long" resultType="com.esv.freight.customer.module.driver.dto.DriverVehicleDto">
select ab.*,
c.account as driverAccount, c.account_status as driverAccountStatus, c.source_type as driverSourceType, c.audit_status as driverAuditStatus,
d.name as driverName,
e.vehicle_status as vehicleStatus, e.source_type as vehicleSourceType, e.audit_status as vehicleAuditStatus, e.license_number as vehicleLicenseNumber
from (
select a.vehicle_id as vehicleId, a.driver_id as driverId,
b.account_id as carrierId, b.carrier_type as carrierType, b.carrier_full_name as carrierFullName, b.contactor as carrierContactor
from vehicle_driver a, carrier_info b
where a.carrier_id = b.account_id
<if test="carrierId != null">
and a.carrier_id = #{carrierId}
</if>
)ab
left join driver_account c on ab.carrierId = c.carrier_id and ab.driverId = c.id
left join driver_info d on ab.carrierId = d.carrier_id and ab.driverId = d.driver_id
left join vehicle e on ab.carrierId = e.carrier_id and ab.vehicleId = e.id
order by carrierId asc, vehicleLicenseNumber asc
</select>
</mapper>
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.driver.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.module.driver.form.CarrierForm;
import com.esv.freight.customer.module.driver.form.DriverQueryForm;
import com.esv.freight.customer.module.driver.form.DriverVehicleForm;
import lombok.extern.slf4j.Slf4j;
......@@ -258,4 +259,84 @@ public class DriverVehicleControllerTest extends BaseTestController {
Assert.assertTrue(result.getJSONObject("data").containsKey("driverInfo"));
Assert.assertTrue(result.getJSONObject("data").containsKey("vehicleInfo"));
}
/**
* 查询指定承运商的司机与车辆绑定列表:不指定承运商
**/
@Test
public void e1_listByCarrier_success_test() throws Exception {
String url = "/carrier/driver/vehicle/listByCarrier";
// 构造数据
CarrierForm form = new CarrierForm();
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(null != result.getJSONArray("data"));
}
/**
* 查询指定承运商的司机与车辆绑定列表:指定承运商ID存在
**/
@Test
public void e2_listByCarrier_with_right_id_success_test() throws Exception {
String url = "/carrier/driver/vehicle/listByCarrier";
// 构造数据
CarrierForm form = new CarrierForm();
form.setId(2L);
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(null != result.getJSONArray("data"));
}
/**
* 查询指定承运商的司机与车辆绑定列表:指定承运商ID不存在
**/
@Test
public void e3_listByCarrier_with_right_id_success_test() throws Exception {
String url = "/carrier/driver/vehicle/listByCarrier";
// 构造数据
CarrierForm form = new CarrierForm();
form.setId(99999L);
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(0 == result.getJSONArray("data").size());
}
}
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