Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-09-28 16:34:09 +08:00
commit ac5c1ed33d
24 changed files with 513 additions and 442 deletions

View File

@ -0,0 +1,4 @@
alter table `joylink`.`project`
drop COLUMN `name_en`,
CHANGE COLUMN `simple_name` `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL comment '项目简称' AFTER `code`,
CHANGE COLUMN `name` `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL comment '项目描述' AFTER `name`;

View File

@ -5,6 +5,8 @@ import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.services.project.ProjectService;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.project.ProjectViewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -50,9 +52,9 @@ public class ProjectInfoController {
projectService.save(project);
}
@GetMapping("/simple")
public List<Project.SimpleProject> queryProjectSimpleInfo() {
return projectService.getSimpleProjectList();
@GetMapping("/check/code")
public boolean checkProjectCode(String code) {
return projectService.checkProjectCode(code);
}
@GetMapping("/viewSetting/page")
@ -85,14 +87,23 @@ public class ProjectInfoController {
projectService.saveProjectView(projectView);
}
@GetMapping("/check/markKey")
public boolean checkProjectViewMarkKey(String markKey) {
return projectService.checkProjectViewMarkKey(markKey);
}
@GetMapping("/simple")
public List<ProjectVO> queryProjectSimpleInfo() {
return projectService.getSimpleProjectList();
}
@GetMapping("/viewSetting/project/{project}")
public ProjectView.SimpleProjectView queryProjectViewSetting(@PathVariable String project) {
public ProjectViewVO queryProjectViewSetting(@PathVariable String project) {
return projectService.getProjectViewSetting(project);
}
@GetMapping("/viewSetting/simple/all")
public List<ProjectView.SimpleProjectView> queryViewAll() {
public List<ProjectViewVO> queryViewAll() {
return projectService.queryViewAll();
}
}

View File

@ -1,8 +1,6 @@
package club.joylink.rtss.entity.project;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;
@ -17,16 +15,6 @@ import java.util.List;
@Setter
@Getter
public class Project {
/**
* 有效信息标识
*/
public final static Integer EFFECT_PROJECT_STATUS = 1;
/**
* 默认项目的markKey
*/
public final static String DEFAULT_PROJECT_MARK_KEY = "login";
/**
* 默认项目的Code
*/
@ -53,15 +41,10 @@ public class Project {
private String name;
/**
* 项目英文名称
* 描述
*/
private String nameEn;
/**
* 项目简称
*/
private String simpleName;
private String description;
/**
* 创建时间
*/
@ -87,185 +70,8 @@ public class Project {
*/
private String serverSetting;
/**
* 反序列化设置信息
*/
@JsonIgnore
private ProjectServerConfig projectServerConfig;
public void setServerSetting(String serverSetting) {
this.serverSetting = serverSetting;
if (StringUtils.isEmpty(this.serverSetting)) {
this.projectServerConfig = null;
} else {
this.projectServerConfig = JsonUtils.read(this.serverSetting, ProjectServerConfig.class);
}
}
/**
* 是否默认项目
*/
@JsonIgnore
public boolean isDefault() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getDefaultProject() == 1;
}
@JsonIgnore
public static boolean isDefault(String code) {
return StringUtils.isEmpty(code) || DEFAULT_PROJECT_LABEL.contains(code);
}
/**
* 是否登录就创建仿真
*/
@JsonIgnore
public boolean isLoginWithCreateSimulation() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getLoginCreateSimulation() == 1;
}
@JsonIgnore
public boolean isPermissionVail() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getCreateSimulationPermission() == 1;
}
@JsonIgnore
public boolean isCreateLocalSimulation() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getCreateLocalSimulation() == 1;
}
@JsonIgnore
public boolean isMapNeedCharge() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getMapNeedCharge() == 1;
}
/**
* 是否资源免费
*/
@JsonIgnore
public boolean isFreeSource() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getFreeSource() == 1;
}
@JsonIgnore
public boolean isControlDevice() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getControlDevice() == 1;
}
@JsonIgnore
public int getDefaultLoadTrain() {
if (this.projectServerConfig == null) {
return 0;
}
return this.projectServerConfig.getDefaultLoadTrain();
}
@JsonIgnore
public String getDefaultMemberId() {
if (this.projectServerConfig == null) {
return null;
}
return this.projectServerConfig.getDefaultMemberId();
}
/**
* 返回项目编码
*/
public String name() {
return this.code;
}
/**
* 生成项目简单信息
*/
public SimpleProject generateSimpleProject() {
return new SimpleProject(this);
}
@Data
public static class SimpleProject {
private String label;
private String value;
public SimpleProject() {
}
public SimpleProject(Project project) {
this.label = project.getSimpleName();
this.value = project.getCode();
}
public String name() {
return this.value;
}
}
@Data
public static class ProjectServerConfig {
/**
* 默认项目
*/
private int defaultProject;
/**
* 登录后创建仿真
*/
private int loginCreateSimulation;
/**
* 登录时创建仿真的权限判断原BJD使用
*/
private int createSimulationPermission;
/**
* 登录时创建仿真判断WJLS创建现地类型
*/
private int createLocalSimulation;
/**
* 地图需要收费DRTS
*/
private int mapNeedCharge;
/**
* 资源免费CGYZZWW
*/
private int freeSource;
/**
* 需要控制装备HEB
*/
private int controlDevice;
/**
* 默认加载列车数
*/
private int defaultLoadTrain;
/**
* 默认加载角色WJLS默认加载2
*/
private String defaultMemberId;
}
}

