liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
/**
 * *
    ODescription:
    GAuthor: sun xia
    @Date: 2023-07-11 15:31:56
    GIastEditors: sun xia
    @IastEditTime: 2023-07-11 15:31:56
 * */
public with sharing class LexLoanerArrangedEmailController {
    @AuraEnabled
    public static InitData init(String recordId) {
        String statusSting = Label.StatusProcessState;
        List<String> status = statusSting.split(',');
        InitData res = new InitData();
        try {
            List<Rental_Apply__c> racList = [SELECT Id, Status__c, RA_Status__c, Campaign__c, RC_return_to_office__c, Repair_Final_Inspection_Date_F__c, Repair__c, Assigned_Not_Shipment__c, Demo_purpose1__c, Contract_pdf_updated__c, Wei_Assigned_Cnt__c,AccDealerBlacklist__c,
            Hospital__r.IFTradeComplianceIntercept2__c// WYL 贸易合规2期add
             from Rental_Apply__c where Id = :recordId];
            if(racList.size()>0){
                Rental_Apply__c rac = racList[0];
                if( rac.Campaign__c != null ){
                    //获取学会对象
                    Campaign camp = [select Id, Status, Rental_Apply_Flag__c,IF_Approved__c,Approved_Status__c, Meeting_Approved_No__c from Campaign where id = :rac.Campaign__c];
                    res.campaignId = camp.Id;
                    res.campaignStatus = camp.Status;
                    res.iFApproved = camp.IF_Approved__c;
                    res.meetingApprovedNo = camp.Meeting_Approved_No__c;
                    res.approvedStatus = camp.Approved_Status__c;
                }   
                res.id = recordId;   
                res.raStatus = rac.RA_Status__c;
                res.weiAssignedCnt = Integer.valueOf(rac.Wei_Assigned_Cnt__c);
                res.assignedNotShipment = Integer.valueOf(rac.Assigned_Not_Shipment__c);
                res.demoPurpose1 = rac.Demo_purpose1__c;
                res.contractPdfUpdated = rac.Contract_pdf_updated__c;
                res.repairId = rac.Repair__c;
                res.repairFinalInspectionDateF = rac.Repair_Final_Inspection_Date_F__c;
                res.rCReturnToOffice = rac.RC_return_to_office__c;
                res.statusList = status;
                res.accDealerBlacklist = rac.AccDealerBlacklist__c;
                // WYL 贸易合规2期 start
                if (rac.Hospital__r.IFTradeComplianceIntercept2__c == 'intercept') {
                    res.accDealerBlacklist2 = '1';
                }else if (rac.Hospital__r.IFTradeComplianceIntercept2__c == 'Freeze'){
                    res.accDealerBlacklist2 = '2';
                }
                // WYL 贸易合规2期 end
                //贸易合规二期  20231126 sx add start  邮件新加字段20240131
                List<Rental_Apply_Equipment_Set_Detail__c> raesdList = [SELECT Id, Asset__r.Name, Asset__r.SerialNumber, Asset__r.Product2.ProTradeComplianceStatus__c, Asset__r.Product2.CountryOfOrigin__c, Asset__r.Product2.USRatio_US__c FROM Rental_Apply_Equipment_Set_Detail__c WHERE Rental_Apply__c = :recordId AND Shipment_request_day__c = null];
                //发邮件明细 start
                List<String> emailList = new List<String>();
                //发邮件明细 end
                if(raesdList.size()>0 && rac.AccDealerBlacklist__c == '2'){
                    for(Rental_Apply_Equipment_Set_Detail__c rea : raesdList){
                        if(rea.Asset__r.Product2.ProTradeComplianceStatus__c == '0'){
                            res.tradeComplianceStatus = '0';
                            emailList.add(rea.Id);        //发邮件明细 add
                        }
                    }
                }
                //发邮件明细 start
                if(res.tradeComplianceStatus == '0' && emailList.size() > 0){
                    SendEmailUtil.tradeTempleSend(recordId, '出库指示', null, emailList);
                }
                //发邮件明细 end
                //贸易合规二期  20231126 sx add start
            }
        }
        catch (Exception e) {
            System.debug(LoggingLevel.INFO, '****e:' + e);
        }
        system.debug('res======'+res);
        return res;
    }
 
    
    //获取备品借出一栏
    @AuraEnabled
    public static Integer getRentalApplyEquipmentSet(String recordId) {
        Rental_Apply__c tempRa = [SELECT Id, Bollow_Date__c from Rental_Apply__c where Id = :recordId];
        List<Rental_Apply_Equipment_Set__c> tempRaEquipSetList = new List<Rental_Apply_Equipment_Set__c>();
        // Integer pageLength;
        Integer pageLength=1 ;//20231110 李文涛 默认值不能为null
        if(tempRa.Bollow_Date__c != null) {
            tempRaEquipSetList = [SELECT Id from Rental_Apply_Equipment_Set__c where Rental_Apply__c = :recordId AND Shippment_loaner_time__c != null and RAES_Status__c != '已分配' and RAES_Status__c != '取消分配'];
        }else {
            tempRaEquipSetList = [SELECT Id from Rental_Apply_Equipment_Set__c where Rental_Apply__c = :recordId AND RAES_Status__c != '已分配' and RAES_Status__c != '取消分配'];
        }
        //
        if(tempRaEquipSetList.size()>0) {
            Integer setLength = tempRaEquipSetList.size();
            pageLength = Math.mod(setLength,10) == 0 ? setLength/10 : Math.round(setLength) + 1;
        }
        return pageLength;
    }
 
    public class InitData{
        @AuraEnabled
        public String id;
        @AuraEnabled
        public String campaignStatus;   //学会状态
        @AuraEnabled
        public String campaignId;   //学会Id
        @AuraEnabled
        public String raStatus;     //备品借出申请状态
        @AuraEnabled
        public Integer weiAssignedCnt;      //未分配件数  Wei_Assigned_Cnt__c
        @AuraEnabled
        public Integer assignedNotShipment; //已分配未出库指示  Assigned_Not_Shipment__c
        @AuraEnabled
        public String demoPurpose1;         //使用目的1  Demo_purpose1__c
        @AuraEnabled
        public Boolean contractPdfUpdated;  //合同书已上传    Contract_pdf_updated__c
        @AuraEnabled
        public String repairId;             //学会.修理Id
        @AuraEnabled
        public Date repairFinalInspectionDateF;     //修理最终检测日F      Repair_Final_Inspection_Date_F__c
        @AuraEnabled
        public Date rCReturnToOffice;       //RC修理品返送日      RC_return_to_office__c
        @AuraEnabled
        public Boolean iFApproved;          //学会.是否需要申请决裁
        @AuraEnabled
        public String meetingApprovedNo;    //学会.会议决裁编码
        @AuraEnabled
        public String approvedStatus;       //学会.决裁状态   Approved_Status__c
        @AuraEnabled
        public List<String> statusList;
        @AuraEnabled
        public String accDealerBlacklist;
        @AuraEnabled
        public String tradeComplianceStatus;    // 对应产品的贸易合规状态
        @AuraEnabled
        public String accDealerBlacklist2; // WYL 贸易合规2期 add
    }
}