Commit f4185393 by 杨林龙

Merge remote-tracking branch 'origin/master'

2 parents c690879c 286194a2
......@@ -22,5 +22,15 @@ public final class Constants {
* 有源在线时间点 6分钟 单位 毫秒/ms
*/
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 {
/**
* 特约店围栏管理相关业务异常错误码,错误信息 1214开头
*/
TRIAL_DRIVE_SHOP_EXISTED(121430001, "此特约店已存在"),
TRIAL_DRIVE_SHOP_EXISTED(121430001, "特约店已存在"),
TRIAL_DRIVE_SHOP_FENCE_EXISTED(121430002, "特约店围栏名称已存在")
;
......
......@@ -119,4 +119,16 @@ public class TrialDriveShopController {
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> {
TrialDriveShop selectById(@Param("id") Long id);
TrialDriveShop selectByUserId(@Param("userId") Long userId);
/**
* 逻辑删除
*
......
......@@ -17,6 +17,7 @@ import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Field;
import java.util.ArrayList;
......@@ -123,6 +124,7 @@ public class TrialDriveVehicleImportListener extends AnalysisEventListener<Trial
/**
* 加上存储数据库
*/
@Transactional(rollbackFor = Exception.class)
private void saveData() {
int total = baseImportInfo.getTotal() + list.size();
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;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
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 java.util.Date;
......@@ -40,8 +42,12 @@ import java.util.stream.Collectors;
@Slf4j
@Service
@RefreshScope
public class TrialDriveShopService {
@Value("${specialshop.user.level:4}")
private Integer shopUserLevel;
@Autowired
private TrialDriveShopMapper trialDriveShopMapper;
......@@ -145,16 +151,30 @@ public class TrialDriveShopService {
* @param updateFlag
*/
public void checkTrialDriveShop(TrialDriveShopBO shopBO, boolean updateFlag) {
//1、特约店和账号
//2、特约店和特约店围栏
//1、特约店和账号一一对应
//2、特约店和特约店围栏一一对应
TrialDriveShop shop = trialDriveShopMapper.selectByUserId(shopBO.getSpecialShopId());
if (updateFlag) {
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());
if (existedFence != null && !trialDriveShop.getFenceId().equals(existedFence.getId())) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
}
} else {
//账号已经新建过特约店围栏
if (shop != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_EXISTED);
}
//名称已存在
ElectricFence existedFence = electricFenceMapper.selectByFenceNameAndBizType(shopBO.getFenceName(), BizFenceTypeEnum.TRIAL_DRIVE_SHOP.getCode());
if (existedFence != null) {
throw new AdminException(ResultEnum.TRIAL_DRIVE_SHOP_FENCE_EXISTED);
......@@ -207,6 +227,7 @@ public class TrialDriveShopService {
//围栏信息
detailsDTO.setFenceName(fence.getFenceName());
detailsDTO.setAddress(fence.getAnalysisAddress());
if (StringUtils.isNotEmpty(fence.getLnglat())) {
detailsDTO.setLng(fence.getLnglat().split(",")[0]);
detailsDTO.setLat(fence.getLnglat().split(",")[1]);
......@@ -241,7 +262,7 @@ public class TrialDriveShopService {
}
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>>() {
}.getType());
return orgList;
......@@ -293,4 +314,15 @@ public class TrialDriveShopService {
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.*;
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.request.FindDictDataRequest;
import cn.com.glsx.publiccenter.api.dto.response.SysDictDataResponse;
import cn.com.glsx.publiccenter.api.feign.SysDictDataService;
import cn.com.glsx.usercenter.api.dto.request.FindUserRequest;
import cn.com.glsx.usercenter.api.dto.response.User;
......@@ -27,6 +29,7 @@ import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
import com.glsx.plat.core.web.R;
import com.google.errorprone.annotations.FormatString;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
......@@ -34,6 +37,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import scala.runtime.StringFormat;
import java.io.FileNotFoundException;
import java.io.InputStream;
......@@ -61,9 +65,8 @@ public class VehicleService {
@Autowired
private OrganizaService organizaService;
@Autowired
private SysDictDataService dictDataService;
private DictService dictService;
public PageInfo<TrialDriveVehiclePageDTO> searchTrialDrive(VehicleManageSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
......@@ -173,6 +176,11 @@ public class VehicleService {
*/
@Transactional(rollbackFor = Exception.class)
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);
List<VehicleDevice> bindVehicleDevice = vehicleDeviceService.listVehicleDeviceByVehicleIdBind(Long.valueOf(driveVehicleoBo.getTempId()));
String sn = driveVehicleoBo.getSn();
......@@ -191,6 +199,7 @@ public class VehicleService {
for (VehicleDevice vehicleDevice : bindVehicleDevice) {
if (vehicleDevice.getSn().equals(sn)) {
bindFlag = true;
break;
}
}
// 不相同 提示
......@@ -287,7 +296,6 @@ public class VehicleService {
}
/**
* 导出时间车辆数据
*
......@@ -444,6 +452,15 @@ public class VehicleService {
//保存车辆
Vehicle vehicle = new 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.setCreatedDate(new Date());
vehicle.setVehicleType(ConstantsVehicle.TRIAL_DRIVE_TYPE);
......@@ -457,6 +474,8 @@ public class VehicleService {
vehicleDeviceService.saveSnToVehicleId(sn, vehicle.getId());
}
/**
* 保存导入失败的数据
*
......
......@@ -97,9 +97,9 @@
and tef.biz_fence_type = 12
<if test="term != null and term !=''">
and (
ttds.shop_name like CONCAT('%',#{term},'%')
tu.username like CONCAT('%',#{term},'%')
or
ttds.shop_code like CONCAT('%',#{term},'%')
tu.account like CONCAT('%',#{term},'%')
or
tef.fence_name like CONCAT('%',#{term},'%')
)
......@@ -127,9 +127,9 @@
and tef.biz_fence_type = 12
<if test="term != null and term !=''">
and (
ttds.shop_name like CONCAT('%',#{term},'%')
tu.username like CONCAT('%',#{term},'%')
or
ttds.shop_code like CONCAT('%',#{term},'%')
tu.account like CONCAT('%',#{term},'%')
or
tef.fence_name like CONCAT('%',#{term},'%')
)
......
......@@ -46,9 +46,9 @@
and tef.biz_fence_type = 13
<if test="term != null and term !=''">
and (
shop_name like CONCAT('%',#{term},'%')
tu.username like CONCAT('%',#{term},'%')
or
shop_code like CONCAT('%',#{term},'%')
tu.account like CONCAT('%',#{term},'%')
)
</if>
<if test="area != null and area !=''">
......@@ -83,9 +83,9 @@
and tef.biz_fence_type = 13
<if test="term != null and term !=''">
and (
ttds.shop_name like CONCAT('%',#{term},'%')
tu.username like CONCAT('%',#{term},'%')
or
ttds.shop_code like CONCAT('%',#{term},'%')
tu.account like CONCAT('%',#{term},'%')
)
</if>
<if test="area != null and area !=''">
......@@ -108,6 +108,14 @@
and ttds.id = #{id}
</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
<include refid="Base_Column_List"/>
......
......@@ -12,10 +12,12 @@ import cn.com.glsx.auth.model.Department;
import cn.com.glsx.auth.model.Role;
import cn.com.glsx.auth.model.SyntheticUser;
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 com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
......@@ -176,6 +178,16 @@ public class VehicleServiceTest {
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!