Li Jun
2022-03-28 f5a94e721ae5a26f817f0df75065b64f1f192eb3
force-app/main/default/classes/NFM501FutureController.cls
@@ -4,13 +4,19 @@
    //    投标截止时间
    // 2021/01/04 18:00
    //add by sushanhu for pi 20220310 start
    public static String txId;
    public  String txId;
    
    //add by sushanhu for pi 20220310 end
    public String rowData_id;
    public NFM501FutureController(String rowData_id) {
        this.rowData_id = rowData_id;
    }
     //add by sushanhu for pi 20220310 start
    //  public NFM501FutureController(String rowData_id,String txId) {
    //      this.rowData_id = rowData_id;
    //     this.txId = txId;
    //  }
     //add by sushanhu for pi 20220310 end
    public static Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt);
    public void execute(QueueableContext context /*, String iflog_Id*/ ) {
        //需加一数字变量(如果获取到 html附件,其他附件,在日志中显示数量)
@@ -22,7 +28,14 @@
            from BatchIF_Log__c where RowDataFlg__c = true and Id = : rowData_id
        ];
        //存放报错信息
        txId =rowData.AWS_Transaction_Id__c; //add by sushanhu for pipl 20220310
        //add by sushanhu for pipl 20220311 start
        system.debug('txId from log'+rowData.AWS_Transaction_Id__c);
        if (!String.isEmpty(rowData.AWS_Transaction_Id__c)) {
            txId =rowData.AWS_Transaction_Id__c; //add by sushanhu for pipl 20220310
        }else {
            system.debug('txId from NF501'+txId);
        }
         //add by sushanhu for pipl 20220311 end
        system.debug('nfm501future awsid'+txId);
        BatchIF_Log__c iflog501Future = new BatchIF_Log__c();
        iflog501Future.Type__c = 'NFM501';
@@ -32,11 +45,14 @@
        iflog501Future.RowDataFlg__c = false;
        iflog501Future.AWS_Transaction_Id__c=rowData.AWS_Transaction_Id__c;
        insert iflog501Future;
        NFM501FutureController.main(rowData.Id, iflog501Future.Id, false);
        NFM501FutureController.main(rowData.Id, iflog501Future.Id, false,txId);
    }
    @future(callout = true)
    //重发(把从接口获取到的数据存入日志中,再把日志中存入的数据重新JOSN解析一遍)
    public static void main(String rowData_id, String iflog_id, boolean Manual_execution501future) {
    public static void main(String rowData_id, String iflog_id, boolean Manual_execution501future,
                                String txId //增加事务id forpipl 20220310
            ) {
        BatchIF_Log__c rowData = [Select Id, Name, Log__c, ErrorLog__c, Log2__c, Log3__c,
            Log4__c, Log5__c, Log6__c, Log7__c, Log8__c, Log9__c, Log10__c, Log11__c,
            Log12__c, MessageGroupNumber__c, retry_cnt__c, NFM501Future_Count__c,
@@ -106,7 +122,8 @@
            SumUnit__c, AreaCity__c, AreaCountry__c, AgentUnit1__c,
            AgentUnit2__c, AgentUnit3__c, AgentUnit4__c, AgentUnit5__c,
            ZhaoRelationName__c, ZhongRelationName__c,
            publicDate__c, noticeDate__c, ResultDate__c
            publicDate__c, noticeDate__c, ResultDate__c,
            AWS_Data_Id__c //ADD FOR pi SUSHANHU 20220311
            FROM Tender_information__c Where ProjectId__c in : projectIdList
        ];
        Map < String, Tender_information__c > TenMap = new Map < String, Tender_information__c > ();
@@ -144,7 +161,11 @@
            for (NFM501Controller.ListItem LI: getQLMData1.data.list1) {
                // 項目転送のセット
                Tender_information__c te1 = new Tender_information__c();
                //add aws dataid sushanhu 20220223 start
                if(String.isEmpty(LI.DataId)){
                    continue;
                }
                te1.AWS_Data_Id__c = LI.DataId;
                //add aws dataid sushanhu 20220223 end
                if (String.isBlank(LI.projectId)) {
@@ -537,6 +558,7 @@
            Map < string, Tender_information__c > TenderMap = new map < string, Tender_information__c > ();
            
            for (Tender_information__c TMap: updateTenderMap.values()) {
                system.debug('TMap---'+JSON.serialize(TMap));
                TenderMap.put(TMap.ProjectId__c, TMap);
                PIHelper.IdList il= new PIHelper.IdList();
                // add for pipl  sushanhu 20220310 start
@@ -581,13 +603,15 @@
                throw new ControllerUtil.myException('aaa');
            }
            //确认事务 add for pi sushanhu 20220310 start
            PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            // PIHelper.confirmTrans('NFM501',1,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            PIHelper.insertConfirmTrans('NFM501',1,null,txId,1,NFM501AWS.transactionURL,idList);
            //确认事务 add for pi sushanhu 20220310 end
        } catch (Exception ex) {
            // 如果数据获取过程中,有错误(同一游标,如果报错,是他重新获取一遍,如果三次都没能获取到,就发送邮件报错信息,然后手动进行获取)
            Database.rollback(sp);
            //确认事务 add for pi sushanhu 20220310 start
            PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            // PIHelper.confirmTrans('NFM501',0,null,txId,NFM501AWS.token,NFM501AWS.transactionURL,idList);
            PIHelper.insertConfirmTrans('NFM501',0,null,txId,1,NFM501AWS.transactionURL,idList);
            //确认事务 add for pi sushanhu 20220310 end
            System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getMessage());
            System.debug(Logginglevel.ERROR, 'QLMData_' + rowData.MessageGroupNumber__c + ':' + ex.getStackTraceString());