高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
101
102
103
104
105
106
107
public with sharing class ConsumApplyEquipmentSetSRListController {
    public List<Consum_Apply_Equipment_Set__c> resList { get; set; }
    public String sr_open { get; set; }
    public String sr_apply_no { get; set; }
    public String sr_id { get; set; }
    public String sr_type { get; set; }
    public List<SelectOption> typeList {get; set;}
    public String selectedType {get; set;}
    private String Id;
    public Integer getResListSize() {
        return resList.size();
    }
    
    public ConsumApplyEquipmentSetSRListController() {
//        Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
        Id = ApexPages.currentPage().getParameters().get('id');
        sr_type = ApexPages.currentPage().getParameters().get('type');
        sr_open = ApexPages.currentPage().getParameters().get('open');
    }
 
    public void init() {
        resList = new List<Consum_Apply_Equipment_Set__c>();
        initTypeList();
 
        if (Id != null) {
            resList = [select Model_No__c
                            , Consum_Apply__r.Name
                            , Yi_Assigned_Cnt__c
                            , Yi_Shipment_request__c
                            //, Yi_Return__c
                            , RetalFSetDetail_Cnt__c
                            , First_RAESD_Model_No_F__c
                            , First_RAESD__r.SerialNumber_F__c
                            , First_RAESD__r.Fixture_QRCode_F__c
                            , RAES_Status__c
                    from Consum_Apply_Equipment_Set__c
                    where Consum_Apply__r.Name = :id and Cancel_Select__c = false order by Name
                    //AND Cancel_Select__c = false
                    ];
            if (resList.size() > 0) {
                sr_apply_no = resList[0].Consum_Apply__r.Name;
                sr_id = resList[0].Consum_Apply__r.Name;
            } else {
                List<Consum_Apply_Equipment_Set_Detail__c> raesdList = [select Id from Consum_Apply_Equipment_Set_Detail__c where Fixture_QRCode_F__c = :id
                              //and Cancel_Select__c = False
                            ];
                Set<Id> raesdSet = new Set<Id>();
                if (raesdList.size() > 0) {
                    for (Consum_Apply_Equipment_Set_Detail__c raesd : raesdList) {
                        raesdSet.add(raesd.Id);
                    }
                }
                resList = [select Id
                                , Model_No__c
                                , Consum_Apply__c
                                , Yi_Assigned_Cnt__c
                                , Yi_Shipment_request__c
                                //, Yi_Return__c
                                , RetalFSetDetail_Cnt__c
                                , Consum_Apply__r.Name
                                , First_RAESD_Model_No_F__c
                                , First_RAESD__r.SerialNumber_F__c
                                , First_RAESD__r.Fixture_QRCode_F__c
                                , RAES_Status__c
                        from Consum_Apply_Equipment_Set__c
                       where (First_RAESD__c in :raesdSet
                                or ((First_RAESD__r.Canceled__c in :raesdSet or First_RAESD__r.Canceled__r.Canceled__c in :raesdSet)
                                        and Consum_Apply__r.ShelfUp_ng_num__c <> 0
                                )
                            ) 
                         and Consum_Apply__r.RA_Status__c <> :FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Wan_Liao.ordinal())
                         and Cancel_Select__c = false
                       order by Name
                    ];
                if (resList.size() > 0) {
                    sr_apply_no = resList[0].Consum_Apply__r.Name;
                    sr_id = resList[0].Id;
                } else {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '备品不存在'));
                }
            }
 
        }
        return;
    }
    
    private void initTypeList(){
        typeList = new List<SelectOption>();
        typeList.add(new SelectOption('无','无'));
        typeList.add(new SelectOption('发货', '发货'));
        typeList.add(new SelectOption('收货', '收货'));
        System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
        selectedType = config.CAESD_Action_Type__c;
        if (String.isBlank(selectedType)){
            selectedType = '无';
        }
 
    }
    public void setType(){
        if (selectedType != '无' && selectedType != null ){
            System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId());
            config.CAESD_Action_Type__c = selectedType;
            FixtureUtil.withoutUpsertObjects(new System_UserSetting__c[]{config});
        }
 
    }
}