Commit b40c071e authored by huangcb's avatar huangcb

承运商接口:编辑车辆信息

parent 9bd9c019
...@@ -137,4 +137,13 @@ public class ErrorMessageComponent { ...@@ -137,4 +137,13 @@ public class ErrorMessageComponent {
private String carrierVehicleAdd1003; private String carrierVehicleAdd1003;
@Value("${error-message.carrier.vehicle.add.1004}") @Value("${error-message.carrier.vehicle.add.1004}")
private String carrierVehicleAdd1004; private String carrierVehicleAdd1004;
@Value("${error-message.carrier.vehicle.edit.1001}")
private String carrierVehicleEdit1001;
@Value("${error-message.carrier.vehicle.edit.1002}")
private String carrierVehicleEdit1002;
@Value("${error-message.carrier.vehicle.edit.1003}")
private String carrierVehicleEdit1003;
@Value("${error-message.carrier.vehicle.edit.1004}")
private String carrierVehicleEdit1004;
} }
...@@ -5,6 +5,7 @@ import com.esv.freight.customer.common.exception.EException; ...@@ -5,6 +5,7 @@ import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.ECode; import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.common.response.EResponse; import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.vehicle.form.VehicleInfoForm; import com.esv.freight.customer.module.vehicle.form.VehicleInfoForm;
import com.esv.freight.customer.module.vehicle.service.VehicleService; import com.esv.freight.customer.module.vehicle.service.VehicleService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -66,4 +67,17 @@ public class VehicleController { ...@@ -66,4 +67,17 @@ public class VehicleController {
data.put("id", id); data.put("id", id);
return EResponse.ok(data); return EResponse.ok(data);
} }
/**
* description 更新车辆信息
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/27 11:05
**/
@PostMapping("/edit")
public EResponse edit(@RequestBody @Validated(ValidatorUpdate.class) VehicleInfoForm form) throws EException {
vehicleService.updateVehicle(form);
return EResponse.ok();
}
} }
package com.esv.freight.customer.module.vehicle.form; package com.esv.freight.customer.module.vehicle.form;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
...@@ -25,6 +26,7 @@ public class VehicleInfoForm { ...@@ -25,6 +26,7 @@ public class VehicleInfoForm {
/** /**
* *
*/ */
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class})
private Long id; private Long id;
/** /**
* 承运商帐号ID * 承运商帐号ID
...@@ -34,35 +36,19 @@ public class VehicleInfoForm { ...@@ -34,35 +36,19 @@ public class VehicleInfoForm {
/** /**
* 车牌号 * 车牌号
*/ */
@Length(min = 7, max = 8, message = "参数licenseNumber长度不合法", groups = {ValidatorInsert.class}) @Length(min = 7, max = 8, message = "参数licenseNumber长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数licenseNumber不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数licenseNumber不能为空", groups = {ValidatorInsert.class})
private String licenseNumber; private String licenseNumber;
/**
* 车辆状态:1-正常、2-停用
*/
private String vehicleStatus;
/**
* 审核状态(字典表):0-待审核、1-审核成功,2-审核失败
*/
private Integer auditStatus;
/**
* 入网状态:字典表
*/
private Integer netInStatus;
/**
* 入网时间
*/
private String netInDate;
/** /**
* 牌照类型(字典表):1-大型汽车号牌、2-小型汽车号牌、3-其他号牌 * 牌照类型(字典表):1-大型汽车号牌、2-小型汽车号牌、3-其他号牌
*/ */
@Range(min = 1, max = 3, message = "参数licenseType不合法", groups = {ValidatorInsert.class}) @Range(min = 1, max = 3, message = "参数licenseType不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数licenseType不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数licenseType不能为空", groups = {ValidatorInsert.class})
private Integer licenseType; private Integer licenseType;
/** /**
* 车牌颜色(字典表):1-蓝色、2-黄色、3-黑色、4-白色、5-绿色、6-农黄色、7-农绿色、8-黄绿色、9-渐变绿、0-其他 * 车牌颜色(字典表):1-蓝色、2-黄色、3-黑色、4-白色、5-绿色、6-农黄色、7-农绿色、8-黄绿色、9-渐变绿、0-其他
*/ */
@Range(min = 0, max = 9, message = "参数licenseColor不合法", groups = {ValidatorInsert.class}) @Range(min = 0, max = 9, message = "参数licenseColor不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数licenseColor不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数licenseColor不能为空", groups = {ValidatorInsert.class})
private Integer licenseColor; private Integer licenseColor;
/** /**
...@@ -78,194 +64,185 @@ public class VehicleInfoForm { ...@@ -78,194 +64,185 @@ public class VehicleInfoForm {
/** /**
* 车辆长度(单位毫米) * 车辆长度(单位毫米)
*/ */
@Range(min = 1000, max = 50000, message = "参数vehicleLength不合法", groups = {ValidatorInsert.class}) @Range(min = 1000, max = 50000, message = "参数vehicleLength不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数vehicleLength不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数vehicleLength不能为空", groups = {ValidatorInsert.class})
private Integer vehicleLength; private Integer vehicleLength;
/** /**
* 车辆宽度(单位毫米) * 车辆宽度(单位毫米)
*/ */
@Range(min = 1000, max = 5000, message = "参数vehicleWidth不合法", groups = {ValidatorInsert.class}) @Range(min = 1000, max = 5000, message = "参数vehicleWidth不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数vehicleWidth不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数vehicleWidth不能为空", groups = {ValidatorInsert.class})
private Integer vehicleWidth; private Integer vehicleWidth;
/** /**
* 车辆高度(单位毫米) * 车辆高度(单位毫米)
*/ */
@Range(min = 1000, max = 5000, message = "参数vehicleHeight不合法", groups = {ValidatorInsert.class}) @Range(min = 1000, max = 5000, message = "参数vehicleHeight不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数vehicleHeight不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数vehicleHeight不能为空", groups = {ValidatorInsert.class})
private Integer vehicleHeight; private Integer vehicleHeight;
/** /**
* 车辆所属(字典表):1-自有车、2-外协车 * 车辆所属(字典表):1-自有车、2-外协车
*/ */
@Range(min = 1, max = 2, message = "参数vehicleBelong不合法", groups = {ValidatorInsert.class}) @Range(min = 1, max = 2, message = "参数vehicleBelong不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数vehicleBelong不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数vehicleBelong不能为空", groups = {ValidatorInsert.class})
private Integer vehicleBelong; private Integer vehicleBelong;
/** /**
* 年审日期 * 年审日期
*/ */
@Length(max = 20, message = "参数yearAuditDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数yearAuditDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String yearAuditDate; private String yearAuditDate;
/** /**
* 能源类型(字典表):1-汽油、2-柴油、3-电、4-混合油、5-天然气、6-液化石油气、7-甲醇、8-乙醇、9-太阳能、10-混合动力、0-其他 * 能源类型(字典表):1-汽油、2-柴油、3-电、4-混合油、5-天然气、6-液化石油气、7-甲醇、8-乙醇、9-太阳能、10-混合动力、0-其他
*/ */
@Range(min = 0, max = 10, message = "参数energyType不合法", groups = {ValidatorInsert.class}) @Range(min = 0, max = 10, message = "参数energyType不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数energyType不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数energyType不能为空", groups = {ValidatorInsert.class})
private Integer energyType; private Integer energyType;
/** /**
* 行驶证档案编号 * 行驶证档案编号
*/ */
@Length(max = 20, message = "参数vehicleLicenseNumber长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数vehicleLicenseNumber长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleLicenseNumber不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleLicenseNumber不能为空", groups = {ValidatorInsert.class})
private String vehicleLicenseNumber; private String vehicleLicenseNumber;
/** /**
* 核定载质量(吨) * 核定载质量(吨)
*/ */
@DecimalMax(value = "9999.99", message = "参数loadCapacity不合法", groups = {ValidatorInsert.class}) @DecimalMax(value = "9999.99", message = "参数loadCapacity不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@DecimalMin(value = "1.00", message = "参数loadCapacity不合法", groups = {ValidatorInsert.class}) @DecimalMin(value = "1.00", message = "参数loadCapacity不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数loadCapacity不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数loadCapacity不能为空", groups = {ValidatorInsert.class})
private BigDecimal loadCapacity; private BigDecimal loadCapacity;
/** /**
* 总质量(吨) * 总质量(吨)
*/ */
@DecimalMax(value = "9999.99", message = "参数totalMass不合法", groups = {ValidatorInsert.class}) @DecimalMax(value = "9999.99", message = "参数totalMass不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@DecimalMin(value = "1.00", message = "参数totalMass不合法", groups = {ValidatorInsert.class}) @DecimalMin(value = "1.00", message = "参数totalMass不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private BigDecimal totalMass; private BigDecimal totalMass;
/** /**
* 整备质量(吨) * 整备质量(吨)
*/ */
@DecimalMax(value = "9999.99", message = "参数unladenMass不合法", groups = {ValidatorInsert.class}) @DecimalMax(value = "9999.99", message = "参数unladenMass不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@DecimalMin(value = "1.00", message = "参数unladenMass不合法", groups = {ValidatorInsert.class}) @DecimalMin(value = "1.00", message = "参数unladenMass不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private BigDecimal unladenMass; private BigDecimal unladenMass;
/** /**
* 车辆所有人 * 车辆所有人
*/ */
@Length(max = 20, message = "参数vehicleOwner长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数vehicleOwner长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleOwner不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleOwner不能为空", groups = {ValidatorInsert.class})
private String vehicleOwner; private String vehicleOwner;
/** /**
* 车辆所有人代码:企业-统一社会信用代码,个人-身份证号码 * 车辆所有人代码:企业-统一社会信用代码,个人-身份证号码
*/ */
@Length(max = 20, message = "参数vehicleOwnerCode长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数vehicleOwnerCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleOwnerCode不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleOwnerCode不能为空", groups = {ValidatorInsert.class})
private String vehicleOwnerCode; private String vehicleOwnerCode;
/** /**
* 使用性质 * 使用性质
*/ */
@Length(max = 20, message = "参数useNature长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数useNature长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String useNature; private String useNature;
/** /**
* 注册日期 * 注册日期
*/ */
@Length(max = 20, message = "参数registerDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数registerDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String registerDate; private String registerDate;
/** /**
* 车辆识别代码 * 车辆识别代码
*/ */
@Length(max = 20, message = "参数vin长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数vin长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String vin; private String vin;
/** /**
* 品牌型号 * 品牌型号
*/ */
@Length(max = 20, message = "参数brandModel长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数brandModel长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String brandModel; private String brandModel;
/** /**
* 发动机号 * 发动机号
*/ */
@Length(max = 20, message = "参数engineNumber长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数engineNumber长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String engineNumber; private String engineNumber;
/** /**
* 发证日期 * 发证日期
*/ */
@Length(max = 20, message = "参数vehicleLicenseIssuedDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数vehicleLicenseIssuedDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String vehicleLicenseIssuedDate; private String vehicleLicenseIssuedDate;
/** /**
* 检验有效期至 * 检验有效期至
*/ */
@Length(max = 20, message = "参数vehicleLicenseExpireDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数vehicleLicenseExpireDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String vehicleLicenseExpireDate; private String vehicleLicenseExpireDate;
/** /**
* 发证机关 * 发证机关
*/ */
@Length(max = 50, message = "参数vehicleLicenseIssueDepartment长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数vehicleLicenseIssueDepartment长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String vehicleLicenseIssueDepartment; private String vehicleLicenseIssueDepartment;
/** /**
* 道路运输证号 * 道路运输证号
*/ */
@Length(max = 50, message = "参数roadCertificateNumber长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数roadCertificateNumber长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String roadCertificateNumber; private String roadCertificateNumber;
/** /**
* 经营许可证号 * 经营许可证号
*/ */
@Length(max = 20, message = "参数businessLicenseNumber长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数businessLicenseNumber长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String businessLicenseNumber; private String businessLicenseNumber;
/** /**
* 经营许可证有效期至 * 经营许可证有效期至
*/ */
@Length(max = 20, message = "参数businessLicenseExpireDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数businessLicenseExpireDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String businessLicenseExpireDate; private String businessLicenseExpireDate;
/** /**
* 车籍地-省份代码 * 车籍地-省份代码
*/ */
@Length(max = 6, message = "参数vehicleProvinceCode长度不合法", groups = {ValidatorInsert.class}) @Length(max = 6, message = "参数vehicleProvinceCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleProvinceCode不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleProvinceCode不能为空", groups = {ValidatorInsert.class})
private String vehicleProvinceCode; private String vehicleProvinceCode;
/** /**
* 车籍地-市代码 * 车籍地-市代码
*/ */
@Length(max = 6, message = "参数vehicleCityCode长度不合法", groups = {ValidatorInsert.class}) @Length(max = 6, message = "参数vehicleCityCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleCityCode不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleCityCode不能为空", groups = {ValidatorInsert.class})
private String vehicleCityCode; private String vehicleCityCode;
/** /**
* 车籍地-区县代码 * 车籍地-区县代码
*/ */
@Length(max = 6, message = "参数vehicleDistrictCode长度不合法", groups = {ValidatorInsert.class}) @Length(max = 6, message = "参数vehicleDistrictCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleDistrictCode不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleDistrictCode不能为空", groups = {ValidatorInsert.class})
private String vehicleDistrictCode; private String vehicleDistrictCode;
/** /**
* 是否开通ETC:1-已开通、2-未开通、3-未知 * 是否开通ETC:1-已开通、2-未开通、3-未知
*/ */
@Pattern(regexp = "[12]", message = "参数etc不合法", groups = {ValidatorInsert.class}) @Pattern(regexp = "[12]", message = "参数etc不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String etc; private String etc;
/**
* 上报状态(字典表):0-未上报、1-上报成功、2-上报失败
*/
@Range(min = 0, max = 2, message = "参数uploadState不合法", groups = {ValidatorInsert.class})
private Integer uploadState;
/**
* 上报时间
*/
private String uploadTime;
/** /**
* 车头照片URL * 车头照片URL
*/ */
@Length(max = 200, message = "参数vehicleHeadUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数vehicleHeadUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String vehicleHeadUrl; private String vehicleHeadUrl;
/** /**
* 人车合照URL * 人车合照URL
*/ */
@Length(max = 200, message = "参数vehicleHeadPersonUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数vehicleHeadPersonUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String vehicleHeadPersonUrl; private String vehicleHeadPersonUrl;
/** /**
* 行驶证正面URL * 行驶证正面URL
*/ */
@Length(max = 200, message = "参数vehicleLicenseFrontUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleLicenseFrontUrl不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleLicenseFrontUrl不能为空", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数vehicleLicenseFrontUrl长度不合法", groups = {ValidatorInsert.class})
private String vehicleLicenseFrontUrl; private String vehicleLicenseFrontUrl;
/** /**
* 行驶证背面URL * 行驶证背面URL
*/ */
@Length(max = 200, message = "参数vehicleLicenseBackUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数vehicleLicenseBackUrl不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数vehicleLicenseBackUrl不能为空", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数vehicleLicenseBackUrl长度不合法", groups = {ValidatorInsert.class})
private String vehicleLicenseBackUrl; private String vehicleLicenseBackUrl;
/** /**
* 道路运输证正面URL * 道路运输证正面URL
*/ */
@Length(max = 200, message = "参数roadCertificateFrontUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数roadCertificateFrontUrl不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数roadCertificateFrontUrl不能为空", groups = {ValidatorInsert.class})
@Length(max = 200, message = "参数roadCertificateFrontUrl长度不合法", groups = {ValidatorInsert.class})
private String roadCertificateFrontUrl; private String roadCertificateFrontUrl;
/** /**
* 挂靠声明URL * 挂靠声明URL
*/ */
@Length(max = 200, message = "参数attachedStatementUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数attachedStatementUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String attachedStatementUrl; private String attachedStatementUrl;
@Override @Override
......
...@@ -22,5 +22,14 @@ public interface VehicleService extends IService<VehicleEntity> { ...@@ -22,5 +22,14 @@ public interface VehicleService extends IService<VehicleEntity> {
**/ **/
Long insertVehicle(VehicleInfoForm form); Long insertVehicle(VehicleInfoForm form);
/**
* description 更新车辆信息
* param [form]
* return java.lang.Integer
* author Administrator
* createTime 2020/04/27 9:23
**/
Integer updateVehicle(VehicleInfoForm form);
} }
package com.esv.freight.customer.module.vehicle.service.impl; package com.esv.freight.customer.module.vehicle.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.common.component.ErrorMessageComponent; import com.esv.freight.customer.common.component.ErrorMessageComponent;
import com.esv.freight.customer.common.exception.EException; import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.common.util.ReqUtils; import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity; import com.esv.freight.customer.module.carrier.entity.CarrierAccountEntity;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService; import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
...@@ -17,11 +19,14 @@ import com.esv.freight.customer.module.vehicle.service.AttachmentService; ...@@ -17,11 +19,14 @@ import com.esv.freight.customer.module.vehicle.service.AttachmentService;
import com.esv.freight.customer.module.vehicle.service.VehicleAuditHistoryService; import com.esv.freight.customer.module.vehicle.service.VehicleAuditHistoryService;
import com.esv.freight.customer.module.vehicle.service.VehicleService; import com.esv.freight.customer.module.vehicle.service.VehicleService;
import com.esv.gateway.common.GatewayHeaders; import com.esv.gateway.common.GatewayHeaders;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
@Service("vehicleService") @Service("vehicleService")
public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> implements VehicleService { public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> implements VehicleService {
...@@ -71,6 +76,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i ...@@ -71,6 +76,7 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
// 2:新增车辆 // 2:新增车辆
VehicleEntity vehicleEntity = new VehicleEntity(); VehicleEntity vehicleEntity = new VehicleEntity();
BeanUtils.copyProperties(form, vehicleEntity); BeanUtils.copyProperties(form, vehicleEntity);
vehicleEntity.setId(null);
vehicleEntity.setVehicleStatus(VehicleConstants.VEHICLE_ACCOUNT_STATUS_UNBLOCK); vehicleEntity.setVehicleStatus(VehicleConstants.VEHICLE_ACCOUNT_STATUS_UNBLOCK);
vehicleEntity.setAuditStatus(VehicleConstants.VEHICLE_AUDIT_STATUS_SUCCESS); vehicleEntity.setAuditStatus(VehicleConstants.VEHICLE_AUDIT_STATUS_SUCCESS);
vehicleEntity.setSourceType(VehicleConstants.VEHICLE_SOURCE_TYPE_PLATFORM); vehicleEntity.setSourceType(VehicleConstants.VEHICLE_SOURCE_TYPE_PLATFORM);
...@@ -95,4 +101,63 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i ...@@ -95,4 +101,63 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleDao, VehicleEntity> i
return vehicleId; return vehicleId;
} }
@Override
public Integer updateVehicle(VehicleInfoForm form) {
// 1:校验
// 1.1校验车辆ID是否有效
VehicleEntity vehicleEntity = this.baseMapper.selectById(form.getId());
if (null == vehicleEntity) {
throw new EException(1001, errorMessageComponent.getCarrierVehicleEdit1001());
}
// 1.2校验车牌号是否存在
int count = 0;
if (StringUtils.isNotBlank(form.getLicenseNumber())) {
this.baseMapper.selectCount(new QueryWrapper<VehicleEntity>().lambda()
.ne(VehicleEntity::getId, form.getId())
.eq(VehicleEntity::getLicenseNumber, form.getLicenseNumber()));
if (0 < count) {
throw new EException(1002, errorMessageComponent.getCarrierVehicleEdit1002());
}
}
// 1.3校验行驶证档案编号是否存在
if (StringUtils.isNotBlank(form.getVehicleLicenseNumber())) {
count = this.baseMapper.selectCount(new QueryWrapper<VehicleEntity>().lambda()
.ne(VehicleEntity::getId, form.getId())
.eq(VehicleEntity::getVehicleLicenseNumber, form.getVehicleLicenseNumber()));
if (0 < count) {
throw new EException(1003, errorMessageComponent.getCarrierVehicleEdit1003());
}
}
// 1.4校验道路运输证号是否存在
if (StringUtils.isNotBlank(form.getRoadCertificateNumber())) {
count = this.baseMapper.selectCount(new QueryWrapper<VehicleEntity>().lambda()
.ne(VehicleEntity::getId, form.getId())
.eq(VehicleEntity::getRoadCertificateNumber, form.getRoadCertificateNumber()));
if (0 < count) {
throw new EException(1004, errorMessageComponent.getCarrierVehicleEdit1004());
}
}
// 道路运输证号,4.5吨及以下普货车辆可以为空
BigDecimal bigDecimal4_5 = new BigDecimal("4.5");
if (-1 == bigDecimal4_5.compareTo(form.getLoadCapacity())
&& StringUtils.isBlank(form.getRoadCertificateNumber())
&& StringUtils.isBlank(vehicleEntity.getRoadCertificateNumber())) {
throw new EException(ECode.PARAM_ERROR.code(), "4.5顿以上载重的车辆,道路运输证号不能为空");
}
// 2:更新车辆信息
int flag = 0;
vehicleEntity = new VehicleEntity();
BeanUtils.copyProperties(form, vehicleEntity);
flag += this.baseMapper.updateById(vehicleEntity);
// 3:更新车辆附件
AttachmentEntity attachmentEntity = new AttachmentEntity();
BeanUtils.copyProperties(form, attachmentEntity);
flag += this.attachmentService.getBaseMapper().update(attachmentEntity,
new UpdateWrapper<AttachmentEntity>().lambda().eq(AttachmentEntity::getVehicleId, form.getId()));
return flag;
}
} }
\ No newline at end of file
...@@ -125,4 +125,9 @@ error-message: ...@@ -125,4 +125,9 @@ error-message:
1001: 无效的承运商ID 1001: 无效的承运商ID
1002: 车牌号已存在 1002: 车牌号已存在
1003: 行驶证档案编号已存在 1003: 行驶证档案编号已存在
1004: 道路运输证号已存在
edit:
1001: 无效的车辆ID
1002: 车牌号已存在
1003: 行驶证档案编号已存在
1004: 道路运输证号已存在 1004: 道路运输证号已存在
\ No newline at end of file
...@@ -25,7 +25,7 @@ import java.math.BigDecimal; ...@@ -25,7 +25,7 @@ import java.math.BigDecimal;
/** /**
* @description: * @description:
* @project: freight-customer-service * @project: freight-customer-service
* @name: com.esv.freight.customer.module.vehicle.controller.VehicleControllerTest * @name: com.esv.freight.customer.module.vehicle.controller.VehicleControllerAddTest
* @author: 黄朝斌 * @author: 黄朝斌
* @email: huangchaobin@esvtek.com * @email: huangchaobin@esvtek.com
* @createTime: 2020/04/26 15:27 * @createTime: 2020/04/26 15:27
......
package com.esv.freight.customer.module.vehicle.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.vehicle.form.VehicleInfoForm;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.vehicle.controller.VehicleControllerEditTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/26 15:27
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class VehicleControllerEditTest extends BaseTestController {
/**
* 编辑车辆信息
**/
@Test
public void a1_edit_success_test() throws Exception {
String url = "/carrier/vehicle/edit";
// 构造数据
VehicleInfoForm form = new VehicleInfoForm();
form.setId(1L);
form.setCarrierId(2L);
form.setLicenseNumber("辽A12311");
form.setLicenseType(2); // 牌照类型(字典表):1-大型汽车号牌、2-小型汽车号牌、3-其他号牌
form.setVehicleType(14); // 车辆类型(字典表):14-微型货车
form.setVehicleType2(1402); // 二级车辆类型(字典表):1402-微型厢式货车
form.setLicenseColor(1); // 车牌颜色(字典表):1-蓝色、2-黄色、3-黑色、4-白色、5-绿色、6-农黄色、7-农绿色、8-黄绿色、9-渐变绿、0-其他
form.setVehicleLength(4800);
form.setVehicleWidth(1900);
form.setVehicleHeight(2100);
form.setVehicleBelong(1); // 车辆所属(字典表):1-自有车、2-外协车
form.setYearAuditDate("20191018");
form.setEnergyType(2); // 能源类型(字典表):1-汽油、2-柴油、3-电、4-混合油、5-天然气、6-液化石油气、7-甲醇、8-乙醇、9-太阳能、10-混合动力、0-其他
form.setVehicleLicenseNumber("210102123456");
form.setLoadCapacity(new BigDecimal("4.0"));
form.setTotalMass(new BigDecimal("5.1"));
form.setVehicleOwner("辽宁省沈阳市恒源物流有限公司");
form.setVehicleOwnerCode("91310107MA1G11CY6D");
form.setUseNature("营运");
form.setRegisterDate("20150618");
form.setVin("LGWEF6A59HH505511");
form.setBrandModel("京杯");
form.setEngineNumber("S12345678");
form.setVehicleLicenseIssuedDate("20160618");
form.setVehicleLicenseIssueDepartment("辽宁省沈阳市公安局交通警察支队");
form.setVehicleProvinceCode("210000");
form.setVehicleCityCode("210100");
form.setVehicleDistrictCode("210103");
form.setEtc("1"); // 是否开通ETC:1-已开通、2-未开通、3-未知
form.setVehicleHeadUrl("http://127.0.0.1/Vehicle_Head_Url_001.jpg");
form.setVehicleHeadPersonUrl("http://127.0.0.1/Vehicle_Head_Person_Url_001.jpg");
form.setVehicleLicenseFrontUrl("http://127.0.0.1/Vehicle_License_Front_Url_001.jpg");
form.setVehicleLicenseBackUrl("http://127.0.0.1/Vehicle_License_Back_Url_001.jpg");
form.setRoadCertificateFrontUrl("http://127.0.0.1/Road_Certificate_Front_Url_001.jpg");
form.setAttachedStatementUrl("http://127.0.0.1/Attached_Statement_Url_001.jpg");
JSONObject reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.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"));
}
/**
* 编辑车辆信息:无效的车辆ID
**/
@Test
public void a2_edit_vehicle_wrong_id_success_test() throws Exception {
String url = "/carrier/vehicle/edit";
// 构造数据
VehicleInfoForm form = new VehicleInfoForm();
form.setId(99999L);
form.setCarrierId(2L);
form.setLicenseNumber("辽A12311");
form.setLicenseType(2); // 牌照类型(字典表):1-大型汽车号牌、2-小型汽车号牌、3-其他号牌
form.setVehicleType(14); // 车辆类型(字典表):14-微型货车
form.setVehicleType2(1402); // 二级车辆类型(字典表):1402-微型厢式货车
form.setLicenseColor(1); // 车牌颜色(字典表):1-蓝色、2-黄色、3-黑色、4-白色、5-绿色、6-农黄色、7-农绿色、8-黄绿色、9-渐变绿、0-其他
form.setVehicleLength(4800);
form.setVehicleWidth(1900);
form.setVehicleHeight(2100);
form.setVehicleBelong(1); // 车辆所属(字典表):1-自有车、2-外协车
form.setYearAuditDate("20191018");
form.setEnergyType(2); // 能源类型(字典表):1-汽油、2-柴油、3-电、4-混合油、5-天然气、6-液化石油气、7-甲醇、8-乙醇、9-太阳能、10-混合动力、0-其他
form.setVehicleLicenseNumber("210102123456");
form.setLoadCapacity(new BigDecimal("4.0"));
form.setTotalMass(new BigDecimal("5.1"));
JSONObject reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code"));
}
/**
* 编辑车辆信息:车牌号已存在
**/
@Test
public void a3_edit_vehicle_wrong_licenseNumber_failure_test() throws Exception {
String url = "/carrier/vehicle/edit";
// 构造数据
VehicleInfoForm form = new VehicleInfoForm();
form.setId(1L);
form.setLicenseNumber("辽A12302");
JSONObject reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1002, result.getIntValue("code"));
}
/**
* 编辑车辆信息:行驶证档案编号已存在
**/
@Test
public void a4_edit_vehicle_wrong_vehicleLicenseNumber_failure_test() throws Exception {
String url = "/carrier/vehicle/edit";
// 构造数据
VehicleInfoForm form = new VehicleInfoForm();
form.setId(1L);
form.setVehicleLicenseNumber("210101123457");
JSONObject reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1003, result.getIntValue("code"));
}
/**
* 编辑车辆信息:道路运输证号已存在
**/
@Test
public void a5_edit_vehicle_wrong_roadCertificateNumber_failure_test() throws Exception {
String url = "/carrier/vehicle/edit";
// 构造数据
VehicleInfoForm form = new VehicleInfoForm();
form.setId(1L);
form.setRoadCertificateNumber("510184010714");
JSONObject reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1004, result.getIntValue("code"));
}
/**
* 编辑车辆信息:道路运输证号,4.5吨及以下普货车辆可以为空
**/
@Test
public void a6_edit_vehicle_wrong_roadCertificateNumber_failure_test() throws Exception {
String url = "/carrier/vehicle/edit";
// 构造数据
VehicleInfoForm form = new VehicleInfoForm();
form.setId(1L);
form.setLoadCapacity(new BigDecimal("5.0"));
JSONObject reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.PARAM_ERROR.code(), result.getIntValue("code"));
}
}
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