| | |
| | | public String RepairType; //修理区分------------------- |
| | | public String QuotationGread; //报价等级(new) |
| | | public String detectionResult; //检测结果 |
| | | //LLIU-CG53S9 LY 20220711 start |
| | | public String isContractUser; //是否合同用户 |
| | | public String oldRepairNo; //原修理单号 |
| | | public String closeRepairDate; //修理单关闭日 |
| | | //LLIU-CG53S9 LY 20220711 end |
| | | public String cus_dn; //DN号 |
| | | //修理增加OTS运单号字段 thh 20220308 start |
| | | public String OTSRepairOrder; |
| | |
| | | Repair_Final_Inspection_DateTime__c, |
| | | Repair_Shipped_DateTime__c, |
| | | Repair_Discount_approval_DateTime_form__c, |
| | | // 2022-05-20 zyh update start |
| | | Repair_Estimated_Date__c, |
| | | Repair_Estimated_date_formula__c, |
| | | // 2022-05-20 zyh update end |
| | | Agreed_DateTime__c, |
| | | //修理增加OTS运单号字段 thh 20220308 start |
| | | OTSRepairOrder__c |
| | | //修理增加OTS运单号字段 thh 20220308 end |
| | | //LLIU-CG53S9 LY 20220711 start |
| | | ,IF_ContractUser__c |
| | | ,Old_Name__c |
| | | ,SAP_not_accept_repair_result__c |
| | | //LLIU-CG53S9 LY 20220711 end |
| | | from Repair__c where id in: repairOrderIdList |
| | | ]; |
| | | } |
| | | String logstr = iflog.Log__c + ' ' + 'NumberOfRecord=' + repairList.size() + '\n'; |
| | | String logstr = iflog.Log__c + ' ' + 'NumberOfRecord=' + repairList.size() + '\n' + repairList[0].Name + '\n'; |
| | | try { |
| | | List < Id > repairIdList = new List < Id > (); |
| | | for (Repair__c repair: repairList) { |
| | |
| | | info.RepairType = repair.Repair_Severity_Rank__c; //修理区分---------- |
| | | info.QuotationGread = repair.Repair_Rank__c; //报价等级 |
| | | info.detectionResult = repair.InspectionResultFlag__c; //检测结果 |
| | | //LLIU-CG53S9 LY 20220711 start |
| | | info.isContractUser = repair.IF_ContractUser__c ? 'true' : 'false'; //是否合同用户 |
| | | info.oldRepairNo = repair.Old_Name__c; //原修理受付番号 |
| | | info.closeRepairDate = NFMUtil.formatDate2StrDateTime(repair.SAP_not_accept_repair_result__c); //修理单关闭日 |
| | | //LLIU-CG53S9 LY 20220711 end |
| | | info.FaultDesc = reasonMap.get(repair.id); //故障描述List |
| | | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| | | info.deliveryLogisticsMode = repair.DeliveryLogisticsMode__c; //送修物流方式======自己写字段 |
| | |
| | | info.RCacceptanceDate = NFMUtil.formatDateTime2Str(repair.Repair_Ordered_DateTime__c); //4.修理品RC受理日(小程序) |
| | | //info.inspectionDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Inspection_Date__c); //修理检测日 |
| | | info.inspectionDate = NFMUtil.formatDateTime2Str(repair.Repair_Inspection_DateTime__c); //5.修理检测日(小程序) |
| | | info.FirstQuotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Firstestimated_Date_formula__c); //初次报价日 |
| | | // info.FirstQuotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Firstestimated_Date_formula__c); //初次报价日 2022-05-20 zyh 注释 |
| | | info.FirstQuotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Estimated_Date__c); //初次报价日 2022-05-20 zyh add |
| | | //info.priceApprovalDate = NFMUtil.formatDate2StrDateTime(repair.Repair_Discount_approval_Date_formula__c); //减价申请批准日 |
| | | info.priceApprovalDate = NFMUtil.formatDateTime2Str(repair.Repair_Discount_approval_DateTime_form__c); //减价申请批准日(小程序) |
| | | info.quotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Quotation_date__c); //报价日 |
| | | // info.quotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Quotation_date__c); //报价日 2022-05-20 zyh 注释 |
| | | info.quotationDate = NFMUtil.formatDate2StrDateNewTime(repair.Repair_Estimated_date_formula__c); //报价日 2022-05-20 zyh add |
| | | //info.cancelRepairDate = NFMUtil.formatDate2StrDateTime(repair.repair_cancel_date__c); //修理取消日 |
| | | info.cancelRepairDate = NFMUtil.formatDateTime2Str(repair.repair_cancel_dateTime__c); //修理取消日(小程序) |
| | | //info.userAgreeDAte = NFMUtil.formatDate2StrDateTime(repair.Agreed_Date__c); //用户同意日 |
| | |
| | | logstr += '\nend'; |
| | | if (repairs.size() > 0) { |
| | | // 2022-05-05 zyh update start |
| | | for (RepairOrderInfo roi : repairs ) { |
| | | /*for (RepairOrderInfo roi : repairs ) { |
| | | repairs1.add(roi); |
| | | rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs1); |
| | | // 2022-05-07 zyh update start |
| | |
| | | // rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs); |
| | | // execute(rowData, iflog); |
| | | repairs1 = new List < RepairOrderInfo > (); |
| | | } |
| | | }// 2022-08-19 zyh 小程序异步处理,恢复批量发送 |
| | | */ // 2023-02-02 zyh 五个一批推送小程序 注释上方for循环 |
| | | // 2023-02-02 zyh 五个一批推送小程序 start |
| | | for (Integer i=1; i <= repairs.size();i++ ) { |
| | | if(Math.mod(i, 5) > 0 ){ |
| | | repairs1.add(repairs[i-1]); |
| | | if(i == repairs.size()){ |
| | | rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs1); |
| | | if (String.isBlank(rowData.MessageGroupNumber__c)) { |
| | | rowData.MessageGroupNumber__c = nowStr; |
| | | } |
| | | execute1(rowData, iflog); |
| | | } |
| | | }else{ |
| | | repairs1.add(repairs[i-1]); |
| | | rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs1); |
| | | if (String.isBlank(rowData.MessageGroupNumber__c)) { |
| | | rowData.MessageGroupNumber__c = nowStr; |
| | | } |
| | | execute1(rowData, iflog); |
| | | repairs1 = new List < RepairOrderInfo > (); |
| | | } |
| | | |
| | | } |
| | | // 2023-02-02 zyh 五个一批推送小程序 end |
| | | upsert logList; |
| | | upsert rowList; |
| | | delete logMap.values(); |
| | | // 2022-05-11 zyh update start |
| | | if (logMap.size() > 0) { |
| | | delete logMap.values(); |
| | | } |
| | | // 2022-05-11 zyh update end |
| | | // delete logMap.values(); |
| | | // 2022-05-05 zyh update end |
| | | // upsert rowData; |
| | | } |
| | |
| | | public static void execute(BatchIF_Log__c rowDataSFDC, BatchIF_Log__c iflog) { |
| | | Integer batch_retry_max_cnt = Integer.valueOf(System.Label.batch_retry_max_cnt); |
| | | |
| | | String logstr = rowDataSFDC.MessageGroupNumber__c + ' start\n'; |
| | | String logstr = rowDataSFDC.Name + ' start\n'; |
| | | if (iflog == null) { |
| | | iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = LOG_TYPE; |
| | |
| | | logstr += status + '\n'; |
| | | rowDataSFDC.retry_cnt__c = 0; |
| | | } else { |
| | | rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status); |
| | | // rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status); //2022-06-24 zyh 注释:重发逻辑修改 |
| | | //2022-06-24 zyh update start |
| | | if (rowDataSFDC.retry_cnt__c == null) rowDataSFDC.retry_cnt__c = 0; |
| | | if (rowDataSFDC.retry_cnt__c < batch_retry_max_cnt) { |
| | | rowDataSFDC.retry_cnt__c++; |
| | | // 20230201 ljh start |
| | | // LogAutoSendSchedule.logId = rowDataSFDC.Id; |
| | | LogAutoSendSchedule.assignOneMinute(); |
| | | // LogAutoSendSchedule.assignOneMinute(rowDataSFDC.MessageGroupNumber__c,rowDataSFDC.Type__c); |
| | | // 20230201 ljh end |
| | | } |
| | | if (rowDataSFDC.retry_cnt__c >= batch_retry_max_cnt) { |
| | | rowDataSFDC.ErrorLog__c = 'status:' + status + |
| | | '\n错误次数已经超过自动送信设定的最大次数,请手动送信'; |
| | | } |
| | | //2022-06-24 zyh update end |
| | | } |
| | | |
| | | } catch (Exception ex) { |
| | |
| | | iflog.ErrorLog__c += ex.getMessage() + '\n'; |
| | | iflog.ErrorLog__c += ex.getStackTraceString() + '\n'; |
| | | if(!Test.isRunningTest()){ |
| | | rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null); |
| | | // rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null); //2022-06-24 zyh 注释:重发逻辑修改 |
| | | //2022-06-24 zyh update start |
| | | if (rowDataSFDC.retry_cnt__c == null) rowDataSFDC.retry_cnt__c = 0; |
| | | if (rowDataSFDC.retry_cnt__c < batch_retry_max_cnt){ |
| | | rowDataSFDC.retry_cnt__c++; |
| | | // 20230201 ljh start |
| | | // LogAutoSendSchedule.logId = rowDataSFDC.Id; |
| | | LogAutoSendSchedule.assignOneMinute(); |
| | | // LogAutoSendSchedule.assignOneMinute(rowDataSFDC.MessageGroupNumber__c,rowDataSFDC.Type__c); |
| | | // 20230201 ljh end |
| | | } |
| | | if (rowDataSFDC.retry_cnt__c >= batch_retry_max_cnt){ |
| | | rowDataSFDC.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowDataSFDC.ErrorLog__c+'错误次数已经超过自动送信设定的最大次数,请手动送信'; |
| | | } |
| | | //2022-06-24 zyh update end |
| | | } |
| | | } |
| | | iflog.Log__c = logstr; |
| | |
| | | // iflog.Type__c = LOG_TYPE; |
| | | // iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c; |
| | | // logstr = iflog.Log__c; |
| | | logMap.put(iflog.Id, iflog); |
| | | // 2022-05-11 zyh update start |
| | | if (String.isNotBlank(iflog.Id)) { |
| | | logMap.put(iflog.Id, iflog); |
| | | } |
| | | // 2022-05-11 zyh update end |
| | | // logMap.put(iflog.Id, iflog); |
| | | iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = LOG_TYPE; |
| | | iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c; |
| | |
| | | logstr += status + '\n'; |
| | | rowDataSFDC.retry_cnt__c = 0; |
| | | } else { |
| | | rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status); |
| | | // rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status); //2022-06-24 zyh 注释:重发逻辑修改 |
| | | //2022-06-24 zyh update start |
| | | if (rowDataSFDC.retry_cnt__c == null) rowDataSFDC.retry_cnt__c = 0; |
| | | if (rowDataSFDC.retry_cnt__c < batch_retry_max_cnt) { |
| | | rowDataSFDC.retry_cnt__c++; |
| | | // 20230201 ljh start |
| | | // LogAutoSendSchedule.logId = rowDataSFDC.Id; |
| | | LogAutoSendSchedule.assignOneMinute(); |
| | | // LogAutoSendSchedule.assignOneMinute(rowDataSFDC.MessageGroupNumber__c,rowDataSFDC.Type__c); |
| | | // 20230201 ljh end |
| | | } |
| | | if (rowDataSFDC.retry_cnt__c >= batch_retry_max_cnt) { |
| | | rowDataSFDC.ErrorLog__c = 'status:' + status + |
| | | '\n错误次数已经超过自动送信设定的最大次数,请手动送信'; |
| | | } |
| | | //2022-06-24 zyh update end |
| | | } |
| | | |
| | | } catch (Exception ex) { |
| | |
| | | iflog.ErrorLog__c += ex.getMessage() + '\n'; |
| | | iflog.ErrorLog__c += ex.getStackTraceString() + '\n'; |
| | | if(!Test.isRunningTest()){ |
| | | rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null); |
| | | // rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null); //2022-06-24 zyh 注释:重发逻辑修改 |
| | | //2022-06-24 zyh update start |
| | | if (rowDataSFDC.retry_cnt__c == null) rowDataSFDC.retry_cnt__c = 0; |
| | | if (rowDataSFDC.retry_cnt__c < batch_retry_max_cnt){ |
| | | rowDataSFDC.retry_cnt__c++; |
| | | // 20230201 ljh start |
| | | // LogAutoSendSchedule.logId = rowDataSFDC.Id; |
| | | LogAutoSendSchedule.assignOneMinute(); |
| | | // LogAutoSendSchedule.assignOneMinute(rowDataSFDC.MessageGroupNumber__c,rowDataSFDC.Type__c); |
| | | // 20230201 ljh end |
| | | } |
| | | if (rowDataSFDC.retry_cnt__c >= batch_retry_max_cnt){ |
| | | rowDataSFDC.ErrorLog__c = ex.getMessage() + '\n' + ex.getStackTraceString() + '\n' + rowDataSFDC.ErrorLog__c+'错误次数已经超过自动送信设定的最大次数,请手动送信'; |
| | | } |
| | | //2022-06-24 zyh update end |
| | | } |
| | | } |
| | | iflog.Log__c = logstr; |
| | |
| | | Repair__c oldrpr = oldMap.get(rpr.Id); |
| | | // 修理有报修子单号,并且 待发送AWS为false 发送给AWS |
| | | if (String.isNotBlank(rpr.RepairSubOrder__c) && !rpr.AwaitToSendAWS__c) { |
| | | if (((rpr.status__c == '0.申请完毕' || rpr.status__c == '1.受理完毕') && (oldrpr.SAP_Transfer_time__c == null && rpr.SAP_Transfer_time__c != null)) || |
| | | if (((rpr.status__c == '0.申请完毕' || rpr.status__c == '1.受理完毕' || rpr.Status1__c == '0.删除') && (oldrpr.SAP_Transfer_time__c == null && rpr.SAP_Transfer_time__c != null)) || |
| | | (rpr.Address_type__c == 'X' && (rpr.Address_Type_Index__c != oldrpr.Address_Type_Index__c)) || |
| | | // 2022/4/6 zhangyuheng update start |
| | | (rpr.OTSRepairOrder__c != oldrpr.OTSRepairOrder__c) || // OTS订单号有值,发送AWS |
| | |
| | | // 2022/4/18 zhangyuheng update start |
| | | (rpr.FSE_ApplyForRepair_time__c != oldrpr.FSE_ApplyForRepair_time__c) || // FSE申请修理日发生改变,发送AWS |
| | | (rpr.Repair_Ordered_DateTime__c != oldrpr.Repair_Ordered_DateTime__c) || // 4.修理品RC受理日(小程序)发生改变,发送AWS |
| | | (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) || // 初次报价日(不用)发生改变,发送AWS |
| | | // (rpr.Repair_Firstestimated_Date__c != oldrpr.Repair_Firstestimated_Date__c) || // 初次报价日(不用)发生改变,发送AWS 2022-05-20 zyh 注释 |
| | | (rpr.Repair_Estimated_Date__c != oldrpr.Repair_Estimated_Date__c) || // 报价日(不用)--初次报价日用发生改变,发送AWS 2022-05-20 zyh add |
| | | (rpr.Repair_Shipped_DateTime__c != oldrpr.Repair_Shipped_DateTime__c) || // 11.RC修理品返送日(小程序)发生改变,发送AWS |
| | | (rpr.Repair_Final_Inspection_DateTime__c != oldrpr.Repair_Final_Inspection_DateTime__c) || // 10.最终检测日(小程序)发生改变,发送AWS |
| | | (rpr.Agreed_DateTime__c != oldrpr.Agreed_DateTime__c) || //7.用户同意日(小程序)发生改变,发送AWS |
| | | (rpr.Agreed_Date__c != oldrpr.Agreed_Date__c) || // 7.用户同意日发生改变,发送AWS |
| | | (rpr.engineerSendDate__c != oldrpr.engineerSendDate__c) //修理品寄送日发生改变,发送AWS |
| | | // 2022/4/18 zhangyuheng update start |
| | | //LLIU-CG53S9(状态是已删除的修理单要同步到服务系统) LY 20220713 start |
| | | || (rpr.SAP_not_accept_repair_result__c != oldrpr.SAP_not_accept_repair_result__c) //修理单关闭日 |
| | | //LLIU-CG53S9(状态是已删除的修理单要同步到服务系统) LY 20220713 end |
| | | ) { |
| | | |
| | | if (NFM603Controller.NFM603_Ids.contains(rpr.Id) == false) { |
| | | NFM603Controller.NFM603_Ids.add(rpr.Id); |
| | | rprIdMap.put(rpr.Id, rpr.Id); |
| | | System.debug('111111111111111111112222222222'); |
| | | } |
| | | } |
| | | // 2022/4/19 zhangyuheng update start |