From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/StraightBackAddressController.cls |  205 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 128 insertions(+), 77 deletions(-)

diff --git a/force-app/main/default/classes/StraightBackAddressController.cls b/force-app/main/default/classes/StraightBackAddressController.cls
index 2564baa..c71f1ab 100644
--- a/force-app/main/default/classes/StraightBackAddressController.cls
+++ b/force-app/main/default/classes/StraightBackAddressController.cls
@@ -145,6 +145,12 @@
                     }
                 }else if('杩旈�佸姙浜嬪'.equals(pc.Returns_Product_way__c)){
                     optionAddressClassification.Address_Classification__c = '鍔炰簨澶�';
+                // 
+                }else if ('澶囧搧涓績'.equals(pc.Returns_Product_way__c)) {
+                    optionAddressClassification.Address_Classification__c = '澶囧搧';
+                // 
+
+
                 }else{
                     //鑾峰彇褰撳墠淇悊鐨勮繑閫佺粡閿�鍟�
                     if(!String.isBlank(pc.Dealer__c) && '杩旈�佺粡閿�鍟�'.equals(pc.Returns_Product_way__c)){
@@ -349,18 +355,19 @@
                     tableData.add(new AddressData(accoutList[0],'none','inline','none','鍖婚櫌'));
                 }
             }
-            //鍔炰簨澶�
-            /*if('鍔炰簨澶�'.equals(typeText)){
-                String AccountOfficeSql = makeTextAccOfficeSql();
-                //鑾峰彇鍦板潃淇℃伅
-                List<Account> accDataList = Database.query(AccountOfficeSql);
-                if(accDataList != null && accDataList.size() > 0){
-                    for(Integer i = 0;i<accDataList.size();i++){
-                        indexCou++;
-                        tableData.add(new AddressData(accDataList[i],'none','鍔炰簨澶�'));
-                    }
-                }
-            }*/
+            // //澶囧搧锛�
+            // if(('澶囧搧'.equals(typeText))){
+            //     //HP_ID__c  鍖婚櫌id
+                
+            //     typeSearchId = pc.HP_ID__c;
+            //     String AccountSql = makeTextAccountSql(pc.HP_ID__c);
+            //     //鑾峰彇鍦板潃淇℃伅
+            //     List<Account> accoutList = Database.query(AccountSql);
+            //     if(accoutList != null && accoutList.size() > 0){
+            //         indexCou++;
+            //         tableData.add(new AddressData(accoutList[0],'none','inline','none','澶囧搧'));
+            //     }
+            // }
             //缁忛攢鍟嗭細
             //1锛氬鏋滄煡鍒板鏉$粡閿�鍟嗭紝骞朵笖鍦ㄥ湴鍧�涓煡鍒版湁鏁版嵁锛屽彧鏄剧ず鍦板潃鏁版嵁锛屽鏋滃湴鍧�鏁版嵁娌℃煡涓嶅埌锛屽氨涓嶆樉绀猴紝
             //2锛氬鏋滄煡鍒版湁涓�鏉$粡閿�鍟嗭紝閭d箞绗竴琛屽氨鏄缁忛攢鍟嗘暟鎹紝浠庣浜岃寮�濮嬩负鍦板潃鏁版嵁
