FUYU
2023-12-18 b329ab986e250bb27e46ace97cf208f3b26d145a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
public with sharing class lexCopyToBaseController {
    public lexCopyToBaseController() {
        
    }
    @AuraEnabled
    public static String init(String recordId){
        String s='';
        try {
            String objectName = 'Opportunity'; // 要获取字段的对象名
            Map<String, Schema.SObjectType> globalDescribe = Schema.getGlobalDescribe();
            Schema.SObjectType objType = globalDescribe.get(objectName);
            if (objType != null) {
                Schema.DescribeSObjectResult objDescribe = objType.getDescribe();
                Map<String, Schema.SObjectField> 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<Opportunity> 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;
    }
    // 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<Integer> charArr = new List<Integer>();
        Integer change=bA-a;
        Integer st=(str.charAt(0)+change);
        charArr.add(st);
        for(Integer i=0;i<str.length()-2;i++){
            Integer c=str.charAt(i);
            Integer nextC=str.charAt(i+1);
            if(c==x&&nextC>=a&&nextC<z&&i!=str.length()-2){
                nextC+=change;
            }
            charArr.add(nextC);
        }
        res=String.fromCharArray(charArr);
        res+=str.substring(str.length()-1,str.length());
 
        return res;
    }
}