public with sharing class lexCopyToBaseController { public lexCopyToBaseController() { } @AuraEnabled public static String init(String recordId){ String s=''; try { String objectName = 'Opportunity'; // 要获取字段的对象名 Map globalDescribe = Schema.getGlobalDescribe(); Schema.SObjectType objType = globalDescribe.get(objectName); if (objType != null) { Schema.DescribeSObjectResult objDescribe = objType.getDescribe(); Map fieldMap = objDescribe.fields.getMap(); s+='SELECT '; // 现在,fieldMap中包含了对象的所有字段信息 for (String fieldName : fieldMap.keySet()) { if(!fieldName.equals('id') &&!fieldName.equals('Id')) s+=fieldName+','; } s=s.removeEnd(','); s+=' FROM Opportunity where id=\''+recordId+'\''; system.debug('SQL:'+s); List opportunitys = Database.query(s); s=''; if(opportunitys.size()>0){ system.debug('in!'); for (String fieldName : fieldMap.keySet()) { String formaF=fieldMap.get(fieldName).getDescribe().getName(); if(opportunitys.get(0).get(fieldName)!=null&&!opportunitys.get(0).get(fieldName).equals('null')){ if(formaF.equals('Id') ||formaF.equals('OwnerId') ||formaF.equals('CreatedDate') ||formaF.equals('CreatedById') ) { continue; } Object val=opportunitys.get(0).get(fieldName); if(val instanceof Date ){ String str=String.valueOf(val); str=str.replace(' ','T'); str+='.000Z'; s+=formaF+'='+str+','; }else if (val instanceof DateTime){ String str=String.valueOf(val); str=str.replace(' ','T'); str+='.000Z'; s+=formaF+'='+str+','; }else{ s+=formaF+'='+opportunitys.get(0).get(fieldName)+','; } } } s=s.removeEnd(','); return s; } } return s; } catch (Exception e) { System.debug('lexCopyToBaseController init error:'+e.getMessage()); } return s; } //DB202311617653 【询价】内外贸转换,报价单清除,询价页面金额问题 start @AuraEnabled public static Opportunity init2(String recordId){ Opportunity s = new Opportunity(); try { List opportunitys = [select Name,AccountId,Opportunity_Category__c,SAP_Province__c,StageName,Purchase_Type__c ,ifOpenBid__c,Sales_Method__c,Trade__c,Promise_Class__c,Sales_Root__c,Close_Forecasted_Date__c ,CloseDate,Purchase_Reason__c,Fund_Basis__c,GeneralInquirySeparateBill__c,Hospital__c ,Department_Class__c,RecordTypeId from Opportunity where id =:recordId]; if(opportunitys.size()>0){ s=opportunitys[0]; return s; } return s; } catch (Exception e) { System.debug('lexCopyToBaseController init error:'+e.getMessage()); } return s; } //DB202311617653 【询价】内外贸转换,报价单清除,询价页面金额问题 end // public static getData(){ // } public static String forma(String str){ String res=''; String stra='a'; Integer a=stra.charAt(0); String strz='z'; Integer z=strz.charAt(0); String strAa='A'; Integer bA=strAa.charAt(0); String strZz='Z'; Integer bZ=strZz.charAt(0); String strx='_'; Integer x=strx.charAt(0); List charArr = new List(); Integer change=bA-a; Integer st=(str.charAt(0)+change); charArr.add(st); for(Integer i=0;i=a&&nextC