From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/NewConsumApplyEquipSetDetailController.cls |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/force-app/main/default/classes/NewConsumApplyEquipSetDetailController.cls b/force-app/main/default/classes/NewConsumApplyEquipSetDetailController.cls
index 17cc810..251c272 100644
--- a/force-app/main/default/classes/NewConsumApplyEquipSetDetailController.cls
+++ b/force-app/main/default/classes/NewConsumApplyEquipSetDetailController.cls
@@ -11,6 +11,7 @@
     public String awsToken{set;get;}
     public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
     public static String sobjectTypeValue = 'Consum_Apply_Equipment_Set_Detail__c';
+    public Boolean isCloneMode{protected set;get;}
     public Boolean isNewMode{set;get;}
     public String rtTypeId {get; set;}
     public String AWSDataId{set;get;}
@@ -22,11 +23,19 @@
     public String requiredErrorMsg{set;get;}
     public String sobjecttypeForFrontEnd{set;get;}
     public String sobjectPrefix{set;get;}
+    //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+    public String staticResourceV2 {get; set;}
+    //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
     public NewConsumApplyEquipSetDetailController(ApexPages.StandardController controller) {
         isNewMode = true;
+        isCloneMode = false;
         Input_Required_Field_Msg = Label.Input_Required_Field_Msg;
         sobjecttypeForFrontEnd = sobjectTypeValue;
         //鑾峰彇鎵�鏈夊瓧娈�
+        Map<string,string> mso = ApexPages.currentPage().getParameters();
+        if(mso != null && mso.containsKey('newclone')){
+            isCloneMode = true;
+        }
         List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Consum_Apply_Equipment_Set_Detail__c').getDescribe().fields.getMap().keyset());  
         if (!Test.isRunningTest()) { 
             controller.addFields(fieldList);
@@ -50,6 +59,9 @@
         fieldAPIToLabelMapStr = JSON.serialize(fieldAPIToLabelMap);
         PIHelper.PIIntegration piIntegration =PIHelper.getPIIntegrationInfo('Consum_Apply_Equipment_Set_Detail__c');
         staticResource = JSON.serialize(piIntegration);
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+        staticResourceV2 = JSON.serialize(PIHelper.getPIIntegrationInfo('Consum_Apply_Equipment_Set_Detail__cV2'));
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
         encryptedAPIList = piIntegration.PIFields;
         sobjectPrefix = piIntegration.sobjectPrefix;
     }
@@ -81,9 +93,14 @@
                 if(String.isNotBlank(fieldValue)&&fieldValue.contains('T')){
                     fieldValue = fieldValue.replace('T',' ');
                     consumApplyInfo.put(fieldAPI, Datetime.valueOfGmt(fieldValue));
+                //20220405 By ChenYanan Start
+                }else if(String.isNotBlank(fieldValue))  {
+                    fieldValue = fieldValue.replace('/', '-') + ':00';
+                    consumApplyInfo.put(fieldAPI, Datetime.valueOf(fieldValue));
+                //20220405 By ChenYanan End
                 }else{
                     consumApplyInfo.put(fieldAPI, null);
-                }                    
+                }               
             }else if(String.valueof(fielddataType)=='CURRENCY'|| String.valueof(fielddataType)=='PERCENT'||String.valueOf(fielddataType)=='Number'||String.valueOf(fielddataType)=='DOUBLE' ){
                 consumApplyInfo.put(fieldAPI, (String.isBlank(fieldValue)||String.isEmpty(fieldValue))?0:Decimal.valueOf(fieldValue)); 
             } else if(String.valueof(fielddataType)=='BOOLEAN'){
@@ -98,17 +115,26 @@
         Response resp = new Response();
         Savepoint sp = Database.setSavepoint();
         String rid = '';
+        Boolean isClone = false;
+        String awsDataId = '';
         try{
             System.debug('abcde');
+            awsDataId = (String)consumApplyInfo.get('AWS_Data_Id__c');
+            System.debug('awsDataId = ' + awsDataId);
+            Consum_Apply_Equipment_Set_Detail__c[] ConsumApplys = [select id from Consum_Apply_Equipment_Set_Detail__c where AWS_Data_Id__c =:awsDataId];
+            
+            if(!isNew || isClone){
+                isClone = ConsumApplys.size() == 0;
+            }
             if(isNew){
                 System.debug('consumApplyInfozhj = ' + consumApplyInfo);
                 insert consumApplyInfo;
                 System.debug('consumApplyInfo.Id' + consumApplyInfo.Id);
             }else{
                 System.debug('into update');
-                String awsDataId = (String)consumApplyInfo.get('AWS_Data_Id__c');
-                System.debug('awsDataId = ' + awsDataId);
-                Consum_Apply_Equipment_Set_Detail__c[] ConsumApplys = [select id from Consum_Apply_Equipment_Set_Detail__c where AWS_Data_Id__c =:awsDataId];
+                // String awsDataId = (String)consumApplyInfo.get('AWS_Data_Id__c');
+                // System.debug('awsDataId = ' + awsDataId);
+                // Consum_Apply_Equipment_Set_Detail__c[] ConsumApplys = [select id from Consum_Apply_Equipment_Set_Detail__c where AWS_Data_Id__c =:awsDataId];
                 System.debug('ConsumApplys[0].id = ' + ConsumApplys[0].id);
                 consumApplyInfo.put('Id',ConsumApplys[0].id);//For testing;
                 update consumApplyInfo;

--
Gitblit v1.9.1