gzw
2022-02-15 168114b11da83c5005cd608c1b23a66311717a0f
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
public without sharing class ConsumptionListController {
    /*****************検索用******************/
    //public Consumable_order__c coc { get; set; }
    /*****************画面初始化用********************************/
    /******20160313_add**************/
    //public String IdCheck{get;set;}
    //暂用20160323
    /*****************画面表示Bean******************/
    /*public List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
    public String baseUrl {get;private set;}
    public String sortKey { get; set; }
    public String preSortKey { get; private set; }
    public Boolean sortOrderAsc { get; private set; }
    public String[] sortOrder { get; private set; }
 
    private String[] columus = new String[]{ 'Name'};
 
    // 已选择备品set明细
    private List<Consumable_order_details__c> consumableorderdetailsSelected = new List<Consumable_order_details__c>();
    private List<Product2__c> product2Selected = new List<Product2__c>();
 
    // 产品 ID
    private String ESetId = '';*/
 
    public ConsumptionListController() {
        //Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
        //baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        //ESetId = ApexPages.currentPage().getParameters().get('esetId');
        //consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
    }
    // 画面初始化
    /*public void init() {
        IdCheck = EsetId;
        consumableorderdetailsRecords = new List<ConsumableorderdetailsInfo>();
        if(ESetId== NULL || ESetId==''){
 
        }else{
            List<Consumable_order__c> qs = New List<Consumable_order__c>();
            qs = [select Id,ShipmentAccount__c,Order_Indication__c, Name,Consumable_pdf_insert_day__c,Inventory_date__c,Consume_date__c,Order_ForDealerText__c,Arrive_Order__c  From Consumable_order__c Where Id =:ESetId];
         if (qs.size()>0){
                coc = qs[0];
            }
            // 選択済みの明细を取得
            consumableorderdetailsSelected = [select Id,
                                                    Name,
                                                    Consumable_order__c,
                                                    Consumable_Product__c,
                                                    Consumable_Product__r.Name,
                                                    Consumable_Product__r.Name__c,
                                                    Sterilization_limit__c,
                                                    Consumable_Count__c,
                                                    Deliver_date__c,Intra_Trade_List_RMB__c,
                                                    Asset_Model_No__c,
                                                    Sum_of_money__c,
                                                    ProductPacking_list_manual__c,
                                                    Box_Piece__c,
                                                    Guarantee_period_for_products__c,
                                                    Order_details_Piece__c
                                                from Consumable_order_details__c
                                                where  Consumable_Sale_order__c = :ESetId
                                                order by Name ];
            //输出
            for (Integer i = 0; i < consumableorderdetailsSelected.size(); i++) {
                consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(consumableorderdetailsSelected[i]));
            }
        }
        // 排序
        this.sortKey = '1';
        this.preSortKey = '1';
        this.sortOrderAsc = false;
        this.sortOrder = new String[1];
        this.sortOrder = new String[]{'', '↓'};
    }
 
    //上传纳品书
    public PageReference FilesUpload(){
        PageReference ref = new Pagereference('/p/attach/NoteAttach?pid='+ESetid+'&retURL=%2F' + '/ConsumptionList?ESetid=' +ESetid);
        ref.setRedirect(true);
        return ref;
     }
    //限制性排序
/*    public void SortLimited(){ 
    List<ConsumableorderdetailsInfo> reSet = new List<ConsumableorderdetailsInfo>();
        if (this.sortKey == this.preSortKey) {
            // 方向が変わるのみ
            this.sortOrderAsc = !this.sortOrderAsc;
            this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '↑' : '↓');
        } else {
            this.sortOrderAsc = true;
            this.sortOrder[Integer.valueOf(this.preSortKey)] = ' ';
            this.sortOrder[Integer.valueOf(this.sortKey)] = (this.sortOrderAsc == true ? '↑' : '↓');
        }
        this.preSortKey = this.sortKey;
        if(EsetId==null||ESetId==''){
        }else{
        // 所有产品取得
        String soql = 'select Id,  Name, Consumable_order__c, Consumable_Product__c,Consumable_Product__r.Name, Sterilization_limit__c,Consumable_Count__c,Deliver_date__c,Intra_Trade_List_RMB__c,Asset_Model_No__c,Sum_of_money__c from Consumable_order_details__c where   Consumable_Sale_order__c = \''+ESetId+'\'';
        soql += ' order by ' + this.columus[Integer.valueOf(this.sortKey)] + ' ' + (this.sortOrderAsc == true ? 'asc nulls first' : 'desc nulls last');
        List<Consumable_order_details__c> queryList = Database.query(soql);
        // 選択済みの明细を取得
        Map<String, String> selectedIdMap = new Map<String, String>();
        for (Integer i = 0; i < queryList.size(); i++) {
                // 未选择的消耗品明细
                reSet.add(new ConsumableorderdetailsInfo(queryList[i]));
            }
            consumableorderdetailsRecords = reSet;
            // 显示数据条数信息
            }
    } */
 
    // 撤销错误数据
    /*public PageReference ConsumableorderDel() {
        if(coc.Consume_date__c <> date.today()){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '只允许撤销当天的销售记录'));
            return null;
        }
        List<Consumable_order__c> qs = New List<Consumable_order__c>();
        List<Consumable_order_details__c> Dqs= New List<Consumable_order_details__c>();
        Consumable_order__c Consumable_order= New Consumable_order__c();
        List<Consumable_order_details__c> orderDetails= New List<Consumable_order_details__c>();
        qs  = [select Id From Consumable_order__c Where Id =:ESetId];
        System.debug('+++++Order_Indication__c' + coc.Order_Indication__c);
        List<ConsumableorderdetailsInfo> ConsumableorderdetailsRecordsdummy = new List<ConsumableorderdetailsInfo>();
        if (qs.size()>0){
            try {
                if(coc.Order_Indication__c ==null || coc.Order_Indication__c  ==''){
                    orderDetails = [select Id,  Name, Consumable_order__c,
                                            Consumable_Product__c,Consumable_Product__r.Name,
                                            Consumable_Product__r.Name__c, Sterilization_limit__c,
                                            Consumable_Count__c,Deliver_date__c,
                                            Intra_Trade_List_RMB__c,Asset_Model_No__c,Sum_of_money__c
                                    from Consumable_order_details__c
                                    where  Consumable_principal__c =:coc.Arrive_Order__c];
                    for (Integer i = 0; i < consumableorderdetailsSelected.size(); i++) {
                        ConsumableorderdetailsRecordsdummy.add(new ConsumableorderdetailsInfo(orderDetails[i]));
                    }
                    for (ConsumableorderdetailsInfo ass : ConsumableorderdetailsRecordsdummy)  {
                        Consumable_order_details__c Updet = new Consumable_order_details__c();
                        Updet.Id = ass.esd.Id;
                        Updet.Consumable_Sale_order__c = null;
                        Dqs.add(Updet);
                    }
                    delete qs;
                    update Dqs;
                }else{
                    Consumable_order.Id = coc.Order_Indication__c;
                    Consumable_order.SummonsStatus_c__c = '出库单已打印';
                    update Consumable_order;
                    delete qs;
                }
            }
            catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
        }
        if(coc.Order_Indication__c  =='' || coc.Order_Indication__c == null){
            PageReference ref = new Pagereference('/SaleAndDelivery');
            ref.setRedirect(true);
            return ref;
        }else{
            PageReference ref = new Pagereference('/summonsCreat?ESetid=' + coc.Order_Indication__c);
            ref.setRedirect(true);
            return ref;
        }
     }
    // Data Bean
    class ConsumableorderdetailsInfo implements Comparable {
        public Boolean check { get; set; }
        public Boolean oldCheck { get; set; }
        public Consumable_order_details__c esd { get; set; }
        public Product2__c Prod { get; set; }
        public Boolean canSelect { get; set; }
        // 已存在备品set明细用
        public ConsumableorderdetailsInfo(Consumable_order_details__c e) {
            check = true;
            oldCheck = true;
            esd = e;
            //Prod = e.Consumable_Product__r;
            //oldConsumableCount = e.Consumable_Count__c;
            canSelect = true;
        }
        // 排序
        public Integer compareTo(Object compareTo) {
            return null;
        }
    }*/
}