| | |
| | | // private static final String API = '/admin/api/scd/save'; |
| | | private static final String API = '/admin/api/repair/save'; |
| | | |
| | | // 2022-05-05 zyh update start |
| | | private static List < BatchIF_Log__c > logList = new List < BatchIF_Log__c > (); |
| | | private static List < BatchIF_Log__c > rowList = new List < BatchIF_Log__c > (); |
| | | private static Map < Id,BatchIF_Log__c > logMap = new Map < Id,BatchIF_Log__c > (); |
| | | // 2022-05-05 zyh update end |
| | | public static Integer status; |
| | | public static String message; |
| | | public class RepairOrderInfo { |
| | |
| | | iflog.MessageGroupNumber__c = nowStr; |
| | | } |
| | | List < RepairOrderInfo > repairs = new List < RepairOrderInfo > (); |
| | | List < RepairOrderInfo > repairs1 = new List < RepairOrderInfo > (); |
| | | BatchIF_Log__c rowData = null; |
| | | List < Repair__c > repairList = new List < Repair__c > (); |
| | | if (repairOrderIdList != null && repairOrderIdList.size() > 0) { |
| | |
| | | } |
| | | logstr += '\nend'; |
| | | if (repairs.size() > 0) { |
| | | rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs); |
| | | execute(rowData, iflog); |
| | | // 2022-05-05 zyh update start |
| | | for (RepairOrderInfo roi : repairs ) { |
| | | repairs1.add(roi); |
| | | rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs1); |
| | | execute1(rowData, iflog); |
| | | // rowData = NFMUtil.makeRowData(iflog, LOG_TYPE, repairs); |
| | | // execute(rowData, iflog); |
| | | repairs1 = new List < RepairOrderInfo > (); |
| | | } |
| | | upsert logList; |
| | | upsert rowList; |
| | | delete logMap.values(); |
| | | // 2022-05-05 zyh update end |
| | | // upsert rowData; |
| | | } |
| | | } catch (Exception e) { |
| | | // 发生错误时 |
| | |
| | | iflog.Log__c = logstr; |
| | | upsert iflog; |
| | | upsert rowDataSFDC; |
| | | // logList.add(iflog); |
| | | // rowList.add(rowDataSFDC); |
| | | |
| | | } |
| | | // 2022-05-05 zyh update start |
| | | public static void execute1(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'; |
| | | if (iflog == null) { |
| | | iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = LOG_TYPE; |
| | | iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c; |
| | | iflog.Log__c = logstr; |
| | | iflog.ErrorLog__c = ''; |
| | | |
| | | } else { |
| | | // iflog.Type__c = LOG_TYPE; |
| | | // iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c; |
| | | // logstr = iflog.Log__c; |
| | | logMap.put(iflog.Id, iflog); |
| | | iflog = new BatchIF_Log__c(); |
| | | iflog.Type__c = LOG_TYPE; |
| | | iflog.MessageGroupNumber__c = rowDataSFDC.MessageGroupNumber__c; |
| | | iflog.Log__c = logstr; |
| | | iflog.ErrorLog__c = ''; |
| | | } |
| | | |
| | | try { |
| | | String data = NFMUtil.getRowDataStr(rowDataSFDC); |
| | | String status = NFMUtil.sendToAWS(data, API); |
| | | System.debug('NFM603Log--status->' + status); |
| | | |
| | | if ('OK'.equals(status)) { |
| | | logstr += status + '\n'; |
| | | rowDataSFDC.retry_cnt__c = 0; |
| | | } else { |
| | | rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, null, status); |
| | | } |
| | | |
| | | } catch (Exception ex) { |
| | | // TODO IOException |
| | | // 错误发生时 |
| | | logstr += ex.getMessage(); |
| | | iflog.ErrorLog__c += ex.getMessage() + '\n'; |
| | | iflog.ErrorLog__c += ex.getStackTraceString() + '\n'; |
| | | if(!Test.isRunningTest()){ |
| | | rowDataSFDC = NFMUtil.LogAutoSend(rowDataSFDC, ex, null); |
| | | } |
| | | } |
| | | iflog.Log__c = logstr; |
| | | // upsert iflog; |
| | | // upsert rowDataSFDC; |
| | | logList.add(iflog); |
| | | rowList.add(rowDataSFDC); |
| | | |
| | | } |
| | | |
| | | // 2022-05-05 zyh update end |
| | | // 故障描述 |
| | | private static Map < id, List < FaultDesc >> getFaultDescMap(List < String > repairOrderIdList) { |
| | | List < Repair_reason__c > reasonList = |
| | |
| | | iflog.Type__c = LOG_TYPE; |
| | | iflog.Log__c = 'callout start\n'; |
| | | insert iflog; |
| | | NFM603Controller.executefuture(iflog, rprIds); |
| | | // 2022-04-29 zyh update start |
| | | if(UserInfo.getUserId().equals(System.Label.interfaceUserID)){ |
| | | NFM603Controller.executefuture(iflog, rprIds); |
| | | }else{ |
| | | NFM603Controller.callout(iflog.Id, rprIds); |
| | | } |
| | | // 2022-04-29 zyh update end |
| | | } |
| | | } else { |
| | | if (Trigger.isUpdate) { |