| | |
| | | //20220330 lt WLIG-CCT9UG 【委托】关于市场多年保计提金调整 start |
| | | public String QuotationDate; |
| | | //20220330 lt WLIG-CCT9UG 【委托】关于市场多年保计提金调整 end |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 start |
| | | public String BollowDate; //备品中心出库日 |
| | | public String IfRentalApply; //是否申请备品 |
| | | public String OfferRental; //是否提供备品(NEW) |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 end |
| | | //URF限次合同2期 xxf 20220811 start |
| | | public String Series; |
| | | //URF限次合同2期 xxf 20220811 end |
| | | |
| | | |
| | | //再注册分析 需求 新增字段 20220811 |
| | | public String Reanalysis; |
| | | //DB202211397391“维保预判”和“维保项目”新增方案 fy start |
| | | public String MAINITIAL; |
| | | //DB202211397391“维保预判”和“维保项目”新增方案 fy end |
| | | // 上限合同 by20230104 start |
| | | public String ZFLAG_SX; //到达上限 |
| | | public String ZFLAG_CGSX; //超过合同上限 |
| | | // 上限合同 by20230104 end |
| | | } |
| | | ////NFM103修改Rest end |
| | | |
| | | // Repair__cのId |
| | | public static Set<Id> NFM103_Ids = new Set<Id>(); |
| | | public static String debug_msg = ''; |
| | | public static String rprId = '' ; //2022-07-14 zyh add |
| | | |
| | | // on Repair__c (after insert, after update) |
| | | // 新規修理、or 受付用の項目を編集した時(RepairOrderStatusCode__c = A95時のみ 受付用の項目を編集 できます) |
| | |
| | | NFM103Controller.debug_msg += 'NFM103_callout_update_' + rpr.Name; |
| | | } |
| | | } |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 start |
| | | if (rpr.SAPRepairNo__c !=null && (oldMap.get(rpr.Id).Bollow_Date__c != rpr.Bollow_Date__c ||oldMap.get(rpr.Id).if_Rental_Apply__c !=rpr.if_Rental_Apply__c || oldMap.get(rpr.Id).Offer_Rental_New__c != rpr.Offer_Rental_New__c)){ |
| | | if (NFM103Controller.NFM103_Ids.contains(rpr.Id) == false) { |
| | | NFM103_Ids.add(rpr.Id); |
| | | rprIds.add(rpr.Id); |
| | | updMap.put(rpr.Id, new Repair__c(Id = rpr.Id,Address_type__c = 'A')); |
| | | NFM103Controller.debug_msg += 'NFM103_callout_update2_' + rpr.Name; |
| | | } |
| | | } |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 end |
| | | |
| | | // 到达上限 修理单修改时 上限合同 by20230104 start |
| | | if ((rpr.ZFLAG_SX__c == true && oldMap.get(rpr.Id).ZFLAG_SX__c !=rpr.ZFLAG_SX__c && rpr.Agreed_Date__c!=null) || |
| | | (rpr.ZFLAG_SX__c == false && oldMap.get(rpr.Id).ZFLAG_SX__c !=rpr.ZFLAG_SX__c && rpr.Agreed_Date__c==null) ){ |
| | | if (NFM103Controller.NFM103_Ids.contains(rpr.Id) == false) { |
| | | NFM103_Ids.add(rpr.Id); |
| | | rprIds.add(rpr.Id); |
| | | updMap.put(rpr.Id, new Repair__c(Id = rpr.Id,Address_type__c = 'X')); |
| | | NFM103Controller.debug_msg += 'NFM103_callout_update3_' + rpr.Name; |
| | | } |
| | | } |
| | | // 到达上限 修理单修改时 上限合同 by20230104 end |
| | | // // RepairOrderStatusCode__c = A95 (取消修理受理)の時だけ 受付用の項目を編集した時、再度 SAP に送信 |
| | | // // TODO SAP側 同じ番号の再送はできるか?、使ってないかも!! |
| | | // else if (NFM103Controller.NFM103_Ids.contains(rpr.Id) == false && rpr.RepairOrderStatusCode__c == 'A95') { |
| | |
| | | insert iflog; |
| | | iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id]; |
| | | System.debug(Logginglevel.DEBUG, 'NFM103_' + iflog.Name + ' start'); // callout の中 end のlogを出します |
| | | NFM103Controller.callout(iflog.Id, rprIds); |
| | | // 20220902 ljh XLIU-CHSD8G update start |
| | | // NFM103Controller.callout(iflog.Id, rprIds); |
| | | String uid = UserInfo.getUserId(); |
| | | String BUid = System.Label.Batch_User_Id; |
| | | String OLYid = System.Label.OlympusSystem_ID; |
| | | System.debug('zheli'); |
| | | if (uid.substring(0,15) == BUid.substring(0,15) || uid.substring(0,15) == OLYid.substring(0,15)) { |
| | | NFM103Controller.calloutNotfuture(iflog.Id, rprIds); |
| | | }else{ |
| | | NFM103Controller.callout(iflog.Id, rprIds); |
| | | } |
| | | // 20220902 ljh XLIU-CHSD8G update end |
| | | } |
| | | System.debug('-----NFM103Trigger end'); |
| | | } |
| | |
| | | */ |
| | | @future (callout = true) |
| | | public static void callout(String iflog_Id, List<Id> repairIds) { |
| | | |
| | | calloutNotfuture(iflog_Id, repairIds); |
| | | } |
| | | //20220902 ljh 新增(复制)方法 XLIU-CHSD8G |
| | | public static void calloutNotfuture(String iflog_Id, List<Id> repairIds) { |
| | | |
| | | if (repairIds == null || repairIds.size() == 0) { |
| | | return; |
| | |
| | | //20220330 lt WLIG-CCT9UG 【委托】关于市场多年保计提金调整 start |
| | | ,Delivered_Product__r.Backorder__r.Opportunity__r.SAP_Send_OK_Date__c |
| | | //20220330 lt WLIG-CCT9UG 【委托】关于市场多年保计提金调整 end |
| | | //XLIU-CEX8A6 中文标签导入-SFDC传输型号修改(优先对应) 20220602 LY Start |
| | | ,Delivered_Product__r.Product2.Chinese_Labels__c |
| | | //XLIU-CEX8A6 中文标签导入-SFDC传输型号修改(优先对应) 20220602 LY End |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 start |
| | | ,Bollow_Date__c //备品中心出库日 |
| | | ,if_Rental_Apply__c //是否申请备品 |
| | | ,Offer_Rental_New__c //是否提供备品(NEW) |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 end |
| | | //URF限次合同2期 xxf 20220811 start |
| | | ,Delivered_Product__r.Product2.ProductURF__c |
| | | ,Delivered_Product__r.Product2.ProductURF__r.URFLimitSerial__c |
| | | ,URF_Reapir__c |
| | | ,Maintenance_Contract__r.URF_Contract__c |
| | | //URF限次合同2期 xxf 20220811 end |
| | | //DB202211397391“维保预判”和“维保项目”新增方案 fy start |
| | | ,MAINITIAL__c |
| | | //DB202211397391“维保预判”和“维保项目”新增方案 fy end |
| | | // 上限合同 by20230104 start |
| | | ,Maintenance_Contract__r.Limit_Price_Amount__c |
| | | ,Maintenance_Contract__r.Sum_repair_price_new__c |
| | | ,Repair_Quotation_Id__r.Usage_Ratio_Price__c |
| | | ,Maintenance_Contract__r.Remaining_Amount__c |
| | | ,Maintenance_Contract__r.Limit_Price__c |
| | | ,ZFLAG_CGSX__c |
| | | ,ZFLAG_SX__c |
| | | // 上限合同 by20230104 end |
| | | from Repair__c where Id IN :repairIds]; // 削除データを検索しないはず、All ROWS いらないはず |
| | | System.debug(Logginglevel.DEBUG, 'NFM103_ recptList.size()=' + recptList.size()); |
| | | |
| | |
| | | element.DepartmentNo = rpr.Account__r.Management_Code__c; |
| | | element.SAPAgentNo = rpr.Dealer__r.Management_Code__c; |
| | | element.RepairOTCode = rpr.Delivered_Product__r.Product2.ProductCode; |
| | | |
| | | //LJPH-C7Z8AP LY Start |
| | | element.RepairModel = rpr.Delivered_Product__r.Product2.Asset_Model_No__c; |
| | | // LJPH-C9SB9C LHJ 特殊对应 Start |
| | | //element.RepairModel = rpr.Delivered_Product__r.Product2.Asset_Model_No__c; |
| | | //LJPH-C9SB9C LHJ 特殊对应 Start |
| | | //XLIU-CEX8A6 中文标签导入-SFDC传输型号修改(优先对应) 20220602 LY Start |
| | | if (String.isBlank(rpr.Delivered_Product__r.Product2.Chinese_Labels__c)) { |
| | | element.RepairModel = rpr.Delivered_Product__r.Product2.Asset_Model_No__c; |
| | | } else { |
| | | element.RepairModel = rpr.Delivered_Product__r.Product2.Chinese_Labels__c; |
| | | } |
| | | //XLIU-CEX8A6 中文标签导入-SFDC传输型号修改(优先对应) 20220602 LY End |
| | | if (element.RepairModel == 'G400') { |
| | | element.RepairModel = '777000'; |
| | | } else if (element.RepairModel == 'EU-ME2(KEYBOARD)') { |
| | |
| | | element.TradeType = NFMUtil.getMapValue(transferMap, 'Trade__c', rpr.Delivered_Product__r.Backorder__r.Opportunity__r.Trade__c, iflog); |
| | | |
| | | //20220330 lt WLIG-CCT9UG 【委托】关于市场多年保计提金调整 start |
| | | element.QuotationDate = NFMUtil.formatDateTime2StrSprit2(rpr.Delivered_Product__r.Backorder__r.Opportunity__r.SAP_Send_OK_Date__c).replaceAll('/', ''); |
| | | element.QuotationDate = rpr.Delivered_Product__r.SerMarGuranteeType__c != '市场多年保修' ? '' : NFMUtil.formatDateTime2StrSprit2(rpr.Delivered_Product__r.Backorder__r.Opportunity__r.SAP_Send_OK_Date__c).replaceAll('/', ''); |
| | | //20220330 lt WLIG-CCT9UG 【委托】关于市场多年保计提金调整 end |
| | | |
| | | // 多年保修 LHJ Start |
| | |
| | | element.RecordPersonEmail = rpr.CreatedBy.Email; |
| | | element.RepairContractObject = ''; |
| | | element.RepairContractNumber = ''; |
| | | // 上限合同 by20230201 LY start |
| | | element.ZFLAG_SX = ''; |
| | | element.ZFLAG_CGSX = ''; |
| | | // 上限合同 by20230201 LY end |
| | | /*// Gzw 20201216 NFM103传SAP的时候,需要传FSE修理申请时的维修合同信息 start |
| | | // if (rpr.Maintenance_Contract__c != null && rpr.Maintenance_Contract__r.Status__c == '契約') { |
| | | if (rpr.Maintenance_Contract__c != null && rpr.FSE_ApplyForRepair_Day__c != null |
| | |
| | | // 维修合同 |
| | | if (rpr.Maintenance_Contract__c != null && rpr.FSE_ApplyForRepair_Day__c != null |
| | | && rpr.FSE_ApplyForRepair_Day__c >= rpr.Contract_Start_Date__c && rpr.FSE_ApplyForRepair_Day__c <= rpr.Contract_End_Date__c) { |
| | | element.RepairContractObject = 'X'; |
| | | element.RepairContractNumber = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c; |
| | | // 上限合同 by20230201 LY start 如果是上限合同才去判断是否“超过合同上限”和“到达上限”标识 |
| | | if (rpr.Maintenance_Contract__r.Limit_Price__c == true){ |
| | | |
| | | if (rpr.ZFLAG_CGSX__c == true) { // “超过合同上限”为true,不传合同信息,ZFLAG_CGSX传Y |
| | | element.ZFLAG_CGSX = 'X'; |
| | | }else if (rpr.ZFLAG_SX__c == true) { //“到达上限”为true,传合同信息,ZFLAG_SX传Y |
| | | element.ZFLAG_SX = 'X'; |
| | | element.RepairContractObject = 'X'; |
| | | element.RepairContractNumber = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c; |
| | | }else { //没超过合同上限也没达到上限 传合同信息 ZFLAG_CGSX传空 ZFLAG_SX传空 |
| | | element.RepairContractObject = 'X'; |
| | | element.RepairContractNumber = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c; |
| | | } |
| | | }else { //不是上限合同 传合同信息 |
| | | element.RepairContractObject = 'X'; |
| | | element.RepairContractNumber = rpr.Maintenance_Contract__r.Maintenance_Contract_No__c; |
| | | } |
| | | // 上限合同 by20230201 LY end |
| | | |
| | | } else { |
| | | if (!String.isBlank(tradeType) && tradeType.equals('外貿')) { |
| | | // 多年保外贸服务多年保 (生成虚拟维修合同号) 和 多年保外贸市场多年保 (生成虚拟维修合同号) |
| | |
| | | //add pi 密文 sushanhu 20220222 start |
| | | element.DataId =rpr.AWS_Data_Id__c;//aws存储凭证 |
| | | //add pi 密文 sushanhu 20220222 end |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 start |
| | | element.BollowDate =NFMUtil.formatDate2Str(rpr.Bollow_Date__c); //备品中心出库日 |
| | | element.IfRentalApply =rpr.if_Rental_Apply__c ? 'X':''; //是否申请备品 |
| | | element.OfferRental =rpr.Offer_Rental_New__c ? 'X':''; //是否提供备品(NEW) |
| | | //XLIU-CGAD3Z 【委托】备品相关字段传输至SAP LY 20220714 end |
| | | //DB202211397391“维保预判”和“维保项目”新增方案 fy start |
| | | element.MAINITIAL =rpr.MAINITIAL__c ? 'X':''; |
| | | //DB202211397391“维保预判”和“维保项目”新增方案 fy end |
| | | //URF限次合同2期 xxf 20220811 start |
| | | if (!String.isBlank(rpr.Maintenance_Contract__c)){ |
| | | if (rpr.Maintenance_Contract__r.URF_Contract__c == true && rpr.Delivered_Product__r.Product2.ProductURF__c !=null) { |
| | | element.Series =rpr.Delivered_Product__r.Product2.ProductURF__r.URFLimitSerial__c =='URF-P'?'P':'V'; //限次合同系列 |
| | | }else{ |
| | | element.Series =null; |
| | | } |
| | | } |
| | | |
| | | //URF限次合同2期 xxf 20220811 end |
| | | rprId = rpr.Id; //2022-07-14 zyh add |
| | | |
| | | //再注册分析 需求 新增字段 20220811 sx start |
| | | element.Reanalysis = null; |
| | | //再注册分析 需求 新增字段 20220811 sx end |
| | | } |
| | | |
| | | if (repairRequest.GeneralData.size() > 0) { |
| | |
| | | // NFM103修改Rest end |
| | | execute(rowData, iflog); |
| | | } |
| | | logstr += '\nStatus:' + status; |
| | | logstr += '\nStatus:' + status ; |
| | | // WLIG-BXQBH6 start 保存回复内容 |
| | | logstr += '\nResponse:' + responseBody; |
| | | System.debug('SAPRepairNo2:' + SAPRepairNo); |
| | | if(string.isNotEmpty(SAPRepairNo)){ |
| | | System.debug('SAPRepairNo3:' + SAPRepairNo); |
| | | Repair__c rpr = new repair__c(id = repairIds[0], SAPRepairNo__c = SAPRepairNo); |
| | | System.debug('rpr1:' + rpr); |
| | | update rpr; |
| | | } |
| | | // WLIG-BXQBH6 end 保存回复内容 |
| | | //备品相关字段传输至SAP LY 20220908 start |
| | | List <Repair__c> rprflag = new List <Repair__c>(); |
| | | for (Id idflag :repairIds){ |
| | | Repair__c rprnew = new repair__c(); |
| | | rprnew.id = idflag; |
| | | rprnew.Address_type__c = ''; |
| | | rprflag.add(rprnew); |
| | | } |
| | | update rprflag; |
| | | //备品相关字段传输至SAP LY 20220908 end |
| | | logstr += '\nend'; |
| | | } catch (Exception ex) { |
| | | // エラーが発生した場合 |
| | |
| | | logstr = iflog.Log__c; |
| | | } |
| | | try { |
| | | // if (rowData.retry_cnt__c >= 1) { |
| | | // }else { |
| | | // List<BatchIF_Log__c> logList = [Select Id, Name, Log__c, ErrorLog__c from BatchIF_Log__c where Id = :rowData.Id]; |
| | | // BatchIF_Log__c log1 = logList[9]; |
| | | // } //2022-07-18 zyh 注释 |
| | | // NFM103修改Rest start |
| | | // Nfm103Sync.HTTPS_Port stub = new Nfm103Sync.HTTPS_Port(); |
| | | // stub.timeout_x = 100000; // timeout in milliseconds |
| | |
| | | // NFMUtil.response response = |
| | | // NFMUtil.sendToSapStatusAndBody(rowDataStr, NFMUtil.NFM103_ENDPOINT); |
| | | //update to aws 20220222 sushanhu start for PIPL |
| | | PIHelper.PIIntegration NFM103AWS =PIHelper.getPIIntegrationInfo('NFM103'); |
| | | NFMUtil.response response = NFMUtil.sendToPiAWS(rowDataStr, NFM103AWS.newUrl,NFM103AWS.token); |
| | | PIHelper.PIIntegration NFM103AWS =PIHelper.getPIIntegrationInfo('NFM103'); |
| | | NFMUtil.response response = NFMUtil.sendToPiAWS(rowDataStr, NFM103AWS.newUrl,NFM103AWS.token); |
| | | //update to aws 20220222 sushanhu end for PIPL |
| | | status = response.status; |
| | | system.debug('AWS Response status:'+status); |
| | |
| | | NFM103Response = |
| | | (NFM103Response) JSON.deserializeStrict(ResponseBody, NFM103Response.class); |
| | | } |
| | | System.debug('NFM103Response.SAPRepairNo:' + NFM103Response.response[0].LOG.SAPRepairNo); |
| | | if (NFM103Response.response != null && |
| | | NFM103Response.response.size() > 0 && |
| | | NFM103Response.response[0].LOG != null && |
| | |
| | | SAPRepairNo = NFM103Response.response[0].LOG.SAPRepairNo; |
| | | |
| | | } |
| | | System.debug('SAPRepairNo1===:' + SAPRepairNo); |
| | | //2022-07-14 zyh add start |
| | | // if (rowData.retry_cnt__c != 2) { |
| | | // String srn = NFM103Response.Response[9].LOG.SAPRepairNo; |
| | | // } |
| | | String repairNo1 = nfm103.RepairRequest.GeneralData[0].SFDCRepairNo; |
| | | System.debug('repairNo1--------------------1:' + repairNo1); |
| | | |
| | | List<Repair__c> repairList = [SELECT Id From Repair__c Where Name = :repairNo1]; |
| | | if(string.isNotEmpty(SAPRepairNo)){ |
| | | System.debug('SAPRepairNo3-1:' + SAPRepairNo); |
| | | System.debug('rprId--------------------1:' + rprId); |
| | | Repair__c rpr = new repair__c(id = repairList[0].Id, SAPRepairNo__c = SAPRepairNo); |
| | | System.debug('rpr1-1:' + rpr); |
| | | update rpr; |
| | | } |
| | | //2022-07-14 zyh add end |
| | | rowData.retry_cnt__c = 0; |
| | | //add wangweipeng 2022/02/18 start |
| | | //如果为true,证明是重新发送的接口,需要把日志记录下 |
| | |
| | | // エラーが発生した場合 |
| | | System.debug(Logginglevel.ERROR, 'NFM103_' + iflog.Name + ':' + ex.getMessage()); |
| | | System.debug(Logginglevel.ERROR, 'NFM103_' + iflog.Name + ':' + ex.getStackTraceString()); |
| | | logstr += ex.getMessage(); |
| | | iflog.ErrorLog__c += ex.getMessage() + '\n'; |
| | | iflog.ErrorLog__c += ex.getStackTraceString() + '\n'; |
| | | //NFM105触发103接口 20230303 LY start |
| | | // Callout from triggers are currently not supported. |
| | | System.debug('NFM201jiekou'+ex.getMessage()); |
| | | if (!String.valueOf(ex.getMessage()).contains('Callout from triggers')) { |
| | | |
| | | logstr += ex.getMessage(); |
| | | iflog.ErrorLog__c += ex.getMessage() + '\n'; |
| | | iflog.ErrorLog__c += ex.getStackTraceString() + '\n'; |
| | | } |
| | | System.debug('标记0--------------------1:' + rowData.retry_cnt__c); |
| | | |
| | | //NFM105触发103接口 20230303 LY end |
| | | //---Gaozw---add |
| | | if (rowData.retry_cnt__c == null) rowData.retry_cnt__c = 0; |
| | | if (rowData.retry_cnt__c < batch_retry_max_cnt) { |