buli
2022-03-11 02ddc35714cbd1688b7cb057f770f1410de79dab
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
public with sharing class AgencyAccountCmp {
    public AgencyAccountCmp() {
        
    }
 
    @AuraEnabled
    public static List<Agency_Contact__c> getAccounts() {
        //List<Agency_Contact__c> aoList = [select Id, Agency_Hospital_Target__c, Agency_Hospital_Target__r.Name from Agency_Opportunity__c where Id = :recordId];
        //if (aoList.size() > 0) {
        //    Map<String,String> res = new Map<String, String>();
        //    res.put('Id', aoList[0].Agency_Hospital_Target__c);
        //    res.put('Name', aoList[0].Agency_Hospital_Target__r.Name);
        //    return res;
        //} else {
        //    throw new AuraHandledException('找不到经销商医院');
        //}  
        Set<String> hospitalSet = new Set<String>();
        Set<String> aHospitalSet = new Set<String>();
        List<Agency_Hospital_Link__c> ahls = [select Id, Hospital__c from Agency_Hospital_Link__c];
        for (Agency_Hospital_Link__c ahl : ahls) {
            hospitalSet.add(ahl.Hospital__c);
            aHospitalSet.add(ahl.Id);
        }
        List<Agency_Contact__c> acList1 = LightningUtil.selectOCMAgencyContact(hospitalSet, aHospitalSet);
        
        //List<Agency_Contact__c> acList2 = [select Id, Name, Doctor_Division1__c, Type__c, Hospital_DC_Name__c from Agency_Contact__c where Department_Class__c = null order by Name];
        //acList1.addAll(acList2);
 
        return acList1;
    }
 
    @AuraEnabled
    public static Map<String,String> getfiledsmap()
    {
        Map<String,Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String,List<String>>   typemap = new Map<String,List<String>>  ();
        
        Map<String,Schema.SObjectField> fieldMap = schemaMap.get('Agency_Contact__c').getDescribe().fields.getMap();
        Map<String,String> mappingmap = new Map<String,String>();
        for(Schema.SObjectField sfield : fieldMap.Values())
        {
            Schema.describefieldresult dfield = sfield.getDescribe();
            String lab = '';
            lab = dfield.getLabel();
            mappingmap.put(dfield.name,lab);
        }
        return mappingmap;
    }
 
    @AuraEnabled
    public static List<Agency_Contact__c> searchAccounts(String hosStr, String conStr) {
        //List<Agency_Contact__c> aoList = [select Id, Agency_Hospital_Target__c, Agency_Hospital_Target__r.Name from Agency_Opportunity__c where Id = :recordId];
        //if (aoList.size() > 0) {
        //    Map<String,String> res = new Map<String, String>();
        //    res.put('Id', aoList[0].Agency_Hospital_Target__c);
        //    res.put('Name', aoList[0].Agency_Hospital_Target__r.Name);
        //    return res;
        //} else {
        //    throw new AuraHandledException('找不到经销商医院');
        //}  
        String f1 = '%'+hosStr+'%';
        String f2 = '%'+conStr+'%';
        if (String.isBlank(hosStr)) f1 = '%';
        if (String.isBlank(conStr)) f2 = '%';
        Set<String> hospitalSet = new Set<String>();
        Set<String> aHospitalSet = new Set<String>();
        List<Agency_Hospital_Link__c> ahls = [select Id, Hospital__c from Agency_Hospital_Link__c];
        for (Agency_Hospital_Link__c ahl : ahls) {
            hospitalSet.add(ahl.Hospital__c);
            aHospitalSet.add(ahl.Id);
        }
        List<Agency_Contact__c> acList1 = LightningUtil.searchOCMAgencyContact(hospitalSet, aHospitalSet, f1, f2);
        //List<Agency_Contact__c> acList2 = [select Id, Name, Doctor_Division1__c, Type__c, Hospital_DC_Name__c from Agency_Contact__c where Department_Class__c = null and Hospital_DC_Name__c like :f1 and Name like :f2  order by Name];
        //acList1.addAll(acList2);
 
        return acList1;
    }
 
    @AuraEnabled
    public static void SaveLog(String module,String content,String status,String respMsg){
        string awsDataId = '';
        string sfId = '';
        string transId = '';
        try {
            Map<string,object> mso = (Map<string,object>)JSON.deserializeUntyped(respMsg);
            awsDataId = String.valueOf(mso.get('AWS_Data_Id__c'));
            transId = String.valueOf(mso.get('txId'));
            
        } catch (Exception e) {
            
        }
 
        PIHelper.saveTransLog(module, awsDataId, sfId, transId, content, status, respMsg);
    }
 
    // 20220222 PI改造 by Bright--start
 
    @AuraEnabled
    public static Map<string,string> GetConfig() {
        Map<String,string> result = new Map<String,string>();
        result.put('staticResource', JSON.serialize(PIHelper.getPIIntegrationInfo('Agency_Contact__c')));
        //result.put('sessionId', UserInfo.getSessionId());
        return result;
    }
 
    @AuraEnabled
    public static List<Agency_Contact__c> searchAccounts2(String hosStr, List<string> awsids) {
        System.debug('hosStr='+hosStr);
        System.debug('awsids='+awsids);
        String f1 = '%'+hosStr+'%';
        
        if (String.isBlank(hosStr)) f1 = '%';
        Set<String> hospitalSet = new Set<String>();
        Set<String> aHospitalSet = new Set<String>();
        List<Agency_Hospital_Link__c> ahls = [select Id, Hospital__c from Agency_Hospital_Link__c];
        for (Agency_Hospital_Link__c ahl : ahls) {
            hospitalSet.add(ahl.Hospital__c);
            aHospitalSet.add(ahl.Id);
        }
        List<Agency_Contact__c> acList1 = LightningUtil.searchOCMAgencyContact(hospitalSet, aHospitalSet, f1, awsids);
 
 
        return acList1;
    }
    // 20220222 PI改造 by Bright--end
}