|  |  | 
 |  |  |             ins_opp.Dealer__c = opportunity.Dealer__c; | 
 |  |  |             ins_opp.CrossCooperativeDealer__c = opportunity.CrossCooperativeDealer__c; | 
 |  |  |             ins_opp.the_Upload_of_quotation_number__c = null; | 
 |  |  |             ins_opp.copyOpp__c = opp.Id; | 
 |  |  |             //ins_opp.org_opportunity__c = opp.Id; | 
 |  |  |             insert ins_opp; | 
 |  |  |  | 
 |  |  | 
 |  |  |                 OpportunityTeamMember ins_otm = otm.clone(); | 
 |  |  |                 ins_otm.OpportunityId = ins_opp.Id; | 
 |  |  |                 ins_otm.Id = null; | 
 |  |  |                 ins_otmList.add(ins_otm); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             System.debug(ins_otmList.size()); | 
 |  |  |             if (ins_otmList.size() >0 ) { | 
 |  |  |                 System.debug(ins_otmList); | 
 |  |  |                 insert ins_otmList; | 
 |  |  |             } | 
 |  |  |  | 
 
 |  |  | 
 |  |  |  | 
 |  |  |         Savepoint sp = Database.setSavepoint(); | 
 |  |  |         try { | 
 |  |  |  | 
 |  |  |             //0120K000000OptT正式环境 | 
 |  |  |             //0120T0000003Ser测试环境 | 
 |  |  |             opp.RecordTypeId = '0120T0000003Ser'; | 
 |  |  |             opp.SalesChannel__c = 'direct'; | 
 |  |  |             insert opp; | 
 |  |  | 
 |  |  |  | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public static void asd() { | 
 |  |  |         Integer i = 1; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |         i++; | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  | private class IENewOpportunityControllerTest { | 
 |  |  |  | 
 |  |  |     @isTest static void test_method_one() { | 
 |  |  |         IENewOpportunityController.asd(); | 
 |  |  |         List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE']; | 
 |  |  |         Account accIE = new Account( | 
 |  |  |             Name = '*', | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     WebService static String checkDealerId(String dealerId) { | 
 |  |  |         String rtn = '0'; | 
 |  |  |         // 获取系统管理员Id | 
 |  |  |         String getUserId = System.label.SystemAdmin1_2_GPI; | 
 |  |  |         // 获取当前用户Id | 
 |  |  |         String userId = UserInfo.getUserId().subString(0,15); | 
 |  |  |         dealerId.subString(0,15); | 
 |  |  |  | 
 |  |  |         String userDealerId; | 
 |  |  |         List<User> userList = new List<User>(); | 
 |  |  |         User user = new User(); | 
 |  |  |  | 
 |  |  |         if (String.isNotBlank(getUserId)) { | 
 |  |  |             if (!getUserId.contains(userId)) { | 
 |  |  |                 userList = [select mu_Dealer__c   | 
 |  |  |                 from User  | 
 |  |  |                 where id =: userId]; | 
 |  |  |  | 
 |  |  |                 user = userList[0]; | 
 |  |  |                 userDealerId = user.mu_Dealer__c; | 
 |  |  |                 if (String.isNotBlank(userDealerId)) { | 
 |  |  |                     userDealerId.substring(0,15); | 
 |  |  |                 } | 
 |  |  |                 if (userDealerId == dealerId) { | 
 |  |  |                     rtn = '1'; | 
 |  |  |                 } | 
 |  |  |             }else { | 
 |  |  |                 rtn = '0'; | 
 |  |  |             } | 
 |  |  |         }else { | 
 |  |  |             rtn = '0'; | 
 |  |  |         } | 
 |  |  |         System.debug('rtn='+rtn); | 
 |  |  |         return rtn; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 
 |  |  | 
 |  |  |         List<Order> orderList = [select Id, AccountId, OpportunityId, Opportunity.Dealer__c, Opportunity.SpecialDeliveryAddress__c, Opportunity.SpecialDeliveryContact__c,Opportunity.InquiryNumber__c, | 
 |  |  |                                         PDF_S_Name__c, PDF_S_Address__c, PDF_S_City__c, PDF_S_Province__c, PDF_S_Phone__c,Opportunity.CreatedBy.ContactId,CreatedBy.ContactId, | 
 |  |  |                                         Name, Opportunity.ExpectedDeliveryDate__c, PDF_Sap_No__c, OrderNumber, Opportunity.SubDealer__c, | 
 |  |  |                                         PDF_Property__c, Opportunity.Name, PDF_No__c, Description, PDF_Order_No__c,CrossCooperativeProject__c,Dealer_A__c, | 
 |  |  |                                         PDF_Property__c, Opportunity.Name, PDF_No__c, Description, PDF_Order_No__c,CrossCooperativeProject__c, | 
 |  |  |                                         Olympus_Price_BeforeDiscount_D__c, Discount_D__c, OlympusContractPricesD__c, CustomerContractPriceD__c, | 
 |  |  |                                         Opportunity.ProductSegment__c, Opportunity.SalesChannel__c, Opportunity.Machine_Parts__c, | 
 |  |  |                                         SpecialDeliveryAccount__c, SpecialDeliveryAccount_D__c, SpecialDeliveryContact2__c, SpecialDeliveryContact2_D__c | 
 |  |  | 
 |  |  |         }*/ | 
 |  |  |         buyer = new Account(); | 
 |  |  |         if (order.Opportunity.Dealer__c != null) { | 
 |  |  |              if (order.CrossCooperativeProject__c) { | 
 |  |  |              /*if (order.CrossCooperativeProject__c) { | 
 |  |  |                 buyer = [select Id, Name, Address1__c,Business_license__c, City__c, Province__c, Phone from Account where Id = :order.Dealer_A__c]; | 
 |  |  |             }else{ | 
 |  |  |                 buyer = [select Id, Name, Address1__c,Business_license__c, City__c, Province__c, Phone from Account where Id = :order.Opportunity.Dealer__c]; | 
 |  |  |             } | 
 |  |  |             //buyer = [select Id, Name, Address1__c,Business_license__c, City__c, Province__c, Phone from Account where Id = :order.Opportunity.Dealer__c]; | 
 |  |  |             }*/ | 
 |  |  |             buyer = [select Id, Name, Address1__c,Business_license__c, City__c, Province__c, Phone from Account where Id = :order.Opportunity.Dealer__c]; | 
 |  |  |         } | 
 |  |  |         notSpecialDealer = !StaticParameter.specialDealerMap.containsKey(((String)order.Opportunity.Dealer__c)); | 
 |  |  |         system.debug('order.Opportunity.Dealer__c' + order.Opportunity.Dealer__c); | 
 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |            //ProductListApproveStatus__c = 'Reject' | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  |  | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |            //ProductListApproveStatus__c = 'Reject' | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  |  | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |            //ProductListApproveStatus__c = 'Reject' | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  |  | 
 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  |  | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  |  | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  |  | 
 |  |  | 
 |  |  |             EffectiveDate = Date.today(), | 
 |  |  |             Status = 'Draft', | 
 |  |  |             Pricebook2Id = pricebook.Id, | 
 |  |  |             EndUser__c = contact.Id | 
 |  |  |             EndUser__c = contact.Id, | 
 |  |  |             EndUserD__c = contact.Id | 
 |  |  |         ); | 
 |  |  |         insert order; | 
 |  |  |  | 
 
 |  |  | 
 |  |  |                      | 
 |  |  |                     system.debug('2222222'+getModelQuantityMap); | 
 |  |  |                     String accountDealerErrorMessage = RadiationUtil.updateCertificationDetails(oliList[0].Opportunity.DealerId__c, null, getModelQuantityMap, false); | 
 |  |  |                     String olympusDealerErrorMessage = RadiationUtil.updateCertificationDetails(olympusAccountId, null, getModelQuantityMap, false) == '' ? '' : '奥林巴斯可销售数量不足'; | 
 |  |  |                     //result = accountDealerErrorMessage + (olympusDealerErrorMessage == '' ? '' : '奥林巴斯可销售数量不足') ; | 
 |  |  |                     String olympusDealerErrorMessage = RadiationUtil.updateCertificationDetails(olympusAccountId, null, getModelQuantityMap, false) == '' ? '' : '仪景通可销售数量不足'; | 
 |  |  |                     //result = accountDealerErrorMessage + (olympusDealerErrorMessage == '' ? '' : '仪景通可销售数量不足') ; | 
 |  |  |                     Boolean temp = accountDealerErrorMessage.startsWith('你不能'); | 
 |  |  |                     String strOly = LicenseCheckUtil.LicenseCheckOly(); | 
 |  |  |                     if(temp){ | 
 
| New file | 
 |  |  | 
 |  |  | /* | 
 |  |  |  * Author: Bubba Li | 
 |  |  |  * Created Date: 01/26/2022 | 
 |  |  |  * Purpose: Utility class for PI  | 
 |  |  |  * Test Class: PIHelper | 
 |  |  |  * History:  | 
 |  |  |  *      01/26/2022 - Bubba Li - Initial Code. | 
 |  |  |  *  | 
 |  |  |  * */ | 
 |  |  | global without sharing class PIHelper { | 
 |  |  |     public static String getObjectKeyPrefix(String objName){ | 
 |  |  |         try{ | 
 |  |  |             schema.sObjectType sObjType = Schema.getGlobalDescribe().get(objName); | 
 |  |  |             return (sObjType.getDescribe().getKeyPrefix()); | 
 |  |  |         }catch(Exception e){ | 
 |  |  |             system.debug('Exception from get key prefix:'+e.getMessage()); | 
 |  |  |             return ''; | 
 |  |  |         }     | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     // Use this log method | 
 |  |  |     public static void saveTransLog(String module,String awsDataId,String sfId, String transId,String content,String status,String respMsg){ | 
 |  |  |         Transaction_Log__c traLog = new Transaction_Log__c(); | 
 |  |  |         traLog.AWS_Data_Id__c = awsDataId; | 
 |  |  |         traLog.SFRecordId__c = sfId; | 
 |  |  |         traLog.Module__c = 'Upsert SF ' + module; | 
 |  |  |         traLog.TransId__c = transId; | 
 |  |  |         traLog.Request__c = content; | 
 |  |  |         traLog.Status__c = status; | 
 |  |  |         traLog.Response__c = respMsg; | 
 |  |  |         traLog.Interface_URL__c = traLog.Module__c; | 
 |  |  |         insert traLog; | 
 |  |  |     } | 
 |  |  |     public static PIIntegration getPIIntegrationInfo(String sobjectType){ | 
 |  |  |         PIIntegration piIntegration = new PIIntegration(); | 
 |  |  |         //查询url | 
 |  |  |         PI_Policy_Configuration__c config = [select Full_New_URL__c,Full_Search_URL__c,Full_Update_URL__c,Full_Undelete_URL__c,Full_Read_URL__c,Full_Delete_URL__c,TransactionURL__c from PI_Policy_Configuration__c where Sobject_Type__c =: sobjectType]; | 
 |  |  |         System.debug('config = ' + config); | 
 |  |  |  | 
 |  |  |         //获取appid和appsecret | 
 |  |  |         AWS_Integration_Info__mdt awsConfiguration = [SELECT App_Id__c,Token_URL__c,App_Secret__c,Host_URL__c FROM AWS_Integration_Info__mdt  WHERE DeveloperName = 'AWS_Default_Configuration']; | 
 |  |  |         if (awsConfiguration == null) { | 
 |  |  |             System.debug('AWS_Integration_Info__mdt没配置'); | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |         String awsAppId = awsConfiguration.App_Id__c; | 
 |  |  |         String awsAppSecret = awsConfiguration.App_Secret__c; | 
 |  |  |  | 
 |  |  |         System.debug('awsAppId = ' + awsAppId); | 
 |  |  |         System.debug('awsAppSecret = ' + awsAppSecret); | 
 |  |  |         System.debug('Host_URL__c = ' + awsConfiguration.Host_URL__c); | 
 |  |  |         System.debug('Token URL = ' + awsConfiguration.Token_URL__c); | 
 |  |  |  | 
 |  |  |         //获取token | 
 |  |  |         String token = ''; | 
 |  |  |         try{ | 
 |  |  |             Http http = new Http(); | 
 |  |  |             HttpRequest request = new HttpRequest(); | 
 |  |  |             String url = awsConfiguration.Token_URL__c; | 
 |  |  |             request.setEndpoint(url); | 
 |  |  |             request.setMethod('GET'); | 
 |  |  |             HttpResponse response = http.send(request); | 
 |  |  |             System.debug('response = ' + response); | 
 |  |  |             Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); | 
 |  |  |             token = (String)results.get('object'); | 
 |  |  |             System.debug('token = ' + token); | 
 |  |  |         }catch(Exception e){ | 
 |  |  |             // System.debug(e.getMessage()); | 
 |  |  |             // System.debug(e.getStackTraceString()); | 
 |  |  |             Transaction_Log__c traLog = new Transaction_Log__c(); | 
 |  |  |             traLog.Module__c = 'Get Token'; | 
 |  |  |             traLog.Status__c = 'fail'; | 
 |  |  |             traLog.Response__c = e.getMessage(); | 
 |  |  |             traLog.Interface_URL__c = awsConfiguration.Token_URL__c; | 
 |  |  |             insert traLog; | 
 |  |  |         } | 
 |  |  |      | 
 |  |  |         //Insert Get Token Log | 
 |  |  |  | 
 |  |  |         //获取敏感字段 | 
 |  |  |         piIntegration.PIDetails = [select id,PI_Policy_Configuration__r.Full_New_URL__c, Enable_Encrypt__c, SF_Field_API_Name__c,SF_Field_Encrypted_API__c, AWS_Field_API__c,AWS_Encrypted_Field_API__c,Field_Type__c from PI_Field_Policy_Detail__c  where PI_Policy_Configuration_Name__c =:sobjectType and Enable_Encrypt__c=true]; | 
 |  |  |         List<String> vLookUpFields = new List<String>(); | 
 |  |  |         List<String> PIFields = new List<String>(); | 
 |  |  |         for (PI_Field_Policy_Detail__c PIDetail : piIntegration.PIDetails) { | 
 |  |  |             if(PIDetail.Field_Type__c == 'Reference'){ | 
 |  |  |                 vLookUpFields.add(PIDetail.SF_Field_API_Name__c); | 
 |  |  |             } | 
 |  |  |             PIFields.add(PIDetail.SF_Field_API_Name__c); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         System.debug('vLookUpFields = ' + vLookUpFields.toString()); | 
 |  |  |         System.debug('PIFields = ' + PIFields.toString()); | 
 |  |  |  | 
 |  |  |         //填充数据 | 
 |  |  |         piIntegration.newUrl = config.Full_New_URL__c; | 
 |  |  |         piIntegration.updateUrl = config.Full_Update_URL__c; | 
 |  |  |         piIntegration.queryUrl = config.Full_Read_URL__c; | 
 |  |  |         piIntegration.deleteUrl = config.Full_Delete_URL__c; | 
 |  |  |         piIntegration.undeleteUrl = config.Full_Undelete_URL__c; | 
 |  |  |         piIntegration.transactionURL = config.TransactionURL__c; | 
 |  |  |         piIntegration.hostUrl = awsConfiguration.Host_URL__c; | 
 |  |  |         piIntegration.searchUrl = config.Full_Search_URL__c; | 
 |  |  |         piIntegration.token = token; | 
 |  |  |         piIntegration.awsAppId = awsAppId; | 
 |  |  |         piIntegration.awsAppSecret = awsAppSecret; | 
 |  |  |         piIntegration.vLookUpFields = vLookUpFields; | 
 |  |  |         piIntegration.PIFields = PIFields; | 
 |  |  |         piIntegration.sobjectPrefix = getObjectKeyPrefix(sobjectType); | 
 |  |  |         System.debug('piIntegration' + piIntegration); | 
 |  |  |         return piIntegration; | 
 |  |  |     } | 
 |  |  |     global class PIIntegration{ | 
 |  |  |         public String sobjectPrefix{set;get;} | 
 |  |  |         public String searchUrl{set;get;} | 
 |  |  |         public String newUrl{set;get;} | 
 |  |  |         public String updateUrl{set;get;} | 
 |  |  |         public String queryUrl{set;get;} | 
 |  |  |         public String deleteUrl{set;get;} | 
 |  |  |         public String undeleteUrl{set;get;} | 
 |  |  |         public String hostUrl{set;get;} | 
 |  |  |         public String token{set;get;} | 
 |  |  |         public String awsAppId{set;get;} | 
 |  |  |         public String awsAppSecret{set;get;} | 
 |  |  |         public String transactionUrl{set;get;} | 
 |  |  |         public List<String> vLookUpFields{set;get;} | 
 |  |  |         public List<String> PIFields{set;get;} | 
 |  |  |         public List<PI_Field_Policy_Detail__c > PIDetails{set;get;} | 
 |  |  |     } | 
 |  |  | } | 
 
| New file | 
 |  |  | 
 |  |  | <?xml version="1.0" encoding="UTF-8"?> | 
 |  |  | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | 
 |  |  |     <apiVersion>52.0</apiVersion> | 
 |  |  |     <status>Active</status> | 
 |  |  | </ApexClass> | 
 
| New file | 
 |  |  | 
 |  |  | public class PIHelperTest { | 
 |  |  |  | 
 |  |  | } | 
 
| New file | 
 |  |  | 
 |  |  | <?xml version="1.0" encoding="UTF-8"?> | 
 |  |  | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | 
 |  |  |     <apiVersion>54.0</apiVersion> | 
 |  |  |     <status>Active</status> | 
 |  |  | </ApexClass> | 
 
 |  |  | 
 |  |  |         if (UpdProMap.keySet().size() > 0)  update UpdProMap.values(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //产品降类,只要注册证更新了,就检查一遍,重新给产品上的等级类别字段赋值。 | 
 |  |  |     //可以找出需要的Id,然后调用方法。 | 
 |  |  |     //用于降类,产品注册证更新了,就把产品注册证下的产品的等级类别字段赋空,触发产品的触发器 | 
 |  |  |     public static void checkRegistervervaldatum(List<Product_Register__c> newList, Map<Id, Product_Register__c> newMap, List<Product_Register__c> oldList, Map<Id, Product_Register__c> oldMap) { | 
 |  |  |         List<String> prcList = new List<String>(); | 
 |  |  |         for (Product_Register__c pr : newList) { | 
 |  |  |             Product_Register__c oldpr = oldMap.get(pr.Id); | 
 |  |  |             //有效期的始与终变了,就把这个产品注册证的id放入一个List集合里面 | 
 |  |  |             //if (pr.ValidTo__c != oldpr.ValidTo__c || pr.ValidFrom__c != oldpr.ValidFrom__c) { | 
 |  |  |                 prcList.add(pr.id); | 
 |  |  |             //} | 
 |  |  |         } | 
 |  |  |         //放到Map里,用于注册证更新产品 | 
 |  |  |         Map<Id,Product2> prt2Map = new Map<Id,Product2>(); | 
 
 |  |  | 
 |  |  |        } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     //用于降类 | 
 |  |  |     public static void checkProduct2Level(List<Product2> newList, Map<Id, Product2> newMap, List<Product2> oldList, Map<Id, Product2> oldMap) { | 
 |  |  |         //取产品id | 
 |  |  |         List<String> p2ids = new List<String>(); | 
 |  |  |         for(Product2 p2 : newList) | 
 |  |  |         { | 
 |  |  |             p2ids.add(p2.id); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //存放查找的soql文 | 
 |  |  |         //存放查找的soql文,关系表里的产品和注册证相关字段 | 
 |  |  |         List<Product_Register_Link__c> pro2List = new List<Product_Register_Link__c>(); | 
 |  |  |         pro2List = [select Product2__r.id,Product2__r.demoteer_Sap__c,Product2__r.Diedatvanink__c,Product_Register__r.Stelsedag__c,Product_Register__r.MedPrdClass__c,Product_Register__r.ValidTo__c,Product_Register__r.ValidFrom__c,Product_Register__c,Product2__c  | 
 |  |  |         from Product_Register_Link__c  | 
 |  |  | 
 |  |  |         Map<Id,Date> prSte1Map = new Map<Id,Date>();//存二类维护日 | 
 |  |  |         if (pro2List.size()>0) { | 
 |  |  |             for (Product_Register_Link__c prl: pro2List) { | 
 |  |  |                 //有医疗器械分类就增加,没有就放进去 | 
 |  |  |                 if (pro2Map.containsKey(prl.Product2__r.Id)) { | 
 |  |  |                     pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c); | 
 |  |  |                 }else { | 
 |  |  |                     pro2Map.put(prl.Product2__r.Id, new List<String>()); | 
 |  |  |                     pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //一类证.维护日不为空.产品生产日期在注册证有效期之内,下面的是二类 | 
 |  |  |                 if (prl.Product_Register__r.MedPrdClass__c == '1' && prl.Product_Register__r.Stelsedag__c <> null &&  | 
 |  |  |                     newMap.get(prl.Product2__r.Id).demoteer_Sap__c <= prl.Product_Register__r.ValidTo__c && newMap.get(prl.Product2__r.Id).demoteer_Sap__c >= prl.Product_Register__r.ValidFrom__c) { | 
 |  |  |                     (newMap.get(prl.Product2__r.Id).demoteer_Sap__c <= prl.Product_Register__r.ValidTo__c && newMap.get(prl.Product2__r.Id).demoteer_Sap__c >= prl.Product_Register__r.ValidFrom__c)) { | 
 |  |  |                     if (prSteMap.containsKey(prl.Product2__r.Id)) { | 
 |  |  |                         if (prSteMap.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) { | 
 |  |  |                         //这一步,map可能有id,但是值是null,所以是null时也给他赋值 | 
 |  |  |                         if (prSteMap.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c || prSteMap.get(prl.Product2__r.Id) == null) { | 
 |  |  |                             prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c); | 
 |  |  |                         } | 
 |  |  |                     }else { | 
 |  |  |                         prSteMap.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c); | 
 |  |  |                     } | 
 |  |  |                 }else { | 
 |  |  |                     //不符合就赋空,和上面的判断条件有关联*** | 
 |  |  |                     if (!prSteMap.containsKey(prl.Product2__r.Id) || prSteMap.get(prl.Product2__r.Id) == null) { | 
 |  |  |                         prSteMap.put(prl.Product2__r.Id,null); | 
 |  |  |                     }   | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //和上面一样                | 
 |  |  |                 if ((prl.Product_Register__r.MedPrdClass__c == '2' || prl.Product_Register__r.MedPrdClass__c == '3') && prl.Product_Register__r.Stelsedag__c <> null &&  | 
 |  |  |                     newMap.get(prl.Product2__r.Id).demoteer_Sap__c <= prl.Product_Register__r.ValidTo__c && newMap.get(prl.Product2__r.Id).demoteer_Sap__c >= prl.Product_Register__r.ValidFrom__c) { | 
 |  |  |                     (newMap.get(prl.Product2__r.Id).demoteer_Sap__c <= prl.Product_Register__r.ValidTo__c && newMap.get(prl.Product2__r.Id).demoteer_Sap__c >= prl.Product_Register__r.ValidFrom__c)) { | 
 |  |  |                     System.debug(prSte1Map.containsKey(prl.Product2__r.Id)); | 
 |  |  |                     System.debug(prSte1Map); | 
 |  |  |                     if (prSte1Map.containsKey(prl.Product2__r.Id)) { | 
 |  |  |                         if (prSte1Map.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c) { | 
 |  |  |                         System.debug(prSte1Map.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c); | 
 |  |  |                         if (prSte1Map.get(prl.Product2__r.Id) > prl.Product_Register__r.Stelsedag__c || prSte1Map.get(prl.Product2__r.Id) == null) { | 
 |  |  |                             prSte1Map.put(prl.Product2__r.Id,prl.Product_Register__r.Stelsedag__c); | 
 |  |  |                         } | 
 |  |  |                     }else { | 
 |  |  | 
 |  |  |         System.debug('prSte1Map='+prSte1Map); | 
 |  |  |         Date stedate; | 
 |  |  |  | 
 |  |  |         //通过上面的循环,把关系表过获取的数据读出来,传给map | 
 |  |  |         //通过上面的循环,把关系表过获取的数据读出来,传给map,一共分为3个map,要注意 | 
 |  |  |         if (pro2Map.size()>0) { | 
 |  |  |             for (Product_Register_Link__c pr: pro2List) { | 
 |  |  |                 //保证id在上面的map里存在,但是这一步有没有好像没啥区别,又没错误,索性不删掉 | 
 |  |  |                 if (pro2Map.containsKey(pr.Product2__r.Id) && (prSteMap.containsKey(pr.Product2__r.Id) || prSte1Map.containsKey(pr.Product2__r.Id))) { | 
 |  |  |                     //取得是产品的生产日期在注册证的有效期内的注册证上面的维护日,一类优先,其次二类 | 
 |  |  |                     stedate = prSteMap.get(pr.Product2__r.Id)==null?(prSte1Map.get(pr.Product2__r.Id)==null?null:prSte1Map.get(pr.Product2__r.Id)):prSteMap.get(pr.Product2__r.Id); | 
 |  |  |                     if (stedate <> null) { | 
 |  |  |                         if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <> null && newMap.get(pr.Product2__r.Id).Diedatvanink__c <> null) { | 
 |  |  |                         //保证产品上的生产日有值 | 
 |  |  |                         if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <> null) { | 
 |  |  |                             //注册证维护日有值 | 
 |  |  |                             if (pr.Product_Register__r.Stelsedag__c <> null) { | 
 |  |  |                                 if (newMap.get(pr.Product2__r.Id).Diedatvanink__c <= stedate) { | 
 |  |  |                                 //入库日小于等于维护日 | 
 |  |  |                                 if (newMap.get(pr.Product2__r.Id).Diedatvanink__c == null || newMap.get(pr.Product2__r.Id).Diedatvanink__c <= stedate) { | 
 |  |  |                                    if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c | 
 |  |  |                                         && pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3') { | 
 |  |  |                                         System.debug('2'); | 
 |  |  | 
 |  |  |                                                 prlMap.put(pr.Product2__r.Id, Lins); | 
 |  |  |                                             } | 
 |  |  |                                     } | 
 |  |  |                                 }else if (newMap.get(pr.Product2__r.Id).Diedatvanink__c > stedate) { | 
 |  |  |                                 //入库日大于维护日 | 
 |  |  |                                 }else if (newMap.get(pr.Product2__r.Id).Diedatvanink__c <> null && newMap.get(pr.Product2__r.Id).Diedatvanink__c > stedate) { | 
 |  |  |                                     if (newMap.get(pr.Product2__r.Id).demoteer_Sap__c <= pr.Product_Register__r.ValidTo__c && newMap.get(pr.Product2__r.Id).demoteer_Sap__c >= pr.Product_Register__r.ValidFrom__c | 
 |  |  |                                         && pr.Product_Register__r.MedPrdClass__c == '1') { | 
 |  |  |                                         if (prl1Map.get(pr.Product2__r.Id) == null || !prl1Map.containsKey(pr.Product2__r.Id)) { | 
 |  |  | 
 |  |  |                                     } | 
 |  |  |                                 } | 
 |  |  |                             }else { | 
 |  |  |                                 //维护日空,这个map置空 | 
 |  |  |                                 prl2Map.put(pr.Product2__r.Id, '空'); | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     }else { | 
 |  |  |                         //前面map无值,这个map置空 | 
 |  |  |                         prl2Map.put(pr.Product2__r.Id, '空'); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  | 
 |  |  |                     pr2.Level_Category__c = '二类'; | 
 |  |  |                 } | 
 |  |  |             }else if (prl2Map.containsKey(pr2.Id)) { | 
 |  |  |                 //为了避免麻烦与后续修改,统一非监管了。 | 
 |  |  |                 pr2.Level_Category__c = '非监管'; | 
 |  |  |             } | 
 |  |  |             if (pr2.demoteer_Sap__c == null || pr2.Diedatvanink__c == null) { | 
 |  |  |             //生产日无值,等级类别置空 | 
 |  |  |             if (pr2.demoteer_Sap__c == null) { | 
 |  |  |                 pr2.Level_Category__c = null; | 
 |  |  |             } | 
 |  |  |             System.debug('pr2.Level_Category__c='+pr2.Level_Category__c); | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     public static Boolean oldOrder = false; | 
 |  |  |  | 
 |  |  |     public static BOolean is_oly = false; | 
 |  |  |  | 
 |  |  |     public static Boolean EscapeOrderTriggerHandler = true; | 
 |  |  |     /** | 
 |  |  |      * [updateRadiationTypeQuantity description]更新代理商证照明细,更新奥林巴斯代理商的证照明细 | 
 |  |  | 
 |  |  |     public static void updateRadiationTypeQuantity (String Id, String orderFounder, String dealerId, Boolean toloseFlag, String operationType, String operator) { | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         String olympusAccountId = oldOrder ? System.label.Olympus_Id : System.label.newOlympus_Id; | 
 |  |  |         String olympusAccountId =  System.label.Olympus_Id ; | 
 |  |  |  | 
 |  |  |         String orderId = Id; | 
 |  |  |         //获取合同的辐射类型和数量 | 
 |  |  | 
 |  |  |             //查代理商的代理商购买明细 | 
 |  |  |             Map<String, PurchaseDetails__c> dealerModelQuantityMap = GetPurchaseDetailsMap(dealerId); | 
 |  |  |             //查奥林巴斯的代理商购买明细 | 
 |  |  |             is_oly = true; | 
 |  |  |             Map<String, PurchaseDetails__c> olympusModelQuantityMap = GetPurchaseDetailsMap(olympusAccountId); | 
 |  |  |             is_oly = false; | 
 |  |  |             // 查找 合同提交对应的代理商购买明细 | 
 |  |  |             Map<String, PurchaseDetails__c> dealerResult = new Map<String, PurchaseDetails__c>(); | 
 |  |  |             Map<String, PurchaseDetails__c> olympusResult = new Map<String, PurchaseDetails__c>(); | 
 |  |  | 
 |  |  |  | 
 |  |  |                     } else {//增加已售产品数量 | 
 |  |  |                         reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator)); | 
 |  |  |                         is_oly = true; | 
 |  |  |                         olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap); | 
 |  |  |                         is_oly = false; | 
 |  |  |                     } | 
 |  |  |                 } else {//减去已售产品数量 | 
 |  |  |                     if (toloseFlag) { | 
 |  |  | 
 |  |  |                         olympusResult.get(radiationType).SoldNumber__c -= quantity; | 
 |  |  |                     } else {//增加已售产品数量 | 
 |  |  |                         reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator)); | 
 |  |  |                         is_oly = true; | 
 |  |  |                         olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap); | 
 |  |  |                         is_oly = false; | 
 |  |  |                     } | 
 |  |  |                      | 
 |  |  |                 } | 
 |  |  | 
 |  |  |  | 
 |  |  |                 if ( olympusResult.size() > 0 && olympusResult != null) { | 
 |  |  |                     upsert olympusResult.values(); | 
 |  |  |                     is_oly = true; | 
 |  |  |                     insertReportMap.putAll(insertChangedReport(olympusResult, reportMap)); | 
 |  |  |                     is_oly = false; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |             } else { | 
 |  |  | 
 |  |  |  | 
 |  |  |                 if ( olympusModelQuantityMap.size() > 0 && olympusModelQuantityMap != null) { | 
 |  |  |                     upsert olympusModelQuantityMap.values(); | 
 |  |  |                     is_oly = true; | 
 |  |  |                     insertReportMap.putAll(insertChangedReport(olympusModelQuantityMap, reportMap)); | 
 |  |  |                     is_oly = false; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |                  | 
 |  |  | 
 |  |  |              | 
 |  |  |             Map<String, Integer> radiationMap =  new Map<String, Integer>(); | 
 |  |  |             String accountDealerErrorMessage = updateCertificationDetails(dealerId, orderFounder, radiationMap, true); | 
 |  |  |             is_oly = true; | 
 |  |  |             String olympusDealerErrorMessage = updateCertificationDetails(olympusAccountId, orderFounder, radiationMap, true); | 
 |  |  |             is_oly = false; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  | 
 |  |  |             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              [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>(); | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     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,  | 
 |  |  |         List<CertificationDetails__c> certificationDetailsList = new List<CertificationDetails__c>(); | 
 |  |  |         if (oldOrder && is_oly) { | 
 |  |  |             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 = false]; | 
 |  |  |              | 
 |  |  |         }else{ | 
 |  |  |             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, | 
 |  |  | 
 |  |  |                                     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); | 
 |  |  | 
 |  |  |         purchaseDetail.PurProductModel__c = productModel; | 
 |  |  |         purchaseDetail.PurchaseAccount__c = id; | 
 |  |  |         purchaseDetail.TakeEffectInYear__c = effectiveYear; | 
 |  |  |         if (oldOrder && is_oly) { | 
 |  |  |             purchasedetail.company__c = '奥林巴斯'; | 
 |  |  |         }else if(is_oly){ | 
 |  |  |             purchaseDetail.company__c = '仪景通光学科技'; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         for (String model:certificationDetailMap.keySet()) { | 
 |  |  |             if ('Delta和Vanta'.equals(model)) { | 
 |  |  | 
 |  |  |     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, | 
 |  |  |         List<PurchaseDetails__c> purchaseDetailsList = new List<PurchaseDetails__c>(); | 
 |  |  |         if(is_oly == false){ | 
 |  |  |             purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c, | 
 |  |  |                                  PurProductModel__c, PurchaseAccount__c | 
 |  |  |                                  from PurchaseDetails__c | 
 |  |  |                                  where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId]; | 
 |  |  |         }else{ | 
 |  |  |             if (oldOrder) { | 
 |  |  |                 purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c, | 
 |  |  |                                  PurProductModel__c, PurchaseAccount__c | 
 |  |  |                                  from PurchaseDetails__c | 
 |  |  |                                  where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId and company__c = '奥林巴斯']; | 
 |  |  |             }else{ | 
 |  |  |                 purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c, | 
 |  |  |                                  PurProductModel__c, PurchaseAccount__c | 
 |  |  |                                  from PurchaseDetails__c | 
 |  |  |                                  where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId and company__c = '仪景通光学科技']; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if (purchaseDetailsList.size() > 0) { | 
 |  |  |             for (PurchaseDetails__c purchaseDetail : purchaseDetailsList) { | 
 |  |  |                 result.put(purchaseDetail.PurProductModel__c, purchaseDetail); | 
 
 |  |  | 
 |  |  |  | 
 |  |  |         public String ProductCode;//物料 | 
 |  |  |         public String ProductDate;//监管产品最早生产日期 | 
 |  |  |  | 
 |  |  |         public String StorageDate;//监管产品入库日期 | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |         String result = ''; | 
 |  |  |         //根据产品Code查询产品信息 | 
 |  |  |         List<Product2> getProductList =  | 
 |  |  |                     [SELECT Id, Name, ProductCode,demoteer_Sap__c  | 
 |  |  |                     [SELECT Id, Name, ProductCode,demoteer_Sap__c,Diedatvanink__c  | 
 |  |  |                     FROM Product2  | 
 |  |  |                     WHERE ProductCode  | 
 |  |  |                     IN:satisfyGeDataDetailMap.keyset()  | 
 |  |  | 
 |  |  |             if (productMap.containsKey(productCode)) { | 
 |  |  |                 GeDataDetails geDataDetails = satisfyGeDataDetailMap.get(productCode); | 
 |  |  |                 Date demoteer_Sap = NFMUtil.parseStr2Date(geDataDetails.ProductDate, false); | 
 |  |  |                 Date Diedatvanink = NFMUtil.parseStr2Date(geDataDetails.StorageDate, false); | 
 |  |  |                 Product2  product = productMap.get(productCode); | 
 |  |  |                 product.demoteer_Sap__c = demoteer_Sap; | 
 |  |  |                 product.Diedatvanink__c = Diedatvanink; | 
 |  |  |  | 
 |  |  |                 productMap.put(productCode,product); | 
 |  |  |                 result += 'productCode [ ' + productCode + ' ]\n';   | 
 
 |  |  | 
 |  |  |                                                 Opportunity.SalesChannel__c, Opportunity.ExpectedDeliveryDate__c, Opportunity.DealerId__c,Opportunity.DealerSalesStaffName__c,OlympusContractPricesD__c,SpecialDeliveryContact_D__c,Opportunity.SpecialDeliveryContact_D__r.ManagementCode_F__c, | 
 |  |  |                                                 Opportunity.ForeignTradeCompany__c, Opportunity.SpecialDeliveryAddress__c,PaymentTerms__c,SpecialDeliveryContact__c,PDF_Sp_Shipment_Term__c,PDF_Sp_ShippingTerms__c, | 
 |  |  |                                                 ForeignTradeCompany_D__r.ManagementCode_F__c, SpecialDeliveryAccount_D__r.ManagementCode_F__c, SpecialDeliveryContact2_D__r.ManagementCode_F__c,Opportunity.Dealer__r.DummyDealer__c,ContractPriceTotal__c, | 
 |  |  |                                                 If_Supervise__c,CrossCooperativeDealerCode__c,SplitRatio__c,CrossCooperativeProject__c,Level_Category__c,DealerSalesStaffNameA__c,Dealer_A__r.ManagementCode_Ext__c,Dealer_B__r.ManagementCode_F__c | 
 |  |  |                                                 If_Supervise__c,CrossCooperativeDealerCode__c,SplitRatio__c,CrossCooperativeProject__c,Level_Category__c,DealerSalesStaffNameA__c,Dealer_A__r.ManagementCode_Ext__c,Dealer_B__r.ManagementCode_F__c  | 
 |  |  |                                              from order where Id IN :ordIds ]; | 
 |  |  |             //List<order> ordList = [select Id,Name,Opportunity.Name, Opportunity.CurrencyIsoCode,OrderNumber,Opportunity.ForeignTradeCompany__r.ManagementCode_F__c,CustomerContractPriceD__c,SpecialCondition_text__c,SalesChannel__c, | 
 |  |  |             //                                    Owner.Name,Opportunity.AccountId__c,Opportunity.InquiryNumber__c,Opportunity.SpecialDeliveryAddress__r.ManagementCode_F__c, ServiceFee_D__c,Opportunity.SpecialDeliveryAddress_D__c,Opportunity.SpecialDeliveryAddress_D__r.ManagementCode_F__c, | 
 |  |  | 
 |  |  |                 //CBPR | 
 |  |  |                 if (ord.Opportunity.Dealer__r.DummyDealer__c == true || ord.Opportunity.SalesChannel__c == 'direct'){ | 
 |  |  |                 quotation.DealerCode          = ord.Opportunity.Account.ManagementCode_F__c; | 
 |  |  |                 quotation.SalesAccountCode                   = ord.SpecialDeliveryAccount_D__r.ManagementCode_F__c; | 
 |  |  |                     if (ord.Opportunity.TradeType__c == 'Tax Exemption' && ord.Opportunity.SalesChannel__c == 'direct') { | 
 |  |  |                         quotation.SalesAccountCode = ord.Opportunity.Account.ManagementCode_F__c; | 
 |  |  |                     }else { | 
 |  |  |                         quotation.SalesAccountCode = ord.SpecialDeliveryAccount_D__r.ManagementCode_F__c; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 else{ | 
 |  |  |                 quotation.DealerCode          = ord.Opportunity.Dealer__r.ManagementCode_Ext__c; | 
 |  |  | 
 |  |  |                 quotation.Other2            = other2;//ord.SpecialCondition_text__c; | 
 |  |  |                 quotation.Other3            = ord.Shipment_Term_D__c + ',' + ord.Shipment_Term2_D__c; | 
 |  |  |                 // 跨区域销售 XHL 20210831 Start | 
 |  |  |                 quotation.CoopAgent = ''; | 
 |  |  |                 /*quotation.CoopAgent = ''; | 
 |  |  |                 quotation.CoopAgentPCT = ''; | 
 |  |  |                 if (ord.CrossCooperativeProject__c) {//跨省份合作项目 | 
 |  |  |                     quotation.CoopAgent = ord.Dealer_B__r.ManagementCode_F__c;//合作区域代理商Code | 
 |  |  | 
 |  |  |                         Integer pct = Integer.valueOf(splitRatio.split(':')[1].trim())*10; | 
 |  |  |                         quotation.CoopAgentPCT = String.valueof(pct);//业绩拆分比例(取:后边的值*10) | 
 |  |  |                     }  | 
 |  |  |                 } */ | 
 |  |  |  | 
 |  |  |                 quotation.CoopAgent = ''; | 
 |  |  |                 quotation.CoopAgentPCT = ''; | 
 |  |  |                 if (ord.CrossCooperativeProject__c) {//跨省份合作项目 | 
 |  |  |                     quotation.CoopAgent = ord.CrossCooperativeDealerCode__c;//合作区域代理商Code | 
 |  |  |                     String splitRatio = ord.SplitRatio__c; | 
 |  |  |                     if (String.isNotBlank(splitRatio) && splitRatio.indexof(':') > 0) { | 
 |  |  |                         Integer pct = Integer.valueOf(splitRatio.split(':')[1].trim())*10; | 
 |  |  |                         quotation.CoopAgentPCT = String.valueof(pct);//业绩拆分比例(取:后边的值*10) | 
 |  |  |                     }  | 
 |  |  |                 }  | 
 |  |  |                 // 跨区域销售 XHL 20210831 End | 
 |  |  |                 quotation.GeDataDetails = new List<GeDataDetails_element>(); | 
 
 |  |  | 
 |  |  |             RecordTypeId = '01228000000NJt6', | 
 |  |  |             confirm__c = false, | 
 |  |  |             SP_21__c = true, | 
 |  |  |             EndUser__c = con.Id | 
 |  |  |             Discount_D__c = 10, | 
 |  |  |             EndUser__c = con.Id, | 
 |  |  |             EndUserD__c = con.Id | 
 |  |  |         ); | 
 |  |  |         insert odr; | 
 |  |  |  | 
 
 |  |  | 
 |  |  |         }    | 
 |  |  | System.debug('-----SBG027OrderTrigger start');     | 
 |  |  |         Map<Id, Id> accIds = new Map<Id, Id>(); | 
 |  |  |             List<String> strlist = new List<String>(); | 
 |  |  |                 for (Order newOrd : newList) { | 
 |  |  |             | 
 |  |  |                 /*for (Order newOrd : newList) { | 
 |  |  |                     strlist.add(newOrd.id); | 
 |  |  |                 } | 
 |  |  |                 }*/ | 
 |  |  |  | 
 |  |  |                 for (Order newOrd : newList) { | 
 |  |  |                      Order oldOrd = oldMap.get(newOrd.Id); | 
 |  |  |                      if (oldOrd.confirm__c ==false && newOrd.confirm__c == true ){ | 
 |  |  |                      if ((oldOrd.confirm__c ==false && newOrd.confirm__c == true)  || newOrd.Is_batch__c == true){ | 
 |  |  |                         newOrd.Is_batch__c = false; | 
 |  |  |                         SBG027TriggerHandler.SBG027_Ids.add(newOrd.Id); | 
 |  |  |                         BatchIF_Log__c iflog = new BatchIF_Log__c(); | 
 |  |  |                         iflog.Type__c = 'SBG027'; | 
 |  |  |                         iflog.Log__c  = 'callout start\n'; | 
 |  |  |                         insert iflog; | 
 |  |  |                         List<String> strlist = new List<String>(); | 
 |  |  |                         strlist.add(newOrd.id); | 
 |  |  |                         iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id]; | 
 |  |  |                         //SBG027TriggerHandler.callout(iflog.id,strlist, new Map<String, String>()); | 
 |  |  |                         SBG027Controller.callout(iflog.id,strlist, new Map<String, String>()); | 
 
 |  |  | 
 |  |  |     public static void deleteAccountLicenseInformation(Map<String, Account> accountMap) { | 
 |  |  |  | 
 |  |  |         System.debug('deleteAccountLicenseInformation--->Start'); | 
 |  |  |         List<License_Information__c> existList = [select id, Name, AccountManagementCode__c | 
 |  |  |                 from License_Information__c where AccountManagementCode__c In :accountMap.keySet()]; | 
 |  |  |         List<License_Information__c> existList = [select id, Name, AccountManagementCode__c,Is_Active_Formula__c  | 
 |  |  |                 from License_Information__c where AccountManagementCode__c In :accountMap.keySet() and Is_Active_Formula__c = true]; | 
 |  |  |  | 
 |  |  |         if (existList.size() > 0) { | 
 |  |  |             delete existList; | 
 
 |  |  | 
 |  |  |         public String ValidFrom;          //注册证号效期从 | 
 |  |  |         public String ValidTo;            //注册证号效期至 | 
 |  |  |         public String MedPrdClass;        //医疗器械分类 | 
 |  |  |         public String EffectDate;         //系统维护日 | 
 |  |  |  | 
 |  |  |         public String Model;              //产品型号 | 
 |  |  |         public String ProductName;        //产品名称(委托产品名称) | 
 |  |  | 
 |  |  |                     pr.RegisterNoClass_Old__c = data.RegisterNoClass_Old; //注册证号分类编号(旧) | 
 |  |  |                     pr.ValidFrom__c           = NFMUtil.parseStr2Date(data.ValidFrom);          //注册证号效期从 | 
 |  |  |                     pr.ValidTo__c             = NFMUtil.parseStr2Date(data.ValidTo);            //注册证号效期至 | 
 |  |  |                     pr.Stelsedag__c           = NFMUtil.parseStr2Date(data.EffectDate);         //系统维护日 | 
 |  |  |                     pr.MedPrdClass__c         = data.MedPrdClass;        //医疗器械分类 | 
 |  |  |                     pr.PrdCompanyLicense__c   = data.PrdCompanyLicense;  //生产企业许可证号/备案凭证号 | 
 |  |  |                     pr.PrdCompanyAddr__c      = data.PrdCompanyAddr;     //生产企业地址 | 
 
 |  |  | 
 |  |  |         '0010K00002W6zlh' => '00G0K000004AYjU',//成都盛锴科技有限公司(NDT) | 
 |  |  |         '0010K00002ZVOwt' => '00G0K000004c0oG',//天津宏基伟业科技发展有限公司(NDT) | 
 |  |  |         '0010K00002b6v6W' => '00G0K000004c4xH',//成都主导科技有限责任公司(NDT) | 
 |  |  |         '0010T00000LO3ph' => '00G0T0000029vfq'//北京深景量光科技有限公司(BS) | 
 |  |  |         /*'0010T00000LO3ph' => '00G0T0000029vfq'//北京深景量光科技有限公司(BS)*/ | 
 |  |  |         '0010K00002dmXEJ' => '00G0K0000059tJo'//北京主导科技有限责任公司(NDT) | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     public static List<String> specialDealerList = new List<String>{ |