View File

@ -1,17 +1,18 @@
package club.joylink.rtss.entity.project;
import club.joylink.rtss.util.JsonUtils;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
@Setter
@Getter
public class ProjectView {
/**
* 默认项目的markKey
*/
public final static String DEFAULT_PROJECT_MARK_KEY = "login";
private Long id;
private String markKey;
@ -25,30 +26,4 @@ public class ProjectView {
private Integer status;
private String viewSetting;
public SimpleProjectView simplifyProjectView() {
return new SimpleProjectView(this);
}
@Setter
@Getter
public static class SimpleProjectView {
private String markKey;
private String project;
private Map<String, Object> viewSetting;
public SimpleProjectView(ProjectView projectView) {
this.markKey = projectView.getMarkKey();
this.project = projectView.getProject();
if (StringUtils.isEmpty(projectView.getViewSetting())) {
this.viewSetting = new HashMap<>();
} else {
this.viewSetting = JsonUtils.read(projectView.getViewSetting(), Map.class);
}
}
}
}

View File

@ -0,0 +1,10 @@
package club.joylink.rtss.services;
import club.joylink.rtss.util.MinioClientUtil;
public interface MinioService {
/**
* 根据目录获取MINIO客户端
*/
MinioClientUtil createMinioClientUtil(String directory);
}

View File

@ -0,0 +1,27 @@
package club.joylink.rtss.services;
import club.joylink.rtss.configuration.MinioClientConfig;
import club.joylink.rtss.util.MinioClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Service
public class MinioServiceImpl implements MinioService {
private Map<String, MinioClientUtil> minioClientMap = new ConcurrentHashMap<>();
@Autowired
private MinioClientConfig minioClientConfig;
@Override
public MinioClientUtil createMinioClientUtil(String directory) {
if (minioClientMap.containsKey(directory)) {
return minioClientMap.get(directory);
}
MinioClientUtil minioClientUtil = MinioClientUtil.getInstance(minioClientConfig, directory);
minioClientMap.put(directory, minioClientUtil);
return minioClientUtil;
}
}

View File

@ -22,6 +22,7 @@ import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.client.project.RelationLoginConfigVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.wx.WmUserSession;
import club.joylink.rtss.websocket.StompMessageService;
import lombok.Getter;
@ -120,25 +121,22 @@ public class AuthenticateService implements IAuthenticateService {
}
}
/**
* TODO 20220922 用于替换上方方法 占位
*/
@Override
public LoginStatusVO getWmLoginUrl(String clientId, String secret, String projectCode, String deviceCode) {
Client client = Client.getByIdAndSecret(clientId, secret);
Project project = projectService.queryLoginProjectByCode(projectCode);
ProjectVO projectVO = projectService.queryLoginProjectByCode(projectCode);
ProjectDeviceVO deviceVO = null;
if (!StringUtils.isEmpty(deviceCode)) {
deviceVO = this.deviceService.getDeviceDetailInfoOf(project.getCode(), deviceCode);
deviceVO = this.deviceService.getDeviceDetailInfoOf(projectVO.name(), deviceCode);
}
String sessionId = RandomGenerator.uuid();
String url = qrCodeManager.getLoginCode(clientId, project.name(), sessionId);
String url = qrCodeManager.getLoginCode(clientId, projectVO.name(), sessionId);
LocalDateTime now = LocalDateTime.now();
LoginStatusVO loginStatusVO = LoginStatusVO.builder()
.url(url)
.sessionId(sessionId)
.client(client)
.projectInfo(project)
.projectVO(projectVO)
.deviceVO(deviceVO)
.time(now)
.lastQueryTime(now)
@ -249,7 +247,7 @@ public class AuthenticateService implements IAuthenticateService {
if (StringUtils.isEmpty(loginStatusVo.getToken())) { //正常扫码登陆
// 构造登陆用户信息
LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(user, loginStatusVo.getClient(),
loginStatusVo.getProjectInfo().name(), loginStatusVo.getDeviceVO());
loginStatusVo.getProjectVO().name(), loginStatusVo.getDeviceVO());
// 设置组织信息
iSysUserService.setOrgInfoOfOrgRelWithTheProject(loginUserInfo.getProjectInfo().name(), user);
// 登陆
@ -354,8 +352,8 @@ public class AuthenticateService implements IAuthenticateService {
@Override
public String loginWithPwd(LoginUserVO loginUser) {
// TODO 20220922
Project project = projectService.queryLoginProjectByCode(loginUser.getProject());
AccountVO user = this.iSysUserService.findUserByAccountAndPassword(loginUser.getAccount(), loginUser.getPassword(), project.name());
ProjectVO projectVO = projectService.queryLoginProjectByCode(loginUser.getProject());
AccountVO user = this.iSysUserService.findUserByAccountAndPassword(loginUser.getAccount(), loginUser.getPassword(), projectVO.name());
BusinessExceptionAssertEnum.LOGIN_INFO_ERROR.assertNotNull(user, "账号或密码不正确!");
if (loginUser.isTeacherLogin()) {
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertEquals(true, user.getCompanyAdmin(), "账号无教师权限");
@ -363,10 +361,10 @@ public class AuthenticateService implements IAuthenticateService {
Client client = Client.getByIdAndSecret(loginUser.getClientId(), loginUser.getSecret());
ProjectDeviceVO deviceVO = null;
if (!StringUtils.isEmpty(loginUser.getDeviceCode())) {
deviceVO = this.deviceService.getDeviceDetailInfoOf(project.name(), loginUser.getDeviceCode());
deviceVO = this.deviceService.getDeviceDetailInfoOf(projectVO.name(), loginUser.getDeviceCode());
}
// 构造登陆用户信息
LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(user, client, project, deviceVO);
LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(user, client, projectVO, deviceVO);
// 执行登录
login(loginUserInfo, true);
return loginUserInfo.getToken();
@ -381,9 +379,9 @@ public class AuthenticateService implements IAuthenticateService {
loginInfo.getAccount());
Client client = Client.getByIdAndSecret(loginInfo.getClientId(), loginInfo.getSecret());
// TODO 20220922
club.joylink.rtss.entity.project.Project project = projectService.queryLoginProjectByCode(loginInfo.getProject());
ProjectVO projectVO = projectService.queryLoginProjectByCode(loginInfo.getProject());
// 构造登陆用户信息
LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(accountVO, client, project, null);
LoginUserInfoVO loginUserInfo = new LoginUserInfoVO(accountVO, client, projectVO, null);
// 执行登录
login(loginUserInfo, true);
return loginUserInfo.getToken();

View File

@ -8,7 +8,6 @@ import club.joylink.rtss.dao.CompetitionDAO;
import club.joylink.rtss.dao.CompetitionRecordDAO;
import club.joylink.rtss.dao.CompetitionVoiceRecordDAO;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.*;
import club.joylink.rtss.services.project.ProjectService;
@ -43,6 +42,7 @@ import club.joylink.rtss.vo.client.script.ScriptActionVO;
import club.joylink.rtss.vo.client.script.ScriptVO;
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.project.ProjectVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
@ -386,8 +386,8 @@ public class CompetitionPracticalService implements ICompetitionPracticalService
@Override
public String createSimulationAndLoadCompetition(Long id, LoginUserInfoVO userInfo) {
Project project = projectService.queryLoginProjectByCode("DRTS");
String group = projectSimulationService.createCenterSimulation(userInfo, project);
ProjectVO projectVO = projectService.queryLoginProjectByCode("DRTS");
String group = projectSimulationService.createCenterSimulation(userInfo, projectVO);
loadCompetition(group, id, userInfo);
return group;
}
@ -448,8 +448,8 @@ public class CompetitionPracticalService implements ICompetitionPracticalService
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(monthAmount > 0,
"购买月数需大于0");
MapVO mapInfo = iMapService.getMapInfoById(mapId);
Project project = projectService.queryLoginProjectByCode(mapInfo.getProjectCode());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(project.isMapNeedCharge(), "非国赛地图无需购买权限");
ProjectVO projectVO = projectService.queryLoginProjectByCode(mapInfo.getProjectCode());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(projectVO.isMapNeedCharge(), "非国赛地图无需购买权限");
List<UserPermissionVO> ups = iUserPermissionService.getSimulationUserPermission(user, mapId, MapPrdTypeEnum.JOINT.getCode());
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(ups.size() > 1,
"地图权限数量大于1暂不能购买");

View File

@ -2,7 +2,6 @@ package club.joylink.rtss.services.pay.wechat;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.constants.ServicePath;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.event.OrderPaySuccessEvent;
import club.joylink.rtss.exception.BusinessException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
@ -24,6 +23,7 @@ import club.joylink.rtss.vo.client.permission.PermissionVO;
import club.joylink.rtss.vo.client.permissionDistribute.DistributeVO;
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.project.ProjectVO;
import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
@ -310,8 +310,8 @@ public class WechatPayService {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(permission.getName().contains("综合演练"),
String.format("支付的[%s]中的商品不是综合演练权限", orderVO.logStr()));
MapVO mapInfo = iMapService.getMapInfoById(permission.getMapId());
Project project = projectService.queryLoginProjectByCode(mapInfo.getProjectCode());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(project.isMapNeedCharge(),
ProjectVO projectVO = projectService.queryLoginProjectByCode(mapInfo.getProjectCode());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(projectVO.isMapNeedCharge(),
String.format("支付的[%s]中的商品不是国赛的权限", orderVO.logStr()));
AccountVO user = iSysUserService.getUserById(orderVO.getCreatorId());

View File

@ -32,6 +32,7 @@ import club.joylink.rtss.vo.map.graph.MapSectionNewVO;
import club.joylink.rtss.vo.map.graph.MapSignalNewVO;
import club.joylink.rtss.vo.map.graph.MapSwitchVO;
import club.joylink.rtss.vo.map.graph.MapTrainVO;
import club.joylink.rtss.vo.project.ProjectVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
@ -722,10 +723,10 @@ public class DeviceServiceImpl implements DeviceService {
return list;
}
private ProjectDevice buildIm(Project project, Long creatorId) {
private ProjectDevice buildIm(ProjectVO projectVO, Long creatorId) {
ProjectDevice im = new ProjectDevice();
im.setProjectCode(project.name());
im.setCode(project.name().toLowerCase() + "-" + "im");
im.setProjectCode(projectVO.name());
im.setCode(projectVO.name().toLowerCase() + "-" + "im");
im.setType(ProjectDeviceType.IM.name());
im.setCreator(creatorId);
im.setCreateTime(LocalDateTime.now());

View File

@ -4,6 +4,8 @@ import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.project.ProjectViewVO;
import java.util.List;
@ -17,83 +19,94 @@ public interface ProjectService {
*/
PageVO<Project> pagingQuery(PageQueryVO queryVO);
/**
* 前端设置信息分页
*/
PageVO<ProjectView> projectViewPagingQuery(PageQueryVO queryVO);
/**
* 列表
*/
List<Project> getAllProject();
/**
* 获取所有的前端配置
*/
List<ProjectView> getAllProjectView();
/**
* 前端通过项目编码前端请求项目信息
*/
Project queryLoginProjectByCode(String code);
/**
* 前端通过项目编码前端请求项目信息
*/
ProjectView queryLoginProjectByMarkKey(String project);
/**
* 项目Id请求项目信息
*/
Project queryProjectById(Long id);
/**
* 配置ID获取前端配置信息
*/
ProjectView queryProjectViewById(Long id);
/**
* 修改项目信息
*/
void updateProject(Project project);
/**
* 修改项目前端配置信息
*/
void updateProjectView(ProjectView projectView);
/**
* 删除项目信息
*/
void deleteProject(Long id);
/**
* 删除项目前端配置信息
*/
void deleteProjectView(Long id);
/**
* 保存项目信息
*/
void save(Project project);
/**
* 检查项目编码是否存在
*/
boolean checkProjectCode(String code);
/**
* 前端设置信息分页
*/
PageVO<ProjectView> projectViewPagingQuery(PageQueryVO queryVO);
/**
* 获取所有的前端配置
*/
List<ProjectView> getAllProjectView();
/**
* 配置ID获取前端配置信息
*/
ProjectView queryProjectViewById(Long id);
/**
* 修改项目前端配置信息
*/
void updateProjectView(ProjectView projectView);
/**
* 删除项目前端配置信息
*/
void deleteProjectView(Long id);
/**
* 保存前端配置信息
*/
void saveProjectView(ProjectView projectView);
/**
* 更新项目的前端设置信息
* 检查项目编码是否存在
*/
ProjectView.SimpleProjectView getProjectViewSetting(String project);
boolean checkProjectViewMarkKey(String markKey);
/************************** runtime ***************************/
/**
* 前端通过项目编码前端请求项目信息
*/
ProjectVO queryLoginProjectByCode(String code);
/**
* 获取项目的简要信息前端关联时使用
*/
List<Project.SimpleProject> getSimpleProjectList();
List<ProjectVO> getSimpleProjectList();
/**
* 前端通过项目编码前端请求项目信息
*/
ProjectViewVO queryLoginProjectByMarkKey(String project);
/**
* 更新项目的前端设置信息
*/
ProjectViewVO getProjectViewSetting(String project);
/**
* 前端请求所有设置信息
*/
List<ProjectView.SimpleProjectView> queryViewAll();
List<ProjectViewVO> queryViewAll();
}

View File

@ -10,6 +10,8 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.vo.client.PageQueryVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.project.ProjectViewVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,6 +28,10 @@ import java.util.stream.Collectors;
@Service
public class ProjectServiceImpl implements ProjectService {
/**
* 有效信息标识
*/
public final static Integer EFFECT_PROJECT_STATUS = 1;
@Autowired
private ProjectDAO projectDAO;
@ -37,63 +43,22 @@ public class ProjectServiceImpl implements ProjectService {
public PageVO<Project> pagingQuery(PageQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS);
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS);
Page<Project> page = (Page<Project>) projectDAO.selectByExample(projectExample);
return PageVO.convert(page, page.getResult());
}
@Override
public PageVO<ProjectView> projectViewPagingQuery(PageQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS);
Page<ProjectView> page = (Page<ProjectView>) projectViewDAO.selectByExample(projectViewExample);
return PageVO.convert(page, page.getResult());
}
@Override
public List<Project> getAllProject() {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS);
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS);
return projectDAO.selectByExample(projectExample);
}
@Override
public List<ProjectView> getAllProjectView() {
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS);
return projectViewDAO.selectByExample(projectViewExample);
}
@Override
@Cacheable(cacheNames = "project", keyGenerator = "projectKeyGenerator", unless = "#result == null")
public Project queryLoginProjectByCode(String code) {
String codeKey = Project.isDefault(code) ? Project.DEFAULT_PROJECT_CODE : code;
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andCodeEqualTo(codeKey);
List<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
return projectList.get(0);
}
@Override
public ProjectView queryLoginProjectByMarkKey(String project) {
String markKey = StringUtils.isEmpty(project) ? Project.DEFAULT_PROJECT_MARK_KEY : project;
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andMarkKeyEqualTo(markKey);
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(projectViewExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
return projectList.get(0);
}
@Override
public Project queryProjectById(Long id) {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andIdEqualTo(id);
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andIdEqualTo(id);
List<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
if (CollectionUtils.isEmpty(projectList)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
@ -101,23 +66,12 @@ public class ProjectServiceImpl implements ProjectService {
return projectList.get(0);
}
@Override
public ProjectView queryProjectViewById(Long id) {
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andIdEqualTo(id);
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(projectViewExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
return projectList.get(0);
}
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(cacheNames = "project", allEntries = true)
public void updateProject(Project project) {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andIdEqualTo(project.getId());
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andIdEqualTo(project.getId());
List<Project> projectList = projectDAO.selectByExample(projectExample);
if (CollectionUtils.isEmpty(projectList)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
@ -126,11 +80,70 @@ public class ProjectServiceImpl implements ProjectService {
projectDAO.updateByPrimaryKeySelective(project);
}
@Override
@CacheEvict(cacheNames = "project", allEntries = true)
public void deleteProject(Long id) {
Project project = new Project();
project.setId(id);
project.setStatus(0);
projectDAO.updateByPrimaryKeySelective(project);
}
@Override
@CacheEvict(cacheNames = "project", allEntries = true)
public void save(Project project) {
if (checkProjectCode(project.getCode())) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目已存在");
}
project.setCreateTime(LocalDateTime.now());
project.setUpdateTime(LocalDateTime.now());
project.setStatus(EFFECT_PROJECT_STATUS);
projectDAO.insert(project);
}
@Override
public boolean checkProjectCode(String code) {
if (Project.isDefault(code)) {
return true;
}
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andCodeEqualTo(code);
long num = projectDAO.countByExample(projectExample);
return num > 0;
}
@Override
public PageVO<ProjectView> projectViewPagingQuery(PageQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS);
Page<ProjectView> page = (Page<ProjectView>) projectViewDAO.selectByExample(projectViewExample);
return PageVO.convert(page, page.getResult());
}
@Override
public List<ProjectView> getAllProjectView() {
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS);
return projectViewDAO.selectByExample(projectViewExample);
}
@Override
public ProjectView queryProjectViewById(Long id) {
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andIdEqualTo(id);
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(projectViewExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
return projectList.get(0);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateProjectView(ProjectView projectView) {
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andIdEqualTo(projectView.getId());
projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andIdEqualTo(projectView.getId());
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(projectViewExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
@ -139,59 +152,81 @@ public class ProjectServiceImpl implements ProjectService {
projectViewDAO.updateByPrimaryKeySelective(projectView);
}
@Override
@CacheEvict(cacheNames = "project", allEntries = true)
public void deleteProject(Long id) {
projectDAO.deleteByPrimaryKey(id);
}
@Override
public void deleteProjectView(Long id) {
projectViewDAO.deleteByPrimaryKey(id);
}
@Override
@CacheEvict(cacheNames = "project", allEntries = true)
public void save(Project project) {
project.setCreateTime(LocalDateTime.now());
project.setUpdateTime(LocalDateTime.now());
project.setStatus(Project.EFFECT_PROJECT_STATUS);
projectDAO.insert(project);
ProjectView projectView = new ProjectView();
projectView.setId(id);
projectView.setStatus(0);
projectViewDAO.updateByPrimaryKeySelective(projectView);
}
@Override
public void saveProjectView(ProjectView projectView) {
if (checkProjectViewMarkKey(projectView.getMarkKey())) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目已存在");
}
projectView.setCreateTime(LocalDateTime.now());
projectView.setUpdateTime(LocalDateTime.now());
projectView.setStatus(Project.EFFECT_PROJECT_STATUS);
projectView.setStatus(EFFECT_PROJECT_STATUS);
projectViewDAO.insert(projectView);
}
@Override
public ProjectView.SimpleProjectView getProjectViewSetting(String project) {
String markKey = Project.isDefault(project) ? Project.DEFAULT_PROJECT_MARK_KEY : project;
public boolean checkProjectViewMarkKey(String markKey) {
ProjectViewExample projectExample = new ProjectViewExample();
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andMarkKeyEqualTo(markKey);
long num = projectViewDAO.countByExample(projectExample);
return num > 0;
}
@Override
@Cacheable(cacheNames = "project", keyGenerator = "projectKeyGenerator", unless = "#result == null")
public ProjectVO queryLoginProjectByCode(String code) {
String codeKey = ProjectVO.isDefault(code) ? Project.DEFAULT_PROJECT_CODE : code;
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andCodeEqualTo(codeKey);
List<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
return new ProjectVO(projectList.get(0));
}
@Override
public List<ProjectVO> getSimpleProjectList() {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andViewShowEqualTo(1);
List<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
return projectList.stream().map(project -> new ProjectVO(project)).collect(Collectors.toList());
}
@Override
public ProjectViewVO queryLoginProjectByMarkKey(String project) {
String markKey = StringUtils.isEmpty(project) ? ProjectView.DEFAULT_PROJECT_MARK_KEY : project;
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andMarkKeyEqualTo(markKey);
projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andMarkKeyEqualTo(markKey);
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(projectViewExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
ProjectView projectInfo = projectList.get(0);
return projectInfo.simplifyProjectView();
}
@Override
public List<Project.SimpleProject> getSimpleProjectList() {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(Project.EFFECT_PROJECT_STATUS).andViewShowEqualTo(1);
List<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
return projectList.stream().map(Project::generateSimpleProject).collect(Collectors.toList());
return new ProjectViewVO(projectList.get(0));
}
@Override
public List<ProjectView.SimpleProjectView> queryViewAll() {
public ProjectViewVO getProjectViewSetting(String project) {
String markKey = Project.isDefault(project) ? ProjectView.DEFAULT_PROJECT_MARK_KEY : project;
ProjectViewExample projectViewExample = new ProjectViewExample();
projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andMarkKeyEqualTo(markKey);
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(projectViewExample);
if (CollectionUtils.isEmpty(projectList)) { // 未找到项目则获取默认信息
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
return new ProjectViewVO(projectList.get(0));
}
@Override
public List<ProjectViewVO> queryViewAll() {
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(new ProjectViewExample());
return projectList.stream().map(ProjectView::simplifyProjectView).collect(Collectors.toList());
return projectList.stream().map(projectView -> new ProjectViewVO(projectView)).collect(Collectors.toList());
}
}
}

View File

@ -1,7 +1,7 @@
package club.joylink.rtss.services.simulation;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.project.ProjectVO;
/**
* 项目综合演练仿真服务
@ -14,5 +14,5 @@ public interface ProjectSimulationService {
* @param project
* @return
*/
String createCenterSimulation(LoginUserInfoVO loginUserInfo, Project project);
String createCenterSimulation(LoginUserInfoVO loginUserInfo, ProjectVO project);
}

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.services.simulation;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.IUserPermissionService;
@ -13,6 +12,7 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.project.ProjectVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -41,17 +41,17 @@ public class ProjectSimulationServiceImpl implements ProjectSimulationService {
private RtSimulationService rtSimulationService;
@Override
public String createCenterSimulation(LoginUserInfoVO loginUserInfo, Project project) {
public String createCenterSimulation(LoginUserInfoVO loginUserInfo, ProjectVO projectVO) {
AccountVO accountVO = loginUserInfo.getAccountVO();
// 查询用户综合演练配置
// 查询项目地图默认取第一个暂时这样处理后面考虑配置实训室-地图对应
List<MapVO> mapList = this.iMapService.findOnlineMapByProjectCode(project.name());
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(mapList, String.format("项目[%s]无地图", project.name()));
List<MapVO> mapList = this.iMapService.findOnlineMapByProjectCode(projectVO.name());
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(mapList, String.format("项目[%s]无地图", projectVO.name()));
Long mapId = mapList.get(0).getId();
// 权限判断 : Project.BJD.equals(project)
if (project.isPermissionVail()) {
if (projectVO.isPermissionVail()) {
List<UserPermissionVO> userPermissionList = this.iUserPermissionService
.getSimulationUserPermission(accountVO, mapId, MapPrdTypeEnum.CENTER.getCode());
BusinessExceptionAssertEnum.SIMULATION_PERMISSION_NOT_EXIST
@ -66,7 +66,7 @@ public class ProjectSimulationServiceImpl implements ProjectSimulationService {
.assertNotTrue(CollectionUtils.isEmpty(collect), "用户仿真权限当前时间不可用");
}
// Project.WJLS.equals(project)
if (project.isCreateLocalSimulation()) {
if (projectVO.isCreateLocalSimulation()) {
return rtSimulationService.create(loginUserInfo.getAccountVO(), mapId, MapPrdTypeEnum.LOCAL).getId();
}
// 构建仿真

View File

@ -4,7 +4,6 @@ import club.joylink.rtss.configuration.configProp.OtherConfig;
import club.joylink.rtss.configuration.configProp.WeChatConfig;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.*;
import club.joylink.rtss.services.org.IOrgService;
@ -71,6 +70,7 @@ import club.joylink.rtss.vo.client.training.TrainingNewVO;
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.websocket.StompMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -1066,8 +1066,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Override
public boolean hasPermission(AccountVO accountVO, Long mapId, String prdType) {
MapVO mapDetail = iMapService.getMapDetail(mapId);
Project project = projectService.queryLoginProjectByCode(mapDetail.getProjectCode());
if (project.isFreeSource()) { //成都工业,郑州共赢所有资源免费
ProjectVO projectVO = projectService.queryLoginProjectByCode(mapDetail.getProjectCode());
if (projectVO.isFreeSource()) { //成都工业,郑州共赢所有资源免费
return true;
}
List<UserPermissionVO> ups = iUserPermissionService.getSimulationUserPermission(accountVO, mapId, prdType);

View File

@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.data.SimulationLog;
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
@ -31,6 +30,7 @@ import club.joylink.rtss.simulation.cbtc.training2.Training2;
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.fault.FaultRuleVO;
import club.joylink.rtss.vo.project.ProjectVO;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@ -68,7 +68,7 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
*/
private String project;
private Project projectInfo;
private ProjectVO projectVO;
/**
* 数据仓库

View File

@ -48,7 +48,7 @@ public class SimulationBuilder {
if (Objects.nonNull(buildParams.getLoginUserInfo())) {
simulation.setCreatorId(buildParams.getLoginUserInfo().getAccountVO().getIdStr());
simulation.setProject(buildParams.getLoginUserInfo().getProject());
simulation.setProjectInfo(buildParams.getLoginUserInfo().getProjectInfo());
simulation.setProjectVO(buildParams.getLoginUserInfo().getProjectInfo());
}
// 线路配置参数
simulation.getRepository().setConfig(buildConfig(buildParams.getMap().getConfigVO(),

View File

@ -70,7 +70,7 @@ public class SimulationRealDeviceThread {
public void controlDevice(Simulation simulation) {
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
if (!CollectionUtils.isEmpty(realDeviceList)) {
if (simulation.getProjectInfo().isControlDevice()) {
if (simulation.getProjectVO().isControlDevice()) {
Set<VirtualRealityScreenDoor> vrPsdSet = new HashSet<>();
Set<VirtualRealitySwitch> vrSwitchSet = new HashSet<>();
for (RealDeviceConfig realDevice : realDeviceList) {

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.simulation.rt;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IDailyRunPlanService;
import club.joylink.rtss.services.ILoadPlanService;
@ -28,6 +27,7 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.runplan.RunPlanLoadVO;
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.project.ProjectVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -82,8 +82,8 @@ public class RtSimulationService {
}
rtSimulation.init();
// 郑州共赢驾驶默认加载一辆列车
Project project = projectService.queryLoginProjectByCode(mapVO.getProjectCode());
if (project.getDefaultLoadTrain() > 0 && Objects.equals(MapPrdTypeEnum.DRIVER, prdTypeEnum)) {
ProjectVO projectVO = projectService.queryLoginProjectByCode(mapVO.getProjectCode());
if (projectVO.getDefaultLoadTrain() > 0 && Objects.equals(MapPrdTypeEnum.DRIVER, prdTypeEnum)) {
this.srTrainOperationHandler.loadTrain(rtSimulation, "001", true, "T21");
}
simulationManager.start(rtSimulation.getId());
@ -122,10 +122,10 @@ public class RtSimulationService {
private void initCreatorPlayMember(RtSimulation rtSimulation, MapVO mapVO) {
// RtSimulationMember simulationMember = rtSimulation.querySimulationMemberById("2");
// List<RtSimulationMember> memberList = rtSimulation.querySimulationMembersOfRole(RtSimulationMember.Role.LOWS);
Project project = projectService.queryLoginProjectByCode(mapVO.getProjectCode());
if (!StringUtils.isEmpty(project.getDefaultMemberId())) {
ProjectVO projectVO = projectService.queryLoginProjectByCode(mapVO.getProjectCode());
if (!StringUtils.isEmpty(projectVO.getDefaultMemberId())) {
// 大铁微机联锁项目默认新绛站值班员
this.simulationManager.memberPlayedByUser(rtSimulation.getId(), project.getDefaultMemberId(), rtSimulation.getCreator().getId());
this.simulationManager.memberPlayedByUser(rtSimulation.getId(), projectVO.getDefaultMemberId(), rtSimulation.getCreator().getId());
} else {
String memberId = rtSimulation.getSimulationMembers().stream().filter(r -> Objects.equals("001", r.deviceId))
.map(RtSimulationMember::getId).findFirst().orElse("1");

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.entity.SysAccountLogin;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.util.EncryptUtil;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.project.ProjectVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -29,7 +30,7 @@ public class LoginUserInfoVO {
private String project;
//TODO 20220922 添加
private Project projectInfo;
private ProjectVO projectInfo;
private ProjectDeviceVO deviceVO;
@ -59,10 +60,10 @@ public class LoginUserInfoVO {
this.token = buildToken();
}
public LoginUserInfoVO(AccountVO accountVO, Client client, Project projectInfo, ProjectDeviceVO deviceVO) {
public LoginUserInfoVO(AccountVO accountVO, Client client, ProjectVO projectVO, ProjectDeviceVO deviceVO) {
this.accountVO = accountVO;
this.client = client;
this.projectInfo = projectInfo;
this.projectInfo = projectVO;
this.project = projectInfo.name();
this.deviceVO = deviceVO;
LocalDateTime now = LocalDateTime.now();

View File

@ -1,8 +1,8 @@
package club.joylink.rtss.vo.client;
import club.joylink.rtss.constants.Client;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.project.ProjectVO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Builder;
import lombok.Getter;
@ -28,7 +28,7 @@ public class LoginStatusVO {
private String project;
@JsonIgnore
private Project projectInfo;
private ProjectVO projectVO;
private ProjectDeviceVO deviceVO;

View File

@ -0,0 +1,178 @@
package club.joylink.rtss.vo.project;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.util.StringUtils;
@Data
public class ProjectVO {
/**
* 项目简称
*/
private String label;
/**
* 项目Code
*/
private String value;
/**
* 反序列化设置信息
*/
@JsonIgnore
private ProjectServerConfig projectServerConfig;
public ProjectVO(Project project) {
this.label = project.getName();
this.value = project.getCode();
if (StringUtils.isEmpty(project.getServerSetting())) {
this.projectServerConfig = null;
} else {
this.projectServerConfig = JsonUtils.read(project.getServerSetting(), ProjectServerConfig.class);
}
}
/**
* 返回项目编码
*/
public String name() {
return this.value;
}
/**
* 是否默认项目
*/
@JsonIgnore
public boolean isDefault() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getDefaultProject() == 1;
}
@JsonIgnore
public static boolean isDefault(String code) {
return Project.isDefault(code);
}
/**
* 是否登录就创建仿真
*/
@JsonIgnore
public boolean isLoginWithCreateSimulation() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getLoginCreateSimulation() == 1;
}
@JsonIgnore
public boolean isPermissionVail() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getCreateSimulationPermission() == 1;
}
@JsonIgnore
public boolean isCreateLocalSimulation() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getCreateLocalSimulation() == 1;
}
@JsonIgnore
public boolean isMapNeedCharge() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getMapNeedCharge() == 1;
}
/**
* 是否资源免费
*/
@JsonIgnore
public boolean isFreeSource() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getFreeSource() == 1;
}
@JsonIgnore
public boolean isControlDevice() {
if (this.projectServerConfig == null) {
return false;
}
return this.projectServerConfig.getControlDevice() == 1;
}
@JsonIgnore
public int getDefaultLoadTrain() {
if (this.projectServerConfig == null) {
return 0;
}
return this.projectServerConfig.getDefaultLoadTrain();
}
@JsonIgnore
public String getDefaultMemberId() {
if (this.projectServerConfig == null) {
return null;
}
return this.projectServerConfig.getDefaultMemberId();
}
@Data
public static class ProjectServerConfig {
/**
* 默认项目
*/
private int defaultProject;
/**
* 登录后创建仿真
*/
private int loginCreateSimulation;
/**
* 登录时创建仿真的权限判断原BJD使用
*/
private int createSimulationPermission;
/**
* 登录时创建仿真判断WJLS创建现地类型
*/
private int createLocalSimulation;
/**
* 地图需要收费DRTS
*/
private int mapNeedCharge;
/**
* 资源免费CGYZZWW
*/
private int freeSource;
/**
* 需要控制装备HEB
*/
private int controlDevice;
/**
* 默认加载列车数
*/
private int defaultLoadTrain;
/**
* 默认加载角色WJLS默认加载2
*/
private String defaultMemberId;
}
}

View File

@ -0,0 +1,28 @@
package club.joylink.rtss.vo.project;
import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.util.JsonUtils;
import lombok.Data;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
@Data
public class ProjectViewVO {
private String markKey;
private String project;
private Map<String, Object> viewSetting;
public ProjectViewVO(ProjectView projectView) {
this.markKey = projectView.getMarkKey();
this.project = projectView.getProject();
if (StringUtils.isEmpty(projectView.getViewSetting())) {
this.viewSetting = new HashMap<>();
} else {
this.viewSetting = JsonUtils.read(projectView.getViewSetting(), Map.class);
}
}
}

View File

@ -5,8 +5,7 @@
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="name_en" property="nameEn" jdbcType="VARCHAR"/>
<result column="simple_name" property="simpleName" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="status" property="status" jdbcType="INTEGER"/>
@ -76,7 +75,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, code, name, name_en, simple_name, create_time, update_time, status, view_show
id, code, name, description, create_time, update_time, status, view_show
</sql>
<sql id="Blob_Column_List">
server_setting
@ -147,12 +146,8 @@
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.project.Project">
insert into project ( code,
name, name_en, simple_name,
create_time, update_time, status,
server_setting,view_show)
values (#{code,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{nameEn,jdbcType=VARCHAR}, #{simpleName,jdbcType=VARCHAR},
insert into project ( code, name, description, create_time, update_time, status, server_setting,view_show)
values (#{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER},
#{serverSetting,jdbcType=LONGVARCHAR},#{viewShow,jdbcType=INTEGER})
</insert>
@ -169,11 +164,8 @@
<if test="name != null">
name,
</if>
<if test="nameEn != null">
name_en,
</if>
<if test="simpleName != null">
simple_name,
<if test="description != null">
description,
</if>
<if test="createTime != null">
create_time,
@ -201,11 +193,8 @@
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="nameEn != null">
#{nameEn,jdbcType=VARCHAR},
</if>
<if test="simpleName != null">
#{simpleName,jdbcType=VARCHAR},
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
@ -234,11 +223,8 @@
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="nameEn != null">
name_en = #{nameEn,jdbcType=VARCHAR},
</if>
<if test="simpleName != null">
simple_name = #{simpleName,jdbcType=VARCHAR},
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
@ -263,8 +249,7 @@
update project
set code = #{code,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
name_en = #{nameEn,jdbcType=VARCHAR},
simple_name = #{simpleName,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
@ -277,8 +262,7 @@
update project
set code = #{code,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
name_en = #{nameEn,jdbcType=VARCHAR},
simple_name = #{simpleName,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},