fix(util): 修复车辆路径查找工具中的图标名称比较错误
- 修复CarPathFinderUtil中使用iconName而非iconImage进行功能匹配 - 添加ExTiVehicleFunctionService接口的findNextClickToFunction方法定义 - 实现车辆功能服务中的路径查找逻辑,支持查找从当前页面到目标功能的最短点击路径 - 集成字典数据服务以获取功能和界面配置的映射关系 - 在车辆界面控制器中暴露路径查找API端点 - 添加必要的Lombok注解和依赖注入配置
This commit is contained in:
parent
d761a2fe5b
commit
22463c1763
@ -5,6 +5,7 @@ import com.cmvr.common.core.controller.BaseController;
|
||||
import com.cmvr.common.core.domain.AjaxResult;
|
||||
import com.cmvr.common.core.page.TableDataInfo;
|
||||
import com.cmvr.common.enums.BusinessType;
|
||||
import com.cmvr.test.service.ex.ExTiVehicleFunctionService;
|
||||
import com.cmvr.ti.model.domain.TiVehicleUi;
|
||||
import com.cmvr.ti.service.ITiVehicleFunctionService;
|
||||
import com.cmvr.ti.service.ITiVehicleUiService;
|
||||
@ -30,6 +31,8 @@ import java.util.List;
|
||||
public class TiVehicleUiController extends BaseController {
|
||||
private final ITiVehicleUiService tiVehicleUiService;
|
||||
|
||||
private final ExTiVehicleFunctionService exTiVehicleFunctionService;
|
||||
|
||||
@ApiOperation("查询车机功能列表")
|
||||
@PreAuthorize("@ss.hasPermi('ti:ui:list')")
|
||||
@GetMapping("/list")
|
||||
@ -69,4 +72,10 @@ public class TiVehicleUiController extends BaseController {
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(tiVehicleUiService.deleteTiVehicleUiByIds(ids));
|
||||
}
|
||||
|
||||
@ApiOperation("搜索路径")
|
||||
@GetMapping("/findNextClickToFunction")
|
||||
public AjaxResult findNextClickToFunction(Long vehicleConfigId, String currentUi, String clickFunction) {
|
||||
return AjaxResult.success(exTiVehicleFunctionService.findNextClickToFunction(vehicleConfigId, currentUi, clickFunction));
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ public class CarPathFinderUtil {
|
||||
if (ObjUtil.isEmpty(icon.getIconImage())) {
|
||||
continue;
|
||||
}
|
||||
if (icon.getIconImage().equals(targetFeature)) {
|
||||
if (icon.getIconName().equals(targetFeature)) {
|
||||
currentPath.add(icon);
|
||||
return currentPath;
|
||||
}
|
||||
|
||||
@ -9,4 +9,6 @@ public interface ExTiVehicleFunctionService {
|
||||
|
||||
public JSONObject queryById(Long id);
|
||||
|
||||
public JSONObject findNextClickToFunction(Long vehicleConfigId, String currentUi, String clickFunction);
|
||||
|
||||
}
|
||||
|
||||
@ -5,10 +5,16 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.cmvr.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@ApiModel("触控交互--车机界面")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TiVehicleUi extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -2,12 +2,18 @@ package com.cmvr.ti.model.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ApiModel("触控交互--车机功能列表查询")
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TiVehicleFunctionVO {
|
||||
|
||||
@ApiModelProperty("车辆配置ID")
|
||||
|
||||
@ -4,13 +4,24 @@ import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cmvr.common.core.domain.entity.SysDictData;
|
||||
import com.cmvr.common.exception.GlobalException;
|
||||
import com.cmvr.common.utils.StringUtils;
|
||||
import com.cmvr.system.domain.vo.CarIcon;
|
||||
import com.cmvr.system.domain.vo.CarUi;
|
||||
import com.cmvr.system.service.ISysDictTypeService;
|
||||
import com.cmvr.system.util.CarPathFinderUtil;
|
||||
import com.cmvr.test.service.ex.ExTiVehicleFunctionService;
|
||||
import com.cmvr.ti.model.domain.TiVehicleFunction;
|
||||
import com.cmvr.ti.model.domain.TiVehicleUi;
|
||||
import com.cmvr.ti.model.vo.TiVehicleFunctionVO;
|
||||
import com.cmvr.ti.service.ITiVehicleFunctionService;
|
||||
import com.cmvr.ti.service.ITiVehicleUiService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -18,6 +29,11 @@ public class ExTiVehicleFunctionServiceImpl implements ExTiVehicleFunctionServic
|
||||
|
||||
private final ITiVehicleFunctionService tiVehicleFunctionService;
|
||||
|
||||
private final ITiVehicleUiService tiVehicleUiService;
|
||||
|
||||
private final ISysDictTypeService iSysDictTypeService;
|
||||
|
||||
|
||||
@Override
|
||||
public JSONArray queryByIds(String ids) {
|
||||
List<TiVehicleFunction> tiVehicleFunctions = tiVehicleFunctionService.listByIds(StrUtil.split(StrPool.COMMA, ids));
|
||||
@ -29,5 +45,92 @@ public class ExTiVehicleFunctionServiceImpl implements ExTiVehicleFunctionServic
|
||||
return JSONObject.from(tiVehicleFunctionService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 寻找从当前页面到能执行目标功能的最短点击路径
|
||||
* 返回:点击的功能序列(JSONArray 包装 List<TiVehicleFunction>)
|
||||
*/
|
||||
@Override
|
||||
public JSONObject findNextClickToFunction(
|
||||
Long vehicleConfigId,
|
||||
String startUiName,
|
||||
String targetFuncName) {
|
||||
// 功能字典
|
||||
// 实际用的是 sys_dict_data,这里假设你有方法能查到 data 列表
|
||||
List<SysDictData> functionDictData = iSysDictTypeService.selectDictDataByType("ti_function_config");
|
||||
|
||||
// 界面字典
|
||||
List<SysDictData> uiDictData = iSysDictTypeService.selectDictDataByType("ti_ui_config");
|
||||
|
||||
// 构建 功能 value → label 的映射
|
||||
Map<String, String> funcValueToLabel = new HashMap<>();
|
||||
for (SysDictData data : functionDictData) {
|
||||
funcValueToLabel.put(data.getDictValue(), data.getDictLabel());
|
||||
}
|
||||
|
||||
// 构建 界面 value → label 的映射
|
||||
Map<String, String> uiValueToLabel = new HashMap<>();
|
||||
for (SysDictData data : uiDictData) {
|
||||
uiValueToLabel.put(data.getDictValue(), data.getDictLabel());
|
||||
}
|
||||
|
||||
// 1. 查询当前车型的实际界面和功能数据
|
||||
List<TiVehicleUi> uiList = tiVehicleUiService.selectTiVehicleUiList(
|
||||
TiVehicleUi.builder().vehicleConfigId(vehicleConfigId).build());
|
||||
|
||||
List<TiVehicleFunction> funcList = tiVehicleFunctionService.selectTiVehicleFunctionList(
|
||||
TiVehicleFunctionVO.builder().vehicleConfigId(vehicleConfigId).build());
|
||||
|
||||
// 2. uiKey → TiVehicleUi
|
||||
Map<String, TiVehicleUi> uiByKey = new HashMap<String, TiVehicleUi>();
|
||||
for (TiVehicleUi ui : uiList) {
|
||||
uiByKey.put(ui.getUiKey(), ui);
|
||||
}
|
||||
|
||||
// 3. funcKey → TiVehicleFunction
|
||||
Map<Long, TiVehicleFunction> funcById = new HashMap<Long, TiVehicleFunction>();
|
||||
for (TiVehicleFunction f : funcList) {
|
||||
funcById.put(f.getId(), f);
|
||||
}
|
||||
// 4.组装uiMap
|
||||
Map<String, CarUi> uiMap = new HashMap<>();
|
||||
List<CarIcon> icons;
|
||||
CarUi carUi;
|
||||
for (TiVehicleUi ui : uiList) {
|
||||
icons = new ArrayList<>();
|
||||
for (String funcId : StringUtils.split(ui.getFuncIds(), StrPool.COMMA)) {
|
||||
TiVehicleFunction func = funcById.get(Long.valueOf(funcId));
|
||||
CarIcon icon = new CarIcon(
|
||||
funcValueToLabel.get(func.getFuncKey()),
|
||||
func.getIconUrl(),
|
||||
"",
|
||||
"",
|
||||
"1".equals(func.getRemark()) ? funcValueToLabel.get(func.getFuncKey()) : ""
|
||||
);
|
||||
icons.add(icon);
|
||||
}
|
||||
carUi = new CarUi(
|
||||
uiValueToLabel.get(ui.getUiKey()),
|
||||
ui.getUiUrl(),
|
||||
icons
|
||||
);
|
||||
uiMap.put(carUi.getUiName(), carUi);
|
||||
}
|
||||
// 5.获取路径
|
||||
List<CarIcon> path = CarPathFinderUtil.findPath(uiMap, startUiName, targetFuncName);
|
||||
if (CollectionUtils.isEmpty(path)) {
|
||||
throw new GlobalException("没有找到匹配的路径");
|
||||
}
|
||||
// 组装结果
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("nextLocation", path.get(0).getIconName());
|
||||
map.put("isEnd", path.size() == 1);
|
||||
map.put("iconUrl", path.get(0).getIconImage());
|
||||
|
||||
return JSONObject.from(map);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user