This commit is contained in:
2025-11-05 14:28:35 +08:00
parent d6fb143ac8
commit e2bb5ac6bc
21 changed files with 532 additions and 58 deletions

View File

@ -91,13 +91,6 @@ public class FileInfoController {
// 计算文件MD5用于校验文件完整性 // 计算文件MD5用于校验文件完整性
String fileMd5 = DigestUtil.md5Hex(destFile); String fileMd5 = DigestUtil.md5Hex(destFile);
// 查询有没有文件名一样并且 MD5 也一样的数据
LambdaQueryWrapper<FileInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FileInfo::getFileName, originalFilename).eq(FileInfo::getFileMd5, fileMd5);
if (fileInfoService.count(queryWrapper) > 0) {
return ApiResponse.failure("已存在文件名相同且内容完全一致的文件");
}
// 保存文件信息到数据库 // 保存文件信息到数据库
FileInfo fileInfo = new FileInfo(); FileInfo fileInfo = new FileInfo();
fileInfo.setFileName(originalFilename); fileInfo.setFileName(originalFilename);

View File

@ -5,7 +5,11 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yj.earth.annotation.CheckAuth; import com.yj.earth.annotation.CheckAuth;
import com.yj.earth.business.domain.Role; import com.yj.earth.business.domain.Role;
import com.yj.earth.business.domain.RoleMenu;
import com.yj.earth.business.domain.RoleOperate;
import com.yj.earth.business.domain.User; import com.yj.earth.business.domain.User;
import com.yj.earth.business.service.RoleMenuService;
import com.yj.earth.business.service.RoleOperateService;
import com.yj.earth.business.service.RoleService; import com.yj.earth.business.service.RoleService;
import com.yj.earth.business.service.UserService; import com.yj.earth.business.service.UserService;
import com.yj.earth.common.util.ApiResponse; import com.yj.earth.common.util.ApiResponse;
@ -34,12 +38,18 @@ public class RoleController {
private RoleService roleService; private RoleService roleService;
@Resource @Resource
private UserService userService; private UserService userService;
@Resource
private RoleOperateService roleOperateService;
@Resource
private RoleMenuService roleMenuService;
@Operation(summary = "新增角色") @Operation(summary = "新增角色")
@PostMapping("/add") @PostMapping("/add")
public ApiResponse save(@RequestBody AddRoleDto addRoleDto) { public ApiResponse save(@RequestBody AddRoleDto addRoleDto) {
Role role = new Role(); Role role = new Role();
BeanUtils.copyProperties(addRoleDto, role); BeanUtils.copyProperties(addRoleDto, role);
// 设置默认不是管理员
role.setIsSuper(0);
roleService.save(role); roleService.save(role);
return ApiResponse.success(null); return ApiResponse.success(null);
} }
@ -126,6 +136,24 @@ public class RoleController {
return ApiResponse.success(null); return ApiResponse.success(null);
} }
@Operation(summary = "根据角色ID返回权限信息")
@GetMapping("/getOptionByRoleId")
public ApiResponse getOptionByRoleId(@RequestParam(required = true) @Parameter(description = "角色ID") String roleId) {
// 查询角色操作表
LambdaQueryWrapper<RoleOperate> operateLambdaQueryWrapper = new LambdaQueryWrapper<>();
operateLambdaQueryWrapper.eq(RoleOperate::getRoleId, roleId);
List<RoleOperate> roleOperates = roleOperateService.list(operateLambdaQueryWrapper);
// 查询角色菜单表
LambdaQueryWrapper<RoleMenu> menuLambdaQueryWrapper = new LambdaQueryWrapper<>();
menuLambdaQueryWrapper.eq(RoleMenu::getRoleId, roleId);
List<RoleMenu> roleMenus = roleMenuService.list(menuLambdaQueryWrapper);
// 返回数据
Map<String, Object> data = new HashMap<>();
data.put("roleOperates", roleOperates);
data.put("roleMenus", roleMenus);
return ApiResponse.success(data);
}
@Operation(summary = "根据角色ID返回用户信息") @Operation(summary = "根据角色ID返回用户信息")
@GetMapping("/getUsersByRoleId") @GetMapping("/getUsersByRoleId")
public ApiResponse getUsersByRoleId(@Parameter(description = "角色ID") String roleId) { public ApiResponse getUsersByRoleId(@Parameter(description = "角色ID") String roleId) {

View File

@ -35,23 +35,19 @@ public class RoleMenuController {
if (permissionList == null || permissionList.isEmpty()) { if (permissionList == null || permissionList.isEmpty()) {
return ApiResponse.success(null); return ApiResponse.success(null);
} }
// 遍历权限列表中的每一组配置 // 遍历权限列表中的每一组配置
for (Map<String, List<String>> permissionMap : permissionList) { for (Map<String, List<String>> permissionMap : permissionList) {
if (permissionMap == null || permissionMap.isEmpty()) { if (permissionMap == null || permissionMap.isEmpty()) {
continue; continue;
} }
// 遍历每个菜单的权限配置 // 遍历每个菜单的权限配置
Set<Map.Entry<String, List<String>>> entries = permissionMap.entrySet(); Set<Map.Entry<String, List<String>>> entries = permissionMap.entrySet();
for (Map.Entry<String, List<String>> entry : entries) { for (Map.Entry<String, List<String>> entry : entries) {
String menu = entry.getKey(); String menu = entry.getKey();
List<String> permissions = entry.getValue(); List<String> permissions = entry.getValue();
if (permissions == null) { if (permissions == null) {
permissions = new ArrayList<>(); permissions = new ArrayList<>();
} }
if (permissions.isEmpty()) { if (permissions.isEmpty()) {
RoleMenu roleMenu = new RoleMenu(); RoleMenu roleMenu = new RoleMenu();
roleMenu.setRoleId(roleId); roleMenu.setRoleId(roleId);
@ -69,7 +65,6 @@ public class RoleMenuController {
} }
} }
} }
return ApiResponse.success(null); return ApiResponse.success(null);
} }
@ -83,9 +78,47 @@ public class RoleMenuController {
@Operation(summary = "修改角色菜单权限") @Operation(summary = "修改角色菜单权限")
@PostMapping("/update") @PostMapping("/update")
public ApiResponse update(@RequestBody UpdateMenuDto updateMenuDto) { public ApiResponse update(@RequestBody UpdateMenuDto updateMenuDto) {
// 先删除角色菜单权限
LambdaQueryWrapper<RoleMenu> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RoleMenu::getRoleId, updateMenuDto.getRoleId());
roleMenuService.remove(queryWrapper);
// 再新增
String roleId = updateMenuDto.getRoleId();
List<Map<String, List<String>>> permissionList = updateMenuDto.getPermissionList();
if (permissionList == null || permissionList.isEmpty()) {
return ApiResponse.success(null);
}
// 遍历权限列表中的每一组配置
for (Map<String, List<String>> permissionMap : permissionList) {
if (permissionMap == null || permissionMap.isEmpty()) {
continue;
}
// 遍历每个菜单的权限配置
Set<Map.Entry<String, List<String>>> entries = permissionMap.entrySet();
for (Map.Entry<String, List<String>> entry : entries) {
String menu = entry.getKey();
List<String> permissions = entry.getValue();
if (permissions == null) {
permissions = new ArrayList<>();
}
if (permissions.isEmpty()) {
RoleMenu roleMenu = new RoleMenu(); RoleMenu roleMenu = new RoleMenu();
BeanUtils.copyProperties(updateMenuDto, roleMenu); roleMenu.setRoleId(roleId);
roleMenuService.updateById(roleMenu); roleMenu.setMenu(menu);
roleMenu.setPermission(null);
roleMenuService.save(roleMenu);
} else {
for (String permission : permissions) {
RoleMenu roleMenu = new RoleMenu();
roleMenu.setRoleId(roleId);
roleMenu.setMenu(menu);
roleMenu.setPermission(permission);
roleMenuService.save(roleMenu);
}
}
}
}
return ApiResponse.success(null); return ApiResponse.success(null);
} }

View File

@ -46,9 +46,17 @@ public class RoleOperateController {
@Operation(summary = "修改角色操作权限") @Operation(summary = "修改角色操作权限")
@PostMapping("/update") @PostMapping("/update")
public ApiResponse update(@RequestBody UpdateRoleOperateDto updateRoleOperateDto) { public ApiResponse update(@RequestBody UpdateRoleOperateDto updateRoleOperateDto) {
// 删除原有的角色操作权限
LambdaQueryWrapper<RoleOperate> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RoleOperate::getRoleId, updateRoleOperateDto.getRoleId());
roleOperateService.remove(queryWrapper);
List<String> operateList = updateRoleOperateDto.getOperateList();
for (String operate : operateList) {
RoleOperate roleOperate = new RoleOperate(); RoleOperate roleOperate = new RoleOperate();
BeanUtils.copyProperties(updateRoleOperateDto, roleOperate); roleOperate.setRoleId(updateRoleOperateDto.getRoleId());
roleOperateService.updateById(roleOperate); roleOperate.setOperate(operate);
roleOperateService.save(roleOperate);
}
return ApiResponse.success(null); return ApiResponse.success(null);
} }

View File

@ -2,7 +2,9 @@ package com.yj.earth.business.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yj.earth.business.domain.TsEvent; import com.yj.earth.business.domain.TsEvent;
import com.yj.earth.business.domain.TsSource;
import com.yj.earth.business.service.TsEventService; import com.yj.earth.business.service.TsEventService;
import com.yj.earth.business.service.TsSourceService;
import com.yj.earth.common.util.ApiResponse; import com.yj.earth.common.util.ApiResponse;
import com.yj.earth.dto.tsEvent.AddTsEventDto; import com.yj.earth.dto.tsEvent.AddTsEventDto;
import com.yj.earth.dto.tsEvent.UpdateTsEventDto; import com.yj.earth.dto.tsEvent.UpdateTsEventDto;
@ -13,6 +15,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Tag(name = "态势事件管理") @Tag(name = "态势事件管理")
@ -21,6 +26,8 @@ import javax.annotation.Resource;
public class TsEventController { public class TsEventController {
@Resource @Resource
private TsEventService tsEventService; private TsEventService tsEventService;
@Resource
private TsSourceService tsSourceService;
@PostMapping("/add") @PostMapping("/add")
@Operation(summary = "添加态势事件") @Operation(summary = "添加态势事件")
@ -50,10 +57,32 @@ public class TsEventController {
@Operation(summary = "查询某个态势方案下资源下的事件") @Operation(summary = "查询某个态势方案下资源下的事件")
public ApiResponse query( public ApiResponse query(
@Parameter(description = "态势方案ID") @RequestParam(required = true) String planId, @Parameter(description = "态势方案ID") @RequestParam(required = true) String planId,
@Parameter(description = "态势资源ID") @RequestParam(required = true) String sourceId) { @Parameter(description = "态势资源ID") @RequestParam(required = false) String sourceId) {
LambdaQueryWrapper<TsEvent> queryWrapper = new LambdaQueryWrapper<>(); List<String> sourceIdList;
queryWrapper.eq(TsEvent::getPlanId, planId); if (sourceId == null) {
queryWrapper.eq(TsEvent::getSourceId, sourceId); // 查询该方案下所有资源ID
return ApiResponse.success(tsEventService.list(queryWrapper)); LambdaQueryWrapper<TsSource> sourceWrapper = new LambdaQueryWrapper<>();
sourceWrapper.eq(TsSource::getPlanId, planId);
sourceIdList = tsSourceService.list(sourceWrapper)
.stream()
.map(TsSource::getId)
.collect(Collectors.toList());
} else {
sourceIdList = Collections.singletonList(sourceId);
}
// 若资源ID列表为空、直接返回空结果、避免无效查询
if (sourceIdList.isEmpty()) {
return ApiResponse.success(Collections.emptyList());
}
// 查询事件
LambdaQueryWrapper<TsEvent> eventWrapper = new LambdaQueryWrapper<>();
eventWrapper.eq(TsEvent::getPlanId, planId).in(TsEvent::getSourceId, sourceIdList);
return ApiResponse.success(tsEventService.list(eventWrapper));
} }
} }

View File

@ -1,9 +1,13 @@
package com.yj.earth.business.controller; package com.yj.earth.business.controller;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yj.earth.business.domain.TsSource; import com.yj.earth.business.domain.TsSource;
import com.yj.earth.business.service.TsSourceService; import com.yj.earth.business.service.TsSourceService;
import com.yj.earth.common.util.ApiResponse; import com.yj.earth.common.util.ApiResponse;
import com.yj.earth.common.util.JsonUtil;
import com.yj.earth.common.util.MapUtil;
import com.yj.earth.dto.tsSource.AddTsModelSourceDto;
import com.yj.earth.dto.tsSource.AddTsSourceDto; import com.yj.earth.dto.tsSource.AddTsSourceDto;
import com.yj.earth.dto.tsSource.UpdateTsSourceDto; import com.yj.earth.dto.tsSource.UpdateTsSourceDto;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -14,6 +18,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import static com.yj.earth.common.constant.GlobalConstant.SHOW;
@Tag(name = "态势资源管理") @Tag(name = "态势资源管理")
@RestController @RestController
@RequestMapping("/tsSource") @RequestMapping("/tsSource")
@ -52,4 +58,36 @@ public class TsSourceController {
queryWrapper.eq(TsSource::getPlanId, id); queryWrapper.eq(TsSource::getPlanId, id);
return ApiResponse.success(tsSourceService.list(queryWrapper)); return ApiResponse.success(tsSourceService.list(queryWrapper));
} }
@Operation(summary = "添加态势模型资源")
@PostMapping("/addTsModelSource")
public ApiResponse addTsModelSource(@RequestBody AddTsModelSourceDto addTsModelSourceDto) {
// 获取资源绝对路径
String sourcePath = addTsModelSourceDto.getSourcePath();
// 获取资源名称
String sourceName = FileUtil.mainName(sourcePath);
// 校验是否通过
String message = tsSourceService.checkIsPass(addTsModelSourceDto.getParentId(), sourceName);
if (message != null) {
return null;
}
// 调用SDK加载资源
String sourceId = tsSourceService.addAndGetSourceId(sourcePath);
// 获取文件路径并处理详情
String detail = tsSourceService.getDetail(sourcePath, sourceId);
// 构建并保存资源对象
TsSource tsSource = new TsSource();
tsSource.setId(addTsModelSourceDto.getId());
tsSource.setSourcePath(sourcePath);
tsSource.setSourceName(sourceName);
tsSource.setParentId(addTsModelSourceDto.getParentId());
tsSource.setTreeIndex(addTsModelSourceDto.getTreeIndex());
tsSource.setParams(JsonUtil.mapToJson(addTsModelSourceDto.getParams()));
tsSource.setDetail(detail);
tsSource.setSourceType(MapUtil.getString(MapUtil.jsonToMap(detail), "fileType"));
tsSource.setIsShow(SHOW);
tsSource.setPlanId(addTsModelSourceDto.getPlanId());
tsSourceService.save(tsSource);
return ApiResponse.success(tsSource);
}
} }

