高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/NewAndEditReportController.cls
@@ -38,6 +38,11 @@
    public String contactName4{set;get;}
    public String contactName5{set;get;}
    public String sfRecordIdForEdit{set;get;}//Add By LiJun for Edit Record from NFM609, 20220510
    public String VLookUpFieldsJson{get;private set;}
    //zhj MEBG新方案改造 2022-11-29 start
    public String staticResourceV2 {get; set;}
    //zhj MEBG新方案改造 2022-11-29 end
    public NewAndEditReportController(ApexPages.StandardController controller) {
        ApiPrefix = 'PIBackApi';
        layoutEncryptedAPIList = new List<String>();
@@ -191,10 +196,23 @@
                }
            }
        }
        //获取lookup字段
        List<String> VLookUpFields = new List<String>();
        for (LayoutDescriberHelper.LayoutSection ls : layoutSections) {
            for (LayoutDescriberHelper.LayoutField lf : ls.layoutFields) {
                if (lf.fieldAPI != '' && lf.fieldType == 'reference') {
                    VLookUpFields.add(lf.fieldAPI);
                }
            }
        }
        VLookUpFieldsJson = Json.serialize(VLookUpFields);
        for (PI_Field_Policy_Detail__c PIDetail : piIntegration.PIDetails) {
            AWSToSobjectEncryptedMap.put(PIDetail.AWS_Field_API__c, PIDetail.SF_Field_API_Name__c);
        }
        System.debug('AWSToSobjectEncryptedMap = ' + AWSToSobjectEncryptedMap);
        //zhj MEBG新方案改造 2022-11-29 start
        staticResourceV2 = JSON.serialize(PIHelper.getPIIntegrationInfo('Report__cV2'));
        //zhj MEBG新方案改造 2022-11-29 end
    }
    global class Response{
@@ -260,16 +278,27 @@
            String awsDataId = (String)reportInfo.get('AWS_Data_Id__c');
            String sfRecordId =  (String)reportInfo.get('Id');
            System.debug('awsDataId = ' + awsDataId);
            report__c[] reports = [select id from report__c where AWS_Data_Id__c =:awsDataId or id =:sfRecordId];
            System.debug('sfRecordId = ' + sfRecordId);
            report__c[] reports = [select id from report__c where AWS_Data_Id__c =:awsDataId or id=:sfRecordId];
            //report__c[] reportsFromDaily = [select id from report__c where AWS_Data_Id__c =:awsDataId or id=:sfRecordId];
            
            if(!isNew){
                isClone = reports.size() == 0;
            }
            system.debug('isClone'+isClone + ' isNew'+isNew);
            if(isNew){
            if(isNew || isClone){
                System.debug('reportInfo = ' + reportInfo);               
                if(!Test.isRunningTest()){
                   insert reportInfo;
                    // if(isClone){
                    //     Report__c[] r = [select Practitioner4__c,Practitioner5__c from Report__c where id=:sfRecordId];
                    //     if(r.size()>0){
                    //         reportInfo.Practitioner4__c = r[0].Practitioner4__c;
                    //         reportInfo.Practitioner5__c = r[0].Practitioner5__c;
                    //     }
                    //     reportInfo.Id = null;
                    // }
                    reportInfo.Status__c = '草案中';
                    insert reportInfo;
                } else {
                    Report__c reportTest = new Report__c();
                    insert reportTest;
@@ -282,7 +311,7 @@
                System.debug('reports[0].id = ' + reports[0].id);
                reportInfo.put('Id',reports[0].id);//For testing;                
                if(!Test.isRunningTest()){
                   update reportInfo;
                    update reportInfo;
                }
            }
            rid=reportInfo.Id;
@@ -302,7 +331,7 @@
            System.debug(e.getDmlMessage(index));
            System.debug(e.getDmlStatusCode(index));
            System.debug(e.getDmlType(index));
         system.debug(e.getMessage());
            system.debug(e.getMessage());
            system.debug(e.getStackTraceString());
            System.debug('into catch'+e.getMessage());