|
@@ -1,577 +0,0 @@
|
|
-package com.dragoninfo.dcuc.authweb.restcontroller.org;
|
|
|
|
-
|
|
|
|
-import com.dragoninfo.dcuc.auth.sub.facade.IAuthUserInfoFacade;
|
|
|
|
-import com.dragoninfo.dcuc.authweb.business.MtAuthBusiness;
|
|
|
|
-import com.dragoninfo.dcuc.authweb.common.SysConstants;
|
|
|
|
-import com.dragoninfo.dcuc.authweb.restcontroller.org.vo.OrgRangeVo;
|
|
|
|
-import com.dragoninfo.dcuc.authweb.restcontroller.statisics.vo.OrgTreeNodeVo;
|
|
|
|
-import com.dragoninfo.dcuc.authweb.util.VersionUtils;
|
|
|
|
-import com.dragoninfo.dcuc.org.entity.OrgInfo;
|
|
|
|
-import com.dragoninfo.dcuc.org.facade.IOrgInfoFacade;
|
|
|
|
-import com.dragoninfo.dcuc.org.vo.OrgTreeNode;
|
|
|
|
-import com.dragoninfo.duceap.commons.util.server.OrgInfoUtil;
|
|
|
|
-import com.dragoninfo.duceap.core.response.Result;
|
|
|
|
-import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
|
|
|
|
-import com.dragonsoft.duceap.base.entity.security.SecurityUser;
|
|
|
|
-import com.dragonsoft.duceap.base.enums.BooleanEnum;
|
|
|
|
-import com.dragonsoft.duceap.base.utils.UserContextUtils;
|
|
|
|
-import com.dragonsoft.duceap.commons.util.string.StringUtils;
|
|
|
|
-import com.dragonsoft.duceap.commons.util.tree.SimpleTreeNodeItemResolver;
|
|
|
|
-import com.dragonsoft.duceap.commons.util.tree.TreeNodeUtils;
|
|
|
|
-import com.dragonsoft.duceap.core.context.ContextUtils;
|
|
|
|
-import com.dragonsoft.duceap.web.utils.SessionUtils;
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
|
-import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
-import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
-
|
|
|
|
-import java.util.*;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 勿删权限机构列表
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-@Api(tags = {"机构管理接口"})
|
|
|
|
-@RestController
|
|
|
|
-@RequestMapping(value = "/orgsvr/" + VersionUtils.VERSION_UID + "/")
|
|
|
|
-public class OrgInfoController {
|
|
|
|
- @Autowired
|
|
|
|
- private IOrgInfoFacade iOrgInfoFacade;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private IAuthUserInfoFacade authUserInfoFacade;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private MtAuthBusiness mtAuthBusiness;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 当前用户的管理范围机构树
|
|
|
|
- *
|
|
|
|
- * @param params type:机构树类型 (ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围 ), id:异步加载的树节点
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @ApiOperation(value = "机构树")
|
|
|
|
- @ApiImplicitParams({
|
|
|
|
- @ApiImplicitParam(name = "id", value = "id"),
|
|
|
|
- @ApiImplicitParam(name = "type", value = "type:机构树类型(ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围)")})
|
|
|
|
- @PostMapping(value = "org/tree/catalog")
|
|
|
|
- public Result orgMtTreeYB(@RequestBody Map params) {
|
|
|
|
- String id = (String) params.get("id");
|
|
|
|
- String type = (String) params.get("type");
|
|
|
|
- //获取管理范围ids
|
|
|
|
- SecurityUser curUser = UserContextUtils.getCurrentUser();
|
|
|
|
- String mtAuthIds = mtAuthBusiness.getMtAuth(curUser.getId(), type);
|
|
|
|
- if (StringUtils.isEmpty(id)) {
|
|
|
|
- //获取机构树根节点列表
|
|
|
|
- List<Map<String, Object>> result = this.treeRootList(mtAuthIds);
|
|
|
|
- return Result.success(result);
|
|
|
|
- } else {
|
|
|
|
- List<Map<String, Object>> result = this.getChildTreeNode(id, BooleanEnum.FALSE.getValue(), mtAuthIds);
|
|
|
|
- return Result.success(result);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 获取单个树节点机构信息
|
|
|
|
- */
|
|
|
|
- @ApiOperation(value = "单个树节点信息")
|
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "机构ID", required = true
|
|
|
|
- , example = "40288a8b699fc2500169a33b20540000")})
|
|
|
|
- @GetMapping(value = "org/tree/node/{id}")
|
|
|
|
- public Result<OrgTreeNodeVo> orgTreeNode(@PathVariable("id") String id) {
|
|
|
|
- OrgTreeNode orgTreeNode = iOrgInfoFacade.getOrgTreeNode(id);
|
|
|
|
- OrgTreeNodeVo vo = new OrgTreeNodeVo();
|
|
|
|
- BeanUtils.copyProperties(orgTreeNode, vo);
|
|
|
|
- vo.setName(orgTreeNode.getLabel());
|
|
|
|
- return Result.success(vo);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 管理员管理—管理范围—分配树
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @ApiOperation(value = "管理员管理—管理范围—分配树")
|
|
|
|
- @PostMapping(value = "org/tree/admin")
|
|
|
|
- @ApiImplicitParams({
|
|
|
|
- @ApiImplicitParam(name = "id", value = "id"),
|
|
|
|
- @ApiImplicitParam(name = "userId", value = "用户ID", required = true),
|
|
|
|
- @ApiImplicitParam(name = "mtType", value = "type:机构树类型(ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围)", required = true)
|
|
|
|
- })
|
|
|
|
- public Result orgMtTreeWithChecked(@RequestBody OrgRangeVo orgRangeVo) {
|
|
|
|
- String id = orgRangeVo.getId();
|
|
|
|
- String mtType = orgRangeVo.getMtType();
|
|
|
|
- String userId = orgRangeVo.getUserId();
|
|
|
|
- //获取管理范围ids
|
|
|
|
- SecurityUser curUser = UserContextUtils.getCurrentUser();
|
|
|
|
- String mtAuthIds = mtAuthBusiness.getMtAuth(curUser.getId(), mtType);
|
|
|
|
- //当临时表没有数据时候,获取登录人的权限范围
|
|
|
|
- if (StringUtils.isEmpty(mtAuthIds) && SysConstants.MT_TEMP.equals(orgRangeVo.getMtType())) {
|
|
|
|
- mtAuthIds = mtAuthBusiness.getMtAuth(curUser.getId(), SysConstants.MT_APP);
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isEmpty(id)) {
|
|
|
|
- //获取机构树根节点列表
|
|
|
|
- List<Map<String, Object>> treeList = this.treeRootList(mtAuthIds);
|
|
|
|
- return Result.success(checkTreeNode(treeList, mtType, userId));
|
|
|
|
- } else {
|
|
|
|
- List<Map<String, Object>> treeList = this.getChildTreeNode(id, BooleanEnum.FALSE.getValue(), mtAuthIds);
|
|
|
|
- return Result.success(checkTreeNode(treeList, mtType, userId));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 、机构新增
|
|
|
|
-// *
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// @ApiOperation(value = "机构新增")
|
|
|
|
-// @PostMapping(value = "org")
|
|
|
|
-// public Result save(@RequestBody OrgVo vo) {
|
|
|
|
-// try {
|
|
|
|
-// OrgInfo orgInfo = new OrgInfo();
|
|
|
|
-// BeanUtils.copyProperties(orgInfo, vo);
|
|
|
|
-// SecurityUser user = (SecurityUser) ContextUtils.getUserInfo();
|
|
|
|
-// orgInfo = this.upSetOrg(orgInfo);
|
|
|
|
-// if (iOrgInfoFacade.checkCode("", orgInfo.getCode()) != null) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "机构代码已存在");
|
|
|
|
-// }
|
|
|
|
-// if (iOrgInfoFacade.checkName("", orgInfo.getFullName(), "") != null) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "机构名称已存在");
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if (!authUserInfoFacade.getRootUser().equals(user.getUserName()) && StringUtils.isEmpty(orgInfo.getUpGovId())) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "请选择机构后再新增!");
|
|
|
|
-// }
|
|
|
|
-// //保存机构在这
|
|
|
|
-// orgInfo = iOrgInfoFacade.addOrg(orgInfo);
|
|
|
|
-// // TODO: 2019/1/30
|
|
|
|
-// //维护子表
|
|
|
|
-// if (!authUserInfoFacade.getRootUser().equals(user.getName())) {
|
|
|
|
-// OrgMtAuth orgMtAuth = iOrgMtAuthFacade.getOrgMtAuthById(user.getId()).get(0);
|
|
|
|
-// String orgMtIds = orgMtAuth.getOrgId();
|
|
|
|
-// if (orgMtIds != null && orgMtIds.indexOf(orgInfo.getUpGovId() + ":0") >= 0) {
|
|
|
|
-// //原机构范围只勾选了父节点,需添加新增的机构节点,修改父节点记录为勾选部分子节点
|
|
|
|
-// orgMtIds = orgMtIds.replace(orgInfo.getUpGovId() + ":0", orgInfo.getUpGovId() + ":1," + orgInfo.getId() + ":-1");
|
|
|
|
-// } else if (orgMtIds != null && orgMtIds.indexOf(orgInfo.getUpGovId() + ":1") >= 0) {
|
|
|
|
-// //原父节点记录为勾选部分子节点,需添加新增的机构节点
|
|
|
|
-// orgMtIds = orgMtIds.replace(orgInfo.getUpGovId() + ":1", orgInfo.getUpGovId() + ":1," + orgInfo.getId() + ":-1");
|
|
|
|
-// }
|
|
|
|
-// if (!orgMtAuth.getOrgId().equals(orgMtIds)) {
|
|
|
|
-// orgMtAuth.setOrgId(orgMtIds);
|
|
|
|
-// iOrgMtAuthFacade.save(orgMtIds, user.getId());
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// logger.error(e.getMessage(), e);
|
|
|
|
-// return Result.fail(ResultEnum.SERVICE_FAIL.getValue(), "新增异常");
|
|
|
|
-// }
|
|
|
|
-// return Result.success();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// @ApiOperation(value = "机构修改")
|
|
|
|
-// @PutMapping(value = "org/{id}")
|
|
|
|
-// public Result update(@RequestBody OrgVo vo) {
|
|
|
|
-// try {
|
|
|
|
-// if (iOrgInfoFacade.checkCode(vo.getId(), vo.getCode()) != null) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "机构代码已存在");
|
|
|
|
-// }
|
|
|
|
-// if (iOrgInfoFacade.checkName(vo.getId(), vo.getFullName(), "") != null) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "机构名称已存在");
|
|
|
|
-// }
|
|
|
|
-// OrgInfo orgInfo = iOrgInfoFacade.detail(vo.getId());
|
|
|
|
-// Date date = orgInfo.getOrgEndDate();
|
|
|
|
-// BeanUtils.copyProperties(orgInfo, vo);
|
|
|
|
-// orgInfo.setOrgStartDate(date);
|
|
|
|
-// iOrgInfoFacade.updateOrg(orgInfo);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// logger.error("修改失败", e);
|
|
|
|
-// return Result.fail(ResultEnum.SERVICE_FAIL.getKey(), "保存失败");
|
|
|
|
-// }
|
|
|
|
-// return Result.success();
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 设置org更新值
|
|
|
|
-// *
|
|
|
|
-// * @param orgInfo
|
|
|
|
-// */
|
|
|
|
-//
|
|
|
|
-// private OrgInfo upSetOrg(OrgInfo orgInfo) {
|
|
|
|
-// OrgInfo oldOrg = new OrgInfo();
|
|
|
|
-// if (StringUtils.isNotEmpty(orgInfo.getId())) {
|
|
|
|
-// oldOrg = iOrgInfoFacade.detail(orgInfo.getId());
|
|
|
|
-// } else {
|
|
|
|
-// oldOrg.setOrgStartDate(new Date());
|
|
|
|
-// }
|
|
|
|
-// oldOrg.setUpGovId(orgInfo.getUpGovId());
|
|
|
|
-// oldOrg.setOrgKind(orgInfo.getOrgKind());
|
|
|
|
-// oldOrg.setFullName(orgInfo.getFullName());
|
|
|
|
-// oldOrg.setShortName(orgInfo.getShortName());
|
|
|
|
-// oldOrg.setAreaCode(orgInfo.getAreaCode());
|
|
|
|
-// oldOrg.setBizType(orgInfo.getBizType());
|
|
|
|
-// oldOrg.setCode(orgInfo.getCode());
|
|
|
|
-// oldOrg.setOrgType(orgInfo.getOrgType());
|
|
|
|
-// oldOrg.setUnitClass(orgInfo.getUnitClass());
|
|
|
|
-// oldOrg.setOrgLevel(orgInfo.getOrgLevel());
|
|
|
|
-// oldOrg.setEmail(orgInfo.getEmail());
|
|
|
|
-// oldOrg.setLinkMan(orgInfo.getLinkMan());
|
|
|
|
-// oldOrg.setTel(orgInfo.getTel());
|
|
|
|
-// oldOrg.setOrgRank(orgInfo.getOrgRank());
|
|
|
|
-// return oldOrg;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 机构删除
|
|
|
|
-// *
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// @ApiOperation(value = "机构删除")
|
|
|
|
-// @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "机构ID", required = true
|
|
|
|
-// , example = "40288a8b699fc2500169a33b20540000")})
|
|
|
|
-// @DeleteMapping(value = "org/{id}")
|
|
|
|
-// public Result deleteOrg(@PathVariable("id") String id) {
|
|
|
|
-// logger.info(id);
|
|
|
|
-// Searchable searchable = Searchable.newSearchable();
|
|
|
|
-// searchable.addSearchFilter("orgId", SearchOperator.eq, id);
|
|
|
|
-// searchable.addSearchFilter("deleted", SearchOperator.eq, BooleanEnum.FALSE.getValue());
|
|
|
|
-// SearchDTO searchDTO = searchable.toSearchDTO();
|
|
|
|
-// Page<AuthUserDTO> page = authUserInfoFacade.page(searchDTO);
|
|
|
|
-// if (page.getContent().size() > 0) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "该机构有人员存在,不可删除");
|
|
|
|
-// }
|
|
|
|
-// Page<ApplyInfo> appPage = applyInfoFacade.applyInfoPage(searchDTO);
|
|
|
|
-// if (appPage.getContent().size() > 0) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "该机构有应用存在,不可删除");
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// try {
|
|
|
|
-// iOrgInfoFacade.deleteOrg(id);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// logger.error("删除失败", e);
|
|
|
|
-// return Result.fail(ResultEnum.SERVICE_FAIL.getKey(), "删除失败");
|
|
|
|
-// }
|
|
|
|
-// return Result.success();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-//
|
|
|
|
-// @ApiOperation(value = "机构调动")
|
|
|
|
-// @ApiImplicitParams({@ApiImplicitParam(name = "orgId", value = "机构id", required = true),
|
|
|
|
-// @ApiImplicitParam(name = "upGovId", value = "上级机构Id", required = true),})
|
|
|
|
-// @PostMapping(value = "org/transfer")
|
|
|
|
-// public Result orgInfoMove(@RequestBody MergersVo mergersVo) {
|
|
|
|
-// String orgId = mergersVo.getOrgId();
|
|
|
|
-// String upGovId = mergersVo.getUpGovId();
|
|
|
|
-// if (orgId.equals(upGovId)) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "不能选择自身");
|
|
|
|
-// }
|
|
|
|
-// OrgInfo orgInfo = iOrgInfoFacade.detail(orgId);
|
|
|
|
-// if (orgInfo.getUpGovId().equals(upGovId)) {
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "不能选择同一个上级机构");
|
|
|
|
-// }
|
|
|
|
-// try {
|
|
|
|
-// iOrgInfoFacade.moveOrg(orgId, upGovId);
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// logger.error("调动失败", e);
|
|
|
|
-// return Result.fail(ResultEnum.SERVICE_FAIL.getKey(), "调动失败");
|
|
|
|
-// }
|
|
|
|
-// return Result.success();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// /**
|
|
|
|
-// * 机构合并
|
|
|
|
-// *
|
|
|
|
-// * @param mergersVo
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// @ApiOperation(value = "机构合并")
|
|
|
|
-// @ApiImplicitParams({@ApiImplicitParam(name = "orgId", value = "合并机构id", required = true),
|
|
|
|
-// @ApiImplicitParam(name = "targetId", value = "目标机构Id", required = true),})
|
|
|
|
-// @PostMapping(value = "org/mergers")
|
|
|
|
-// public Result orgInfoMerfe(@RequestBody MergersVo mergersVo) {
|
|
|
|
-// String orgId = mergersVo.getOrgId();
|
|
|
|
-// String targetId = mergersVo.getTargetId();
|
|
|
|
-// if (orgId.equals(targetId))
|
|
|
|
-// return Result.fail(ResultEnum.FAIL.getKey(), "不能选择自身");
|
|
|
|
-// ResponseStatus result = iOrgInfoFacade.orgInfoMerge(orgId, targetId);
|
|
|
|
-// if (result.getStatusCode().equals("200")) {
|
|
|
|
-// OrgInfo orgInfo = iOrgInfoFacade.detail(targetId);
|
|
|
|
-// authUserInfoFacade.updateByOrgId(orgId, targetId, orgInfo.getFullName(),orgInfo.getCode());
|
|
|
|
-// List<NoticeUserVO> list = iManageInfoFacade.getManagerByOrgId(orgId);
|
|
|
|
-// for (NoticeUserVO note : list) {
|
|
|
|
-// if (!StringUtils.isEmpty(note.getUserId())) {
|
|
|
|
-// iAppMtAuthFacade.save("", note.getUserId());
|
|
|
|
-// iUserMtAuthFacade.save("", note.getUserId());
|
|
|
|
-// iOrgMtAuthFacade.save("", note.getUserId());
|
|
|
|
-// iManageInfoFacade.deleteAdmin(note.getUserId(), "");
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// return Result.success();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// @ApiOperation(value = "机构拖动排序")
|
|
|
|
-// @ApiImplicitParams({@ApiImplicitParam(name = "startId", value = "需要拖动的机构", required = true),
|
|
|
|
-// @ApiImplicitParam(name = "endId", value = "拖动到目标机构", required = true),
|
|
|
|
-// @ApiImplicitParam(name = "moveType", value = "prev:目标机构前,next: 目标机构后", required = true)})
|
|
|
|
-// @PostMapping(value = "org/sort")
|
|
|
|
-// public Result reSort(@RequestBody SortVo sortVo) {
|
|
|
|
-//
|
|
|
|
-// try {
|
|
|
|
-// iOrgInfoFacade.reSort(sortVo.getStartId(), sortVo.getEndId(), sortVo.getMoveType());
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// logger.error("排序失败", e);
|
|
|
|
-// }
|
|
|
|
-// return Result.success();
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 机构详情
|
|
|
|
-// *
|
|
|
|
-// * @param orgId
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// @GetMapping(value = "org/{id}")
|
|
|
|
-// @ApiOperation(value = "获取单个机构")
|
|
|
|
-// @ApiImplicitParams({@ApiImplicitParam(paramType = "path", name = "id", value = "机构ID", required = true
|
|
|
|
-// , example = "40288a8b699fc2500169a33b20540000")})
|
|
|
|
-// public Result<OrgVo> orgInfoDetail(@PathVariable(value = "id") String orgId) {
|
|
|
|
-// OrgInfo detail = iOrgInfoFacade.detail(orgId);
|
|
|
|
-// OrgVo org = new OrgVo();
|
|
|
|
-// BeanUtils.copyProperties(org, detail);
|
|
|
|
-// List<NoticeUserVO> managerList = this.getAdmins(orgId);
|
|
|
|
-// org.setAdmins(managerList);
|
|
|
|
-// return Result.success(org);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * orginfo转map
|
|
|
|
- *
|
|
|
|
- * @param orgInfosList
|
|
|
|
- * @param orgNums
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- private List<Map<String, Object>> orgToTreeNode(List<OrgInfo> orgInfosList, Map<String, Long> orgNums) {
|
|
|
|
- //子级和自身的子级个数
|
|
|
|
- List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
|
- for (OrgInfo orgInfo : orgInfosList) {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("id", orgInfo.getId());
|
|
|
|
- map.put("code", orgInfo.getCode());
|
|
|
|
- map.put("name", orgInfo.getFullName());
|
|
|
|
- map.put("pid", orgInfo.getUpGovId());
|
|
|
|
- map.put("path", orgInfo.getPath());
|
|
|
|
- if (orgNums.containsKey(orgInfo.getId()) && orgNums.get(orgInfo.getId()) > 0) {
|
|
|
|
- map.put("isParent", true);
|
|
|
|
- } else {
|
|
|
|
- map.put("isParent", false);
|
|
|
|
- }
|
|
|
|
- mapList.add(map);
|
|
|
|
- }
|
|
|
|
- return mapList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据ids获取初始树根节点
|
|
|
|
- *
|
|
|
|
- * @param mtAuthIds:管理范围ids
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<Map<String, Object>> treeRootList(String mtAuthIds) {
|
|
|
|
- if (StringUtils.isBlank(mtAuthIds)) {
|
|
|
|
- return new ArrayList<>();
|
|
|
|
- }
|
|
|
|
- StringBuffer orgIds = new StringBuffer();
|
|
|
|
- for (String orgIdStr : mtAuthIds.split(",")) {
|
|
|
|
- String[] orgIdStatus = orgIdStr.split(":");
|
|
|
|
- orgIds.append(orgIdStatus[0] + ",");
|
|
|
|
- }
|
|
|
|
- List<OrgInfo> orgInfosList = iOrgInfoFacade.getOrgsByIds(orgIds.toString());
|
|
|
|
- Map<String, Long> orgNums = iOrgInfoFacade.countOrgByIds(orgIds.toString());
|
|
|
|
- List<Map<String, Object>> mapList = this.orgToTreeNode(orgInfosList, orgNums);
|
|
|
|
- mapList = TreeNodeUtils.generateTree(mapList, new SimpleTreeNodeItemResolver("id", "pid"), 0);
|
|
|
|
- for (Map<String, Object> map : mapList) {
|
|
|
|
- map.remove("children");
|
|
|
|
- }
|
|
|
|
- return mapList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 异步获取子节点
|
|
|
|
- *
|
|
|
|
- * @param parentId 父节点id
|
|
|
|
- * @param state 机构状态:0:未删除,1:已删除,null:全部
|
|
|
|
- * @param mtAuthIds 管理范围,为""或null时不过滤
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<Map<String, Object>> getChildTreeNode(String parentId, String state, String mtAuthIds) {
|
|
|
|
- //子级机构
|
|
|
|
- List<OrgInfo> childList = iOrgInfoFacade.getOrgListByUpId(parentId);
|
|
|
|
- Map<String, Long> orgNums = iOrgInfoFacade.countOrgByUpOrgId(parentId, state);
|
|
|
|
- if (StringUtils.isNotEmpty(mtAuthIds)) {
|
|
|
|
- Iterator<OrgInfo> iterator = childList.iterator();
|
|
|
|
- while (iterator.hasNext()) {
|
|
|
|
- OrgInfo orgInfo = iterator.next();
|
|
|
|
- //不在管理范围内
|
|
|
|
- if (!OrgInfoUtil.isHaveAuth(orgInfo.getId(), orgInfo.getPath(), mtAuthIds)){
|
|
|
|
- iterator.remove();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- List<Map<String, Object>> mapList = this.orgToTreeNode(childList, orgNums);
|
|
|
|
- return mapList;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 管理员管理-管理范围-节点状态勾选
|
|
|
|
- *
|
|
|
|
- * @param treeNodes
|
|
|
|
- * @param type 机构树类型
|
|
|
|
- * @param targetUserId
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public List<Map<String, Object>> checkTreeNode(List<Map<String, Object>> treeNodes, String type, String targetUserId) {
|
|
|
|
- String mtAuthIds = mtAuthBusiness.getMtAuth(targetUserId, type);
|
|
|
|
- for (Map<String, Object> treeNode : treeNodes) {
|
|
|
|
- String orgId = (String) treeNode.get("id");
|
|
|
|
- String path = (String) treeNode.get("path");
|
|
|
|
- if (StringUtils.isNotEmpty(mtAuthIds) && mtAuthIds.indexOf(orgId + ":1") > -1) {//半勾选
|
|
|
|
- treeNode.put("checked", "1");
|
|
|
|
- } else if (OrgInfoUtil.isHaveAuth(orgId, path, mtAuthIds)) {//全勾选
|
|
|
|
- treeNode.put("checked", "2");
|
|
|
|
- } else {
|
|
|
|
- treeNode.put("checked", "0");//未勾选
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return treeNodes;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @ApiOperation(value = "完整树")
|
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "节点机构id"),
|
|
|
|
- @ApiImplicitParam(name = "type", value = "'1':顶点为自身所在机构,0:根节点", required = true)})
|
|
|
|
- @PostMapping(value = "org/tree/full")
|
|
|
|
- public Result fullOrgTree(@RequestBody Map<String, String> params) {
|
|
|
|
- String id = params.get("id");
|
|
|
|
- String type = params.get("type");
|
|
|
|
- if (StringUtils.isEmpty(id)) {
|
|
|
|
- SecurityUser securityUser = SessionUtils.getUserInfo();
|
|
|
|
- if (BooleanEnum.TRUE.getValue().equals(type) && StringUtils.isNotEmpty(securityUser.getDeptId())) {
|
|
|
|
- id = securityUser.getDeptId();
|
|
|
|
- } else {
|
|
|
|
- id = iOrgInfoFacade.getRootOrgId();
|
|
|
|
- }
|
|
|
|
- List<OrgInfo> orgInfos = iOrgInfoFacade.getOrgsByIds(id);
|
|
|
|
- Map<String, Long> orgNums = iOrgInfoFacade.countOrgByIds(id);
|
|
|
|
- List<Map<String, Object>> resultList = this.orgToTreeNode(orgInfos, orgNums);
|
|
|
|
- return Result.success(resultList);
|
|
|
|
- } else {
|
|
|
|
- List<Map<String, Object>> result = this.getChildTreeNode(id, BooleanEnum.FALSE.getValue(), null);
|
|
|
|
- return Result.success(result);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// /**
|
|
|
|
-// * 审计管理—机构树
|
|
|
|
-// *
|
|
|
|
-// * @param type 机构树类型 ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围
|
|
|
|
-// * @param id 异步加载的树节点
|
|
|
|
-// * @return
|
|
|
|
-// */
|
|
|
|
-// @ApiOperation(value = "审计管理—机构树")
|
|
|
|
-// @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "节点机构id", required = true),
|
|
|
|
-// @ApiImplicitParam(name = "type", value = "机构树类型 ORG:机构管理范围 USER:用户管理范围 APP:权限管理范围 MGE:管理员管理范围", required = true)})
|
|
|
|
-// @PostMapping(value = "org/tree/audit")
|
|
|
|
-// public Result userAuditTree(
|
|
|
|
-// @RequestParam(value = "type", required = false) String type,
|
|
|
|
-// @RequestParam(value = "id", required = false) String id) {
|
|
|
|
-// //获取管理范围ids
|
|
|
|
-// SecurityUser curUser = (SecurityUser) ContextUtils.getUserInfo();
|
|
|
|
-// String mtAuthIds = mtAuthBusiness.getMtAuth(curUser.getId(), type);
|
|
|
|
-// if (StringUtils.isEmpty(id)) {
|
|
|
|
-// List<Map<String, Object>> result = this.treeRootList(mtAuthIds);
|
|
|
|
-// return Result.success(result);
|
|
|
|
-// } else {
|
|
|
|
-// List<Map<String, Object>> result = this.getChildTreeNode(id, null, mtAuthIds);
|
|
|
|
-// return Result.success(result);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
- @ApiOperation(value = "机构树匹配")
|
|
|
|
- @ApiImplicitParams({@ApiImplicitParam(name = "name", value = "机构id", required = false),
|
|
|
|
- @ApiImplicitParam(name = "mtType", value = "机构树类型 org:机构管理范围 user:用户管理范围 app:权限管理范围 mge:管理员管理范围", required = false),
|
|
|
|
- @ApiImplicitParam(name = "pageNum", value = "条数", required = false),
|
|
|
|
- @ApiImplicitParam(name = "pageSize", value = "页数", required = false)
|
|
|
|
- })
|
|
|
|
- @PostMapping(value = "org/tree/match")
|
|
|
|
- public Result orgMatch(@RequestBody Map<String, Object> params) {
|
|
|
|
- String mtType = (String) params.get("mtType");
|
|
|
|
- String name = (String) params.get("name");
|
|
|
|
- Integer pageNum = (Integer) params.get("pageNum");
|
|
|
|
- Integer pageSize = (Integer) params.get("pageSize");
|
|
|
|
- String mts = "";
|
|
|
|
- String id = UserContextUtils.getCurrentUser().getId();
|
|
|
|
- if (StringUtils.isBlank(mtType)) {
|
|
|
|
- mts = "";
|
|
|
|
- } else {
|
|
|
|
- mts = mtAuthBusiness.getMtAuth(id, SysConstants.MT_APP);
|
|
|
|
- }
|
|
|
|
- if (!authUserInfoFacade.isRootUser(id) && StringUtils.isBlank(mts) && !StringUtils.isBlank(mtType) && !"all".equals(mtType)) {
|
|
|
|
- return Result.success();
|
|
|
|
- }
|
|
|
|
- ResponseDTO responseDTO = iOrgInfoFacade.orgMatch(name, mts, pageNum, pageSize);
|
|
|
|
- return Result.success(StringUtils.getLong(responseDTO.getMessage()), responseDTO.getResult());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// private String getRootUser() {
|
|
|
|
-// String rootUserId = authWebConfig.getRootUserId();
|
|
|
|
-// if(null == rootUserId) {
|
|
|
|
-// rootUserId = "";
|
|
|
|
-// }
|
|
|
|
-// return rootUserId;
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-// @ApiOperation(value = "获取过滤后的父节点")
|
|
|
|
-// @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "机构id", required = true),
|
|
|
|
-// @ApiImplicitParam(name = "type", value = "机构树类型 org:机构管理范围 user:用户管理范围 app:权限管理范围 mge:管理员管理范围", required = true),
|
|
|
|
-// })
|
|
|
|
-// @PostMapping(value = "org/tree/filter")
|
|
|
|
-// public Result getFilterOrgTree(@RequestParam(value = "codeId") String codeId,
|
|
|
|
-// @RequestParam(value = "type", required = false) String type) {
|
|
|
|
-// OrgTreeNode node = iOrgInfoFacade.getOrgTreeNode(codeId);
|
|
|
|
-// String path = node.getPath();
|
|
|
|
-// String[] paths = path.split("-");
|
|
|
|
-// List<String> levelOrder = new ArrayList<String>();
|
|
|
|
-// String mtIds = "";
|
|
|
|
-// if (StringUtils.isBlank(type)) {
|
|
|
|
-// mtIds = "";
|
|
|
|
-// } else if ("org".equals(type)) {
|
|
|
|
-// mtIds = iOrgMtAuthFacade.mgeOrgRightRangeStr(ContextUtils.getUserInfo().getId());
|
|
|
|
-// } else if ("user".equals(type)) {
|
|
|
|
-// mtIds = iUserMtAuthFacade.mgeUserRightRangeStr(ContextUtils.getUserInfo().getId());
|
|
|
|
-// } else if ("app".equals(type)) {
|
|
|
|
-// mtIds = iAppMtAuthFacade.mgeAppRightRangeStr(ContextUtils.getUserInfo().getId());
|
|
|
|
-// } else if ("mge".equals(type)) {
|
|
|
|
-// mtIds = iMgeMtAuthFacade.mgeMgeRightRangeStr(ContextUtils.getUserInfo().getId());
|
|
|
|
-// } else {
|
|
|
|
-// mtIds = "";
|
|
|
|
-// }
|
|
|
|
-// for (String curNodeId : paths) {
|
|
|
|
-// OrgTreeNode curNode = iOrgInfoFacade.getOrgTreeNode(curNodeId);
|
|
|
|
-// if (OrgInfoUtil.isHaveAuth(curNode.getValue(), curNode.getPath(), mtIds) || StringUtils.isEmpty(mtIds)) {
|
|
|
|
-// levelOrder.add(curNodeId);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// levelOrder.add(codeId);
|
|
|
|
-// return Result.success(levelOrder);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
-}
|
|
|