From 9b197b7fac92278fb591ea8f4942c7d5687cb5ce Mon Sep 17 00:00:00 2001
From: 李金换 <lijinhuan@prec-tech.com>
Date: 星期一, 28 三月 2022 18:01:22 +0800
Subject: [PATCH] LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备0328
---
force-app/main/default/classes/StraightBackAddressController.cls | 93 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 83 insertions(+), 10 deletions(-)
diff --git a/force-app/main/default/classes/StraightBackAddressController.cls b/force-app/main/default/classes/StraightBackAddressController.cls
index 452d4a3..f4e8e7b 100644
--- a/force-app/main/default/classes/StraightBackAddressController.cls
+++ b/force-app/main/default/classes/StraightBackAddressController.cls
@@ -9,9 +9,14 @@
/***************琛ㄦ牸鏁版嵁*********************/
public List<AddressData> tableData { get; set; }
+ public String tableDataStr{ get; set; }
+ public String staticResource {get; set;}
+ public String staticResourceContact {get; set;}
+ public Contact newCon{get; set;}
/***************搴曢儴 缂栬緫鍜屾柊澧炵殑 瀵硅薄*******************/
public Address__c insUpdData{get;set;}
+ public String insUpdDataStr{get;set;}
/***************琚紪杈戞暟鎹殑id********************/
public String UpdId{get;set;}
@@ -55,6 +60,20 @@
/***************鏄惁鍙戠敓鏁版嵁鎺ュ彛鐨勫簭鍙�*************/
public Integer AddressTypeIndex{get;set;}
+ public String contactId{set;get;}//For Lookup field
+
+ // Add by Li Jun for PIPL 20220308 Start
+ public String contactNameValue{set;get;}
+ public String contactIdValue{set;get;}
+ 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');
@@ -77,15 +96,23 @@
addContact = new Contact();
//鏌ヨ鍒版墍鏈夌殑绉戝绫诲埆
hospitalTypp = '瑷虹檪绉� 銇濄伄浠�,瑷虹檪绉� 鍛煎惛绉�,瑷虹檪绉� 濠︿汉绉�,瑷虹檪绉� 鏅绉�,瑷虹檪绉� 娉屽翱绉�,瑷虹檪绉� 娑堝寲绉�,瑷虹檪绉� 鑰抽蓟鍠夌,瑷虹檪绉戯紙鍏遍�氾級';
+
+
+ staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Address__c'));
+ staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
}
/**
* 寮�濮嬫柟娉�
*/
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);
+ system.debug('pc = ' + pc);
//缁欎竴涓叏灞�鍙橀噺璧嬪�煎尰闄d
if(!String.isBlank(pc.HP_ID__c)){
hospitalId = pc.HP_ID__c;
@@ -126,9 +153,22 @@
ApexPages.addMessages(e);
}
insUpdData = new Address__c();
+ 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)){
@@ -141,6 +181,7 @@
insUpdData = tableData[i].address;
}
}
+ insUpdDataStr = JSON.serialize(insUpdData);
}
}
return null;
@@ -163,6 +204,7 @@
}
}
}
+ insUpdDataStr = JSON.serialize(insUpdData);
}
}
return null;
@@ -196,8 +238,12 @@
}
//鑱旂郴浜�
String contactsName = '';
+ String contactsNameEncrypt ='';
+ String contactawsDataId = '';
if(!String.isBlank(tableData[i].address.Contacts__c)){
contactsName = tableData[i].address.Contacts__r.Name;
+ contactsNameEncrypt = tableData[i].address.Contacts__r.LastName_Encrypted__c;
+ contactawsDataId = tableData[i].address.Contacts__r.AWS_Data_Id__c;
}
//瀹㈡埛
String ContactPerson = '';
@@ -207,11 +253,19 @@
try{
//淇濆瓨鏁版嵁鍒颁慨鐞嗚〃涓�
Repair__c rc = new Repair__c();
- rc.id=RepairId;
- rc.address_Contacts__c=contactsName;
+ 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;
+ rc.Address_Contacts_Encrypt__c = contactsNameEncrypt;
rc.address_ZipCode__c = tableData[i].address.ZipCode__c;
+ rc.Address_ZipCode_Encrypt__c = tableData[i].address.ZipCode_Encrypted__c;
rc.address_City__c = cityName;
rc.address_Contacts_Name__c = ContactPerson;
+ rc.Detailed_Address__c = tableData[i].address.Detailed_Address__c;
+ rc.Detailed_Address_Encrypt__c = tableData[i].address.Detailed_Address_Encrypted__c;
+ rc.address_Telephone__c = tableData[i].address.Telephone__c;
+ rc.Address_Telephone_Encrypt__c = tableData[i].address.Telephone_Encrypted__c;
//isUpload锛氭槸鍚︿笂浼燬AP FSEApplyForRepairTime锛歋AP淇悊鐢宠鏃堕棿
if(isUpload && (FSEApplyForRepairTime != null)){
rc.Address_type__c = 'X';
@@ -317,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'){
@@ -343,6 +399,8 @@
}
}
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '鍏辨湁 '+indexCou+' 鏉℃暟鎹�'));
+ tableDataStr = JSON.serialize(tableData);
+ system.debug('tableDataStr = ' + tableDataStr);
}catch(Exception e){
//澶辫触鎻愮ず
ApexPages.addMessages(e);
@@ -354,6 +412,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;
+ }
+ system.debug('Address value:'+JSON.serialize(insUpdData));
savepoint sp = Database.setsavepoint();
if(insUpdData != null){
boolean flag = true;
@@ -429,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)){
@@ -451,7 +514,13 @@
monicker = surname.substring(1,surname.length());
surname = surname.substring(0,1);
}
- addContact = new Contact(LastName=surname,FirstName=monicker,AccountId=insUpdData.Customer__c,RecordTypeId=typeL);
+ 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;
@@ -515,8 +584,8 @@
}
//鏌ヨ鍦板潃琛ㄦ暟鎹�
private String makeTextAddressSql(String typeSearchId) {
- String AddressSql = 'SELECT ID,Address_Classification__c,Customer__c,Customer__r.Name,Contacts__c,Contacts__r.Name,Telephone__c'
- +',Province__c,Province__r.Name,City__c,City__r.name,Detailed_Address__c,Create_Contacts__c,ZipCode__c,CreatedByid '
+ 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';
//绫诲瀷绛涢��
if(!String.isBlank(typeText)){
@@ -542,8 +611,11 @@
AddressSql += ' and Customer__r.Name LIKE \'%' + txtName.trim() + '%\'' ;
}
//璇︾粏鍦板潃绛涢��
- if(!String.isBlank(txtAddress)){
- AddressSql += ' and Detailed_Address__c LIKE \'%' + txtAddress.trim() + '%\'' ;
+ // if(!String.isBlank(txtAddress)){
+ // AddressSql += ' and Detailed_Address__c LIKE \'%' + txtAddress.trim() + '%\'' ;
+ // }
+ if(!String.isBlank(addressDataIds)){
+ AddressSql += ' and AWS_Data_Id__c in('+addressDataIds.trim()+')';
}
//鎺掑簭锛屾牴鎹笂娆′慨鏀规椂闂村拰閲囩敤鏃堕棿杩涜闄嶅簭鎺掑簭,鍊间负绌烘斁鍒板悗闈�
AddressSql += ' order by LastModifiedDate desc,Using_Datetime__c desc NULLS LAST';
@@ -551,6 +623,7 @@
if(String.isBlank(typeSearchId)){
AddressSql += ' limit 1000 ';
}
+ System.debug('AddressSql = '+AddressSql);
return AddressSql;
}
//鏌ヨ鍖婚櫌瀹㈡埛浜哄憳淇℃伅
--
Gitblit v1.9.1