From e937d0111a52e2c13c50bbc3386d20a12d125899 Mon Sep 17 00:00:00 2001
From: wangting <675591594@qq.com>
Date: 星期五, 06 九月 2024 10:54:54 +0800
Subject: [PATCH] 链接类型查询模板
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java | 186 ++++++++++++++++++++++++++++++++--------------
1 files changed, 129 insertions(+), 57 deletions(-)
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java
index 79a32e7..5b993f0 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java
@@ -16,9 +16,7 @@
import com.vci.corba.omd.ltm.LinkType;
import com.vci.corba.omd.qtm.QTD;
import com.vci.corba.omd.qtm.QTInfo;
-import com.vci.dto.AttributeDefDTO;
-import com.vci.dto.QTDDTO;
-import com.vci.dto.QTInfoDTO;
+import com.vci.dto.*;
import com.vci.omd.constants.SystemAttribute;
import com.vci.omd.objects.OtherInfo;
import com.vci.po.OsLinkTypePO;
@@ -196,6 +194,9 @@
VciBaseUtil.alertNotNull(btName,"绫诲瀷鍚�");
QTInfo[] objTypeQTs = platformClientUtil.getQTDService().getObjTypeQTs(btName);
List<QTInfoDTO> dtos = new ArrayList<>();
+ Map<String, AttributeDef> allSysAttr = Arrays.stream(platformClientUtil.getBtmService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e));
+ allSysAttr.putAll(Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e)));
+
for (QTInfo obj : objTypeQTs) {
QTInfoDTO qtInfoDTO = new QTInfoDTO();
qtInfoDTO.setCreator(obj.creator);
@@ -206,13 +207,84 @@
qtInfoDTO.setQtUIText(obj.qtUIText);
if(StringUtils.isNotBlank(obj.qtUIText)){
//灏嗙粰瀹氱殑String鏂囨湰瑙f瀽涓篨ML鏂囨。骞惰繑鍥炴柊鍒涘缓鐨刣ocument
- qtInfoDTO.setTree(analysisXml(obj));
+ qtInfoDTO.setTree(analysisXml(obj, allSysAttr));
}
- qtInfoDTO.setQueryTemplate(OQTool.getQTByDoc(DocumentHelper.parseText(obj.qtText), obj.qtName));
+ QueryTemplate qtByDoc = OQTool.getQTByDoc(DocumentHelper.parseText(obj.qtText), obj.qtName);
+ qtInfoDTO.setQueryTemplate(queryTemplateToDto(qtByDoc, allSysAttr));
qtInfoDTO.setCreateTimeText(DateFormatUtils.format(new Date(obj.createTime), DateUtil.PATTERN_DATETIME));
dtos.add(qtInfoDTO);
}
return BaseResult.dataList(dtos);
+ }
+
+ /**
+ * 瀵硅薄杞崲
+ * @param qtByDoc 妯℃澘瀵硅薄
+ * @param allSysAttr 鎵�鏈夌郴缁熷睘鎬�
+ * @return 妯℃澘浼犺緭瀵硅薄
+ * @throws PLException
+ */
+ private QueryTemplateDTO queryTemplateToDto(QueryTemplate qtByDoc, Map<String, AttributeDef> allSysAttr) throws PLException {
+ QueryTemplateDTO dto = new QueryTemplateDTO();
+ dto.setId(qtByDoc.getId());
+ dto.setBtmType(qtByDoc.getBtmType());
+ dto.setDirection(qtByDoc.getDirection());
+ dto.setLevel(qtByDoc.getLevel());
+ dto.setQueryChildrenFlag(qtByDoc.isQueryChildren());
+ dto.setQueryISLeaf(qtByDoc.isQueryISLeaf());
+ dto.setClauseList(qtByDoc.getClauseList());
+ dto.setPageInfo(qtByDoc.getPageInfo());
+ dto.setLinkType(qtByDoc.getLinkType());
+ dto.setVersion(qtByDoc.getVersion());
+ dto.setType(qtByDoc.getType());
+ dto.setSecretFlag(qtByDoc.isSecretFlag());
+ dto.setRightFlag(qtByDoc.isRightFlag());
+ dto.setOrderInfoList(qtByDoc.getOrderInfoList());
+ dto.setRecReturnMode(qtByDoc.getRecReturnMode());
+ Condition con = qtByDoc.getCondition();
+ if(con != null){
+ ConditionDTO conDto = new ConditionDTO();
+ conDto.setRootCIName(con.getRootCIName());
+ Map<String, ConditionItem> ciMap = con.getCIMap();
+ Map<String, ConditionItemDTO> ciMapDto = new HashMap<>();
+ for (String key : ciMap.keySet()) {
+ ConditionItem item = ciMap.get(key);
+ LeafInfo leafInfo = item.getLeafInfo();
+ ConditionItemDTO itemDTO = new ConditionItemDTO();
+ itemDTO.setChildrenInfo(item.getChildrenInfo());
+ itemDTO.setId(item.getId());
+ itemDTO.setLeafFlag(item.isLeaf());
+ ciMapDto.put(key, itemDTO);
+ if(leafInfo == null){
+ continue;
+ }
+ LeafInfoDTO leafInfoDTO = new LeafInfoDTO();
+ itemDTO.setLeafInfo(leafInfoDTO);
+ //澶勭悊鏌ヨ瀛楁绫诲瀷
+ String column = leafInfo.getClause();
+ if(column.contains(".")){
+ column = StringUtils.substringAfterLast(column, ".");
+ }
+ AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(column);
+ if(att == null || "".equals(att.oid)){
+ att = allSysAttr.get(column.toLowerCase());
+ }
+ leafInfoDTO.setClause(leafInfo.getClause());
+
+ leafInfoDTO.setOperator(leafInfo.getOperator());
+ leafInfoDTO.setType(att.vtDataType);
+ if(leafInfo.getValue() != null ){
+ LeafValueDto valueDto = new LeafValueDto();
+ valueDto.setOrdinaryValue(leafInfo.getValue().getOrdinaryValue());
+ valueDto.setQueryTemplate(leafInfo.getValue().getQueryTemplate() != null ? queryTemplateToDto(leafInfo.getValue().getQueryTemplate(),allSysAttr) : null);
+ leafInfoDTO.setValue(valueDto);
+ }
+
+ }
+ conDto.setCIMap(ciMapDto);
+ dto.setCondition(conDto);
+ }
+ return dto;
}
/**
@@ -221,14 +293,13 @@
* @return
* @throws DocumentException
*/
- private HashMap<String,Object> analysisXml(QTInfo obj) throws DocumentException {
+ private HashMap<String,Object> analysisXml(QTInfo obj, Map<String, AttributeDef> allSysAttr) throws DocumentException, PLException {
org.dom4j.Document document = DocumentHelper.parseText(obj.qtUIText);
if(document == null){
return null;
}
//鑾峰彇鏍硅妭鐐�,鍦ㄤ緥瀛愪腑灏辨槸responsedata鑺傜偣
Element root = document.getRootElement();
- List<HashMap<String,Object>> treeList = new ArrayList<>();
HashMap<String,Object> treeMap = new HashMap<>();
treeMap.put("connector",root.getText());
List<Element> children = root.elements();
@@ -236,9 +307,20 @@
for(Iterator<Element> i = children.iterator(); i.hasNext();){
Element child = i.next();
if(AND.equals(child.getText()) || OR.equals(child.getText())){
- childList.add(addDefaultMutableTree(child));
+ childList.add(addDefaultMutableTree(child, allSysAttr));
}else {
- childList.add(child.getText().trim());
+ String column = StringUtils.substringBefore(child.getText().trim(), " ");
+
+ if(column.contains(".")){
+ column = StringUtils.substringAfterLast(column, ".");
+ }
+ AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(column);
+ if(att == null || "".equals(att.oid)){
+ att = allSysAttr.get(column.toLowerCase());
+ }
+ HashMap<String, String> data = new HashMap<>();
+ data.put("column",child.getText().trim());
+ data.put("type",att.vtDataType);
}
}
treeMap.put("child",childList);
@@ -249,7 +331,7 @@
* 灏嗗瓙鑺傜偣杞负map缁撴瀯
* @param element
*/
- public Map<String, Object> addDefaultMutableTree(Element element){
+ public Map<String, Object> addDefaultMutableTree(Element element, Map<String, AttributeDef> allSysAttr) throws PLException {
List<Object> childList = new ArrayList<>();
List<Element> children = element.elements();
HashMap<String,Object> treeMap = new HashMap<>();
@@ -257,9 +339,21 @@
for(Iterator<Element> i = children.iterator(); i.hasNext();){
Element child = i.next();
if(AND.equals(child.getText()) || OR.equals(child.getText())){
- childList.add(addDefaultMutableTree(child));
+ childList.add(addDefaultMutableTree(child, allSysAttr));
}else {
- childList.add(child.getText().trim());
+ String column = StringUtils.substringBefore(child.getText().trim(), " ");
+
+ if(column.contains(".")){
+ column = StringUtils.substringAfterLast(column, ".");
+ }
+ AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(column);
+ if(att == null || "".equals(att.oid)){
+ att = allSysAttr.get(column.toLowerCase());
+ }
+ HashMap<String, String> data = new HashMap<>();
+ data.put("column",child.getText().trim());
+ data.put("type",att.vtDataType);
+ childList.add(data);
}
}
treeMap.put("child",childList);
@@ -1571,51 +1665,27 @@
tree.put("children", childList);
return BaseResult.success(tree);
}
-
+ /**
+ * 鏌ヨ妯℃澘鐨勫垪琛ㄦ坊鍔犱簡瀛楁鐨勭浉鍏冲睘鎬�
+ * @param btmName 绫诲瀷
+ * @param linkFlag 鏄惁閾炬帴绫诲瀷 锛歵rue 閾炬帴绫诲瀷 锛宖alse 涓氬姟绫诲瀷
+ * @param direction 姝e弽鏂瑰悜
+ * @return 鏌ヨ妯℃澘鐨勫垪琛�
+ */
@Override
public BaseResult queryTemplateListByAttr(String btmName, Boolean linkFlag, String direction) throws PLException {
//杩斿洖鐨勭晫闈笅鎷夋鏄剧ず鏍�
List<QTDDTO> qtddtos = new ArrayList<>();
-
+ //灏嗛摼鎺ョ被鍨嬩笌涓氬姟绫诲瀷鐨勬墍鏈夐粯璁ゅ瓧娈垫煡璇㈠嚭鏉ユ斁鍒癿ap閲岄潰鏂逛究鍚庣画璋冪敤
Map<String, AttributeDef> allSysAttr = Arrays.stream(platformClientUtil.getBtmService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e));
-
-// if(linkFlag){
-// QTD[] qtdArray = platformClientUtil.getQTDService().getLinkTypeQTDs(btmName);
-// for (QTD qtd : qtdArray) {
-// QTDDTO qtddto = new QTDDTO();
-// qtddto.setName(qtd.name);
-// qtddto.setCreateTime(qtd.createTime);
-// qtddto.setLinkTypeName(qtd.linkTypeName);
-// qtddto.setBtmName(qtd.btmName);
-// qtddto.setCreator(qtd.creator);
-// for (String abName : qtd.abNames) {
-// AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(abName);
-// AttributeDefDTO attrDto = new AttributeDefDTO();
-// attrDto.setDescription(att.description);
-// attrDto.setLabel(att.label);
-// attrDto.setOid(att.oid);
-// attrDto.setCreator(att.creator);
-// attrDto.setName(att.name);
-// attrDto.setDefValue(att.defValue);
-// attrDto.setRage(att.rage);
-// attrDto.setVtDataType(att.vtDataType);
-// attrDto.setOther(att.other);
-// qtddto.getAttrs().add(attrDto);
-// }
-// qtddtos.add(qtddto);
-// }
-//
-// }else {
-// Map<String, AttributeDef> lSysAttr = Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e));
allSysAttr.putAll(Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs()).collect(Collectors.toMap(e -> e.name, e -> e)));
QTD[] qtdArray = null;
+ //鏌ヨ鐩稿叧绫诲瀷鐨勬煡璇㈡ā鏉胯繘琛屽鐞�
if(linkFlag){
qtdArray = platformClientUtil.getQTDService().getLinkTypeQTDs(btmName);
}else {
qtdArray = platformClientUtil.getQTDService().getBizTypeQTDs(btmName);
}
-
-// QTD[]
for (QTD qtd : qtdArray) {
QTDDTO qtddto = new QTDDTO();
qtddto.setName(qtd.name);
@@ -1625,13 +1695,20 @@
qtddto.setCreator(qtd.creator);
for (String abName : qtd.abNames) {
AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(abName);
+ //濡傛灉鍦ㄥ睘鎬ф帴鍙d腑娌℃湁鏌ュ埌鐩稿叧瀛楁搴旇灏卞湪榛樿瀛楁涓�
if(att == null || "".equals(att.oid)){
att = allSysAttr.get(abName.toLowerCase());
}
if(direction != null) {
if (direction.equals(QTConstants.DIRECTION_POSITIVE)) {
+ if(att == null ){
+ throw new PLException("500",new String[]{"灞炴�у瓧娈�:"+ abName +"鏈煡璇㈠埌锛岃纭锛�"});
+ }
att.name = "T_OID." + abName;
} else if (direction.equals(QTConstants.DIRECTION_OPPOSITE)) {
+ if(att == null ){
+ throw new PLException("500",new String[]{"灞炴�у瓧娈�:"+ abName +"鏈煡璇㈠埌锛岃纭锛�"});
+ }
att.name = "F_OID." + abName;
}
}else{
@@ -1653,9 +1730,14 @@
}
qtddtos.add(qtddto);
}
-// }
- return BaseResult.dataList(Arrays.asList(qtddtos));
+ return BaseResult.dataList(qtddtos);
}
+
+ /**
+ * 瀛愯妭鐐瑰鐞�
+ * @param attributeDefByName 鐖惰妭鐐圭殑灞炴�т俊鎭�
+ * @param allSysAttr 鎵�鏈夐粯璁ゅ瓧娈�
+ */
private void addNode(AttributeDefDTO attributeDefByName, Map<String, AttributeDef> allSysAttr){
if(attributeDefByName.getLayersNum() >= 3){
@@ -1666,7 +1748,6 @@
if(abName.contains(".")){
abName = abName.substring(abName.lastIndexOf(".") + 1);
}
-// qtddto.getAttrs().add(attributeDefByName);
if(SystemAttribute.sysAttList().contains(abName.toUpperCase())){
return;
}
@@ -1706,10 +1787,7 @@
addNode(attrDto, allSysAttr);
}
//绯荤粺灞炴�D,NAME,DESCRIPTION
-// AttributeDef[] sysAttributeDefs = platformClientUtil.getBtmService().getSysAttributeDefs();
-// for (int i = 0; i < sysAttributeDefs.length; i++) {
for (int i = 0; i < SystemAttribute.bosysAttList().size(); i++) {
-// addNode(node, new DefaultMutableTreeNode(pName + SystemAttribute.bosysAttList().get(i)));
AttributeDef attributeDef = allSysAttr.get(SystemAttribute.bosysAttList().get(i).toLowerCase());
AttributeDefDTO attrDto = new AttributeDefDTO();
attrDto.setDescription(attributeDef.description);
@@ -1743,7 +1821,6 @@
String[] abNames = link.attributes;
for(int i = 0; i < abNames.length; i++){
String abName_ = abNames[i];
-// DefaultMutableTreeNode node_ = new DefaultMutableTreeNode(pName + abName_);
AttributeDef att = platformClientUtil.getAttributeService().getAttributeDefByName(abName_);
if(att == null || att.oid.equals("")){
att = allSysAttr.get(abName_.toLowerCase());
@@ -1764,11 +1841,6 @@
}
//绯荤粺灞炴�D,NAME,DESCRIPTION
for (int i = 0; i < SystemAttribute.losysAttList().size(); i++) {
-// addNode(node, new DefaultMutableTreeNode(pName + SystemAttribute.losysAttList().get(i)));
-// }
-// AttributeDef[] sysAttributeDefs = platformClientUtil.getLinkTypeService().getSysAttributeDefs();
-// for (int i = 0; i < sysAttributeDefs.length; i++) {
-// addNode(node, new DefaultMutableTreeNode(pName + SystemAttribute.bosysAttList().get(i)));
AttributeDef sysAttributeDefs = allSysAttr.get(SystemAttribute.losysAttList().get(i).toLowerCase());
AttributeDefDTO attrDto = new AttributeDefDTO();
attrDto.setDescription(sysAttributeDefs.description);
--
Gitblit v1.9.3