高章伟
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
global without sharing class NFM401WebService{
    webservice static String sendToETQ(String iflog_Id,BatchIF_Log__c rowDataSFDC, List<String> repairIds,String statu){
        List<QIS_Report__c> temp = [select id from QIS_Report__c where id in :repairIds ];
        if(temp != null && temp.size() > 0){
            try {
                Database.executeBatch(new QISToPDFBatch(iflog_Id, rowDataSFDC,repairIds,statu),50); //生成PDF
            }
            catch (Exception e) {
                return '更新QIS报错:'+ e.getMessage();
            }
            // Database.executeBatch(new QISToPDFBatch(iflog_Id, rowDataSFDC,repairIds,statu),50); //生成PDF
        }else{
 
            // var updateRe = new sforce.SObject("Repair__c"); 
            // updateRe.Id = RepairId; 
            // updateRe.INTERFACE_RECORD_ID__c = null; 
            // updateRe.ETQ_UPLOAD_STATUS__c = null; 
            // updateRe.ETQ_UPLOAD_MESSAGE__c = null; 
            // updateRe.OSH_ConfirmationDate__c = new Date(); 
            // updateRe.OSH_Affirmant__c = uid; 
            // var serverTimestamp = sforce.connection.getServerTimestamp(); 
            // updateRe.AWS_Interface_Time__c = serverTimestamp.timestamp; 
            // updateRe.AsyncData__c = true; 
            // //alert('updateRe'+updateRe); 
            // result = sforce.connection.update([updateRe]); 
            BatchIF_Log__c iflog = new BatchIF_Log__c();
            iflog.Type__c = 'sendToETQ';
            iflog.ErrorLog__c = '';
            iflog.Log__c = 'NFM401WebService start--';
 
            Repair__c updateRe = new Repair__c();
            updateRe.Id = repairIds[0];
            updateRe.INTERFACE_RECORD_ID__c = null; 
            updateRe.ETQ_UPLOAD_STATUS__c = null; 
            updateRe.ETQ_UPLOAD_MESSAGE__c = null; 
            updateRe.OSH_ConfirmationDate__c = Date.today(); 
            updateRe.OSH_Affirmant__c = UserInfo.getUserId(); 
            updateRe.AWS_Interface_Time__c = Datetime.now();
            updateRe.AsyncData__c = true; 
            //update by rentx 2021-03-23 start 需要先更新修理的信息再掉401接口 不然的话可能会出现 调用成功但是部分修理更新失败的情况 将更新修理的步骤提前 则当修理更新失败时 就不会往下执行401的接口了 
            try{
                update updateRe;
                Database.executeBatch(new RepairToPDFBatch(iflog_Id, rowDataSFDC,repairIds,statu)); //生成PDF
                iflog.Log__c += '\n修理:'+updateRe+' 更新成功';
                iflog.Log__c = '\nNFM401WebService end--';
                insert iflog;
            }catch(Exception ex){
                iflog.ErrorLog__c += '修理:'+updateRe+' 更新失败,因为::'+ex.getMessage();
                iflog.Log__c = '\nNFM401WebService end--';
                // System.debug('更新修理报错::36'+updateRe);
                insert iflog;
                return '更新修理报错:'+ ex.getMessage();
            }
            // update updateRe;
            // Database.executeBatch(new RepairToPDFBatch(iflog_Id, rowDataSFDC,repairIds,statu)); //生成PDF
            //update by rentx end
        }
        return '发送成功!';
    }
}