Commit 38cc1512 by 刘宇峰

车型管理

1 parent 7661aeaa
...@@ -9,12 +9,10 @@ import cn.com.glsx.admin.modules.model.param.*; ...@@ -9,12 +9,10 @@ import cn.com.glsx.admin.modules.model.param.*;
import cn.com.glsx.admin.modules.service.DeviceService; import cn.com.glsx.admin.modules.service.DeviceService;
import cn.com.glsx.admin.modules.service.VehicleService; import cn.com.glsx.admin.modules.service.VehicleService;
import cn.com.glsx.admin.modules.utils.FileIOUtil; import cn.com.glsx.admin.modules.utils.FileIOUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.biz.common.base.entity.CarBrandSelected; import com.glsx.biz.common.base.entity.*;
import com.glsx.biz.common.base.entity.Carbrand;
import com.glsx.biz.common.base.entity.Carseries;
import com.glsx.biz.common.base.entity.Cartype;
import com.glsx.plat.common.annotation.SysLog; import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType; import com.glsx.plat.common.enums.OperateType;
import com.glsx.plat.common.utils.DateUtils; import com.glsx.plat.common.utils.DateUtils;
...@@ -169,6 +167,13 @@ public class VehicleController { ...@@ -169,6 +167,13 @@ public class VehicleController {
return R.ok().putPageData(pageInfo); return R.ok().putPageData(pageInfo);
} }
@ApiOperation(value = "车型管理列表查询")
@GetMapping("/tenanttypes/search")
public R tenantTypesSearch(TenantTypesSearch search) {
PageInfo<TenantTypesDTO> pageInfo = vehicleService.tenantTypesSearch(search);
return R.ok().putPageData(pageInfo);
}
@ApiOperation(value = "车辆品牌系别查询") @ApiOperation(value = "车辆品牌系别查询")
@GetMapping("/brandseries") @GetMapping("/brandseries")
public R<List<CarBrandSelected>> brandsSeries() { public R<List<CarBrandSelected>> brandsSeries() {
...@@ -219,4 +224,11 @@ public class VehicleController { ...@@ -219,4 +224,11 @@ public class VehicleController {
return R.ok().data(typesDTO); return R.ok().data(typesDTO);
} }
@ApiOperation(value = "获取车型库配置树")
@GetMapping("/getSelectedTypeTree")
public R<List<CarInfoSelected>> getTypeSelectedTree() {
List<CarInfoSelected> selectedTree = vehicleService.getTypeSelectedTree(ShieldContextHolder.getVisibleTenantIds());
return R.ok().data(selectedTree);
}
} }
...@@ -34,6 +34,18 @@ public class TenantVehicleType extends BaseEntity { ...@@ -34,6 +34,18 @@ public class TenantVehicleType extends BaseEntity {
private String brandName; private String brandName;
/** /**
* 车辆子品牌id
*/
@Column(name = "sub_brand_id")
private Long subBrandId;
/**
* 车辆子品牌
*/
@Column(name = "sub_brand_name")
private String subBrandName;
/**
* 车辆系别id * 车辆系别id
*/ */
@Column(name = "series_id") @Column(name = "series_id")
......
...@@ -2,15 +2,30 @@ package cn.com.glsx.admin.modules.mapper; ...@@ -2,15 +2,30 @@ package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.TenantVehicleType; import cn.com.glsx.admin.modules.entity.TenantVehicleType;
import cn.com.glsx.admin.modules.model.TenantTypesDTO; import cn.com.glsx.admin.modules.model.TenantTypesDTO;
import cn.com.glsx.admin.modules.model.param.TenantTypesSearch;
import com.glsx.biz.common.base.entity.CarInfoSelected;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
@Mapper @Mapper
public interface TenantVehicleTypeMapper extends CommonBaseMapper<TenantVehicleType> { public interface TenantVehicleTypeMapper extends CommonBaseMapper<TenantVehicleType> {
List<TenantTypesDTO> search(TenantTypesSearch search);
TenantTypesDTO selectByTenantId(Long tenantId); TenantTypesDTO selectByTenantId(Long tenantId);
List<CarInfoSelected> selectBrandByTenantIds(@Param("tenantIds") Collection<Long> tenantIds);
List<CarInfoSelected> selectSubBrandByTenantIds(@Param("tenantIds") Collection<Long> tenantIds, @Param("brandId") Integer brandId);
List<CarInfoSelected> selectSeriesByTenantIds(@Param("tenantIds") Collection<Long> tenantIds, @Param("subBrandId") Integer subBrandId);
List<CarInfoSelected> selectTypesByTenantIds(@Param("tenantIds") Collection<Long> tenantIds, @Param("seriesId") Integer seriesId);
/** /**
* 逻辑删除 * 逻辑删除
* *
......
package cn.com.glsx.admin.modules.model; package cn.com.glsx.admin.modules.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data; import lombok.Data;
import java.util.Date;
import java.util.List; import java.util.List;
@Data @Data
...@@ -10,6 +12,8 @@ public class TenantTypesDTO { ...@@ -10,6 +12,8 @@ public class TenantTypesDTO {
private Long tenantId; private Long tenantId;
private String tenantName;
private String name; private String name;
/** /**
* 启用状态:0关闭;1开启 * 启用状态:0关闭;1开启
...@@ -21,4 +25,14 @@ public class TenantTypesDTO { ...@@ -21,4 +25,14 @@ public class TenantTypesDTO {
private List<Long> typeIds; private List<Long> typeIds;
private Long createdBy;
private String creator;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
} }
package cn.com.glsx.admin.modules.model.param;
import cn.hutool.db.Page;
import lombok.Data;
@Data
public class TenantTypesSearch extends Page {
private String term;
}
...@@ -24,12 +24,10 @@ import cn.com.glsx.auth.utils.ShieldContextHolder; ...@@ -24,12 +24,10 @@ import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse; import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse;
import cn.com.glsx.usercenter.api.dto.request.FindUserRequest; import cn.com.glsx.usercenter.api.dto.request.FindUserRequest;
import cn.com.glsx.usercenter.api.dto.response.User; import cn.com.glsx.usercenter.api.dto.response.User;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.biz.common.base.entity.CarBrandSelected; import com.glsx.biz.common.base.entity.*;
import com.glsx.biz.common.base.entity.Carbrand;
import com.glsx.biz.common.base.entity.Carseries;
import com.glsx.biz.common.base.entity.Cartype;
import com.glsx.biz.common.base.service.CarbrandService; import com.glsx.biz.common.base.service.CarbrandService;
import com.glsx.biz.common.base.service.CarseriesService; import com.glsx.biz.common.base.service.CarseriesService;
import com.glsx.biz.common.base.service.CartypeService; import com.glsx.biz.common.base.service.CartypeService;
...@@ -96,6 +94,34 @@ public class VehicleService { ...@@ -96,6 +94,34 @@ public class VehicleService {
@Autowired @Autowired
private TenantVehicleTypeMapper tenantVehicleTypeMapper; private TenantVehicleTypeMapper tenantVehicleTypeMapper;
private static CarInfoSelected applyCarBrandConvert(TenantVehicleType tvt) {
CarInfoSelected selected = new CarInfoSelected();
selected.setId(Math.toIntExact(tvt.getBrandId()));
selected.setName(tvt.getBrandName());
return selected;
}
private static CarInfoSelected applyCarSubBrandConvert(TenantVehicleType tvt) {
CarInfoSelected selected = new CarInfoSelected();
selected.setId(Math.toIntExact(tvt.getSubBrandId()));
selected.setName(tvt.getSubBrandName());
return selected;
}
private static CarInfoSelected applyCarSeriesConvert(TenantVehicleType tvt) {
CarInfoSelected selected = new CarInfoSelected();
selected.setId(Math.toIntExact(tvt.getSeriesId()));
selected.setName(tvt.getSeriesName());
return selected;
}
private static CarInfoSelected applyCarTypesConvert(TenantVehicleType tvt) {
CarInfoSelected selected = new CarInfoSelected();
selected.setId(Math.toIntExact(tvt.getTypeId()));
selected.setName(tvt.getTypeName());
return selected;
}
public PageInfo<TrialDriveVehiclePageDTO> searchTrialDrive(VehicleManageSearch search) { public PageInfo<TrialDriveVehiclePageDTO> searchTrialDrive(VehicleManageSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize()); PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<TrialDriveVehiclePageDTO> listDriveVehicle = vehicleMapper.searchTrialDrive(search); List<TrialDriveVehiclePageDTO> listDriveVehicle = vehicleMapper.searchTrialDrive(search);
...@@ -688,6 +714,12 @@ public class VehicleService { ...@@ -688,6 +714,12 @@ public class VehicleService {
return userMap; return userMap;
} }
public PageInfo<TenantTypesDTO> tenantTypesSearch(TenantTypesSearch search) {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<TenantTypesDTO> list = tenantVehicleTypeMapper.search(search);
return new PageInfo<>(list);
}
public List<CarBrandSelected> getCarBrandSeriesList() { public List<CarBrandSelected> getCarBrandSeriesList() {
return carbrandService.getCarInfoCompleteForSelected(); return carbrandService.getCarInfoCompleteForSelected();
} }
...@@ -718,21 +750,31 @@ public class VehicleService { ...@@ -718,21 +750,31 @@ public class VehicleService {
public void saveVehicleTypes(VehicleTypesBO typesBO) { public void saveVehicleTypes(VehicleTypesBO typesBO) {
Date now = new Date();
List<TenantVehicleType> tvTypeList = Lists.newArrayListWithCapacity(typesBO.getTypeIds().size()); List<TenantVehicleType> tvTypeList = Lists.newArrayListWithCapacity(typesBO.getTypeIds().size());
typesBO.getTypeIds().forEach(tId -> { typesBO.getTypeIds().forEach(tId -> {
Cartype carType = this.getByTypeId(tId); Cartype carType = this.getByTypeId(tId);
if (carType != null) { if (carType != null) {
Carbrand carBrand = carbrandService.getParentBrandByBrandId(carType.getCarBrandId());
TenantVehicleType tvType = new TenantVehicleType(); TenantVehicleType tvType = new TenantVehicleType();
tvType.setTenantId(typesBO.getTenantId()); tvType.setTenantId(typesBO.getTenantId());
tvType.setName(typesBO.getName()); tvType.setName(typesBO.getName());
tvType.setBrandId(Long.valueOf(carType.getCarBrandId())); if (carBrand != null) {
tvType.setBrandName(carType.getCarBrandName()); tvType.setBrandId(Long.valueOf(carBrand.getBid()));
tvType.setBrandName(carBrand.getBrand());
}
tvType.setSubBrandId(Long.valueOf(carType.getCarBrandId()));
tvType.setSubBrandName(carType.getCarBrandName());
tvType.setSeriesId(Long.valueOf(carType.getSeriesId())); tvType.setSeriesId(Long.valueOf(carType.getSeriesId()));
tvType.setSeriesName(carType.getCarSeriesName()); tvType.setSeriesName(carType.getCarSeriesName());
tvType.setTypeId(Long.valueOf(carType.getCarTypeId())); tvType.setTypeId(Long.valueOf(carType.getCarTypeId()));
tvType.setTypeName(carType.getName()); tvType.setTypeName(carType.getName());
tvType.setEnableStatus(typesBO.getEnableStatus()); tvType.setEnableStatus(typesBO.getEnableStatus());
tvType.setCreatedBy(ShieldContextHolder.getUserId());
tvType.setCreatedDate(now);
tvTypeList.add(tvType); tvTypeList.add(tvType);
} }
}); });
...@@ -753,4 +795,25 @@ public class VehicleService { ...@@ -753,4 +795,25 @@ public class VehicleService {
return typesDTO; return typesDTO;
} }
public List<CarInfoSelected> getTypeSelectedTree(Collection<Long> tenantIds) {
//品牌
List<CarInfoSelected> brandList = tenantVehicleTypeMapper.selectBrandByTenantIds(tenantIds);
brandList.forEach(brand -> {
//子品牌
List<CarInfoSelected> subBrandList = tenantVehicleTypeMapper.selectSubBrandByTenantIds(tenantIds, brand.getId());
brand.setChilds(subBrandList);
subBrandList.forEach(subBrand -> {
//车系
List<CarInfoSelected> seriesList = tenantVehicleTypeMapper.selectSeriesByTenantIds(tenantIds, subBrand.getId());
subBrand.setChilds(seriesList);
seriesList.forEach(series -> {
//车型
List<CarInfoSelected> typesList = tenantVehicleTypeMapper.selectTypesByTenantIds(tenantIds, series.getId());
series.setChilds(typesList);
});
});
});
return brandList;
}
} }
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
<result column="name" jdbcType="VARCHAR" property="name"/> <result column="name" jdbcType="VARCHAR" property="name"/>
<result column="brand_id" jdbcType="INTEGER" property="brandId"/> <result column="brand_id" jdbcType="INTEGER" property="brandId"/>
<result column="brand_name" jdbcType="VARCHAR" property="brandName"/> <result column="brand_name" jdbcType="VARCHAR" property="brandName"/>
<result column="sub_brand_id" jdbcType="INTEGER" property="subBrandId"/>
<result column="sub_brand_name" jdbcType="VARCHAR" property="subBrandName"/>
<result column="series_id" jdbcType="INTEGER" property="seriesId"/> <result column="series_id" jdbcType="INTEGER" property="seriesId"/>
<result column="series_name" jdbcType="VARCHAR" property="seriesName"/> <result column="series_name" jdbcType="VARCHAR" property="seriesName"/>
<result column="type_id" jdbcType="INTEGER" property="typeId"/> <result column="type_id" jdbcType="INTEGER" property="typeId"/>
...@@ -25,10 +27,16 @@ ...@@ -25,10 +27,16 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, tenant_id, `name`, brand_id, brand_name, series_id, series_name, type_id, type_name, id, tenant_id, `name`, brand_id, brand_name, sub_brand_id,sub_brand_name,series_id, series_name, type_id,
enable_status, del_flag, created_date, created_by, updated_date, updated_by type_name,enable_status, del_flag, created_date, created_by, updated_date, updated_by
</sql> </sql>
<select id="search" resultType="cn.com.glsx.admin.modules.model.TenantTypesDTO">
select tenant_id tenantId, name, created_by createdBy, created_date createdDate, enable_status enableStatus
from t_tenant_vehicle_type
where del_flag = 0
group by tenant_id, name
</select>
<select id="selectByTenantId" resultType="cn.com.glsx.admin.modules.model.TenantTypesDTO"> <select id="selectByTenantId" resultType="cn.com.glsx.admin.modules.model.TenantTypesDTO">
select tenant_id tenantId, name, group_concat(type_id) types, enable_status enableStatus select tenant_id tenantId, name, group_concat(type_id) types, enable_status enableStatus
...@@ -38,6 +46,53 @@ ...@@ -38,6 +46,53 @@
group by tenant_id, name group by tenant_id, name
</select> </select>
<select id="selectBrandByTenantIds" resultType="com.glsx.biz.common.base.entity.CarInfoSelected">
select brand_id id,brand_name name
from t_tenant_vehicle_type
where del_flag = 0
and tenant_id in
<foreach collection="tenantIds" separator="," open="(" close=")" item="item">
#{item}
</foreach>
group by brand_id,brand_name
</select>
<select id="selectSubBrandByTenantIds" resultType="com.glsx.biz.common.base.entity.CarInfoSelected">
select sub_brand_id id,sub_brand_name name
from t_tenant_vehicle_type
where del_flag = 0
and tenant_id in
<foreach collection="tenantIds" separator="," open="(" close=")" item="item">
#{item}
</foreach>
and brand_id = #{brandId}
group by sub_brand_id,sub_brand_name
</select>
<select id="selectSeriesByTenantIds" resultType="com.glsx.biz.common.base.entity.CarInfoSelected">
select series_id id,series_name name
from t_tenant_vehicle_type
where del_flag = 0
and tenant_id in
<foreach collection="tenantIds" separator="," open="(" close=")" item="item">
#{item}
</foreach>
and sub_brand_id = #{subBrandId}
group by series_id,series_name
</select>
<select id="selectTypesByTenantIds" resultType="com.glsx.biz.common.base.entity.CarInfoSelected">
select type_id id,type_name name
from t_tenant_vehicle_type
where del_flag = 0
and tenant_id in
<foreach collection="tenantIds" separator="," open="(" close=")" item="item">
#{item}
</foreach>
and series_id = #{seriesId}
group by type_id,type_name
</select>
<update id="logicDeleteByTenantId"> <update id="logicDeleteByTenantId">
update t_tenant_vehicle_type update t_tenant_vehicle_type
set del_flag = -1 set del_flag = -1
......
...@@ -58,11 +58,11 @@ public class DubboServiceTest { ...@@ -58,11 +58,11 @@ public class DubboServiceTest {
@Test @Test
public void getCartype() { public void getCartype() {
// List<Cartype> cartypeList = cartypeService.getBySeiesId(1145341); List<Cartype> cartypeList = cartypeService.getBySeiesId(1145108);
// System.out.println(JSONUtil.toJsonStr(cartypeList)); System.out.println(JSONUtil.toJsonStr(cartypeList));
Cartype cartype1 = cartypeService.getByCarTypeId(Math.toIntExact(43083L)); // Cartype cartype1 = cartypeService.getByCarTypeId(Math.toIntExact(43083L));
System.out.println(111); // System.out.println(111);
} }
} }
...@@ -15,6 +15,7 @@ import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse; ...@@ -15,6 +15,7 @@ import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse;
import cn.com.glsx.publiccenter.api.feign.SysDictDataService; import cn.com.glsx.publiccenter.api.feign.SysDictDataService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.glsx.biz.common.base.entity.CarInfoSelected;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -220,4 +221,12 @@ public class VehicleServiceTest { ...@@ -220,4 +221,12 @@ public class VehicleServiceTest {
vehicleService.saveVehicleTypes(typesBO); vehicleService.saveVehicleTypes(typesBO);
} }
@Test
public void testVehicleTypes() {
List<Long> tenantIds = Lists.newArrayList();
tenantIds.add(37L);
List<CarInfoSelected> list = vehicleService.getTypeSelectedTree(tenantIds);
System.out.println(JSONObject.toJSONString(list));
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!