| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.omd.data.BusinessObject; |
| | | import com.vci.frameworkcore.compatibility.OrgDeptQueryServiceI; |
| | | import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus; |
| | |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.wrapper.VciQueryWrapperForDO; |
| | | import com.vci.web.service.WebBoServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Autowired |
| | | private WebBoServiceI boService; |
| | | |
| | | /** |
| | | * 平台调用客户端 |
| | | */ |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | /** |
| | | * 对象操作工具类 |
| | |
| | | } |
| | | return departmentVO; |
| | | } |
| | | |
| | | /** |
| | | * 批量获取部门的信息 (根据部门主键) |
| | | * @param deptOidCollections 部门主键的集合,可以超过1000个 |
| | |
| | | }); |
| | | return deptDO2VOs(depts); |
| | | } |
| | | |
| | | /** |
| | | * 获取部门的列表,默认会以部门名称升序排列,部门的编辑页面列表不要使用这个接口 |
| | | * @param queryMap 查询条件 |
| | |
| | | } |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * 根据部门主键获取部门的姓名 |
| | | * @param deptOid 部门主键 |
| | |
| | | if(queryMap == null){ |
| | | queryMap = new HashMap<>(); |
| | | } |
| | | List<OrgDeptForPlatform1> roles = new ArrayList<>(); |
| | | List<OrgDeptForPlatform1> deptForPlatform1s = new ArrayList<>(); |
| | | if(userOid.contains(",")){ |
| | | Map<String, String> finalQueryMap = queryMap; |
| | | WebUtil.switchCollectionForOracleIn(WebUtil.str2List(userOid)).stream().forEach(userOids->{ |
| | |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(conditionMap,OrgDeptForPlatform1.class); |
| | | List<OrgDeptForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class); |
| | | if(!CollectionUtils.isEmpty(roleForPlatform1s)){ |
| | | roles.addAll(roleForPlatform1s); |
| | | deptForPlatform1s.addAll(roleForPlatform1s); |
| | | } |
| | | }); |
| | | }else { |
| | |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(queryMap,OrgDeptForPlatform1.class); |
| | | List<OrgDeptForPlatform1> roleForPlatform1s = boService.selectByQueryWrapper(queryWrapper, OrgDeptForPlatform1.class); |
| | | if(!CollectionUtils.isEmpty(roleForPlatform1s)){ |
| | | roles.addAll(roleForPlatform1s); |
| | | deptForPlatform1s.addAll(roleForPlatform1s); |
| | | } |
| | | return deptDO2VOs(roles); |
| | | return deptDO2VOs(deptForPlatform1s); |
| | | } |
| | | /** |
| | | |
| | | /** |
| | | * 根据用户主键获取关联的部门 |
| | | * @param userOid 用户主键 |
| | | * @param queryMap 查询条件,如果需要使用用户的属性来查询可以使用pkUser.xxxx |
| | | * @return 部门的显示对象 |
| | | */ |
| | | @Override |
| | | public OrgDepartmentVO listDeptByUserOid(String userOid, |
| | | public List<OrgDepartmentVO> listDeptByUserOid(String userOid, |
| | | Map<String, String> queryMap) { |
| | | List<OrgDepartmentVO> departmentVOS = listDeptByUserOid(userOid, queryMap, false); |
| | | if(CollectionUtils.isEmpty(departmentVOS)){ |
| | | return null; |
| | | return new ArrayList<>(); |
| | | } |
| | | return departmentVOS.get(0); |
| | | return departmentVOS; |
| | | } |
| | | |
| | | /** |
| | | * 获取未关联某个用户的部门 |
| | | * @param userOid 用户主键 |
| | |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | if(!CollectionUtils.isEmpty(cbos)){ |
| | | cbos.stream().forEach(cbo->{ |
| | | String userOid = ObjectTool.getBOAttributeValue(cbo,"pluseruid"); |
| | | String userOid = ObjectTool.getNewBOAttributeValue(cbo,"pluseruid"); |
| | | List<String> deptOids = userDeptOidMap.getOrDefault(userOid,new ArrayList<>()); |
| | | deptOids.add(ObjectTool.getBOAttributeValue(cbo,"pldeptuid")); |
| | | deptOids.add(ObjectTool.getNewBOAttributeValue(cbo,"pldeptuid")); |
| | | userDeptOidMap.put(userOid,deptOids); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | if(!CollectionUtils.isEmpty(deptVOList)){ |
| | | Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | //这儿应该对deptVOList做一次去重处理,因为肯定会有重复的部门被查出来 |
| | | Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream() |
| | | .collect(Collectors.toMap(OrgDepartmentVO::getOid, Function.identity(), (existing, replacement) -> existing)); |
| | | //Map<String, OrgDepartmentVO> deptVOMap = deptVOList.stream().distinct().collect(Collectors.toMap(s -> s.getOid(), t -> t)); |
| | | Map<String, List<OrgDepartmentVO>> userDeptVOMap = new HashMap<>(); |
| | | userDeptOidMap.forEach((userOid,deptOids)->{ |
| | | List<OrgDepartmentVO> deptVOS = new ArrayList<>(); |
| | |
| | | } |
| | | return new HashMap<>(); |
| | | } |
| | | |
| | | /** |
| | | * 获取某个部门的直属下级部门 |
| | | * @param pkFatherDepartmment 部门的主键 |
| | |
| | | List<OrgDeptForPlatform1> depts = boService.selectByQueryWrapper(queryWrapperForDO, OrgDeptForPlatform1.class); |
| | | return deptDO2VOs(depts); |
| | | } |
| | | |
| | | /** |
| | | * 获取某个部门的所有层级的下级部门 |
| | | * @param pkFatherDepartmment 部门的主键 |
| | |
| | | queryWrapperForDO.in("pluid","select pluid from pldept start with " + (StringUtils.isBlank(pkFatherDepartmment)?" (plparentuid is null or plparentuid = '') ":"plparentuid = '" + pkFatherDepartmment.trim() + "'") + "connect by PRIOR pluid=plparentuid"); |
| | | return deptDO2VOs(boService.selectByQueryWrapper(queryWrapperForDO, OrgDeptForPlatform1.class)); |
| | | } |
| | | |
| | | /** |
| | | * 参照树形数据的部门信息 |
| | | * @param treeQueryObject 树形查询的条件 |
| | |
| | | return dept.getId() + " " + dept.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equals(dept.getLcStatus())?"【停用】":""); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 参照树形表格的部门信息,上级部门的是表格中的树形列 |
| | | * @param treeQueryObject 树形查询的条件 |
| | |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * 保存部门角色关联信息,带查重功能 |
| | | * @param userOIds 用户id |
| | | * @param deptId 部门id |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveUsersDept(String[] userOIds, String deptId) throws PLException { |
| | | if(Func.isEmpty(userOIds) || Func.isBlank(deptId)){ |
| | | return false; |
| | | } |
| | | //先进性查重处理 |
| | | List<String> repeatUserOidList = new ArrayList<>(); |
| | | //循环进行查重,避免in大于1000 |
| | | WebUtil.switchCollectionForOracleIn(Arrays.asList(userOIds)).stream().forEach(userOId->{ |
| | | String sql = "select pluseruid,pldeptuid from pluserdept where pldeptuid = '" + deptId |
| | | + "' and " + "pluseruid in ("+WebUtil.toInSql(userOId.toArray(new String[0]))+")"; |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | if(!CollectionUtils.isEmpty(cbos)){ |
| | | cbos.stream().forEach(cbo->{ |
| | | repeatUserOidList.add(ObjectTool.getNewBOAttributeValue(cbo,"pluseruid")); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | //从即将要执行保存的用户oid中移除当前用户已经存在关联关系的oid |
| | | //移除重复的 |
| | | List<String> tempList = new ArrayList<>(Arrays.asList(userOIds)); |
| | | tempList.removeAll(repeatUserOidList); |
| | | userOIds = tempList.toArray(new String[tempList.size()]); |
| | | if(Func.isNotEmpty(userOIds)){ |
| | | platformClientUtil.getFrameworkService().saveUserDept(userOIds, deptId,null); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |