// by ljh
public class ReantalApplySeriesNoController{
	private String raqId{get;set;}
	public Rental_Apply_Sequence__c  raq{get;set;}
	// public List<Raqinfo> raqInfoList { get; set; }
    public List<Rental_Apply_Sequence__c> raqList { get; set; }
    public Boolean Isadmix { get; set; }
    public ReantalApplySeriesNoController(){
        raqId = ApexPages.currentPage().getParameters().get('raqId');
        raq = new Rental_Apply_Sequence__c();
        raqList = new List<Rental_Apply_Sequence__c>();
        Isadmix = false;
    }
    public void init() {
    	// raqInfoList = new List<Raqinfo>();
    	raq = [Select Fixture_Model_No__c,Internal_asset_location__c,Salesdepartment__c,Equipment_Type__c,Product_category__c,Invalid_Flag__c From Rental_Apply_Sequence__c where Id =:raqId and Invalid_Flag__c = false limit 1];
    	// List<Rental_Apply_Sequence__c> 
        raqList = [Select Id,Series_No__c,Invalid_Flag__c,Apply_Set_Detail_ExternalKey__c,
                Apply_Set_Detail__r.Queue_Time_F__c,Apply_Set_Detail__r.Queue_Number__c,Apply_Set_Detail__r.Queue_User__c,
    			Rental_Apply__r.Name,Rental_Apply__r.WorkPlace__c,Rental_Apply__r.Person_In_Charge__c,
                Rental_Apply__r.Request_shipping_day__c,Rental_Apply__r.demo_purpose2__c,
                Rental_Apply__r.Request_approval_time__c,Rental_Apply__r.Hospital__c,
                Rental_Apply__r.Campaign__c
		    	From Rental_Apply_Sequence__c
		        where Invalid_Flag__c = false
		        and  Fixture_Model_No__c =:raq.Fixture_Model_No__c 
		        and  Internal_asset_location__c =:raq.Internal_asset_location__c 
		        and  Salesdepartment__c =:raq.Salesdepartment__c 
		        and  Equipment_Type__c =:raq.Equipment_Type__c 
		        and  Product_category__c =:raq.Product_category__c 
		        order by Series_No__c ASC nulls last];
        // LineNo
        // for (Integer i = 0; i < raqList.size(); i++) {
        //     // 作成明细行
        //     Raqinfo raqinfod = new Raqinfo(raqList[i]);
        //     raqinfod.LineNo = i+1;
        //     raqInfoList.add(raqinfod);
        // }
        String IsadmixStr = '';
        for (Rental_Apply_Sequence__c raq:raqList) {
            if(String.isBlank(IsadmixStr)){
                IsadmixStr = raq.Apply_Set_Detail_ExternalKey__c;
            }else{
                if(String.isBlank(raq.Apply_Set_Detail_ExternalKey__c) || (!String.isBlank(raq.Apply_Set_Detail_ExternalKey__c) && IsadmixStr != raq.Apply_Set_Detail_ExternalKey__c)){
                    //混合
                    Isadmix = true; break;
                }
            } 
        }
    }

    // class Raqinfo  {
    //     public Integer LineNo {get; set;}
    //     public Rental_Apply_Sequence__c raq {get; set;}
    //     public Raqinfo(Rental_Apply_Sequence__c q) {
    //         raq = q;
    //     }
    // }
}