From db4e75dabb6c61be6c3a09e9f11707f6018c2ef2 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期日, 20 三月 2022 15:21:18 +0800
Subject: [PATCH] PIPLDeploy0320

---
 force-app/main/default/classes/StraightBackAddressController.cls |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/force-app/main/default/classes/StraightBackAddressController.cls b/force-app/main/default/classes/StraightBackAddressController.cls
index e63368a..f4e8e7b 100644
--- a/force-app/main/default/classes/StraightBackAddressController.cls
+++ b/force-app/main/default/classes/StraightBackAddressController.cls
@@ -68,6 +68,12 @@
     public String addressDataIds{set;get;} 
     // Add by Li Jun for PIPL 20220308 End
 
+    public String accRecordTypeId {set;get;}//褰撳墠 璁板綍绫诲瀷id 
+
+    public String accOfficeTypeId {set;get;}//璁板綍绫诲瀷id  鍔炰簨澶�
+    public String accAgencyTypeId {set;get;}//璁板綍绫诲瀷id  璨╁2搴�
+    public String accAgencyContactTypeId {set;get;}//璁板綍绫诲瀷id  缁忛攢鍟嗚仈绯讳汉
+
     public StraightBackAddressController() {
         //鑾峰彇url鏁版嵁
         RepairId = System.currentPageReference().getParameters().get('id');
@@ -100,6 +106,9 @@
      * 寮�濮嬫柟娉�
      */
     public PageReference init(){
+        accOfficeTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Office').getRecordTypeId();
+        accAgencyTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
+        accAgencyContactTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('AgencyContact').getRecordTypeId();
         String RepairSql = makeTextRepairSql(RepairId);
         try{
             pc = Database.query(RepairSql);
@@ -147,7 +156,19 @@
         newCon = new Contact();
         return null;
     }
-
+    //鏌ヨ瀹㈡埛璁板綍绫诲瀷
+    public PageReference queryRecordType(){
+        if(insUpdData.Customer__c!=null){
+            String accid = insUpdData.Customer__c;
+            Account acc = [SELECT id,name,RecordTypeId FROM Account WHERE id =: accid];
+            System.debug('acc---'+acc);
+            System.debug('insUpdData---'+insUpdData);
+            if(acc!=null&&acc.RecordTypeId!=null&&insUpdData.Customer__c!=null){
+                accRecordTypeId = acc.RecordTypeId;
+            }
+        }
+        return null;
+    }
     //缂栬緫鑾峰彇鏁版嵁
     public PageReference onEditor(){
         if(!String.isBlank(UpdId)){
@@ -232,7 +253,7 @@
                         try{
                             //淇濆瓨鏁版嵁鍒颁慨鐞嗚〃涓�
                             Repair__c rc = new Repair__c();
-                            rc.id=RepairId;
+                            rc.id = RepairId;
                             rc.Address_AWS_Data_Id__c = tableData[i].address.AWS_Data_Id__c;
                             rc.Contact_AWS_Data_Id__c = contactawsDataId;
                             rc.address_Contacts__c = contactsName;
@@ -350,12 +371,14 @@
             List<Address__c> dataList = Database.query(AddressSql);
             if(dataList != null && dataList.size()> 0){
                 indexCou += dataList.size();
+                System.debug('dataList-----'+dataList);
                 for(Integer i = 0;i<dataList.size();i++){
                     String createID = dataList[i].CreatedByid;
                     createId = createId.substring(0,15);
                     //鍔炰簨澶勭殑鍦板潃涓嶅彲淇敼
+                    
                     if(dataList[i].Address_Classification__c == '鍔炰簨澶�'){
-                            tableData.add(new AddressData(dataList[i],'none','none','inline'));
+                        tableData.add(new AddressData(dataList[i],'none','none','inline'));
                     }else{
                         //鍙兘鏀硅嚜宸卞垱寤虹殑鍦板潃鏁版嵁锛岀郴缁熺鐞嗗憳銆丟PI_绯荤粺绠$悊鍛楴ew 娌¢檺鍒�
                         if(loginPerson == createId ||loginPerson == '00e10000000dzzG' ||loginPerson == '00e10000000Y3o5'){
@@ -470,7 +493,6 @@
                 }
             }
             //鍒ゆ柇鑱旂郴浜烘槸鍚﹂兘涓虹┖
-            
             if(insUpdData.Contacts__c == null || String.isBlank(insUpdData.Contacts__c)){
                 //鍒ゆ柇鏂板缓鑱旂郴浜烘槸鍚︿负绌�
                 if(insUpdData.Create_Contacts__c == null || String.isBlank(insUpdData.Create_Contacts__c)){
@@ -493,7 +515,12 @@
                             surname = surname.substring(0,1);
                         }
                         System.debug('newCon = '+newCon);
-                        addContact = new Contact(LastName=surname,FirstName=monicker,AccountId=insUpdData.Customer__c,RecordTypeId=typeL,AWS_Data_Id__c = newCon.AWS_Data_Id__c,LastName_Encrypted__c=newCon.LastName_Encrypted__c);
+                        addContact = new Contact(LastName = surname,
+                                                FirstName = monicker,
+                                                AccountId = insUpdData.Customer__c,
+                                                RecordTypeId = typeL,
+                                                AWS_Data_Id__c = newCon.AWS_Data_Id__c,
+                                                LastName_Encrypted__c = newCon.LastName_Encrypted__c);
                         try{
                             //鏂板涓�鏉¤仈绯讳汉鏁版嵁
                             insert addContact;
@@ -557,7 +584,7 @@
     }
     //鏌ヨ鍦板潃琛ㄦ暟鎹�
     private String makeTextAddressSql(String typeSearchId) {
-        String AddressSql = 'SELECT AWS_Data_Id__c,ID,Address_Classification__c,Customer__c,Customer__r.Name,Contacts__c,Contacts__r.Name,Contacts__r.AWS_Data_Id__c,Telephone__c'
+        String AddressSql = 'SELECT AWS_Data_Id__c,ID,Address_Classification__c,Customer__c,Customer__r.Name,Customer__r.Type,Customer__r.RecordTypeId,Contacts__c,Contacts__r.Name,Contacts__r.AWS_Data_Id__c,Telephone__c'
                         +',Province__c,Province__r.Name,City__c,City__r.name,Detailed_Address__c,Create_Contacts__c,ZipCode__c,CreatedByid,Detailed_Address_Encrypted__c,Telephone_Encrypted__c,ZipCode_Encrypted__c,Contacts__r.LastName_Encrypted__c'
                         + ' FROM Address__c where id != null';
         //绫诲瀷绛涢��

--
Gitblit v1.9.1