黄千龙
2023-04-06 53d3efae4778c0ee936911317411d931f930bf2b
force-app/main/default/classes/QISReportController.cls
@@ -20,7 +20,7 @@
        String recordTypeId = LightingButtonConstant.DEVELOPER_NAME_ASAC_DECISION;
        try{
            PAE_DecisionRecord__c RCPAEDIdList = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_QIS__c = :qisReportId  And RecordType.DeveloperName =  :recordTypeId limit 1]; 
            res.PAEid = RCPAEDIdList.id;
            res.pAEid = RCPAEDIdList.id;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -49,7 +49,7 @@
        String recordTypeId = LightingButtonConstant.DEVELOPER_NAME_ASRC_DECISION;
        try{
            PAE_DecisionRecord__c ASRCDIdList = [SELECT LastModifiedDate, Id, Name, LastModifiedById,RecordType.DeveloperName FROM PAE_DecisionRecord__c where PAE_QIS__c = :qisReportId  And RecordType.DeveloperName =  :recordTypeId Limit 1]; 
            res.PAEid = ASRCDIdList.id;
            res.pAEid = ASRCDIdList.id;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -217,54 +217,159 @@
        }
         return re;
    }
    // 提交
     @AuraEnabled
    public static InitData initForOCMSubmitButton (String recordId){
        InitData res = new initData();
        try{
            QIS_Report__c report = [SELECT  id,is_aohui_product__c,QIS_Status__c,OCM_Manager_Mail_F__c,QISInstallDate__c,contract_number__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.QIStatus = report.QIS_Status__c;
            res.QISInstallDate = report.QISInstallDate__c;
            res.contractnumber = report.contract_number__c;
            res.isaohuiproduct = report.is_aohui_product__c;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisWithOCM (String recordId){
        String re = '成功';
        QIS_Report__c report = [SELECT  id,QIS_Status__c,QISInstallDate__c,contract_number__c,OCM_Manager_Mail_F__c
                                ,OCM_Member_Mail_F__c,OCM_Repair_Mail_F__c,OCM_Repair_Mail1_F__c,FSE_Special_Mail_F__c,FSE_Special_Manager_Mail_F__c
                                    ,WorkLocation_CC_Mail_F__c,is_aohui_product__c,QuolityApproveResult__c
                                FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
        try{
            QIS_Report__c rac  = new QIS_Report__c();
            rac.id = recordId;
            rac.QIS_Status__c = LightingButtonConstant.STATUS_QIS_FSE_COMPLATED;
            rac.OCM_Manager_Mail__c = report.OCM_Manager_Mail_F__c;
            rac.OCM_Member_Mail__c = report.OCM_Member_Mail_F__c;
            rac.OCM_Repair_Mail__c = report.OCM_Repair_Mail_F__c;
            rac.OCM_Repair_Mail1__c = report.OCM_Repair_Mail1_F__c;
            rac.FSE_Special_Mail__c = report.FSE_Special_Mail_F__c;
            rac.FSE_Special_Manager_Mail__c = report.FSE_Special_Manager_Mail_F__c;
            rac.WorkLocation_CC_Mail__c = report.WorkLocation_CC_Mail_F__c;
            rac.Cancel_QIS_Reason__c = null;
            if (report.is_aohui_product__c == true) {
                    rac.OCM_judgement__c = '质量问题';
                    rac.next_action__c = '无偿维修';
                    rac.RecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_OSH).getRecordTypeId();
                    rac.QIS_Status__c = LightingButtonConstant.STATUS_QIS_OSH_TESTING_APP;
            }
            if (report.QuolityApproveResult__c == null || report.QuolityApproveResult__c == '') {
                rac.QuolityApproveResult__c = '3.已审核,一般质量问题';
            }
            update rac;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    // QIS结果跟进完毕
     @AuraEnabled
    public static InitData initForQisAgreeButton (String recordId){
        InitData res = new initData();
        try{
            QIS_Report__c report = [SELECT  id ,OwnerId FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.ownerId = report.OwnerId;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisForQisAgree (String recordId){
        String re = '成功';
        ID myUserID = UserInfo.getUserId();
        String answerComp = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_OSH_FINASH).getRecordTypeId();
        String fina = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_FINAL).getRecordTypeId();
        String comp = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByName().get(LightingButtonConstant.RECORD_TYPE_NAME_BY_COMP).getRecordTypeId();
        // RecordType rectyp = [SELECT id ,name FROM RecordType where  id = '01210000000gFTH'];
        QIS_Report__c report = [SELECT  id,OwnerId,RecordTypeId FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
        try{
            if (report.ownerid == myUserID) {
                QIS_Report__c rac  = new QIS_Report__c();
                rac.id = recordId;
                rac.QIS_Status__c = LightingButtonConstant.STATUS_QIS_COMPLATED;
                if (report.RecordTypeId == answerComp) {
                    rac.RecordTypeId = fina;
                }else{
                    rac.RecordTypeId = comp;
                }
                rac.QIS_Complete_Day__c  = Date.today();
                update rac;
            }
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    public class InitData{
        @AuraEnabled
        public String Id;
        @AuraEnabled
        public String OwnerId;
        public String ownerId;
        @AuraEnabled
        public String qisRecordTypeId;
        @AuraEnabled
        public String qisRecordName;
        @AuraEnabled
        public String ProfileName;
        public String profileName;
        @AuraEnabled
        public String PAEid;
        public String isAEProfile;
        @AuraEnabled
        public String OCSMAdministrativeReportNumber;
        public String isPAEProfile;
        @AuraEnabled
        public String OCSMAdministrativeReportStatus;
        public String isCNBuy;
        @AuraEnabled
        public String QIStatus;
        public String pAEid;
        @AuraEnabled
        public String OSHstaff;
        public String oCSMAdministrativeReportNumber;
        @AuraEnabled
        public String OSHstaffEmail;
        public String oCSMAdministrativeReportStatus;
        @AuraEnabled
        public String CancelQISReason;
        public String qIStatus;
        @AuraEnabled
        public String RCid;
        public String oSHstaff;
        @AuraEnabled
        public String oSHstaffEmail;
        @AuraEnabled
        public String cancelQISReason;
        @AuraEnabled
        public String rCid;
        @AuraEnabled
        public String contractnumber;
        @AuraEnabled
        public Date RCinspectionDate;
        public Date rCinspectionDate;
        @AuraEnabled
        public Date QISReplyDay;
        public Date qISReplyDay;
        @AuraEnabled
        public Date QISInstallDate;
        public Date qISInstallDate;
        @AuraEnabled
        public Date cdsdate;
        @AuraEnabled
        public Date Aware_date;
        public Date awaredate;
        @AuraEnabled
        public Date OCSMAdministrativeReportDate;
        public Date oCSMAdministrativeReportDate;
        @AuraEnabled
        public Boolean RCproblemnotfound;
        public Boolean rCproblemnotfound;
        @AuraEnabled
        public Boolean isaohuiproduct;
        @AuraEnabled
        public Boolean IsSendQIS;
        public Boolean isSendQIS;
    }
}