解除对Org.projectCode的使用
This commit is contained in:
parent
7ef02b4ce4
commit
e81fa4548d
@ -44,7 +44,7 @@ public class CompanyController {
|
||||
* 创建顶级组织
|
||||
*/
|
||||
@PostMapping
|
||||
public CompanyVO create(@RequestBody @Validated CompanyVO company, @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO user) {
|
||||
public OrgVO create(@RequestBody @Validated OrgVO company, @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO user) {
|
||||
return iOrgService.createTopOrg(company, user);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class CompanyController {
|
||||
* 获取公司列表
|
||||
*/
|
||||
@GetMapping
|
||||
public List<CompanyVO> queryAll() {
|
||||
public List<OrgVO> queryAll() {
|
||||
return iOrgService.queryAllTopOrg();
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public class CompanyController {
|
||||
* 分页获取公司列表
|
||||
*/
|
||||
@GetMapping("paging")
|
||||
public PageVO<CompanyVO> pagingQueryAll(OrgQueryVO queryVO) {
|
||||
public PageVO<OrgVO> pagingQueryAll(OrgQueryVO queryVO) {
|
||||
return iOrgService.pagedQueryAllTopOrg(queryVO);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class CompanyController {
|
||||
* 查询公司信息
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
public CompanyVO get(@PathVariable Long id) {
|
||||
public OrgVO get(@PathVariable Long id) {
|
||||
return iOrgService.get(id);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class CompanyController {
|
||||
* 更新公司信息
|
||||
*/
|
||||
@PutMapping("{id}")
|
||||
public CompanyVO updateCompany(@PathVariable Long id, @RequestBody @Validated CompanyVO company, @RequestAttribute AccountVO user) {
|
||||
public OrgVO updateCompany(@PathVariable Long id, @RequestBody @Validated OrgVO company, @RequestAttribute AccountVO user) {
|
||||
return iOrgService.updateOrg(id, company, user);
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class CompanyController {
|
||||
* 微信小程用户绑定为单位管理员
|
||||
*/
|
||||
@PutMapping(path = "/bind/company")
|
||||
public CompanyVO userScanCodeBindCompany(Long userId, Long companyId) {
|
||||
public OrgVO userScanCodeBindCompany(Long userId, Long companyId) {
|
||||
return iOrgUserService.userScanCodeBindCompanyManager(userId, companyId);
|
||||
}
|
||||
|
||||
@ -92,15 +92,15 @@ public class CompanyController {
|
||||
* 添加部门信息
|
||||
*/
|
||||
@PostMapping(path = "/dept")
|
||||
public DepartmentVO createDepart(@RequestBody @Validated DepartmentVO departmentVO) {
|
||||
return iOrgUserService.createDepart(departmentVO);
|
||||
public OrgVO createDepart(@RequestBody @Validated OrgVO orgVO) {
|
||||
return iOrgUserService.createDepart(orgVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单位所有部门
|
||||
*/
|
||||
@GetMapping(path = "{companyId}/dept")
|
||||
public List<DepartmentVO> queryCompanyDepart(@PathVariable Long companyId) {
|
||||
public List<OrgVO> queryCompanyDepart(@PathVariable Long companyId) {
|
||||
return iOrgUserService.getCompanyAllDepart(companyId);
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ public class CompanyController {
|
||||
* 获取部门及其子树
|
||||
*/
|
||||
@GetMapping(path = "{companyId}/dept/{deptId}/tree")
|
||||
public DepartmentVO queryDepartTree(@PathVariable Long deptId, @PathVariable Long companyId) {
|
||||
public OrgVO queryDepartTree(@PathVariable Long deptId, @PathVariable Long companyId) {
|
||||
return iOrgUserService.getDepartTree(companyId, deptId);
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class CompanyController {
|
||||
* 获取部门及其子部门
|
||||
*/
|
||||
@GetMapping(path = "{companyId}/dept/{deptId}")
|
||||
public List<DepartmentVO> queryDepart(@PathVariable Long deptId, @PathVariable Long companyId) {
|
||||
public List<OrgVO> queryDepart(@PathVariable Long deptId, @PathVariable Long companyId) {
|
||||
return iOrgUserService.getDepartAndChild(companyId, deptId);
|
||||
}
|
||||
|
||||
@ -132,16 +132,16 @@ public class CompanyController {
|
||||
* 查询部门信息
|
||||
*/
|
||||
@GetMapping("/dept/{deptId}")
|
||||
public DepartmentVO getDepart(@PathVariable Long deptId) {
|
||||
return iOrgUserService.getDepartById(deptId);
|
||||
public OrgVO queryDepart(@PathVariable Long deptId) {
|
||||
return iOrgUserService.queryDepartById(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新部门信息
|
||||
*/
|
||||
@PutMapping("/dept/{id}")
|
||||
public void updateDepartInfo(@PathVariable Long id, @RequestBody @Validated DepartmentVO departmentVO) {
|
||||
iOrgUserService.updateDepartInfo(id, departmentVO);
|
||||
public void updateDepartInfo(@PathVariable Long id, @RequestBody @Validated OrgVO orgVO) {
|
||||
iOrgUserService.updateDepartInfo(id, orgVO);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,7 +228,7 @@ public class CompanyController {
|
||||
* 分页查询当前登录用户所属组织下的班级
|
||||
*/
|
||||
@GetMapping("/paged/cls")
|
||||
public PageVO<DepartmentVO> pagedQuerySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
|
||||
public PageVO<OrgVO> pagedQuerySelfCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
|
||||
return iOrgService.pagedQueryCls(queryVO, loginInfo);
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ public class CompanyController {
|
||||
* 查询当前登录项目所属组织下的班级
|
||||
*/
|
||||
@GetMapping("/list/cls")
|
||||
public List<DepartmentVO> queryCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
|
||||
public List<OrgVO> queryCls(OrgQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) {
|
||||
return iOrgService.queryCls(queryVO, loginInfo);
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ public class CompanyController {
|
||||
* 查询规则能够应用到的组织
|
||||
*/
|
||||
@GetMapping("/orgScoringRule/{ruleId}/canApplyTo")
|
||||
public List<DepartmentVO> queryRuleCanApplyTo(@PathVariable Long ruleId, @RequestAttribute AccountVO user) {
|
||||
public List<OrgVO> queryRuleCanApplyTo(@PathVariable Long ruleId, @RequestAttribute AccountVO user) {
|
||||
return iOrgScoringRuleService.queryRuleCanApplyTo(ruleId, user);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package club.joylink.rtss.controller.org;
|
||||
|
||||
import club.joylink.rtss.services.org.IOrgService;
|
||||
import club.joylink.rtss.vo.client.org.DepartmentVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -23,7 +23,7 @@ public class OrgController {
|
||||
* 列表查询该组织下的所有班级
|
||||
*/
|
||||
@GetMapping("/{topOrgId}/cls/list")
|
||||
public List<DepartmentVO> listQueryCls(@PathVariable long topOrgId) {
|
||||
public List<OrgVO> listQueryCls(@PathVariable long topOrgId) {
|
||||
return iOrgService.listQueryCls(topOrgId);
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import club.joylink.rtss.entity.org.OrgProject;
|
||||
import club.joylink.rtss.services.org.IOrgProjectService;
|
||||
import club.joylink.rtss.services.org.OrgService;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgProjectVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -57,8 +57,8 @@ public class OrgProjectController {
|
||||
OrgProject orgProject = new OrgProject();
|
||||
orgProject.setCreateTime(LocalDateTime.now());
|
||||
orgProject.setCreatorId(1L);
|
||||
List<CompanyVO> orgs = orgService.queryAllTopOrg();
|
||||
for (CompanyVO org : orgs) {
|
||||
List<OrgVO> orgs = orgService.queryAllTopOrg();
|
||||
for (OrgVO org : orgs) {
|
||||
List<String> projectCodes = org.getProjectCodes();
|
||||
if (!CollectionUtils.isEmpty(projectCodes)) {
|
||||
for (String projectCode : projectCodes) {
|
||||
|
@ -6,7 +6,7 @@ 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.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import club.joylink.rtss.vo.project.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -69,14 +69,14 @@ public class ProjectInfoController {
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/orgList")
|
||||
public List<CompanyVO> orgList(@PathVariable Long id) {
|
||||
public List<OrgVO> orgList(@PathVariable Long id) {
|
||||
return projectService.projectOrgList(id);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/createDefaultOrg")
|
||||
public ProjectInfoVO quickCreateDefaultOrg(@PathVariable Long id, @RequestBody CompanyVO companyVO
|
||||
public ProjectInfoVO quickCreateDefaultOrg(@PathVariable Long id, @RequestBody OrgVO orgVO
|
||||
, @RequestAttribute(AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO user) {
|
||||
return projectService.quickCreateDefaultOrg(id, companyVO, user);
|
||||
return projectService.quickCreateDefaultOrg(id, orgVO, user);
|
||||
}
|
||||
|
||||
@GetMapping("/viewSetting/page")
|
||||
|
@ -4,7 +4,7 @@ import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @author
|
||||
* 组织树
|
||||
*/
|
||||
public class Org implements Serializable {
|
||||
@ -28,6 +28,7 @@ public class Org implements Serializable {
|
||||
/**
|
||||
* 关联项目code
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
private String projectCode;
|
||||
|
||||
private String code;
|
||||
@ -211,4 +212,4 @@ public class Org implements Serializable {
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package club.joylink.rtss.services;
|
||||
|
||||
import club.joylink.rtss.entity.Org;
|
||||
import club.joylink.rtss.entity.SysAccount;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.UserQueryVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import club.joylink.rtss.vo.client.user.*;
|
||||
import club.joylink.rtss.vo.user.AccountCreateVO;
|
||||
import club.joylink.rtss.vo.wx.WmUserSession;
|
||||
@ -33,16 +32,6 @@ public interface ISysUserService {
|
||||
*/
|
||||
AccountVO findUserById(Long id);
|
||||
|
||||
/**
|
||||
* 设置用户的(与项目{project}关联的)组织信息
|
||||
*/
|
||||
void setOrgInfoOfOrgRelWithTheProject(String project, AccountVO accountVO);
|
||||
|
||||
/**
|
||||
* 设置用户与该组织的关联信息
|
||||
*/
|
||||
void setOrgInfoOfThisOrg(Org topOrg, AccountVO accountVO);
|
||||
|
||||
SysAccount findEntity(@NonNull String account, long orgId);
|
||||
|
||||
boolean isExist(@NonNull String account, long orgId);
|
||||
@ -308,7 +297,7 @@ public interface ISysUserService {
|
||||
*/
|
||||
void userBindWm(String code, Long userId);
|
||||
|
||||
CompanyVO userScanCodeBindCompanyManager(Long userId, Long companyId);
|
||||
OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId);
|
||||
|
||||
AccountVO getUserBaseInfoById(Long id);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package club.joylink.rtss.services;
|
||||
|
||||
import club.joylink.rtss.configuration.configProp.WeChatConfig;
|
||||
import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.constants.EmailSubject;
|
||||
import club.joylink.rtss.constants.StatusEnum;
|
||||
@ -10,13 +9,14 @@ import club.joylink.rtss.dao.UserSubscribeMapper;
|
||||
import club.joylink.rtss.entity.*;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.cache.ICacheService;
|
||||
import club.joylink.rtss.services.org.IOrgProjectService;
|
||||
import club.joylink.rtss.services.org.IOrgService;
|
||||
import club.joylink.rtss.services.org.IOrgUserService;
|
||||
import club.joylink.rtss.util.EncryptUtil;
|
||||
import club.joylink.rtss.util.RandomGenerator;
|
||||
import club.joylink.rtss.vo.*;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import club.joylink.rtss.vo.client.user.*;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.user.AccountCreateVO;
|
||||
@ -64,9 +64,6 @@ public class SysUserService implements ISysUserService {
|
||||
@Autowired
|
||||
private UserSubscribeMapper userSubscribeMapper;
|
||||
|
||||
@Autowired
|
||||
private WeChatConfig weChatConfig;
|
||||
|
||||
@Autowired
|
||||
private IWxApiService iWxApiService;
|
||||
|
||||
@ -84,6 +81,8 @@ public class SysUserService implements ISysUserService {
|
||||
|
||||
@Autowired
|
||||
private QRCodeManager qrCodeManager;
|
||||
@Autowired
|
||||
private IOrgProjectService iOrgProjectService;
|
||||
|
||||
/**
|
||||
* @update 20221019 删除账号查询逻辑,去除绑定组织操作
|
||||
@ -112,47 +111,6 @@ public class SysUserService implements ISysUserService {
|
||||
return accountVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrgInfoOfOrgRelWithTheProject(String project, AccountVO accountVO) {
|
||||
if (project != null) {
|
||||
Org topOrg = iOrgService.findTopOrgOfUser(accountVO.getId());
|
||||
if (topOrg != null && topOrg.getProjectCode().contains(project)) {
|
||||
setOrgInfoOfThisOrg(topOrg, accountVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrgInfoOfThisOrg(Org topOrg, AccountVO accountVO) {
|
||||
if (topOrg != null && accountVO != null && topOrg.getId() != null && accountVO.getId() != null) {
|
||||
boolean flag = false;
|
||||
if (Objects.equals(topOrg.getId(), accountVO.getOrgId())) {
|
||||
flag = true;
|
||||
} else {
|
||||
List<OrgUser> orgUsers = iOrgUserService.findEntitiesByUserId(accountVO.getId(), null);
|
||||
if (CollectionUtils.isEmpty(orgUsers))
|
||||
return;
|
||||
if (orgUsers.stream().anyMatch(ou -> Objects.equals(ou.getOrgId(), topOrg.getId()))) {
|
||||
flag = true;
|
||||
} else {
|
||||
List<Long> orgIds = orgUsers.stream().map(OrgUser::getOrgId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(orgIds))
|
||||
return;
|
||||
List<Org> orgs = iOrgService.findEntities(orgIds, BusinessConsts.Org.Status.VALID);
|
||||
if (CollectionUtils.isEmpty(orgs))
|
||||
return;
|
||||
Set<Long> userRelTopOrgId = orgs.stream().map(Org::getRootId).collect(Collectors.toSet()); //用户直接或间接关联的所有顶级组织id
|
||||
if (userRelTopOrgId.contains(topOrg.getId())) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
accountVO.setOrgInfo(topOrg, iOrgUserService.isTheRoleInThisOrg(accountVO.getId(), topOrg.getId(), BusinessConsts.OrgRole.Admin));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysAccount findEntity(@NonNull String account, long orgId) {
|
||||
SysAccountExample example = new SysAccountExample();
|
||||
@ -301,20 +259,32 @@ public class SysUserService implements ISysUserService {
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
Page<SysAccount> page = (Page<SysAccount>) this.sysAccountDAO.selectByExample(example);
|
||||
List<AccountVO> accountVOS = AccountVO.convertFromDB(page.getResult());
|
||||
List<Long> userIds = accountVOS.stream().map(AccountVO::getId).collect(Collectors.toList());
|
||||
Map<Long, Long> userOrgMap = iOrgUserService.findEntitiesByUserIds(userIds, BusinessConsts.OrgRole.Admin)
|
||||
.stream().collect(Collectors.toMap(OrgUser::getUserId, OrgUser::getOrgId));
|
||||
Map<Long, Org> orgMap = iOrgService.findEntities(new ArrayList<>(userOrgMap.values()), BusinessConsts.Org.Status.VALID)
|
||||
.stream().collect(Collectors.toMap(Org::getId, Function.identity()));
|
||||
accountVOS.forEach(vo -> {
|
||||
Long orgId = userOrgMap.get(vo.getId());
|
||||
if (orgId != null) {
|
||||
Org org = orgMap.get(orgId);
|
||||
if (org != null) {
|
||||
vo.setOrgInfo(org, true);
|
||||
}
|
||||
// List<Long> userIds = accountVOS.stream().map(AccountVO::getId).collect(Collectors.toList());
|
||||
// Map<Long, Long> userOrgMap = iOrgUserService.findEntitiesByUserIds(userIds, BusinessConsts.OrgRole.Admin)
|
||||
// .stream().collect(Collectors.toMap(OrgUser::getUserId, OrgUser::getOrgId));
|
||||
// Map<Long, Org> orgMap = iOrgService.findEntities(new ArrayList<>(userOrgMap.values()), BusinessConsts.Org.Status.VALID)
|
||||
// .stream().collect(Collectors.toMap(Org::getId, Function.identity()));
|
||||
// Map<Long, List<String>> orgId_projects_map = iOrgProjectService.queryOrgProjectListByOrgIds(new ArrayList<>(orgMap.keySet())).stream()
|
||||
// .collect(Collectors.groupingBy(OrgProject::getOrgId, Collectors.mapping(OrgProject::getProjectCode, Collectors.toList())));
|
||||
// accountVOS.forEach(vo -> {
|
||||
// Long orgId = userOrgMap.get(vo.getId());
|
||||
// if (orgId != null) {
|
||||
// Org org = orgMap.get(orgId);
|
||||
// if (org != null) {
|
||||
// vo.setOrgInfo(org, true, orgId_projects_map.get(org.getId()));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
List<Long> orgIds = accountVOS.stream().map(AccountVO::getOrgId).collect(Collectors.toList());
|
||||
Map<Long, Org> orgMap = iOrgService.findEntities(orgIds, null).stream()
|
||||
.collect(Collectors.toMap(Org::getId, Function.identity()));
|
||||
accountVOS.forEach(accountVO -> {
|
||||
Org org = orgMap.get(accountVO.getOrgId());
|
||||
if (org != null) {
|
||||
accountVO.setOrgInfo(org, false, null);
|
||||
}
|
||||
});
|
||||
|
||||
return PageVO.convert(page, accountVOS);
|
||||
}
|
||||
|
||||
@ -405,15 +375,13 @@ public class SysUserService implements ISysUserService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CompanyVO userScanCodeBindCompanyManager(Long userId, Long companyId) {
|
||||
Org company = companyDAO.selectByPrimaryKey(companyId);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(company, String.format("id为[%s]的组织不存在", companyId));
|
||||
public OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId) {
|
||||
SysAccount sysAccount = sysAccountDAO.selectByPrimaryKey(userId);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(sysAccount, String.format("id为[%s]的用户不存在", userId));
|
||||
AccountVO accountVO = new AccountVO(sysAccount);
|
||||
iOrgUserService.userBindCompanyManager(accountVO, companyId);
|
||||
OrgVO orgVO = iOrgUserService.userBindCompanyManager(accountVO, companyId);
|
||||
this.loginSessionManager.updateLoginUser(accountVO);
|
||||
return new CompanyVO(company);
|
||||
return orgVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1056,11 +1024,16 @@ public class SysUserService implements ISysUserService {
|
||||
private AccountVO queryUserInfoWithOrgInfo(long userId) {
|
||||
SysAccount sysAccount = getEntity(userId);
|
||||
AccountVO accountVO = new AccountVO(sysAccount);
|
||||
List<OrgUser> adminOrgUser = iOrgUserService.findEntitiesByUserId(userId, BusinessConsts.OrgRole.Admin);
|
||||
if (!CollectionUtils.isEmpty(adminOrgUser)) {
|
||||
Org org = iOrgService.findEntity(adminOrgUser.get(0).getOrgId());
|
||||
accountVO.setOrgInfo(org, true);
|
||||
}
|
||||
// 2022-12-09 17:27:30 账号组织关系变成一对多之后,这里逻辑不清楚了,经查,只用到了account字段,故删除以下
|
||||
// List<OrgUser> adminOrgUser = iOrgUserService.findEntitiesByUserId(userId, BusinessConsts.OrgRole.Admin);
|
||||
// if (!CollectionUtils.isEmpty(adminOrgUser)) {
|
||||
// Org org = iOrgService.findEntity(adminOrgUser.get(0).getOrgId());
|
||||
// if (org != null) {
|
||||
// List<String> projects = iOrgProjectService.queryOrgProjectListByOrgId(org.getId()).stream()
|
||||
// .map(OrgProject::getProjectCode).collect(Collectors.toList());
|
||||
// accountVO.setOrgInfo(org, true, projects);
|
||||
// }
|
||||
// }
|
||||
return accountVO;
|
||||
}
|
||||
|
||||
|
@ -37,4 +37,6 @@ public interface IOrgProjectService {
|
||||
* 保存顶级信息时,处理编辑信息
|
||||
*/
|
||||
void update(Long orgId, List<String> projectList, AccountVO user);
|
||||
|
||||
List<OrgProject> queryOrgProjectListByOrgIds(List<Long> orgIds);
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ package club.joylink.rtss.services.org;
|
||||
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.org.DepartmentVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgScoringResultVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgScoringRuleQueryVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgScoringRuleVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
@ -57,5 +57,5 @@ public interface IOrgScoringRuleService {
|
||||
* 查询评价规则能应用到的组织
|
||||
* @return
|
||||
*/
|
||||
List<DepartmentVO> queryRuleCanApplyTo(Long ruleId, AccountVO user);
|
||||
List<OrgVO> queryRuleCanApplyTo(Long ruleId, AccountVO user);
|
||||
}
|
||||
|
@ -6,10 +6,9 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.ExamDefinitionVO;
|
||||
import club.joylink.rtss.vo.client.Node;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.org.DepartmentVO;
|
||||
import club.joylink.rtss.vo.client.org.NonTopOrgCreateVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgQueryVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -17,11 +16,11 @@ import java.util.List;
|
||||
|
||||
public interface IOrgService {
|
||||
@Transactional
|
||||
CompanyVO createTopOrg(CompanyVO companyVO, AccountVO user);
|
||||
OrgVO createTopOrg(OrgVO orgVO, AccountVO user);
|
||||
|
||||
List<CompanyVO> queryAllTopOrg();
|
||||
List<OrgVO> queryAllTopOrg();
|
||||
|
||||
PageVO<CompanyVO> pagedQueryAllTopOrg(OrgQueryVO queryVO);
|
||||
PageVO<OrgVO> pagedQueryAllTopOrg(OrgQueryVO queryVO);
|
||||
|
||||
void confirmExist(Long orgId);
|
||||
|
||||
@ -37,7 +36,7 @@ public interface IOrgService {
|
||||
// TODO 20220922 将Project 修改为 String
|
||||
Collection<Org> findEntities(String project, String status);
|
||||
|
||||
CompanyVO updateOrg(Long id, CompanyVO companyVO, AccountVO user);
|
||||
OrgVO updateOrg(Long id, OrgVO orgVO, AccountVO user);
|
||||
|
||||
/**
|
||||
* 删除非顶级组织
|
||||
@ -51,12 +50,12 @@ public interface IOrgService {
|
||||
/**
|
||||
* 分页查询自己创建的班级
|
||||
*/
|
||||
PageVO<DepartmentVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo);
|
||||
PageVO<OrgVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo);
|
||||
|
||||
/**
|
||||
* 查询自己创建的班级
|
||||
*/
|
||||
List<DepartmentVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo);
|
||||
List<OrgVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo);
|
||||
|
||||
/**
|
||||
* 获取该组织所属的顶级组织
|
||||
@ -70,7 +69,7 @@ public interface IOrgService {
|
||||
*/
|
||||
Node<Object> adminQueryOrgTree(Long orgId);
|
||||
|
||||
CompanyVO get(Long id);
|
||||
OrgVO get(Long id);
|
||||
|
||||
/**
|
||||
* 查询这些考试关联的班级
|
||||
@ -96,5 +95,12 @@ public interface IOrgService {
|
||||
* 查询该组织下的所有班级。
|
||||
* 目前组织结构仅有两级,非顶级的就是班级。
|
||||
*/
|
||||
List<DepartmentVO> listQueryCls(long topOrgId);
|
||||
List<OrgVO> listQueryCls(long topOrgId);
|
||||
|
||||
/**
|
||||
* 查询组织信息(可能返回null)
|
||||
*/
|
||||
OrgVO query(Long id);
|
||||
|
||||
OrgVO getTopOrg(long topOrgId);
|
||||
}
|
||||
|
@ -15,21 +15,21 @@ public interface IOrgUserService {
|
||||
/**
|
||||
* 用户绑定为单位管理员
|
||||
*/
|
||||
CompanyVO userScanCodeBindCompanyManager(Long userId, Long companyId);
|
||||
OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId);
|
||||
|
||||
DepartmentVO createDepart(DepartmentVO departmentVO);
|
||||
OrgVO createDepart(OrgVO orgVO);
|
||||
|
||||
void updateDepartInfo(Long id, DepartmentVO departmentVO);
|
||||
void updateDepartInfo(Long id, OrgVO orgVO);
|
||||
|
||||
DepartmentVO getDepartById(Long deptId);
|
||||
OrgVO queryDepartById(Long deptId);
|
||||
|
||||
List<DepartmentVO> getCompanyDepartTree(Long companyId);
|
||||
List<OrgVO> getCompanyDepartTree(Long companyId);
|
||||
|
||||
List<DepartmentVO> getCompanyAllDepart(Long companyId);
|
||||
List<OrgVO> getCompanyAllDepart(Long companyId);
|
||||
|
||||
DepartmentVO getDepartTree(Long companyId, Long deptId);
|
||||
OrgVO getDepartTree(Long companyId, Long deptId);
|
||||
|
||||
List<DepartmentVO> getDepartAndChild(Long companyId, Long deptId);
|
||||
List<OrgVO> getDepartAndChild(Long companyId, Long deptId);
|
||||
|
||||
void addDepartUserInfo(AccountVO user, UserDepartRelVO userDepartRelVO);
|
||||
|
||||
@ -74,7 +74,7 @@ public interface IOrgUserService {
|
||||
|
||||
List<OrgUser> findEntitiesByUserId(long userId, BusinessConsts.OrgRole role);
|
||||
|
||||
void userBindCompanyManager(AccountVO accountVO, Long topOrgId);
|
||||
OrgVO userBindCompanyManager(AccountVO accountVO, Long topOrgId);
|
||||
|
||||
List<StudentsUsageStatisticsVO> statisticUsage(UsageQueryVO queryVO);
|
||||
|
||||
|
@ -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.client.org.OrgVO;
|
||||
import club.joylink.rtss.vo.project.ProjectVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -22,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -38,6 +40,10 @@ public class OrgProjectService implements IOrgProjectService {
|
||||
|
||||
@Autowired
|
||||
private OrgDAO orgDAO;
|
||||
@Autowired
|
||||
private IOrgService iOrgService;
|
||||
@Autowired
|
||||
private IOrgUserService iOrgUserService;
|
||||
|
||||
@Override
|
||||
public List<OrgProject> queryOrgProjectListByOrgId(Long orgId) {
|
||||
@ -78,24 +84,9 @@ public class OrgProjectService implements IOrgProjectService {
|
||||
|
||||
@Override
|
||||
public void signInOrg(Long orgId, LoginUserInfoVO loginInfo) {
|
||||
// TODO 验证权限
|
||||
|
||||
Org topOrg = orgDAO.selectByPrimaryKey(orgId);
|
||||
if (topOrg == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||
}
|
||||
// 是否是顶级组织的管理员
|
||||
OrgUserExample example = new OrgUserExample();
|
||||
example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andOrgIdEqualTo(orgId);
|
||||
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
|
||||
OrgProjectVO orgProjectVO = new OrgProjectVO(topOrg);
|
||||
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);
|
||||
OrgVO orgVO = iOrgService.getTopOrg(orgId);
|
||||
boolean orgAdmin = iOrgUserService.isTheRoleInThisOrg(loginInfo.getAccountVO().getId(), orgId, BusinessConsts.OrgRole.Admin);
|
||||
loginInfo.setOrgProjectVO(orgVO, orgAdmin);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -139,6 +130,17 @@ public class OrgProjectService implements IOrgProjectService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgProject> queryOrgProjectListByOrgIds(List<Long> orgIds) {
|
||||
if (CollectionUtils.isEmpty(orgIds)) {
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
OrgProjectExample example = new OrgProjectExample();
|
||||
example.createCriteria().andOrgIdIn(orgIds);
|
||||
return orgProjectDao.selectByExample(example);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数组是否发生变化
|
||||
*/
|
||||
|
@ -4,6 +4,7 @@ import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.dao.OrgScoringRuleDAO;
|
||||
import club.joylink.rtss.dao.OrgScoringRuleRelDAO;
|
||||
import club.joylink.rtss.entity.*;
|
||||
import club.joylink.rtss.entity.org.OrgProject;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.IExamService;
|
||||
import club.joylink.rtss.services.ISysUserService;
|
||||
@ -14,10 +15,10 @@ 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.UserRankStatsVO;
|
||||
import club.joylink.rtss.vo.client.org.DepartmentVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgScoringResultVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgScoringRuleQueryVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgScoringRuleVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.NonNull;
|
||||
@ -68,6 +69,8 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
|
||||
|
||||
@Autowired
|
||||
private IOrgExamService iOrgExamService;
|
||||
@Autowired
|
||||
private IOrgProjectService iOrgProjectService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -233,7 +236,7 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentVO> queryRuleCanApplyTo(Long ruleId, AccountVO user) {
|
||||
public List<OrgVO> queryRuleCanApplyTo(Long ruleId, AccountVO user) {
|
||||
OrgScoringRuleWithBLOBs rule = getRuleEntity(ruleId);
|
||||
OrgScoringRuleVO vo = OrgScoringRuleVO.buildDetails(rule, null);
|
||||
List<Long> lessonIds = vo.getAllLessonIds();
|
||||
@ -251,9 +254,9 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
|
||||
clsIds.addAll(iOrgExamService.findEntities(examIds, user.getId())
|
||||
.stream().map(OrgExam::getOrgId).collect(Collectors.toList()));
|
||||
} else {
|
||||
return DepartmentVO.convert2VOList(iOrgService.findEntitiesByParentId(rule.getOrgId(), null, BusinessConsts.Org.Status.VALID));
|
||||
return OrgVO.convert2VOList(iOrgService.findEntitiesByParentId(rule.getOrgId(), null, BusinessConsts.Org.Status.VALID));
|
||||
}
|
||||
return DepartmentVO.convert2VOList(iOrgService.findEntities(clsIds, BusinessConsts.Org.Status.VALID));
|
||||
return OrgVO.convert2VOList(iOrgService.findEntities(clsIds, BusinessConsts.Org.Status.VALID));
|
||||
}
|
||||
|
||||
private void check4Update(OrgScoringRuleVO orgScoringRuleVO) {
|
||||
@ -306,8 +309,9 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
|
||||
List<Long> userIds = students.stream().map(OrgUser::getUserId).collect(Collectors.toList());
|
||||
List<SysAccount> users = iSysUserService.findEntities(userIds, "id");
|
||||
Org topOrg = iOrgService.getTopOrgEntity(orgScoringRuleVO.getOrgIds().get(0));
|
||||
List<String> projects = iOrgProjectService.queryOrgProjectListByOrgId(topOrg.getId()).stream()
|
||||
.map(OrgProject::getProjectCode).collect(Collectors.toList());
|
||||
List<OrgScoringResultVO> results = users.stream().map(OrgScoringResultVO::new).collect(Collectors.toList());
|
||||
List<String> projects = List.of(topOrg.getProjectCode().split(","));
|
||||
this.score(results, orgScoringRuleVO.getScoringRules(), projects);
|
||||
return results;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import club.joylink.rtss.entity.Org;
|
||||
import club.joylink.rtss.entity.OrgExample;
|
||||
import club.joylink.rtss.entity.OrgUser;
|
||||
import club.joylink.rtss.entity.SysAccount;
|
||||
import club.joylink.rtss.entity.org.OrgProject;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.ISysUserService;
|
||||
import club.joylink.rtss.services.QRCodeManager;
|
||||
@ -14,7 +15,10 @@ import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.ExamDefinitionVO;
|
||||
import club.joylink.rtss.vo.client.Node;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.org.*;
|
||||
import club.joylink.rtss.vo.client.org.NonTopOrgCreateVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgQueryVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgUserVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.NonNull;
|
||||
@ -48,14 +52,14 @@ public class OrgService implements IOrgService {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CompanyVO createTopOrg(CompanyVO companyVO, AccountVO user) {
|
||||
public OrgVO createTopOrg(OrgVO orgVO, AccountVO user) {
|
||||
// /* 检查 */
|
||||
// if (!CollectionUtils.isEmpty(companyVO.getProjectCodes())) {
|
||||
// confirmProjectCodesNotRepeat(null, companyVO.getProjectCodes());
|
||||
// if (!CollectionUtils.isEmpty(orgVO.getProjectCodes())) {
|
||||
// confirmProjectCodesNotRepeat(null, orgVO.getProjectCodes());
|
||||
// }
|
||||
confirmNameUnique(null, companyVO.getName());
|
||||
confirmNameUnique(null, orgVO.getName());
|
||||
/* 处理 */
|
||||
Org entity = companyVO.toDB();
|
||||
Org entity = orgVO.toDB();
|
||||
entity.setId(null);
|
||||
entity.setCreatorId(user.getId());
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
@ -64,8 +68,8 @@ public class OrgService implements IOrgService {
|
||||
entity.setRootId(entity.getId());
|
||||
orgDAO.updateByPrimaryKey(entity);
|
||||
// 20220929 增加
|
||||
orgProjectService.save(entity.getId(), companyVO.getProjectCodes(), user);
|
||||
return new CompanyVO(entity);
|
||||
orgProjectService.save(entity.getId(), orgVO.getProjectCodes(), user);
|
||||
return new OrgVO(entity, orgVO.getProjectCodes());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,15 +87,17 @@ public class OrgService implements IOrgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyVO> queryAllTopOrg() {
|
||||
public List<OrgVO> queryAllTopOrg() {
|
||||
OrgExample example = new OrgExample();
|
||||
example.createCriteria().andParentIdIsNull();
|
||||
List<Org> list = this.orgDAO.selectByExample(example);
|
||||
return CompanyVO.convert2VOList(list);
|
||||
List<Org> orgs = this.orgDAO.selectByExample(example);
|
||||
List<Long> orgIds = orgs.stream().map(Org::getId).collect(Collectors.toList());
|
||||
List<OrgProject> orgProjects = orgProjectService.queryOrgProjectListByOrgIds(orgIds);
|
||||
return OrgVO.convert2VOList(orgs, orgProjects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageVO<CompanyVO> pagedQueryAllTopOrg(OrgQueryVO queryVO) {
|
||||
public PageVO<OrgVO> pagedQueryAllTopOrg(OrgQueryVO queryVO) {
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
OrgExample example = new OrgExample();
|
||||
OrgExample.Criteria criteria = example.createCriteria();
|
||||
@ -100,7 +106,9 @@ public class OrgService implements IOrgService {
|
||||
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
|
||||
}
|
||||
Page<Org> page = (Page<Org>) orgDAO.selectByExample(example);
|
||||
List<CompanyVO> voList = CompanyVO.convert2VOList(page.getResult());
|
||||
List<Long> orgIds = page.getResult().stream().map(Org::getId).collect(Collectors.toList());
|
||||
List<OrgProject> orgProjects = orgProjectService.queryOrgProjectListByOrgIds(orgIds);
|
||||
List<OrgVO> voList = OrgVO.convert2VOList(page.getResult(), orgProjects);
|
||||
return PageVO.convert(page, voList);
|
||||
}
|
||||
|
||||
@ -152,23 +160,25 @@ public class OrgService implements IOrgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyVO updateOrg(Long id, CompanyVO companyVO, AccountVO user) {
|
||||
public OrgVO updateOrg(Long id, OrgVO orgVO, AccountVO user) {
|
||||
//校验
|
||||
Org org = getEntity(id);
|
||||
if (!CollectionUtils.isEmpty(companyVO.getProjectCodes())) {
|
||||
if (!CollectionUtils.isEmpty(orgVO.getProjectCodes())) {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(isTopOrg(org), "非顶级组织不能修改关联项目");
|
||||
// confirmProjectCodesNotRepeat(org.getId(), companyVO.getProjectCodes());
|
||||
// confirmProjectCodesNotRepeat(org.getId(), orgVO.getProjectCodes());
|
||||
// 20220929 增加
|
||||
orgProjectService.update(id, companyVO.getProjectCodes(), user);
|
||||
orgProjectService.update(id, orgVO.getProjectCodes(), user);
|
||||
}
|
||||
confirmNameUnique(id, companyVO.getName());
|
||||
confirmNameUnique(id, orgVO.getName());
|
||||
//更新
|
||||
org.setName(companyVO.getName());
|
||||
org.setProjectCode(companyVO.getDBProjectCode());
|
||||
org.setName(orgVO.getName());
|
||||
// org.setProjectCode(orgVO.getDBProjectCode());
|
||||
org.setUpdateId(user.getId());
|
||||
org.setUpdateTime(LocalDateTime.now());
|
||||
this.orgDAO.updateByPrimaryKeySelective(org);
|
||||
return new CompanyVO(org);
|
||||
List<String> projects = orgProjectService.queryOrgProjectListByOrgId(org.getId()).stream()
|
||||
.map(OrgProject::getProjectCode).collect(Collectors.toList());
|
||||
return new OrgVO(org, projects);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -194,21 +204,19 @@ public class OrgService implements IOrgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageVO<DepartmentVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
|
||||
public PageVO<OrgVO> pagedQueryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
|
||||
OrgExample example = new OrgExample();
|
||||
OrgExample.Criteria criteria = example.createCriteria().andParentIdEqualTo(loginInfo.getTopOrgId())
|
||||
.andStatusEqualTo(BusinessConsts.Org.Status.VALID);
|
||||
if (queryVO != null) {
|
||||
if (StringUtils.hasText(queryVO.getName())) {
|
||||
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
|
||||
}
|
||||
if (StringUtils.hasText(queryVO.getCreatorName())) {
|
||||
List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(AccountVO::getId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(creatorIds)) {
|
||||
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
|
||||
} else {
|
||||
criteria.andCreatorIdIn(creatorIds);
|
||||
}
|
||||
if (StringUtils.hasText(queryVO.getName())) {
|
||||
criteria.andNameLike(String.format("%%%s%%", queryVO.getName()));
|
||||
}
|
||||
if (StringUtils.hasText(queryVO.getCreatorName())) {
|
||||
List<Long> creatorIds = iSysUserService.findUserByName(queryVO.getCreatorName()).stream().map(AccountVO::getId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(creatorIds)) {
|
||||
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), 0, new ArrayList<>());
|
||||
} else {
|
||||
criteria.andCreatorIdIn(creatorIds);
|
||||
}
|
||||
}
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
@ -216,15 +224,15 @@ public class OrgService implements IOrgService {
|
||||
List<Long> creatorIds = page.stream().map(Org::getCreatorId).collect(Collectors.toList());
|
||||
Map<Long, SysAccount> creatorMap = iSysUserService.findEntities(creatorIds, null).stream()
|
||||
.collect(Collectors.toMap(SysAccount::getId, Function.identity()));
|
||||
List<DepartmentVO> list = page.getResult().stream().map(entity -> {
|
||||
List<OrgVO> list = page.getResult().stream().map(entity -> {
|
||||
int numberOfPeople = iOrgUserService.getQuantities(entity.getId(), BusinessConsts.OrgRole.Student);
|
||||
return new DepartmentVO(entity, numberOfPeople, creatorMap.get(entity.getCreatorId()));
|
||||
return new OrgVO(entity, null, numberOfPeople, creatorMap.get(entity.getCreatorId()));
|
||||
}).collect(Collectors.toList());
|
||||
return PageVO.convert(page, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
|
||||
public List<OrgVO> queryCls(OrgQueryVO queryVO, LoginUserInfoVO loginInfo) {
|
||||
OrgExample example = new OrgExample();
|
||||
OrgExample.Criteria criteria = example.createCriteria()
|
||||
.andParentIdEqualTo(loginInfo.getTopOrgId())
|
||||
@ -235,7 +243,7 @@ public class OrgService implements IOrgService {
|
||||
}
|
||||
}
|
||||
List<Org> clsList = orgDAO.selectByExample(example);
|
||||
return clsList.stream().map(DepartmentVO::new).collect(Collectors.toList());
|
||||
return clsList.stream().map(OrgVO::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -263,13 +271,13 @@ public class OrgService implements IOrgService {
|
||||
@Override
|
||||
public Node<Object> adminQueryOrgTree(Long orgId) {
|
||||
/* 先筛选组织 */
|
||||
Org org = getEntity(orgId);
|
||||
Map<Long, List<Org>> groupByParentIdOrg = findEntitiesByRootId(org.getRootId(), null, BusinessConsts.Org.Status.VALID)
|
||||
.stream().filter(o -> o.getParentId() != null).collect(Collectors.groupingBy(Org::getParentId));
|
||||
Node<Object> root = new Node<>(new DepartmentVO(org), Node.Type.ORG);
|
||||
OrgVO orgVO = get(orgId);
|
||||
Map<Long, List<Org>> groupByParentIdOrg = findEntitiesByRootId(orgVO.getRootId(), null, BusinessConsts.Org.Status.VALID)
|
||||
.stream().filter(o -> !isTopOrg(o)).collect(Collectors.groupingBy(Org::getParentId));
|
||||
Node<Object> root = new Node<>(orgVO, Node.Type.ORG);
|
||||
Map<Long, Node<Object>> all_orgId_node_map = new HashMap<>(); //所有的组织和对应的节点
|
||||
Map<Long, Node<Object>> orgId_node_map = new HashMap<>();
|
||||
orgId_node_map.put(org.getId(), root);
|
||||
orgId_node_map.put(orgVO.getId(), root);
|
||||
while (!orgId_node_map.isEmpty()) {
|
||||
all_orgId_node_map.putAll(orgId_node_map);
|
||||
Map<Long, Node<Object>> newMap = new HashMap<>();
|
||||
@ -277,7 +285,7 @@ public class OrgService implements IOrgService {
|
||||
List<Org> childOrgList = groupByParentIdOrg.get(k);
|
||||
if (!CollectionUtils.isEmpty(childOrgList)) {
|
||||
List<Node<Object>> children = childOrgList.stream().map(o -> {
|
||||
Node<Object> node = new Node<>(new DepartmentVO(o), Node.Type.ORG);
|
||||
Node<Object> node = new Node<>(new OrgVO(o), Node.Type.ORG);
|
||||
newMap.put(o.getId(), node);
|
||||
return node;
|
||||
}).collect(Collectors.toList());
|
||||
@ -309,9 +317,10 @@ public class OrgService implements IOrgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyVO get(Long id) {
|
||||
Org entity = getEntity(id);
|
||||
return new CompanyVO(entity);
|
||||
public OrgVO get(Long id) {
|
||||
OrgVO vo = query(id);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(vo, String.format("[id:%s]的组织不存在", id));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -381,9 +390,35 @@ public class OrgService implements IOrgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentVO> listQueryCls(long topOrgId) {
|
||||
public List<OrgVO> listQueryCls(long topOrgId) {
|
||||
List<Org> clsList = findClsByTopOrgId(topOrgId);
|
||||
return DepartmentVO.convert2VOList(clsList);
|
||||
return OrgVO.convert2VOList(clsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgVO query(Long id) {
|
||||
Org entity = findEntity(id);
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
List<String> projects;
|
||||
if (isTopOrg(entity)) {
|
||||
projects = orgProjectService.queryOrgProjectListByOrgId(entity.getId()).stream()
|
||||
.map(OrgProject::getProjectCode).collect(Collectors.toList());
|
||||
} else {
|
||||
projects = null;
|
||||
}
|
||||
return new OrgVO(entity, projects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrgVO getTopOrg(long topOrgId) {
|
||||
Org org = getEntity(topOrgId);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(isTopOrg(org),
|
||||
String.format("[id:%s]的组织不是顶级组织", topOrgId));
|
||||
List<String> projects = orgProjectService.queryOrgProjectListByOrgId(topOrgId)
|
||||
.stream().map(OrgProject::getProjectCode).collect(Collectors.toList());
|
||||
return new OrgVO(org, projects);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -420,7 +455,7 @@ public class OrgService implements IOrgService {
|
||||
}
|
||||
|
||||
private boolean isTopOrg(long orgId) {
|
||||
return getEntity(orgId).getParentId() == null;
|
||||
return isTopOrg(getEntity(orgId));
|
||||
}
|
||||
|
||||
private boolean isTopOrg(Org org) {
|
||||
|
@ -66,7 +66,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
|
||||
|
||||
@Override
|
||||
public CompanyVO userScanCodeBindCompanyManager(Long userId, Long companyId) {
|
||||
public OrgVO userScanCodeBindCompanyManager(Long userId, Long companyId) {
|
||||
return iSysUserService.userScanCodeBindCompanyManager(userId, companyId);
|
||||
}
|
||||
|
||||
@ -76,23 +76,22 @@ public class OrgUserService implements IOrgUserService {
|
||||
* 增加部门
|
||||
*/
|
||||
@Override
|
||||
public DepartmentVO createDepart(DepartmentVO departmentVO) {
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(departmentIsExist(departmentVO), "同级部门信息重复");
|
||||
Org entity = departmentVO.toDB();
|
||||
public OrgVO createDepart(OrgVO orgVO) {
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(departmentIsExist(orgVO), "同级部门信息重复");
|
||||
Org entity = orgVO.toDB();
|
||||
orgDAO.insert(entity);
|
||||
departmentVO.setId(entity.getId());
|
||||
return departmentVO;
|
||||
orgVO.setId(entity.getId());
|
||||
return orgVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改部门
|
||||
*/
|
||||
@Override
|
||||
public void updateDepartInfo(Long deptId, DepartmentVO departmentVO) {
|
||||
Org entity = departmentVO.toDB();
|
||||
public void updateDepartInfo(Long deptId, OrgVO orgVO) {
|
||||
Org entity = orgVO.toDB();
|
||||
entity.setId(deptId);
|
||||
entity.setRootId(null);
|
||||
entity.setProjectCode(null);
|
||||
orgDAO.updateByPrimaryKeySelective(entity);
|
||||
}
|
||||
|
||||
@ -102,12 +101,8 @@ public class OrgUserService implements IOrgUserService {
|
||||
* @param deptId
|
||||
*/
|
||||
@Override
|
||||
public DepartmentVO getDepartById(Long deptId) {
|
||||
Org entity = orgDAO.selectByPrimaryKey(deptId);
|
||||
if (Objects.isNull(entity)) {
|
||||
return null;
|
||||
}
|
||||
return new DepartmentVO(entity);
|
||||
public OrgVO queryDepartById(Long deptId) {
|
||||
return iOrgService.query(deptId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,54 +111,54 @@ public class OrgUserService implements IOrgUserService {
|
||||
* @param companyId
|
||||
*/
|
||||
@Override
|
||||
public List<DepartmentVO> getCompanyDepartTree(Long companyId) {
|
||||
public List<OrgVO> getCompanyDepartTree(Long companyId) {
|
||||
OrgExample example = new OrgExample();
|
||||
example.createCriteria().andRootIdEqualTo(companyId);
|
||||
List<Org> orgList = orgDAO.selectByExample(example);
|
||||
return DepartmentVO.buildDeptTree(DepartmentVO.convert2VOList(orgList));
|
||||
return OrgVO.buildDeptTree(OrgVO.convert2VOList(orgList));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentVO> getCompanyAllDepart(Long companyId) {
|
||||
public List<OrgVO> getCompanyAllDepart(Long companyId) {
|
||||
OrgExample example = new OrgExample();
|
||||
example.createCriteria().andRootIdEqualTo(companyId).andParentIdIsNotNull();
|
||||
List<Org> companyDepartments = orgDAO.selectByExample(example);
|
||||
return DepartmentVO.convert2VOList(companyDepartments);
|
||||
return OrgVO.convert2VOList(companyDepartments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DepartmentVO getDepartTree(Long companyId, Long deptId) {
|
||||
public OrgVO getDepartTree(Long companyId, Long deptId) {
|
||||
Org companyDepartment = orgDAO.selectByPrimaryKey(deptId);
|
||||
OrgExample example = new OrgExample();
|
||||
example.createCriteria().andRootIdEqualTo(companyId).andParentIdIsNotNull();
|
||||
List<Org> companyDepartments = orgDAO.selectByExample(example);
|
||||
List<DepartmentVO> childDept = DepartmentVO.getChildDept(deptId, DepartmentVO.convert2VOList(companyDepartments));
|
||||
DepartmentVO departmentVO = new DepartmentVO(companyDepartment);
|
||||
departmentVO.setChildDept(childDept);
|
||||
return departmentVO;
|
||||
List<OrgVO> childDept = OrgVO.getChildDept(deptId, OrgVO.convert2VOList(companyDepartments));
|
||||
OrgVO orgVO = new OrgVO(companyDepartment);
|
||||
orgVO.setChildDept(childDept);
|
||||
return orgVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DepartmentVO> getDepartAndChild(Long companyId, Long deptId) {
|
||||
public List<OrgVO> getDepartAndChild(Long companyId, Long deptId) {
|
||||
var example = new OrgExample();
|
||||
example.createCriteria().andRootIdEqualTo(companyId).andParentIdIsNotNull();
|
||||
var companyDepartments = orgDAO.selectByExample(example);
|
||||
var childDept = DepartmentVO.getChildDeptList(deptId, DepartmentVO.convert2VOList(companyDepartments));
|
||||
var childDept = OrgVO.getChildDeptList(deptId, OrgVO.convert2VOList(companyDepartments));
|
||||
var companyDepartment = orgDAO.selectByPrimaryKey(deptId);
|
||||
childDept.add(new DepartmentVO(companyDepartment));
|
||||
childDept.add(new OrgVO(companyDepartment));
|
||||
return childDept;
|
||||
}
|
||||
|
||||
|
||||
private boolean departmentIsExist(DepartmentVO departmentVO) {
|
||||
private boolean departmentIsExist(OrgVO orgVO) {
|
||||
var example = new OrgExample();
|
||||
OrgExample.Criteria criteria = example.createCriteria()
|
||||
.andRootIdEqualTo(departmentVO.getRootId())
|
||||
.andNameEqualTo(departmentVO.getName());
|
||||
if (Objects.isNull(departmentVO.getParentId())) {
|
||||
.andRootIdEqualTo(orgVO.getRootId())
|
||||
.andNameEqualTo(orgVO.getName());
|
||||
if (Objects.isNull(orgVO.getParentId())) {
|
||||
criteria.andParentIdIsNull();
|
||||
} else {
|
||||
criteria.andParentIdEqualTo(departmentVO.getParentId());
|
||||
criteria.andParentIdEqualTo(orgVO.getParentId());
|
||||
}
|
||||
|
||||
return orgDAO.countByExample(example) != 0;
|
||||
@ -373,9 +368,9 @@ public class OrgUserService implements IOrgUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userBindCompanyManager(AccountVO accountVO, Long topOrgId) {
|
||||
Org topOrg = iOrgService.getEntity(topOrgId);
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNull(topOrg.getParentId(), "所选组织不是顶级组织");
|
||||
public OrgVO userBindCompanyManager(AccountVO accountVO, Long topOrgId) {
|
||||
OrgVO topOrgVO = iOrgService.get(topOrgId);
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNull(topOrgVO.getParentId(), "所选组织不是顶级组织");
|
||||
BusinessExceptionAssertEnum.OPERATION_REPEAT.assertNotTrue(isTheRoleInThisOrg(accountVO.getId(), topOrgId, BusinessConsts.OrgRole.Admin),
|
||||
"已经是所选组织管理员");
|
||||
/* 如果是其它组织的管理员,删除关系 */
|
||||
@ -388,7 +383,9 @@ public class OrgUserService implements IOrgUserService {
|
||||
}
|
||||
/* 建立新关系 */
|
||||
create(topOrgId, accountVO.getId(), BusinessConsts.OrgRole.Admin);
|
||||
accountVO.setOrgInfo(topOrg, true);
|
||||
return topOrgVO;
|
||||
|
||||
// accountVO.setOrgInfo(topOrg, true); 现在登录信息里的组织信息应该是和登录的项目相关,所以不需要这个逻辑
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,7 +4,7 @@ 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.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import club.joylink.rtss.vo.project.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -62,12 +62,12 @@ public interface ProjectService {
|
||||
/**
|
||||
* 根据项目ID获取与项目关联的所有组织信息
|
||||
*/
|
||||
List<CompanyVO> projectOrgList(Long id);
|
||||
List<OrgVO> projectOrgList(Long id);
|
||||
|
||||
/**
|
||||
* 快速创建默认组织
|
||||
*/
|
||||
ProjectInfoVO quickCreateDefaultOrg(Long id, CompanyVO companyVO, AccountVO user);
|
||||
ProjectInfoVO quickCreateDefaultOrg(Long id, OrgVO companyVO, AccountVO user);
|
||||
|
||||
/**
|
||||
* 前端设置信息分页
|
||||
|
@ -18,7 +18,7 @@ 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.client.org.CompanyVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import club.joylink.rtss.vo.project.*;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@ -166,7 +166,7 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyVO> projectOrgList(Long id) {
|
||||
public List<OrgVO> projectOrgList(Long id) {
|
||||
Project project = projectDAO.selectByPrimaryKey(id);
|
||||
if (project == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在");
|
||||
@ -175,7 +175,7 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
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 orgList.stream().map(OrgVO::simpleInfoVO).collect(Collectors.toList());
|
||||
}
|
||||
return List.of();
|
||||
}
|
||||
@ -183,7 +183,7 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(cacheNames = "project", allEntries = true)
|
||||
public ProjectInfoVO quickCreateDefaultOrg(Long id, CompanyVO companyVO, AccountVO user) {
|
||||
public ProjectInfoVO quickCreateDefaultOrg(Long id, OrgVO companyVO, AccountVO user) {
|
||||
Project project = projectDAO.selectByPrimaryKey(id);
|
||||
if (project == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "项目不存在");
|
||||
@ -194,7 +194,7 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}
|
||||
// 保存默认组织
|
||||
companyVO.setProjectCodes(List.of(project.getCode()));
|
||||
CompanyVO resultCompany = orgService.createTopOrg(companyVO, user);
|
||||
OrgVO resultCompany = orgService.createTopOrg(companyVO, user);
|
||||
// 修改项目信息
|
||||
setProjectDefaultOrg(id, resultCompany.getId());
|
||||
ProjectInfoVO projectVO = new ProjectInfoVO(project);
|
||||
@ -395,4 +395,4 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
}).collect(Collectors.toList());
|
||||
return projectVOList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package club.joylink.rtss.vo;
|
||||
import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.entity.Org;
|
||||
import club.joylink.rtss.entity.SysAccount;
|
||||
import club.joylink.rtss.vo.client.org.OrgProjectVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
@ -17,7 +17,6 @@ import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -49,7 +48,7 @@ public class AccountVO implements Serializable {
|
||||
public static final String Type_3 = "3"; // 第三方企业子账户
|
||||
|
||||
/**
|
||||
* 用户所属的顶级组织
|
||||
* 账号所属的组织(是账号表里的字段)
|
||||
*/
|
||||
private Long orgId;
|
||||
|
||||
@ -298,13 +297,11 @@ public class AccountVO implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void setOrgInfo(Org org, Boolean companyAdmin) {
|
||||
public void setOrgInfo(Org org, Boolean companyAdmin, List<String> projectCodes) {
|
||||
this.companyId = org.getId();
|
||||
this.companyName = org.getName();
|
||||
this.companyAdmin = companyAdmin;
|
||||
if (StringUtils.hasText(org.getProjectCode())) {
|
||||
this.projectCodes = Arrays.asList(org.getProjectCode().split(","));
|
||||
}
|
||||
this.projectCodes = projectCodes;
|
||||
}
|
||||
|
||||
public void copyOrgInfo(AccountVO accountVO) {
|
||||
@ -321,13 +318,12 @@ public class AccountVO implements Serializable {
|
||||
return Type_3.equalsIgnoreCase(this.type) && StringUtils.hasText(this.parentAccount);
|
||||
}
|
||||
|
||||
public void setOrgProjectVO(OrgProjectVO orgProjectVO) {
|
||||
if (orgProjectVO != null) {
|
||||
this.companyId = orgProjectVO.getOrgId();
|
||||
this.companyName = orgProjectVO.getName();
|
||||
this.companyAdmin = !CollectionUtils.isEmpty(orgProjectVO.getRole())
|
||||
&& orgProjectVO.getRole().contains(BusinessConsts.OrgRole.Admin.name());
|
||||
this.projectCodes = Arrays.asList(orgProjectVO.getProjectCode().split(","));
|
||||
public void setOrgProjectVO(OrgVO orgVO, boolean orgAdmin) {
|
||||
if (orgVO != null) {
|
||||
this.companyId = orgVO.getId();
|
||||
this.companyName = orgVO.getName();
|
||||
this.companyAdmin = orgAdmin;
|
||||
this.projectCodes = orgVO.getProjectCodes();
|
||||
} else {
|
||||
this.companyId = 0L;
|
||||
this.companyName = null;
|
||||
|
@ -4,7 +4,7 @@ import club.joylink.rtss.constants.Client;
|
||||
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.org.OrgProjectVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||
import club.joylink.rtss.vo.project.ProjectVO;
|
||||
import lombok.Getter;
|
||||
@ -50,9 +50,6 @@ public class LoginUserInfoVO {
|
||||
private LocalDateTime preLogoutTime;
|
||||
private LocalDateTime lastQueryTime; // 最后使用时间
|
||||
|
||||
// 20220929 增加
|
||||
private OrgProjectVO orgProjectVO;
|
||||
|
||||
public LoginUserInfoVO(AccountVO accountVO, Client client, String project, ProjectDeviceVO deviceVO) {
|
||||
this.accountVO = accountVO;
|
||||
this.client = client;
|
||||
@ -148,14 +145,10 @@ public class LoginUserInfoVO {
|
||||
* 获取顶级组织Id
|
||||
*/
|
||||
public Long getTopOrgId() {
|
||||
if (orgProjectVO == null) {
|
||||
return null;
|
||||
}
|
||||
return orgProjectVO.getTopOrgId();
|
||||
return getAccountVO().getCompanyId();
|
||||
}
|
||||
|
||||
public void setOrgProjectVO(OrgProjectVO orgProjectVO) {
|
||||
this.orgProjectVO = orgProjectVO;
|
||||
this.accountVO.setOrgProjectVO(orgProjectVO);
|
||||
public void setOrgProjectVO(OrgVO orgVO, boolean orgAdmin) {
|
||||
this.accountVO.setOrgProjectVO(orgVO, orgAdmin);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package club.joylink.rtss.vo.client;
|
||||
|
||||
import club.joylink.rtss.entity.ExamDefinition;
|
||||
import club.joylink.rtss.entity.SysAccount;
|
||||
import club.joylink.rtss.vo.client.org.DepartmentVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgVO;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
@ -135,7 +135,7 @@ public class ExamDefinitionVO {
|
||||
private Boolean system;
|
||||
|
||||
/**关联班级列表*/
|
||||
private List<DepartmentVO> classes;
|
||||
private List<OrgVO> classes;
|
||||
|
||||
private List<Long> clsIds;
|
||||
|
||||
|
@ -1,75 +0,0 @@
|
||||
package club.joylink.rtss.vo.client.org;
|
||||
|
||||
import club.joylink.rtss.entity.Org;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class CompanyVO {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String code;
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@NotBlank(message = "公司名称不能为空")
|
||||
private String name;
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDBProjectCode() {
|
||||
if (!CollectionUtils.isEmpty(projectCodes)) {
|
||||
return String.join(",", projectCodes);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,12 +17,9 @@ public class OrgProjectVO {
|
||||
|
||||
private List<String> role;
|
||||
|
||||
private String projectCode;
|
||||
|
||||
public OrgProjectVO(Org org) {
|
||||
this.orgId = org.getId();
|
||||
this.name = org.getName();
|
||||
this.topOrgId = org.getRootId();
|
||||
this.projectCode = org.getProjectCode();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.rtss.vo.client.org;
|
||||
|
||||
import club.joylink.rtss.entity.Org;
|
||||
import club.joylink.rtss.entity.SysAccount;
|
||||
import club.joylink.rtss.entity.org.OrgProject;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
@ -9,20 +10,19 @@ import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class DepartmentVO {
|
||||
public class OrgVO {
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@ -49,7 +49,7 @@ public class DepartmentVO {
|
||||
*/
|
||||
private Integer numberOfPeople;
|
||||
|
||||
private List<DepartmentVO> childDept;
|
||||
private List<OrgVO> childDept;
|
||||
|
||||
private Long creatorId;
|
||||
|
||||
@ -57,26 +57,28 @@ public class DepartmentVO {
|
||||
|
||||
private String creatorNickName;
|
||||
|
||||
public DepartmentVO(Org entity) {
|
||||
public OrgVO(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(","));
|
||||
}
|
||||
this.parentId = entity.getParentId();
|
||||
this.rootId = entity.getRootId();
|
||||
this.creatorId = entity.getCreatorId();
|
||||
this.createTime = entity.getCreateTime();
|
||||
}
|
||||
|
||||
public DepartmentVO(Org entity, Integer numberOfPeople) {
|
||||
public OrgVO(Org entity, List<String> projectCodes) {
|
||||
this(entity);
|
||||
this.projectCodes = projectCodes;
|
||||
}
|
||||
|
||||
public OrgVO(Org entity, List<String> projectCodes, Integer numberOfPeople) {
|
||||
this(entity, projectCodes);
|
||||
this.numberOfPeople = numberOfPeople;
|
||||
}
|
||||
|
||||
public DepartmentVO(Org entity, Integer numberOfPeople, SysAccount creator) {
|
||||
this(entity, numberOfPeople);
|
||||
public OrgVO(Org entity, List<String> projectCodes, Integer numberOfPeople, SysAccount creator) {
|
||||
this(entity, projectCodes, numberOfPeople);
|
||||
if (creator != null) {
|
||||
this.creatorId = creator.getId();
|
||||
this.creatorName = creator.getName();
|
||||
@ -84,11 +86,24 @@ public class DepartmentVO {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<DepartmentVO> convert2VOList(List<Org> dataList) {
|
||||
if (CollectionUtils.isEmpty(dataList)) {
|
||||
public static List<OrgVO> convert2VOList(List<Org> orgs) {
|
||||
if (CollectionUtils.isEmpty(orgs)) {
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
return dataList.stream().map(DepartmentVO::new).collect(Collectors.toList());
|
||||
return orgs.stream().map(OrgVO::new).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
public static List<OrgVO> convert2VOList(List<Org> orgs, List<OrgProject> orgProjects) {
|
||||
if (CollectionUtils.isEmpty(orgs)) {
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
Map<Long, List<String>> orgId_projects_map = orgProjects.stream()
|
||||
.collect(Collectors.groupingBy(OrgProject::getOrgId,
|
||||
Collectors.mapping(OrgProject::getProjectCode, Collectors.toList())));
|
||||
return orgs.stream()
|
||||
.map(org -> new OrgVO(org, orgId_projects_map.get(org.getId())))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,12 +113,11 @@ public class DepartmentVO {
|
||||
entity.setName(this.name);
|
||||
entity.setParentId(this.parentId);
|
||||
entity.setRootId(this.rootId);
|
||||
entity.setProjectCode(String.join(",", this.projectCodes));
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static List<DepartmentVO> buildDeptTree(List<DepartmentVO> voList) {
|
||||
List<DepartmentVO> rootDeparts = new ArrayList<>();
|
||||
public static List<OrgVO> buildDeptTree(List<OrgVO> voList) {
|
||||
List<OrgVO> rootDeparts = new ArrayList<>();
|
||||
voList.forEach(d -> {
|
||||
if (Objects.isNull(d.getParentId())) {
|
||||
d.setChildDept(getChildDept(d.getId(), voList));
|
||||
@ -113,8 +127,8 @@ public class DepartmentVO {
|
||||
return rootDeparts;
|
||||
}
|
||||
|
||||
public static List<DepartmentVO> getChildDept(Long parentId, List<DepartmentVO> list) {
|
||||
List<DepartmentVO> child = new ArrayList<>();
|
||||
public static List<OrgVO> getChildDept(Long parentId, List<OrgVO> list) {
|
||||
List<OrgVO> child = new ArrayList<>();
|
||||
list.forEach(c -> {
|
||||
if (parentId == c.getParentId()) {
|
||||
child.add(c);
|
||||
@ -129,8 +143,8 @@ public class DepartmentVO {
|
||||
return child;
|
||||
}
|
||||
|
||||
public static List<DepartmentVO> getChildDeptList(Long parentId, List<DepartmentVO> list) {
|
||||
List<DepartmentVO> child = new ArrayList<>();
|
||||
public static List<OrgVO> getChildDeptList(Long parentId, List<OrgVO> list) {
|
||||
List<OrgVO> child = new ArrayList<>();
|
||||
list.forEach(c -> {
|
||||
if (parentId == c.getParentId()) {
|
||||
child.add(c);
|
||||
@ -143,4 +157,11 @@ public class DepartmentVO {
|
||||
});
|
||||
return child;
|
||||
}
|
||||
|
||||
public static OrgVO simpleInfoVO(Org org) {
|
||||
OrgVO orgVO = new OrgVO();
|
||||
orgVO.setId(org.getId());
|
||||
orgVO.setName(org.getName());
|
||||
return orgVO;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user