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 | 298 +++++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 219 insertions(+), 79 deletions(-)
diff --git a/force-app/main/default/classes/StraightBackAddressController.cls b/force-app/main/default/classes/StraightBackAddressController.cls
index c2a0a89..c71f1ab 100644
--- a/force-app/main/default/classes/StraightBackAddressController.cls
+++ b/force-app/main/default/classes/StraightBackAddressController.cls
@@ -1,4 +1,4 @@
-public without sharing class StraightBackAddressController {
+global without sharing class StraightBackAddressController {
/**
* 椤甸潰椤堕儴妫�绱㈡暟鎹�
*/
@@ -12,6 +12,7 @@
public String tableDataStr{ get; set; }
public String staticResource {get; set;}
public String staticResourceContact {get; set;}
+ public String staticResourceRepair {get; set;}
public Contact newCon{get; set;}
/***************搴曢儴 缂栬緫鍜屾柊澧炵殑 瀵硅薄*******************/
@@ -66,7 +67,14 @@
public String contactNameValue{set;get;}
public String contactIdValue{set;get;}
public String addressDataIds{set;get;}
+ public String sfRecordId{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鏁版嵁
@@ -94,15 +102,21 @@
staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Address__c'));
staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
+ staticResourceRepair = JSON.serialize(PIHelper.getPIIntegrationInfo('Repair__c'));
}
/**
* 寮�濮嬫柟娉�
*/
public PageReference init(){
- System.debug('RepairId-----'+RepairId);
+ Schema.RecordTypeInfo recordTypeValue = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Office');
+ if(recordTypeValue == null){
+ recordTypeValue = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('office');
+ }
+ accOfficeTypeId = recordTypeValue.getRecordTypeId();
+ accAgencyTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
+ accAgencyContactTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('AgencyContact').getRecordTypeId();
String RepairSql = makeTextRepairSql(RepairId);
- System.debug('RepairSql-----'+RepairSql);
try{
pc = Database.query(RepairSql);
system.debug('pc = ' + pc);
@@ -131,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)){
@@ -144,14 +164,25 @@
}catch(exception e){
//澶辫触鎻愮ず
ApexPages.addMessages(e);
- System.debug(e.getMessage());
- System.debug(e.getlineNumber());
}
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)){
@@ -192,6 +223,7 @@
}
return null;
}
+ /*
//閲囩敤鎸夐挳
public PageReference adoptSave(){
//adoptId 瑕侀噰鐢ㄧ殑鍦板潃鏁版嵁id
@@ -256,7 +288,9 @@
}
rc.address_Telephone__c=tableData[i].address.Telephone__c;
rc.Detailed_Address__c=address;
- update rc;
+ if(!Test.isRunningTest()){
+ update rc;
+ }
//淇濆瓨鏁版嵁鍒颁繚鏈夎澶囪〃涓�
Asset ast = new Asset(
@@ -285,13 +319,14 @@
}
return null;
}
-
+*/
//閲嶅畾鍚戝埌 淇悊椤甸潰
public PageReference redirectPag(){
PageReference ref = new Pagereference('/' + RepairId);
ref.setRedirect(true);
return ref;
}
+
/**
* 妫�绱㈡暟鎹煡璇�
@@ -320,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箞绗竴琛屽氨鏄缁忛攢鍟嗘暟鎹紝浠庣浜岃寮�濮嬩负鍦板潃鏁版嵁
@@ -362,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'));
@@ -396,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){
@@ -430,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('璇︾粏鍦板潃涓嶈兘涓虹┖锛�');
@@ -475,63 +516,75 @@
}
}
}
- //鍒ゆ柇鑱旂郴浜烘槸鍚﹂兘涓虹┖
- 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;
- 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{
//鏂板鎴栦慨鏀规暟鎹�
upsert insUpdData;
+
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '淇濆瓨鎴愬姛锛�'));
isSearchBtn = true;
//淇濆瓨鎴愬姛锛岄渶瑕佸垵濮嬪寲涓�涓嬫瀵硅薄锛岄槻姝㈠啀娆$偣鍑绘鎸夐挳淇濆瓨涓�涓潯鍚屾牱鐨勬暟鎹�
@@ -557,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 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,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)){
@@ -577,6 +658,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)){
@@ -646,6 +733,51 @@
+ ' RecordType.name,Parent.Parent.Id FROM Account WHERE ID = \'' + accId + '\'';
return AccountSql;
}
+
+ @RemoteAction
+ global static string SaveEx(string repaire_json,string asset_json, string address_id){
+ return SaveExCore(repaire_json,asset_json,address_id);
+ }
+
+ public static string SaveExCore(string repaire_json,string asset_json, string address_id){
+ string message = null;
+ string savemessage = null;
+ savepoint sp = Database.setsavepoint();
+ try {
+ Repair__c r = (Repair__c)JSON.deserialize(repaire_json,Repair__c.class);
+ Asset ast = (Asset)JSON.deserialize(asset_json,Asset.class);
+ Address__c add = new Address__c(Id=address_id,Using_Datetime__c = Datetime.now());
+ update r;
+ update ast;
+ update add;
+ }catch(DmlException e) {
+ Integer index = 0;
+ System.debug(e.getNumDml());
+ System.debug(e.getDmlFields(index));
+ System.debug(e.getDmlId(index));
+ System.debug(e.getDmlIndex(index));
+ System.debug(e.getDmlMessage(index));
+ System.debug(e.getDmlStatusCode(index));
+ System.debug(e.getDmlType(index));
+ system.debug(e.getMessage());
+ system.debug(e.getStackTraceString());
+
+ System.debug('into catch'+e.getMessage());
+ Database.rollback(sp);
+
+ message ='淇濆瓨澶辫触锛屽師鍥�:'+ e.getDmlMessage(index);
+ savemessage = e.getMessage()+e.getStackTraceString();
+ } catch (Exception e) {
+ System.debug('into catch'+e.getMessage());
+ Database.rollback(sp);
+
+ savemessage = e.getMessage()+e.getStackTraceString();
+ message = '淇濆瓨澶辫触';
+ } finally {
+ PIHelper.saveTransLog('StraightBackAddressController',address_id,address_id,address_id, repaire_json ,'success',message);
+ }
+ return message;
+ }
/**
* 涓轰簡鏂逛究鍓嶆table鑾峰彇鍊�
@@ -653,6 +785,14 @@
class AddressData {
//鏁版嵁
public Address__c address { get; set; }
+
+ public string addressJson { get{
+ if (address == null) {
+ return null;
+ }
+ return JSON.serialize(address);
+ } }
+
//缂栬緫鎸夐挳鏄惁灞曠ず
public String canEdit { get; private set; }
//缂栬緫鎸夐挳鏄惁灞曠ず
--
Gitblit v1.9.1