|
@@ -10,10 +10,11 @@ import com.dragoninfo.dcuc.auth.auth.dto.OrgQuotaOpeDTO;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.OrgQuotaAuthInfo;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.OrgQuotaAuthLog;
|
|
|
import com.dragoninfo.dcuc.auth.auth.entity.RoleInfo;
|
|
|
-import com.dragoninfo.dcuc.auth.auth.enumresources.YesNotEnum;
|
|
|
import com.dragoninfo.dcuc.auth.auth.service.IOrgQuotaAuthLogService;
|
|
|
import com.dragoninfo.dcuc.auth.auth.service.IOrgQuotaAuthService;
|
|
|
import com.dragoninfo.dcuc.auth.auth.service.IStaffAssignAuthInfoService;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.business.IAuthOrgBusiness;
|
|
|
+import com.dragoninfo.dcuc.auth.sub.dto.OrgQuotaNumDTO;
|
|
|
import com.dragoninfo.dcuc.auth.sub.dto.OrgTreeNodeDTO;
|
|
|
import com.dragoninfo.dcuc.auth.sub.entity.AuthOrgInfo;
|
|
|
import com.dragoninfo.dcuc.auth.sub.service.IAuthOrgInfoService;
|
|
@@ -23,7 +24,6 @@ import com.dragoninfo.duceap.commons.util.server.OrgInfoUtil;
|
|
|
import com.dragoninfo.duceap.core.service.impl.BaseService;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
-import com.dragonsoft.duceap.base.entity.security.BaseSecurityUser;
|
|
|
import com.dragonsoft.duceap.base.entity.security.SecurityUser;
|
|
|
import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
import com.dragonsoft.duceap.base.utils.UserContextUtils;
|
|
@@ -65,6 +65,9 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
@Autowired
|
|
|
private IAuthOrgTreeService authOrgTreeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IAuthOrgBusiness authOrgBusiness;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IAppMtAuthFacade appMtAuthFacade;
|
|
|
|
|
@@ -169,7 +172,7 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
long time2 = System.currentTimeMillis();
|
|
|
logger.info("authCancelChild:orgInfoFacade.detail耗时:{} ms", (time2 - time1));
|
|
|
// TODO
|
|
|
- List<String> childIds = authOrgTreeService.getChildById(orgId)
|
|
|
+ List<String> childIds = authOrgTreeService.getOneLevelChildById(orgId)
|
|
|
.stream().map(OrgTreeNodeDTO::getId).collect(Collectors.toList());
|
|
|
long time3 = System.currentTimeMillis();
|
|
|
logger.info("authCancelChild:orgInfoFacade.getChildrenIds耗时:{} ms", (time3 - time2));
|
|
@@ -223,7 +226,7 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
private int cancelQuota(String orgId, String appMtAuths, List<OrgQuotaAuthInfo> updateList, Map<String, OrgQuotaAuthInfo> orgQuotaAuthInfoMap) {
|
|
|
int count = 0;
|
|
|
// TODO
|
|
|
- List<String> childrenIds = authOrgTreeService.getChildById(orgId)
|
|
|
+ List<String> childrenIds = authOrgTreeService.getOneLevelChildById(orgId)
|
|
|
.stream().map(OrgTreeNodeDTO::getId).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(childrenIds)) {
|
|
@@ -241,7 +244,7 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
return count;
|
|
|
}
|
|
|
// TODO
|
|
|
- List<OrgTreeNodeDTO> list = authOrgTreeService.getChildById(orgId);
|
|
|
+ List<OrgTreeNodeDTO> list = authOrgTreeService.getOneLevelChildById(orgId);
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return count;
|
|
|
}
|
|
@@ -374,7 +377,6 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
*
|
|
|
* @param
|
|
|
*/
|
|
|
-// SecurityUser userInfo, String appId, String roleId, String rootId, String unitClass, String roleLevel, String targetOrgLevel, int addNum
|
|
|
@Override
|
|
|
public ResponseStatus orgQutaInfoCalSave(OrgQuotaOpeDTO orgQuotaOpeDTO) {
|
|
|
SecurityUser userInfo = orgQuotaOpeDTO.getSecurityUser();
|
|
@@ -388,32 +390,28 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
|
|
|
String userId = userInfo.getId();
|
|
|
|
|
|
- // TODO
|
|
|
- Map<String, Object> resultMap = null/*orgInfoFacade.searchOrg(userId, rootId, unitClass, roleLevel)*/;
|
|
|
+ OrgQuotaNumDTO orgQuotaNumDTO = authOrgBusiness.searchOrg(userId, rootId, unitClass, roleLevel);
|
|
|
|
|
|
ApplyInfo applyInfo = applyInfoFacade.applyDetail(appId);
|
|
|
|
|
|
AuthOrgInfo rootOrg = authOrgInfoService.findById(rootId);
|
|
|
- int count = (Integer) resultMap.get("count");
|
|
|
+ int count = orgQuotaNumDTO.getCount();
|
|
|
OrgQuotaAuthInfo rootOrgQuota = orgQuotaAuthInfoBpo.getOrgQuotoAuthInfo(appId, roleId, rootId);//获取当前本级机构配额信息
|
|
|
//判断空闲名额是否足够
|
|
|
if (!rootId.equals(applyInfo.getOrgId()) && (rootOrgQuota == null || rootOrgQuota.getDfpNum() < count * addNum)) {
|
|
|
int kxme = rootOrgQuota == null ? 0 : rootOrgQuota.getDfpNum();
|
|
|
return ResponseStatus.fail("机构【" + rootOrg.getFullName() + "】空闲名额不足,当前空闲名额为:" + kxme + ",所需下发名额为:" + addNum * count);
|
|
|
}
|
|
|
- List<Map> allList = (List<Map>) resultMap.get("allList");
|
|
|
+ List<OrgTreeNodeDTO> resultTreeNodes = orgQuotaNumDTO.getResultTreeNodes();
|
|
|
Map<String, OrgQuotaAuthInfo> orgQuotaMap = getOrgQuotaAuthInfoMap(roleId);
|
|
|
final List<OrgQuotaAuthInfo> orgQuotaAuthInfos = new ArrayList<OrgQuotaAuthInfo>();
|
|
|
- for (Map orgTreeNode : allList) {
|
|
|
- if (!(Boolean) orgTreeNode.get("treeNode") && (int) orgTreeNode.get("count") == 0) { //没有变化的节点
|
|
|
- continue;
|
|
|
- }
|
|
|
+ for (OrgTreeNodeDTO orgTreeNode : resultTreeNodes) {
|
|
|
if (StringUtils.isNotBlank(targetOrgLevel)) {
|
|
|
//有配额但不下发
|
|
|
- if (StringUtils.isBlank((String) orgTreeNode.get("orgLevel")) || Integer.parseInt((String) orgTreeNode.get("orgLevel")) > Integer.parseInt(targetOrgLevel)) {
|
|
|
+ if (StringUtils.isBlank(orgTreeNode.getOrgLevel()) || Integer.parseInt(orgTreeNode.getOrgLevel()) > Integer.parseInt(targetOrgLevel)) {
|
|
|
continue;
|
|
|
} else {
|
|
|
- boolean flag = Integer.parseInt((String) orgTreeNode.get("orgLevel")) == Integer.parseInt(targetOrgLevel); //机构层级与分配范围的层级相等
|
|
|
+ boolean flag = Integer.parseInt(orgTreeNode.getOrgLevel()) == Integer.parseInt(targetOrgLevel); //机构层级与分配范围的层级相等
|
|
|
OrgQuotaAuthInfo orgQuotaAuthInfo = newOrUpdateOrgQuota(orgQuotaMap, orgTreeNode, flag, addNum, userInfo, appId, roleId);
|
|
|
orgQuotaAuthInfos.add(orgQuotaAuthInfo);
|
|
|
}
|
|
@@ -427,10 +425,14 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
boolean flag = StringUtils.isNotBlank(targetOrgLevel) && StringUtils.isNotBlank(orgLevel)
|
|
|
&& Integer.parseInt(orgLevel) == Integer.parseInt(targetOrgLevel); //根节点机构层级与分配范围的层级相等
|
|
|
if (rootId.equals(applyInfo.getOrgId())) { //根节点为应用所属机构
|
|
|
- Map rootOrgTreeNode = new HashMap();
|
|
|
- rootOrgTreeNode.put("value", rootId);
|
|
|
- rootOrgTreeNode.put("count", count);
|
|
|
- rootOrgTreeNode.put("treeNode", false);
|
|
|
+ OrgTreeNodeDTO rootOrgTreeNode = new OrgTreeNodeDTO();
|
|
|
+ rootOrgTreeNode.setIsParent(false);
|
|
|
+ rootOrgTreeNode.setId(rootId);
|
|
|
+ List<String> childIds = new ArrayList<>();
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ childIds.add("0");
|
|
|
+ }
|
|
|
+ rootOrgTreeNode.setChildIds(childIds);
|
|
|
OrgQuotaAuthInfo orgQuotaAuthInfo = newOrUpdateOrgQuota(orgQuotaMap, rootOrgTreeNode, false, addNum, userInfo, appId, roleId);
|
|
|
orgQuotaAuthInfos.add(orgQuotaAuthInfo);
|
|
|
} else {
|
|
@@ -445,9 +447,9 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
return ResponseStatus.success("保存成功!");
|
|
|
}
|
|
|
|
|
|
- private OrgQuotaAuthInfo newOrUpdateOrgQuota(Map<String, OrgQuotaAuthInfo> orgQuotaMap, Map orgTreeNode, boolean flag, int addNum, SecurityUser userInfo, String appId, String roleId) {
|
|
|
- OrgQuotaAuthInfo orgQuotaAuthInfo = orgQuotaMap.get(orgTreeNode.get("value"));
|
|
|
- int ownAddNum = (Boolean) orgTreeNode.get("treeNode") ? addNum : 0; //本机构新增的空闲名额
|
|
|
+ private OrgQuotaAuthInfo newOrUpdateOrgQuota(Map<String, OrgQuotaAuthInfo> orgQuotaMap, OrgTreeNodeDTO orgTreeNode, boolean flag, int addNum, SecurityUser userInfo, String appId, String roleId) {
|
|
|
+ OrgQuotaAuthInfo orgQuotaAuthInfo = orgQuotaMap.get(orgTreeNode.getId());
|
|
|
+ int ownAddNum = orgTreeNode.getIsParent() ? addNum : 0; //本机构新增的空闲名额
|
|
|
if (orgQuotaAuthInfo != null) {
|
|
|
int dfp = 0;
|
|
|
int yxf = 0;
|
|
@@ -458,16 +460,16 @@ public class OrgQuotaAuthService extends BaseService<OrgQuotaAuthInfo, String> i
|
|
|
yxf = orgQuotaAuthInfo.getYxfNum();
|
|
|
}
|
|
|
if (flag) { //如果机构层级与分配范围的层级相等,则把下级的分配的总数加到本机构的空闲名额中
|
|
|
- orgQuotaAuthInfo.setDfpNum(dfp + ownAddNum + (int) orgTreeNode.get("count") * addNum);
|
|
|
+ orgQuotaAuthInfo.setDfpNum(dfp + ownAddNum + orgTreeNode.getChildIds().size() * addNum);
|
|
|
} else {
|
|
|
- orgQuotaAuthInfo.setYxfNum(yxf + (int) orgTreeNode.get("count") * addNum);
|
|
|
+ orgQuotaAuthInfo.setYxfNum(yxf + orgTreeNode.getChildIds().size() * addNum);
|
|
|
orgQuotaAuthInfo.setDfpNum(dfp + ownAddNum);
|
|
|
}
|
|
|
} else {
|
|
|
if (flag) { //如果机构层级与分配范围的层级相等,则把下级的分配的总数加到本机构的空闲名额中
|
|
|
- orgQuotaAuthInfo = setOrgQuotaAuthInfo(appId, roleId, (String) orgTreeNode.get("value"), 0, 0, ownAddNum + (int) orgTreeNode.get("count") * addNum, "10", userInfo.getUserName(), userInfo.getDeptId());
|
|
|
+ orgQuotaAuthInfo = setOrgQuotaAuthInfo(appId, roleId, orgTreeNode.getId(), 0, 0, ownAddNum + orgTreeNode.getChildIds().size() * addNum, "10", userInfo.getUserName(), userInfo.getDeptId());
|
|
|
} else {
|
|
|
- orgQuotaAuthInfo = setOrgQuotaAuthInfo(appId, roleId, (String) orgTreeNode.get("value"), 0, (int) orgTreeNode.get("count") * addNum, ownAddNum, "10", userInfo.getUserName(), userInfo.getDeptId());
|
|
|
+ orgQuotaAuthInfo = setOrgQuotaAuthInfo(appId, roleId, orgTreeNode.getId(), 0, orgTreeNode.getChildIds().size() * addNum, ownAddNum, "10", userInfo.getUserName(), userInfo.getDeptId());
|
|
|
}
|
|
|
}
|
|
|
return orgQuotaAuthInfo;
|