From 7d7b42822d9a11f8fa107fc3bbbbd518f0a7ef91 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期六, 09 十一月 2024 01:17:28 +0800
Subject: [PATCH] 1、修复系统功能模块-》管理功能模块修改是否有效功能修改无效问题。 2、Action管理,Action分类删除报错问题修改。

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIDataServiceImpl.java |  184 +++++++++++++++++++++++++++++++++------------
 1 files changed, 135 insertions(+), 49 deletions(-)

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 f5d358d..30f044b 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
@@ -1,16 +1,14 @@
 package com.vci.web.service.impl;
 
-import com.vci.client.common.providers.ClientServiceProvider;
 import com.vci.corba.common.PLException;
-import com.vci.corba.omd.data.BusinessObject;
-import com.vci.corba.omd.data.LinkObject;
-import com.vci.corba.omd.data.RevisionDataInfo;
-import com.vci.corba.omd.data.VersionDataInfo;
+import com.vci.corba.framework.data.UserInfo;
+import com.vci.corba.omd.data.*;
 import com.vci.corba.omd.lcm.LifeCycle;
-import com.vci.file.pagemodel.VciFileObjectVO;
+import com.vci.dto.*;
 import com.vci.frameworkcore.lcstatuspck.FrameworkDataLCStatus;
 import com.vci.frameworkcore.lcstatuspck.ReleaseDataLCStatus;
 import com.vci.omd.utils.ObjectTool;
+import com.vci.pagemodel.*;
 import com.vci.starter.revision.bo.TreeWrapperOptions;
 import com.vci.starter.web.annotation.bus.VciChangeDataAfter;
 import com.vci.starter.web.annotation.bus.VciChangeDataBefore;
@@ -23,10 +21,9 @@
 import com.vci.starter.web.pagemodel.*;
 import com.vci.starter.web.util.*;
 import com.vci.starter.web.wrapper.VciQueryWrapperForDO;
-import com.vci.web.dto.*;
+import com.vci.web.enumpck.DeleteTypeEnum;
 import com.vci.web.enumpck.UIFieldTypeEnum;
 import com.vci.web.enumpck.UITreeLoadTypeEnum;
-import com.vci.web.pageModel.*;
 import com.vci.web.query.UIDataGridQuery;
 import com.vci.web.query.UIFormQuery;
 import com.vci.web.query.UILinkTypeDataQuery;
@@ -37,13 +34,15 @@
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.lang.reflect.Method;
 import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST;
+import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_OID_NOT_EXIST;
+
 
 /**
  * UI涓婄殑鏁版嵁鏌ヨ
@@ -70,6 +69,11 @@
      */
     @Autowired
     private OsBtmServiceI btmService;
+    /**
+     * 灞炴�ф湇鍔�
+     */
+    @Autowired
+    private OsAttributeServiceI attrService;
 
     /**
      * 閾炬帴绫诲瀷
@@ -131,10 +135,10 @@
      * @throws VciBaseException 鏌ヨ鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父
      */
     @Override
