public with sharing class EnquiryDetailsController { public String ESetId{get;set;} public String baseUrl {get;private set;} public Opportunity insOppo{get;set;} /* public String EnquiryName{get;set;} */ public String IndexNum{get;set;} public Event__c ShowEvent{get;set;} public Opportunity showOppOName {get;set;} public boolean goOrNot {get;set;} //*************************Insert 20160627 OCM-225 趙徳芳 Start*************************// private String Old_Competitor {get;set;} //*************************Insert 20160627 OCM-225 趙徳芳 End***************************// public EnquiryDetailsController(){ baseUrl = URL.getSalesforceBaseUrl().toExternalForm(); ESetId = ApexPages.currentPage().getParameters().get('ESetId'); //EnquiryName = ApexPages.currentPage().getParameters().get('idParam'); IndexNum = ApexPages.currentPage().getParameters().get('indexNumber'); } public void init(){ insOppo = new Opportunity(); ShowEvent = new Event__c(); showOppOName = new Opportunity(); //新增Competitor__c字节 //2021-12-10 增加 中标日 招标日 yjk String soql = 'select id,Name,Competitor__c,Opportunity_stage__c,TenderBeginDate__c,Closing_Bid_Date_Bid__c,Application_Amount_Submit__c,Budget_Amount_Approval__c,Bid_Date__c,Close_Forecasted_Date__c,CloseDate,Closing_Bid_Date__c,Department_Name__c,Status_Formula__c,Close_Forecasted_Assume_Date__c from Opportunity where id = :ESetId'; String sql = 'select name , id ,Related_Opportunity'+IndexNum+'__c,Related_Opportunity'+IndexNum+'_ID__c from Event__c where Related_Opportunity'+IndexNum+'_ID__c =:ESetId'; //List showName = Database.query(sql); List OppoName = Database.query(soql); //*************************Insert 20160627 OCM-225 趙徳芳 Start*************************// if(OppoName.size()>0){ Old_Competitor = OppoName[0].Competitor__c; } //*************************Insert 20160627 OCM-225 趙徳芳 End***************************// //if(showName.size()>0){ //ShowEvent = showName[0]; //} if(OppoName.size()>0){ insOppo = OppoName[0]; } } public PageReference save(){ system.debug('测试进入'); Map ApplyMap = new Map(); Map ApproveMap = new Map(); ApplyMap.put('提交了预算申请','提交了预算申请'); ApplyMap.put('预算已经批准','预算已经批准'); ApproveMap.put('预算已经批准','预算已经批准 '); ApplyMap.put('确定了对手参数','确定了对手参数'); ApproveMap.put('确定了对手参数','确定了对手参数 '); ApplyMap.put('没有确定参数','没有确定参数'); ApproveMap.put('没有确定参数','没有确定参数'); ApplyMap.put('确定了OLY参数','确定了OLY参数'); ApproveMap.put('确定了OLY参数','确定了OLY参数'); ApplyMap.put('中标签约','中标签约'); ApproveMap.put('中标签约','中标签约'); //if(insOppo.Close_Forecasted_Date__c == null){ // insOppo.Close_Forecasted_Date__c.addError('预测COM签约日不能为空'); // system.debug('测试进入6'); // goOrNot = false; //} //else if(insOppo.CloseDate==null){ // insOppo.CloseDate.addError('预测发货日不能为空'); // system.debug('测试进入7'); //} //else if(insOppo.Closing_Bid_Date__c >insOppo.Close_Forecasted_Date__c ){ //insOppo.Close_Forecasted_Date__c.addError('预测OCM签约日不允许早于中标日'); //system.debug('测试进入8'); //goOrNot = false; //} //else if(insOppo.Close_Forecasted_Date__c insOppo.CloseDate){ // insOppo.Close_Forecasted_Date__c.addError('预测COM签约日不允许晚于预测发货日'); // system.debug('测试进入9'); // goOrNot = false; //} //else if(insOppo.Bid_Date__c >insOppo.Closing_Bid_Date__c ){ if(insOppo.Bid_Date__c >insOppo.Closing_Bid_Date__c ){ insOppo.Closing_Bid_Date__c.addError('中标日不允许早于招标日'); system.debug('测试进入10'); goOrNot = false; } /*else if(insOppo.CloseDate < Date.today()){ insOppo.CloseDate.addError('预测发货日不允许登录过去日期'); system.debug('测试进入11'); goOrNot = false; }*/ else if(insOppo.Closing_Bid_Date__c >Date.today() ){ insOppo.Closing_Bid_Date__c.addError('中标日不允许登录未来日期'); system.debug('测试进入8'); goOrNot = false; } /* SWAG-B8Y84V 2019-02-11 start 提交申请金额 和 预算批准金额 不再必填 else if(ApplyMap.containsKey(insOppo.Opportunity_stage__c)&& insOppo.Application_Amount_Submit__c ==null){ insOppo.Application_Amount_Submit__c.addError('提交申请金额不能为空'); goOrNot = false; } else if(ApproveMap.containsKey(insOppo.Opportunity_stage__c)&& insOppo.Budget_Amount_Approval__c ==null){ insOppo.Budget_Amount_Approval__c.addError('预算批准金额不能为空'); goOrNot = false; } SWAG-B8Y84V 2019-02-11 start */ //*************************Insert 20160627 OCM-225 趙徳芳 Start*************************// else if((Old_Competitor == 'C'||Old_Competitor == 'A'||Old_Competitor == 'B')&&(insOppo.Competitor__c =='D'||insOppo.Competitor__c =='E')){ insOppo.Opportunity_stage__c.addError('询价等级已达到'+Old_Competitor+',询价等级为C及以上的,不可以修改到D或E'); goOrNot = false; } //*************************Insert 20160627 OCM-225 趙徳芳 End***************************// else if('中标签约'.equals(insOppo.Opportunity_stage__c)&& insOppo.Closing_Bid_Date__c ==null){ insOppo.Closing_Bid_Date__c.addError('中标日不能为空'); goOrNot = false; } else{ try{ Opportunity Oppo = new Opportunity(); Oppo.id = ESetId; Oppo.Opportunity_stage__c = insOppo.Opportunity_stage__c; Oppo.Application_Amount_Submit__c = insOppo.Application_Amount_Submit__c; Oppo.Budget_Amount_Approval__c = insOppo.Budget_Amount_Approval__c; Oppo.Bid_Date__c = insOppo.Bid_Date__c; Oppo.Closing_Bid_Date__c = insOppo.Closing_Bid_Date__c; Oppo.Close_Forecasted_Date__c = insOppo.Close_Forecasted_Date__c; Oppo.Close_Forecasted_Assume_Date__c = insOppo.Close_Forecasted_Assume_Date__c; //Oppo.CloseDate = insOppo.CloseDate; update Oppo; goOrNot = true; //SWAG-B8Y84V 2019-02-11 start ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, '保存完了!')); // SWAG-B8Y84V 2019-02-11 end }catch(DmlException ex) { ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, ' '+ex.getDmlMessage(0))); //SAP上传后,不允许修改「预测OCM签约日」 system.debug('测试进入13:'+ex.getDmlMessage(0)); return null; } system.debug('测试进入12'); } return null; } }