| | |
| | | public Boolean saveBtnDisabled { get; private set; } |
| | | public boolean ReturnRefuse {get;private set;} |
| | | public String ErrorMessage {get; set;} |
| | | public String CDSFinished {get;set;} |
| | | public boolean LostFlg {get;set;} |
| | | // public String CDSFinished {get;set;} |
| | | // public boolean LostFlg {get;set;} |
| | | public String Step_status { get; private set; } |
| | | public Boolean needCDS { get; private set; } |
| | | public Boolean done_flg { get; set; } |
| | |
| | | |
| | | // 保存按钮 |
| | | public PageReference save() { |
| | | // 备品优化临时验证追加 20230409 lc Start |
| | | /*StaticParameter.EscapeVMCTrigger = true; |
| | | Oly_TriggerHandler.bypass('AssetHandler');*/ |
| | | // 备品优化临时验证追加 20230409 lc End |
| | | |
| | | List<String> raids = Raid.split(':'); |
| | | //检查是否可以继续 |
| | | List<Rental_Apply__c> RaTarList = [select Name,Campaign__c,Repair__c,next_action__c,QIS_number__r.ReplaceDeliveryDate__c,demo_purpose2__c,Follow_UP_Opp__r.Shipping_Finished_Day_Func__c, |
| | | Campaign__r.Status,repair__r.Return_Without_Repair_Date__c,Repair__r.Repair_Final_Inspection_Date__c,Repair__r.Repair_Shipped_Date__c |
| | | List<Rental_Apply__c> RaTarList = [select Id,Name,Campaign__c,Repair__c,next_action__c |
| | | ,QIS_number__r.ReplaceDeliveryDate__c,demo_purpose2__c |
| | | ,Follow_UP_Opp__r.Shipping_Finished_Day_Func__c |
| | | ,Campaign__r.Status |
| | | ,Campaign__r.IF_Approved__c |
| | | ,Campaign__r.Meeting_Approved_No__c // 20220315 ljh obpm备品决裁状态相关修改 |
| | | ,Campaign__r.Approved_Status__c // 20220315 ljh obpm备品决裁状态相关修改 |
| | | ,repair__r.Return_Without_Repair_Date__c |
| | | ,Repair__r.Repair_Final_Inspection_Date__c |
| | | ,AccDealerBlacklist__c//贸易合规 you |
| | | ,EquipmentGuaranteeFlg__c//贸易合规 you |
| | | ,Repair__r.Repair_Shipped_Date__c |
| | | from Rental_Apply__c |
| | | where id in :raids];//20210602 ljh update 增加查询Name SFDC-C3LBNL |
| | | |
| | | // add lc 20220927 SFDC-CJ48VE 备品预计出库日逻辑调整 start |
| | | Map<Id, String> rentalApplyNameMap = new Map<Id, String>(); |
| | | List<Rental_Apply_Equipment_Set__c> RAESRecords = [ |
| | | SELECT Id,Rental_Apply__c,Rental_Apply__r.Name |
| | | FROM Rental_Apply_Equipment_Set__c |
| | | WHERE Rental_Apply__c in :raids |
| | | AND Cancel_Select__c = False |
| | | AND Rental_Start_Date__c <> :Date.today() |
| | | ORDER BY Rental_Apply__c]; |
| | | |
| | | for (Rental_Apply_Equipment_Set__c RAES : RAESRecords) { |
| | | if (rentalApplyNameMap.isEmpty() || !rentalApplyNameMap.containsKey(RAES.Rental_Apply__c)) { |
| | | rentalApplyNameMap.put(RAES.Rental_Apply__c, RAES.Rental_Apply__r.Name); |
| | | } |
| | | } |
| | | // add lc 20220927 SFDC-CJ48VE 备品预计出库日逻辑调整 end |
| | | |
| | | //20210604 ljh update SFDC-C3LBNL start |
| | | Boolean errorFlag = false; |
| | | String message0 = ''; |
| | |
| | | String message = ''; |
| | | String message4 = '';//1822 yc 20211025 已购待货目的,新品已有发货日不能出库 |
| | | String message5 = '';//1822 yc 20211108 索赔QIS目的,QIS已有新品发货日不能出库 |
| | | String message6 = ''; |
| | | String message7 = '';// 20220315 ljh obpm备品决裁状态相关修改 end |
| | | String message8 = '';//add lc 20220927 SFDC-CJ48VE 备品预计出库日逻辑调整 |
| | | String message9 = '';//贸易合规 you |
| | | // 要判断决裁状态不能是草稿/驳回/终止申请/取消/删除 |
| | | List<String> statusList = System.Label.StatusProcessState.split(','); |
| | | Map<Id, Rental_Apply__c> RaMap = new Map<Id, Rental_Apply__c>(); |
| | | for (Rental_Apply__c RaTar : RaTarList) { |
| | | if( RaTar.Campaign__r.Status == '取消'){ |
| | | |
| | | // 20230215 ljh DB202301265636 学会取消申请也拦截 start |
| | | // if( RaTar.Campaign__r.Status == '取消'){ |
| | | //贸易合规 you |
| | | if(System.Label.TradeComplianceStatusFlagBP =='true' && RaTar.AccDealerBlacklist__c == '1' && RaTar.EquipmentGuaranteeFlg__c==false){ |
| | | errorFlag = true; |
| | | message9 += RaTar.Name+'、'; |
| | | }else if( RaTar.Campaign__r.Status == '取消' || RaTar.Campaign__r.Status == '取消申请中'){ |
| | | // 20230215 ljh DB202301265636 学会取消申请也拦截 end |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '学会已取消,不能继续操作了')); |
| | | // return null; |
| | | errorFlag = true; |
| | |
| | | }else if(RaTar.demo_purpose2__c=='索赔QIS' && RaTar.next_action__c=='无偿更换' && RaTar.QIS_number__r.ReplaceDeliveryDate__c!= null){ |
| | | errorFlag = true; |
| | | message5 += RaTar.Name+'、'; |
| | | } |
| | | } |
| | | //1822 yc 20211025 已购待货目的,新品已有发货日不能出库 end |
| | | // 20220315 ljh obpm备品决裁状态相关修改 start |
| | | // else if (!campMap.isEmpty() && campMap.containsKey(RaTar.Campaign__c) && campMap.get(RaTar.Campaign__c).IF_Approved__c){ |
| | | // if (String.isBlank(campMap.get(RaTar.Campaign__c).Meeting_Approved_No__c) |
| | | // || String.isBlank(campMap.get(RaTar.Campaign__c).Meeting_Approved_No__r.MeetingApprovedNo__c)) { |
| | | // errorFlag = true; |
| | | // message6 = RaTar.Name + '、'; |
| | | // } |
| | | // } |
| | | else if(RaTar.Campaign__c!= null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c == null) { |
| | | errorFlag = true; |
| | | message6 += RaTar.Name + '、'; |
| | | } |
| | | else if(RaTar.Campaign__c!= null && RaTar.Campaign__r.IF_Approved__c && RaTar.Campaign__r.Meeting_Approved_No__c != null && statusList.contains(RaTar.Campaign__r.Approved_Status__c)) { |
| | | errorFlag = true; |
| | | message7 += RaTar.Name + '、'; |
| | | } |
| | | // 20220315 ljh obpm备品决裁状态相关修改 end |
| | | //20220217 sx add 备品借出申请-决裁控制 No.3 在出库时增加判断,判断学会是否申请决裁,如果是的话,再判断决裁编号是否不为空,满足条件才能出库,否则提示错误 |
| | | } |
| | | |
| | | // add lc 20220927 SFDC-CJ48VE 备品预计出库日逻辑调整 start |
| | | if (!rentalApplyNameMap.isEmpty()) { |
| | | errorFlag = true; |
| | | for (String rentalApplyKey : rentalApplyNameMap.keySet()) { |
| | | message8 += rentalApplyNameMap.get(rentalApplyKey) + '、'; |
| | | } |
| | | } |
| | | // add lc 20220927 SFDC-CJ48VE 备品预计出库日逻辑调整 end |
| | | |
| | | if(errorFlag){ |
| | | if(String.isNotBlank(message0)){ |
| | | message += '单号NO.'+message0.removeEnd('、')+'学会已取消,不能继续操作了'; |
| | | // 20230215 ljh DB202301265636 学会取消申请也拦截 start |
| | | // message += '单号NO.'+message0.removeEnd('、')+'学会已取消,不能继续操作了'; |
| | | message += '单号NO.'+message0.removeEnd('、')+'学会已取消或者取消申请中,不能继续操作了'; |
| | | // 20230215 ljh DB202301265636 学会取消申请也拦截 start |
| | | } |
| | | if(String.isNotBlank(message1)){ |
| | | message += '单号NO.'+message1.removeEnd('、')+'存在修理最终检测日,不能继续了'; |
| | |
| | | message += '单号NO.'+message5.removeEnd('、')+'索赔QIS目的,QIS已有新品发货日,不能继续了'; |
| | | } |
| | | //1822 yc 20211025 已购待货目的,新品已有发货日不能出库 end |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,message)); |
| | | if(String.isNotBlank(message6)){ |
| | | message += '单号No.'+ message6.removeEnd('、')+ '已申请决裁但决裁编码为空'; |
| | | } |
| | | // 20220315 ljh obpm备品决裁状态相关修改 add start |
| | | if(String.isNotBlank(message7)){ |
| | | message += '单号No.'+ message7.removeEnd('、')+ '已申请决裁但决裁状态不符合条件'; |
| | | } |
| | | // 20220315 ljh obpm备品决裁状态相关修改 add end |
| | | |
| | | // add lc 20220927 SFDC-CJ48VE 备品预计出库日逻辑调整 start |
| | | if(String.isNotBlank(message8)){ |
| | | message += '单号No.'+ message8.removeEnd('、')+ '的备品预计出货日应该等于今天,否则不能发货'; |
| | | } |
| | | // add lc 20220927 SFDC-CJ48VE 备品预计出库日逻辑调整 end |
| | | |
| | | if(String.isNotBlank(message9)){ |
| | | message += '单号No.'+ message9.removeEnd('、')+ System.Label.IFTradeComplianceAlertBP; |
| | | } |
| | | |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,message)); |
| | | return null; |
| | | } |
| | | //20210604 ljh update SFDC-C3LBNL end |
| | |
| | | Asset__r.Remark__c, Asset__r.ImageAsset__c, Asset__r.ImageSerial__c, Asset__r.ImageAssetUploadedTime__c, Asset__r.ImageSerialUploadedTime__c, |
| | | Loaner_CDS_Info__c, Inspection_result__c, Check_lost_Item__c, Pre_disinfection__c, Water_leacage_check__c, Inspection_result_after__c, Arrival_in_wh__c, |
| | | Asset__r.Pre_Reserve_RAES_Detail__c, Asset__r.Pre_Reserve_RAES_Detail__r.After_Inspection_time__c, |
| | | Rental_Apply__r.Request_approval_time__c , Add_Request_approval_time__c ,ApplyToShipmentWorkTime__c, //20220309 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 |
| | | Inspection_result_after_ng__c, Inspection_result_ng__c, Lost_item_giveup__c, CDS_complete__c, Loaner_accsessary__c,Key_product__c |
| | | from Rental_Apply_Equipment_Set_Detail__c where Id in :eSet for update]; |
| | | Boolean needSaveSet = false; |
| | |
| | | Map<String,boolean> keyPointProduct = new Map<String,boolean>(); |
| | | //wangweipeng 是否是重点产品 2021/08/30 end |
| | | Set<Id> astForLock = new Set<Id>(); |
| | | Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>> approvalMap = new Map<Datetime, List<Rental_Apply_Equipment_Set_Detail__c>>();// 20220315 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 |
| | | for (Rental_Apply_Equipment_Set_Detail__c esd : eList) { |
| | | if (esd.Inspection_result__c <> null && esd.StockDown__c == false) { |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, '备品set未下架,不能填写发货前检查结果')); |
| | |
| | | } |
| | | //wangweipeng 是否是重点产品 2021/08/30 end |
| | | astForLock.add(esd.Asset__c); |
| | | // 20220315 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 start |
| | | Datetime keyDt = esd.Add_Request_approval_time__c != null?esd.Add_Request_approval_time__c:esd.Rental_Apply__r.Request_approval_time__c; |
| | | List<Rental_Apply_Equipment_Set_Detail__c> tempRaesdL; |
| | | if(approvalMap.containsKey(keyDt)){ |
| | | tempRaesdL = approvalMap.get(keyDt); |
| | | }else{ |
| | | tempRaesdL = new List<Rental_Apply_Equipment_Set_Detail__c>(); |
| | | } |
| | | tempRaesdL.add(esd); |
| | | approvalMap.put(keyDt,tempRaesdL); |
| | | // 20220315 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 end |
| | | } |
| | | List<Asset> astLock = [select Id |
| | | from Asset |
| | | where id in :astForLock |
| | | for update]; |
| | | |
| | | if (Step_status == '明细') { |
| | | needDeliverySlip = true; |
| | | //if (slip.Id == null) { |
| | |
| | | slip.Shippment_loaner_time__c = Datetime.now(); |
| | | needSaveDetail = true; |
| | | } |
| | | List<Rental_Apply__c> raList = [select Id, DeliverySlip__c from Rental_Apply__c where Id in :raSet]; |
| | | List<Rental_Apply__c> raList = [select Id, DeliverySlip__c, Campaign__c |
| | | , Campaign__r.IF_Approved__c // 20220315 ljh obpm备品决裁状态相关修改 |
| | | , Campaign__r.Meeting_Approved_No__r.Name // 20220315 ljh obpm备品决裁状态相关修改 |
| | | , Campaign__r.Approved_Status__c // 20220315 ljh obpm备品决裁状态相关修改 |
| | | , Hospital__r.TradeComplianceStatus__c//贸易合规 you |
| | | //, Outbound_TradeStatus__c//贸易合规 you |
| | | from Rental_Apply__c where Id in :raSet]; |
| | | Savepoint sp = Database.setSavepoint(); |
| | | try { |
| | | //if (needSaveSet) ControllerUtil.upRAdEquipmentSet(es); |
| | | if (needDeliverySlip) { |
| | | FixtureUtil.withoutUpsertObjects(new List<FixtureDeliverySlip__c>{ slip }); |
| | | //ControllerUtil.updRADeliverySlipDetail(slip); |
| | | // 20220315 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 start |
| | | map<String,Decimal> ApplyToShipmentMap = new map<String,Decimal>(); |
| | | if(approvalMap.size() > 0 ){ |
| | | // dtList[0] 第一个就是最小时间 |
| | | List<Datetime> dtList = new List<Datetime>(approvalMap.keySet()); |
| | | Date startDateSOQL = date.newinstance(dtList[0].year(), dtList[0].month(), dtList[0].day()); |
| | | List<OlympusCalendar__c> ocList = [SELECT Id, Date__c,IsWorkDay__c |
| | | FROM OlympusCalendar__c |
| | | WHERE Date__c >= :startDateSOQL |
| | | AND Date__c <= :Date.today() |
| | | ORDER BY Date__c ASC]; |
| | | Map<Date,String> ocMap = new Map<Date,String>(); |
| | | for(OlympusCalendar__c oc:ocList){ |
| | | String IsWorkDay = oc.IsWorkDay__c.format(); |
| | | ocMap.put(oc.Date__c,IsWorkDay); |
| | | } |
| | | for(Datetime dt:dtList){ |
| | | Boolean startFlag = false; |
| | | Boolean endFlag = false; |
| | | Datetime startTime = dt; |
| | | Date startDate = Date.newInstance(startTime.year(),startTime.month(),startTime.day()); |
| | | Datetime endTime = Datetime.now(); |
| | | Date endDate = Date.today(); |
| | | // 审批时间是非奥林巴斯工作日 |
| | | // if(ocList[0].IsWorkDay__c == 0){ |
| | | if(ocMap.get(startDate) == '0'){ |
| | | for(OlympusCalendar__c oc:ocList){ |
| | | if(startDate < oc.Date__c && oc.IsWorkDay__c == 1){ |
| | | startTime = Datetime.newInstance(oc.Date__c.year(),oc.Date__c.month(),oc.Date__c.day(),0,0,0); |
| | | startDate = oc.Date__c; |
| | | startFlag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // 发货时间是非奥林巴斯工作日 |
| | | if(ocList[ocList.size() - 1].IsWorkDay__c == 0){ |
| | | for(Integer i = ocList.size() - 1; i >= 0;i--){ |
| | | if(ocList[i].IsWorkDay__c == 1){ |
| | | endTime = Datetime.newInstance(ocList[i].Date__c.addDays(1).year(),ocList[i].Date__c.addDays(1).month(),ocList[i].Date__c.addDays(1).day(),0,0,0); |
| | | endDate = ocList[i].Date__c.addDays(1); |
| | | endFlag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | Decimal timeDifLast; |
| | | if(ocList[0].IsWorkDay__c == 0 && ocList[ocList.size() - 1].IsWorkDay__c == 0 && !startFlag && !endFlag){ |
| | | timeDifLast = 0; |
| | | }else{ |
| | | Long startL = startTime.getTime(); |
| | | Long tendL = endTime.getTime(); |
| | | Long timeDif = tendL - startL; |
| | | Decimal time11 = timeDif*1.00; |
| | | Decimal time12 = 24*3600*1000*1.00; |
| | | timeDifLast = time11/time12; |
| | | Integer tempWeek = 0; |
| | | for(OlympusCalendar__c oc:ocList){ |
| | | if(oc.IsWorkDay__c == 0 && startDate < oc.Date__c && oc.Date__c < endDate){ |
| | | tempWeek++; |
| | | } |
| | | } |
| | | timeDifLast = timeDifLast - tempWeek; |
| | | } |
| | | // dtestLast 四舍五入 保留1位小数 |
| | | for(Rental_Apply_Equipment_Set_Detail__c raesd00:approvalMap.get(dt)){ |
| | | ApplyToShipmentMap.put(raesd00.Id,timeDifLast.setScale(1)); |
| | | } |
| | | } |
| | | } |
| | | // 20220315 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 end |
| | | for (Rental_Apply_Equipment_Set_Detail__c esd : eList) { |
| | | esd.DeliverySlip__c = slip.Id; |
| | | // 20220315 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 start |
| | | if(ApplyToShipmentMap.containsKey(esd.Id)){ |
| | | esd.ApplyToShipmentWorkTime__c = ApplyToShipmentMap.get(esd.Id); |
| | | } |
| | | // 20220315 ljh SFDC-CC6CLJ phase5上线课题131 提交申请到备品出库时长 end |
| | | } |
| | | |
| | | for (Rental_Apply__c ra : raList) { |
| | |
| | | //wangweipeng 是否是重点产品 2021/08/30 start |
| | | ra.Is_keyPoint_Product__c = keyPointProduct.get(ra.Id); |
| | | //wangweipeng 是否是重点产品 2021/08/30 start |
| | | //ra.Outbound_TradeStatus__c = ra.Hospital__r.TradeComplianceStatus__c;//贸易合规 you |
| | | // 20220315 ljh obpm备品决裁状态相关修改 update start |
| | | //20220217 sx add 备品借出申请-决裁控制 No.4 出库成功时,把此时点的决裁编号和决裁状态写到决裁编号(出库)和决裁状态(出库)上 |
| | | // if (!campMap.isEmpty() && campMap.containsKey(ra.Campaign__c) && campMap.get(ra.Campaign__c).IF_Approved__c){ |
| | | // ra.ApprovedNo_Delivery__c = campMap.get(ra.Campaign__c).Meeting_Approved_No__r.MeetingApprovedNo__c; |
| | | // ra.Approved_State_Delivery__c = campMap.get(ra.Campaign__c).Meeting_Approved_No__r.ProcessState__c; |
| | | // } |
| | | if (ra.Campaign__c != null&& ra.Campaign__r.IF_Approved__c && ra.Campaign__r.Meeting_Approved_No__r.Name != null){ |
| | | ra.ApprovedNo_Delivery__c = ra.Campaign__r.Meeting_Approved_No__r.Name; |
| | | ra.Approved_State_Delivery__c = ra.Campaign__r.Approved_Status__c; |
| | | } |
| | | // 20220315 ljh obpm备品决裁状态相关修改 update end |
| | | } |
| | | } |
| | | //if (needSaveDetail) ControllerUtil.updRAEquipmentSetDetail(eList); |
| | |
| | | return null; |
| | | } catch (Exception ex) { |
| | | system.debug('=====' + ex.getMessage()); |
| | | ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getMessage()+'( '+Step_status+' )')); |
| | | // ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ex.getDmlMessage(0))); |
| | | ApexPages.addMessages(ex); |
| | | Database.rollback(sp); |
| | | done_flg = false; |
| | | return null; |