-    public DataGrid getDataForGrid(UIDataGridQuery dataGridQuery) throws VciBaseException {
+    public DataGrid getDataForGrid(UIDataGridQuery dataGridQuery) throws VciBaseException, PLException {
         VciBaseUtil.alertNotNull(dataGridQuery,"鏌ヨ瀵硅薄",dataGridQuery.getBtmname(),"涓氬姟绫诲瀷",dataGridQuery.getTableDefineId());
         //鍏堝垽鏂煡璇㈡ā鏉�
-        UITableDefineVO tableDefineVO = uiEngineService.getComponentByOid(dataGridQuery.getComponentOid()).getTableDefineVO();
+        UITableDefineVO tableDefineVO = uiEngineService.getComponentByOid(dataGridQuery.getComponentOid(),null).getTableDefineVO();
         String queryTemplate = !CollectionUtils.isEmpty(dataGridQuery.getSourceData())?dataGridQuery.getSourceData().getOrDefault("querytemplate",tableDefineVO.getQueryTemplateName()):tableDefineVO.getQueryTemplateName();
         if(StringUtils.isBlank(queryTemplate)){
             //璇存槑娌℃湁璁剧疆鏌ヨ妯℃澘锛岄渶瑕佺湅鐪嬪湪杩欎釜琛ㄦ牸鎵�鍦ㄧ殑缁勪欢鏈夋病鏈夎缃�
@@ -340,7 +344,8 @@
     @Override
     public List<Tree> getDataForTree(UITreeQuery treeQuery) throws VciBaseException {
         VciBaseUtil.alertNotNull(treeQuery,"琛ㄥ崟鐨勬煡璇㈠璞�",treeQuery.getBtmname(),"涓氬姟绫诲瀷鐨勪俊鎭�",treeQuery.getComponentOid(),"鏍戞墍鍦ㄧ殑缁勪欢鐨勪富閿�");
-        UIComponentVO componentVO = uiEngineService.getComponentByOid(treeQuery.getComponentOid());
+        Map<String, OsAttributeVO> attributeVOMap = attrService.selectAllAttributeMap();
+        UIComponentVO componentVO = uiEngineService.getComponentByOid(treeQuery.getComponentOid(),attributeVOMap);
         if(componentVO == null || StringUtils.isBlank(componentVO.getOid())){
             throw new VciBaseException("鏍戠殑閰嶇疆淇℃伅娌℃湁鑾峰彇鍒�");
         }
@@ -383,7 +388,7 @@
         if(StringUtils.isBlank(treeDefineVO.getLinkType())){
             //杩欎釜鏄笟鍔$被鍨嬬殑鑷弬鐓�
             //浠ュ墠鐨勫钩鍙版病鏈夊鑷弬鐓ц繖绉嶆湁鍏ㄩ儴鏌ヨ鐨�
-            OsBtmTypeVO btmTypeVO = btmService.getBtmById(treeDefineVO.getBtmType());
+            OsBtmTypeVO btmTypeVO = btmService.getBtmById(treeDefineVO.getBtmType(),attributeVOMap);
             queryFieldList.addAll(btmTypeVO.getAttributes().stream().map(OsBtmTypeAttributeVO::getId).collect(Collectors.toList()));
             queryFieldList.addAll(WebBoServiceImpl.BO_BASE_FIELD_MAP.values());
 
@@ -763,7 +768,7 @@
      * @throws VciBaseException 閰嶇疆鎴栬�呮槸璋冪敤涓嶆垚鍔熺殑鏃跺�欙紝浼氭姏鍑哄紓甯�
      */
     @Override
-    public BaseResult callPreEvent(BaseModelDTOList baseModelDTOList,BaseLinkModelDTOList baseLinkModelDTOList, String preEvent, VciChangeDocumentTypeEnum businessType) throws VciBaseException{
+    public BaseResult callPreEvent(BaseModelDTOList baseModelDTOList, BaseLinkModelDTOList baseLinkModelDTOList, String preEvent, VciChangeDocumentTypeEnum businessType) throws VciBaseException{
         if((baseModelDTOList == null || CollectionUtils.isEmpty(baseModelDTOList.getDataList())) && (baseLinkModelDTOList == null || CollectionUtils.isEmpty(baseLinkModelDTOList.getDataList()))){
             return BaseResult.success();
         }
@@ -1133,7 +1138,7 @@
         Map<String,String> baseDataMap = formDataDTO2MapLow(formDataDTO);
         Map<String,String> allDataMapLow = new HashMap<>();
         allDataMapLow.putAll(dataLow);
-//        allDataMapLow.putAll(baseDataMap);
+        allDataMapLow.putAll(baseDataMap);
         //鍒ゆ柇蹇呰緭椤�
         BaseResult result = checkRequired(formDefineVO,null,allDataMapLow);
         if(!result.isSuccess()){
@@ -1243,7 +1248,7 @@
             if(baseModel.getRevisionValue() == null){
                 baseModel.setRevisionValue("");
             }
-            return  changeRevisionValueInfoToObject(platformClientUtil.getBOFactoryService().getNextRevisionValueObject(WebUtil.getTableName(btmTypeVO.getId()),baseModel.getNameOid(),btmTypeVO.getRevisionRuleId(),btmTypeVO.isInputRevisionFlag(),baseModel.getRevisionValue()));
+            return  changeRevisionValueInfoToObject(platformClientUtil.getBOFactoryService().getNextRevisionValueObject(btmTypeVO.getId(),baseModel.getNameOid(),btmTypeVO.getRevisionRuleId(),btmTypeVO.isInputRevisionFlag(),baseModel.getRevisionValue()));
         } catch (PLException vciError) {
             throw WebUtil.getVciBaseException(vciError);
         }
@@ -1365,7 +1370,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);
             }
@@ -1429,7 +1434,7 @@
      * @throws VciBaseException 淇濆瓨鍑洪敊鐨勬椂鍊欎細鎶涘嚭寮傚父
      */
     @Override
-    public BaseResult<Map<String, Object>> upRevision(FormDataDTO formDataDTO) throws VciBaseException {
+    public BaseResult<Map<String, Object>> upRevision(FormDataDTO formDataDTO) throws VciBaseException, PLException {
         //棣栧厛鍒ゆ柇瀵硅薄鏄惁涓虹┖
         VciBaseUtil.alertNotNull(formDataDTO,"淇敼鐨勬暟鎹璞�",formDataDTO.getBtmname(),"涓氬姟绫诲瀷鐨勫悕绉�",formDataDTO.getFormDefineId(),"琛ㄥ崟瀹氫箟鐨勭紪鍙�",formDataDTO.getCopyFromVersion(),"鑰佺増鏈殑涓婚敭");
         UIFormDefineVO formDefineVO = uiEngineService.getFormById(formDataDTO.getBtmname(), formDataDTO.getFormDefineId());
@@ -1440,28 +1445,40 @@
             //璇存槑鍓嶇疆浜嬩欢娌℃湁鎵ц鎴愬姛
             return beforeResult;
         }
-        //灏佽鏁版嵁
-        BaseResult<BusinessObject> resultCbo = wrapperCbo(formDataDTO,formDefineVO,false,formDataDTO.isUpVersion()?false:true,formDataDTO.isUpVersion());
-        if(!resultCbo.isSuccess()){
-            return BaseResult.fail(resultCbo.getMsg(),resultCbo.getMsgObjs());
+        List<BusinessObject> businessObjects = null;
+        Date ts = formDataDTO.getTs();
+        Map<String,String> conditionMap = WebUtil.getOidQuery(formDataDTO.getCopyFromVersion());
+        conditionMap.put("ts", VciDateUtil.date2Str(ts,VciDateUtil.DateTimeMillFormat));
+        conditionMap.put("oid",formDataDTO.getCopyFromVersion());
+        businessObjects = boService.queryCBO(formDataDTO.getBtmname(), conditionMap);
+        if(businessObjects.size() ==0){
+            throw new VciBaseException("鏁版嵁涓嶆槸鏈�鏂扮殑锛屽缓璁偍鍒锋柊鍚庨噸鏂版搷浣�");
         }
+        //鎵╁睍灞炴�х殑鍊�
+        Map<String, String> data = formDataDTO.getData();
+        Map<String,String> dataLow = new HashMap<>();
+        data.forEach((key,value)->{
+            dataLow.put(key.toLowerCase(),value);
+        });
+
+        Map<String,String> baseDataMap = formDataDTO2MapLow(formDataDTO);
+        Map<String,String> allDataMapLow = new HashMap<>();
+        allDataMapLow.putAll(dataLow);
+        allDataMapLow.putAll(baseDataMap);
+        //鍒ゆ柇鍞竴椤�
+        BaseResult baseResult = checkUnique(formDefineVO, null, allDataMapLow, true);
+        if(!baseResult.isSuccess()){
+            return baseResult;
+        }
+        BusinessObject businessObject = platformClientUtil.getBOFService()
+                .revisionBusinessObject(businessObjects.get(0), null, !formDataDTO.isUpVersion(),true, false, false);
         //鎵ц淇濆瓨
-        BaseResult<Map<String,Object>> result = BaseResult.success();
-        try {
-            BusinessObject bo = platformClientUtil.getBOFService().createBusinessObject(resultCbo.getObj(),formDataDTO.isUpVersion()?false:true,formDataDTO.isUpVersion());
-            BusinessObject afterCbo = new BusinessObject();
-            afterCbo = bo;
-            result.setObj(boService.cbo2Map(afterCbo));
-        } catch (PLException vciError) {
-            throw WebUtil.getVciBaseException(vciError);
-        }
-        if(!CollectionUtils.isEmpty(formDataDTO.getReleaseFileOids())){
-            fileObjectService.releasedFile(resultCbo.getObj().btName,resultCbo.getObj().oid,formDataDTO.getReleaseFileOids());
-        }
+        BaseResult<Map<String, Object>> result = BaseResult.success();
+        result.setObj(boService.cbo2Map(businessObject));
         //鍚庣疆浜嬩欢
         String afterEvent = formDataDTO.getPostEvent();
         try {
-            callPostEvent(Arrays.stream(new BusinessObject[]{resultCbo.getObj()}).collect(Collectors.toList()), null,afterEvent, VciChangeDocumentTypeEnum.EDIT);
+            callPostEvent(Arrays.stream(new BusinessObject[]{businessObject}).collect(Collectors.toList()), null,afterEvent, VciChangeDocumentTypeEnum.EDIT);
         }catch (Throwable e){
             throw new VciBaseException(LangBaseUtil.getErrorMsg(e),new String[]{},e);
         }
@@ -1673,13 +1690,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)){
@@ -1700,10 +1710,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);
@@ -1758,7 +1770,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);
@@ -1771,6 +1782,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;
@@ -2029,7 +2048,7 @@
                     if (ruleVO == null || StringUtils.isBlank(ruleVO.getOid())) {
                         throw new VciBaseException("{0}閲岀殑鐗堟湰瑙勫垯璁剧疆寰椾笉姝g‘锛屽湪绯荤粺涓病鏈夋壘鍒皗1}杩欎釜鐗堟湰瑙勫垯", new String[]{btmTypeVO.getName(), btmTypeVO.getRevisionRuleId()});
                     }
-                    cbo.revisionValue = ruleVO.getStartCode();
+                    cbo.revisionValue = ruleVO.getInitialValue();
                 }
                 if (StringUtils.isBlank(cbo.nameoid)) {
                     cbo.nameoid = VciBaseUtil.getPk();
@@ -2147,8 +2166,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<>();
@@ -2285,7 +2302,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);
                 }
@@ -2294,7 +2311,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);
                 }
