高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
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
public with sharing class RentalReportExportController {
    public List<SelectOption> objectOptions{set;get;}
    public List<SelectOption> contactOptions{set;get;}
    public List<SelectOption> filedOptions{set;get;}
    public List<SelectOption> operationSelectOptions{set;get;}
    public List<InputFilter> fieldInputList{set;get;}
    public String staticResource {get; set;}
    public String staticResourceContact {get; set;}
    public Boolean isContactAll {get; set;}
    public String selectedObject{set;get;}
    public Integer fieldSize{get; set;}
    public RentalReportExportController() {
        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('Rental_Apply__c')); 
        staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));     
        fieldInputList = new List<InputFilter>();
        InputFilter ifilter = new InputFilter();
        ifilter.fieldAPI = 'sfRecordId';
        ifilter.operation = 'in';
        ifilter.value = '';
        fieldInputList.add(ifilter);
        fieldSize = fieldInputList.size();
        System.debug('fieldSize ' + fieldSize);
        getAwsField();
        objectOptions = new List<SelectOption>();
        contactOptions = new List<SelectOption>();
        SelectOption so = new SelectOption('Rental_Apply__c','备品发货地');
        objectOptions.add(so);
        contactOptions.add(new SelectOption('Contact','客户人员'));
        operationSelectOptions = new List<SelectOption>();
        operationSelectOptions.add(new SelectOption('like','包含'));
 
        isContactAll = false;
        System.debug('isContactAll ' + isContactAll);
        User users = [select Id, Profile.UserType, Profile.UserLicense.Name from User Where Id =:UserInfo.getUserId()];
        System.debug('users: ' + users);
        Profile profiles = [select Id, UserType, UserLicense.Name, Name from Profile Where Id =:users.ProfileId];
        System.debug('profiles: ' + profiles);
        // PermissionSet permissionSet = [select Profile.Name, Id, ProfileId from PermissionSet where ProfileId =:profiles.Id];
        // System.debug('permissionSet: ' + permissionSet);
        // ObjectPermissions objectPermission = [select ParentId, PermissionsViewAllRecords, PermissionsRead from ObjectPermissions Where SObjectType = 'Contact' and ParentId =:permissionSet.Id limit 1];
        // System.debug('objectPermission: ' + objectPermission);
        if(profiles.Name == '系统管理员'){
            isContactAll = true;
        }  
        System.debug('isContactAll ' + isContactAll);
 
    }
 
    public void getAwsField(){
        // List<PI_Field_Policy_Detail__c> contactField = [select id, PI_Policy_Configuration__r.Sobject_Type__c, SF_Field_API_Name__c, SF_Field_Name__c, AWS_Field_API__c from PI_Field_Policy_Detail__c where PI_Policy_Configuration__r.Sobject_Type__c = 'Contact'];
        filedOptions = new List<SelectOption>();
        filedOptions.add(new SelectOption('sfRecordId', 'ID'));
        // for (PI_Field_Policy_Detail__c piField : contactField) {
        //     filedOptions.add(new SelectOption(piField.AWS_Field_API__c, piField.SF_Field_Name__c));
        // }
        System.debug('filedOptions ' + filedOptions);
    }
 
    public PageReference addFilter(){
        InputFilter ifilter = new InputFilter();
        ifilter.fieldAPI = 'lastName';
        ifilter.operation = 'Equals';
        ifilter.value = '';
        fieldInputList.add(ifilter);
        System.debug('fieldInputList add ' + fieldInputList);
        fieldSize = fieldInputList.size();
        System.debug('fieldSize ' + fieldSize);
        return null;
    }
 
    
    public PageReference removeFilter(){
        System.debug('fieldInputList remove ' + fieldInputList);
        fieldInputList.remove(fieldInputList.size() - 1);
        fieldSize = fieldInputList.size();
        System.debug('fieldSize ' + fieldSize);
        return null;
    }
 
    public class InputFilter{
        public String fieldAPI{set;get;}
        public String operation{set;get;}
        public String value{set;get;}
    }
}