| | |
| | | import com.vci.ubcs.starter.web.util.LangBaseUtil; |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.dto.ClassifyAuthDTO; |
| | | import com.vci.ubcs.system.feign.ISysClient; |
| | | import org.apache.poi.hssf.util.HSSFColor; |
| | | import org.slf4j.Logger; |
| | |
| | | import java.io.File; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static com.vci.ubcs.code.constant.FrameWorkDefaultValueConstant.*; |
| | | import static com.vci.ubcs.starter.web.util.VciBaseUtil.getTableName; |
| | | |
| | | @Service |
| | | public class CodeClassifyServiceImpl extends ServiceImpl<CodeClassifyMapper, CodeClassify> implements ICodeClassifyService { |
| | |
| | | |
| | | @Resource |
| | | private CodeBasicSecMapper codeBasicSecMapper; |
| | | |
| | | /** |
| | | * 上级节点的属性名称 |
| | | */ |
| | | public static final String PARENT_FIELD_NAME = "parentCodeClassifyOid"; |
| | | |
| | | /** |
| | | * 使用查询封装器来查询 |
| | | * @param wrapper 查询封装器 |
| | |
| | | * @param |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R addSave(CodeClassify codeClassifyEntity) { |
| | | try { |
| | | VciBaseUtil.alertNotNull(codeClassifyEntity.getId(),"主题库编号不能为空!",codeClassifyEntity.getName(),"主题库名称不能为空!"); |
| | |
| | | } |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(codeClassifyEntity, MdmBtmTypeConstant.CODE_CLASSIFY); |
| | | codeClassifyEntity.setLcStatus(FRAMEWORK_DATA_ENABLED); |
| | | int insertNumber = codeClassifyMapper.insert(codeClassifyEntity); |
| | | return R.status(SqlHelper.retBool(insertNumber)); |
| | | boolean resBoolean = SqlHelper.retBool(codeClassifyMapper.insert(codeClassifyEntity)); |
| | | if (!resBoolean) { |
| | | return R.status(resBoolean); |
| | | } |
| | | // 分类添加成功,给系统管理员和当前角色增加分类权限和数据权限 |
| | | ClassifyAuthDTO classifyAuthDTO = new ClassifyAuthDTO(); |
| | | classifyAuthDTO.setClassifyId(codeClassifyEntity.getOid()); |
| | | // classifyAuthDTO.setClassId(codeClassifyEntity.getId()); |
| | | R r = sysClient.saveAddClassifyDefaultAuth(classifyAuthDTO); |
| | | if (!r.isSuccess()) { |
| | | throw new ServiceException("给角色授予默认权限时出现错误,原因:"+r.getMsg()); |
| | | } |
| | | return R.status(resBoolean); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | if(StringUtils.isNotBlank(id) || StringUtils.isNotBlank(lcStatus) ){ |
| | | //String tableName = this.getTableName(treeQueryObject.getConditionMap().get("btmTypeId"),treeQueryObject.getConditionMap().get("id"), treeQueryObject.getConditionMap().get("lcStatus")); |
| | | // TODO: 2024-1-24 23:25我去掉了懒加载,因为会影响数据授权过滤和分类搜索功能,而且这儿感觉没必要做懒加载 |
| | | doList = codeClassifyMapper |
| | | .selectCodeClassifyDOByTree( |
| | | treeQueryObject.getConditionMap().get("id"), |
| | |
| | | List<CodeClassifyVO> voList = codeClassifyDO2VOs(doList); |
| | | TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_FIELD_NAME); |
| | | treeWrapperOptions.copyFromTreeQuery(treeQueryObject); |
| | | List<Tree> tree= revisionModelUtil.doList2Trees(voList,treeWrapperOptions,(CodeClassifyVO s) ->{ |
| | | List<Tree> tree = revisionModelUtil.doList2Trees(voList,treeWrapperOptions,(CodeClassifyVO s) ->{ |
| | | //可以在这里处理树节点的显示 |
| | | return s.getId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s |
| | | .getLcStatus()) ? (" 【停用】 ") : ""); |
| | | }); |
| | | //超管显示所有分类 |
| | | if(VciBaseUtil.checkAdminTenant()){ |
| | | Iterator var6 = tree.listIterator(); |
| | | while(var6.hasNext()){ |
| | | Tree trees = (Tree) var6.next(); |
| | | boolean checkHasChild=codeClassifyMapper.checkHasChild(trees.getOid()); |
| | | if(checkHasChild){ |
| | | trees.setLeaf(false); |
| | | }else{ |
| | | trees.setLeaf(true); |
| | | } |
| | | } |
| | | }else { |
| | | // 非超管过滤未授权的分类 |
| | | if(!VciBaseUtil.checkAdminTenant()){ |
| | | // 那些分类具备查看权限 |
| | | R<List<String>> viewClassByRoleIds = sysClient.getViewClassByRoleIds(Arrays.asList(AuthUtil.getUser().getRoleId().split(",")),treeQueryObject.getConditionMap().getOrDefault("authType","classify_auth"),treeQueryObject.getConditionMap().getOrDefault("menuCode","classify_view")); |
| | | R<List<String>> viewClassByRoleIds = sysClient.getViewClassByRoleIds( |
| | | Arrays.asList(AuthUtil.getUser().getRoleId().split(",")), |
| | | treeQueryObject.getConditionMap().getOrDefault("authType","classify_auth"), |
| | | treeQueryObject.getConditionMap().getOrDefault("buttonCode","classify_view"), |
| | | treeQueryObject.getConditionMap().getOrDefault("menuCode","classifyTree") |
| | | ); |
| | | // 请求失败或者请求得到的具备查看权限的分类id集合为空 |
| | | if(!viewClassByRoleIds.isSuccess() && viewClassByRoleIds.getData().isEmpty()){ |
| | | throw new ServiceException("主数据查看权限未配置,或配置有误!"); |
| | |
| | | // 过滤 |
| | | filterTreeNodes(tree,viewClassByRoleIds.getData()); |
| | | } |
| | | // 加载分类是否具有子分类 |
| | | tree.parallelStream().forEach(item -> { |
| | | boolean checkHasChild = checkHasChild(item.getOid()); |
| | | item.setLeaf(!checkHasChild); |
| | | }); |
| | | return tree; |
| | | } |
| | | |
| | |
| | | Iterator<Tree> iterator = trees.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Tree tree = iterator.next(); |
| | | Boolean checkHasChild = codeClassifyMapper.checkHasChild(tree.getOid()); |
| | | tree.setLeaf(!checkHasChild); |
| | | /*Boolean checkHasChild = checkHasChild(tree.getOid()); |
| | | tree.setLeaf(!checkHasChild);*/ |
| | | if (classifyIds.contains(tree.getOid())) { |
| | | // 如果顶层节点存在于 classifyIds 中,直接保留其子节点集合 |
| | | // 如果顶层节点存在 classifyIds ,直接保留其子节点集合 |
| | | continue; |
| | | } |
| | | if (tree.getChildren() != null && !tree.getChildren().isEmpty()) { |
| | |
| | | String oids = codeClassifies.stream() |
| | | .map(CodeClassify::getOid) |
| | | .map(s -> "'" + s + "'") |
| | | .collect(Collectors.joining(","));; |
| | | return oids; |
| | | } |
| | | |
| | | /** |
| | | * 根据顶层节点oid查询所有叶子节点分类oid |
| | | * @param pid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public String selectLeafByPid(String pid) { |
| | | List<CodeClassify> codeClassifies = codeClassifyMapper.selectLeafByPid(pid); |
| | | if(codeClassifies.isEmpty()){ |
| | | return ""; |
| | | } |
| | | String oids = codeClassifies.stream() |
| | | .map(CodeClassify::getOid) |
| | | .map(s ->s) |
| | | .collect(Collectors.joining(","));; |
| | | return oids; |
| | | } |
| | |
| | | if(!CollectionUtils.isEmpty(dataList)){ |
| | | for(Map data:dataList){ |
| | | CodeClassify codeClassifyDO = new CodeClassify(); |
| | | codeClassifyDO.setOid(VciBaseUtil.getStringValueFromObject(data.get("OID"))); |
| | | codeClassifyDO.setId(VciBaseUtil.getStringValueFromObject(data.get("ID"))); |
| | | codeClassifyDO.setName(VciBaseUtil.getStringValueFromObject(data.get("NAME"))); |
| | | codeClassifyDO.setBtmTypeId(VciBaseUtil.getStringValueFromObject(data.get("BTMTYPEID"))); |
| | | codeClassifyDO.setBtmTypeName(VciBaseUtil.getStringValueFromObject(data.get("BTMTYPENAME"))); |
| | | codeClassifyDO.setOid(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getMapValueIgnoreCase(data,"OID"))); |
| | | codeClassifyDO.setId(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getMapValueIgnoreCase(data,"ID"))); |
| | | codeClassifyDO.setName(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getMapValueIgnoreCase(data,"NAME"))); |
| | | codeClassifyDO.setBtmTypeId(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getMapValueIgnoreCase(data,"BTMTYPEID"))); |
| | | codeClassifyDO.setBtmTypeName(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getMapValueIgnoreCase(data,"BTMTYPENAME"))); |
| | | oidList.add(codeClassifyDO); |
| | | } |
| | | } |
| | |
| | | wrapper.eq("parentCodeClassifyOid",codeClassifyOid); |
| | | return codeClassifyMapper.selectCount(wrapper).intValue(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |