Li Jun
2022-04-06 fb04e7c01d119c60632b4298d18fd93f3ccb3d79
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
public with sharing class QISPDFController {
    public QIS_Report__c qr { get; private set; }
    public User usr { get; private set; }
    public Boolean inGuarantee { get; private set; }
    public string staticResource { get; private set; }
    public string staticResourceFile { get; private set; }
    
    //  HWAG-BC68W3  故障发生日为空时, 它为真  start
    public Boolean outOfGuarantee { get; private set; }
    //  HWAG-BC68W3  故障发生日为空时, 它为真  end
    public QISPDFController() {
        qr = new QIS_Report__c();
        usr = new User();
        inGuarantee = false;
        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('QIS_Report__c'));
        staticResourceFile = JSON.serialize(PIHelper.getPIIntegrationInfo('Document'));
        
    }
    
    public void init() {
        String id = ApexPages.currentPage().getParameters().get('id');
        
        Schema.DescribeSobjectResult d = QIS_Report__c.sObjectType.getDescribe();
        Map<String, Schema.SObjectField> fieldMap = d.fields.getMap();
        
        String soql = 'select ';
        String fields = '';
        for (String field : fieldMap.keySet()) {
            if (fields.length() > 0) {
                fields += ', ';
            }
            fields += field;
        }
        soql += fields;
        soql += ', Hospital_Department__r.Phone, Hospital_Department__r.Parent.Parent.State_Master__r.Name, Hospital_Department__r.Parent.Parent.City_Master__r.Name, Hospital__r.Name'
              + ', RC__r.Alias__c, RC_manager__r.Alias__c, OSH_Manager__r.Alias__c, OSH_Manager__r.BuchangApprovalManager__c, OSH_Manager__r.BuchangApprovalManager__r.Alias__c';
 
        soql += ' from QIS_Report__c where Id = \'' + id + '\'';
        
        List<QIS_Report__c> qrList = Database.query(soql);
        if (qrList.size() > 0) {
            qr = qrList[0];
            // TODO 一つのSOQLで出来る?
            usr = [select Name, Manager.Name, fen_corp_name__c, Salesdepartment__c from User where Id = :qr.OwnerId];
            // HWAG-BC68W3 
            /*
            if (qr.QIS_Submit_day__c >= Date.today()) {
            */
           if (qr.Faliour_date__c == null) {
                outOfGuarantee = true;
           }
           if ( qr.Faliour_date__c !=null && qr.guarantee_period_formula__c >= qr.Faliour_date__c) {
            //HWAG-BC68W3 end
                inGuarantee = true;
            }
        }
    }
}