From f0b8a8d9966d0ccbb23ee8baaedf4ff8ba6060ed Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 08 八月 2024 18:15:42 +0800
Subject: [PATCH] 业务类型新增、修改、删除、查看使用范围、创建视图、一致性检查、一致性检查修复、删除数据、删除数据界面查询、删除全部类型接口上传。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java |  112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java
index febe978..bd33e47 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLinkTypeServiceImpl.java
@@ -12,6 +12,7 @@
 import com.vci.corba.omd.ltm.LinkType;
 import com.vci.corba.omd.ltm.LinkTypeServicePrx;
 import com.vci.dto.OsAttributeDTO;
+import com.vci.omd.constants.AttributeConstants;
 import com.vci.omd.constants.LinkTypeConstants;
 import com.vci.omd.utils.ObjectTool;
 import com.vci.pagemodel.*;
@@ -23,6 +24,7 @@
 import com.vci.starter.poi.constant.ExcelLangCodeConstant;
 import com.vci.starter.poi.util.ExcelUtil;
 import com.vci.starter.web.annotation.log.VciUnLog;
+import com.vci.starter.web.enumpck.ResultCodeEnum;
 import com.vci.starter.web.enumpck.VciFieldTypeEnum;
 import com.vci.starter.web.exception.VciBaseException;
 import com.vci.starter.web.pagemodel.BaseQueryObject;
@@ -46,7 +48,10 @@
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -443,7 +448,9 @@
             returnData.put("btmCheckMap",btmCheckMap);
             List<Map> list = new ArrayList<>();
             list.add(returnData);
-            return BaseResult.dataList(500,list,"闇�瑕佽繘琛屽垪鐨勪慨澶嶏紒锛�");
+            BaseResult<List<Map>> listBaseResult = BaseResult.dataList(200, list, "闇�瑕佽繘琛屽垪鐨勪慨澶嶏紒锛�");
+            listBaseResult.setSuccess(false);
+            return listBaseResult;
         }
     }
 
@@ -559,7 +566,7 @@
             ExcelUtil.writeDataToFile(excelPath, excelOption);
             //瀵煎嚭灞炴��
             String attrPath = attributeService.exportAttributes("attr",
-                    String.valueOf(attributes.stream().collect(Collectors.joining(","))));
+                    String.valueOf(attributes.stream().collect(Collectors.joining(","))),true);
             //绉诲姩灞炴�у埌閾炬帴绫诲瀷鏂囦欢澶归噷闈㈠幓
             FileUtil.move(new File(attrPath), new File(defaultTempFolder),true);
             FileUtil.del(attrPath.substring(0,attrPath.lastIndexOf("\\")));
@@ -688,6 +695,62 @@
         //鍒犻櫎涓婁紶鐨勬枃浠跺す
         FileUtil.del(defaultTempFolder + File.separator);
         return BaseResult.success("閾炬帴绫诲瀷瀵煎叆鎴愬姛锛�");
+    }
+    /**
+     * 鑾峰彇閾炬帴绫诲瀷鍖呭惈鐨勫睘鎬�
+     * @param name 閾炬帴绫诲瀷鐨勭紪鍙�
+     * @return 灞炴�х殑淇℃伅
+     */
+    @Override
+    public List<OsLinkTypeAttributeVO> getAllAttributeByLink(String name) throws PLException, ParseException {
+        AttributeDef[] attributes = platformClientUtil.getLinkTypeService().getAttributes(name);
+        Map<String, AttributeDef> collect = Arrays.stream(platformClientUtil.getLinkTypeService().getSysAttributeDefs())
+                .collect(Collectors.toMap(str -> str.name, str -> str));
+
+        List<OsLinkTypeAttributeVO> links = new ArrayList<>();
+        String[] sysAttibutes = { "OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID",
+                "F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" };
+        for (String sysname : sysAttibutes) {
+            AttributeDef sysAttributeDef = collect.get(sysname.toLowerCase());
+            OsLinkTypeAttributeVO vo = new OsLinkTypeAttributeVO();
+            vo.setOid(sysAttributeDef.oid);
+            vo.setAttrDataType(sysAttributeDef.vtDataType);
+            vo.setPkLinkType(name);
+            vo.setCreateTime(new Date(sysAttributeDef.createTime));
+            vo.setCreator(sysAttributeDef.creator);
+            vo.setDefaultValue(sysAttributeDef.defValue);
+            vo.setDescription(sysAttributeDef.description);
+            vo.setRange(sysAttributeDef.rage);
+            vo.setId(sysname);
+            vo.setName(sysAttributeDef.label);
+            vo.setLastModifier(sysAttributeDef.modifier);
+            vo.setLastModifyTime(new Date(sysAttributeDef.modifyTime));
+            links.add(vo);
+        }
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        for (AttributeDef attribute : attributes) {
+            OsLinkTypeAttributeVO vo = new OsLinkTypeAttributeVO();
+            vo.setOid(attribute.oid);
+            vo.setAttrDataType(attribute.vtDataType);
+            vo.setPkLinkType(name);
+            vo.setCreateTime(new Date(attribute.createTime));
+            vo.setCreator(attribute.creator);
+            vo.setDefaultValue(attribute.defValue);
+            vo.setDescription(attribute.description);
+            vo.setRange(attribute.rage);
+            vo.setId(attribute.name);
+            vo.setName(attribute.label);
+            vo.setTs(formatter.parse(attribute.ts));
+            vo.setLastModifier(attribute.modifier);
+            vo.setOwner(attribute.creator);
+            vo.setLastModifyTime(new Date(attribute.modifyTime));
+            String maxLength = AttributeConstants.getOtherValueByType(attribute.other, AttributeConstants.LENGTH);
+            if(StringUtils.isNotBlank(maxLength)){
+                vo.setAttributeLength(Integer.valueOf(maxLength));
+            }
+            links.add(vo);
+        }
+        return links;
     }
 
     /**
@@ -925,4 +988,49 @@
         return null;
     }
 
+    /**
+     * 鑾峰彇浣跨敤璇ヤ笟鍔$被鍨嬬殑閾炬帴绫诲瀷鍚�
+     * @param btmName 涓氬姟绫诲瀷鍚嶇О
+     * @return
+     */
+    @Override
+    public List<String> getUsedBtmLinkList(String btmName) {
+        try {
+            List<String> list = new ArrayList<String>();
+            LinkType[] linkTypes = platformClientUtil.getLinkTypeService().getLinkTypes();
+            for(int i = 0; i < linkTypes.length; i++){
+                LinkType linkType = linkTypes[i];
+                if(this.containsBtm(linkType, btmName)){
+                    list.add(linkType.name);
+                }
+            }
+            return list;
+        } catch (PLException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 鎸囧畾鐨勯摼鎺ョ被鍨嬫槸鍚︿娇鐢ㄤ簡鎸囧畾鐨勪笟鍔$被鍨�
+     * @param link
+     * @param btmName
+     * @return
+     */
+    private boolean containsBtm(LinkType link, String btmName){
+        String[] btms = link.btmItemsFrom;
+        for(int i = 0; i < btms.length; i++){
+            if(btmName.equalsIgnoreCase(btms[i])){
+                return true;
+            }
+        }
+        btms = link.btmItemsTo;
+        for(int i = 0; i < btms.length; i++){
+            if(btmName.equalsIgnoreCase(btms[i])){
+                return true;
+            }
+        }
+        return false;
+    }
+
 }

--
Gitblit v1.9.3