@@ -391,7 +398,9 @@
                     
                     if(dataList[i].Address_Classification__c == '鍔炰簨澶�'){
                         tableData.add(new AddressData(dataList[i],'none','none','inline'));
-                    }else{
+                    }else if (dataList[i].Address_Classification__c == '澶囧搧'){
+                        tableData.add(new AddressData(dataList[i],'none','none','inline'));
+                    } else{
                         //鍙兘鏀硅嚜宸卞垱寤虹殑鍦板潃鏁版嵁锛岀郴缁熺鐞嗗憳銆丟PI_绯荤粺绠$悊鍛楴ew 娌¢檺鍒�
                         if(loginPerson == createId ||loginPerson == '00e10000000dzzG' ||loginPerson == '00e10000000Y3o5'){
                             tableData.add(new AddressData(dataList[i],'inline','inline','inline'));
@@ -425,10 +434,12 @@
      */
     public PageReference save(){
         system.debug('Address value:'+JSON.serialize(insUpdData));       
-        if(String.isNotBlank(contactIdValue)&&String.isNotEmpty(contactIdValue)){
-            system.debug('Contact Value:'+contactIdValue);
-            insUpdData.Contacts__c = contactIdValue;
-        }
+        // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start
+        // if(String.isNotBlank(contactIdValue)&&String.isNotEmpty(contactIdValue)){
+        //     system.debug('Contact Value:'+contactIdValue);
+        //     insUpdData.Contacts__c = contactIdValue;
+        // }
+        // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end
         system.debug('Address value:'+JSON.serialize(insUpdData));
         savepoint sp = Database.setsavepoint();
         if(insUpdData != null){
@@ -459,6 +470,7 @@
                 this.insUpdData.Telephone__c.addError('涓嶈兘涓虹┖锛�');
             }
             //璇︾粏鍦板潃涓嶈兘涓虹┖
+            System.debug('insUpdData.Detailed_Address__c1:' + insUpdData.Detailed_Address__c);
             if(String.isBlank(insUpdData.Detailed_Address__c)){
                 flag = false;
                 this.insUpdData.Detailed_Address__c.addError('璇︾粏鍦板潃涓嶈兘涓虹┖锛�');
@@ -504,65 +516,70 @@
                     }
                 }
             }
-            //鍒ゆ柇鑱旂郴浜烘槸鍚﹂兘涓虹┖
-            if(insUpdData.Contacts__c == null || String.isBlank(insUpdData.Contacts__c)){
+            //WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start 
+            //鍒ゆ柇鑱旂郴浜烘槸鍚︿负绌�
+            System.debug('insUpdData.ContactName__c1:' + insUpdData.ContactName__c);
+            if(String.isBlank(insUpdData.ContactName__c)){
+                this.insUpdData.ContactName__c.addError('銆愯仈绯讳汉銆戜笉鑳戒负绌猴紒');
                 //鍒ゆ柇鏂板缓鑱旂郴浜烘槸鍚︿负绌�
-                if(insUpdData.Create_Contacts__c == null || String.isBlank(insUpdData.Create_Contacts__c)){
-                    flag = false;
-                    this.insUpdData.Create_Contacts__c.addError('銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃朵负绌猴紒');
-                }else{//濡傛灉鑱旂郴浜轰负绌猴紝浣嗘槸鏂板缓鑱旂郴浜轰笉涓虹┖锛岄偅涔堟柊澧炰竴鏉¤仈绯讳汉鏁版嵁
-                    if(flag){
-                        String typeL = '';//绫诲瀷
-                        if(insUpdData.Address_Classification__c == '鍖婚櫌'){
-                            typeL = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId();//鍖诲斧
-                        }else if(insUpdData.Address_Classification__c == '缁忛攢鍟�'){
-                            typeL = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();//璨╁2搴�
-                        }else if(insUpdData.Address_Classification__c == '鍔炰簨澶�'){
-                            typeL = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Internal_staff').getRecordTypeId();//绀惧唴鍛樺伐
-                        }
-                        String surname = String.valueOf(insUpdData.Create_Contacts__c);//濮�
-                        String monicker = '';//鍚�
-                        if(surname.length() >= 2){
-                            monicker = surname.substring(1,surname.length());
-                            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);
-                        try{
-                            //鏂板涓�鏉¤仈绯讳汉鏁版嵁
-                            insert addContact;
-                            sfRecordId = addContact.id;
-                            insUpdData.Create_Contacts__c = '';
-                        }catch(Exception e){
-                            //ApexPages.addMessages(e);
-                            Database.rollback(sp);
-                            //澶辫触鎻愮ず
-                            System.debug('myException caught when save or submit: ' + e.getMessage() + e.getStackTraceString());
-                            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
-                            isSearchBtn = false;
-                            return null;
-                        }
-                        insUpdData.Contacts__c = addContact.id;
-                        //name璧嬪��
-                        /*if(insUpdData.Contacts__c == null){
-                            insUpdData.name =  insUpdData.Customer__r.Name+'_'+insUpdData.Contacts__r.Name;
-                        }else{
-                            insUpdData.name =  insUpdData.Customer__r.Name+'_'+insUpdData.Create_Contacts__c;
-                        }*/
-                    }
-                }
-            }else{//鑱旂郴浜哄拰鏂板缓鑱旂郴浜轰笉鑳介兘鏈夊��
-                //鍒ゆ柇鏂板缓鑱旂郴浜烘槸鍚︿负绌�
-                if(!String.isBlank(insUpdData.Create_Contacts__c)){
-                    flag = false;
-                    this.insUpdData.Create_Contacts__c.addError('銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃堕兘鏈夊�硷紒');
-                }
+                // if(insUpdData.Create_Contacts__c == null || String.isBlank(insUpdData.Create_Contacts__c)){
+                //     flag = false;
+                //     this.insUpdData.Create_Contacts__c.addError('銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃朵负绌猴紒');
+                // }else{//濡傛灉鑱旂郴浜轰负绌猴紝浣嗘槸鏂板缓鑱旂郴浜轰笉涓虹┖锛岄偅涔堟柊澧炰竴鏉¤仈绯讳汉鏁版嵁
+                //     if(flag){
+                //         String typeL = '';//绫诲瀷
+                //         if(insUpdData.Address_Classification__c == '鍖婚櫌'){
+                //             typeL = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Doctor').getRecordTypeId();//鍖诲斧
+                //         }else if(insUpdData.Address_Classification__c == '缁忛攢鍟�'){
+                //             typeL = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();//璨╁2搴�
+                //         }else if(insUpdData.Address_Classification__c == '鍔炰簨澶�'){
+                //             typeL = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Internal_staff').getRecordTypeId();//绀惧唴鍛樺伐
+                //         }
+                //         String surname = String.valueOf(insUpdData.Create_Contacts__c);//濮�
+                //         String monicker = '';//鍚�
+                //         if(surname.length() >= 2){
+                //             monicker = surname.substring(1,surname.length());
+                //             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);
+                //         try{
+                //             //鏂板涓�鏉¤仈绯讳汉鏁版嵁
+                //             insert addContact;
+                //             sfRecordId = addContact.id;
+                //             insUpdData.Create_Contacts__c = '';
+                //         }catch(Exception e){
+                //             //ApexPages.addMessages(e);
+                //             Database.rollback(sp);
+                //             //澶辫触鎻愮ず
+                //             System.debug('myException caught when save or submit: ' + e.getMessage() + e.getStackTraceString());
+                //             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
+                //             isSearchBtn = false;
+                //             return null;
+                //         }
+                //         insUpdData.Contacts__c = addContact.id;
+                //         //name璧嬪��
+                //         /*if(insUpdData.Contacts__c == null){
+                //             insUpdData.name =  insUpdData.Customer__r.Name+'_'+insUpdData.Contacts__r.Name;
+                //         }else{
+                //             insUpdData.name =  insUpdData.Customer__r.Name+'_'+insUpdData.Create_Contacts__c;
+                //         }*/
+                //     }
+                // }
             }
+            // else{//鑱旂郴浜哄拰鏂板缓鑱旂郴浜轰笉鑳介兘鏈夊��
+            //     //鍒ゆ柇鏂板缓鑱旂郴浜烘槸鍚︿负绌�
+            //     if(!String.isBlank(insUpdData.Create_Contacts__c)){
+            //         flag = false;
+            //         this.insUpdData.Create_Contacts__c.addError('銆愯仈绯讳汉銆戝拰銆愯仈绯讳汉锛堟柊寤猴級銆戜笉鑳藉悓鏃堕兘鏈夊�硷紒');
+            //     }
+            // }
+            //WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end
             if(flag){
                 try{
                     //鏂板鎴栦慨鏀规暟鎹�
@@ -593,14 +610,42 @@
 
     //鏌ヨ淇悊琛ㄦ暟鎹�
     private String makeTextRepairSql(String uuid){
-        String RepairSql = 'SELECT ID,NAME,HP_ID__c,HP_Name__c,Delivered_Product__c,FSE_ApplyForRepair_time__c,SAP_Transfer_time__c,Dealer__c,Dealer__r.Name,Returns_Product_way__c,Address_Type_Index__c,AWS_Data_Id__c FROM Repair__c where id = \''+RepairId+'\'';
+        String RepairSql = 'SELECT ID,NAME,HP_ID__c,HP_Name__c,Delivered_Product__c,FSE_ApplyForRepair_time__c,SAP_Transfer_time__c,Dealer__c,Dealer__r.Name,Returns_Product_way__c,Address_Type_Index__c,AWS_Data_Id__c,Incharge_Staff__r.UserRole.name,Incharge_Staff__r.Branch__c,Incharge_Staff__r.Profile.name FROM Repair__c where id = \''+RepairId+'\'';
         return RepairSql;
     }
     //鏌ヨ鍦板潃琛ㄦ暟鎹�
     private String makeTextAddressSql(String typeSearchId) {
-        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'
+        // DB202212270703 澶囧搧淇悊鐩磋繑鍦板潃椤圭洰瀵煎叆 start
+        String beipCenter = '';
+        if (pc.Returns_Product_way__c == '澶囧搧涓績') {
+            if (pc.Incharge_Staff__r.Profile.name.startsWith('2B2')) {
+                if (pc.Incharge_Staff__r.Branch__c == '鍖椾含') {
+                    beipCenter = '鍖椾含澶囧搧涓績';
+                }else if (pc.Incharge_Staff__r.Branch__c == '涓婃捣') {
+                    beipCenter = '鍗庝笢澶囧搧涓績';
+                }else if (pc.Incharge_Staff__r.Branch__c == '骞垮窞') {
+                    beipCenter = '骞垮窞澶囧搧涓績';
+                }
+            }else if (pc.Incharge_Staff__r.UserRole.name == 'CTEC鏁欒偛鏈儴') {
+                if (pc.Incharge_Staff__r.Branch__c == '鍖椾含') {
+                    beipCenter = '鍖椾含C-TEC';
+                }else if (pc.Incharge_Staff__r.Branch__c == '涓婃捣') {
+                    beipCenter = '涓婃捣C-TEC';
+                }else if (pc.Incharge_Staff__r.Branch__c == '骞垮窞') {
+                    beipCenter = '骞垮窞C-TEC';
+                }
+                
+            }
+        }
+        // DB202212270703 澶囧搧淇悊鐩磋繑鍦板潃椤圭洰瀵煎叆 end
+        // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 start 
+        // 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,ContactName__c,Telephone__c,ContactName_Encrypted__c' //zhj 鏂版柟妗堟敼閫� 鍘婚櫎Encrypted__c 2022-12-05
+        //                 +',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';
+        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,ContactName__c,Telephone__c' //zhj 鏂版柟妗堟敼閫� 鍘婚櫎Encrypted__c 2022-12-05
+                        +',Province__c,Province__r.Name,City__c,City__r.name,Detailed_Address__c,Create_Contacts__c,ZipCode__c,CreatedByid'
                         + ' FROM Address__c where id != null';
+        // WLIG-CCX4BB 銆愬鎵樸�戜慨鐞嗙洿杩旀敹璐у湴鍧�鍔熻兘鏀归�� thh 20220513 end 
         //绫诲瀷绛涢��
         if(!String.isBlank(typeText)){
             if('鍖婚櫌'.equals(typeText)){
@@ -614,6 +659,12 @@
             if('鍔炰簨澶�'.equals(typeText)){
                 AddressSql += ' and Address_Classification__c LIKE \'%' + typeText.trim() + '%\'' ;
             }
+            if('澶囧搧'.equals(typeText)){
+                AddressSql += ' and Address_Classification__c LIKE \'%' + typeText.trim() + '%\'' ;
+                if (String.isNotBlank(beipCenter)) {
+                    AddressSql += ' and Beipin_Center__c = \'' + String.escapeSingleQuotes(beipCenter) +'\'' ;
+                }
+            }
             if('缁忛攢鍟�'.equals(typeText)){
                 if(String.isBlank(typeSearchId)){
                     AddressSql += ' and Address_Classification__c LIKE \'%' + typeText.trim() + '%\'' ;

--
Gitblit v1.9.1