/**
*  2021-05-19 mzy 
* 页面提醒当前用户招标信息
*/
public with sharing class TenderManageController {
    public TenderManageController() {
        
    }

    //获取当前用户招投标项目信息
    public static TenderInformation getCurrentTenderInformation(){
    	//1.根据当前用户信息进行查找
    	List<Tender_information__c> AllTender =	goSelectByCurrentUser();

    	//2.分组
		   // 1) 待确认的招投标项目
		   List<Tender_information__c> MyTBCTender = new List<Tender_information__c>();
		   // 2) 待关联询价的招投标项目
		   List<Tender_information__c> MyTBRTender = new List<Tender_information__c>();
		   // 3) 待应标的招投标项目
		   List<Tender_information__c> MyTBBTender = new List<Tender_information__c>();
		   // 4) 分组
		   if(AllTender.size()>0){
		   		for(Tender_information__c tempT : AllTender){
		   			//待确认
		   			if( tempT.ViewWaitConfirm__c && '01.待确认'.equals(tempT.status__c)){
		   				MyTBCTender.add(tempT);
		   			}
		   			//待关联询价
		   			if(tempT.ViewRelatedOpp__c && '04.待关联询价'.equals(tempT.status__c)){
		   				MyTBRTender.add(tempT);
		   			}
		   			//待应标 zys 20210709 应标确认 变为 待应标确认
                    //20210716  mzy 添加 ViewBidConfirm__c 判断 排除2s6-2s9的助理的提醒
		   			if(tempT.ViewBidConfirm__c&&'03.是否应标'.equals(tempT.status__c)&&tempT.NotBidApprovalStatus__c != '申请中'){
		   				MyTBBTender.add(tempT);
		   			}
		   		}
		   }

    	//3.封装
    	TenderInformation MyTenderInformation= new TenderInformation(MyTBCTender,MyTBRTender,MyTBBTender);

    	return MyTenderInformation;
    }

    //根据当前用户查找招标项目
    public static List<Tender_information__c> goSelectByCurrentUser(){
    	//定义List封装查询结果
    	List<Tender_information__c> AllTender = new List<Tender_information__c>();
    	//查询
    	String query = 'SELECT id,status__c,NotBidApprovalStatus__c,ViewWaitConfirm__c,ViewRelatedOpp__c,ViewBidConfirm__c ';
    	       query += 'FROM Tender_information__c ';
    	       //待确认 
    	       query += 'WHERE ( status__c = \'01.待确认\' AND  ViewWaitConfirm__c = true ) ';
               //待关联询价 
               query += 'OR ( status__c =\'04.待关联询价\' AND ViewRelatedOpp__c = true ) ';
    	       //待应标 zys 20210709 应标确认 变为 待应标确认
    	       query += 'OR ( status__c = \'03.是否应标\' AND NotBidApprovalStatus__c != \'申请中\'  ) ';
    	
        AllTender = Database.query(query);

    	return AllTender;
    }

 	public class TenderInformation {
 		//待确认的招投标项目 : GI / SP AND 01.待确认
 		public List<Tender_information__c> MyTBCTender;

		//待关联询价的招投标项目 : GI / SP AND 04.确认应标
 		public List<Tender_information__c> MyTBRTender;

 		//待应标的招投标项目 : AccountOwner
 		public List<Tender_information__c> MyTBBTender;

 		public TenderInformation(list<Tender_information__c> MyTBCTender, list<Tender_information__c> MyTBRTender, list<Tender_information__c> MyTBBTender) {
            this.MyTBCTender = MyTBCTender;
            this.MyTBRTender = MyTBRTender;
            this.MyTBBTender = MyTBBTender;
        }
    }		

}