|
|
@@ -119,6 +119,8 @@ public class OrganizationManagerServiceImpl extends SuperService {
|
|
|
|
|
|
@Autowired
|
|
|
OrganizationServiceImpl organizationServiceImpl;
|
|
|
+ @Autowired
|
|
|
+ private ProjectBindOrgServiceImpl projectBindOrgServiceImpl;
|
|
|
|
|
|
/**
|
|
|
* 保存项目 下的机构信息
|
|
|
@@ -133,35 +135,25 @@ public class OrganizationManagerServiceImpl extends SuperService {
|
|
|
|| authType == AuthType.Project) {
|
|
|
return ResultContent.buildFail("authType 类型错误");
|
|
|
}
|
|
|
- // 项目信息
|
|
|
- ResultContent<Organization> checkProjectContent = checkProject(param.getProjectOid());
|
|
|
- if (checkProjectContent.isFailed()) {
|
|
|
- return ResultContent.buildFail(checkProjectContent.getMsg());
|
|
|
- }
|
|
|
- Organization projectInfo = checkProjectContent.getContent();
|
|
|
-
|
|
|
- String code = param.getCode();
|
|
|
- if (StringUtils.isEmpty(code)) {
|
|
|
- code = NextNoUtil.getNextNo(authType.getCode().toUpperCase());
|
|
|
- param.setCode(code);
|
|
|
- }
|
|
|
String name = param.getName();
|
|
|
|
|
|
Organization organization = null;
|
|
|
- Organization nameOrganization = organizationDao.findTopByNameAndAuthType(name, authType);
|
|
|
+ Organization orgCodeOrganization = organizationDao.findTopByOrgCode(param.getOrgCode());
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
organization = organizationDao.findTopById(param.getId());
|
|
|
if (ObjectUtils.isEmpty(organization)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
|
|
|
}
|
|
|
- if (ObjectUtils.isNotEmpty(nameOrganization) && !nameOrganization.getId().equals(organization.getId())) {
|
|
|
- return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getName()));
|
|
|
+ if (ObjectUtils.isNotEmpty(orgCodeOrganization) && !orgCodeOrganization.getId().equals(organization.getId())) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getOrgCode()));
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, organization, "code");
|
|
|
initUpdateEntity(organization);
|
|
|
+ organizationDao.save(organization);
|
|
|
} else {
|
|
|
- if (ObjectUtils.isNotEmpty(nameOrganization)) {
|
|
|
- return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getName()));
|
|
|
+ if (ObjectUtils.isNotEmpty(orgCodeOrganization)) {
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getOrgCode()));
|
|
|
}
|
|
|
// 初始权限中心的机构信息
|
|
|
ResultContent<String> initOrgContent = organizationServiceImpl.authCenterAddOrgInfo(name, authType, param.getRemark());
|
|
|
@@ -169,15 +161,23 @@ public class OrganizationManagerServiceImpl extends SuperService {
|
|
|
return ResultContent.buildFail(initOrgContent.getMsg());
|
|
|
}
|
|
|
String oid = initOrgContent.getContent();
|
|
|
+ if (StringUtils.isEmpty(param.getCode())) {
|
|
|
+ param.setCode(NextNoUtil.getNextNo(authType.getCode().toUpperCase()));
|
|
|
+ }
|
|
|
+ String code = param.getCode();
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
+ code = NextNoUtil.getNextNo(authType.getCode().toUpperCase());
|
|
|
+ param.setCode(code);
|
|
|
+ }
|
|
|
+
|
|
|
organization = new Organization();
|
|
|
BeanUtils.copyProperties(param, organization);
|
|
|
initEntityNoCheckOid(organization);
|
|
|
organization.setIsOrg(Boolean.TRUE);
|
|
|
|
|
|
+ // 机构关联的 权限中心的oid
|
|
|
organization.setOid(oid);
|
|
|
- organization.setProjectOid(projectInfo.getOid());
|
|
|
- organization.setAboutOid(projectInfo.getOid());
|
|
|
- organization.setAboutAuthType(projectInfo.getAuthType());
|
|
|
+
|
|
|
organizationDao.save(organization);
|
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
|
@@ -191,7 +191,6 @@ public class OrganizationManagerServiceImpl extends SuperService {
|
|
|
* @return
|
|
|
*/
|
|
|
public ResultContent<Page<OrganizationSimpleModel>> orgPage(OrganizationSearchParam param, Pageable pageable) {
|
|
|
- initSearchParam(param);
|
|
|
param.setIsOrg(Boolean.TRUE);
|
|
|
Page<Organization> page = organizationDao.page(pageable, param);
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toSimpleModel));
|
|
|
@@ -227,7 +226,11 @@ public class OrganizationManagerServiceImpl extends SuperService {
|
|
|
return ResultContent.buildFail("当前不属于结构类型,不能删除");
|
|
|
}
|
|
|
|
|
|
- //1. 判断是否可以删除
|
|
|
+ //1. 判断机构是否可以删除
|
|
|
+ long number = projectBindOrgServiceImpl.countOrgBindNumber(oid);
|
|
|
+ if (number > 0) {
|
|
|
+ return ResultContent.buildFail(String.format("机构已绑定项目,不能删除"));
|
|
|
+ }
|
|
|
|
|
|
//2. 删除机构
|
|
|
organizationDao.delete(organization);
|
|
|
@@ -239,32 +242,6 @@ public class OrganizationManagerServiceImpl extends SuperService {
|
|
|
|
|
|
//---------------------------------供其他服务调用接口 start---------------------
|
|
|
|
|
|
- /**
|
|
|
- * 查询项目下所有的机构信息列表
|
|
|
- *
|
|
|
- * @param projectOid
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ResultContent<List<OrganizationSimpleModel>> getProjectOrgList(String projectOid) {
|
|
|
- List<OrganizationSimpleModel> models = new ArrayList<>();
|
|
|
- List<Organization> list = organizationDao.findByProjectOidAndIsOrg(projectOid, Boolean.TRUE);
|
|
|
- if (ObjectUtils.isNotEmpty(list)) {
|
|
|
- models = list.stream().map(this::toSimpleModel).collect(Collectors.toList());
|
|
|
- }
|
|
|
- return ResultContent.buildSuccess(models);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 项目关联的结构 数量
|
|
|
- *
|
|
|
- * @param projectOid
|
|
|
- * @return
|
|
|
- */
|
|
|
- public long countProjectOrgNumber(String projectOid) {
|
|
|
- return organizationDao.countByProjectOid(projectOid, Boolean.TRUE);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 检查项目是否存在 是否是项目类型
|
|
|
*
|
|
|
@@ -285,10 +262,38 @@ public class OrganizationManagerServiceImpl extends SuperService {
|
|
|
return ResultContent.buildSuccess(organization);
|
|
|
}
|
|
|
|
|
|
+ public OidAboutInfo getOidAboutInfo(String oid) {
|
|
|
+ OidAboutInfo aboutInfo = new OidAboutInfo();
|
|
|
+ Organization organization = organizationDao.findTopByOid(oid);
|
|
|
+ if (ObjectUtils.isNotEmpty(organization)) {
|
|
|
+ aboutInfo.setOid(oid);
|
|
|
+ aboutInfo.setAuthType(organization.getAuthType());
|
|
|
+ AuthType authType = organization.getAuthType();
|
|
|
+
|
|
|
+ } else {
|
|
|
+ aboutInfo.setOid(oid);
|
|
|
+ }
|
|
|
+ return aboutInfo;
|
|
|
+ }
|
|
|
+
|
|
|
public OrganizationSimpleModel toSimpleModel(Organization entity) {
|
|
|
OrganizationSimpleModel model = new OrganizationSimpleModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
+
|
|
|
+ // 区域信息
|
|
|
+ String adminDivisionItemCode = entity.getAdminDivisionItemCode();
|
|
|
+ if (StringUtils.isNotEmpty(adminDivisionItemCode)) {
|
|
|
+ List<String> codes = List.of(adminDivisionItemCode.split(","));
|
|
|
+ List<Region> regions = regionDao.findByCodeInOrderByIndexAsc(codes);
|
|
|
+ List<RegionModel> regionList = regions.stream().map(it -> {
|
|
|
+ RegionModel regionModel = new RegionModel();
|
|
|
+ BeanUtils.copyProperties(it, regionModel);
|
|
|
+ return regionModel;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ model.setRegionList(regionList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return model;
|
|
|
}
|