Commit 8d4bd46f by 刘宇峰

车型库数据可见度控制

1 parent d73c0858
......@@ -4,7 +4,6 @@ import cn.com.glsx.admin.modules.entity.TenantVehicleType;
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.common.annotation.DataPerm;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -15,7 +14,7 @@ import java.util.List;
@Mapper
public interface TenantVehicleTypeMapper extends CommonBaseMapper<TenantVehicleType> {
@DataPerm(showSql = true)
//@DataPerm(showSql = true)
List<TenantTypesDTO> search(TenantTypesSearch search);
TenantVehicleType selectByTypeId(@Param("typeId") Integer typeId);
......
......@@ -3,9 +3,13 @@ package cn.com.glsx.admin.modules.model.param;
import cn.hutool.db.Page;
import lombok.Data;
import java.util.Collection;
@Data
public class TenantTypesSearch extends Page {
private String term;
private Collection<Long> tenantIds;
}
......@@ -14,7 +14,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
......@@ -26,11 +25,14 @@ public class OrganizationApiService {
private OrganizationService organizationService;
public void drawOrganization(List<? extends BaseOrgDto> list) {
Type type = new TypeToken<List<Organization>>() {
}.getType();
if (CollectionUtils.isEmpty(list)) {
return;
}
List<Long> userIds = list.stream().map(BaseOrgDto::getCreatedBy).collect(Collectors.toList());
R<List<Organization>> orgsR = organizationService.getTenantPathsByUserIds(userIds);
List<Organization> orgList = orgsR.getDataList(type);
List<Organization> orgList = orgsR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
if (CollectionUtils.isNotEmpty(orgList)) {
list.forEach(efd -> {
List<Organization> organizations = orgList.stream().filter(index -> index.getUserId().equals(efd.getCreatedBy())).collect(Collectors.toList());
......
......@@ -63,8 +63,6 @@ public class TrialDriveShopService {
private EFenceComponent eFenceComponent;
public PageInfo<TrialDriveShopDTO> search(TrialDriveShopSearch search) {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
// if (search.getArea() != null) {
// R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(Lists.newArrayList(search.getArea())));
// List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
......@@ -77,12 +75,18 @@ public class TrialDriveShopService {
// }.getType());
// search.setUserIds(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
// }
List<TrialDriveShopDTO> list = Lists.newArrayList();
if (search.getCity() != null) {
List<User> userList = userApiService.findAllByOrg(Lists.newArrayList(search.getCity()));
search.setUserIds(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
if (CollectionUtils.isEmpty(userList)) {
return new PageInfo<>(list);
}
}
List<TrialDriveShopDTO> list = trialDriveShopMapper.search(search);
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
list = trialDriveShopMapper.search(search);
organizationApiService.drawOrganization(list);
return new PageInfo<>(list);
}
......
......@@ -32,6 +32,7 @@ import com.glsx.biz.common.base.service.CarseriesService;
import com.glsx.biz.common.base.service.CartypeService;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
import com.glsx.plat.redis.utils.RedisUtils;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.ConvertUtils;
......@@ -41,7 +42,6 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -93,6 +93,9 @@ public class VehicleService {
private CartypeService cartypeService;
@Autowired
private RedisUtils redisUtils;
@Autowired
private TenantVehicleTypeMapper tenantVehicleTypeMapper;
private static CarInfoSelected applyCarBrandConvert(TenantVehicleType tvt) {
......@@ -738,6 +741,9 @@ public class VehicleService {
public PageInfo<TenantTypesDTO> tenantTypesSearch(TenantTypesSearch search) {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
search.setTenantIds(ShieldContextHolder.getVisibleTenantIds());
List<TenantTypesDTO> list = tenantVehicleTypeMapper.search(search);
Set<Long> userIds = list.stream().map(TenantTypesDTO::getCreatedBy).collect(Collectors.toSet());
......@@ -792,7 +798,6 @@ public class VehicleService {
return cartypeService.getByCarTypeId(typeId);
}
@Async
public void saveVehicleTypes(VehicleTypesBO typesBO, Long userId) {
Date now = new Date();
......@@ -824,8 +829,16 @@ public class VehicleService {
tvTypeList.add(tvType);
}
});
//redisUtils.lSet("TenantVehicleType" + typesBO.getTenantId(), tvTypeList);
syncData2Db(typesBO.getTenantId(), tvTypeList);
}
//@Async
public void syncData2Db(Long tenantId, List<TenantVehicleType> tvTypeList) {
if (CollectionUtils.isNotEmpty(tvTypeList)) {
tenantVehicleTypeMapper.deleteByTenantId(typesBO.getTenantId());
tenantVehicleTypeMapper.deleteByTenantId(tenantId);
tenantVehicleTypeMapper.insertList(tvTypeList);
}
......
......@@ -48,6 +48,10 @@
tenant_name like CONCAT('%',#{term},'%')
)
</if>
and tenant_id in
<foreach collection="tenantIds" separator="," open="(" close=")" item="item">
#{item}
</foreach>
group by tenant_id, name
order by created_date desc
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!