| | |
| | | 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.*; |
| | |
| | | */ |
| | | @Autowired |
| | | private WebBoServiceI boService; |
| | | |
| | | /** |
| | | * 平台调用客户端 |
| | | */ |
| | | @Autowired |
| | | private PlatformClientUtil platformClientUtil; |
| | | |
| | | /** |
| | | * 对象操作工具类 |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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; |
| | | } |
| | | |
| | | /** |
| | |
| | | return dataGrid; |
| | | } |
| | | |
| | | /** |
| | | * 保存部门角色关联信息,带查重功能 |
| | | * @param userId 用户id |
| | | * @param deptIds 部门id |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean saveUserDepts(String userId, List<String> deptIds) throws PLException { |
| | | if(Func.isBlank(userId) || Func.isEmpty(deptIds)){ |
| | | return false; |
| | | } |
| | | List<String> repeatDeptOidList = new ArrayList<>(); |
| | | //循环进行查重,避免in大于1000 |
| | | WebUtil.switchCollectionForOracleIn(deptIds).stream().forEach(deptoids->{ |
| | | String sql = "select pluseruid,pldeptuid from pluserdept where pluseruid = " + userId |
| | | + " and " + "pldeptuid in ("+WebUtil.toInSql(deptoids.toArray(new String[0]))+")"; |
| | | List<BusinessObject> cbos = boService.queryBySql(sql, null); |
| | | if(!CollectionUtils.isEmpty(cbos)){ |
| | | cbos.stream().forEach(cbo->{ |
| | | repeatDeptOidList.add(ObjectTool.getNewBOAttributeValue(cbo,"pldeptuid")); |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | //从即将要执行保存的部门oid中移除当前用户已经存在关联关系的的部门oid |
| | | deptIds.removeAll(repeatDeptOidList); |
| | | if(Func.isNotEmpty(deptIds)){ |
| | | for (String deptId : deptIds){ |
| | | platformClientUtil.getFrameworkService().saveUserDept(new String[]{userId}, deptId,null); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | } |