黄千龙
2023-04-07 03dbeca473dd82350778bcacfe6b6b36cf658861
force-app/main/default/classes/QISReportController.cls
@@ -350,158 +350,7 @@
        }
         return re;
    }
    //OCSM不要报告
    @AuraEnabled
    public static InitData initForlexOCSMNoToReportLightingButton (String recordId){
        InitData res = new initData();
        try{
            QIS_Report__c report = [SELECT  id ,OCSMAdministrativeReportNumber__c,OCSMAdministrativeReportDate__c,Aware_date__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.oCSMAdministrativeReportNumber = report.OCSMAdministrativeReportNumber__c;
            res.oCSMAdministrativeReportDate = report.OCSMAdministrativeReportDate__c;
            res.Awaredate = report.Aware_date__c;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisForlexOCSMNoToReportLighting (String recordId){
        String re = '成功';
        QIS_Report__c report = [SELECT  id FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
        try{
                QIS_Report__c rac  = new QIS_Report__c();
                rac.id = recordId;
                rac.OCSMAdministrativeReportStatus__c = '无需报告';
                update rac;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    //OCSM要报告
    @AuraEnabled
    public static InitData initForlexOCSMToReportLightingButton (String recordId){
        InitData res = new initData();
        try{
            QIS_Report__c report = [SELECT  id ,OCSMAdministrativeReportStatus__c,Aware_date__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.oCSMAdministrativeReportStatus = report.OCSMAdministrativeReportStatus__c;
            res.Awaredate = report.Aware_date__c;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisForlexOCSMToReportLighting (String recordId){
        String re = '成功';
        QIS_Report__c report = [SELECT  id FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
        try{
                QIS_Report__c rac  = new QIS_Report__c();
                rac.id = recordId;
                rac.OCSMAdministrativeReportStatus__c  = '待报告';
                update rac;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    //发送QIS到SPO
    @AuraEnabled
    public static InitData initForlexSendQISButton (String recordId){
        InitData res = new initData();
        ID myUserID = UserInfo.getUserId();
        User userinfo = [SELECT id,Profile.name FROM User WHERE Id = :myUserID LIMIT 1];
        try{
            QIS_Report__c report = [SELECT  id ,RecordTypeId,IsSendQIS__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            RecordType rec = [SELECT id,name FROM RecordType where  Id = :report.RecordTypeId];
            res.Id = report.Id;
            res.qisRecordTypeId = report.RecordTypeId;
            res.qisRecordName = rec.name;
            res.profileName = userinfo.Profile.name;
            res.IsSendQIS = report.IsSendQIS__c;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisForSendQIS (String recordId){
        String re = '成功';
        QIS_Report__c report = [SELECT Id,Name,IsSendQIS__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
        if(report == null ){
            return '没有QIS:' + recordId + '的数据。';
        }
        Savepoint sp = Database.setSavepoint();
        try{
                QIS_Report__c rac  = new QIS_Report__c();
                rac.id = recordId;
                rac.IsSendQIS__c = true;
                update rac;
        }catch(Exception e){
            Database.rollback(sp);
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    // OCSM服务本部收到实物
    @AuraEnabled
    public static InitData initForlexRCRecievedButton (String recordId){
        InitData res = new initData();
        ID myUserID = UserInfo.getUserId();
        User userinfo = [SELECT id,Profile.name FROM User WHERE Id = :myUserID LIMIT 1];
        try{
            QIS_Report__c report = [SELECT  id ,isAE_Profile__c,QIS_Status__c,isPAE_Profile__c,is_CNBuy__c FROM QIS_Report__c WHERE Id = :recordId LIMIT 1];
            res.Id = report.Id;
            res.isAEProfile = report.isAE_Profile__c;
            res.isPAEProfile = report.isPAE_Profile__c;
            res.QIStatus = report.QIS_Status__c;
            res.isCNBuy = report.is_CNBuy__c;
            System.debug(LoggingLevel.INFO, '*** res: ' + res);
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
        }
        return res;
    }
    @AuraEnabled
    public static String updateQisForRCRecieved (String recordId){
        String re = '成功';
        ID myUserID = UserInfo.getUserId();
        User userinfo = [SELECT id,Alias,BuchangApprovalManagerSales__c,JingliApprovalManager__c, BuchangApprovalManager__c, ZongjianApprovalManager__c FROM User WHERE Id = :myUserID LIMIT 1];
        try{
                QIS_Report__c rac  = new QIS_Report__c();
                rac.id = recordId;
                rac.QIS_Status__c = 'RC检测中';
                rac.OCM_RC_RecievedDate__c = Date.today();
                rac.RC__c = myUserID;
                rac.RC_Receive_staff__c = userinfo.Alias;
                if (userinfo != null  && userinfo.BuchangApprovalManagerSales__c!= null) {
                    rac.RC_Manager__c = userinfo.BuchangApprovalManagerSales__c;
                } else {
                    rac.RC_Manager__c = myUserID;
                }
                update rac;
        }catch(Exception e){
            System.debug(LoggingLevel.INFO, '*** e: ' + e);
            re = e.getMessage();
        }
         return re;
    }
    public class InitData{
        @AuraEnabled
        public String Id;