SWAG-CBUB2W 【委托】【优先】询问单相关修改
| | |
| | | |
| | | protected override void beforeInsert() { |
| | | beforeExecute(); |
| | | //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 start |
| | | // getContactInformation(); |
| | | //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 end |
| | | } |
| | | protected override void beforeUpdate() { |
| | | beforeExecute(); |
| | | //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 start |
| | | // getContactInformation(); |
| | | //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 end |
| | | } |
| | | |
| | | protected override void afterInsert() { |
| | | shareToOSCM(); |
| | | //shareToOSCM(); |
| | | } |
| | | |
| | | protected override void afterUpdate() { |
| | | shareToOSCM(); |
| | | //shareToOSCM(); |
| | | } |
| | | //Before処理 |
| | | private void beforeExecute() { |
| | | Map<Id,Inquiry_form__c> accMap = new Map<Id,Inquiry_form__c>(); |
| | | Map<Id,Account> accMap = new Map<Id,Account>(); |
| | | Inquiry_form__c oObj = null; |
| | | List<String> depIDList = new List<String>(); |
| | | List<Account> accList = new List<Account>(); |
| | | |
| | | for(Inquiry_form__c nnObj : newList) { |
| | | if (oldMap != null && oldMap.containsKey(nnObj.Id)) { |
| | | oObj = oldMap.get(nnObj.Id); |
| | | } |
| | | if (String.isNotBlank(nnObj.Hospital_Name__c) && (Trigger.isInsert || oObj.Hospital_Name__c != nnObj.Hospital_Name__c || System.Label.Inquiry_form_flag == 'True')) { |
| | | depIDList.add(nnObj.Hospital_Name__c); |
| | | } |
| | | if (Trigger.isUpdate && String.isBlank(nnObj.Hospital_Name__c)){ |
| | | nnObj.Depart_Owner__c = null; //战略科室所有人 |
| | | nnObj.OwnerId = nnObj.CreatedById; //所有人 |
| | | nnObj.Department_Class__c = null; //战略科室 |
| | | nnObj.HospitalName__c = null; //医院名 |
| | | nnObj.Hospital__c = null; //医院 |
| | | } |
| | | } |
| | | if (depIDList.size()>0) { |
| | | accList = [Select Id,OwnerId, |
| | | Hospital__c,Hospital__r.Name, |
| | | Department_Class__c |
| | | from Account where Id =: depIDList]; |
| | | if (accList.size()>0) { |
| | | for(Account acc : accList){ |
| | | accMap.put(acc.Id, acc); |
| | | } |
| | | } |
| | | } |
| | | |
| | | for(Inquiry_form__c nObj : newList) { |
| | | List<Account> accList = [Select Id,OwnerId from Account where Id =: nObj.Department_ID__c]; |
| | | for(Account acc : accList){ |
| | | nObj.Depart_Owner__c = acc.OwnerId; |
| | | } |
| | | if (accMap.containsKey(nObj.Hospital_Name__c)){ |
| | | nObj.Depart_Owner__c = accMap.get(nObj.Hospital_Name__c).OwnerId; //战略科室所有人 |
| | | nObj.OwnerId = accMap.get(nObj.Hospital_Name__c).OwnerId; //所有人 |
| | | nObj.Department_Class__c = accMap.get(nObj.Hospital_Name__c).Department_Class__c; //战略科室 |
| | | nObj.HospitalName__c = accMap.get(nObj.Hospital_Name__c).Hospital__r.Name; //医院名 |
| | | nObj.Hospital__c = accMap.get(nObj.Hospital_Name__c).Hospital__c; //医院 |
| | | } |
| | | |
| | | //产品信息的拼接 |
| | | if (String.isNotBlank(nObj.Product1__c) && String.isNotBlank(nObj.Product1_Manual__c)){ |
| | | nObj.Product1__c = nObj.Product1__c +';'+nObj.Product1_Manual__c; |
| | | }else if (String.isBlank(nObj.Product1__c) && String.isNotBlank(nObj.Product1_Manual__c)){ |
| | | nObj.Product1__c = nObj.Product1_Manual__c; |
| | | }else if (String.isNotBlank(nObj.Product1__c) && String.isBlank(nObj.Product1_Manual__c)) { |
| | | nObj.Product1__c = nObj.Product1__c; |
| | | }else { |
| | | nObj.Product1__c = ''; |
| | | } |
| | | |
| | | //产品咨询单名称 |
| | | if (String.isNotBlank(nObj.Product1__c)&& String.isNotBlank(nObj.HospitalName__c)){ |
| | | nObj.Name = nObj.HospitalName__c+'-'+nObj.Product1__c; |
| | | }else if (String.isBlank(nObj.HospitalName__c)&& String.isNotBlank(nObj.Product1__c)) { |
| | | nObj.Name = nObj.Product1__c; |
| | | }else if (String.isNotBlank(nObj.HospitalName__c)&& String.isBlank(nObj.Product1__c)){ |
| | | nObj.Name = nObj.HospitalName__c; |
| | | }else{ |
| | | nObj.Name = '*'; |
| | | } |
| | | |
| | | nObj.Product1_Manual__c = ''; |
| | | } |
| | | } |
| | | |
| | | |
| | | //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 start |
| | | // private void getContactInformation(){ |
| | | // List<String> ContactIdList = new List<String>(); |
| | | // List<Contact> ContactList = new List<Contact>(); |
| | | // Map<String, Contact> ContactMap = new Map<String, Contact>(); |
| | | // for(Inquiry_form__c nnObj : newList) { |
| | | // if(String.isNotBlank(nnObj.Contact_Name__c)){ |
| | | // ContactIdList.add(nnObj.Contact_Name__c); |
| | | // } |
| | | // } |
| | | // if(ContactIdList.size() > 0){ |
| | | // ContactList = [select id, Phone, Email from Contact where Id IN :ContactIdList]; |
| | | // for(Contact contact : ContactList){ |
| | | // ContactMap.put(contact.Id, contact); |
| | | // } |
| | | // } |
| | | // for(Inquiry_form__c nnObj : newList) { |
| | | // if(String.isNotBlank(nnObj.Contact_Name__c)){ |
| | | // if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Phone)){ |
| | | // nnObj.Phone__c = ContactMap.get(nnObj.Contact_Name__c).Phone; |
| | | // } |
| | | // if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Email)){ |
| | | // nnObj.Email__c = ContactMap.get(nnObj.Contact_Name__c).Email; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 end |
| | | |
| | | // 战略科室的主担当 を取得、Inquiry_form__Shareに設定(Read) |
| | | private void shareToOSCM() { |
| | | //存放用于新增的共享数据 |
| | | List<Inquiry_form__Share> insertList = new List<Inquiry_form__Share>(); |
| | | //存放(会议询问单id,共享对象) |
| | | Map<Id,Inquiry_form__Share> insertMap = new Map<Id,Inquiry_form__Share>(); |
| | | //存放最后需要新增的共享数据 |
| | | List<Inquiry_form__Share> lastInsertList = new List<Inquiry_form__Share>(); |
| | | //存放已有的相同的共享原因的数据 |
| | | List<Id> deleteTargetAOIdList = new List<Id>(); |
| | | //存放用于的id |
| | | List<Id> userIdList = new List<Id>(); |
| | | // String rowCause = 'Manual'; |
| | | //新增一个共享原因 |
| | | String rowCause = Schema.Inquiry_form__Share.RowCause.OCSM_Owner_c_User__c; |
| | | System.debug('rowCause:'+rowCause); |
| | | String ownerCause = 'Owner'; |
| | | //Apex共有の理由名OCSM_Owner_c_User |
| | | for(Inquiry_form__c nObj : newList) { |
| | | Inquiry_form__c oObj = null; |
| | | System.debug('战略科室担当:'+nObj.Depart_Owner__c); |
| | | if (oldMap != null && oldMap.containsKey(nObj.Id)) { |
| | | oObj = oldMap.get(nObj.Id); |
| | | } |
| | | // private void shareToOSCM() { |
| | | // //存放用于新增的共享数据 |
| | | // List<Inquiry_form__Share> insertList = new List<Inquiry_form__Share>(); |
| | | // //存放(会议询问单id,共享对象) |
| | | // Map<Id,Inquiry_form__Share> insertMap = new Map<Id,Inquiry_form__Share>(); |
| | | // //存放最后需要新增的共享数据 |
| | | // List<Inquiry_form__Share> lastInsertList = new List<Inquiry_form__Share>(); |
| | | // //存放已有的相同的共享原因的数据 |
| | | // List<Id> deleteTargetAOIdList = new List<Id>(); |
| | | // //存放用于的id |
| | | // List<Id> userIdList = new List<Id>(); |
| | | // // String rowCause = 'Manual'; |
| | | // //新增一个共享原因 |
| | | // String rowCause = Schema.Inquiry_form__Share.RowCause.OCSM_Owner_c_User__c; |
| | | // System.debug('rowCause:'+rowCause); |
| | | // String ownerCause = 'Owner'; |
| | | // //Apex共有の理由名OCSM_Owner_c_User |
| | | // for(Inquiry_form__c nObj : newList) { |
| | | // Inquiry_form__c oObj = null; |
| | | // System.debug('战略科室担当:'+nObj.Depart_Owner__c); |
| | | // if (oldMap != null && oldMap.containsKey(nObj.Id)) { |
| | | // oObj = oldMap.get(nObj.Id); |
| | | // } |
| | | |
| | | |
| | | if ( nObj.Depart_Owner__c != null && (oObj == null || oObj.Depart_Owner__c != nObj.Depart_Owner__c)) { |
| | | Inquiry_form__Share aos = new Inquiry_form__Share( |
| | | RowCause = rowCause, |
| | | ParentId = nObj.Id, |
| | | UserOrGroupId = nObj.Depart_Owner__c, |
| | | AccessLevel = 'Edit'); |
| | | //存放要新增的共享数据 |
| | | insertList.add(aos); |
| | | System.debug('key:'+nObj.Id); |
| | | //存放(会议询问单id,共享对象); |
| | | insertMap.put(nObj.Id,aos); |
| | | //存放用户id 用作检索条件 |
| | | userIdList.add(nObj.Depart_Owner__c); |
| | | if (oObj != null && oObj.Depart_Owner__c != nObj.Depart_Owner__c) { |
| | | deleteTargetAOIdList.add(nObj.Id); |
| | | } |
| | | } |
| | | } |
| | | System.debug('insertList:'+insertList); |
| | | System.debug('insertMap1:'+insertMap); |
| | | System.debug('IDlIST:'+deleteTargetAOIdList); |
| | | // 先 Delete 后 Insert |
| | | if (deleteTargetAOIdList.size() > 0) { |
| | | List<Inquiry_form__Share> deleteList = [SELECT Id |
| | | FROM Inquiry_form__Share |
| | | WHERE RowCause = :rowCause |
| | | AND ParentId IN :deleteTargetAOIdList |
| | | ]; |
| | | delete deleteList; |
| | | } |
| | | //判断需要共享的人 是不是创建人 如果是则说明有一条这个人的owner数据 则不新增 |
| | | if (insertMap!= null) { |
| | | List<Inquiry_form__Share> ownerList = [SELECT Id,ParentId,UserOrGroupId |
| | | FROM Inquiry_form__Share |
| | | WHERE RowCause = :ownerCause |
| | | AND ParentId IN :insertMap.keySet() |
| | | AND UserOrGroupId IN :userIdList |
| | | ]; |
| | | System.debug('ownerList:'+ownerList); |
| | | if(ownerList.size() > 0){ |
| | | for( Inquiry_form__Share inq:ownerList){ |
| | | String id = String.valueOf(inq.ParentId); |
| | | System.debug('id:'+id); |
| | | if(insertMap.containsKey(id)){ |
| | | insertMap.remove(inq.ParentId); |
| | | } |
| | | } |
| | | } |
| | | // if ( nObj.Depart_Owner__c != null && (oObj == null || oObj.Depart_Owner__c != nObj.Depart_Owner__c)) { |
| | | // Inquiry_form__Share aos = new Inquiry_form__Share( |
| | | // RowCause = rowCause, |
| | | // ParentId = nObj.Id, |
| | | // UserOrGroupId = nObj.Depart_Owner__c, |
| | | // AccessLevel = 'Edit'); |
| | | // //存放要新增的共享数据 |
| | | // insertList.add(aos); |
| | | // System.debug('key:'+nObj.Id); |
| | | // //存放(会议询问单id,共享对象); |
| | | // insertMap.put(nObj.Id,aos); |
| | | // //存放用户id 用作检索条件 |
| | | // userIdList.add(nObj.Depart_Owner__c); |
| | | // if (oObj != null && oObj.Depart_Owner__c != nObj.Depart_Owner__c) { |
| | | // deleteTargetAOIdList.add(nObj.Id); |
| | | // } |
| | | // } |
| | | // } |
| | | // System.debug('insertList:'+insertList); |
| | | // System.debug('insertMap1:'+insertMap); |
| | | // System.debug('IDlIST:'+deleteTargetAOIdList); |
| | | // // 先 Delete 后 Insert |
| | | // if (deleteTargetAOIdList.size() > 0) { |
| | | // List<Inquiry_form__Share> deleteList = [SELECT Id |
| | | // FROM Inquiry_form__Share |
| | | // WHERE RowCause = :rowCause |
| | | // AND ParentId IN :deleteTargetAOIdList |
| | | // ]; |
| | | // delete deleteList; |
| | | // } |
| | | // //判断需要共享的人 是不是创建人 如果是则说明有一条这个人的owner数据 则不新增 |
| | | // if (insertMap!= null) { |
| | | // List<Inquiry_form__Share> ownerList = [SELECT Id,ParentId,UserOrGroupId |
| | | // FROM Inquiry_form__Share |
| | | // WHERE RowCause = :ownerCause |
| | | // AND ParentId IN :insertMap.keySet() |
| | | // AND UserOrGroupId IN :userIdList |
| | | // ]; |
| | | // System.debug('ownerList:'+ownerList); |
| | | // if(ownerList.size() > 0){ |
| | | // for( Inquiry_form__Share inq:ownerList){ |
| | | // String id = String.valueOf(inq.ParentId); |
| | | // System.debug('id:'+id); |
| | | // if(insertMap.containsKey(id)){ |
| | | // insertMap.remove(inq.ParentId); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | System.debug('insertMap2:'+insertMap); |
| | | // } |
| | | // System.debug('insertMap2:'+insertMap); |
| | | |
| | | if(insertMap != null){ |
| | | for(Inquiry_form__Share inquiry : insertMap.values()){ |
| | | lastInsertList.add(inquiry); |
| | | } |
| | | } |
| | | // if(insertMap != null){ |
| | | // for(Inquiry_form__Share inquiry : insertMap.values()){ |
| | | // lastInsertList.add(inquiry); |
| | | // } |
| | | // } |
| | | |
| | | |
| | | System.debug('共享内容:' +lastInsertList); |
| | | if(lastInsertList.size() > 0){ |
| | | insert lastInsertList; |
| | | } |
| | | // System.debug('共享内容:' +lastInsertList); |
| | | // if(lastInsertList.size() > 0){ |
| | | // insert lastInsertList; |
| | | // } |
| | | |
| | | } |
| | | // } |
| | | } |
| | |
| | | @isTest |
| | | private class InquiryFormHandlerTest { |
| | | |
| | | static testMethod void testBeforeInsert() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | if (rectHp.size() == 0) { |
| | | return; |
| | | } |
| | | //科室 |
| | | List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | if (rectDpt.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | |
| | | |
| | | |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | insert hp; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt.Name = '*'; |
| | | dpt.Department_Name__c = 'TestDepart'; |
| | | dpt.ParentId = dc.Id; |
| | | dpt.Department_Class__c = dc.Id; |
| | | dpt.Hospital__c = hp.Id; |
| | | insert dpt; |
| | | |
| | | Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt1.Name = '*'; |
| | | dpt1.Department_Name__c = 'TestDepart1'; |
| | | dpt1.ParentId = dc.Id; |
| | | dpt1.Department_Class__c = dc.Id; |
| | | dpt1.Hospital__c = hp.Id; |
| | | insert dpt1; |
| | | |
| | | Contact contact2 = new Contact(); |
| | | contact2.AccountId = dpt1.Id; |
| | | contact2.FirstName = '責任者'; |
| | | contact2.LastName = 'test1经销商'; |
| | | insert contact2; |
| | | @isTest static void test_method_one() { |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | inquiryform.Hospital_Name__c = dpt1.Id; |
| | | List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | inquiryform.Status__c ='未跟进'; |
| | | inquiryform.Company__c ='北京某某某测试公司'; |
| | | inquiryform.Family_Name__c ='靳'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.Contact_Name__c = contact2.Id; |
| | | inquiryform.Reasons_options__c ='客户不存在'; |
| | | inquiryform.Phone__c = '13844756322'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Name = '2019102101'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | Test.startTest(); |
| | | inquiryform.Product1__c = '超声'; |
| | | insert inquiryform; |
| | | |
| | | |
| | | Test.stopTest(); |
| | | |
| | | |
| | | } |
| | | static testMethod void testBeforeUpdate() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | // @isTest static void test_method_two() { |
| | | // //医院 |
| | | // List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | // if (rectHp.size() == 0) { |
| | | // return; |
| | | // } |
| | | // //科室 |
| | | // List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | // if (rectDpt.size() == 0) { |
| | | // return; |
| | | // } |
| | | |
| | | |
| | | // Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | // User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | // insert hpOwner; |
| | | // User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | // insert hpOwner2; |
| | | |
| | | |
| | | |
| | | // Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | // hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | // hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | // insert hp; |
| | | |
| | | // //战略科室 |
| | | // Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | // Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | // dpt.Name = '*'; |
| | | // dpt.Department_Name__c = 'TestDepart'; |
| | | // dpt.ParentId = dc.Id; |
| | | // dpt.Department_Class__c = dc.Id; |
| | | // dpt.Hospital__c = hp.Id; |
| | | // insert dpt; |
| | | |
| | | // Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | // dpt1.Name = '*'; |
| | | // dpt1.Department_Name__c = 'TestDepart1'; |
| | | // dpt1.ParentId = dc.Id; |
| | | // dpt1.Department_Class__c = dc.Id; |
| | | // dpt1.Hospital__c = hp.Id; |
| | | // insert dpt1; |
| | | |
| | | // Contact contact2 = new Contact(); |
| | | // contact2.AccountId = dpt1.Id; |
| | | // contact2.FirstName = '責任者'; |
| | | // contact2.LastName = 'test1经销商'; |
| | | // insert contact2; |
| | | |
| | | // Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | // inquiryform.Hospital_Name__c = dpt1.Id; |
| | | // inquiryform.Status__c ='01.未跟进'; |
| | | // inquiryform.Family_Name__c ='靳'; |
| | | // inquiryform.Opportunity_Division__c = '询价'; |
| | | // inquiryform.Contact_Name__c = contact2.Id; |
| | | // inquiryform.Reasons_options__c ='客户无意向'; |
| | | // inquiryform.Phone__c = '13844756322'; |
| | | // inquiryform.Product1__c = '超声'; |
| | | // inquiryform.Request1__c = '需要报价'; |
| | | |
| | | // insert inquiryform; |
| | | |
| | | // List<Inquiry_form__c> info= [select id,Hospital_Name__c,Contact_Name__c,Department_Class__c,Hospital__c,Hospital__r.Name,OwnerId from Inquiry_form__c where id =: inquiryform.Id]; |
| | | // System.assertEquals(hp.Id, info[0].Hospital_Name__c); |
| | | // System.assertEquals('hp-超声', info[0].Name); |
| | | // } |
| | | @isTest static void test_method_three() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | if (rectHp.size() == 0) { |
| | | return; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | |
| | | |
| | | |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | insert hp; |
| | |
| | | insert contact2; |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | inquiryform.Name = '2019102101'; |
| | | inquiryform.Hospital_Name__c = dpt1.Id; |
| | | List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | inquiryform.Status__c ='未跟进'; |
| | | inquiryform.Company__c ='北京某某某测试公司'; |
| | | inquiryform.Status__c ='01.未跟进'; |
| | | inquiryform.Family_Name__c ='靳'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.Contact_Name__c = contact2.Id; |
| | | inquiryform.Reasons_options__c ='客户不存在'; |
| | | //inquiryform.Contact_Name__c = contact2.Id; |
| | | inquiryform.Reasons_options__c ='客户无意向'; |
| | | inquiryform.Phone__c = '13844756322'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | Test.startTest(); |
| | | insert inquiryform; |
| | | ////.客户人员名前を変更する |
| | | inquiryform.Phone__c = '16444756322'; |
| | | try { |
| | | update inquiryform; |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | Inquiry_form__c inquiryform0 = new Inquiry_form__c(Id = inquiryform.id); |
| | | inquiryform0.Hospital_Name__c = null; |
| | | //System.runAs (inquiryform){ |
| | | update inquiryform0; |
| | | //} |
| | | |
| | | } |
| | | // static testMethod void testBeforeUpdate() { |
| | | // //医院 |
| | | // List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | // if (rectHp.size() == 0) { |
| | | // return; |
| | | // } |
| | | // //科室 |
| | | // List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | // if (rectDpt.size() == 0) { |
| | | // return; |
| | | // } |
| | | |
| | | |
| | | Test.stopTest(); |
| | | } |
| | | // Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | // User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | // insert hpOwner; |
| | | // User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | // insert hpOwner2; |
| | | |
| | | |
| | | |
| | | // Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | // hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | // hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | // insert hp; |
| | | |
| | | // //战略科室 |
| | | // Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | // Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | // dpt.Name = '*'; |
| | | // dpt.Department_Name__c = 'TestDepart'; |
| | | // dpt.ParentId = dc.Id; |
| | | // dpt.Department_Class__c = dc.Id; |
| | | // dpt.Hospital__c = hp.Id; |
| | | // insert dpt; |
| | | |
| | | // Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | // dpt1.Name = '*'; |
| | | // dpt1.Department_Name__c = 'TestDepart1'; |
| | | // dpt1.ParentId = dc.Id; |
| | | // dpt1.Department_Class__c = dc.Id; |
| | | // dpt1.Hospital__c = hp.Id; |
| | | // insert dpt1; |
| | | |
| | | // Contact contact2 = new Contact(); |
| | | // contact2.AccountId = dpt1.Id; |
| | | // contact2.FirstName = '責任者'; |
| | | // contact2.LastName = 'test1经销商'; |
| | | // insert contact2; |
| | | |
| | | // Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // // inquiryform.Name = '2019102101'; |
| | | // inquiryform.Hospital_Name__c = dpt1.Id; |
| | | // List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | // inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | // inquiryform.Status__c ='01.未跟进'; |
| | | // inquiryform.Company__c ='北京某某某测试公司'; |
| | | // inquiryform.Family_Name__c ='靳'; |
| | | // inquiryform.Opportunity_Division__c = '询价'; |
| | | // inquiryform.Contact_Name__c = contact2.Id; |
| | | // inquiryform.Reasons_options__c ='客户无意向'; |
| | | // inquiryform.Phone__c = '13844756322'; |
| | | // inquiryform.Product1__c = '超声'; |
| | | // inquiryform.Request1__c = '需要报价'; |
| | | // Test.startTest(); |
| | | // insert inquiryform; |
| | | // ////.客户人员名前を変更する |
| | | // inquiryform.Phone__c = '16444756322'; |
| | | // try { |
| | | // update inquiryform; |
| | | // } catch (Exception e) { |
| | | |
| | | // } |
| | | |
| | | // Test.stopTest(); |
| | | // } |
| | | // static testMethod void TestshareToOSCM(){ |
| | | // List<Inquiry_form__c> tList = [SELECT Name, Id |
| | | // FROM Inquiry_form__c ORDER BY Id LIMIT 1]; |
New file |
| | |
| | | public with sharing class StatusPageController { |
| | | public StatusPageController() { |
| | | Inquiryform = new Inquiry_form__c(); |
| | | } |
| | | public Inquiry_form__c Inquiryform{get; set;} |
| | | |
| | | public void init(){ |
| | | String infId = ApexPages.currentPage().getParameters().get('id'); |
| | | List<Inquiry_form__c> infList = [SELECT id,Reasons_options__c,Opp_Name_Search__c,Follow_Content__c,Follow_Content_Other__c,Status__c FROM Inquiry_form__c WHERE id = :infId]; |
| | | if (infList.size() == 0) { |
| | | |
| | | }else{ |
| | | Inquiryform = infList[0]; |
| | | } |
| | | } |
| | | public void save(){ |
| | | try{ |
| | | if (String.isBlank(Inquiryform.Reasons_options__c)) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '不需要理由不能为空')); |
| | | return; |
| | | } |
| | | if (Inquiryform.Reasons_options__c == '已经有询价' && String.isBlank(Inquiryform.Opp_Name_Search__c)) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '已有询价名称不能为空')); |
| | | return; |
| | | } |
| | | Inquiryform.Status__c = '02.不需要'; |
| | | update Inquiryform; |
| | | }catch (Exception ex){ |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage())); |
| | | } |
| | | } |
| | | public void savefo(){ |
| | | try { |
| | | if (String.isBlank(Inquiryform.Follow_Content__c) && String.isBlank(Inquiryform.Follow_Content_Other__c)) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '跟进内容不能为空')); |
| | | } |
| | | if (String.isBlank(Inquiryform.Follow_Content__c)) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '跟进内容不能为空')); |
| | | } |
| | | if ('其他'.equals(Inquiryform.Follow_Content__c) && String.isBlank(Inquiryform.Follow_Content_Other__c)) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '跟进内容(其他)不能为空')); |
| | | } |
| | | // Date nowDT = Date.now(); |
| | | Inquiryform.Follow_Date__c = Date.toDay(); |
| | | Inquiryform.Status__c = '03.已跟进'; |
| | | update Inquiryform; |
| | | } |
| | | catch (Exception ex) { |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage())); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>41.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
New file |
| | |
| | | @isTest |
| | | private class StatusPageControllerTest { |
| | | |
| | | static testMethod void testMethod1() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | if (rectHp.size() == 0) { |
| | | return; |
| | | } |
| | | //科室 |
| | | List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | if (rectDpt.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | |
| | | |
| | | |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | insert hp; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt.Name = '*'; |
| | | dpt.Department_Name__c = 'TestDepart'; |
| | | dpt.ParentId = dc.Id; |
| | | dpt.Department_Class__c = dc.Id; |
| | | dpt.Hospital__c = hp.Id; |
| | | insert dpt; |
| | | |
| | | Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt1.Name = '*'; |
| | | dpt1.Department_Name__c = 'TestDepart1'; |
| | | dpt1.ParentId = dc.Id; |
| | | dpt1.Department_Class__c = dc.Id; |
| | | dpt1.Hospital__c = hp.Id; |
| | | insert dpt1; |
| | | |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | inquiryform.Hospital_Name__c = dpt1.Id; |
| | | List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | inquiryform.Status__c ='未跟进'; |
| | | inquiryform.Company__c ='北京某某某测试公司'; |
| | | inquiryform.Family_Name__c ='靳'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.Phone__c = '13844756322'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | inquiryform.Reasons_options__c = '已经有询价'; |
| | | Test.startTest(); |
| | | insert inquiryform; |
| | | PageReference page = new PageReference('/apex/StatusPage?id='+inquiryform.Id); |
| | | System.Test.setCurrentPage(page); |
| | | StatusPageController controller = new StatusPageController(); |
| | | controller.init(); |
| | | controller.save(); |
| | | controller.savefo(); |
| | | } |
| | | static testMethod void testMethod2() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | if (rectHp.size() == 0) { |
| | | return; |
| | | } |
| | | //科室 |
| | | List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | if (rectDpt.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | |
| | | |
| | | |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | insert hp; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt.Name = '*'; |
| | | dpt.Department_Name__c = 'TestDepart'; |
| | | dpt.ParentId = dc.Id; |
| | | dpt.Department_Class__c = dc.Id; |
| | | dpt.Hospital__c = hp.Id; |
| | | insert dpt; |
| | | |
| | | Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt1.Name = '*'; |
| | | dpt1.Department_Name__c = 'TestDepart1'; |
| | | dpt1.ParentId = dc.Id; |
| | | dpt1.Department_Class__c = dc.Id; |
| | | dpt1.Hospital__c = hp.Id; |
| | | insert dpt1; |
| | | |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | inquiryform.Hospital_Name__c = dpt1.Id; |
| | | List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | inquiryform.Status__c ='未跟进'; |
| | | inquiryform.Company__c ='北京某某某测试公司'; |
| | | inquiryform.Family_Name__c ='靳'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.Phone__c = '13844756322'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | inquiryform.Reasons_options__c = '客户无意向'; |
| | | inquiryform.Follow_Content__c = ''; |
| | | Test.startTest(); |
| | | insert inquiryform; |
| | | PageReference page = new PageReference('/apex/StatusPage?id='+inquiryform.Id); |
| | | System.Test.setCurrentPage(page); |
| | | StatusPageController controller = new StatusPageController(); |
| | | controller.init(); |
| | | controller.save(); |
| | | controller.savefo(); |
| | | } |
| | | static testMethod void testMethod2_1() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | if (rectHp.size() == 0) { |
| | | return; |
| | | } |
| | | //科室 |
| | | List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | if (rectDpt.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | |
| | | |
| | | |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | insert hp; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt.Name = '*'; |
| | | dpt.Department_Name__c = 'TestDepart'; |
| | | dpt.ParentId = dc.Id; |
| | | dpt.Department_Class__c = dc.Id; |
| | | dpt.Hospital__c = hp.Id; |
| | | insert dpt; |
| | | |
| | | Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt1.Name = '*'; |
| | | dpt1.Department_Name__c = 'TestDepart1'; |
| | | dpt1.ParentId = dc.Id; |
| | | dpt1.Department_Class__c = dc.Id; |
| | | dpt1.Hospital__c = hp.Id; |
| | | insert dpt1; |
| | | |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | inquiryform.Hospital_Name__c = dpt1.Id; |
| | | List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | inquiryform.Status__c ='未跟进'; |
| | | inquiryform.Company__c ='北京某某某测试公司'; |
| | | inquiryform.Family_Name__c ='靳'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.Phone__c = '13844756322'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | inquiryform.Reasons_options__c = ''; |
| | | inquiryform.Follow_Content__c = ''; |
| | | Test.startTest(); |
| | | insert inquiryform; |
| | | PageReference page = new PageReference('/apex/StatusPage?id='+inquiryform.Id); |
| | | System.Test.setCurrentPage(page); |
| | | StatusPageController controller = new StatusPageController(); |
| | | controller.init(); |
| | | controller.save(); |
| | | } |
| | | static testMethod void testMethod3() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | if (rectHp.size() == 0) { |
| | | return; |
| | | } |
| | | //科室 |
| | | List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | if (rectDpt.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | |
| | | |
| | | |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | insert hp; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt.Name = '*'; |
| | | dpt.Department_Name__c = 'TestDepart'; |
| | | dpt.ParentId = dc.Id; |
| | | dpt.Department_Class__c = dc.Id; |
| | | dpt.Hospital__c = hp.Id; |
| | | insert dpt; |
| | | |
| | | Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt1.Name = '*'; |
| | | dpt1.Department_Name__c = 'TestDepart1'; |
| | | dpt1.ParentId = dc.Id; |
| | | dpt1.Department_Class__c = dc.Id; |
| | | dpt1.Hospital__c = hp.Id; |
| | | insert dpt1; |
| | | |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | inquiryform.Hospital_Name__c = dpt1.Id; |
| | | List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | inquiryform.Status__c ='未跟进'; |
| | | inquiryform.Company__c ='北京某某某测试公司'; |
| | | inquiryform.Family_Name__c ='靳'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.Phone__c = '13844756322'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | inquiryform.Reasons_options__c = '客户无意向'; |
| | | inquiryform.Follow_Content_Other__c = ''; |
| | | inquiryform.Follow_Content__c = ''; |
| | | Test.startTest(); |
| | | insert inquiryform; |
| | | PageReference page = new PageReference('/apex/FollowPage?id='+inquiryform.Id); |
| | | System.Test.setCurrentPage(page); |
| | | StatusPageController controller = new StatusPageController(); |
| | | controller.init(); |
| | | controller.savefo(); |
| | | } |
| | | static testMethod void testMethod4() { |
| | | //医院 |
| | | List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; |
| | | if (rectHp.size() == 0) { |
| | | return; |
| | | } |
| | | //科室 |
| | | List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI']; |
| | | if (rectDpt.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin]; |
| | | |
| | | User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner; |
| | | User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id); |
| | | insert hpOwner2; |
| | | |
| | | |
| | | |
| | | Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id); |
| | | hp.FSE_GI_Main_Leader__c = hpOwner.Id; |
| | | hp.FSE_SP_Main_Leader__c = hpOwner2.Id; |
| | | insert hp; |
| | | |
| | | //战略科室 |
| | | Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI']; |
| | | |
| | | Account dpt = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt.Name = '*'; |
| | | dpt.Department_Name__c = 'TestDepart'; |
| | | dpt.ParentId = dc.Id; |
| | | dpt.Department_Class__c = dc.Id; |
| | | dpt.Hospital__c = hp.Id; |
| | | insert dpt; |
| | | |
| | | Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id); |
| | | dpt1.Name = '*'; |
| | | dpt1.Department_Name__c = 'TestDepart1'; |
| | | dpt1.ParentId = dc.Id; |
| | | dpt1.Department_Class__c = dc.Id; |
| | | dpt1.Hospital__c = hp.Id; |
| | | insert dpt1; |
| | | |
| | | |
| | | Inquiry_form__c inquiryform = new Inquiry_form__c(); |
| | | // inquiryform.Name = '2019102101'; |
| | | inquiryform.Hospital_Name__c = dpt1.Id; |
| | | List<Account> dpecList = [select Id,Department_Class__c from Account where Id =: dpt1.Id]; |
| | | inquiryform.Department_Class__c = dpecList[0].Department_Class__c; |
| | | inquiryform.Status__c ='未跟进'; |
| | | inquiryform.Company__c ='北京某某某测试公司'; |
| | | inquiryform.Family_Name__c ='靳'; |
| | | inquiryform.Opportunity_Division__c = '询价'; |
| | | inquiryform.Phone__c = '13844756322'; |
| | | inquiryform.Product1__c = '超声'; |
| | | inquiryform.Request1__c = '需要报价'; |
| | | inquiryform.Reasons_options__c = '客户无意向'; |
| | | inquiryform.Follow_Content_Other__c = ''; |
| | | inquiryform.Follow_Content__c = '其他'; |
| | | Test.startTest(); |
| | | insert inquiryform; |
| | | PageReference page = new PageReference('/apex/FollowPage?id='+inquiryform.Id); |
| | | System.Test.setCurrentPage(page); |
| | | StatusPageController controller = new StatusPageController(); |
| | | controller.init(); |
| | | controller.savefo(); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>41.0</apiVersion> |
| | | <status>Active</status> |
| | | </ApexClass> |
New file |
| | |
| | | <apex:page controller="StatusPageController" showHeader="false" id="allPage" sidebar="false" action="{!init}" docType="html-5.0"> |
| | | <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> |
| | | <apex:includeScript value="/soap/ajax/29.0/connection.js"/> |
| | | <apex:includeScript value="/soap/ajax/29.0/apex.js"/> |
| | | <head> |
| | | <title>不需要的理由</title> |
| | | </head> |
| | | <script type="text/javascript"> |
| | | function save(){ |
| | | var chance = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:chance')).value(); |
| | | var name1 = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:name1')).value(); |
| | | if (((chance.trim() == '' || chance.trim() == null) && (name1.trim() == null || name1.trim() == '')) || chance == null) { |
| | | alert('不需要理由不能为空'); |
| | | return; |
| | | } |
| | | if (chance.trim() == '' || chance.trim() == null) { |
| | | alert('不需要理由不能为空'); |
| | | return; |
| | | } |
| | | if ((chance == '已经有询价') && (name1.trim() == null || name1.trim() == "")) { |
| | | alert('已有询价名称不能为空'); |
| | | return; |
| | | }else{ |
| | | blockme(); |
| | | allSave(); |
| | | } |
| | | } |
| | | function check(){ |
| | | window.opener.location.href = "/{!Inquiryform.id}"; |
| | | window.close(); |
| | | } |
| | | </script> |
| | | <apex:form id="allForm"> |
| | | <apex:outputPanel id="message"> |
| | | <apex:pageMessages /> |
| | | </apex:outputPanel> |
| | | <apex:actionfunction action="{!save}" name="allSave" onComplete="check();unblockUI();"></apex:actionfunction> |
| | | <apex:pageBlock id="pageBlock"> |
| | | <apex:pageBlockSection id="pageBlockSection" > |
| | | <apex:inputField id="chance" value="{!Inquiryform.Reasons_options__c}" style="width: 155px"/> |
| | | <br /> |
| | | <apex:inputField id="name1" value="{!Inquiryform.Opp_Name_Search__c}" style="width: 150px"/> |
| | | </apex:pageBlockSection> |
| | | <apex:pageblockbuttons location="bottom"> |
| | | <apex:commandbutton onclick="save();return false;" value="保存"></apex:commandbutton> |
| | | </apex:pageblockbuttons> |
| | | </apex:pageBlock> |
| | | </apex:form> |
| | | </apex:page> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <ApexPage xmlns="http://soap.sforce.com/2006/04/metadata"> |
| | | <apiVersion>41.0</apiVersion> |
| | | <availableInTouch>false</availableInTouch> |
| | | <confirmationTokenRequired>false</confirmationTokenRequired> |
| | | <label>StatusPage</label> |
| | | </ApexPage> |