Commit f4185393 by 杨林龙

Merge remote-tracking branch 'origin/master'

2 parents c690879c 286194a2
...@@ -22,5 +22,15 @@ public final class Constants { ...@@ -22,5 +22,15 @@ public final class Constants {
* 有源在线时间点 6分钟 单位 毫秒/ms * 有源在线时间点 6分钟 单位 毫秒/ms
*/ */
public static final long ONLINE_SOURCE_TIME = 6 * 60 * 1000L; public static final long ONLINE_SOURCE_TIME = 6 * 60 * 1000L;
/**
* 字典表中车辆车型的type
*/
public static final String TRIALDRIVE_VEHICLE_MODEL = "trialdrive_vehicle_model";
/**
* 字典表中试驾车辆配置的type
*/
public static final String TRIALDRIVE_VEHICLE_CONFIG = "trialdrive_vehicle_config";
} }
...@@ -54,7 +54,7 @@ public enum ResultEnum { ...@@ -54,7 +54,7 @@ public enum ResultEnum {
/** /**
* 特约店围栏管理相关业务异常错误码,错误信息 1214开头 * 特约店围栏管理相关业务异常错误码,错误信息 1214开头
*/ */
TRIAL_DRIVE_SHOP_EXISTED(121430001, "此特约店已存在"), TRIAL_DRIVE_SHOP_EXISTED(121430001, "特约店已存在"),
TRIAL_DRIVE_SHOP_FENCE_EXISTED(121430002, "特约店围栏名称已存在") TRIAL_DRIVE_SHOP_FENCE_EXISTED(121430002, "特约店围栏名称已存在")
; ;
......
...@@ -119,4 +119,16 @@ public class TrialDriveShopController { ...@@ -119,4 +119,16 @@ public class TrialDriveShopController {
return R.ok().data(treeModelList); return R.ok().data(treeModelList);
} }
/**
* 判断是否时特约店
*
* @return
*/
@GetMapping(value = "/isshopuser")
@ApiOperation(value = "判断是否时特约店")
public R isShopUser() {
boolean shopUserFlag = trialDriveShopService.isShopUser();
return R.ok().data(shopUserFlag);
}
} }
...@@ -22,6 +22,8 @@ public interface TrialDriveShopMapper extends CommonBaseMapper<TrialDriveShop> { ...@@ -22,6 +22,8 @@ public interface TrialDriveShopMapper extends CommonBaseMapper<TrialDriveShop> {
TrialDriveShop selectById(@Param("id") Long id); TrialDriveShop selectById(@Param("id") Long id);
TrialDriveShop selectByUserId(@Param("userId") Long userId);
/** /**
* 逻辑删除 * 逻辑删除
* *
......
...@@ -17,6 +17,7 @@ import lombok.NoArgsConstructor; ...@@ -17,6 +17,7 @@ import lombok.NoArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -123,6 +124,7 @@ public class TrialDriveVehicleImportListener extends AnalysisEventListener<Trial ...@@ -123,6 +124,7 @@ public class TrialDriveVehicleImportListener extends AnalysisEventListener<Trial
/** /**
* 加上存储数据库 * 加上存储数据库
*/ */
@Transactional(rollbackFor = Exception.class)
private void saveData() { private void saveData() {
int total = baseImportInfo.getTotal() + list.size(); int total = baseImportInfo.getTotal() + list.size();
AtomicInteger succNum = new AtomicInteger(baseImportInfo.getSuccNum()); AtomicInteger succNum = new AtomicInteger(baseImportInfo.getSuccNum());
......
package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.common.constants.Constants;
import cn.com.glsx.admin.modules.entity.Vehicle;
import cn.com.glsx.publiccenter.api.dto.request.FindDictDataRequest;
import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse;
import cn.com.glsx.publiccenter.api.feign.SysDictDataService;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 字典服务
*/
@Service
public class DictService {
@Autowired
private SysDictDataService dictDataService;
public SysDictDataResponse getDictDataByLabelAndType(String labelName, String type) {
if (StringUtils.isBlank(labelName)) {
return null;
}
FindDictDataRequest request = new FindDictDataRequest();
request.setDictLabel(labelName.trim());
request.setDictType(type);
R<List<SysDictDataResponse>> listR = dictDataService.findByDict(request);
List<SysDictDataResponse> dictDataList = listR.getDataList(new TypeToken<List<SysDictDataResponse>>(){}.getType());
if (CollectionUtils.isEmpty(dictDataList) || dictDataList.size() != 1) {
return null;
}
return dictDataList.get(0);
}
}
...@@ -32,6 +32,8 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -32,6 +32,8 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
...@@ -40,8 +42,12 @@ import java.util.stream.Collectors; ...@@ -40,8 +42,12 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Service @Service
@RefreshScope
public class TrialDriveShopService { public class TrialDriveShopService {
@Value("${specialshop.user.level:4}")
private Integer shopUserLevel;
@Autowired @Autowired
private TrialDriveShopMapper trialDriveShopMapper; private TrialDriveShopMapper trialDriveShopMapper;
...@@ -145,16 +151,30 @@ public class TrialDriveShopService { ...@@ -145,16 +151,30 @@ public class TrialDriveShopService {
* @param updateFlag * @param updateFlag
*/ */
public void checkTrialDriveShop(TrialDriveShopBO shopBO, boolean updateFlag) { public void checkTrialDriveShop(TrialDriveShopBO shopBO, boolean updateFlag) {
//1、特约店和账号 //1、特约店和账号一一对应
//2、特约店和特约店围栏 //2、特约店和特约店围栏一一对应
TrialDriveShop shop = trialDriveShopMapper.selectByUserId(shopBO.getSpecialShopId());
if (updateFlag) { if (updateFlag) {
TrialDriveShop trialDriveShop = trialDriveShopMapper.selectById(shopBO.getId()); TrialDriveShop trialDriveShop = trialDriveShopMapper.selectById(shopBO.getId());
//编辑的审核 选了已经建了特约店围栏的特约店(账号)
if (shop != null && !shop.getId().equals(trialDriveShop.getId())) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_EXISTED);
}
//名称已存在
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode()); ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null && !trialDriveShop.getFenceId().equals(existedFence.getId())) { if (existedFence != null && !trialDriveShop.getFenceId().equals(existedFence.getId())) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED); throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
} }
} else { } else {
//账号已经新建过特约店围栏
if (shop != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_EXISTED);
}
//名称已存在
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode()); ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null) { if (existedFence != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED); throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
...@@ -207,6 +227,7 @@ public class TrialDriveShopService { ...@@ -207,6 +227,7 @@ public class TrialDriveShopService {
//围栏信息 //围栏信息
detailsDTO.setFenceName(fence.getFenceName()); detailsDTO.setFenceName(fence.getFenceName());
detailsDTO.setAddress(fence.getAnalysisAddress());
if (StringUtils.isNotEmpty(fence.getLnglat())) { if (StringUtils.isNotEmpty(fence.getLnglat())) {
detailsDTO.setLng(fence.getLnglat().split(",")[0]); detailsDTO.setLng(fence.getLnglat().split(",")[0]);
detailsDTO.setLat(fence.getLnglat().split(",")[1]); detailsDTO.setLat(fence.getLnglat().split(",")[1]);
...@@ -241,7 +262,7 @@ public class TrialDriveShopService { ...@@ -241,7 +262,7 @@ public class TrialDriveShopService {
} }
public List<Organization> getShopOrgs() { public List<Organization> getShopOrgs() {
R<List<Organization>> orgListR = organizationService.getSpecialLevelOrganizations(4); R<List<Organization>> orgListR = organizationService.getSpecialLevelOrganizations(shopUserLevel);
List<Organization> orgList = orgListR.getDataList(new TypeToken<List<Organization>>() { List<Organization> orgList = orgListR.getDataList(new TypeToken<List<Organization>>() {
}.getType()); }.getType());
return orgList; return orgList;
...@@ -293,4 +314,15 @@ public class TrialDriveShopService { ...@@ -293,4 +314,15 @@ public class TrialDriveShopService {
return treeModelList; return treeModelList;
} }
/**
* 判断是否是特约店 true 是
*
* @return
*/
public boolean isShopUser() {
List<Long> shopOrgIds = this.getShopOrgIds();
boolean userFlag = shopOrgIds.contains(ShieldContextHolder.getDepartmentId());
return userFlag;
}
} }
...@@ -18,6 +18,8 @@ import cn.com.glsx.admin.modules.model.param.*; ...@@ -18,6 +18,8 @@ import cn.com.glsx.admin.modules.model.param.*;
import cn.com.glsx.admin.modules.utils.DateUtil; import cn.com.glsx.admin.modules.utils.DateUtil;
import cn.com.glsx.admin.modules.utils.FileIOUtil; import cn.com.glsx.admin.modules.utils.FileIOUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder; import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.publiccenter.api.dto.request.FindDictDataRequest;
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 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;
...@@ -27,6 +29,7 @@ import com.github.pagehelper.PageInfo; ...@@ -27,6 +29,7 @@ import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.StringUtils; import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils; import com.glsx.plat.context.utils.PropertiesUtils;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import com.google.errorprone.annotations.FormatString;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -34,6 +37,7 @@ import org.springframework.beans.BeanUtils; ...@@ -34,6 +37,7 @@ import org.springframework.beans.BeanUtils;
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 org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import scala.runtime.StringFormat;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
...@@ -61,9 +65,8 @@ public class VehicleService { ...@@ -61,9 +65,8 @@ public class VehicleService {
@Autowired @Autowired
private OrganizaService organizaService; private OrganizaService organizaService;
@Autowired @Autowired
private SysDictDataService dictDataService; private DictService dictService;
public PageInfo<TrialDriveVehiclePageDTO> searchTrialDrive(VehicleManageSearch search) { public PageInfo<TrialDriveVehiclePageDTO> searchTrialDrive(VehicleManageSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize()); PageHelper.startPage(search.getPageNumber(), search.getPageSize());
...@@ -173,6 +176,11 @@ public class VehicleService { ...@@ -173,6 +176,11 @@ public class VehicleService {
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateDriveVehicleById(TrialDriveVehicleEditBo driveVehicleoBo) { public void updateDriveVehicleById(TrialDriveVehicleEditBo driveVehicleoBo) {
//是否编辑了车架号 若编辑了 检验在库中是否已存在
Vehicle vehicle = vehicleMapper.getVehicleByVin(driveVehicleoBo.getVin());
if (Long.parseLong(driveVehicleoBo.getTempId()) != vehicle.getId()) {
throw new AdminException(ResultEnum.EXIST_VEHICLE.getCode(), String.format(ResultEnum.EXIST_VEHICLE.getMessage(), driveVehicleoBo.getVin()));
}
updateVehicle(driveVehicleoBo); updateVehicle(driveVehicleoBo);
List<VehicleDevice> bindVehicleDevice = vehicleDeviceService.listVehicleDeviceByVehicleIdBind(Long.valueOf(driveVehicleoBo.getTempId())); List<VehicleDevice> bindVehicleDevice = vehicleDeviceService.listVehicleDeviceByVehicleIdBind(Long.valueOf(driveVehicleoBo.getTempId()));
String sn = driveVehicleoBo.getSn(); String sn = driveVehicleoBo.getSn();
...@@ -191,6 +199,7 @@ public class VehicleService { ...@@ -191,6 +199,7 @@ public class VehicleService {
for (VehicleDevice vehicleDevice : bindVehicleDevice) { for (VehicleDevice vehicleDevice : bindVehicleDevice) {
if (vehicleDevice.getSn().equals(sn)) { if (vehicleDevice.getSn().equals(sn)) {
bindFlag = true; bindFlag = true;
break;
} }
} }
// 不相同 提示 // 不相同 提示
...@@ -287,7 +296,6 @@ public class VehicleService { ...@@ -287,7 +296,6 @@ public class VehicleService {
} }
/** /**
* 导出时间车辆数据 * 导出时间车辆数据
* *
...@@ -444,6 +452,15 @@ public class VehicleService { ...@@ -444,6 +452,15 @@ public class VehicleService {
//保存车辆 //保存车辆
Vehicle vehicle = new Vehicle(); Vehicle vehicle = new Vehicle();
BeanUtils.copyProperties(vi, vehicle); BeanUtils.copyProperties(vi, vehicle);
//匹配车辆配置和车型
SysDictDataResponse modelDict = dictService.getDictDataByLabelAndType(vehicle.getModelName(), Constants.TRIALDRIVE_VEHICLE_MODEL);
if (modelDict != null) {
vehicle.setModelId(Math.toIntExact(modelDict.getId()));
}
modelDict = dictService.getDictDataByLabelAndType(vehicle.getConfigDesc(), Constants.TRIALDRIVE_VEHICLE_CONFIG);
if (modelDict != null) {
vehicle.setConfigId(Math.toIntExact(modelDict.getId()));
}
vehicle.setCreatedBy(ShieldContextHolder.getUserId()); vehicle.setCreatedBy(ShieldContextHolder.getUserId());
vehicle.setCreatedDate(new Date()); vehicle.setCreatedDate(new Date());
vehicle.setVehicleType(ConstantsVehicle.TRIAL_DRIVE_TYPE); vehicle.setVehicleType(ConstantsVehicle.TRIAL_DRIVE_TYPE);
...@@ -457,6 +474,8 @@ public class VehicleService { ...@@ -457,6 +474,8 @@ public class VehicleService {
vehicleDeviceService.saveSnToVehicleId(sn, vehicle.getId()); vehicleDeviceService.saveSnToVehicleId(sn, vehicle.getId());
} }
/** /**
* 保存导入失败的数据 * 保存导入失败的数据
* *
......
...@@ -97,9 +97,9 @@ ...@@ -97,9 +97,9 @@
and tef.biz_fence_type = 12 and tef.biz_fence_type = 12
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and ( and (
ttds.shop_name like CONCAT('%',#{term},'%') tu.username like CONCAT('%',#{term},'%')
or or
ttds.shop_code like CONCAT('%',#{term},'%') tu.account like CONCAT('%',#{term},'%')
or or
tef.fence_name like CONCAT('%',#{term},'%') tef.fence_name like CONCAT('%',#{term},'%')
) )
...@@ -127,9 +127,9 @@ ...@@ -127,9 +127,9 @@
and tef.biz_fence_type = 12 and tef.biz_fence_type = 12
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and ( and (
ttds.shop_name like CONCAT('%',#{term},'%') tu.username like CONCAT('%',#{term},'%')
or or
ttds.shop_code like CONCAT('%',#{term},'%') tu.account like CONCAT('%',#{term},'%')
or or
tef.fence_name like CONCAT('%',#{term},'%') tef.fence_name like CONCAT('%',#{term},'%')
) )
......
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
and tef.biz_fence_type = 13 and tef.biz_fence_type = 13
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and ( and (
shop_name like CONCAT('%',#{term},'%') tu.username like CONCAT('%',#{term},'%')
or or
shop_code like CONCAT('%',#{term},'%') tu.account like CONCAT('%',#{term},'%')
) )
</if> </if>
<if test="area != null and area !=''"> <if test="area != null and area !=''">
...@@ -83,9 +83,9 @@ ...@@ -83,9 +83,9 @@
and tef.biz_fence_type = 13 and tef.biz_fence_type = 13
<if test="term != null and term !=''"> <if test="term != null and term !=''">
and ( and (
ttds.shop_name like CONCAT('%',#{term},'%') tu.username like CONCAT('%',#{term},'%')
or or
ttds.shop_code like CONCAT('%',#{term},'%') tu.account like CONCAT('%',#{term},'%')
) )
</if> </if>
<if test="area != null and area !=''"> <if test="area != null and area !=''">
...@@ -108,6 +108,14 @@ ...@@ -108,6 +108,14 @@
and ttds.id = #{id} and ttds.id = #{id}
</select> </select>
<select id="selectByUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_trial_drive_shop ttds
where ttds.del_flag = 0
and ttds.created_by = #{userId}
</select>
<select id="selectByShopName" resultMap="BaseResultMap"> <select id="selectByShopName" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
...@@ -12,10 +12,12 @@ import cn.com.glsx.auth.model.Department; ...@@ -12,10 +12,12 @@ import cn.com.glsx.auth.model.Department;
import cn.com.glsx.auth.model.Role; import cn.com.glsx.auth.model.Role;
import cn.com.glsx.auth.model.SyntheticUser; import cn.com.glsx.auth.model.SyntheticUser;
import cn.com.glsx.auth.utils.ShieldContextHolder; import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.publiccenter.api.dto.request.FindDictDataRequest;
import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse; 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.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Before; import org.junit.Before;
...@@ -176,6 +178,16 @@ public class VehicleServiceTest { ...@@ -176,6 +178,16 @@ public class VehicleServiceTest {
System.out.println(JSONObject.toJSONString(response)); System.out.println(JSONObject.toJSONString(response));
} }
@Test
public void findByDictTest() {
FindDictDataRequest request = new FindDictDataRequest();
request.setDictLabel("混动皓影");
request.setDictType("");
R<List<SysDictDataResponse>> listR = dictDataService.findByDict(request);
List<SysDictDataResponse> dictDataList = listR.getData(List.class);
System.out.println(JSONObject.toJSONString(dictDataList));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!