bug修复
This commit is contained in:
@ -90,6 +90,10 @@ public class ZcCarBrandController extends BaseController
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult addSave(ZcCarBrand zcCarBrand)
|
public AjaxResult addSave(ZcCarBrand zcCarBrand)
|
||||||
{
|
{
|
||||||
|
if (ZcCarBrand.NOT_UNIQUE.equals(zcCarBrandService.checkNameUnique(zcCarBrand)))
|
||||||
|
{
|
||||||
|
return error("新增失败,品牌名称'" + zcCarBrand.getBrandName() + "'已存在");
|
||||||
|
}
|
||||||
return toAjax(zcCarBrandService.insertZcCarBrand(zcCarBrand));
|
return toAjax(zcCarBrandService.insertZcCarBrand(zcCarBrand));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +118,10 @@ public class ZcCarBrandController extends BaseController
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult editSave(ZcCarBrand zcCarBrand)
|
public AjaxResult editSave(ZcCarBrand zcCarBrand)
|
||||||
{
|
{
|
||||||
|
if (ZcCarBrand.NOT_UNIQUE.equals(zcCarBrandService.checkNameUnique(zcCarBrand)))
|
||||||
|
{
|
||||||
|
return error("新增失败,品牌名称'" + zcCarBrand.getBrandName() + "'已存在");
|
||||||
|
}
|
||||||
return toAjax(zcCarBrandService.updateZcCarBrand(zcCarBrand));
|
return toAjax(zcCarBrandService.updateZcCarBrand(zcCarBrand));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,9 @@ public class ZcCarBrand extends BaseEntity
|
|||||||
/** 车型管理信息 */
|
/** 车型管理信息 */
|
||||||
private List<ZcCarModel> zcCarModelList;
|
private List<ZcCarModel> zcCarModelList;
|
||||||
|
|
||||||
|
public final static String UNIQUE = "0";
|
||||||
|
public final static String NOT_UNIQUE = "1";
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|||||||
@ -84,4 +84,6 @@ public interface ZcCarBrandMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteZcCarModelByBrandId(Long id);
|
public int deleteZcCarModelByBrandId(Long id);
|
||||||
|
|
||||||
|
public ZcCarBrand checkNameUnique(ZcCarBrand zcCarBrand);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,4 +58,6 @@ public interface IZcCarBrandService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteZcCarBrandById(Long id);
|
public int deleteZcCarBrandById(Long id);
|
||||||
|
|
||||||
|
public String checkNameUnique(ZcCarBrand zcCarBrand);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.ruoyi.operation.service.impl;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.operation.domain.Company;
|
||||||
import com.ruoyi.operation.service.IZcCarModelService;
|
import com.ruoyi.operation.service.IZcCarModelService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -118,6 +119,17 @@ public class ZcCarBrandServiceImpl implements IZcCarBrandService
|
|||||||
return zcCarBrandMapper.deleteZcCarBrandById(id);
|
return zcCarBrandMapper.deleteZcCarBrandById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String checkNameUnique(ZcCarBrand zcCarBrand) {
|
||||||
|
Long id = StringUtils.isNull(zcCarBrand.getId()) ? -1L : zcCarBrand.getId();
|
||||||
|
ZcCarBrand info = zcCarBrandMapper.checkNameUnique(zcCarBrand);
|
||||||
|
if (StringUtils.isNotNull(info) && info.getId().longValue() != id.longValue())
|
||||||
|
{
|
||||||
|
return ZcCarBrand.NOT_UNIQUE;
|
||||||
|
}
|
||||||
|
return ZcCarBrand.UNIQUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增车型管理信息
|
* 新增车型管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@ -12,18 +12,14 @@ import com.ruoyi.common.utils.DictUtils;
|
|||||||
import com.ruoyi.common.utils.ShiroUtils;
|
import com.ruoyi.common.utils.ShiroUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.common.utils.bean.BeanValidators;
|
import com.ruoyi.common.utils.bean.BeanValidators;
|
||||||
import com.ruoyi.operation.domain.Company;
|
import com.ruoyi.operation.domain.*;
|
||||||
import com.ruoyi.operation.domain.CompanyStore;
|
import com.ruoyi.operation.service.*;
|
||||||
import com.ruoyi.operation.service.ICompanyService;
|
|
||||||
import com.ruoyi.operation.service.ICompanyStoreService;
|
|
||||||
import com.ruoyi.operation.util.OperationConstants;
|
import com.ruoyi.operation.util.OperationConstants;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
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 com.ruoyi.operation.mapper.ZcCarMapper;
|
import com.ruoyi.operation.mapper.ZcCarMapper;
|
||||||
import com.ruoyi.operation.domain.ZcCar;
|
|
||||||
import com.ruoyi.operation.service.IZcCarService;
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -47,6 +43,10 @@ public class ZcCarServiceImpl implements IZcCarService
|
|||||||
private ICompanyService companyService;
|
private ICompanyService companyService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ICompanyStoreService companyStoreService;
|
private ICompanyStoreService companyStoreService;
|
||||||
|
@Autowired
|
||||||
|
private IZcCarBrandService zcCarBrandService;
|
||||||
|
@Autowired
|
||||||
|
private IZcCarModelService zcCarModelService;
|
||||||
|
|
||||||
protected Validator validator;
|
protected Validator validator;
|
||||||
|
|
||||||
@ -187,6 +187,17 @@ public class ZcCarServiceImpl implements IZcCarService
|
|||||||
Map<String, Long> storeMap = storeList.stream()
|
Map<String, Long> storeMap = storeList.stream()
|
||||||
.collect(Collectors.toMap(CompanyStore::getName, CompanyStore::getId));
|
.collect(Collectors.toMap(CompanyStore::getName, CompanyStore::getId));
|
||||||
|
|
||||||
|
// 一次性查询所有品牌,构建成 Map 用于快速查找
|
||||||
|
List<ZcCarBrand> carBrandList = zcCarBrandService.selectZcCarBrandList(new ZcCarBrand());
|
||||||
|
Map<String, Long> carBrandMap = carBrandList.stream()
|
||||||
|
.collect(Collectors.toMap(ZcCarBrand::getBrandName, ZcCarBrand::getId));
|
||||||
|
|
||||||
|
// 一次性查询所有型号,构建成 Map 用于快速查找
|
||||||
|
List<ZcCarModel> carModelList = zcCarModelService.selectZcCarModelList(new ZcCarModel());
|
||||||
|
Map<String, Long> carModelMap = carModelList.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
item -> item.getBrandName() + "-" + item.getModelName(),
|
||||||
|
ZcCarModel::getId));
|
||||||
|
|
||||||
int successNum = 0;
|
int successNum = 0;
|
||||||
int failureNum = 0;
|
int failureNum = 0;
|
||||||
@ -204,6 +215,23 @@ public class ZcCarServiceImpl implements IZcCarService
|
|||||||
|
|
||||||
// 只有当所有唯一性校验都通过时才插入数据
|
// 只有当所有唯一性校验都通过时才插入数据
|
||||||
if (StringUtils.isNull(u) && StringUtils.isNull(u2) && StringUtils.isNull(u3)) {
|
if (StringUtils.isNull(u) && StringUtils.isNull(u2) && StringUtils.isNull(u3)) {
|
||||||
|
// 设置品牌
|
||||||
|
if (StringUtils.isNotEmpty(car.getBrandName()) && carBrandMap.containsKey(car.getBrandName())) {
|
||||||
|
car.setBrandId(carBrandMap.get(car.getBrandName()));
|
||||||
|
}else{
|
||||||
|
failureNum++;
|
||||||
|
failureMsg.append("<br/>" + failureNum + "、车辆品牌 " + car.getBrandName() + " 不存在");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 设置车型
|
||||||
|
if (StringUtils.isNotEmpty(car.getModelName()) && carModelMap.containsKey(car.getBrandName()+"-"+car.getModelName())) {
|
||||||
|
car.setModelId(carModelMap.get(car.getBrandName()+"-"+car.getModelName()));
|
||||||
|
}else{
|
||||||
|
failureNum++;
|
||||||
|
failureMsg.append("<br/>" + failureNum + "、车辆品牌 " + car.getBrandName() + " 的车辆型号 " + car.getModelName() + " 不存在");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// 设置运营商ID
|
// 设置运营商ID
|
||||||
if (StringUtils.isNotEmpty(car.getOperatorName()) && companyMap.containsKey(car.getOperatorName())) {
|
if (StringUtils.isNotEmpty(car.getOperatorName()) && companyMap.containsKey(car.getOperatorName())) {
|
||||||
car.setOperatorId(companyMap.get(car.getOperatorName()));
|
car.setOperatorId(companyMap.get(car.getOperatorName()));
|
||||||
|
|||||||
@ -68,7 +68,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
left join zc_car_model b on b.brand_id = a.id
|
left join zc_car_model b on b.brand_id = a.id
|
||||||
where a.id = #{id}
|
where a.id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="checkNameUnique" resultType="com.ruoyi.operation.domain.ZcCarBrand">
|
||||||
|
SELECT * FROM zc_car_brand WHERE del_flag = 0 AND brand_name = #{brandName} limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertZcCarBrand" parameterType="ZcCarBrand" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertZcCarBrand" parameterType="ZcCarBrand" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into zc_car_brand
|
insert into zc_car_brand
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
|||||||
@ -142,6 +142,7 @@
|
|||||||
url: prefix + "/list",
|
url: prefix + "/list",
|
||||||
createUrl: prefix + "/add",
|
createUrl: prefix + "/add",
|
||||||
updateUrl: prefix + "/edit/{id}",
|
updateUrl: prefix + "/edit/{id}",
|
||||||
|
detailUrl: ctx + "orders/order/edit/{id}",
|
||||||
removeUrl: prefix + "/remove",
|
removeUrl: prefix + "/remove",
|
||||||
exportUrl: prefix + "/export",
|
exportUrl: prefix + "/export",
|
||||||
modalName: "订单分成统计",
|
modalName: "订单分成统计",
|
||||||
|
|||||||
Reference in New Issue
Block a user