global class RadiationUtil {

    public static Boolean EscapeOrderTriggerHandler = true;
    /**
     * [updateRadiationTypeQuantity description]更新代理商证照明细，更新奥林巴斯代理商的证照明细
     * @param Id           [description]合同Id
     * @param orderFounder [description]合同创建人
     * @param dealerId     [description]代理商Id
     * @param toloseFlag   [description]根据条件增加还是减去代理商购买明细的数量
     */
    public static void updateRadiationTypeQuantity (String Id, String orderFounder, String dealerId, Boolean toloseFlag, String operationType, String operator) {

        String olympusAccountId = System.label.Olympus_Id;

        String orderId = Id;
        //获取合同的辐射类型和数量
        Map<String, Integer> radiationTypeQuantityMap =  GetModelQuantityMap(Id);
        if ( radiationTypeQuantityMap.size() > 0 ) {

            //查代理商的代理商购买明细
            Map<String, PurchaseDetails__c> dealerModelQuantityMap = GetPurchaseDetailsMap(dealerId);
            //查奥林巴斯的代理商购买明细
            Map<String, PurchaseDetails__c> olympusModelQuantityMap = GetPurchaseDetailsMap(olympusAccountId);
            // 查找 合同提交对应的代理商购买明细
            Map<String, PurchaseDetails__c> dealerResult = new Map<String, PurchaseDetails__c>();
            Map<String, PurchaseDetails__c> olympusResult = new Map<String, PurchaseDetails__c>();
            // 合同驳回、合同调回、合同状态由批准变草案--->已售产品数量    
            if (toloseFlag) {
                // 1.查找合同 的 购买明细变更详情 操作类型是 合同提交和合同草案中变批准        
                List<ChangedReport__c> selectChangedReportList = [
                SELECT Id,Name,ChangedPurchase__c,ChangedReportOrder__c,OperationType__c,
                       ChangedPurchase__r.PurchaseAccount__c 
                FROM ChangedReport__c 
                WHERE ChangedReportOrder__c = :orderId AND OperationType__c IN ('合同提交','合同草案中变批准')  Order by Id ];

                if (selectChangedReportList.size() > 0) {
                    // 2.取出合同对应的代理商最新的 购买明细变更详情
                    Map<String,String> tempMap = new Map<String,String>();
                    for (ChangedReport__c changedReport:selectChangedReportList) {
                        String accountIdSub = changedReport.ChangedPurchase__r.PurchaseAccount__c;
                        accountIdSub = accountIdSub.substring(0,15);
                        tempMap.put(accountIdSub,changedReport.ChangedPurchase__c);
                    }
                    if (tempMap.size() > 0) {
                        // 3.取出对应的 代理商辐射产品购买明细
                        List<PurchaseDetails__c> purchaseDetailsList = [
                        SELECT Id, Name, RemainingNumber__c, SoldNumber__c,
                                                 PurProductModel__c, PurchaseAccount__c
                        FROM PurchaseDetails__c

                        WHERE Id IN :tempMap.values()];
                        
                        if (purchaseDetailsList.size() > 0) {
                            for (PurchaseDetails__c purchaseDetail : purchaseDetailsList) {
                                String accountIdSub = purchaseDetail.PurchaseAccount__c;
                                accountIdSub = accountIdSub.substring(0,15);

                                if (dealerId.equals(accountIdSub)) {
                                    dealerResult.put(purchaseDetail.PurProductModel__c, purchaseDetail);
                                } else if(olympusAccountId.equals(accountIdSub)){
                                    olympusResult.put(purchaseDetail.PurProductModel__c, purchaseDetail);
                                }
                                
                            }
                        }
                    }
                }
            }

            
            Map<String, ChangedReport__c> reportMap = new Map<String, ChangedReport__c>();
            Map<String, ChangedReport__c> insertReportMap = new Map<String, ChangedReport__c>();
            for ( String radiationType : radiationTypeQuantityMap.keySet()) {

                //代理商的代理商购买明细赋值
                Integer quantity = radiationTypeQuantityMap.get(radiationType);
                if (dealerModelQuantityMap.size() > 0) {
                    if ( dealerModelQuantityMap.containsKey(radiationType)) {

                        if (toloseFlag) {//减去已售产品数量
                            reportMap.putAll(upsertChangedReport(dealerId, radiationType, operationType, orderId, -quantity, operator));
                            dealerResult.get(radiationType).SoldNumber__c -= quantity;
                        } else {//增加已售产品数量
                            reportMap.putAll(upsertChangedReport(dealerId, radiationType, operationType, orderId, quantity, operator));
                            dealerModelQuantityMap.get(radiationType).SoldNumber__c += quantity;
                        }

                    } else {//增加已售产品数量
                        reportMap.putAll(upsertChangedReport(dealerId, radiationType, operationType, orderId, quantity, operator));
                        dealerModelQuantityMap = insertPurchaseDetail(dealerModelQuantityMap, dealerId, radiationType, radiationTypeQuantityMap);
                    }
                } else {
                    if (toloseFlag) {//减去已售产品数量
                        reportMap.putAll(upsertChangedReport(dealerId, radiationType, operationType, orderId, -quantity, operator));
                        dealerResult.get(radiationType).SoldNumber__c -= quantity;
                    } else {//增加已售产品数量
                        reportMap.putAll(upsertChangedReport(dealerId, radiationType, operationType, orderId, quantity, operator));
                        dealerModelQuantityMap = insertPurchaseDetail(dealerModelQuantityMap, dealerId, radiationType, radiationTypeQuantityMap);
                    }
                   

                }

                //奥林巴斯的代理商购买明细赋值
                if (olympusModelQuantityMap.size() > 0 ) {
                    if (olympusModelQuantityMap.containsKey(radiationType)) {
                        if (toloseFlag) {//减去已售产品数量
                            reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, -quantity, operator));
                            olympusResult.get(radiationType).SoldNumber__c -= quantity;
                        } else {//增加已售产品数量
                            reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator));
                            olympusModelQuantityMap.get(radiationType).SoldNumber__c += quantity;
                        }

                    } else {//增加已售产品数量
                        reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator));
                        olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap);
                    }
                } else {//减去已售产品数量
                    if (toloseFlag) {
                        reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, -quantity, operator));
                        olympusResult.get(radiationType).SoldNumber__c -= quantity;
                    } else {//增加已售产品数量
                        reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator));
                        olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap);
                    }
                    
                }
            }
            
            if (toloseFlag) {
                if ( dealerResult.size() > 0 && dealerResult != null) {
                    upsert dealerResult.values();

                    insertReportMap.putAll(insertChangedReport(dealerResult,reportMap));
                } 

                if ( olympusResult.size() > 0 && olympusResult != null) {
                    upsert olympusResult.values();
                    insertReportMap.putAll(insertChangedReport(olympusResult, reportMap));
                }

            } else {
                if ( dealerModelQuantityMap.size() > 0 && dealerModelQuantityMap != null) {
                    upsert dealerModelQuantityMap.values();
                    insertReportMap.putAll(insertChangedReport(dealerModelQuantityMap,reportMap));
                } 

                if ( olympusModelQuantityMap.size() > 0 && olympusModelQuantityMap != null) {
                    upsert olympusModelQuantityMap.values();
                    insertReportMap.putAll(insertChangedReport(olympusModelQuantityMap, reportMap));
                }
            }
                
            if ( insertReportMap.size() > 0 && insertReportMap != null) {
                insert insertReportMap.values();
            }
            
            Map<String, Integer> radiationMap =  new Map<String, Integer>();
            String accountDealerErrorMessage = updateCertificationDetails(dealerId, orderFounder, radiationMap, true);
            String olympusDealerErrorMessage = updateCertificationDetails(olympusAccountId, orderFounder, radiationMap, true);
        }

    }
    /**
     * 代理商购买明细操作详情赋值
     * @Author   稀里糊涂
     * @DateTime 2020-02-22
     * @param    detailsMap [description]代理商购买明细
     * @param    reportMap  [description]代理商购买明细操作详情
     * @return              [description]
     */
    public static Map<String, ChangedReport__c> insertChangedReport( Map<String, PurchaseDetails__c> detailsMap, Map<String, ChangedReport__c> reportMap) {
        for (PurchaseDetails__c detail : detailsMap.values()) {
            String accountId = detail.PurchaseAccount__c;
            //String accountIdafter = accountId.subString(0,15);
            String key = accountId.subString(0, 15) + detail.PurProductModel__c;
            if (reportMap.containsKey(key)) {
                reportMap.get(key).ChangedPurchase__c = detail.Id;
            }
        }

        return reportMap;
    }
    /**
     * [updateCertificationDetails description]更新代理商的证照明细
     * @param  accountId    [description]代理商Id
     * @param  orderFounder [description]合同创建人
     * @param  dataMap      [description]待验证的数据
     * @param  updateFlag   [description]是否更新数据
     * @return              [description]
     */
    public static String updateCertificationDetails( String accountId, String orderFounder, Map<String, Decimal> dataMap, Boolean updateFlag) {

        Map<String, CertificationDetails__c> certificationDetailMap = GetAccountCertificationDetail(accountId);
        Map<String, CertificationDetails__c> temporaryCertificationDetailMap = GetAccountCertificationDetail(accountId);
        Map<String, PurchaseDetails__c> purchaseDetailMap = GetPurchaseDetailsMap(accountId);

        Map<String, CertificationDetails__c> updatecertificationDetailMap = new Map<String, CertificationDetails__c>();
        String record = '';
        String errorMessage = '';
        if (certificationDetailMap.size() > 0 && certificationDetailMap != null ) {

            if (dataMap.size() > 0 && dataMap != null) {

                for (String temp : dataMap.keySet()) {
                    if (certificationDetailMap.containsKey(temp)) {

                    } else {
                        if (certificationDetailMap.containsKey('Delta和Vanta')) {
                            List<String> childModels = new List<String> {'Delta', 'Vanta'};
                            if (childModels.contains(temp)) {

                            } else {
                                errorMessage = '你不能' + temp + '系列产品' + certificationDetailMap.keySet();
                                return errorMessage;
                            }
                        } else {
                            errorMessage = '你不能' + temp + '系列产品' + certificationDetailMap.keySet();
                            return errorMessage;

                        }

                    }
                }
            }

            // 遍历查询出来的证照明细
            for (String model : certificationDetailMap.keySet()) {

                Decimal purchaseQuantity = 0;
                //获取辐射证照明细上，该型号对应的数量
                Decimal certificationQuantity = certificationDetailMap.get(model).ProductModelNumber__c;
                //获取证照的客户名称
                String accountName = certificationDetailMap.get(model).CertificationDetailAccountName__c;
                //获取证照的客户是否数量管控
                Boolean ifQuantityCtrl = certificationDetailMap.get(model).LicenseInformation__r.IfQuantityCtrl__c;
                //获取证照的客户的记录类型
                String  accountRecordType = certificationDetailMap.get(model).AccountRecordType__c;
                //证照的客户记录类型为代理商并且非数量管控直接跳过
                if (!ifQuantityCtrl && 'Dealer'.equals(accountRecordType)) {
                    system.debug(' 我被跳过了，请注意');
                    continue;    
                } else {
                    if (certificationQuantity == null || certificationQuantity == 0) {
                        errorMessage += record = '客户名 [ ' + accountName + ' ] 产品辐射类型 [ ' + model + ' ] 所对应可售数量异常！！！';
                        return errorMessage;
                    }
                }
                Decimal percentage = 0;
                Decimal originalQuantity = 0;
                Decimal newQuantity = 0;
                Boolean errorFlag = false;
                if (model.equals('Delta和Vanta')) {
                    List<String> childModels = new List<String> {'Delta', 'Vanta'};
                    for (String childModel : childModels) {
                        if (purchaseDetailMap.containsKey(childModel)) {
                            originalQuantity += purchaseDetailMap.get(childModel).SoldNumber__c;
                        }
                        if (dataMap != null && dataMap.size() > 0 && dataMap.containsKey(childModel)) {

                            newQuantity += dataMap.get(childModel);
                        }
                    }

                } else {
                    if (purchaseDetailMap.containsKey(model)) {
                        originalQuantity = purchaseDetailMap.get(model).SoldNumber__c;

                    }
                    if (dataMap != null && dataMap.size() > 0 && dataMap.containsKey(model)) {
                        newQuantity += dataMap.get(model);
                    }
                }

                purchaseQuantity = originalQuantity + newQuantity;

                percentage = purchaseQuantity / certificationQuantity;

                if (updateFlag) {

                    record = '客户名 [ ' + accountName + ' ] 产品辐射类型 [ ' + model + ' ] 已售出数量为 [ ' + originalQuantity + ' ] 件，允许售出的数量为 [ ' + certificationQuantity + ' ]件。' ;
                    // if (percentage <= 1) {

                    temporaryCertificationDetailMap = radiationSendEmailSign(certificationDetailMap, orderFounder, model, record, percentage, updateFlag);
                        // system.debug('temporaryCertificationDetailMap----->'+'(---'+accountName+'---)'+temporaryCertificationDetailMap);
                    updatecertificationDetailMap.putAll(temporaryCertificationDetailMap);
                    // } else {
                    //     errorMessage += record + '已超出可售数量限制，无法保存。\n';
                    // }

                } else {
                    if (newQuantity > 0) {
                        record = '客户名 [ ' + accountName + ' ] 产品辐射类型 [ ' + model + ' ] 已售出数量为 [ ' + originalQuantity + ' ] 件，新增 [ ' + newQuantity + ' ]件，允许售出的数量为 [ ' + certificationQuantity + ' ]件。';
                        if (percentage > 1) {

                            errorMessage += record + '已超出可售数量限制。\n';
                        }
                    }

                }

            }

            if (updateFlag) {

                if ( updatecertificationDetailMap.size() > 0) {
                    update updatecertificationDetailMap.values();
                }
            }
        }

        return errorMessage;


    }

    /**
     * [radiationSendEmailSign description]检验是否超过可售上限的80%，90%
     * @param  certificationDetailMap [description]代理商的证照明细
     * @param  orderFounder           [description]合同创建人Id
     * @param  model                  [description]辐射产品型号
     * @param  record                 [description]百分比记录
     * @param  percentage             [description]百分比
     * @param  updateFlag             [description]是否更新数据
     * @return                        [description]
     */
    public static Map<String, CertificationDetails__c> radiationSendEmailSign(Map<String, CertificationDetails__c> certificationDetailMap, String orderFounder, String model, String record, Decimal percentage, Boolean updateFlag) {

        Map<String, CertificationDetails__c> result = new  Map<String, CertificationDetails__c>();
        String olympusAccountId = System.label.Olympus_Id;

        CertificationDetails__c  detail = certificationDetailMap.get(model);
        system.debug('detail----->'+detail);
        // 当代理商为"奥林巴斯代理商"时，要给"马喜芝、王冉之"发送邮件
        if (olympusAccountId == detail.CertificationDetailAccount__c) {
            detail.OSHSafeguardOne__c = System.label.OSHSafeguardOne;
            detail.OSHSafeguardTwo__c = System.label.OSHSafeguardTwo;
        } 
        if (percentage >= 1) {
            detail.Ceiling100__c = true;
            detail.Ceiling80__c = true;
            detail.Ceiling90__c = true;
            detail.Record100__c = record + '已达到可售上限，请注意！';
            result.put(model, detail);
        }  else if (percentage >= 0.9) {
            detail.Ceiling80__c = true;
            detail.Ceiling90__c = true;
            detail.Record90__c = record + '已超过可售上限的90%，请注意！';
            result.put(model, detail);
        } else {

            if (percentage >= 0.8 && !detail.Ceiling90__c) {
                detail.Ceiling80__c = true;

                detail.Record80__c = record + '已超过可售上限的80%，请注意！';
                result.put(model, detail);
            }
        }
        return result;

    }
    /**
     * [GetAccountCertificationDetail description]查找代理商的的证照明细
     * @param  accountId [description]代理商Id
     * @return           [description]
     */
    public static Map<String, CertificationDetails__c> GetAccountCertificationDetail (String accountId) {
        Map<String, CertificationDetails__c> result = new Map<String, CertificationDetails__c>();
        List<CertificationDetails__c> certificationDetailsList = [ select Id, Name, ProdustionType__c, 
                                    ProductModelNumber__c, Ceiling80__c, Record80__c, Ceiling90__c, Record90__c , 
                                    CertificationDetailAccount__c, CertificationDetailAccountName__c,
                                    LicenseInformation__r.IfQuantityCtrl__c,AccountRecordType__c,Record100__c,
                                    Ceiling100__c
                                    from CertificationDetails__c 
                                    where CertificationDetailAccount__c = :accountId  
                                        and ActivitieTypes__c = '销售' and IsActive__c = true];

        for  (CertificationDetails__c detail : certificationDetailsList) {
            result.put(detail.ProdustionType__c, detail);
        }


        return result;


    }
    /**
     * [insertPurchaseDetail description]为代理商的代理商购买明细赋值
     * @param  modelQuantityMap         [description]代理商销售明细
     * @param  id                       [description]代理商Id
     * @param  productModel             [description]产品辐射类型
     * @param  radiationTypeQuantityMap [description]新增的类型及对应的数量
     * @return                          [description]
     */
    public static Map<String, PurchaseDetails__c> insertPurchaseDetail(Map<String, PurchaseDetails__c> modelQuantityMap,
            String id, String productModel, Map<String, Integer> radiationTypeQuantityMap) {
    	
        Map<String, CertificationDetails__c>  certificationDetailMap = GetAccountCertificationDetail(id);
        String effectiveYear = String.valueOf(Date.today().year());
       
        PurchaseDetails__c purchaseDetail = new PurchaseDetails__c();
        purchaseDetail.SoldNumber__c = radiationTypeQuantityMap.get(productModel);
        purchaseDetail.PurProductModel__c = productModel;
        purchaseDetail.PurchaseAccount__c = id;
        purchaseDetail.TakeEffectInYear__c = effectiveYear;

        for (String model:certificationDetailMap.keySet()) {
            if ('Delta和Vanta'.equals(model)) {

                List<String> childModels = new List<String> {'Delta', 'Vanta'};
                for (String childModel : childModels) {
                    if (childModel.equals(productModel)) {
                        purchaseDetail.PurchaseDetail__c = certificationDetailMap.get(model).Id;    
                    }
                }

            } else {
                purchaseDetail.PurchaseDetail__c = certificationDetailMap.get(productModel).Id;
            }
        }
        // purchaseDetail.PurchaseDetail__c = certificationDetailMap.get(productModel).Id;            
        modelQuantityMap.put(productModel, purchaseDetail);
        return modelQuantityMap;
    }

    /**
     * 代理商购买明细操作详情
     * @Author   XHL
     * @DateTime 2020-02-22
     * @param    accountId     [description]代理商Id
     * @param    radiationType [description]辐射产品系列
     * @param    operationType [description]操作类型
     * @param    orderId       [description]合同Id
     * @param    quantity      [description]变更数量
     * @param    operator      [description]操作人
     * @return                 [description]
     */
    public static Map<String, ChangedReport__c>  upsertChangedReport(String accountId, String radiationType, String operationType, String orderId, Integer quantity, String operator) {
        
        Map<String, ChangedReport__c> result = new Map<String, ChangedReport__c>();
        String key = accountId + radiationType;
        ChangedReport__c  changedReport = new ChangedReport__c();
        changedReport.ChangedReportOrder__c = orderId;
        changedReport.RadiationType__c = radiationType;
        changedReport.OperationType__c = operationType;
        changedReport.Operator__c = operator;
        changedReport.ChangeQuantity__c = quantity;

        result.put(key, changedReport);

        return result;

    }
    /**
     * [GetPurchaseDetailsMap description]获取客户的代理商购买明细的数据
     * @param  accountId [description]代理商Id
     * @return           [description]
     */
    public static Map<String, PurchaseDetails__c> GetPurchaseDetailsMap( String accountId) {
        String effectiveYear = String.valueOf(Date.today().year());
        Map<String, PurchaseDetails__c> result = new Map<String, PurchaseDetails__c>();
        List<PurchaseDetails__c> purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c,
                                 PurProductModel__c, PurchaseAccount__c
                                 from PurchaseDetails__c
                                 where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId];
        if (purchaseDetailsList.size() > 0) {
            for (PurchaseDetails__c purchaseDetail : purchaseDetailsList) {
                result.put(purchaseDetail.PurProductModel__c, purchaseDetail);
            }
        }

        return  result;
    }

    /**
     * [GetModelQuantityMap description]汇总辐射产品的型号和数量
     * @param  Id [description]合同Id
     * @return    [description]
     */
    public static  Map<String, Integer> GetModelQuantityMap(String Id) {
        Map<String, Integer> result = new Map<String, Integer>();
        List<OrderItem> orderItemList = [select Id, PriceBookEntry.Product2.If_Radiation_Product__c,
                                         PriceBookEntry.Product2.RadiationType__c, PriceBookEntry.Product2.If_Exempt_Product__c, Quantity, Order.Opportunity.Dealer__c
                                         from OrderItem
                                         where OrderId = :Id
                                                 order by QuoteLineItemId, Id];
        if ( orderItemList.size() > 0) {

            for ( OrderItem orderItem : orderItemList) {
                Boolean radiationFlag = orderItem.PriceBookEntry.Product2.If_Radiation_Product__c;
                Boolean exemptFlag = orderItem.PriceBookEntry.Product2.If_Exempt_Product__c;
                if ( radiationFlag && !exemptFlag) {
                    String radiationType = orderItem.PriceBookEntry.Product2.RadiationType__c;
                    Integer quantity  = Integer.valueOf(orderItem.Quantity);
                    if ( result.containsKey(radiationType)) {
                        Integer num = result.get(radiationType) + quantity;
                        result.put(radiationType, num);
                    } else {
                        result.put(radiationType, quantity);
                    }
                }

            }
        }

        return result;
    }

    public static  Map<String, Integer> GetOpportunityLineMap(String Id) {
        Map<String, Integer> result = new Map<String, Integer>();
        List<OpportunityLineItem> oppItemList = [select Id, PriceBookEntry.Product2.If_Radiation_Product__c,
                                  PriceBookEntry.Product2.RadiationType__c, PriceBookEntry.Product2.If_Exempt_Product__c, Quantity, Opportunity.Dealer__c
                                  from OpportunityLineItem
                                  where OpportunityId = :Id
                                          order by Id];
        if ( oppItemList.size() > 0) {

            for ( OpportunityLineItem oppItem : oppItemList) {
                Boolean radiationFlag = oppItem.PriceBookEntry.Product2.If_Radiation_Product__c;
                Boolean exemptFlag = oppItem.PriceBookEntry.Product2.If_Exempt_Product__c;
                if ( radiationFlag && !exemptFlag) {
                    String radiationType = oppItem.PriceBookEntry.Product2.RadiationType__c;
                    Integer quantity  = Integer.valueOf(oppItem.Quantity);
                    if ( result.containsKey(radiationType)) {
                        Integer num = result.get(radiationType) + quantity;
                        result.put(radiationType, num);
                    } else {
                        result.put(radiationType, quantity);
                    }
                }

            }
        }

        return result;
    }

    /**
     * 检查代理商能否可以卖某些辐射产品
     * @param  accountId [description]
     * @param  dataMap   [description]
     * @return           [description]
     */
    public static String GetCertificationDetail (String accountId, Map<String, Decimal> dataMap) {
        Map<String, CertificationDetails__c> certificationDetailMap = GetAccountCertificationDetail(accountId);
        System.debug(certificationDetailMap);
        String record = '';
        String errorMessage = '';
        if (certificationDetailMap.size() > 0 && certificationDetailMap != null ) {

            for (String temp : dataMap.keySet()) {
                if (certificationDetailMap.containsKey(temp)) {

                } else {
                    if (certificationDetailMap.containsKey('Delta和Vanta')) {
                        List<String> childModels = new List<String> {'Delta', 'Vanta'};
                        if (childModels.contains(temp)) {

                        } else {
                            errorMessage = '你不能' + temp + '系列产品' + certificationDetailMap.keySet();
                            return errorMessage;
                        }
                    } else {
                        errorMessage = '你不能' + temp + '系列产品' + certificationDetailMap.keySet();
                        return errorMessage;

                    }

                }
            }
        }
        return errorMessage;

    }
    
}