高章伟
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
public without sharing class summonsPDFController {
     public Consumable_order__c coc { get; set; }
    private String ESetId = '';
    private Map<String,Date> productkucun = new Map<String,Date>();
    //医院经销商分离
    public List<ConsumableorderdetailsInfo> consumableorderdetailsRecords { get; set; }
    private List<Consumable_orderdetails__c> consumableorderdetailsSelected = new List<Consumable_orderdetails__c>();
    private String userId = '';
    private String accountid = '';
    private String accountName = null;
    public summonsPDFController() {
        ESetId = ApexPages.currentPage().getParameters().get('esetId');
        coc = new Consumable_order__c();
    }
    public void init() {
        userId = UserInfo.getUserId();
        List<user> Useracc = New List<user>();
        Useracc = [select accountid from user where id =:userId];
        accountid = Useracc[0].accountid;
        List<account> accountInfo = [SELECT Name FROM account WHERE id =:accountid];
        accountName = accountInfo[0].Name;
        coc = [select Id,Name,SummonsStatus_c__c,Order_ForDealerText__c,ShipmentAccount__c,
                    Order_ForDealer__r.Name,Dealer_Info__r.Name,Order_Dealer_Info__c,Order_ForCustomerText__c,
                    Order_ForHospital__r.Name,SummonsForDirction__c,
                    Order_date__c,Order_status__c
                From Consumable_order__c
                Where Id =:ESetId
                and Order_type__c = '传票'];
             // 選択済みの明细を取得
            consumableorderdetailsSelected = new List<Consumable_orderdetails__c>();
            consumableorderdetailsRecords  = new List<ConsumableorderdetailsInfo>();
            if(ESetId==null||ESetId==''){
            }else{
                consumableorderdetailsSelected = [select Id,
                                                        Name,
                                                        Consumable_order__c,
                                                        Consumable_Product__c,
                                                        Consumable_Product__r.Name,
                                                        Shipment_Count__c,
                                                        Consumable_Product__r.Intra_Trade_List_RMB__c,
                                                        Consumable_Product__r.Asset_Model_No__c,
                                                        Sum_of_money__c,
                                                        Consumable_Product__r.Name__c,
                                                        Box_Piece__c
                                                        from Consumable_orderdetails__c
                                                        where Consumable_order__c = :ESetId
                                                        order by Name ];
            for (Integer i = 0; i < consumableorderdetailsSelected.size(); i++) {
                consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(consumableorderdetailsSelected[i]));
            }
            datelimitSearch();
            for(ConsumableorderdetailsInfo bss : consumableorderdetailsRecords){
                if(productkucun.get(bss.Prod.Id) != null){
                bss.guaranteeperiod = productkucun.get(bss.Prod.Id);
                }
            }
        }
    }
    //消费期限
    public void datelimitSearch(){
        List<Consumable_order_details2__c> orderkucun = [SELECT Id,Bar_Code__c, Name,Consumable_Product__c,Recordtypeid,
                                                            Guarantee_period_for_products__c,Sterilization_limit__c
                                                        FROM Consumable_order_details2__c
                                                        WHERE  Dealer_Arrive__c = true
                                                        AND Dealer_Shipment__c = false
                                                        AND Dealer_Saled__c = false
                                                        AND Lose_Flag__c = false
                                                        AND Bar_Code__c !=null
                                                        AND  Dealer_Info_text__c = :accountName
                                                        //AND Consumable_order_minor__r.Dealer_Info__c = :accountid
                                                        ORDER BY Consumable_Product__c, Sterilization_limit__c asc ];
        for(Integer i = 0 ; i< orderkucun.size();i++){
            if(productkucun.containsKey(orderkucun[i].Consumable_Product__c)){
                continue;
            }else{
                productkucun.put(orderkucun[i].Consumable_Product__c, orderkucun[i].Sterilization_limit__c);
            }
        }
        System.debug('productkucun ++++' + productkucun);
    }
 
    class ConsumableorderdetailsInfo  {
        public Consumable_orderdetails__c esd { get; set; }
        public Product2__c Prod { get; set; }
        public Date guaranteeperiod { get; set; }
 
        // 已存在备品set明细用
        public ConsumableorderdetailsInfo(Consumable_orderdetails__c e) {
            esd = e;
            Prod = e.Consumable_Product__r;
        }
        // 排序
        /*public Integer compareTo(Object compareTo) {
            return null;
        }*/
    }
}