Commit 8928c8a8 by 刘宇峰

新增车辆-车型管理

1 parent e221d409
......@@ -47,7 +47,7 @@ public class ApprovalService {
private ApprovalHistoryService approvalHistoryService;
@Autowired
private OrganizaService organizaService;
private OrganizationApiService organizationApiService;
@Autowired
private ElectricFenceService electricFenceService;
......@@ -155,7 +155,7 @@ public class ApprovalService {
public PageInfo<VehicleApproDto> searchVehiclelicApp(VehicleApproSearch vehicleApproSearch) {
PageHelper.startPage(vehicleApproSearch.getPageNumber(), vehicleApproSearch.getPageSize());
List<VehicleApproDto> vehicleDtoPageInfo=approvalMapper.searchVehiclelicApp(vehicleApproSearch);
organizaService.drawOrganization(vehicleDtoPageInfo);
organizationApiService.drawOrganization(vehicleDtoPageInfo);
return new PageInfo<>(vehicleDtoPageInfo);
}
......@@ -168,7 +168,7 @@ public class ApprovalService {
public PageInfo<FenceApproDto> searchFenceApp(FenceApproSearch fenceApproSearch) {
PageHelper.startPage(fenceApproSearch.getPageNumber(), fenceApproSearch.getPageSize());
List<FenceApproDto> fenceApproDtoList=approvalMapper.searchFenceApp(fenceApproSearch);
organizaService.drawOrganization(fenceApproDtoList);
organizationApiService.drawOrganization(fenceApproDtoList);
if(CollectionUtils.isNotEmpty(fenceApproDtoList)) {
fenceApproDtoList.forEach(index -> {
index.setFenceType(BizFenceTypeEnum.getNameByCode(index.getFenceTypeId()));
......@@ -184,7 +184,7 @@ public class ApprovalService {
*/
public List<VehicleApproExport> export(VehicleApproSearch vehicleApproSearch) {
List<VehicleApproDto> vehicleDtoPageInfo=approvalMapper.searchVehiclelicApp(vehicleApproSearch);
organizaService.drawOrganization(vehicleDtoPageInfo);
organizationApiService.drawOrganization(vehicleDtoPageInfo);
List<VehicleApproExport> vehicleDocList = vehicleDtoPageInfo.stream().map(index -> {
VehicleApproExport vehicleApproExport = new VehicleApproExport();
BeanUtils.copyProperties(index, vehicleApproExport);
......
......@@ -16,13 +16,11 @@ import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
import cn.com.glsx.admin.modules.model.param.ElectricFenceSearch;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.UserService;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -59,24 +57,21 @@ public class ElectricFenceService {
private VehicleMapper vehicleMapper;
@Autowired
private VehicleDeviceMapper vehicleDeviceMapper;
@Autowired
private ApprovalService approvalService;
@Autowired
private UserService userService;
private TrialDriveShopService trialDriveShopService;
@Autowired
private TrialDriveShopService trialDriveShopService;
private UserApiService userApiService;
@Autowired
private OrganizaService organizaService;
private OrganizationApiService organizationApiService;
public PageInfo<ElectricFenceDTO> search(ElectricFenceSearch search) {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<ElectricFenceDTO> list = electricFenceMapper.search(search);
organizaService.drawOrganization(list);
organizationApiService.drawOrganization(list);
list.forEach(index -> {
index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType())));
index.setApprovalResult(ApprovalStatusEnum.getValueByCode(index.getApprovalStatus()));
......@@ -86,7 +81,7 @@ public class ElectricFenceService {
public List<ElectricFenceExport> export(ElectricFenceSearch search) {
List<ElectricFenceExport> list = electricFenceMapper.export(search);
organizaService.drawOrganization(list);
organizationApiService.drawOrganization(list);
list.forEach(index -> {
index.setBizFenceType(BizFenceTypeEnum.getNameByCode(Integer.valueOf(index.getBizFenceType())));
index.setApprovalResult(ApprovalStatusEnum.getValueByCode(index.getApprovalStatus()));
......@@ -521,8 +516,7 @@ public class ElectricFenceService {
});
detailsDTO.setSnList(snsList);
R<User> userR = userService.getById(electricFence.getCreatedBy());
User user = userR.getData(User.class);
User user = userApiService.getUserById(electricFence.getCreatedBy());
if (user != null) {
detailsDTO.setShopId(user.getId());
detailsDTO.setShopName(user.getUsername());
......@@ -551,8 +545,7 @@ public class ElectricFenceService {
});
detailsDTO.setSnList(snsList);
R<User> userR = userService.getById(fenceCopy.getCreatedBy());
User user = userR.getData(User.class);
User user = userApiService.getUserById(fenceCopy.getCreatedBy());
if (user != null) {
detailsDTO.setShopId(user.getId());
detailsDTO.setShopName(user.getUsername());
......
......@@ -10,11 +10,12 @@ 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;
@Service
public class OrganizaService {
public class OrganizationApiService {
@Autowired
private OrganizationService organizationService;
......@@ -46,4 +47,36 @@ public class OrganizaService {
}
}
public List<Organization> getRootOrganizations() {
R<List<Organization>> listR = organizationService.getRootOrganizations();
List<Organization> orgList = listR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
return orgList;
}
public List<Organization> getSubOrganizations(Long orgId) {
R<List<Organization>> listR = organizationService.getSubOrganizations(orgId);
List<Organization> orgList = listR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
return orgList;
}
public List<Organization> getSpecialLevelOrganizations(Integer level) {
R<List<Organization>> orgListR = organizationService.getSpecialLevelOrganizations(level);
List<Organization> orgList = orgListR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
return orgList;
}
public Organization getOrganizationInfo(Long orgId) {
return null;
}
public List<Organization> getBatchOrganizationInfo(Collection<Long> orgIds) {
R<List<Organization>> listR = organizationService.getOrgsByUserIds(orgIds);
List<Organization> orgList = listR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
return orgList;
}
}
......@@ -37,7 +37,7 @@ public class TearDownAlarmSevice {
private VehicleMapper vehicleMapper;
@Autowired
private OrganizaService organizaService;
private OrganizationApiService organizationApiService;
/**
* 查询拆除报警数据
......@@ -85,7 +85,7 @@ public class TearDownAlarmSevice {
}
}
}
organizaService.drawOrganization(modelExportList);
organizationApiService.drawOrganization(modelExportList);
alarmDataPage.setList(modelExportList);
return alarmDataPage;
}
......@@ -99,7 +99,7 @@ public class TearDownAlarmSevice {
public List<TearDownModelExport> export(TearDownQueryBo tearDownQueryBo) {
// 在数据库查询车辆和特约店车辆信息
List<TearDownModelExport> tearDownModelExportList = vehicleMapper.searchTearDownAlarmList(tearDownQueryBo.getKeywords());
organizaService.drawOrganization(tearDownModelExportList);
organizationApiService.drawOrganization(tearDownModelExportList);
String alarmsnStr = StringUtils.join(tearDownModelExportList.stream().map(TearDownModelExport::getSn).toArray(), ",");
AlarmBo alarmBo = new AlarmBo();
alarmBo.setSnList(alarmsnStr);
......
......@@ -17,17 +17,12 @@ import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
import cn.com.glsx.admin.modules.model.param.TrialDriveShopBO;
import cn.com.glsx.admin.modules.model.param.TrialDriveShopSearch;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.usercenter.api.dto.request.FindUserRequest;
import cn.com.glsx.usercenter.api.dto.response.Organization;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.OrganizationService;
import cn.com.glsx.usercenter.api.feign.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
......@@ -59,13 +54,10 @@ public class TrialDriveShopService {
private ElectricFenceService electricFenceService;
@Autowired
private UserService userService;
private UserApiService userApiService;
@Autowired
private OrganizaService organizaService;
@Autowired
private OrganizationService organizationService;
private OrganizationApiService organizationApiService;
@Autowired
private EFenceComponent eFenceComponent;
......@@ -86,20 +78,18 @@ public class TrialDriveShopService {
// search.setUserIds(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
// }
if (search.getCity() != null) {
R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(Lists.newArrayList(search.getCity())));
List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
}.getType());
List<User> userList = userApiService.findAllByOrg(Lists.newArrayList(search.getCity()));
search.setUserIds(StringUtils.join(userList.stream().map(User::getId).toArray(), ","));
}
List<TrialDriveShopDTO> list = trialDriveShopMapper.search(search);
organizaService.drawOrganization(list);
organizationApiService.drawOrganization(list);
return new PageInfo<>(list);
}
public List<TrialDriveShopExport> export(TrialDriveShopSearch search) {
List<TrialDriveShopExport> list = trialDriveShopMapper.export(search);
organizaService.drawOrganization(list);
organizationApiService.drawOrganization(list);
return list;
}
......@@ -264,8 +254,7 @@ public class TrialDriveShopService {
}
detailsDTO.setRadius(fence.getRadius());
R<User> userR = userService.getById(shop.getCreatedBy());
User user = userR.getData(User.class);
User user = userApiService.getUserById(shop.getCreatedBy());
if (user != null) {
detailsDTO.setSpecialShopId(user.getId());
detailsDTO.setShopName(user.getUsername());
......@@ -291,27 +280,18 @@ public class TrialDriveShopService {
electricFenceService.deleteById(shop.getFenceId());
}
public List<Organization> getShopOrgs() {
R<List<Organization>> orgListR = organizationService.getSpecialLevelOrganizations(shopUserLevel);
List<Organization> orgList = orgListR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
return orgList;
}
public List<Long> getShopOrgIds() {
List<Organization> orgList = getShopOrgs();
List<Organization> orgList = organizationApiService.getSpecialLevelOrganizations(shopUserLevel);
List<Long> orgIds = orgList.stream().map(Organization::getId).collect(Collectors.toList());
return orgIds;
}
public List<SimpleTreeModel> getShopWithUserTree() {
List<Organization> orgList = getShopOrgs();
List<Organization> orgList = organizationApiService.getSpecialLevelOrganizations(shopUserLevel);
List<SimpleTreeModel> treeModelList = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(orgList)) {
List<Long> longList = orgList.stream().map(Organization::getId).collect(Collectors.toList());
R<List<User>> byOrg = userService.findByOrg(new FindUserRequest().setOrgIds(longList));
List<User> list = byOrg.getDataList(new TypeToken<List<User>>() {
}.getType());
List<Long> orgIds = orgList.stream().map(Organization::getId).collect(Collectors.toList());
List<User> list = userApiService.findByOrg(orgIds);
orgList.forEach(o -> {
SimpleTreeModel treeModel = new SimpleTreeModel();
treeModel.setId(o.getId());
......
......@@ -3,33 +3,41 @@ package cn.com.glsx.admin.modules.service;
import cn.com.glsx.usercenter.api.dto.request.FindUserRequest;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.feign.ApiUserService;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
import com.glsx.plat.core.web.R;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 用户服务
*/
@Service
public class UserApiService {
@Autowired
private cn.com.glsx.usercenter.api.feign.UserService userService;
/**
* 不需要登录得开放用户服务
*/
@Autowired
private ApiUserService apiUserService;
/**
* 根据创建人id查找用户信息
* @param createdBy
* 根据用户id查找用户信息
*
* @param userId
* @return
*/
public User getUserByCreatedBy(Long createdBy) {
R<User> userR = userService.getById(createdBy);
public User getUserById(Long userId) {
R<User> userR = userService.getById(userId);
if (userR == null) {
return null;
}
......@@ -38,41 +46,77 @@ public class UserApiService {
}
/**
* 查找特约店(账户)是否存在
* @param userRequest
* 根据用户名称查找用户id
*
* @param username
* @return
*/
public List<User> findByUser(FindUserRequest userRequest) {
R<List<User>> userR = userService.findByUser(userRequest);
if (userR == null || !userR.isSuccess()) {
public Long getUserIdByUsername(String username) {
R<List<User>> userR = apiUserService.findByUsername(username);
if (userR == null) {
return null;
}
Long userId = null;
List<User> userList = userR.getDataList(new TypeToken<List<User>>() {
}.getType());
return userList;
if (CollectionUtils.isNotEmpty(userList) && userList.size() == 1) {
userId = userList.get(0).getId();
}
return userId;
}
/**
* 根据店面名称查找用户id
* @param shopName
* 根据用户id获取用户列表
*
* @param userIds
* @return
*/
public Long getUserIdByShopName(String shopName) {
R<List<User>> userR = apiUserService.findByUsername(shopName);
if (userR == null) {
public List<User> findByUser(List<Long> userIds) {
R<List<User>> userR = userService.findByUser(new FindUserRequest().setUserIds(userIds));
if (userR == null || !userR.isSuccess()) {
return null;
}
Long userId = null;
List<User> userList = userR.getDataList(new TypeToken<List<User>>() {
}.getType());
if (CollectionUtils.isNotEmpty(userList) && userList.size() == 1) {
userId = userList.get(0).getId();
}
return userId;
return userList;
}
// @Cacheable(value = "user", key = "#userId")
// public User getUser(Long userId) {
// List<User> userList = this.findAllUser();
// Map<Long, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, t -> t));
// return userMap.get(userId);
// }
/**
* 根据组织id获取用户列表
*
* @param orgIds
* @return
*/
public List<User> findAllByOrg(List<Long> orgIds) {
R<List<User>> byOrg = userService.findAllByOrg(new FindUserRequest().setOrgIds(orgIds));
List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
}.getType());
return userList;
}
/**
* 根据组织id获取用户列表-用户权限内
*
* @param orgIds
* @return
*/
public List<User> findByOrg(List<Long> orgIds) {
R<List<User>> byOrg = userService.findByOrg(new FindUserRequest().setOrgIds(orgIds));
List<User> userList = byOrg.getDataList(new TypeToken<List<User>>() {
}.getType());
return userList;
}
/**
* 查找所有用户信息
*
* @return
*/
public List<User> findAllUser() {
......@@ -84,4 +128,22 @@ public class UserApiService {
}.getType());
return userList;
}
/**
* 封装用户信息 key:门店编码 value:id
*
* @return
*/
public Map<String, Long> findUserIdMapByAccount() {
Map<String, Long> userMap = new HashedMap();
List<User> userList = this.findAllUser();
if (userList == null) {
return userMap;
}
for (User user : userList) {
userMap.put(user.getAccount(), user.getId());
}
return userMap;
}
}
......@@ -11,6 +11,7 @@ import cn.com.glsx.admin.modules.model.VehicleApproDto;
import cn.com.glsx.admin.modules.model.VehicleDocDto;
import cn.com.glsx.admin.modules.model.param.*;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.usercenter.api.feign.OrganizationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
......@@ -42,7 +43,7 @@ public class VehicleDocService {
private ApprovalService approvalService;
@Autowired
private OrganizaService organizaService;
private OrganizationApiService organizationApiService;
/**
* 批量新增或者修改车辆资料
......@@ -131,7 +132,7 @@ public class VehicleDocService {
index.setSubmitStatus("1");
}
});
organizaService.drawOrganization(vehicleDtoPageInfo);
organizationApiService.drawOrganization(vehicleDtoPageInfo);
return new PageInfo<>(vehicleDtoPageInfo);
}
......
......@@ -24,13 +24,11 @@ import cn.com.glsx.alarm.services.model.AlarmDto;
import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData;
import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation;
import cn.com.glsx.usercenter.api.dto.response.Organization;
import cn.com.glsx.usercenter.api.feign.OrganizationService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.glsx.plat.context.utils.PropertiesUtils;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
......@@ -58,6 +56,7 @@ public class VehicleMonitorSevice {
@Autowired
private VehicleMapper vehicleMapper;
@Autowired
private DeviceMapper deviceMapper;
......@@ -65,7 +64,7 @@ public class VehicleMonitorSevice {
private AlarmFeignClient alarmFeignClient;
@Autowired
private OrganizationService organizationService;
private OrganizationApiService organizationApiService;
public List<OrgVehicleTreeModel> vTree(VehicleTreeSearch search) {
List<Organization> orgList = Lists.newArrayList();
......@@ -81,13 +80,9 @@ public class VehicleMonitorSevice {
} else {
if (search.getOrgId() == null) {
R<List<Organization>> listR = organizationService.getRootOrganizations();
orgList = listR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
orgList = organizationApiService.getRootOrganizations();
} else {
R<List<Organization>> listR = organizationService.getSubOrganizations(search.getOrgId());
orgList = listR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
orgList = organizationApiService.getSubOrganizations(search.getOrgId());
}
}
......
......@@ -22,7 +22,6 @@ import cn.com.glsx.admin.modules.utils.DateUtil;
import cn.com.glsx.admin.modules.utils.FileIOUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder;
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.response.User;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
......@@ -48,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Desc:试驾车辆service
......@@ -65,13 +65,13 @@ public class VehicleService {
private VehicleDeviceService vehicleDeviceService;
@Autowired
private UserApiService userApiService;
private DeviceService deviceService;
@Autowired
private DeviceService deviceService;
private UserApiService userApiService;
@Autowired
private OrganizaService organizaService;
private OrganizationApiService organizationApiService;
@Autowired
private DictService dictService;
......@@ -125,7 +125,7 @@ public class VehicleService {
public PageInfo<TrialDriveVehiclePageDTO> searchTrialDrive(VehicleManageSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<TrialDriveVehiclePageDTO> listDriveVehicle = vehicleMapper.searchTrialDrive(search);
organizaService.drawOrganization(listDriveVehicle);
organizationApiService.drawOrganization(listDriveVehicle);
return new PageInfo<>(listDriveVehicle);
}
......@@ -364,7 +364,7 @@ public class VehicleService {
return null;
}
BeanUtils.copyProperties(vehicle, editDTO);
User user = userApiService.getUserByCreatedBy(vehicle.getCreatedBy());
User user = userApiService.getUserById(vehicle.getCreatedBy());
if (user != null) {
editDTO.setShopNameId(user.getId());
editDTO.setShopName(user.getUsername());
......@@ -540,7 +540,7 @@ public class VehicleService {
}
//2.分类的为空再用门店的匹配
if (createId == null) {
createId = userApiService.getUserIdByShopName(shopName);
createId = userApiService.getUserIdByUsername(shopName);
}
//3.如果门店的仍然找不到 使用配置文件中默认的
if (createId == null || createId == 0L) {
......@@ -568,7 +568,7 @@ public class VehicleService {
}
//从用户表中查找后 存在更新后返回
String userRemark = accountData.getUserremark();
Long userId = userApiService.getUserIdByShopName(userRemark);
Long userId = userApiService.getUserIdByUsername(userRemark);
if (userId == null) {
return null;
}
......@@ -687,20 +687,6 @@ public class VehicleService {
}
/**
* 根据门店名和编码查找用户
*
* @param shopName
* @param shopCode
* @return
*/
public List<User> findByNameAndCode(String shopName, String shopCode) {
FindUserRequest userRequest = new FindUserRequest();
userRequest.setUsername(shopName);
userRequest.setAccount(shopCode);
return userApiService.findByUser(userRequest);
}
/**
* 批量插入数据
*
* @param driveList
......@@ -746,6 +732,14 @@ public class VehicleService {
public PageInfo<TenantTypesDTO> tenantTypesSearch(TenantTypesSearch search) {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<TenantTypesDTO> list = tenantVehicleTypeMapper.search(search);
List<Long> userIds = list.stream().map(TenantTypesDTO::getCreatedBy).collect(Collectors.toList());
List<User> userList = userApiService.findByUser(userIds);
list.forEach(ttd -> {
});
return new PageInfo<>(list);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!