From 415f539d731e2514d76f010f782d57cff6242aab Mon Sep 17 00:00:00 2001 From: 张宇恒 <bxyun0@163.com> Date: 星期四, 31 三月 2022 20:25:39 +0800 Subject: [PATCH] SWAG-CBUB2W 【委托】【优先】询问单相关修改 --- force-app/main/default/classes/StatusPageController.cls-meta.xml | 5 force-app/main/default/classes/StatusPageControllerTest.cls-meta.xml | 5 force-app/main/default/pages/StatusPage.page-meta.xml | 7 force-app/main/default/classes/InquiryFormHandlerTest.cls | 263 ++++++++++----- force-app/main/default/classes/StatusPageControllerTest.cls | 352 ++++++++++++++++++++ force-app/main/default/classes/StatusPageController.cls | 53 +++ force-app/main/default/classes/InquiryFormHandler.cls | 275 ++++++++++----- force-app/main/default/pages/StatusPage.page | 51 +++ 8 files changed, 827 insertions(+), 184 deletions(-) diff --git a/force-app/main/default/classes/InquiryFormHandler.cls b/force-app/main/default/classes/InquiryFormHandler.cls index 735a187..d0507c0 100644 --- a/force-app/main/default/classes/InquiryFormHandler.cls +++ b/force-app/main/default/classes/InquiryFormHandler.cls @@ -15,118 +15,211 @@ 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 + // 鎴樼暐绉戝鐨勪富鎷呭綋 銈掑彇寰椼�両nquiry_form__Share銇ō瀹�(Read) - private void shareToOSCM() { - //瀛樻斁鐢ㄤ簬鏂板鐨勫叡浜暟鎹� - List<Inquiry_form__Share> insertList = new List<Inquiry_form__Share>(); - //瀛樻斁(浼氳璇㈤棶鍗昳d,鍏变韩瀵硅薄) - 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>(); - //瀛樻斁鐢ㄤ簬鐨刬d - 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>(); + // //瀛樻斁(浼氳璇㈤棶鍗昳d,鍏变韩瀵硅薄) + // 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>(); + // //瀛樻斁鐢ㄤ簬鐨刬d + // 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; - } - //鍒ゆ柇闇�瑕佸叡浜殑浜� 鏄笉鏄垱寤轰汉 濡傛灉鏄垯璇存槑鏈変竴鏉¤繖涓汉鐨刼wner鏁版嵁 鍒欎笉鏂板 - 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; + // } + // //鍒ゆ柇闇�瑕佸叡浜殑浜� 鏄笉鏄垱寤轰汉 濡傛灉鏄垯璇存槑鏈変竴鏉¤繖涓汉鐨刼wner鏁版嵁 鍒欎笉鏂板 + // 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; + // } - } + // } } \ No newline at end of file diff --git a/force-app/main/default/classes/InquiryFormHandlerTest.cls b/force-app/main/default/classes/InquiryFormHandlerTest.cls index 9afbbd0..2c50375 100644 --- a/force-app/main/default/classes/InquiryFormHandlerTest.cls +++ b/force-app/main/default/classes/InquiryFormHandlerTest.cls @@ -1,83 +1,88 @@ @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 = '瓒呭0'; + inquiryform.Name = '2019102101'; inquiryform.Request1__c = '闇�瑕佹姤浠�'; - Test.startTest(); + inquiryform.Product1__c = '瓒呭0'; 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 = '瓒呭0'; + // 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-瓒呭0', 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; } @@ -88,16 +93,16 @@ } - 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; @@ -128,31 +133,103 @@ 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 = '瓒呭0'; 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 = '瓒呭0'; + // 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]; diff --git a/force-app/main/default/classes/StatusPageController.cls b/force-app/main/default/classes/StatusPageController.cls new file mode 100644 index 0000000..8cf62b4 --- /dev/null +++ b/force-app/main/default/classes/StatusPageController.cls @@ -0,0 +1,53 @@ +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())); + } + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/StatusPageController.cls-meta.xml b/force-app/main/default/classes/StatusPageController.cls-meta.xml new file mode 100644 index 0000000..f3bac1f --- /dev/null +++ b/force-app/main/default/classes/StatusPageController.cls-meta.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> + <apiVersion>41.0</apiVersion> + <status>Active</status> +</ApexClass> diff --git a/force-app/main/default/classes/StatusPageControllerTest.cls b/force-app/main/default/classes/StatusPageControllerTest.cls new file mode 100644 index 0000000..dda6643 --- /dev/null +++ b/force-app/main/default/classes/StatusPageControllerTest.cls @@ -0,0 +1,352 @@ +@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 = '瓒呭0'; + 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 = '瓒呭0'; + 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 = '瓒呭0'; + 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 = '瓒呭0'; + 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 = '瓒呭0'; + 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(); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/StatusPageControllerTest.cls-meta.xml b/force-app/main/default/classes/StatusPageControllerTest.cls-meta.xml new file mode 100644 index 0000000..f3bac1f --- /dev/null +++ b/force-app/main/default/classes/StatusPageControllerTest.cls-meta.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> + <apiVersion>41.0</apiVersion> + <status>Active</status> +</ApexClass> diff --git a/force-app/main/default/pages/StatusPage.page b/force-app/main/default/pages/StatusPage.page new file mode 100644 index 0000000..220b918 --- /dev/null +++ b/force-app/main/default/pages/StatusPage.page @@ -0,0 +1,51 @@ +<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> \ No newline at end of file diff --git a/force-app/main/default/pages/StatusPage.page-meta.xml b/force-app/main/default/pages/StatusPage.page-meta.xml new file mode 100644 index 0000000..fa3d5d5 --- /dev/null +++ b/force-app/main/default/pages/StatusPage.page-meta.xml @@ -0,0 +1,7 @@ +<?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> -- Gitblit v1.9.1