From 64b3629116e6f3f5eb3debf9b451d100f4010fa5 Mon Sep 17 00:00:00 2001 From: 游畅 <youchang@prec-tech.com> Date: 星期五, 22 四月 2022 13:50:56 +0800 Subject: [PATCH] 询问单相关修改 --- force-app/main/default/classes/InquiryFormHandlerTest.cls | 76 +++++++ force-app/main/default/classes/StatusPageControllerTest.cls | 118 ++++++----- force-app/main/default/classes/OpportunityAndContactDailyUpdateTest.cls | 90 ++++++++ force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls | 31 +++ force-app/main/default/classes/StatusPageController.cls | 34 +++ force-app/main/default/pages/ServiceFollowPage.page | 48 ++++ force-app/main/default/classes/InquiryFormHandler.cls | 164 +++++++++++++--- force-app/main/default/pages/ServiceFollowPage.page-meta.xml | 5 8 files changed, 465 insertions(+), 101 deletions(-) diff --git a/force-app/main/default/classes/InquiryFormHandler.cls b/force-app/main/default/classes/InquiryFormHandler.cls index 0d39970..0f96d2d 100644 --- a/force-app/main/default/classes/InquiryFormHandler.cls +++ b/force-app/main/default/classes/InquiryFormHandler.cls @@ -16,22 +16,23 @@ protected override void beforeInsert() { beforeExecute(); //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 start - getContactInformation(); + // getContactInformation(); //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 end } protected override void beforeUpdate() { beforeExecute(); //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 start - getContactInformation(); + // getContactInformation(); //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� thh 20220321 end } protected override void afterInsert() { - //shareToOSCM(); + //FSE涓绘媴褰撳叡浜� + shareToFSEMain(); } protected override void afterUpdate() { - //shareToOSCM(); + shareToFSEMain(); } //Before鍑︾悊 private void beforeExecute() { @@ -54,7 +55,18 @@ nnObj.HospitalName__c = null; //鍖婚櫌鍚� nnObj.Hospital__c = null; //鍖婚櫌 } + //20220419 you SWAG-CBUB2W start + //鍏紡鑰冩枃鏈� 缁橣SE鎷呭綋璧嬪�� + System.debug(nnObj.FSE_Owner_id__c+'==123=='+nnObj.FSE_Owner__c); + if(nnObj.FSE_Owner_id__c != nnObj.FSE_Owner__c){ + nnObj.FSE_Owner__c = nnObj.FSE_Owner_id__c; + } + if(Trigger.isInsert && (nnObj.Request1__c.indexOf('鏈嶅姟瀵瑰簲') !=-1 || nnObj.ServiceCorrespond__c ==true)){ + nnObj.Service_Status__c ='01.鏈窡杩�'; + } + //20220419 you SWAG-CBUB2W end } + if (depIDList.size()>0) { accList = [Select Id,OwnerId, Hospital__c,Hospital__r.Name, @@ -101,34 +113,126 @@ nObj.Product1_Manual__c = ''; } } + //20220419 you SWAG-CBUB2W start + private void shareToFSEMain() { + //瀛樻斁鐢ㄤ簬鏂板鐨勫叡浜暟鎹� + 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.FSE_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('FSE涓绘媴褰擄細'+nObj.FSE_Owner__c); + if (oldMap != null && oldMap.containsKey(nObj.Id)) { + oObj = oldMap.get(nObj.Id); + } + + + if ( nObj.FSE_Owner__c != null && (oObj == null || oObj.FSE_Owner__c != nObj.FSE_Owner__c)) { + Inquiry_form__Share aos = new Inquiry_form__Share( + RowCause = rowCause, + ParentId = nObj.Id, + UserOrGroupId = nObj.FSE_Owner__c, + AccessLevel = 'Edit'); + //瀛樻斁瑕佹柊澧炵殑鍏变韩鏁版嵁 + insertList.add(aos); + System.debug('key:'+nObj.Id); + //瀛樻斁锛堜骇鍝佸挩璇㈠崟id,鍏变韩瀵硅薄锛�; + insertMap.put(nObj.Id,aos); + //瀛樻斁鐢ㄦ埛id 鐢ㄤ綔妫�绱㈡潯浠� + userIdList.add(nObj.FSE_Owner__c); + } + if(oObj != null && oObj.FSE_Owner__c != nObj.FSE_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); + + if(insertMap != null){ + for(Inquiry_form__Share inquiry : insertMap.values()){ + lastInsertList.add(inquiry); + } + } + + + System.debug('鍏变韩鍐呭:' +lastInsertList); + if(lastInsertList.size() > 0){ + insert lastInsertList; + } + + } + //20220419 you SWAG-CBUB2W end //瀹㈡埛浜哄憳褰曞叆鍚�,銆愮數璇濄�戙�愰偖绠便�戣嚜鍔ㄥ綍鍏� 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; - } - } - } - } + // 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) diff --git a/force-app/main/default/classes/InquiryFormHandlerTest.cls b/force-app/main/default/classes/InquiryFormHandlerTest.cls index 9f50f52..7863d8d 100644 --- a/force-app/main/default/classes/InquiryFormHandlerTest.cls +++ b/force-app/main/default/classes/InquiryFormHandlerTest.cls @@ -1,12 +1,68 @@ @isTest private class InquiryFormHandlerTest { + @TestSetup + static void setup(){ + TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c'); + } + + @isTest + static void Test1(){ + Test.setMock(HttpCalloutMock.class, new HttpMock()); + + List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); + lra.add(new Agency_Contact__c( + Id = 'a2R1m0000007BPD' + )); + Test.startTest(); + //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl); + AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); + AWSServiceTool2.EncryptPushFuture(null,null); + Test.stopTest(); + } + + class HttpMock implements HttpCalloutMock{ + + public HTTPResponse respond(HTTPRequest request) { + // 鍒涘缓涓�涓亣鐨勫洖搴� + System.debug('------------------------------------------------------'); + HttpResponse response = new HttpResponse(); + string body = ''; + system.debug(request.getEndpoint()); + if(request.getEndpoint().contains('token')){ + system.debug('url=token'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else if(request.getEndpoint().contains('insert')){ + system.debug('url=Insert'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else if(request.getEndpoint().contains('update')){ + system.debug('url=update'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else{ + + } + + response.setBody(body); + response.setStatus('OK'); + response.setStatusCode(200); + return response; + // } + } + } @isTest static void test_method_one() { + 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; Inquiry_form__c inquiryform = new Inquiry_form__c(); inquiryform.Name = '2019102101'; inquiryform.Request1__c = '闇�瑕佹姤浠�'; inquiryform.Product1__c = '瓒呭0'; + inquiryform.FSE_Owner__c = hpOwner.id; insert inquiryform; } @@ -126,11 +182,11 @@ dpt1.Hospital__c = hp.Id; insert dpt1; - Contact contact2 = new Contact(); - contact2.AccountId = dpt1.Id; - contact2.FirstName = '璨换鑰�'; - contact2.LastName = 'test1缁忛攢鍟�'; - insert contact2; + //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'; @@ -143,8 +199,18 @@ inquiryform.Phone__c = '13844756322'; inquiryform.Product1__c = '瓒呭0'; inquiryform.Request1__c = '闇�瑕佹姤浠�'; + inquiryform.FSE_Owner__c = hpOwner.id; insert inquiryform; + Test.setMock(HttpCalloutMock.class, new HttpMock()); + + List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); + lra.add(new Agency_Contact__c( + Id = 'a2R1m0000007BPD', + Aws_Data_Id__c = '123456' + )); + AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); + Inquiry_form__c inquiryform0 = new Inquiry_form__c(Id = inquiryform.id); inquiryform0.Hospital_Name__c = null; //System.runAs (inquiryform){ diff --git a/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls b/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls index 9cfc17a..e5baedd 100644 --- a/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls +++ b/force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls @@ -100,7 +100,9 @@ AccountDailyUpdateBatch.updateFromHosToContact(deptUpdateList, iflog); updateFromHosToContact(deptUpdateList, iflog); - + //20220415 you SWAG-CBUB2W start + updateFromHosToInquiryForm(deptUpdateList, iflog); + //20220415 you SWAG-CBUB2W end } //鍚屾鎵�灞炵殑璇环锛堜笟鍔℃満浼氾級鐨勬墍鏈変汉 public static void updateFromHosToContact(List<Account> deptUpdateList, BatchIF_Log__c iflog) { @@ -128,6 +130,33 @@ } } + //20220415 you SWAG-CBUB2W start + //鍚屾鎵�灞炵殑浜у搧鍜ㄨ鍗曠殑鎵�鏈変汉 + public static void updateFromHosToInquiryForm(List<Account> deptUpdateList, BatchIF_Log__c iflog) { + List<Inquiry_form__c> updateInquiryFormList = + [select id, Ownerid, Hospital_Name__r.ownerId from Inquiry_form__c + where Hospital_Name__c in:deptUpdateList + and isOwnerDiffWithAccount__c = true ]; + for (Inquiry_form__c ifo : updateInquiryFormList) { + if (ifo.Ownerid != ifo.Hospital_Name__r.ownerId) { + ifo.Ownerid = ifo.Hospital_Name__r.ownerId; + } + } + Integer indexCon = 0; + Database.SaveResult[] lsrUpdateInq = Database.update(updateInquiryFormList, false); + for (Database.SaveResult lsrChild : lsrUpdateInq) { + if (!lsrChild.isSuccess()) { + iflog.Is_Error__c = 3; + Database.Error emsg = lsrChild.getErrors()[0]; + iflog.ErrorLog__c += 'ownerId: ' + updateInquiryFormList.get(indexCon).ownerId + ' \n' + + 'InquiryFormID: ' + updateInquiryFormList.get(indexCon).Id + '\n ConLog:' + emsg.getMessage() + '\n'; + + } + indexCon ++ ; + } + + } + //20220415 you SWAG-CBUB2W end global void finish(Database.BatchableContext BC) { system.debug('=====iflog:' + iflog.id); iflog.Log__c += 'OpportunityAndContactDailyUpdateBatch finish()\n'; diff --git a/force-app/main/default/classes/OpportunityAndContactDailyUpdateTest.cls b/force-app/main/default/classes/OpportunityAndContactDailyUpdateTest.cls index c7e0142..75567e8 100644 --- a/force-app/main/default/classes/OpportunityAndContactDailyUpdateTest.cls +++ b/force-app/main/default/classes/OpportunityAndContactDailyUpdateTest.cls @@ -1,8 +1,8 @@ @isTest private class OpportunityAndContactDailyUpdateTest { - @testsetup private static void setup (){ + TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c'); string profid = '00e10000000Y3o5'; string rectHpID = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId(); List<String> classDeptStr = new List<String>(); @@ -169,11 +169,11 @@ depart.Hospital__c = Hospital.Id; depart.OwnerId = UserGS.Id; insert depart; - Contact core = new Contact(email='jplumber@salesforce.com', - firstname='Joe', - lastname='Plumber', - accountid=depart.id); - insert core; + //Contact core = new Contact(email='jplumber@salesforce.com', + //firstname='Joe', + //lastname='Plumber', + //accountid=depart.id); + //insert core; Opportunity target = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today(), accountid=depart.id); target.Trade__c = '鍐呰部'; @@ -181,11 +181,87 @@ target.Wholesale_Price__c = 9000; target.Sales_Root__c = 'AAA'; insert target; - + + Inquiry_form__c inf =new Inquiry_form__c(); + inf.Hospital_Name__c = depart.id; + inf.OwnerId = UserGI.Id; + inf.Name = 'test'; + inf.Request1__c = '鏈嶅姟瀵瑰簲'; + inf.Product1__c = '瓒呭0'; + insert inf; } + @isTest + static void Test1(){ + Test.setMock(HttpCalloutMock.class, new HttpMock()); + + List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); + lra.add(new Agency_Contact__c( + Id = 'a2R1m0000007BPD' + )); + Test.startTest(); + //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl); + AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); + AWSServiceTool2.EncryptPushFuture(null,null); + Test.stopTest(); + } + + //@isTest + // static void Test2(){ + // Test.setMock(HttpCalloutMock.class, new HttpMock()); + + // List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); + // lra.add(new Agency_Contact__c( + // Id = 'a2R1m0000007BPD', + // Aws_Data_Id__c = '123456' + // )); + // Test.startTest(); + // //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl); + // AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); + // Test.stopTest(); + // } + + class HttpMock implements HttpCalloutMock{ + + public HTTPResponse respond(HTTPRequest request) { + // 鍒涘缓涓�涓亣鐨勫洖搴� + System.debug('------------------------------------------------------'); + HttpResponse response = new HttpResponse(); + string body = ''; + system.debug(request.getEndpoint()); + if(request.getEndpoint().contains('token')){ + system.debug('url=token'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else if(request.getEndpoint().contains('insert')){ + system.debug('url=Insert'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else if(request.getEndpoint().contains('update')){ + system.debug('url=update'); + response.setHeader('Content-Type', 'application/json'); + body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; + } else{ + + } + + response.setBody(body); + response.setStatus('OK'); + response.setStatusCode(200); + return response; + // } + } + } static testMethod void testMethod1() { + Test.setMock(HttpCalloutMock.class, new HttpMock()); + + List<Agency_Contact__c> lra = new List<Agency_Contact__c>(); + lra.add(new Agency_Contact__c( + Id = 'a2R1m0000007BPD', + Aws_Data_Id__c = '123456' + )); + AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); list<account> acclist = [select id from account where name ='Test Hospital']; Id execBTId = Database.executeBatch(new OpportunityAndContactDailyUpdateBatch(), 5); execBTId = Database.executeBatch(new OpportunityAndContactDailyUpdateBatch('1.鍗庡寳'), 5); diff --git a/force-app/main/default/classes/StatusPageController.cls b/force-app/main/default/classes/StatusPageController.cls index 8cf62b4..fd809ee 100644 --- a/force-app/main/default/classes/StatusPageController.cls +++ b/force-app/main/default/classes/StatusPageController.cls @@ -6,7 +6,7 @@ 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]; + List<Inquiry_form__c> infList = [SELECT id,Reasons_options__c,Opp_Name_Search__c,Follow_Content__c,Follow_Content_Other__c,Status__c,Service_Follow_Content__c,Service_Follow_Content_Other__c,Service_Status__c FROM Inquiry_form__c WHERE id = :infId]; if (infList.size() == 0) { }else{ @@ -41,6 +41,15 @@ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '璺熻繘鍐呭锛堝叾浠栵級涓嶈兘涓虹┖')); } // Date nowDT = Date.now(); + //20220418 you SWAG-CBUB2W start + if(String.isNotBlank(Inquiryform.Follow_Content__c) && Inquiryform.Follow_Content__c.indexOf('鏈嶅姟瀵瑰簲')!=-1){ + Inquiryform.ServiceCorrespond__c = true; + Inquiryform.Service_Status__c = '01.鏈窡杩�'; + }else{ + Inquiryform.ServiceCorrespond__c = false; + Inquiryform.Service_Status__c = ''; + } + //20220418 you SWAG-CBUB2W end Inquiryform.Follow_Date__c = Date.toDay(); Inquiryform.Status__c = '03.宸茶窡杩�'; update Inquiryform; @@ -50,4 +59,27 @@ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage())); } } + //20220418 you SWAG-CBUB2W start + public void servicesavefo(){ + try { + if (String.isBlank(Inquiryform.Service_Follow_Content__c) && String.isBlank(Inquiryform.Service_Follow_Content_Other__c)) { + ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏈嶅姟璺熻繘鍐呭涓嶈兘涓虹┖')); + } + if (String.isBlank(Inquiryform.Service_Follow_Content__c)) { + ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏈嶅姟璺熻繘鍐呭涓嶈兘涓虹┖')); + } + if ('鍏朵粬'.equals(Inquiryform.Service_Follow_Content__c) && String.isBlank(Inquiryform.Service_Follow_Content_Other__c)) { + ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '鏈嶅姟璺熻繘鍐呭锛堝叾浠栵級涓嶈兘涓虹┖')); + } + // Date nowDT = Date.now(); + Inquiryform.Service_Follow_Date__c = Date.toDay(); + Inquiryform.Service_Status__c = '03.宸茶窡杩�'; + update Inquiryform; + } + catch (Exception ex) { + + ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage())); + } + } + //20220418 you SWAG-CBUB2W end } \ No newline at end of file diff --git a/force-app/main/default/classes/StatusPageControllerTest.cls b/force-app/main/default/classes/StatusPageControllerTest.cls index 5c4011f..7416c85 100644 --- a/force-app/main/default/classes/StatusPageControllerTest.cls +++ b/force-app/main/default/classes/StatusPageControllerTest.cls @@ -3,7 +3,7 @@ static testMethod void testMethod1() { //鍖婚櫌 - List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; + List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } @@ -14,16 +14,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; @@ -64,15 +64,16 @@ 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(); + System.Test.setCurrentPage(page); + StatusPageController controller = new StatusPageController(); + controller.init(); + controller.save(); + controller.savefo(); + controller.servicesavefo(); } static testMethod void testMethod2() { //鍖婚櫌 - List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; + List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } @@ -83,16 +84,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; @@ -134,15 +135,16 @@ 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(); + System.Test.setCurrentPage(page); + StatusPageController controller = new StatusPageController(); + controller.init(); + controller.save(); + controller.savefo(); + controller.servicesavefo(); } static testMethod void testMethod2_1() { //鍖婚櫌 - List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; + List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } @@ -153,16 +155,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; @@ -204,14 +206,14 @@ 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(); + 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']; + List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } @@ -222,16 +224,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; @@ -274,14 +276,15 @@ 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(); + System.Test.setCurrentPage(page); + StatusPageController controller = new StatusPageController(); + controller.init(); + controller.savefo(); + controller.servicesavefo(); } static testMethod void testMethod4() { //鍖婚櫌 - List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; + List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP']; if (rectHp.size() == 0) { return; } @@ -292,16 +295,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; @@ -344,9 +347,10 @@ 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(); + System.Test.setCurrentPage(page); + StatusPageController controller = new StatusPageController(); + controller.init(); + controller.savefo(); + controller.servicesavefo(); } } \ No newline at end of file diff --git a/force-app/main/default/pages/ServiceFollowPage.page b/force-app/main/default/pages/ServiceFollowPage.page new file mode 100644 index 0000000..4364f4b --- /dev/null +++ b/force-app/main/default/pages/ServiceFollowPage.page @@ -0,0 +1,48 @@ +<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 content = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:content')).value(); + var contentOther = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:contentOther')).value(); + if ((content == '' || content == null) && (contentOther.trim() == null || contentOther.trim() == '')) { + alert('鏈嶅姟璺熻繘鍐呭涓嶈兘涓虹┖锛�'); + return; + }else if (content == '鍏朵粬' && (contentOther.trim() == '' || contentOther.trim() == null)) { + alert('鏈嶅姟璺熻繘鍐呭锛堝叾浠栵級涓嶈兘涓虹┖锛�'); + return; + }else if (content == '' || content == null) { + alert('鏈嶅姟璺熻繘鍐呭涓嶈兘涓虹┖锛�'); + return; + }else{ + blockme(); + allSave(); + } + } + function check(){ + window.opener.location.href = "/{!Inquiryform.id}"; + window.close(); + } + </script> + <apex:form id="allForm"> + <apex:actionfunction action="{!servicesavefo}" name="allSave" onComplete="check();unblockUI();"></apex:actionfunction> + <apex:pageBlock id="pageBlock"> + <apex:pageBlockSection id="pageBlockSection"> + <apex:inputField id="content" value="{!Inquiryform.Service_Follow_Content__c}" /> + <br /> + <apex:inputField id="contentOther" value="{!Inquiryform.Service_Follow_Content_Other__c}" style="width: 150px"/> + <br /> + </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/ServiceFollowPage.page-meta.xml b/force-app/main/default/pages/ServiceFollowPage.page-meta.xml new file mode 100644 index 0000000..149cb75 --- /dev/null +++ b/force-app/main/default/pages/ServiceFollowPage.page-meta.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata"> + <apiVersion>46.0</apiVersion> + <label>ServiceFollowPage</label> +</ApexPage> \ No newline at end of file -- Gitblit v1.9.1