| | |
| | | import com.vci.ubcs.starter.web.util.VciBaseUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | |
| | | oidValues.add(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField(s, doObject))); |
| | | }); |
| | | tree.setOid((String)oidValues.stream().collect(Collectors.joining(wrapperOptions.getOidValueSep()))); |
| | | tree.setName((String) VciBaseUtil.getValueFromField("name", doObject)); |
| | | if (f != null) { |
| | | tree.setText((String)f.apply(doObject)); |
| | | } else { |
| | |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(wrapperOptions.getParentFieldName())) { |
| | | tree.setParentId(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField(wrapperOptions.getParentFieldName(), doObject))); |
| | | String stringValueFromObject = VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField(wrapperOptions.getParentFieldName(), doObject)); |
| | | tree.setParentId(stringValueFromObject); |
| | | } |
| | | |
| | | if (wrapperOptions.isAllAttributes()) { |
| | |
| | | } |
| | | } |
| | | |
| | | public <T, R> List<Tree> doListSystemClassTrees(List<T> doList, TreeWrapperOptions wrapperOptions, Function<T, R> f) { |
| | | if (CollectionUtils.isEmpty(doList)) { |
| | | return new ArrayList(); |
| | | } else { |
| | | List<Tree> allTree = new ArrayList(); |
| | | List<Tree> children = new ArrayList(); |
| | | Iterator var6 = doList.iterator(); |
| | | |
| | | while(true) { |
| | | while(var6.hasNext()) { |
| | | T doObject = (T) var6.next(); |
| | | Tree tree = new Tree(); |
| | | List<String> oidFieldNames = VciBaseUtil.str2List(wrapperOptions.getOidFieldName()); |
| | | List<String> oidValues = new LinkedList(); |
| | | oidFieldNames.stream().forEach((s) -> { |
| | | oidValues.add(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField("oid", doObject))); |
| | | }); |
| | | tree.setOid((String)oidValues.stream().collect(Collectors.joining(wrapperOptions.getOidValueSep()))); |
| | | tree.setName((String) VciBaseUtil.getValueFromField("name", doObject)); |
| | | if (f != null) { |
| | | tree.setText((String)f.apply(doObject)); |
| | | } else { |
| | | List<String> textFieldNames = VciBaseUtil.str2List(wrapperOptions.getTextFieldName()); |
| | | List<String> textValues = new LinkedList(); |
| | | textFieldNames.stream().forEach((s) -> { |
| | | textValues.add(VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField(s, doObject))); |
| | | }); |
| | | tree.setText((String)textValues.stream().collect(Collectors.joining(wrapperOptions.getTextValueSep()))); |
| | | } |
| | | |
| | | if (StringUtils.isNotBlank(wrapperOptions.getParentFieldName())) { |
| | | String stringValueFromObject = VciBaseUtil.getStringValueFromObject(VciBaseUtil.getValueFromField(wrapperOptions.getParentFieldName(), doObject)); |
| | | tree.setParentId(stringValueFromObject); |
| | | } |
| | | |
| | | if (wrapperOptions.isAllAttributes()) { |
| | | try { |
| | | tree.setAttributes(VciBaseUtil.objectToMapString(doObject)); |
| | | } catch (Exception var13) { |
| | | if (this.logger.isErrorEnabled()) { |
| | | this.logger.error("把对象转换为map时出现了错误,但是不影响树的展示,对业务可能有影响"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (wrapperOptions.isMultipleSelect() || wrapperOptions.isShowCheckBox()) { |
| | | tree.setShowCheckbox(true); |
| | | } |
| | | |
| | | if (wrapperOptions.getParentOid() == null) { |
| | | wrapperOptions.setParentOid(""); |
| | | } |
| | | |
| | | if (!StringUtils.isBlank(tree.getParentId()) && (!StringUtils.isNotBlank(wrapperOptions.getParentOid()) || !wrapperOptions.getParentOid().equalsIgnoreCase(tree.getParentId()))) { |
| | | children.add(tree); |
| | | } else { |
| | | allTree.add(tree); |
| | | } |
| | | } |
| | | |
| | | (new Tree()).findSystemClassChild(allTree, children); |
| | | if (allTree.size() <= 0) { |
| | | allTree.addAll(children); |
| | | } |
| | | |
| | | return allTree; |
| | | } |
| | | } |
| | | } |
| | | // |
| | | // public void findSystemClassChild(List<Tree> treenode, List<Tree> children) { |
| | | // Tree node; |
| | | // for(Iterator var3 = treenode.iterator(); var3.hasNext(); { |
| | | // if (var3 == null) { |
| | | // var3.next(); |
| | | // } else { |
| | | // ((Tree) var3.next()).getChildren().add(node); |
| | | // } |
| | | // }) { |
| | | // node = (Tree)var3.next(); |
| | | // Iterator var5 = children.iterator(); |
| | | // |
| | | // while(var5.hasNext()) { |
| | | // Tree childnode = (Tree)var5.next(); |
| | | // if (node.getAttributes().get("classifyOid").equalsIgnoreCase(childnode.getParentId())) { |
| | | // childnode.setParentName(node.getText()); |
| | | // if (StringUtil.isBlank(childnode.getParentBtmName())) { |
| | | // childnode.setParentBtmName((String)node.getAttributes().getOrDefault("btmname", "")); |
| | | // } |
| | | // |
| | | // node.getChildren().add(childnode); |
| | | // } |
| | | // } |
| | | // |
| | | // if (node.getChildren().size() > 0) { |
| | | // this.findSystemClassChild(node.getChildren(), children); |
| | | // node.setLeaf(false); |
| | | // } else { |
| | | // node.setLeaf(true); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | } |