From b47493e37a857208c47d1421edcad81260c734ce Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 02 六月 2023 17:29:05 +0800
Subject: [PATCH] 修改树参照的懒加载
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java | 109 +++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 83 insertions(+), 26 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
index 5bc3366..1ed0304 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/CodeClassifyServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
@@ -18,12 +19,15 @@
import com.vci.ubcs.code.po.CodeClassifyPO;
import com.vci.ubcs.code.service.ICodeClassifyService;
import com.vci.ubcs.code.service.ICodeKeyAttrRepeatService;
+import com.vci.ubcs.code.service.ICodeOsattributeService;
import com.vci.ubcs.code.service.ICodeRuleService;
import com.vci.ubcs.code.vo.CodeOsattributeVO;
import com.vci.ubcs.code.vo.CodeOsbtmtypeVO;
import com.vci.ubcs.code.vo.pagemodel.CodeClassifyVO;
import com.vci.ubcs.code.vo.pagemodel.CodeKeyAttrRepeatRuleVO;
import com.vci.ubcs.code.vo.pagemodel.CodeRuleVO;
+import com.vci.ubcs.omd.feign.IBtmTypeClient;
+import com.vci.ubcs.omd.vo.BtmTypeVO;
import com.vci.ubcs.starter.bo.WriteExcelData;
import com.vci.ubcs.starter.exception.VciBaseException;
import com.vci.ubcs.starter.poi.bo.ReadExcelOption;
@@ -33,6 +37,7 @@
import com.vci.ubcs.starter.revision.model.TreeQueryObject;
import com.vci.ubcs.starter.revision.model.TreeWrapperOptions;
import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
+import com.vci.ubcs.starter.util.BladeTreeQueryObject;
import com.vci.ubcs.starter.util.LocalFileUtil;
import com.vci.ubcs.starter.web.pagemodel.BaseQueryObject;
import com.vci.ubcs.starter.web.pagemodel.DataGrid;
@@ -44,11 +49,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.cache.utils.CacheUtil;
+import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -73,10 +81,18 @@
@Resource
private CodeOsbtmtypeMapper codeOsbtmtypeMapper;
+
@Resource
- CodeOsbtmtypeattributeMapper codeOsbtmtypeattributeMapper;
+ private CodeOsbtmtypeattributeMapper codeOsbtmtypeattributeMapper;
+
@Resource
- ICodeRuleService ICodeRuleService;
+ private IBtmTypeClient btmTypeClient;
+
+ /**
+ * 灞炴�ф湇鍔�
+ */
+// @Autowired
+// private OsAttributeServiceI attributeService;
/**
* 鏃ュ織
@@ -254,9 +270,8 @@
if(StringUtils.isBlank(oid)){
throw new ServiceException("oid涓嶈兘涓虹┖锛�");
}
- return !codeClassifyMapper.checkHasChild(oid.trim());
+ return codeClassifyMapper.checkHasChild(oid.trim());
}
-
/**
* 鍒犻櫎涓婚搴撳垎绫�
@@ -362,7 +377,6 @@
return codeClassifyDO2VOs(codeClassifyDOList);
}
-
/**
* 浣跨敤涓婚敭闆嗗悎鏌ヨ鏁版嵁瀵硅薄
* @param oidCollections 涓婚敭鐨勯泦鍚�
@@ -381,7 +395,6 @@
}
return codeClassifyList;
}
-
/**
* 鎵归噺鏁版嵁瀵硅薄杞崲涓烘樉绀哄璞�
@@ -468,6 +481,19 @@
}
return tree;
}
+
+ /**
+ * 鏍规嵁鏍戝舰鏌ヨ瀵硅薄鏉ユ煡璇㈡暟鎹璞�
+ *
+ * @param treeQueryObject 鏍戝舰鏌ヨ瀵硅薄
+ * @return 鏌ヨ缁撴灉,鏁版嵁瀵硅薄
+ */
+ @Override
+ public List<CodeClassifyVO> selectCodeClassifyDOByTree(TreeQueryObject treeQueryObject) {
+ List<CodeClassify> doList =codeClassifyMapper.selectCodeClassifyVOByTree(treeQueryObject.getParentOid());
+ List<CodeClassifyVO> voList = codeClassifyDO2VOs(doList);
+ return voList;
+ }
/**
* 浣跨敤缂栧彿鐨勮矾寰勮幏鍙栧璞�
*
@@ -476,9 +502,12 @@
*/
@Override
public CodeClassifyVO getObjectByClsfNamePath(String fieldPath){
-
- CodeClassify classify = (CodeClassify) codeClassifyMapper.selectByFieldNamePath(fieldPath, "name");
- return codeClassifyDO2VO(classify);
+ CodeClassifyVO codeClassifyVO=new CodeClassifyVO();
+ List<CodeClassify> classifyList = codeClassifyMapper.selectByFieldNamePath(fieldPath,"name");
+ if(classifyList.size()>0){
+ codeClassifyVO=codeClassifyDO2VO(classifyList.get(0));
+ }
+ return codeClassifyVO;
}
/***
* 鏍规嵁涓婄骇鑺傜偣鑾峰彇涓嬬骇鑺傜偣浠e彿璺緞鍜屽悕绉拌矾寰�
@@ -491,8 +520,7 @@
return null;
}
-
-// /**
+ // /**
// * 鏍规嵁鏍戝舰鏌ヨ瀵硅薄鏉ユ煡璇㈡暟鎹璞�
// *
// * @param treeQueryObject 鏍戝舰鏌ヨ瀵硅薄
@@ -882,7 +910,7 @@
condition.put("pkbtmtype",topClassifyVO.getBtmtypeid());
List<CodeOsbtmtypeattributeEntity> unDefaultAttributes = codeOsbtmtypeattributeMapper.selectByMap(condition);
-// List<OsBtmTypeAttributeVO> unDefaultAttributes = btmService. (topClassifyVO.getBtmtypeid());
+ // List<OsBtmTypeAttributeVO> unDefaultAttributes = btmService. (topClassifyVO.getBtmtypeid());
List<CodeOsattributeVO> attributeVOS = new ArrayList<>();
if(!CollectionUtils.isEmpty(unDefaultAttributes)){
unDefaultAttributes.stream().forEach(attr->{
@@ -892,6 +920,7 @@
attributeVO.setAttrlength(Short.valueOf(attr.getAttributelength()));
attributeVO.setBtmtypeid(attr.getReferbtmtypeid());
attributeVO.setBtmtypename(attr.getReferbtmtypename());
+ attributeVO.setAttributedatatypetext(attr.getReferbtmtypename());
boolean add = true;
if(StringUtils.isNotBlank(id) && !attributeVO.getId().contains(id.replace("*",""))){
add = false;
@@ -904,8 +933,8 @@
}
});
}
-// if(!CollectionUtils.isEmpty(attributeService.getDefaultAttributeVOs())){
-// attributeService.getDefaultAttributeVOs().stream().forEach(attr->{
+// if(!CollectionUtils.isEmpty(codeOsattributeService.getDefaultAttributeVOs())){
+// codeOsattributeService.getDefaultAttributeVOs().stream().forEach(attr->{
// boolean add = true;
// if(StringUtils.isNotBlank(id) && !attr.getId().contains(id.replace("*",""))){
// add = false;
@@ -983,7 +1012,7 @@
* @throws VciBaseException 鍙傛暟涓虹┖锛屾暟鎹笉瀛樺湪鏃朵細鎶涘嚭寮傚父
*/
@Override
- public CodeClassifyVO getObjectByOid(String oid) throws VciBaseException{
+ public CodeClassifyVO getObjectByOid(String oid) throws VciBaseException{
return codeClassifyDO2VO(selectByOid(oid));
}
@@ -1004,7 +1033,7 @@
}
/**
- * 涓婚搴撶殑鏍�
+ * 涓婚搴撶殑鏍�,宸茬粡鑱旇皟涓氬姟绫诲瀷鏌ヨ
*
* @param treeQueryObject 鏍戝舰鏌ヨ瀵硅薄
* @return 涓婚搴撴樉绀烘爲
@@ -1015,10 +1044,20 @@
treeQueryObject = new TreeQueryObject();
}
if(treeQueryObject.getConditionMap() == null){
- treeQueryObject.setConditionMap(new HashMap<>());
+ treeQueryObject.setConditionMap(new HashMap<String,String>());
}
treeQueryObject.getConditionMap().put(PARENT_FIELD_NAME, "=null");
- return treeCodeClassify(treeQueryObject);
+ List<Tree> trees = treeCodeClassify(treeQueryObject);
+ treeQueryObject.getConditionMap().put("domain", AppConstant.APPLICATION_NAME_CODE);
+ BaseQueryObject baseQueryObject = new BaseQueryObject();
+ baseQueryObject.setConditionMap(treeQueryObject.getConditionMap());
+ List<BtmTypeVO> btmTypeVOS = btmTypeClient.getRef(baseQueryObject).getData();
+ if(Func.isEmpty(btmTypeVOS) || Func.isEmpty(trees)){
+ return null;
+ }
+ List<Tree> treeList = trees.stream().filter(tree -> btmTypeVOS.stream().
+ anyMatch(btmType -> Objects.equals(tree.getAttributes().get("id"), btmType.getId()))).collect(Collectors.toList());
+ return treeList;
}
/**
@@ -1072,18 +1111,36 @@
CodeClassify classifyDO = selectByOid(codeClassifyOid);
//鏌ヨ涓婄骇
fullInfo.setCurrentClassifyVO(codeClassifyDO2VO(classifyDO));
- List<Map<String, Object>> maps = codeClassifyMapper.selectAllLevelParentByOid(codeClassifyOid);
- List<CodeClassify> codeClassifyList = new ArrayList<>();
- for (Map<String, Object> map : maps) {
- CodeClassify codeClassify = new CodeClassify();
- codeClassify.setOid(String.valueOf(map.get("OID")));
- codeClassify.setOid(String.valueOf(map.get("LEVEL")));
- codeClassifyList.add(codeClassify);
- }
+// List<Map<String, Object>> maps = codeClassifyMapper.selectAllLevelParentByOid(codeClassifyOid);
+// List<Map<String, Object>> maps = selectAllLevelParentByOid(codeClassifyOid);
+ List<CodeClassify> codeClassifyList = selectAllLevelParentByOid(codeClassifyOid);
+// for (Map<String, Object> map : maps) {
+// CodeClassify codeClassify = new CodeClassify();
+// codeClassify.setOid(String.valueOf(map.get("OID")));
+// codeClassify.setDataLevel((Integer) map.get("LEVEL"));
+// codeClassifyList.add(codeClassify);
+// }
+
fullInfo.setParentClassifyVOs(codeClassifyDO2VOs(codeClassifyList));
if(!CollectionUtils.isEmpty(fullInfo.getParentClassifyVOs())){
fullInfo.setTopClassifyVO(fullInfo.getParentClassifyVOs().stream().filter(s->StringUtils.isBlank(s.getParentcodeclassifyoid())).findFirst().orElseGet(()->null));
}
return fullInfo;
}
+
+ /**
+ * 缁熻瀛愯妭鐐圭殑涓暟
+ *
+ * @param codeClassifyOid 鍒嗙被鐨勪富閿�
+ * @return 涓暟
+ */
+ @Override
+ public int countChildrenByClassifyOid(String codeClassifyOid) {
+// Map<String,String> conditionMap = new HashMap<>();
+// conditionMap.put("parentCodeClassifyOid",codeClassifyOid);
+ QueryWrapper<CodeClassify> wrapper = new QueryWrapper<>();
+ wrapper.eq("parentCodeClassifyOid",codeClassifyOid);
+ return codeClassifyMapper.selectCount(wrapper).intValue();
+ }
+
}
--
Gitblit v1.9.3