| | |
| | | public String awsToken{set;get;} |
| | | public static Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe(); |
| | | public static String sobjectTypeValue = 'Consum_Apply_Equipment_Set_Detail__c'; |
| | | public Boolean isCloneMode{protected set;get;} |
| | | public Boolean isNewMode{set;get;} |
| | | public String rtTypeId {get; set;} |
| | | public String AWSDataId{set;get;} |
| | |
| | | public String sobjectPrefix{set;get;} |
| | | public NewConsumApplyEquipSetDetailController(ApexPages.StandardController controller) { |
| | | isNewMode = true; |
| | | isCloneMode = false; |
| | | Input_Required_Field_Msg = Label.Input_Required_Field_Msg; |
| | | sobjecttypeForFrontEnd = sobjectTypeValue; |
| | | //获取所有字段 |
| | | Map<string,string> mso = ApexPages.currentPage().getParameters(); |
| | | if(mso != null && mso.containsKey('newclone')){ |
| | | isCloneMode = true; |
| | | } |
| | | List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Consum_Apply_Equipment_Set_Detail__c').getDescribe().fields.getMap().keyset()); |
| | | controller.addFields(fieldList); |
| | | if (!Test.isRunningTest()) { |
| | | controller.addFields(fieldList); |
| | | } |
| | | SObject obj = controller.getRecord(); |
| | | if(obj.Id != null){ |
| | | //更新 |
| | |
| | | Response resp = new Response(); |
| | | Savepoint sp = Database.setSavepoint(); |
| | | String rid = ''; |
| | | Boolean isClone = false; |
| | | String awsDataId = ''; |
| | | try{ |
| | | System.debug('abcde'); |
| | | awsDataId = (String)consumApplyInfo.get('AWS_Data_Id__c'); |
| | | System.debug('awsDataId = ' + awsDataId); |
| | | Consum_Apply_Equipment_Set_Detail__c[] ConsumApplys = [select id from Consum_Apply_Equipment_Set_Detail__c where AWS_Data_Id__c =:awsDataId]; |
| | | |
| | | if(!isNew || isClone){ |
| | | isClone = ConsumApplys.size() == 0; |
| | | } |
| | | if(isNew){ |
| | | System.debug('consumApplyInfozhj = ' + consumApplyInfo); |
| | | insert consumApplyInfo; |
| | | System.debug('consumApplyInfo.Id' + consumApplyInfo.Id); |
| | | }else{ |
| | | System.debug('into update'); |
| | | String awsDataId = (String)consumApplyInfo.get('AWS_Data_Id__c'); |
| | | System.debug('awsDataId = ' + awsDataId); |
| | | Consum_Apply_Equipment_Set_Detail__c[] ConsumApplys = [select id from Consum_Apply_Equipment_Set_Detail__c where AWS_Data_Id__c =:awsDataId]; |
| | | // String awsDataId = (String)consumApplyInfo.get('AWS_Data_Id__c'); |
| | | // System.debug('awsDataId = ' + awsDataId); |
| | | // Consum_Apply_Equipment_Set_Detail__c[] ConsumApplys = [select id from Consum_Apply_Equipment_Set_Detail__c where AWS_Data_Id__c =:awsDataId]; |
| | | System.debug('ConsumApplys[0].id = ' + ConsumApplys[0].id); |
| | | consumApplyInfo.put('Id',ConsumApplys[0].id);//For testing; |
| | | update consumApplyInfo; |