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-10-12 17:27:02 +08:00
commit fabaff59fb
22 changed files with 446 additions and 171 deletions

View File

@ -1,3 +1,3 @@
-- 新实训标添加组织id
alter table published_training2 add column org_id bigint;
alter table rts_published_training2 add column org_id bigint;

View File

@ -1,6 +1,6 @@
-- 新题库
DROP TABLE IF EXISTS `paper_question`;
CREATE TABLE `paper_question` (
DROP TABLE IF EXISTS `rts_paper_question`;
CREATE TABLE `rts_paper_question` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
`type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '类型 选择题=select,判断题=judge,多选题=multi',
`question` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题内容',

View File

@ -0,0 +1,2 @@
alter table `joylink`.`project`
ADD COLUMN `default_org` bigint NULL comment '默认组织ID' AFTER `server_setting`;

View File

@ -20,7 +20,7 @@ public class OrgProjectController {
*/
@GetMapping("list")
public List<OrgProjectVO> queryOrgList(@RequestAttribute LoginUserInfoVO loginInfo) {
return orgProjectService.queryOrgProjectListByProjectAndUid(loginInfo.getProject(), loginInfo.getAccountVO().getId());
return orgProjectService.queryOrgProjectListByProjectAndUid(loginInfo.getProjectInfo(), loginInfo.getAccountVO().getId());
}
/**

View File

@ -1,13 +1,13 @@
package club.joylink.rtss.controller.project;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.services.project.ProjectService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.project.ProjectQueryVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.project.ProjectViewQueryVO;
import club.joylink.rtss.vo.project.ProjectViewVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.project.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -24,12 +24,12 @@ public class ProjectInfoController {
private ProjectService projectService;
@GetMapping("/page")
public PageVO<Project> pagingQuery(ProjectQueryVO queryVO) {
public PageVO<ProjectInfoVO> pagingQuery(ProjectQueryVO queryVO) {
return projectService.pagingQuery(queryVO);
}
@GetMapping("/all")
public List<Project> getAllProject() {
public List<ProjectInfoVO> getAllProject() {
return projectService.getAllProject();
}
@ -58,6 +58,22 @@ public class ProjectInfoController {
return projectService.checkProjectCode(code);
}
@PutMapping("/setDefaultOrg")
public void setProjectDefaultOrg(Long id, Long orgId) {
projectService.setProjectDefaultOrg(id, orgId);
}
@GetMapping("/{id}/orgList")
public List<CompanyVO> orgList(@PathVariable Long id) {
return projectService.projectOrgList(id);
}
@PostMapping("/{id}/createDefaultOrg")
public ProjectInfoVO quickCreateDefaultOrg(@PathVariable Long id, String name
, @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO user) {
return projectService.quickCreateDefaultOrg(id, name, user);
}
@GetMapping("/viewSetting/page")
public PageVO<ProjectView> projectViewPagingQuery(ProjectViewQueryVO queryVO) {
return projectService.projectViewPagingQuery(queryVO);

View File

@ -15,7 +15,7 @@ import java.util.List;
@Repository
public interface PaperQuestionDAO {
@Select("<script>" +
"select * from paper_question where 1 = 1 " +
"select * from rts_paper_question where 1 = 1 " +
// "<choose>" +
// "<when test=\"projectCode == '"+ Project.DEFAULT_PROJECT_CODE +"'\">"+
// " and project_code is null" +

View File

@ -60,16 +60,16 @@ public class Project {
*/
private Integer status;
/**
* 是否供前端选择
*/
private Integer viewShow;
/**
* 后端服务设置
*/
private String serverSetting;
/**
* 默认组织ID
*/
private Long defaultOrg;
@JsonIgnore
public static boolean isDefault(String code) {
return StringUtils.isEmpty(code) || DEFAULT_PROJECT_LABEL.contains(code);

View File

@ -61,7 +61,7 @@ public class MinioServiceImpl implements MinioService {
criteria.andDirectoryEqualTo(queryVO.getDirectory());
}
if (!StringUtils.isEmpty(queryVO.getTitle())) {
criteria.andTitleLike(queryVO.getTitle());
criteria.andTitleLike(String.format("%%%s%%", queryVO.getTitle()));
}
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
Page<MinioFileInfo> minioFileInfoPage = (Page<MinioFileInfo>) this.minioFileInfoDao.selectByExample(example);

View File

@ -31,7 +31,6 @@ import club.joylink.rtss.util.VoiceFileUtils;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
import club.joylink.rtss.vo.client.competition.*;
import club.joylink.rtss.vo.client.order.OrderCreateVO;
import club.joylink.rtss.vo.client.order.OrderDetailCreateVO;
@ -41,6 +40,7 @@ import club.joylink.rtss.vo.client.permission.PermissionVO;
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.client.voice.VoiceRecognitionResult;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.project.ProjectVO;
import com.github.pagehelper.Page;

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.entity.org.OrgProject;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.org.OrgProjectVO;
import club.joylink.rtss.vo.project.ProjectVO;
import java.util.List;
@ -20,7 +21,7 @@ public interface IOrgProjectService {
/**
* 根据项目获取组织列表
*/
List<OrgProjectVO> queryOrgProjectListByProjectAndUid(String project, Long uid);
List<OrgProjectVO> queryOrgProjectListByProjectAndUid(ProjectVO projectInfo, Long uid);
/**
* 选择登入项目

View File

@ -15,6 +15,7 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.org.OrgProjectVO;
import club.joylink.rtss.vo.project.ProjectVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -46,71 +47,53 @@ public class OrgProjectService implements IOrgProjectService {
}
@Override
public List<OrgProjectVO> queryOrgProjectListByProjectAndUid(String project, Long uid) {
public List<OrgProjectVO> queryOrgProjectListByProjectAndUid(ProjectVO projectInfo, Long uid) {
// 查询项目关联顶级组织
OrgProjectExample orgProjectExample = new OrgProjectExample();
orgProjectExample.createCriteria().andProjectCodeEqualTo(project);
List<OrgProject> orgProjectList = orgProjectDao.selectByExample(orgProjectExample);
List<OrgProject> orgProjectList = queryOrgProjectList(projectInfo.getValue());
if (CollectionUtils.isEmpty(orgProjectList)) {
return List.of();
throw new SimulationException(SimulationExceptionType.System_Fault, "项目无关联组织");
}
// 获取人员关联组织
OrgUserExample example = new OrgUserExample();
example.createCriteria().andUserIdEqualTo(uid);
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
if (CollectionUtils.isEmpty(orgUserList)) {
return List.of();
List<OrgUser> orgUserList = queryOrgUser(uid);
List<Long> orgIdList = null;
if (!CollectionUtils.isEmpty(orgUserList)) {
// 用户关联组织ID列表
List<Long> userOrgIdList = orgUserList.stream().map(OrgUser::getOrgId).distinct().collect(Collectors.toList());
List<Org> orgList = queryOrgInfoList(userOrgIdList); // 用户组织信息
List<Long> userOrgTopIdList = orgList.stream().map(Org::getRootId).distinct().collect(Collectors.toList());
// 有权限的组织ID
orgIdList = orgProjectList.stream().filter(orgProject -> userOrgTopIdList.contains(orgProject.getOrgId()))
.map(OrgProject::getOrgId).collect(Collectors.toList());
}
// 用户关联组织ID列表
List<Long> orgIdList = orgUserList.stream().map(OrgUser::getOrgId).distinct().collect(Collectors.toList());
// 用户关联组织信息
OrgExample orgExample = new OrgExample();
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList);
List<Org> orgList = orgDAO.selectByExample(orgExample);
if (CollectionUtils.isEmpty(orgUserList)) {
return List.of();
if (CollectionUtils.isEmpty(orgIdList)) { // 用户没有分配组织
if (projectInfo.getDefaultOrg() != null) { // 存在默认组织
orgIdList = List.of(projectInfo.getDefaultOrg());
} else { // 没有默认则获取第一个
orgIdList = List.of(orgProjectList.get(0).getOrgId());
}
}
List<Long> userOrgTopIdList = orgList.stream().map(Org::getRootId).distinct().collect(Collectors.toList());
// 有权限的组织ID
List<Long> authOrgIdList = orgProjectList.stream().filter(orgProject -> userOrgTopIdList.contains(orgProject.getOrgId()))
.map(OrgProject::getOrgId).collect(Collectors.toList());
orgExample = new OrgExample();
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(authOrgIdList);
orgList = orgDAO.selectByExample(orgExample);
List<Org> orgList = queryOrgInfoList(orgIdList);
return orgList.stream().map(OrgProjectVO::new).collect(Collectors.toList());
}
@Override
public void signInOrg(Long orgId, LoginUserInfoVO loginInfo) {
// 查询项目关联顶级组织
OrgProjectExample orgProjectExample = new OrgProjectExample();
orgProjectExample.createCriteria().andProjectCodeEqualTo(loginInfo.getProject()).andOrgIdEqualTo(orgId);
List<OrgProject> orgProjectList = orgProjectDao.selectByExample(orgProjectExample);
if (CollectionUtils.isEmpty(orgProjectList)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
OrgExample orgExample = new OrgExample();
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andRootIdEqualTo(orgId);
List<Org> orgList = orgDAO.selectByExample(orgExample);
// 没有顶级项目
Org topOrg = orgList.stream().filter(o -> o.getId().equals(o.getRootId())).findFirst().orElse(null);
// TODO 验证权限
Org topOrg = orgDAO.selectByPrimaryKey(orgId);
if (topOrg == null) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
List<Long> orgIdList = orgList.stream().map(Org::getId).distinct().collect(Collectors.toList());
// 检验用户是否有组织信息
OrgUserExample example = new OrgUserExample();
example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andOrgIdIn(orgIdList);
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
if (CollectionUtils.isEmpty(orgUserList)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
}
// 是否是顶级组织的管理员
OrgUser orgUser = orgUserList.stream().filter(o -> loginInfo.getAccountVO().getId().longValue() == o.getUserId().longValue()
&& o.getOrgId().longValue() == orgId.longValue()).findFirst().orElse(null);
OrgUserExample example = new OrgUserExample();
example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andOrgIdEqualTo(orgId);
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
OrgProjectVO orgProjectVO = new OrgProjectVO(topOrg);
if (orgUser != null) {
orgProjectVO.setRole(orgUser.getRole());
if (!CollectionUtils.isEmpty(orgUserList)) {
List<String> roleList = orgUserList.stream().map(OrgUser::getRole).collect(Collectors.toList());
orgProjectVO.setRole(roleList);
} else {
orgProjectVO.setRole(List.of());
}
loginInfo.setOrgProjectVO(orgProjectVO);
}
@ -171,4 +154,31 @@ public class OrgProjectService implements IOrgProjectService {
}
return false;
}
/**
* 根据项目编码获取组织与项目的关联信息
*/
private List<OrgProject> queryOrgProjectList(String projectCode) {
OrgProjectExample orgProjectExample = new OrgProjectExample();
orgProjectExample.createCriteria().andProjectCodeEqualTo(projectCode);
return orgProjectDao.selectByExample(orgProjectExample);
}
/**
* 根据用户ID获取组织与用户的信息
*/
private List<OrgUser> queryOrgUser(Long uid) {
OrgUserExample example = new OrgUserExample();
example.createCriteria().andUserIdEqualTo(uid);
return orgUserDAO.selectByExample(example);
}
/**
* 根据组织ID获取组织信息
*/
private List<Org> queryOrgInfoList(List<Long> orgIdList) {
OrgExample orgExample = new OrgExample();
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList);
return orgDAO.selectByExample(orgExample);
}
}

View File

@ -38,8 +38,8 @@ public class PagerQuestionService {
/**
* 查询列表
* @param queryVO
* @param isPaging
* @param queryVO  
* @param isPaging  
* @param companyIdCanNull 是否允许公司组织id可以为空true=管理使用false = 组织使用
* @return
*/
@ -68,7 +68,7 @@ public class PagerQuestionService {
/**
* 获取题库分页列表
* @param queryVO
* @param queryVO  
* @return
*/
public PageVO<PaperQuestionVO> pagingQueryQuestions(QuestionQueryVO queryVO,boolean companyIdCanNull) {
@ -80,7 +80,7 @@ public class PagerQuestionService {
/**
* 获取题型列表
* @param queryVO
* @param queryVO  
* @return
*/
public List<PaperQuestionVO> queryQuestions(QuestionQueryVO queryVO,boolean companyIdCanNull) {
@ -92,7 +92,7 @@ public class PagerQuestionService {
/**
* 获取题型所有数据
* @param questionId
* @param questionId  
* @param doNotCheckDel 是否检测数据状态是否删除 true = 不检测false=检测
* @return
*/
@ -166,8 +166,8 @@ public class PagerQuestionService {
/**
* 根据公司id和标签或类型查询
* @param companyId
* @param queryVO
* @param companyId  
* @param queryVO  
* @return
*/
public List<PaperQuestionVO> queryQuestionsForRaceLable(Long companyId, PagerLableQueryVO queryVO) {
@ -185,8 +185,8 @@ public class PagerQuestionService {
}
/**
* 添加修改
* @param questionVO
* @param accountVO
* @param questionVO  
* @param accountVO  
*/
public void saveOrUpdate(PaperQuestionVO questionVO, AccountVO accountVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.isNull(questionVO.getOrgId()),"组织id不能为空");

View File

@ -278,7 +278,7 @@ public class DeviceServiceImpl implements DeviceService {
private ProjectDevice getEntityById(long id) {
return projectDeviceDAO.selectByPrimaryKey(id);
}
private void check(ProjectDevice entity, ProjectDeviceVO projectDeviceVO) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertEquals(entity.getProjectCode(), projectDeviceVO.getProject());
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertEquals(entity.getCode(), projectDeviceVO.getCode());

View File

@ -2,11 +2,10 @@ package club.joylink.rtss.services.project;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.project.ProjectQueryVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.project.ProjectViewQueryVO;
import club.joylink.rtss.vo.project.ProjectViewVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.project.*;
import java.util.List;
@ -18,12 +17,12 @@ public interface ProjectService {
/**
* 分页
*/
PageVO<Project> pagingQuery(ProjectQueryVO queryVO);
PageVO<ProjectInfoVO> pagingQuery(ProjectQueryVO queryVO);
/**
* 列表
*/
List<Project> getAllProject();
List<ProjectInfoVO> getAllProject();
/**
* 项目Id请求项目信息
@ -50,6 +49,21 @@ public interface ProjectService {
*/
boolean checkProjectCode(String code);
/**
* 设置项目默认组织
*/
void setProjectDefaultOrg(Long id, Long orgId);
/**
* 根据项目ID获取与项目关联的所有组织信息
*/
List<CompanyVO> projectOrgList(Long id);
/**
* 快速创建默认组织
*/
ProjectInfoVO quickCreateDefaultOrg(Long id, String name, AccountVO user);
/**
* 前端设置信息分页
*/

View File

@ -1,18 +1,24 @@
package club.joylink.rtss.services.project;
import club.joylink.rtss.dao.OrgDAO;
import club.joylink.rtss.dao.org.OrgProjectDao;
import club.joylink.rtss.dao.project.ProjectDAO;
import club.joylink.rtss.dao.project.ProjectViewDAO;
import club.joylink.rtss.entity.Org;
import club.joylink.rtss.entity.OrgExample;
import club.joylink.rtss.entity.org.OrgProject;
import club.joylink.rtss.entity.org.OrgProjectExample;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.entity.project.ProjectExample;
import club.joylink.rtss.entity.project.ProjectView;
import club.joylink.rtss.entity.project.ProjectViewExample;
import club.joylink.rtss.services.org.OrgService;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.project.ProjectQueryVO;
import club.joylink.rtss.vo.project.ProjectVO;
import club.joylink.rtss.vo.project.ProjectViewQueryVO;
import club.joylink.rtss.vo.project.ProjectViewVO;
import club.joylink.rtss.vo.client.org.CompanyVO;
import club.joylink.rtss.vo.project.*;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +30,9 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@ -40,8 +48,17 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired
private ProjectViewDAO projectViewDAO;
@Autowired
private OrgProjectDao orgProjectDao;
@Autowired
private OrgDAO orgDAO;
@Autowired
private OrgService orgService;
@Override
public PageVO<Project> pagingQuery(ProjectQueryVO queryVO) {
public PageVO<ProjectInfoVO> pagingQuery(ProjectQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
ProjectExample projectExample = new ProjectExample();
ProjectExample.Criteria criteria = projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS);
@ -49,17 +66,19 @@ public class ProjectServiceImpl implements ProjectService {
criteria.andCodeEqualTo(queryVO.getCode());
}
if (!StringUtils.isEmpty(queryVO.getName())) {
criteria.andNameLike(queryVO.getName());
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
}
Page<Project> page = (Page<Project>) projectDAO.selectWithBLOBsByExample(projectExample);
return PageVO.convert(page, page.getResult());
List<ProjectInfoVO> projectVOList = handleProjectOrgInfo(page.getResult());
return PageVO.convert(page, projectVOList);
}
@Override
public List<Project> getAllProject() {
public List<ProjectInfoVO> getAllProject() {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS);
return projectDAO.selectByExample(projectExample);
List<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
return handleProjectOrgInfo(projectList);
}
@Override
@ -119,6 +138,55 @@ public class ProjectServiceImpl implements ProjectService {
return num > 0;
}
@Override
@CacheEvict(cacheNames = "project", allEntries = true)
public void setProjectDefaultOrg(Long id, Long orgId) {
Project project = new Project();
project.setId(id);
project.setDefaultOrg(orgId);
projectDAO.updateByPrimaryKeySelective(project);
}
@Override
public List<CompanyVO> projectOrgList(Long id) {
Project project = projectDAO.selectByPrimaryKey(id);
if (project == null) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在");
}
List<OrgProject> orgProjectList = getOrgProjectList(List.of(project.getCode()));
if (!CollectionUtils.isEmpty(orgProjectList)) {
List<Long> orgIdList = orgProjectList.stream().map(OrgProject::getOrgId).distinct().collect(Collectors.toList());
List<Org> orgList = getOrgList(orgIdList);
return orgList.stream().map(CompanyVO::simpleInfoVO).collect(Collectors.toList());
}
return List.of();
}
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(cacheNames = "project", allEntries = true)
public ProjectInfoVO quickCreateDefaultOrg(Long id, String name, AccountVO user) {
Project project = projectDAO.selectByPrimaryKey(id);
if (project == null) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在");
}
List<OrgProject> orgProjectList = getOrgProjectList(List.of(project.getCode()));
if (!CollectionUtils.isEmpty(orgProjectList)) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "存在关联组织,请设置");
}
// 保存默认组织
CompanyVO companyVO = new CompanyVO();
companyVO.setName(name);
companyVO.setProjectCodes(List.of(project.getCode()));
CompanyVO resultCompany = orgService.createTopOrg(companyVO, user);
// 修改项目信息
setProjectDefaultOrg(id, resultCompany.getId());
ProjectInfoVO projectVO = new ProjectInfoVO(project);
projectVO.setOrgList(List.of(name));
projectVO.setDefaultOrgName(name);
return projectVO;
}
@Override
public PageVO<ProjectView> projectViewPagingQuery(ProjectViewQueryVO queryVO) {
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
@ -208,7 +276,7 @@ public class ProjectServiceImpl implements ProjectService {
@Override
public List<ProjectVO> getSimpleProjectList() {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS).andViewShowEqualTo(1);
projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS);
List<Project> projectList = projectDAO.selectWithBLOBsByExample(projectExample);
return projectList.stream().map(project -> new ProjectVO(project)).collect(Collectors.toList());
}
@ -242,4 +310,51 @@ public class ProjectServiceImpl implements ProjectService {
List<ProjectView> projectList = projectViewDAO.selectWithBLOBsByExample(new ProjectViewExample());
return projectList.stream().map(projectView -> new ProjectViewVO(projectView)).collect(Collectors.toList());
}
private List<OrgProject> getOrgProjectList(List<String> projectCodeList) {
OrgProjectExample orgProjectExample = new OrgProjectExample();
orgProjectExample.createCriteria().andProjectCodeIn(projectCodeList);
return orgProjectDao.selectByExample(orgProjectExample);
}
private List<Org> getOrgList(List<Long> orgIdList) {
OrgExample orgExample = new OrgExample();
orgExample.createCriteria().andIdIn(orgIdList);
return orgDAO.selectByExample(orgExample);
}
/**
* 查询项目列表时关联组织信息
*/
private List<ProjectInfoVO> handleProjectOrgInfo(List<Project> projectList) {
List<String> projectCodeList = projectList.stream().map(Project::getCode).collect(Collectors.toList());
if (CollectionUtils.isEmpty(projectCodeList)) {
return List.of();
}
List<OrgProject> orgProjectList = getOrgProjectList(projectCodeList);
Map<Long, Org> orgMap = new HashMap<>();
Map<String, List<Long>> orgProjectMap = new HashMap<>(orgProjectList.size());
if (!CollectionUtils.isEmpty(orgProjectList)) {
List<Long> orgIdList = orgProjectList.stream().map(OrgProject::getOrgId).distinct().collect(Collectors.toList());
List<Org> orgList = getOrgList(orgIdList);
orgMap.putAll(orgList.stream().collect(Collectors.toMap(Org::getId, o -> o)));
orgProjectMap.putAll(orgProjectList.stream().collect(Collectors.groupingBy(OrgProject::getProjectCode, Collectors.mapping(OrgProject::getOrgId, Collectors.toList()))));
}
// 包装projectVO
List<ProjectInfoVO> projectVOList = projectList.stream().map(p -> {
ProjectInfoVO projectVO = new ProjectInfoVO(p);
if (orgProjectMap.containsKey(p.getCode())) {
List<String> orgNameList = orgProjectMap.get(p.getCode()).stream().filter(id -> orgMap.containsKey(id))
.map(id -> orgMap.get(id).getName()).sorted().collect(Collectors.toList());
projectVO.setOrgList(orgNameList);
} else {
projectVO.setOrgList(List.of());
}
if (p.getDefaultOrg() != null && orgMap.containsKey(p.getDefaultOrg())) {
projectVO.setDefaultOrgName(orgMap.get(p.getDefaultOrg()).getName());
}
return projectVO;
}).collect(Collectors.toList());
return projectVOList;
}
}

View File

@ -740,42 +740,70 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
}
public enum Type {
/** 地铁 */
/**
* 地铁
*/
METRO,
/** 铁路/大铁 */
/**
* 铁路/大铁
*/
RAILWAY,
/** 应急调度Emergency dispatching command system */
/**
* 应急调度Emergency dispatching command system
*/
EMERGENCY,
}
public enum Usage {
/** 单角色仿真 */
/**
* 单角色仿真
*/
SINGLE_MEMBER,
/** 单客户端仿真 */
/**
* 单客户端仿真
*/
SINGLE_CLIENT,
/** 综合演练 */
/**
* 综合演练
*/
JOINT,
}
public enum Function {
/** 大客流Large passenger flow */
/**
* 大客流Large passenger flow
*/
LPF,
/** 实训室 */
/**
* 实训室
*/
TRAINING_ROOM,
/** 实训设计 */
/**
* 实训设计
*/
TRAINING_DESIGN,
/** 实训 */
/**
* 实训
*/
TRAINING,
/** 考试 */
/**
* 考试
*/
EXAM,
}
public enum Client {
/** 联锁 */
/**
* 联锁
*/
INTERLOCK,
/** 大屏 */
/**
* 大屏
*/
BIG_SCREEN,
/** 综合监控 */
/**
* 综合监控
*/
ISCS,
}
}

View File

@ -20,47 +20,56 @@ import java.util.List;
@NoArgsConstructor
public class CompanyVO {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String code;
/**公司名称*/
@NotBlank(message = "公司名称不能为空")
private String name;
private String code;
/**
* 公司名称
*/
@NotBlank(message = "公司名称不能为空")
private String name;
private List<String> projectCodes;
private List<String> projectCodes;
public CompanyVO(Org entity) {
this.id = entity.getId();
this.code = entity.getCode();
this.name = entity.getName();
if (StringUtils.hasText(entity.getProjectCode())) {
this.projectCodes = Arrays.asList(entity.getProjectCode().split(","));
}
}
public CompanyVO(Org entity) {
this.id = entity.getId();
this.code = entity.getCode();
this.name = entity.getName();
if (StringUtils.hasText(entity.getProjectCode())) {
this.projectCodes = Arrays.asList(entity.getProjectCode().split(","));
}
}
public static List<CompanyVO> convert2VOList(List<Org> dataList) {
List<CompanyVO> voList = new ArrayList<>();
for (Org entity : dataList) {
voList.add(new CompanyVO(entity));
}
return voList;
}
public static CompanyVO simpleInfoVO(Org entity) {
CompanyVO companyVO = new CompanyVO();
companyVO.setId(entity.getId());
companyVO.setName(entity.getName());
return companyVO;
}
public static List<CompanyVO> convert2VOList(List<Org> dataList) {
List<CompanyVO> voList = new ArrayList<>();
for (Org entity : dataList) {
voList.add(new CompanyVO(entity));
}
return voList;
}
public Org toDB() {
Org entity = new Org();
entity.setId(this.id);
entity.setName(this.name);
entity.setProjectCode(getDBProjectCode());
return entity;
}
Org entity = new Org();
entity.setId(this.id);
entity.setName(this.name);
entity.setProjectCode(getDBProjectCode());
return entity;
}
@JsonIgnore
public String getDBProjectCode() {
if (!CollectionUtils.isEmpty(projectCodes)) {
return String.join(",", projectCodes);
} else {
return null;
}
}
@JsonIgnore
public String getDBProjectCode() {
if (!CollectionUtils.isEmpty(projectCodes)) {
return String.join(",", projectCodes);
} else {
return null;
}
}
}

View File

@ -4,6 +4,8 @@ import club.joylink.rtss.entity.Org;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
public class OrgProjectVO {
@ -13,7 +15,7 @@ public class OrgProjectVO {
private Long topOrgId;
private String role;
private List<String> role;
public OrgProjectVO(Org org) {
this.orgId = org.getId();

View File

@ -0,0 +1,74 @@
package club.joylink.rtss.vo.project;
import club.joylink.rtss.entity.project.Project;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* 项目信息管理展示实体
*/
@Setter
@Getter
public class ProjectInfoVO {
/**
* 数据库唯一ID
*/
private Long id;
/**
* 项目编码后端使用
*/
private String code;
/**
* 项目名称
*/
private String name;
/**
* 描述
*/
private String description;
/**
* 后端服务设置
*/
private String serverSetting;
/**
* 关联组织名称
*/
private List<String> orgList;
/**
* 默认组织ID
*/
private Long defaultOrg;
/**
* 默认组织名称
*/
private String defaultOrgName;
/**
* 是否可以创建默认组织
*/
private boolean createDefaultOrg;
public ProjectInfoVO(Project project) {
this.id = project.getId();
this.code = project.getCode();
this.name = project.getName();
this.description = project.getDescription();
this.serverSetting = project.getServerSetting();
this.defaultOrg = project.getDefaultOrg();
}
public void setOrgList(List<String> orgList) {
this.orgList = orgList;
this.createDefaultOrg = CollectionUtils.isEmpty(orgList);
}
}

View File

@ -24,9 +24,13 @@ public class ProjectVO {
@JsonIgnore
private ProjectServerConfig projectServerConfig;
@JsonIgnore
private Long defaultOrg;
public ProjectVO(Project project) {
this.label = project.getName();
this.value = project.getCode();
this.defaultOrg = project.getDefaultOrg();
if (StringUtils.isEmpty(project.getServerSetting())) {
this.projectServerConfig = null;
} else {

View File

@ -87,7 +87,7 @@
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from paper_question
from rts_paper_question
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
@ -109,7 +109,7 @@
distinct
</if>
<include refid="Base_Column_List" />
from paper_question
from rts_paper_question
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
@ -130,21 +130,21 @@
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from paper_question
from rts_paper_question
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from paper_question
delete from rts_paper_question
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="club.joylink.rtss.entity.paper.question.PaperQuestionExample">
delete from paper_question
delete from rts_paper_question
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs">
insert into paper_question (id, `type`, create_user_id,
insert into rts_paper_question (id, `type`, create_user_id,
create_time, org_id, tags,
question_answer, is_del, question,
question_option)
@ -154,7 +154,7 @@
#{questionOption,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs">
insert into paper_question
insert into rts_paper_question
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
@ -221,13 +221,13 @@
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.paper.question.PaperQuestionExample" resultType="java.lang.Long">
select count(*) from paper_question
select count(*) from rts_paper_question
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update paper_question
update rts_paper_question
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
@ -265,7 +265,7 @@
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update paper_question
update rts_paper_question
set id = #{record.id,jdbcType=BIGINT},
`type` = #{record.type,jdbcType=VARCHAR},
create_user_id = #{record.createUserId,jdbcType=BIGINT},
@ -281,7 +281,7 @@
</if>
</update>
<update id="updateByExample" parameterType="map">
update paper_question
update rts_paper_question
set id = #{record.id,jdbcType=BIGINT},
`type` = #{record.type,jdbcType=VARCHAR},
create_user_id = #{record.createUserId,jdbcType=BIGINT},
@ -295,7 +295,7 @@
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs">
update paper_question
update rts_paper_question
<set>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
@ -328,7 +328,7 @@
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.paper.question.PaperQuestionWithBLOBs">
update paper_question
update rts_paper_question
set `type` = #{type,jdbcType=VARCHAR},
create_user_id = #{createUserId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
@ -341,7 +341,7 @@
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.paper.question.PaperQuestion">
update paper_question
update rts_paper_question
set `type` = #{type,jdbcType=VARCHAR},
create_user_id = #{createUserId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},

View File

@ -8,7 +8,7 @@
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="view_show" property="viewShow" jdbcType="INTEGER"/>
<result column="default_org" property="defaultOrg" jdbcType="BIGINT"/>
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="club.joylink.rtss.entity.project.Project" extends="BaseResultMap">
<result column="description" property="description" jdbcType="LONGVARCHAR"/>
@ -75,7 +75,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, code, name, create_time, update_time, status, view_show
id, code, name, create_time, update_time, status, default_org
</sql>
<sql id="Blob_Column_List">
description,server_setting
@ -146,10 +146,10 @@
</delete>
<insert id="insert" parameterType="club.joylink.rtss.entity.project.Project">
insert into project ( code, name, description, create_time, update_time, status, server_setting,view_show)
insert into project ( code, name, description, create_time, update_time, status, server_setting,default_org)
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})
#{serverSetting,jdbcType=LONGVARCHAR}, #{defaultOrg, jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.project.Project">
@ -179,8 +179,8 @@
<if test="serverSetting != null">
server_setting,
</if>
<if test="viewShow != null">
view_show,
<if test="defaultOrg != null">
default_org,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -208,8 +208,8 @@
<if test="serverSetting != null">
#{serverSetting,jdbcType=LONGVARCHAR},
</if>
<if test="viewShow != null">
#{viewShow,jdbcType=INTEGER},
<if test="defaultOrg != null">
#{defaultOrg, jdbcType=BIGINT},
</if>
</trim>
</insert>
@ -238,8 +238,8 @@
<if test="serverSetting != null">
server_setting = #{serverSetting,jdbcType=LONGVARCHAR},
</if>
<if test="viewShow != null">
view_show = #{viewShow,jdbcType=INTEGER},
<if test="defaultOrg != null">
default_org = #{defaultOrg, jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
@ -254,7 +254,7 @@
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
server_setting = #{serverSetting,jdbcType=LONGVARCHAR},
view_show = #{viewShow,jdbcType=INTEGER}
default_org = #{defaultOrg, jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
@ -266,7 +266,7 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER},
server_setting = #{serverSetting,jdbcType=LONGVARCHAR}
default_org = #{defaultOrg, jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>