global class TSRepairUtil {
    
    // 用户故障信息
    public static Map<String, User_FaultInfo__c> GetfaultInfoMap(List<String> ufIdList) {

        Map<String, User_FaultInfo__c> result = new Map<String, User_FaultInfo__c>();
        List<User_FaultInfo__c> faultInfoList = GetfaultInfoList(ufIdList,null,null,'');
        
        if ( faultInfoList.size() > 0) {

            for (User_FaultInfo__c uf : faultInfoList) {

                result.put(uf.Id, uf);
            }
        }
        return result;
    }

    /**
     * 获取用户/故障信息
     * @DateTime 2020-08-22
     * @param    ufIdList     [用户/故障信息 Id]
     * @param    placeholder1 [预留位置1]
     * @param    placeholder2 [预留位置2]
     * @param    placeholder3 [预留位置3]
     * @return                [description]
     */
    public static List<User_FaultInfo__c> GetfaultInfoList(List<String> ufIdList,Set<String> placeholder1,List<String> placeholder2,String placeholder3){
        List<User_FaultInfo__c> result = new List<User_FaultInfo__c>();
        String sql = UserFaultInfoBaseSQL();
        if (ufIdList != null && ufIdList.size() > 0) {
            sql += ' AND Id In : ufIdList';
        }
        sql += ' order by Id';

        result = Database.query(sql);

        return result;
    }
    /**
     * [UserFaultInfoBaseSQL 用户/故障信息的基本SQL]
     * @return [description]
     */
    public static String UserFaultInfoBaseSQL(){
        String sql = '';
            sql += 'SELECT Id,Name,UFAccount__c, UFContact__c, UFDateRequest__c, UFDetermineDate__c,UserFaultInfoReportDate__c,';
            sql += 'UFFaultContent__c, UFManagementCode__c, UFMessageSource__c, UFNatureService__c,';
            sql += 'UFPhone__c, UFRepairDate__c, UFWithoutReason__c,';
            sql += 'UFLineNumber__c, UFTS__c, UserFaultInfoServiceResult__c,UFDateApproval__c,UserFaultInfoApprovalDate__c,UserFaultInfoModel__c,';
            sql += 'UserFaultInfoServiceContent__c, UserFaultInfoCustomerUnit__c,';
            sql += 'UserFaultInfoServicePlace__c, UserFaultInfoBusinessTrip__c,';
            sql += 'UserFaultInfoCompletionDate__c, UserFaultInfoNextService__c,';
            sql += 'UserFaultInfoServiceType__c, UserFaultInfoWorkingHours__c,';
            sql += 'UserFaultInfoBeSelected__c,UserFaultInfoServiceCategory__c,UserFaultInfoServiceContractNo__c,UserFaultInfoCombinedAmount__c,UserFaultInfoDateQuotation__c ';
            sql += ' FROM User_FaultInfo__c WHERE Id != null';
        return sql;
    }

    // 用户故障样机
    public static Map<String, List<FailureAsset__c>> GetUserFaultInfMap(List<String> ufIdList,List<String> baIdList){

        Map<String, List<FailureAsset__c>> result = new Map<String, List<FailureAsset__c>>();
        List<FailureAsset__c> failureAssetList = new List<FailureAsset__c>();
        if (ufIdList != null && ufIdList.size() > 0) {
            failureAssetList = GetFailureAssetList(null,ufIdList,null,null,null);
        }

        if (baIdList != null && baIdList.size() > 0) {
            failureAssetList = GetFailureAssetList(null,null,baIdList,null,null);
        }
        // List<FailureAsset__c> failureAssetList = GetFailureAssetList(null,ufIdList,null,null);
            if ( failureAssetList.size() > 0) {
                for (FailureAsset__c fa : failureAssetList) {
                    if (ufIdList != null && ufIdList.size() > 0) {
                        List<FailureAsset__c> faList = new List<FailureAsset__c>();
                        if (result.containsKey(fa.FAUserFaultInfo__c)) {

                            faList = result.get(fa.FAUserFaultInfo__c);
                        }
                        faList.add(fa);
                        result.put(fa.FAUserFaultInfo__c, faList);
                    }

                    if (baIdList != null && baIdList.size() > 0) {
                        List<FailureAsset__c> faList = new List<FailureAsset__c>();
                        if (result.containsKey(fa.FAActivity__c)) {

                            faList = result.get(fa.FAActivity__c);
                        }
                        faList.add(fa);
                        result.put(fa.FAActivity__c, faList);
                    }

                }
            }
        return result;
    }
    /**
     * 获取故障产品信息
     * @DateTime 2020-08-22
     * @param    faIdList     [故障机器 Id]
     * @param    ufIdList     [用户/故障信息 Id]
     * @param    placeholder1 [预留位置1]
     * @param    placeholder2 [预留位置2]
     * @return                [description]
     */
    public static List<FailureAsset__c> GetFailureAssetList(List<String> faIdList,List<String> ufIdList,List<String> baIdList,Set<String> placeholder1, String placeholder2){

        List<FailureAsset__c> result = new List<FailureAsset__c>();

        String sql = '';
        sql += 'SELECT Id, UFManagementCode__c, model__c, SerialNumber__c, WarrantyStatus__c,';
        sql += 'FAActivity__c, FAUserFaultInfo__c,FAProductSeries__c ';
        sql += ' FROM FailureAsset__c WHERE Id != null ';

        if (faIdList != null && faIdList.size() > 0) {
            sql += ' AND Id In : faIdList ';     
        }
        if (ufIdList != null && ufIdList.size() > 0) {
            sql += ' AND FAUserFaultInfo__c In : ufIdList';
        }

        if (baIdList != null && baIdList.size() > 0) {
            sql += ' AND FAActivity__c In : baIdList';
        }
        sql += ' Order by FAUserFaultInfo__c,Id';
        result = Database.query(sql);

        return result;

    }

    //查找"业务活动"下所有的附件
    public static Map<String,List<Attachment>> GetAttachmentMap(List<String> baIdList) {
        Map<String,List<Attachment>> result = new Map<String,List<Attachment>>();
        List<Attachment>  all_BA_AttachmentList=  GetAttachmentList(baIdList);
        if (all_BA_AttachmentList != null && all_BA_AttachmentList.size() > 0) {

            for (Attachment att :all_BA_AttachmentList) {
                List<Attachment> ba_AttachmentList = new List<Attachment>();
                if (result.containsKey(att.ParentId)) {
                    ba_AttachmentList = result.get(att.ParentId);
                } 
                ba_AttachmentList.add(att);
                result.put(att.ParentId,ba_AttachmentList);
            }
        } 
        return result;
    }


    /**获取附件
     * This is a cool function
     * @param    parentIdList [description]
     * @return                [description]
     */
    public static List<Attachment> GetAttachmentCloneList(List<String> parentIdList) {
        List<Attachment> result = new List<Attachment>();
        String sql = '';
        sql += 'select Id, IsDeleted, ParentId, Name, IsPrivate, ContentType, BodyLength,';
        sql += 'Body, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById,';
        sql += 'SystemModstamp, Description  ';
        sql += ' FROM Attachment where Id != null ';
        if (parentIdList != null && parentIdList.size() >0 ) {
            sql += ' AND ParentId In : parentIdList';
        }

        sql += ' order by Id';

        result = Database.query(sql);

        return result;
    }
    /**
     * [GetdeleteAttachmentList 查询附件]
     * @param  parentIdList [description]
     * @return              [description]
     */
    public static List<Attachment> GetAttachmentList(List<String> parentIdList) {
        List<Attachment> result = new List<Attachment>();
        String sql = '';
        sql += 'select Id,Name,CreatedDate,OwnerId,ParentId  ';
        sql += ' FROM Attachment where Id != null ';
        if (parentIdList != null && parentIdList.size() >0 ) {
            sql += ' AND ParentId In : parentIdList';
        }

        sql += ' order by Id';

        result = Database.query(sql);

        return result;
    }

    /**
     * 获取业务活动
     * @Author   XHL
     * @DateTime 2020-08-22
     * @param    tsRepairIdList         [TS日报 ID]
     * @param    userFaultInfoIdList    [用户/故障信息 ID]
     * @param    businessActivityIdList [业务活动 ID]
     * @param    placeholder1           [预留位置1]
     * @param    placeholder2           [预留位置2]Map.keyset()
     * @param    placeholder3           [预留位置3]
     * @return                          [description]
     */
    public static List<BusinessActivity__c> GetBusinessActivityList(List<String> tsRepairIdList, 
                                                    List<String> userFaultInfoIdList,
                                                    List<String> businessActivityIdList,
                                                    set<String> placeholder1,
                                                    List<String> placeholder2,
                                                    String placeholder3) {

        List<BusinessActivity__c> result = new List<BusinessActivity__c>();
        String sql = '';
        sql += 'SELECT Id, Name, firstInput__c, serviceType__c, BusinessATS__c,BusinessAServicePlace__c,';
        sql += 'BusinessABusinessTrip__c,BusinessACompletionDate__c,BusinessANextService__c,';
        sql += 'BusinessAServiceContent__c,BusinessAOpinion__c,BusinessAApprovalOpinion__c,';
        sql += 'ManagementCode__c,workingHoursFrom__c, workingHoursTo__c,workingHours__c,';
        sql += 'BusinessALineNumber__c,StartTimeHour__c,StartTimeMinute__c,EndTimeHour__c,';
        sql += 'EndTimeMinute__c,FindManagementCode__c,edit__c,BusinessAServiceContentNew__c,';
        sql += 'BusinessAAccount__c,BusinessAContact__c,BusinessAFaultContent__c,BaFromUserFaultInfo__c,';
        sql += 'BusinessARepairDate__c,BusinessADetermineDate__c,BusinessADateRequest__c,';
        sql += 'BusinessAMessageSource__c,BusinessANatureService__c,BusinessAWithoutReason__c,';
        sql += 'BusinessADateApproval__c,User_FaultInfo__c,BusinessAServiceResult__c,StartTime__c,';
        sql += 'BusinessADispatchTime__c,BusinessAMaintainTime__c,BusinessACustomerUnit__c, ';
        sql += 'BusinessADowntime__c,BusinessAServiceCategory__c,BusinessAPhone_F__c,EndTime__c, ';
        sql += 'BusinessAHaveAttachment__c,BusinessAServiceContractNo__c,BusinessAAccount__r.Id,';
        sql += 'BusinessAPhone__c,BusinessASegment__c,BusinessADateQuotation__c,AgreeReportDate__c,  ';
        sql += 'BusinessATSReportStatus__c,BusinessACombinedAmount__c,BusinessAFirstSubmission__c, ';
        sql += 'BusinessATSReportReporter__c,BusinessATSReportDay__c ';
        sql += ' FROM BusinessActivity__c where Id != null ';

        if (tsRepairIdList != null && tsRepairIdList.size() > 0) {
            sql += ' AND BusinessATS__c In : tsRepairIdList';
        }

        if (userFaultInfoIdList != null && userFaultInfoIdList.size() > 0) {
            sql += ' AND User_FaultInfo__c In : userFaultInfoIdList ';
        }

        if (businessActivityIdList != null && businessActivityIdList.size() > 0) {
            sql += ' AND Id In : businessActivityIdList';

        }

        sql += ' order by EndTime__c,Id';

        result = Database.query(sql);

        return result;

    }

    // 删除业务活动、用户故障信息
    public static void deleteBusinessActivityInformation(List<String> deleteBusinessActivityIdList){

        //查找业务活动
        List<BusinessActivity__c> deleteBusinessActivityList = GetBusinessActivityList(null,null,deleteBusinessActivityIdList,null,null,'');
        List<User_FaultInfo__c> deleteUserFaultInfoList = new List<User_FaultInfo__c>();
        //查找 业务活动下 故障产品信息
        List<FailureAsset__c> deleteBAfailureAssetList = GetFailureAssetList(null,null,deleteBusinessActivityIdList,null,null);
        List<String> userFaultInfoIdList = new List<String>();
        System.debug('deleteBusinessActivityList--->'+deleteBusinessActivityList);

        if (deleteBusinessActivityList.size() > 0) {

            for (BusinessActivity__c businessActivity :deleteBusinessActivityList){
                
                // 获取 业务活动 首次登陆案件的值
                if ('是'.equals(businessActivity.firstInput__c) ){
                    // 删除业务活动、用户故障信息、用户故障信息 下 故障产品信息
                    // 因 目前只有未提交的业务活动才可删除，未提交过的业务活动没有关联的用户故障信息，因此注掉
                    // 若以后需要可放开 ---20200912
                    // -----------------------------------------------------------
                    //if (String.isNotBlank(businessActivity.User_FaultInfo__c)) {
                    //    User_FaultInfo__c deleteUserFaultInfo = new User_FaultInfo__c();
                    //    deleteUserFaultInfo.Id = businessActivity.User_FaultInfo__c;
                    //    deleteUserFaultInfoList.add(deleteUserFaultInfo);
                    //    userFaultInfoIdList.add(businessActivity.User_FaultInfo__c); 
                    //}
                    // -----------------------------------------------------------
                                       
                } else if ('否'.equals(businessActivity.firstInput__c) ){
                    // 仅删除业务活动
                } 
            } 

            if (deleteUserFaultInfoList != null && deleteUserFaultInfoList.size() > 0 ) {
                // 查找 用户故障信息下 故障产品信息
                List<FailureAsset__c> deleteUFfailureAssetList = GetFailureAssetList(null,userFaultInfoIdList,null,null,null);
                // 删除 用户故障信息下 故障产品信息
                if (deleteUFfailureAssetList.size() > 0) {
                    delete deleteUFfailureAssetList;
                }
                //删除 用户故障信息
                delete deleteUserFaultInfoList;
            } 
            //删除 业务活动下 故障产品信息
            if (deleteBAfailureAssetList.size() > 0) {
                delete deleteBAfailureAssetList;
            }
            //删除 业务活动
            delete deleteBusinessActivityList;
        }
    }

    /**
     * 获取TS日报
     * @Author   XHL
     * @DateTime 2020-08-22
     * @param    repairId     [TS日报 Id]
     * @param    userId       [用户 Id]
     * @param    tsDate       [报告日期]
     * @param    placeholder1 [预留位置1]
     * @param    placeholder2 [预留位置2]
     * @param    placeholder3 [预留位置3]
     * @return                [description]
     */
    public static List<TS_Repair__c> GetTsRepairList(String repairId,String userId,Date tsDate,
                                        List<String> placeholder1, set<String> placeholder2, String placeholder3){
        List<TS_Repair__c> result = new List<TS_Repair__c>();

        String sql = '';
        sql += 'SELECT Id, TSReportStatus__c,TSRepairClass__c,TSRepairSuperior__c,CreatedById,';
        sql += 'TSApprovalDate__c, TSRepairEmployeeID__c,TSRepairDepartment__c,TSReportPerson__c ,';
        sql += 'TSReportName__c,TSRepairSegment__c, TSReportDate__c,TSRepairDepartmenClass__c,'; 
        sql += 'TSRepairUserArea__c,TSRepairDismissReason__c,LastModifiedDate,Name,CreatedDate, ';
        sql += 'TSRepairFirstSubmission__c ' ;
        sql += ' FROM TS_Repair__c  where Id != null ';

        if (String.isNotBlank(repairId)) {
            sql += ' AND Id = \''+ repairId + '\'';
        }

        if (String.isNotBlank(userId)) {
            sql += ' AND TSReportPerson__c  = \''+userId+'\'';
            sql += ' AND TSReportDate__c = ' + String.valueOf(tsDate);
        }

        result = Database.query(sql);

        return result;
    }

    public static void insertattachmentCloneList(List<String> cloneFromIdList,String cloneToId){

        List<Attachment> cloneFromAttachmentList = TSRepairUtil.GetAttachmentCloneList(cloneFromIdList);
        List<Attachment> attachmentCloneList = new List<Attachment>();
        List<Attachment> cloneToAttachmentList = new List<Attachment>();

        if ( cloneFromAttachmentList.size() > 0) {
            for (Attachment attachment :cloneFromAttachmentList) {
                Attachment attachmentclone = new Attachment();
                attachmentclone = attachment.clone();
                attachmentclone.ParentId = cloneToId;
                cloneToAttachmentList.add(attachmentclone);
            }    
        }
        
        if ( cloneToAttachmentList.size() > 0 ) {
            insert cloneToAttachmentList;
        }
    }
    /**
     * [GetUserList 查询当前用户信息]
     * @param  userIdList [用户ID 集合]
     * @return            [description]
     */
    public static List<User> GetUserList(List<String> userIdList){
        String sql = '';
        System.debug('userIdList--->'+userIdList);
        List<User> result  = new List<User>();
        sql += 'Select Id,Name,TSUserArea__c,TSUserSuperior__c,TSUserDepartment__c,TSUserSegment__c,' ;
        sql += 'TSEmployeeID__c,TSUserClass__c ';
        sql += ' From User where Id In : userIdList' ;
        System.debug('sql--->'+sql);
        result = Database.query(sql);

        return result;
    }

    public static BusinessActivity__c BusinessActivityAssembled(List<User_FaultInfo__c> faultInfoList){

        BusinessActivity__c ba = new BusinessActivity__c();
        User_FaultInfo__c updateUserFaultInfo = faultInfoList[0];
        String fromUserFaultInfoId = updateUserFaultInfo.Id;
        //ba.Id = baId;
        ba.serviceType__c = updateUserFaultInfo.UserFaultInfoServiceType__c  ;//服务类型
        ba.BusinessAFaultContent__c = updateUserFaultInfo.UFFaultContent__c  ;//故障内容 
        ba.BusinessARepairDate__c = updateUserFaultInfo.UFRepairDate__c  ;//保修日期
        ba.BusinessADetermineDate__c = updateUserFaultInfo.UFDetermineDate__c  ;//判断日期
        ba.BusinessADateRequest__c = updateUserFaultInfo.UFDateRequest__c  ;//要求服务日期
        ba.BusinessAMessageSource__c = updateUserFaultInfo.UFMessageSource__c  ;//信息来源
        ba.BusinessANatureService__c = updateUserFaultInfo.UFNatureService__c  ;//服务性质  
        ba.BusinessAWithoutReason__c = updateUserFaultInfo.UFWithoutReason__c  ;//无偿原因
        ba.BusinessADateApproval__c = updateUserFaultInfo.UFDateApproval__c  ;//同意报价日期
        ba.BusinessADateQuotation__c = updateUserFaultInfo.UserFaultInfoDateQuotation__c;//报价日期
        ba.BusinessAServiceContent__c = updateUserFaultInfo.UserFaultInfoServiceContent__c  ;//服务内容(汇总)
        // ba.BusinessAServiceContentNew__c = updateUserFaultInfo.UserFaultInfoServiceContentNew__c  ;//服务内容
        ba.BusinessAServicePlace__c = updateUserFaultInfo.UserFaultInfoServicePlace__c  ;//服务场所
        ba.BusinessABusinessTrip__c = updateUserFaultInfo.UserFaultInfoBusinessTrip__c  ;//出差地
        ba.BusinessACompletionDate__c = updateUserFaultInfo.UserFaultInfoCompletionDate__c  ;//案件完成日
        ba.BusinessANextService__c = updateUserFaultInfo.UserFaultInfoNextService__c  ;//下次服务时间
        ba.BusinessAAccount__c = updateUserFaultInfo.UFAccount__c  ;//客户单位(查找)
        ba.BusinessACustomerUnit__c = updateUserFaultInfo.UserFaultInfoCustomerUnit__c ; //客户单位(文本)
        ba.BusinessAContact__c = updateUserFaultInfo.UFContact__c  ;//联系人
        ba.BusinessAPhone__c = updateUserFaultInfo.UFPhone__c  ;//联系电话
        ba.ManagementCode__c = updateUserFaultInfo.UFManagementCode__c;
        ba.FindManagementCode__c = updateUserFaultInfo.UFManagementCode__c;
        ba.User_FaultInfo__c = updateUserFaultInfo.Id;
        ba.BusinessAServiceCategory__c = updateUserFaultInfo.UserFaultInfoServiceCategory__c;//服务范畴
        ba.BusinessAServiceContractNo__c = updateUserFaultInfo.UserFaultInfoServiceContractNo__c;//服务合同号
        ba.BusinessAServiceResult__c = updateUserFaultInfo.UserFaultInfoServiceResult__c;//服务结果
        ba.AgreeReportDate__c = updateUserFaultInfo.UserFaultInfoReportDate__c;//报告日期(后台用)
        ba.firstInput__c = '否';
        ba.StartTimeHour__c = '0';
        ba.StartTimeMinute__c = '00';
        ba.EndTimeHour__c = '0';
        ba.EndTimeMinute__c = '00';
        ba.workingHours__c = 0.00;

        //判断 用户故障信息 是否有 附件
        List<String> parentIdList = new List<String>();
        parentIdList.add(fromUserFaultInfoId);
        List<Attachment> userFaultInfoAttachmentList = GetAttachmentList(parentIdList);
        if (userFaultInfoAttachmentList.size() > 0) {
            ba.BusinessAHaveAttachment__c = true;
        }
        ba.BaFromUserFaultInfo__c  = true;
        // 判断 用户故障信息 是否有 故障产品信息
        // List<String> ufIdList = new List<String>();
        //     ufIdList.add(fromUserFaultInfoId);
        // List<FailureAsset__c> failureAssetList = TSRepairUtil.GetFailureAssetList(null, ufIdList, null, null, null);
        // if (failureAssetList.size() > 0) {

        // }
        return ba;
    }

    // 获取客户
    public static List<Account> GetAccountList(String accountId,String accountName,List<String> placeholder1,Set<String> placeholder2,String placeholder3){
        List<Account> result = new List<Account>();

        String sql = '';
        sql += 'Select Id,Name ';
        sql += ' from Account ';
        if (String.isNotBlank(accountId) && String.isNotBlank(accountName)) {
            sql += ' Where Id = \''+ accountId + '\' AND Name = \'' + accountName +'\'';
        }
        // 此处要添加只检索 服务客户
        System.debug('sql--->'+sql);
        result = Database.query(sql);

        return result;
    } 
    // 获取联系人
    public static List<Contact> GetContactList(String contactId,List<String> placeholder1,Set<String> placeholder2,String placeholder3){
        List<Contact> result = new List<Contact>();
        String sql = '';
        sql += 'Select Id,Name,AccountId__c ';
        sql += ' from Contact ';
        if (String.isNotBlank(contactId)) {
            sql += ' Where Id = \''+ contactId + '\'';
        }
        result = Database.query(sql);

        return result;
    }
    public static Map<String,String>  GetserviceCategoryMap(){
        Map<String,String> result = new Map<String,String>();
        result.put('服务业务互通', 'Association');
        result.put('零件/固资管理', 'Association');
        result.put('品保协助', 'Association');
        result.put('内部活动', 'Association');
        result.put('服务培训(外部培训)', 'Association');
        result.put('服务培训(内部培训)', 'Association');
        result.put('代理商管理', 'Association');
        result.put('展会活动', 'Association');
        result.put('样机对应', 'Association');
        result.put('订单业务', 'Association');
        result.put('CIC呼叫中心', 'Sevice');
        result.put('品质&返修案件', 'Sevice');
        result.put('巡检', 'Sevice');
        result.put('销售支持', 'Sevice');
        result.put('技术支持', 'Sevice');
        result.put('移机/搬家', 'Sevice');
        result.put('维护保养(一般服务)', 'Sevice');
        result.put('维护保养(服务合同执行)', 'Sevice');
        result.put('产品安装', 'Sevice');
        result.put('服务合同推广', 'Sevice');
        result.put('校准（IE/NDT/ANI）', 'Repair');
        result.put('软件修理', 'Repair');
        result.put('硬件修理', 'Repair');

        return result;
    } 

    public static String AccountBaseRecordTypeIdSQL(){
        // String  serviceAccountANI  = System.label.ServiceAccountANI;
        // String  serviceAccountIE  = System.label.ServiceAccountIE;
        // String  serviceAccountLS  = System.label.ServiceAccountLS;
        // String  serviceAccountNDT  = System.label.ServiceAccountNDT;
        // String  serviceAccountRVI  = System.label.ServiceAccountRVI;

        String  accountANI  = '01228000000TdFL';
        String  accountIE  = '01228000000TdF6';
        String  accountLS  = '01228000000TdF1';
        String  accountNDT  = '01228000000TdFG';
        String  accountRVI  = '01228000000TdFB';
        String sql = '';
        // soql += ' and UFAccount__c  =\''+ accountId +'\'';
        sql += ' (RecordTypeId  =\''+ accountANI +'\'';
        sql += ' OR    RecordTypeId  =\''+ accountIE +'\'';
        sql += ' OR    RecordTypeId  =\''+ accountLS +'\'';
        sql += ' OR    RecordTypeId  =\''+ accountNDT +'\'';
        sql += ' OR    RecordTypeId  =\''+ accountRVI +'\')';

        return sql;
    } 

    public static String AccountBaseRecordTypeIdSQL2(){
        // String  serviceAccountANI  = System.label.ServiceAccountANI;
        // String  serviceAccountIE  = System.label.ServiceAccountIE;
        // String  serviceAccountLS  = System.label.ServiceAccountLS;
        // String  serviceAccountNDT  = System.label.ServiceAccountNDT;
        // String  serviceAccountRVI  = System.label.ServiceAccountRVI;
        String  accountANI  = '01228000000TdFL';
        String  accountIE  = '01228000000TdF6';
        String  accountLS  = '01228000000TdF1';
        String  accountNDT  = '01228000000TdFG';
        String  accountRVI  = '01228000000TdFB';
        String sql = '';
        // soql += ' and UFAccount__c  =\''+ accountId +'\'';
        sql += ' (UFAccount__r.RecordTypeId  =\''+ accountANI +'\'';
        sql += ' OR    UFAccount__r.RecordTypeId  =\''+ accountIE +'\'';
        sql += ' OR    UFAccount__r.RecordTypeId  =\''+ accountLS +'\'';
        sql += ' OR    UFAccount__r.RecordTypeId  =\''+ accountNDT +'\'';
        sql += ' OR    UFAccount__r.RecordTypeId  =\''+ accountRVI +'\')';

        return sql;
    }     

}