@@ -2454,4 +2471,73 @@
         }
         return dataMap;
     }
+
+    /**
+     * 鏁版嵁鍗囩増鏈�/娆★紝鍓嶇浣跨敤JSON鎻愪氦
+     * @param btmname 涓氬姟绫诲瀷鐨勪俊鎭�
+     * @param oid 涓氬姟鏁版嵁鐨勪富閿�
+     * @param type 1:鐗堟瀵硅薄锛�2锛氱増鏈璞★紱3锛氫富瀵硅薄
+     * @return 鎵ц鐨勭粨鏋�
+     */
+    @Override
+    public BaseResult deleteBusinessObject(String btmname, String oid, int type) throws PLException {
+        List<BusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid));
+        BaseResult<Object> objectBaseResult = new BaseResult<>();
+        if(cbos.size() == 0){
+            objectBaseResult.setSuccess(false);
+            throw new PLException("500", new String[]{"娌℃湁鑾峰彇鍒版暟鎹殑涓婚敭"});
+        }
+        for (BusinessObject cbo : cbos) {
+            if(StringUtils.isBlank(cbo.revisionid)){
+                String revisionoid = Arrays.stream(cbo.hisAttrValList).filter(e -> e.attrName.equals("REVISIONOID")).findFirst().map(e -> e.attrVal).orElse("");
+                cbo.revisionid = revisionoid;
+            }
+            boolean b = platformClientUtil.getBOFService().deleteBusinessObject(cbo,type);
+            if(!b){
+                throw new PLException("500", new String[]{"鏁版嵁鍒犻櫎澶辫触锛侊紒"});
+            }
+        }
+        return BaseResult.success();
+    }
+    /**
+     * 鍙樻洿鎵�鏈夎��
+     * @param btmname 涓氬姟绫诲瀷
+     * @param oid 涓婚敭
+     * @return 鎵ц鐨勭粨鏋�
+     */
+    @Override
+    public BaseResult changeBusinessObjectOwner(String btmname, String oid) throws PLException {
+        List<BusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid));
+        BaseResult<Object> objectBaseResult = new BaseResult<>();
+        if(cbos.size() == 0){
+            objectBaseResult.setSuccess(false);
+            throw new PLException("500", new String[]{"娌℃湁鑾峰彇鍒版暟鎹殑涓婚敭"});
+        }
+        UserInfo userInfo = platformClientUtil.getFrameworkService().getUserObjectByUserName(WebUtil.getCurrentUserId());
+        for (BusinessObject cbo : cbos) {
+            platformClientUtil.getBOFService().changeBusinessObjectOwner(cbo,userInfo);
+        }
+        return BaseResult.success();
+    }
+    /**
+     * 鍙樻洿鎵�鏈夎��
+     * @param btmname 涓氬姟绫诲瀷
+     * @param oid 涓婚敭
+     * @param releaseStatus 鍙戝竷鐘舵��
+     * @return 鎵ц鐨勭粨鏋�
+     */
+    @Override
+    @Transactional
+    public BaseResult transferBusinessObject(String btmname, String oid, String toStatus,String releaseStatus) throws PLException {
+        List<BusinessObject> cbos = boService.queryCBO(btmname,WebUtil.getOidQuery(oid));
+        BaseResult<Object> objectBaseResult = new BaseResult<>();
+        if(cbos.size() == 0){
+            objectBaseResult.setSuccess(false);
+            throw new PLException("500", new String[]{"娌℃湁鑾峰彇鍒版暟鎹殑涓婚敭"});
+        }
+        for (BusinessObject cbo : cbos) {
+            platformClientUtil.getBOFService().transferBusinessObjectAndRelease(cbo, toStatus, releaseStatus);
+        }
+        return BaseResult.success();
+    }
 }

--
Gitblit v1.9.3