|
|
@@ -18,6 +18,7 @@ package org.springblade.estate.controller;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import io.lettuce.core.models.role.RedisSentinelInstance;
|
|
|
@@ -165,25 +166,20 @@ public class CarController extends BladeController {
|
|
|
@ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入car")
|
|
|
public R submit(@Valid @RequestBody Car car) {
|
|
|
- int tenantType = 1;//租户类型:默认为1-园区 0是园区
|
|
|
- if (car.getResidentialId() != null) {
|
|
|
- Residential search = new Residential();
|
|
|
- search.setId(car.getResidentialId());
|
|
|
- Residential residential = residentialClient.detail(search);
|
|
|
- Assert.notNull(residential, "找不到车对应的小区");
|
|
|
- car.setOrgPosition(residential.getOrgPosition());
|
|
|
- car.setTenantId(residential.getTenantId());
|
|
|
- car.setAgencyId(residential.getAgencyId());
|
|
|
- } else {
|
|
|
- Assert.notNull(car.getAgencyId(), "车所属园区/园区必选");
|
|
|
- Agency search = new Agency();
|
|
|
- search.setId(car.getAgencyId());
|
|
|
- Agency agency = agencyClient.detail(search);
|
|
|
- Assert.notNull(agency, "找不到车对应的园区/园区");
|
|
|
- car.setOrgPosition(agency.getOrgPosition());
|
|
|
- car.setTenantId(agency.getTenantId());
|
|
|
-
|
|
|
- }
|
|
|
+ Assert.notNull(car.getAgencyId(), "车辆所属社区必选");
|
|
|
+ Agency agency = agencyClient.getById(car.getAgencyId());
|
|
|
+ Assert.notNull(agency, "车辆所属社区不存在");
|
|
|
+ Assert.notNull(car.getResidentialId(),"车辆所属小区必选");
|
|
|
+ Residential residential = residentialClient.getById(car.getResidentialId());
|
|
|
+ Assert.notNull(residential,"车辆所属小区不存在");
|
|
|
+ //判断同一个小区下是否已经存在相同车牌号的车辆
|
|
|
+ LambdaQueryWrapper<Car> lambdaQueryWrapper = new QueryWrapper<>(new Car()).lambda().eq(Car::getResidentialId,car.getResidentialId()).eq(Car::getNumber,car.getNumber());
|
|
|
+ List<Car> dbCarList = carService.selectList(lambdaQueryWrapper);
|
|
|
+ Assert.isTrue(dbCarList.size() == 0,"小区已经存在车辆");
|
|
|
+// int tenantType = 1;//租户类型:默认为1-园区 0是社区
|
|
|
+ car.setOrgPosition(residential.getOrgPosition());
|
|
|
+ car.setTenantId(residential.getTenantId());
|
|
|
+ int tenantType;
|
|
|
TenantType search = new TenantType();
|
|
|
search.setTenantId(car.getTenantId());
|
|
|
TenantTypeVO tenantTypeVO = tenantTypeClient.detail(search);
|