bug修复
This commit is contained in:
@ -132,6 +132,10 @@ public class CompanyController extends BaseController
|
||||
{
|
||||
return error("新增失败,手机号码已存在");
|
||||
}
|
||||
if (Company.NOT_UNIQUE.equals(companyService.checkNameUnique(company)))
|
||||
{
|
||||
return error("新增失败,运营商名称'" + company.getCompanyName() + "'已存在");
|
||||
}
|
||||
company.setCreateBy(getLoginName());
|
||||
int flag = companyService.insertCompany(company);
|
||||
if(flag > 0){
|
||||
@ -167,6 +171,10 @@ public class CompanyController extends BaseController
|
||||
{
|
||||
return error("修改失败,手机号码已存在");
|
||||
}
|
||||
if (Company.NOT_UNIQUE.equals(companyService.checkNameUnique(company)))
|
||||
{
|
||||
return error("新增失败,运营商名称'" + company.getCompanyName() + "'已存在");
|
||||
}
|
||||
company.setUpdateBy(getLoginName());
|
||||
int flag = companyService.updateCompany(company);
|
||||
if(flag > 0){
|
||||
|
||||
@ -111,7 +111,13 @@ public class ZcCarController extends BaseController
|
||||
// 校验 VIN 是否唯一
|
||||
if (StringUtils.isNotEmpty(zcCar.getVin())
|
||||
&& OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkVinUnique(zcCar))) {
|
||||
return error("新增失败,车机号已存在");
|
||||
return error("新增失败,车架号已存在");
|
||||
}
|
||||
if (OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkLicensePlateUnique(zcCar))) {
|
||||
return error("新增失败,车牌号已存在");
|
||||
}
|
||||
if (OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkLotNumberUnique(zcCar))) {
|
||||
return error("新增失败,LOT识别号已存在");
|
||||
}
|
||||
return toAjax(zcCarService.insertZcCar(zcCar));
|
||||
}
|
||||
@ -143,9 +149,14 @@ public class ZcCarController extends BaseController
|
||||
// 校验 VIN 是否唯一
|
||||
if (StringUtils.isNotEmpty(zcCar.getVin())
|
||||
&& OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkVinUnique(zcCar))) {
|
||||
return error("修改失败,车机号已存在");
|
||||
return error("修改失败,车架号已存在");
|
||||
}
|
||||
if (OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkLicensePlateUnique(zcCar))) {
|
||||
return error("新增失败,车牌号已存在");
|
||||
}
|
||||
if (OperationConstants.USER_VIN_NOT_UNIQUE.equals(zcCarService.checkLotNumberUnique(zcCar))) {
|
||||
return error("新增失败,LOT识别号已存在");
|
||||
}
|
||||
|
||||
return toAjax(zcCarService.updateZcCar(zcCar));
|
||||
}
|
||||
|
||||
|
||||
@ -114,13 +114,15 @@ public class ZcRentCarRuleController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(@RequestParam(value = "batteryRules",required = false) List<Long> batteryRuleIds, ZcRentCarRule zcRentCarRule)
|
||||
{
|
||||
StringBuffer remark = new StringBuffer();
|
||||
// 如果是按天租,验证选择的租电套餐支持天数是否一致
|
||||
if("3".equals(zcRentCarRule.getRentalType())){
|
||||
if("2".equals(zcRentCarRule.getRentalType()) || "3".equals(zcRentCarRule.getRentalType())){
|
||||
String[] stringArray = batteryRuleIds.stream()
|
||||
.map(String::valueOf)
|
||||
.toArray(String[]::new);
|
||||
List<ZcRentBatteyRule> batteyRuleList = zcRentBatteyRuleService.selectZcRentBatteyRuleByIds(stringArray);
|
||||
for (ZcRentBatteyRule batteyRule : batteyRuleList) {
|
||||
if("3".equals(zcRentCarRule.getRentalType())) {
|
||||
//2标识按天租,或者租电套餐1标识日租中租赁天数大于1天也为按天租
|
||||
Long duration = batteyRule.getDuration();
|
||||
if (batteyRule.getDurationType() == 2) {
|
||||
@ -130,7 +132,13 @@ public class ZcRentCarRuleController extends BaseController
|
||||
return error("选择租电套餐的租赁天数与租车套餐的租赁天数不一致。");
|
||||
}
|
||||
}
|
||||
remark.append(batteyRule.getCityName()).append(batteyRule.getTitle()).append(",");
|
||||
}
|
||||
}
|
||||
if("2".equals(zcRentCarRule.getRentalType())){
|
||||
zcRentCarRule.setRentalDays(1L);
|
||||
}
|
||||
zcRentCarRule.setRemark(remark.toString());
|
||||
zcRentCarRule.setRuleCode(generateTimestampBasedCode());
|
||||
zcRentCarRule.setCreateBy(getLoginName());
|
||||
int flag = zcRentCarRuleService.insertZcRentCarRule(zcRentCarRule);
|
||||
|
||||
@ -179,6 +179,9 @@ public class Company extends BaseEntity
|
||||
/** */
|
||||
private String extend5;
|
||||
|
||||
public final static String UNIQUE = "0";
|
||||
public final static String NOT_UNIQUE = "1";
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
|
||||
@ -26,7 +26,7 @@ public interface CompanyMapper
|
||||
* @return 运营商对象
|
||||
*/
|
||||
Company checkPhoneUnique(String phone);
|
||||
|
||||
public Company checkNameUnique(String name);
|
||||
/**
|
||||
* 查询运营商列表
|
||||
*
|
||||
|
||||
@ -63,4 +63,8 @@ public interface ZcCarMapper
|
||||
public int deleteZcCarByIds(String[] ids);
|
||||
|
||||
public ZcCar checkVinUnique(String vin);
|
||||
|
||||
public ZcCar checkLicensePlateUnique(String licensePlate);
|
||||
|
||||
public ZcCar checkLotNumberUnique(String lotNumber);
|
||||
}
|
||||
|
||||
@ -73,4 +73,6 @@ public interface ICompanyService
|
||||
public int deleteCompanyById(Long id);
|
||||
|
||||
public int changeStatus(Company company);
|
||||
|
||||
public String checkNameUnique(Company company);
|
||||
}
|
||||
|
||||
@ -63,12 +63,16 @@ public interface IZcCarService
|
||||
|
||||
|
||||
/**
|
||||
* 校验车机号 (VIN) 是否唯一
|
||||
* 校验车架号 (VIN) 是否唯一
|
||||
*
|
||||
* @return 是否唯一 (0:唯一, 1:不唯一)
|
||||
*/
|
||||
String checkVinUnique(ZcCar zcCar);
|
||||
|
||||
String checkLicensePlateUnique(ZcCar zcCar);
|
||||
|
||||
String checkLotNumberUnique(ZcCar zcCar);
|
||||
|
||||
public int changeStatus(ZcCar zcCar);
|
||||
|
||||
public String importCar(List<ZcCar> carList, Boolean isUpdateSupport, SysUser user);
|
||||
|
||||
@ -195,4 +195,15 @@ public class CompanyServiceImpl implements ICompanyService
|
||||
return flag;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkNameUnique(Company company) {
|
||||
Long id = StringUtils.isNull(company.getId()) ? -1L : company.getId();
|
||||
Company info = companyMapper.checkNameUnique(company.getCompanyName());
|
||||
if (StringUtils.isNotNull(info) && info.getId().longValue() != id.longValue())
|
||||
{
|
||||
return Company.NOT_UNIQUE;
|
||||
}
|
||||
return Company.UNIQUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,16 +125,45 @@ public class ZcCarServiceImpl implements IZcCarService
|
||||
return zcCarMapper.deleteZcCarById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkVinUnique(ZcCar zcCar) {
|
||||
private String checkFieldUnique(ZcCar zcCar, String fieldName, Object fieldValue) {
|
||||
Long carId = StringUtils.isNull(zcCar.getId()) ? -1L : zcCar.getId();
|
||||
ZcCar info = zcCarMapper.checkVinUnique(zcCar.getVin());
|
||||
ZcCar info = null;
|
||||
|
||||
switch (fieldName) {
|
||||
case "vin":
|
||||
info = zcCarMapper.checkVinUnique((String) fieldValue);
|
||||
break;
|
||||
case "licensePlate":
|
||||
info = zcCarMapper.checkLicensePlateUnique((String) fieldValue);
|
||||
break;
|
||||
case "lotNumber":
|
||||
info = zcCarMapper.checkLotNumberUnique((String) fieldValue);
|
||||
break;
|
||||
default:
|
||||
return OperationConstants.USER_VIN_UNIQUE;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotNull(info) && info.getId().longValue() != carId.longValue()) {
|
||||
return OperationConstants.USER_VIN_NOT_UNIQUE;
|
||||
}
|
||||
return OperationConstants.USER_VIN_UNIQUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkVinUnique(ZcCar zcCar) {
|
||||
return checkFieldUnique(zcCar, "vin", zcCar.getVin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkLicensePlateUnique(ZcCar zcCar) {
|
||||
return checkFieldUnique(zcCar, "licensePlate", zcCar.getLicensePlate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkLotNumberUnique(ZcCar zcCar) {
|
||||
return checkFieldUnique(zcCar, "lotNumber", zcCar.getLotNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int changeStatus(ZcCar zcCar) {
|
||||
zcCar.setUpdateTime(DateUtils.getNowDate());
|
||||
@ -170,8 +199,11 @@ public class ZcCarServiceImpl implements IZcCarService
|
||||
{
|
||||
// 验证是否存在
|
||||
ZcCar u = zcCarMapper.checkVinUnique(car.getVin());
|
||||
if (StringUtils.isNull(u))
|
||||
{
|
||||
ZcCar u2 = zcCarMapper.checkLicensePlateUnique(car.getLicensePlate());
|
||||
ZcCar u3 = zcCarMapper.checkLotNumberUnique(car.getLotNumber());
|
||||
|
||||
// 只有当所有唯一性校验都通过时才插入数据
|
||||
if (StringUtils.isNull(u) && StringUtils.isNull(u2) && StringUtils.isNull(u3)) {
|
||||
// 车辆归属字典转换
|
||||
car.setBelongType(DictUtils.getDictValue("key_car_belong_type", car.getBelongType(), car.getBelongType()));
|
||||
// 设置运营商ID
|
||||
@ -186,20 +218,23 @@ public class ZcCarServiceImpl implements IZcCarService
|
||||
car.setCreateBy(user.getLoginName());
|
||||
|
||||
this.insertZcCar(car);
|
||||
// processedList.add(car);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、车机号 " + car.getVin() + " 导入成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
successMsg.append("<br/>" + successNum + "导入成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、车机号 " + car.getVin() + " 已存在");
|
||||
if (StringUtils.isNotNull(u)) {
|
||||
failureMsg.append("<br/>" + failureNum + "、车架号 " + car.getVin() + " 已存在");
|
||||
} else if (StringUtils.isNotNull(u2)) {
|
||||
failureMsg.append("<br/>" + failureNum + "、车牌号 " + car.getLicensePlate() + " 已存在");
|
||||
} else if (StringUtils.isNotNull(u3)) {
|
||||
failureMsg.append("<br/>" + failureNum + "、Lot号 " + car.getLotNumber() + " 已存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、车机号 " + car.getVin() + " 导入失败:";
|
||||
String msg = "<br/>" + failureNum + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
log.error(msg, e);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ package com.ruoyi.operation.util;
|
||||
public class OperationConstants {
|
||||
|
||||
/**
|
||||
* 车机号 (VIN) 唯一
|
||||
* 车架号 (VIN) 唯一
|
||||
*/
|
||||
public static final String USER_VIN_UNIQUE = "0";
|
||||
public static final String USER_VIN_NOT_UNIQUE = "1";
|
||||
|
||||
@ -111,6 +111,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="checkPhoneUnique" parameterType="string" resultType="com.ruoyi.operation.domain.Company">
|
||||
SELECT * FROM zc_company WHERE del_flag = 0 AND phone = #{phone}
|
||||
</select>
|
||||
<select id="checkNameUnique" resultType="com.ruoyi.operation.domain.Company">
|
||||
SELECT * FROM zc_company WHERE del_flag = 0 AND company_name = #{companyName} limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertCompany" parameterType="Company" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zc_company
|
||||
|
||||
@ -50,6 +50,7 @@
|
||||
<select id="selectZcCarDamageList" parameterType="ZcCarDamage" resultMap="ZcCarDamageResult">
|
||||
<include refid="selectZcCarDamageVo"/>
|
||||
<where>
|
||||
a.del_flag = 0
|
||||
<if test="carId != null "> and a.car_id = #{carId}</if>
|
||||
<if test="damageType != null and damageType != ''"> and a.damage_type = #{damageType}</if>
|
||||
<if test="damageReason != null and damageReason != ''"> and a.damage_reason = #{damageReason}</if>
|
||||
|
||||
@ -50,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectZcCarList" parameterType="ZcCar" resultMap="ZcCarResult">
|
||||
<include refid="selectZcCarVo"/>
|
||||
<where>
|
||||
del_flag = 0
|
||||
<if test="vin != null and vin != ''"> and vin like concat('%', #{vin}, '%')</if>
|
||||
<if test="licensePlate != null and licensePlate != ''"> and license_plate like concat('%', #{licensePlate}, '%')</if>
|
||||
<if test="brandId != null "> and brand_id = #{brandId}</if>
|
||||
@ -86,7 +87,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="checkVinUnique" resultType="com.ruoyi.operation.domain.ZcCar">
|
||||
SELECT * FROM zc_car WHERE del_flag = 0 AND vin = #{vin}
|
||||
</select>
|
||||
|
||||
<select id="checkLicensePlateUnique" resultType="com.ruoyi.operation.domain.ZcCar">
|
||||
SELECT * FROM zc_car WHERE del_flag = 0 AND license_plate = #{licensePlate} limit 1
|
||||
</select>
|
||||
<select id="checkLotNumberUnique" resultType="com.ruoyi.operation.domain.ZcCar">
|
||||
SELECT * FROM zc_car WHERE del_flag = 0 AND lot_number = #{lotNumber} limit 1
|
||||
</select>
|
||||
<insert id="insertZcCar" parameterType="ZcCar" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into zc_car
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectZcCarModelList" parameterType="ZcCarModel" resultMap="ZcCarModelResult">
|
||||
<include refid="selectZcCarModelVo"/>
|
||||
<where>
|
||||
del_flag = 0
|
||||
<if test="modelName != null and modelName != ''"> and model_name like concat('%', #{modelName}, '%')</if>
|
||||
<if test="brandId != null"> and brand_id = #{brandId}</if>
|
||||
<if test="brandName != null and brandName != ''"> and brand_name like concat('%', #{brandName}, '%')</if>
|
||||
|
||||
@ -88,7 +88,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectZcRentBatteyRuleByIds" resultMap="ZcRentBatteyRuleResult">
|
||||
select * from zc_rent_battey_rule where id in
|
||||
<include refid="selectZcRentBatteyRuleVo2"/>
|
||||
where a.id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">车辆归属:</label>
|
||||
<div class="col-sm-8">
|
||||
<select readonly name="belongType" class="form-control m-b" th:with="type=${@dict.getType('key_car_belong_type')}">
|
||||
<select disabled name="belongType" class="form-control m-b" th:with="type=${@dict.getType('key_car_belong_type')}">
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{belongType}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user