|
@@ -16,6 +16,7 @@ import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.zhongshu.card.client.model.org.*;
|
|
import com.zhongshu.card.client.model.org.*;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.net.ResultMessage;
|
|
import com.github.microservice.net.ResultMessage;
|
|
|
|
|
+import com.zhongshu.card.client.model.project.ProjectSaveParam;
|
|
|
import com.zhongshu.card.client.service.org.OrganizationService;
|
|
import com.zhongshu.card.client.service.org.OrganizationService;
|
|
|
import com.zhongshu.card.client.type.*;
|
|
import com.zhongshu.card.client.type.*;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
@@ -93,6 +94,99 @@ public class OrganizationServiceImpl extends SuperService implements Organizatio
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ProjectSyncIotCenterService projectSyncIotCenterService;
|
|
ProjectSyncIotCenterService projectSyncIotCenterService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ OrganizationUserServiceImpl organizationUserServiceImpl;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 保存项目信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public ResultContent saveProjectInfo(ProjectSaveParam param) {
|
|
|
|
|
+ AuthType authType = param.getAuthType();
|
|
|
|
|
+ String code = param.getCode();
|
|
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
|
|
+ code = NextNoUtil.getNextNo(authType.getCode().toUpperCase());
|
|
|
|
|
+ param.setCode(code);
|
|
|
|
|
+ }
|
|
|
|
|
+ String name = param.getName();
|
|
|
|
|
+ if (ObjectUtils.isEmpty(param.getManagerUserIds())) {
|
|
|
|
|
+ return ResultContent.buildFail("项目负责人不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ String currentOid = getCurrentOid();
|
|
|
|
|
+ List<UserAccount> userAccounts = userAccountService.getUserAccounts(param.getManagerUserIds());
|
|
|
|
|
+ if (userAccounts.size() != param.getManagerUserIds().size()) {
|
|
|
|
|
+ return ResultContent.buildFail("managerUserIds错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ Organization organization = null;
|
|
|
|
|
+ Organization nameOrganization = organizationDao.findTopByNameAndAuthType(name, authType);
|
|
|
|
|
+ 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()));
|
|
|
|
|
+ }
|
|
|
|
|
+ BeanUtils.copyProperties(param, organization, "code");
|
|
|
|
|
+ initUpdateEntity(organization);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(nameOrganization)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, param.getName()));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 初始权限中心的机构信息
|
|
|
|
|
+ ResultContent<String> initOrgContent = authCenterAddOrgInfo(name, authType, param.getRemark());
|
|
|
|
|
+ if (initOrgContent.isFailed()) {
|
|
|
|
|
+ return ResultContent.buildFail(initOrgContent.getMsg());
|
|
|
|
|
+ }
|
|
|
|
|
+ String oid = initOrgContent.getContent();
|
|
|
|
|
+ organization = new Organization();
|
|
|
|
|
+ BeanUtils.copyProperties(param, organization);
|
|
|
|
|
+ organization.setOid(oid);
|
|
|
|
|
+ organization.setProjectOid(oid);
|
|
|
|
|
+ organization.setAboutOid(currentOid);
|
|
|
|
|
+ organization.setCreateUserId(getCurrentUserId());
|
|
|
|
|
+ initEntity(organization);
|
|
|
|
|
+ organizationDao.save(organization);
|
|
|
|
|
+ }
|
|
|
|
|
+ organizationUserServiceImpl.orgBindManager(organization, userAccounts);
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //------------------------------------------------------------------------------------
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 权限中心添加结构信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param name
|
|
|
|
|
+ * @param authType
|
|
|
|
|
+ * @param remark
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private ResultContent<String> authCenterAddOrgInfo(String name, AuthType authType, String remark) {
|
|
|
|
|
+ String oid = "";
|
|
|
|
|
+ com.github.microservice.auth.client.model.OrganizationModel organizationModel = new com.github.microservice.auth.client.model.OrganizationModel();
|
|
|
|
|
+ organizationModel.setName(name);
|
|
|
|
|
+ organizationModel.setAuthType(authType);
|
|
|
|
|
+ organizationModel.setRemark(remark);
|
|
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String> resultContent = organizationService.add(organizationModel);
|
|
|
|
|
+ if (resultContent.getState() == ResultState.Success) {
|
|
|
|
|
+ log.info("平台初始成功: {}", resultContent.getContent());
|
|
|
|
|
+ oid = resultContent.getContent();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String msg = resultContent.getMsg();
|
|
|
|
|
+ if (StringUtils.isEmpty(msg) && resultContent.getException() != null) {
|
|
|
|
|
+ msg = resultContent.getException().getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("initSuperOrganization {}", msg);
|
|
|
|
|
+ return ResultContent.buildFail(msg);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultContent.buildSuccess(oid);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 添加机构 (只是添加、没得编辑)
|
|
* 添加机构 (只是添加、没得编辑)
|
|
|
*
|
|
*
|