From 99bac1ebecd5adf552835c9fe084b0dd3f0a25b7 Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期三, 17 七月 2024 16:43:27 +0800
Subject: [PATCH] 增加、修改、删除链接接口的修改

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/DeleteTypeEnum.java         |   96 ++++++++++++++++++++++++++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIDataServiceImpl.java |   29 +++++----
 2 files changed, 111 insertions(+), 14 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/DeleteTypeEnum.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/DeleteTypeEnum.java
new file mode 100644
index 0000000..edc8955
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/enumpck/DeleteTypeEnum.java
@@ -0,0 +1,96 @@
+package com.vci.web.enumpck;
+/**
+ * 骞冲彴鍒犻櫎鎺ュ彛鏋氫妇
+ * @author yuxc
+ * @date 2024-7-17
+ */
+public enum DeleteTypeEnum {
+    /**
+     * 涓婚敭涓庢搷浣滄椂闂�
+     */
+    OID_AND_TS(1,"涓婚敭涓庢搷浣滄椂闂�"),
+
+    /**
+     * 鐗堟湰涓婚敭
+     */
+    REVISIONOID(2,"鐗堟湰涓婚敭"),
+
+    /**
+     * 鍚嶇О涓婚敭
+     */
+    NAMEOID(3,"鍚嶇О涓婚敭");
+
+    /**
+     * 鍊�
+     */
+    private Integer value;
+
+    /**
+     * 鏄剧ず鏂囨湰
+     */
+    private String text;
+
+    public Integer getValue() {
+        return value;
+    }
+
+
+    public String getText() {
+        return text;
+    }
+
+    public void setValue(Integer value) {
+        this.value = value;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+
+    private DeleteTypeEnum(Integer value, String text){
+        this.value = value;
+        this.text = text;
+    }
+
+    /**
+     * 鏍规嵁鍚嶇О鑾峰彇瀵瑰簲鐨勬灇涓惧��
+     * @param text 鍚嶇О
+     * @return 鏋氫妇鍊�
+     */
+    public static Integer getValueByText(String text){
+        for(DeleteTypeEnum wenum : DeleteTypeEnum.values()){
+            if(wenum.getText().equalsIgnoreCase(text)){
+                return wenum.getValue();
+            }
+        }
+        return 1;
+    }
+
+    /**
+     * 鏍规嵁鏋氫妇鍊艰幏鍙栧悕绉�
+     * @param value 鏋氫妇鍊�
+     * @return 鍚嶇О
+     */
+    public static String getTextByValue(Integer value){
+        for(DeleteTypeEnum wenum : DeleteTypeEnum.values()){
+            if(wenum.getValue() == value){
+                return wenum.getText();
+            }
+        }
+        return "";
+    }
+
+    /**
+     * 鍊艰浆鎹负鏋氫妇瀵硅薄
+     * @param value 鍊�
+     * @return 濡傛灉涓嶇鍚堣姹傝繑鍥濶ull
+     */
+    public static DeleteTypeEnum forValue(Integer value){
+        for(DeleteTypeEnum wenum : DeleteTypeEnum.values()){
+            if(wenum.getValue() == value){
+                return wenum;
+            }
+        }
+        return DeleteTypeEnum.OID_AND_TS;
+    }
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIDataServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIDataServiceImpl.java
index 6ba98e7..f2ea563 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIDataServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIDataServiceImpl.java
@@ -21,6 +21,7 @@
 import com.vci.starter.web.pagemodel.*;
 import com.vci.starter.web.util.*;
 import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
+import com.vci.web.enumpck.DeleteTypeEnum;
 import com.vci.web.enumpck.UIFieldTypeEnum;
 import com.vci.web.enumpck.UITreeLoadTypeEnum;
 import com.vci.web.query.UIDataGridQuery;
@@ -1363,7 +1364,7 @@
         }catch (Throwable e){
             //璇存槑鍚庣疆浜嬩欢鍑虹幇浜嗛敊璇紝閭d箞灏遍渶瑕佸垹闄や互鍓嶇殑杩欐潯鏁版嵁
             try {
-                platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(afterBOs.toArray(new BusinessObject[0]),1);
+                platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(afterBOs.toArray(new BusinessObject[0]),DeleteTypeEnum.OID_AND_TS.getValue());
             } catch (PLException vciError) {
                 throw WebUtil.getVciBaseException(vciError);
             }
@@ -1683,13 +1684,6 @@
             throw new VciBaseException(formLinkDataDTO.isDirection()?"from绔�":"to绔�" + "鐨勪笟鍔$被鍨嬩负绌�");
         }
 
-        //鏌ヨfrom绔殑
-        BusinessObject fromCbo = new BusinessObject();
-        try {
-            fromCbo = platformClientUtil.getBOFService().readBusinessObject(fromOid,fromBtmName);
-        } catch (PLException vciError) {
-            throw WebUtil.getVciBaseException(vciError);
-        }
         String finalPrefix = prefix;
         formLinkDataDTO.getData().forEach((key, value)->{
             if(key.toLowerCase().startsWith(finalPrefix)){
@@ -1710,10 +1704,12 @@
             return BaseResult.fail(resultClo.getMsg(),resultClo.getMsgObjs());
         }
         clo = resultClo.getObj();
+        if(StringUtils.isBlank(clo.toOid)){
+            clo.toOid = toCbo.oid;
+        }
         //鎵ц淇濆瓨
         BusinessObject[] bos = new BusinessObject[1];
         ObjectTool.dealBusinessObjectNullValue(toCbo);
-        ObjectTool.dealLinkObjectNullValue(clo);
         bos[0] = toCbo;
         try {
             platformClientUtil.getBOFService().createBusinessObjectWithLink(bos,clo);
@@ -1768,7 +1764,6 @@
         if(editFlag){
             try {
                 LinkObject linkObject = platformClientUtil.getBOFService().readLinkObjectById(formLinkDataDTO.getOid(), formLinkDataDTO.getLinkType());
-                clo = new LinkObject();
                 clo = linkObject;
             } catch (PLException vciError) {
                 throw WebUtil.getVciBaseException(vciError);
@@ -1781,6 +1776,14 @@
             clo.createTime = System.currentTimeMillis();
             clo.ts = System.currentTimeMillis();
             clo.ltName = formLinkDataDTO.getLinkType();
+            clo.toOid = formLinkDataDTO.getToid();
+            clo.toNameOid = formLinkDataDTO.getTnameoid();
+            clo.toRevOid = formLinkDataDTO.getTrevisionoid();
+            clo.toBTName = formLinkDataDTO.getTbtmname();
+            clo.fromOid = formLinkDataDTO.getFoid();
+            clo.fromBTName = formLinkDataDTO.getFbtmname();
+            clo.fromNameOid = formLinkDataDTO.getFnameoid();
+            clo.fromRevOid = formLinkDataDTO.getFrevisionoid();
         }
         //
         LinkObject finalClo = clo;
@@ -2157,8 +2160,6 @@
         String prefix = formLinkDataDTO.isDirection()?LO_FROM_PREFIX:LO_TO_PREFIX;
         String toOid = formLinkDataDTO.isDirection()?formLinkDataDTO.getFoid():formLinkDataDTO.getToid();
         String toBtmName =  formLinkDataDTO.isDirection()?formLinkDataDTO.getFbtmname():formLinkDataDTO.getTbtmname();
-        String fromOid = formLinkDataDTO.isDirection()?formLinkDataDTO.getToid():formLinkDataDTO.getFoid();
-        String fromBtmName = formLinkDataDTO.isDirection()?formLinkDataDTO.getTbtmname():formLinkDataDTO.getFbtmname();
 
         Map<String,String> boData = new HashMap<>();
         Map<String,String> loData = new HashMap<>();
@@ -2295,7 +2296,7 @@
         if(deleteLinkDataDTO.isDeleteFromData()){
             fromBtmDataGroups.forEach((btm,cbos)->{
                 try{
-                    platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]),1);
+                    platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]), DeleteTypeEnum.OID_AND_TS.getValue());
                 }catch (PLException vciError) {
                     throw WebUtil.getVciBaseException(vciError);
                 }
@@ -2304,7 +2305,7 @@
         if(deleteLinkDataDTO.isDeleteToData()){
             toBtmDataGroups.forEach((btm,cbos)->{
                 try{
-                    platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]),1);
+                    platformClientUtil.getBOFactoryService().batchDeleteBusinessObject(cbos.toArray(new BusinessObject[0]),DeleteTypeEnum.OID_AND_TS.getValue());
                 }catch (PLException vciError) {
                     throw WebUtil.getVciBaseException(vciError);
                 }

--
Gitblit v1.9.3