View File

@ -45,7 +45,7 @@ public class UserController {
@Operation(summary = "新增用户") @Operation(summary = "新增用户")
@PostMapping("/add") @PostMapping("/add")
@RoleAccess(roleNames = "管理员")
public ApiResponse save(@RequestBody AddUserDto addUserDto) { public ApiResponse save(@RequestBody AddUserDto addUserDto) {
User user = new User(); User user = new User();
BeanUtils.copyProperties(addUserDto, user); BeanUtils.copyProperties(addUserDto, user);
@ -90,7 +90,6 @@ public class UserController {
@Operation(summary = "用户列表") @Operation(summary = "用户列表")
@GetMapping("/list") @GetMapping("/list")
@RoleAccess(roleNames = "管理员")
public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum, @Parameter(description = "分页大小") Integer pageSize, @Parameter(description = "搜索字段") String searchKey, @Parameter(description = "角色ID") String roleId, @Parameter(description = "用户状态") Integer status) { public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum, @Parameter(description = "分页大小") Integer pageSize, @Parameter(description = "搜索字段") String searchKey, @Parameter(description = "角色ID") String roleId, @Parameter(description = "用户状态") Integer status) {
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
// 根据用户名或者昵称进行模糊搜索 // 根据用户名或者昵称进行模糊搜索
@ -111,7 +110,7 @@ public class UserController {
@Operation(summary = "设置角色") @Operation(summary = "设置角色")
@PostMapping("/userBindOrUnBindRole") @PostMapping("/userBindOrUnBindRole")
@RoleAccess(roleNames = "管理员")
public ApiResponse userBindOrUnBindRole(@RequestBody UserBindOrUnBindRoleDto userBindOrUnBindRoleDto) { public ApiResponse userBindOrUnBindRole(@RequestBody UserBindOrUnBindRoleDto userBindOrUnBindRoleDto) {
userService.lambdaUpdate().set(User::getRoleId, userBindOrUnBindRoleDto.getRoleId()).eq(User::getId, userBindOrUnBindRoleDto.getUserId()).update(); userService.lambdaUpdate().set(User::getRoleId, userBindOrUnBindRoleDto.getRoleId()).eq(User::getId, userBindOrUnBindRoleDto.getUserId()).update();
return ApiResponse.success(null); return ApiResponse.success(null);
@ -145,6 +144,7 @@ public class UserController {
data.put("token", tokenInfo.getTokenValue()); data.put("token", tokenInfo.getTokenValue());
data.put("roleOperates", roleOperates); data.put("roleOperates", roleOperates);
data.put("roleMenus", roleMenus); data.put("roleMenus", roleMenus);
data.put("avatar", user.getAvatar());
return ApiResponse.success(data); return ApiResponse.success(data);
} }
@ -180,7 +180,7 @@ public class UserController {
@Operation(summary = "设置新密码") @Operation(summary = "设置新密码")
@PostMapping("/setNewPassword") @PostMapping("/setNewPassword")
@RoleAccess(roleNames = "管理员")
public ApiResponse setNewPassword(@RequestBody SetNewPasswordDto setNewPasswordDto) { public ApiResponse setNewPassword(@RequestBody SetNewPasswordDto setNewPasswordDto) {
User user = userService.getById(setNewPasswordDto.getId()); User user = userService.getById(setNewPasswordDto.getId());
if (user == null) { if (user == null) {
@ -206,7 +206,7 @@ public class UserController {
if (role == null) { if (role == null) {
return ApiResponse.failure("角色不存在"); return ApiResponse.failure("角色不存在");
} }
if (role.getIsSuper() == 1) { if (role.getIsSuper() != null && role.getIsSuper() == 1) {
return ApiResponse.success(true); return ApiResponse.success(true);
} }
return ApiResponse.success(false); return ApiResponse.success(false);

View File

@ -45,7 +45,7 @@ public class WebSourceController {
private PbfInfoService pbfInfoService; private PbfInfoService pbfInfoService;
private static final List<String> SUPPORT_EXTENSIONS = Arrays.asList("clt", "mbtiles", "pak", "pbf", "model"); private static final List<String> SUPPORT_EXTENSIONS = Arrays.asList("clt", "mbtiles", "pak", "pbf", "model");
@RoleAccess(roleNames = "管理员")
@Operation(summary = "同步数据") @Operation(summary = "同步数据")
@PostMapping("/sync") @PostMapping("/sync")
public ApiResponse sync() { public ApiResponse sync() {

View File

@ -11,6 +11,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface SourceService extends IService<Source> { public interface SourceService extends IService<Source> {
String checkIsPass(String parentId, String sourceName);
String addAndGetSourceId(String sourcePath); String addAndGetSourceId(String sourcePath);
String getDetail(String sourcePath, String sourceId); String getDetail(String sourcePath, String sourceId);
@ -25,7 +27,5 @@ public interface SourceService extends IService<Source> {
Map<String, Object> getSourceListByUserId(String userId, String type, String name, Integer pageNum, Integer pageSize, LocalDateTime startTime, LocalDateTime endTime); Map<String, Object> getSourceListByUserId(String userId, String type, String name, Integer pageNum, Integer pageSize, LocalDateTime startTime, LocalDateTime endTime);
String checkIsPass(String parentId, String sourceName);
Source addModelSource(AddModelSourceDto addModelSourceDto); Source addModelSource(AddModelSourceDto addModelSourceDto);
} }

View File

@ -3,14 +3,11 @@ package com.yj.earth.business.service;
import com.yj.earth.business.domain.TsSource; import com.yj.earth.business.domain.TsSource;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author 周志雄
* @since 2025-11-03
*/
public interface TsSourceService extends IService<TsSource> { public interface TsSourceService extends IService<TsSource> {
String checkIsPass(String parentId, String sourceName);
String addAndGetSourceId(String sourcePath);
String getDetail(String sourcePath, String sourceId);
} }

View File

@ -83,7 +83,6 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
if (parentId != null) { if (parentId != null) {
LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Source> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Source::getId, parentId); queryWrapper.eq(Source::getId, parentId);
List<Source> list = sourceService.list(queryWrapper);
if (sourceService.count(queryWrapper) == 0) { if (sourceService.count(queryWrapper) == 0) {
return "父级不存在"; return "父级不存在";
} }

View File

@ -1,20 +1,108 @@
package com.yj.earth.business.service.impl; package com.yj.earth.business.service.impl;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yj.earth.business.domain.TsSource; import com.yj.earth.business.domain.TsSource;
import com.yj.earth.business.mapper.TsSourceMapper; import com.yj.earth.business.mapper.TsSourceMapper;
import com.yj.earth.business.service.TsSourceService; import com.yj.earth.business.service.TsSourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yj.earth.common.config.ServerConfig;
import com.yj.earth.common.util.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** import javax.annotation.Resource;
* <p> import java.util.HashMap;
* 服务实现类 import java.util.Map;
* </p> import java.util.function.Function;
*
* @author 周志雄
* @since 2025-11-03
*/
@Service @Service
@Slf4j
public class TsSourceServiceImpl extends ServiceImpl<TsSourceMapper, TsSource> implements TsSourceService { public class TsSourceServiceImpl extends ServiceImpl<TsSourceMapper, TsSource> implements TsSourceService {
@Resource
private ServerConfig serverConfig;
@Resource
private TsSourceService tsSourceService;
// 存储文件后缀与对应处理函数的映射关系
public final Map<String, Function<String, String>> detailFetchers;
// 初始化映射关系
public TsSourceServiceImpl() {
detailFetchers = new HashMap<>();
detailFetchers.put("clt", this::fetchCltDetail);
detailFetchers.put("mbtiles", this::fetchMbtilesDetail);
detailFetchers.put("pak", this::fetchPakDetail);
}
/**
* 调用SDK获取资源ID
*/
@Override
public String addAndGetSourceId(String sourcePath) {
Map<String, Object> addParams = new HashMap<>();
addParams.put("filePath", sourcePath);
String url = buildSdkUrl("/sourceMap/add");
return HttpUtil.doPostForm(url, addParams);
}
/**
* 检测资源是否通过审核
*/
@Override
public String checkIsPass(String parentId, String sourceName) {
// 先查询父节点是否存在
if (parentId != null) {
LambdaQueryWrapper<TsSource> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TsSource::getId, parentId);
if (tsSourceService.count(queryWrapper) == 0) {
return "父级不存在";
}
}
return null;
}
@Override
public String getDetail(String sourcePath, String sourceId) {
String ext = FileUtil.extName(sourcePath);
// 通过映射关系获取并执行对应的处理函数
Function<String, String> fetcher = detailFetchers.get(ext);
if (fetcher != null) {
String detailResult = fetcher.apply(sourceId);
return detailResult;
} else {
log.info("未找到{}类型的处理方式", ext);
}
return null;
}
public String buildSdkUrl(String path) {
return "http://" + serverConfig.getHost() + ":" + serverConfig.getSdkPort() + path;
}
/**
* 获取 CLT 类型资源详情
*/
public String fetchCltDetail(String sourceId) {
String url = buildSdkUrl("/data/clt/detail/" + sourceId);
return HttpUtil.doGet(url);
}
/**
* 获取 MBTiles 类型资源详情
*/
public String fetchMbtilesDetail(String sourceId) {
String url = buildSdkUrl("/data/mbtiles/detail/" + sourceId);
return HttpUtil.doGet(url);
}
/**
* 获取 PAK 类型资源详情
*/
public String fetchPakDetail(String sourceId) {
String url = buildSdkUrl("/data/pak/detail/" + sourceId);
return HttpUtil.doGet(url);
}
} }

View File

@ -3,14 +3,13 @@ package com.yj.earth.dto.roleMenu;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.util.List;
import java.util.Map;
@Data @Data
public class UpdateMenuDto { public class UpdateMenuDto {
@Schema(description = "主键")
private String id;
@Schema(description = "角色ID") @Schema(description = "角色ID")
private String roleId; private String roleId;
@Schema(description = "菜单") @Schema(description = "权限列表")
private String menu; private List<Map<String, List<String>>> permissionList;
@Schema(description = "权限")
private String permission;
} }

View File

@ -3,12 +3,12 @@ package com.yj.earth.dto.roleOperate;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
public class UpdateRoleOperateDto { public class UpdateRoleOperateDto {
@Schema(description = "主键")
private String id;
@Schema(description = "角色ID") @Schema(description = "角色ID")
private String roleId; private String roleId;
@Schema(description = "操作") @Schema(description = "操作")
private String operate; private List<String> operateList;
} }

View File

@ -0,0 +1,22 @@
package com.yj.earth.dto.tsSource;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Map;
@Data
public class AddTsModelSourceDto {
@Schema(description = "态势方案ID")
private String planId;
@Schema(description = "资源ID")
private String id;
@Schema(description = "资源路径")
private String sourcePath;
@Schema(description = "父节点ID")
private String parentId;
@Schema(description = "树状索引")
private Integer treeIndex;
@Schema(description = "前端参数")
private Map<String, Object> params;
}

View File

@ -0,0 +1,15 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
@Data
@SourceType("arcgisBlueImagery")
public class ArcgisBlueImagery {
private String id;
private String name;
private Boolean show;
private Integer alpha;
private Integer brightness;
private Integer layerIndex;
}

View File

@ -0,0 +1,15 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
@Data
@SourceType("arcgisWximagery")
public class ArcgisWximagery {
private String id;
private String name;
private Boolean show;
private Integer alpha;
private Integer brightness;
private Integer layerIndex;
}

View File

@ -0,0 +1,15 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
@Data
@SourceType("gdlwImagery")
public class GdlwImagery {
private String id;
private String name;
private Boolean show;
private Integer alpha;
private Integer brightness;
private Integer layerIndex;
}

View File

@ -0,0 +1,15 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
@Data
@SourceType("gdslImagery")
public class GdslImagery {
private String id;
private String name;
private Boolean show;
private Integer alpha;
private Integer brightness;
private Integer layerIndex;
}

View File

@ -0,0 +1,76 @@
package com.yj.earth.params;
import com.yj.earth.annotation.SourceType;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
@SourceType("sector")
public class Sector {
private String id;
private String name;
private Center center;
private double radius;
private double startAngle;
private double endAngle;
private boolean show;
private String color;
private int heightMode;
private int semiMinorAxis;
private int semiMajorAxis;
private Line line;
private Label label;
private Attribute attribute;
private String richTextContent;
private Map<String, Object> customView;
@Data
public static class Center {
private double lng;
private double lat;
private double alt;
}
@Data
public static class Line {
private int width;
private String color;
}
@Data
public static class Label {
private String text;
private boolean show;
private Position position;
private int fontSize;
private int fontFamily;
private String color;
private int lineWidth;
private int pixelOffset;
private List<String> backgroundColor;
private String lineColor;
private boolean scaleByDistance;
private int near;
private int far;
private boolean ground;
@Data
public static class Position {
private double lng;
private double lat;
private double alt;
}
}
@Data
public static class Attribute {
private Link link;
}
@Data
public static class Link {
private List<Object> content;
}
}

View File

@ -0,0 +1,104 @@
package com.yj.earth.word;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STShd;
import java.io.FileOutputStream;
import java.io.IOException;
public class GenerateDocx {
public static void main(String[] args) {
// 创建文档对象
XWPFDocument document = new XWPFDocument();
try {
// 添加标题段落
XWPFParagraph titlePara = document.createParagraph();
titlePara.setAlignment(ParagraphAlignment.CENTER);
XWPFRun titleRun = titlePara.createRun();
titleRun.setText("POI 生成 Docx 示例");
// 字体大小
titleRun.setFontSize(20);
// 加粗
titleRun.setBold(true);
// 字体
titleRun.setFontFamily("宋体");
// 添加正文段落
XWPFParagraph contentPara1 = document.createParagraph();
contentPara1.setAlignment(ParagraphAlignment.LEFT);
XWPFRun run1 = contentPara1.createRun();
run1.setText("这是使用 Apache POI 生成的 docx 文档。");
run1.setFontSize(12);
run1.setFontFamily("微软雅黑");
// 换行
XWPFParagraph contentPara2 = document.createParagraph();
XWPFRun run2 = contentPara2.createRun();
run2.setText("支持设置文本样式,如:");
run2.setFontSize(12);
// 文本样式示例(同一行不同样式)
XWPFRun run3 = contentPara2.createRun();
run3.setText(" 加粗 ");
run3.setBold(true);
XWPFRun run4 = contentPara2.createRun();
run4.setText(" 斜体 ");
run4.setItalic(true);
XWPFRun run5 = contentPara2.createRun();
run5.setText(" 下划线 ");
run5.setUnderline(UnderlinePatterns.SINGLE); // 单下划线
XWPFRun run6 = contentPara2.createRun();
run6.setText(" 红色 ");
run6.setColor("FF0000"); // 红色
// 添加表格
int rows = 3; // 3行
int cols = 3; // 3列
XWPFTable table = document.createTable(rows, cols);
table.setWidth("100%"); // 表格宽度
// 设置表头
XWPFTableRow headerRow = table.getRow(0);
headerRow.getCell(0).setText("ID");
headerRow.getCell(1).setText("名称");
headerRow.getCell(2).setText("描述");
// 表头背景色(浅灰色)
for (XWPFTableCell cell : headerRow.getTableCells()) {
CTShd cTShd = cell.getCTTc().addNewTcPr().addNewShd();
cTShd.setVal(STShd.CLEAR);
cTShd.setFill("D9D9D9"); // 浅灰色
}
// 设置表格内容
XWPFTableRow row1 = table.getRow(1);
row1.getCell(0).setText("1");
row1.getCell(1).setText("POI");
row1.getCell(2).setText("处理 Office 文档的 Java 库");
XWPFTableRow row2 = table.getRow(2);
row2.getCell(0).setText("2");
row2.getCell(1).setText("Docx");
row2.getCell(2).setText("Word 2007+ 格式");
// 保存文档到本地
FileOutputStream out = new FileOutputStream("poi-demo.docx");
document.write(out);
out.close();
System.out.println("docx 生成成功!");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
document.close(); // 关闭文档,释放资源
} catch (IOException e) {
e.printStackTrace();
}
}
}
}