Merge remote-tracking branch 'origin/master'
| | |
| | | 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; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | public void findSystemClassChild(List<Tree> treenode, List<Tree> children) { |
| | | Tree node; |
| | | for(Iterator var3 = treenode.iterator(); var3.hasNext(); this.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); |
| | | } |
| | | } |
| | | |
| | | } |
| | | @Override |
| | | public String toString() { |
| | | return "Tree{oid='" + this.oid + '\'' + ", text='" + this.text + '\'' + ", leaf=" + this.leaf + ", showCheckbox=" + this.showCheckbox + ", checked=" + this.checked + ", children=" + this.children + ", icon='" + this.icon + '\'' + ", iconCls='" + this.iconCls + '\'' + ", parentId='" + this.parentId + '\'' + ", parentName='" + this.parentName + '\'' + ", parentBtmName='" + this.parentBtmName + '\'' + ", expanded=" + this.expanded + ", href='" + this.href + '\'' + ", index='" + this.index + '\'' + ", attributes=" + this.attributes + '}'; |
| | |
| | | package com.vci.ubcs.code.controller; |
| | | |
| | | |
| | | import com.vci.ubcs.code.dto.CodeClassifyTemplateAttrDTO; |
| | | import com.vci.ubcs.code.entity.SystemClassifyRole; |
| | | import com.vci.ubcs.code.service.ICodeApplyWebManagementService; |
| | | import com.vci.ubcs.code.service.ICodeClassifyService; |
| | | import com.vci.ubcs.starter.web.pagemodel.Tree; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 主é¢åºå®ä¹è¡¨ æ§å¶å¨ |
| | |
| | | * åç±»æå¡å¯¹è±¡ |
| | | */ |
| | | private final ICodeClassifyService codeClassifyService; |
| | | |
| | | private final ICodeApplyWebManagementService codeApplyWebManagementService; |
| | | |
| | | /*** |
| | | * æ ¹æ®åç«¯éæ©çåç±»æéææææ |
| | |
| | | return R.success("æ¥è¯¢æå"); |
| | | } |
| | | |
| | | @PostMapping( "/batchAddSave") |
| | | public R batchAddSave(@RequestBody List<SystemClassifyRole> list,String systemOid,String systemId){ |
| | | return codeApplyWebManagementService.batchAddSave(list,systemOid,systemId); |
| | | } |
| | | |
| | | @GetMapping("/getSystemClassifyRoleTree") |
| | | public List<Tree> getSystemClassifyRoleTree(String systemOid,String systemId){ |
| | | return codeApplyWebManagementService.getSystemClassifyRoleTree(systemOid,systemId); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.vci.ubcs.code.entity.SystemClassifyRole; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface SystemClassifyRoleMapper extends BaseMapper<SystemClassifyRole> { |
| | | public List<SystemClassifyRole> getListSystemClassifyRole(String systemOid, String systemId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.vci.ubcs.code.entity.SystemClassifyRole; |
| | | import com.vci.ubcs.starter.web.pagemodel.Tree; |
| | | import org.springblade.core.tool.api.R; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface ICodeApplyWebManagementService extends IService<SystemClassifyRole> { |
| | | R batchAddSave(List<SystemClassifyRole> list,String systemOid,String systemId); |
| | | |
| | | List<Tree> getSystemClassifyRoleTree(String systemOid, String systemId); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.code.entity.SystemClassifyRole; |
| | | import com.vci.ubcs.code.enumpack.FrameworkDataLCStatus; |
| | | import com.vci.ubcs.code.mapper.SystemClassifyRoleMapper; |
| | | import com.vci.ubcs.code.service.ICodeApplyWebManagementService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO; |
| | | import com.vci.ubcs.starter.revision.model.TreeWrapperOptions; |
| | | import com.vci.ubcs.starter.revision.service.RevisionModelUtil; |
| | | import com.vci.ubcs.starter.util.DefaultAttrAssimtUtil; |
| | | import com.vci.ubcs.starter.web.pagemodel.Tree; |
| | | import jodd.util.StringUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class CodeApplyWebManagementServiceImpl extends ServiceImpl<SystemClassifyRoleMapper, SystemClassifyRole> implements ICodeApplyWebManagementService { |
| | | |
| | | /** |
| | | * ä¸çº§èç¹ç屿§åç§° |
| | | */ |
| | | public static final String PARENT_FIELD_NAME = "classParentOid"; |
| | | |
| | | /** |
| | | * 对象çæä½ |
| | | */ |
| | | @Resource |
| | | private RevisionModelUtil revisionModelUtil; |
| | | |
| | | |
| | | @Override |
| | | public R batchAddSave(List<SystemClassifyRole> roleList,String systemOid,String systemId) { |
| | | if(roleList.size() == 0){ |
| | | return R.fail("ä¼ å
¥æ°æ®ä¸ºç©ºï¼è¯·ç¡®è®¤ï¼ï¼"); |
| | | } |
| | | //å
å é¤ï¼åä¿å |
| | | QueryWrapper<SystemClassifyRole> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("systemOid",systemOid); |
| | | wrapper.eq("systemId",systemId); |
| | | this.remove(wrapper); |
| | | //æ°æ®å¤ç |
| | | roleList.stream().forEach(systemClassifyRole -> { |
| | | if(StringUtil.isBlank(systemClassifyRole.getOid())){ |
| | | DefaultAttrAssimtUtil.addDefaultAttrAssimt(systemClassifyRole,"systemClassifyRole"); |
| | | systemClassifyRole.setSystemId(systemId); |
| | | systemClassifyRole.setSystemOid(systemOid); |
| | | }else{ |
| | | systemClassifyRole.setCreator(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | systemClassifyRole.setCreateTime(new Date()); |
| | | systemClassifyRole.setLastModifier(String.valueOf(AuthUtil.getUser().getUserId())); |
| | | systemClassifyRole.setLastModifyTime(new Date()); |
| | | systemClassifyRole.setTs(new Date()); |
| | | } |
| | | systemClassifyRole.setTenantId(AuthUtil.getTenantId()); |
| | | }); |
| | | //ä¿å |
| | | this.saveBatch(roleList); |
| | | return R.success("æä½æå"); |
| | | } |
| | | |
| | | @Override |
| | | public List<Tree> getSystemClassifyRoleTree(String systemOid, String systemId) { |
| | | List<SystemClassifyRole> listSystemClassifyRole = baseMapper.getListSystemClassifyRole(systemOid, systemId); |
| | | TreeWrapperOptions treeWrapperOptions = new TreeWrapperOptions(PARENT_FIELD_NAME); |
| | | treeWrapperOptions.setOidFieldName("CLASSIFYOID"); |
| | | List<Tree> tree= revisionModelUtil.doListSystemClassTrees(listSystemClassifyRole,treeWrapperOptions,(SystemClassifyRole s) ->{ |
| | | //å¯ä»¥å¨è¿éå¤çæ èç¹çæ¾ç¤º |
| | | return s.getClassifyId() + " " + s.getName() + (FrameworkDataLCStatus.DISABLED.getValue().equalsIgnoreCase(s |
| | | .getLcStatus()) ? (" ãåç¨ã ") : ""); |
| | | }); |
| | | return tree; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.vci.ubcs.code.mapper.SystemClassifyRoleMapper"> |
| | | <!-- éç¨æ¥è¯¢æ å°ç»æ --> |
| | | <resultMap id="plSystemClassifyRoleMap" type="com.vci.ubcs.code.entity.SystemClassifyRole"> |
| | | <result column="OID" property="oid"/> |
| | | <result column="REVISIONOID" property="revisionOid"/> |
| | | <result column="NAMEOID" property="nameOid"/> |
| | | <result column="BTMNAME" property="btmname"/> |
| | | <result column="LASTR" property="lastR"/> |
| | | <result column="FIRSTR" property="firstR"/> |
| | | <result column="LASTV" property="lastV"/> |
| | | <result column="FIRSTV" property="firstV"/> |
| | | <result column="CREATOR" property="creator"/> |
| | | <result column="CREATETIME" property="createTime"/> |
| | | <result column="LASTMODIFIER" property="lastModifier"/> |
| | | <result column="LASTMODIFYTIME" property="lastModifyTime"/> |
| | | <result column="REVISIONRULE" property="revisionRule"/> |
| | | <result column="VERSIONRULE" property="versionRule"/> |
| | | <result column="REVISIONSEQ" property="revisionSeq"/> |
| | | <result column="REVISIONVALUE" property="revisionValue"/> |
| | | <result column="VERSIONSEQ" property="versionSeq"/> |
| | | <result column="VERSIONVALUE" property="versionValue"/> |
| | | <result column="LCTID" property="lctid"/> |
| | | <result column="LCSTATUS" property="lcStatus"/> |
| | | <result column="TS" property="ts"/> |
| | | <result column="ID" property="id"/> |
| | | <result column="NAME" property="name"/> |
| | | <result column="DESCRIPTION" property="description"/> |
| | | <result column="OWNER" property="owner"/> |
| | | <result column="COPYFROMVERSION" property="copyFromVersion"/> |
| | | <result column="TENANT_ID" property="tenantId"/> |
| | | <result column="SYSTEMOID" property="systemOid"/> |
| | | <result column="SYSTEMID" property="systemId"/> |
| | | <result column="CLASSIFYOID" property="classifyOid"/> |
| | | <result column="CLASSIFYID" property="classifyId"/> |
| | | <result column="SELECTED" property="selected"/> |
| | | <result column="CLASSPARENTOID" property="classParentOid"/> |
| | | </resultMap> |
| | | <select id="getListSystemClassifyRole" resultType="com.vci.ubcs.code.entity.SystemClassifyRole"> |
| | | select pc.OID, |
| | | pc.REVISIONOID, |
| | | pc.NAMEOID, |
| | | pc.BTMNAME, |
| | | pc.LASTR, |
| | | pc.FIRSTR, |
| | | pc.LASTV, |
| | | pc.FIRSTV, |
| | | pc.CREATOR, |
| | | pc.CREATETIME, |
| | | pc.LASTMODIFIER, |
| | | pc.LASTMODIFYTIME, |
| | | pc.REVISIONRULE, |
| | | pc.VERSIONRULE, |
| | | pc.REVISIONSEQ, |
| | | pc.REVISIONVALUE, |
| | | pc.VERSIONSEQ, |
| | | pc.VERSIONVALUE, |
| | | pc.LCTID, |
| | | pc.LCSTATUS, |
| | | pc.TS, |
| | | pc.ID, |
| | | p.NAME, |
| | | pc.DESCRIPTION, |
| | | pc.OWNER, |
| | | pc.COPYFROMVERSION, |
| | | pc.GROUPCODE, |
| | | pc.TENANT_ID, |
| | | pc.SYSTEMOID, |
| | | pc.SYSTEMID, |
| | | p.oid CLASSIFYOID, |
| | | p.id CLASSIFYID, |
| | | case when pc.selected is null then 'false' else pc.SELECTED end SELECTED, |
| | | p.PARENTCODECLASSIFYOID CLASSPARENTOID |
| | | from PL_CODE_CLASSIFY p , |
| | | PL_CODE_SYSTEM_CLASSIFY_ROLE pc |
| | | where p.oid = pc.CLASSIFYOID(+) |
| | | and '${systemOid}' = pc.SYSTEMOID(+) |
| | | and '${systemId}' = pc.SYSTEMID(+) |
| | | </select> |
| | | |
| | | </mapper> |