public with sharing class RentalSequenceWatchController { public List rasShowCFList{get;set;} public List rasShowTHList{get;set;} public List raesDShowCFList{get;set;} public List raesDShowTHList{get;set;} public Boolean haveErrCF_X{get;set;} public Boolean haveErrTH_X{get;set;} public Boolean haveErrCF_D{get;set;} public Boolean haveErrTH_D{get;set;} public RentalSequenceWatchController() { haveErrCF_X = false; haveErrTH_X = false; haveErrCF_D = false; haveErrTH_D = false; rasShowCFList = new List(); rasShowTHList = new List(); raesDShowCFList = new List(); raesDShowTHList = new List(); } public void init(){ Map esnMap = new Map(); Map ekeyMap = new Map(); List rasList = [Select Id,ExternalKey_Series_No__c, Series_No__c,ExternalKey__c From Rental_Apply_Sequence__c where Invalid_Flag__c = false order by ExternalKey__c,Series_No__c]; Integer i = 1; for(Rental_Apply_Sequence__c ras:rasList){ if(esnMap.containsKey(ras.ExternalKey_Series_No__c)){ rasShowCFList.add(ras); }else{ esnMap.put(ras.ExternalKey_Series_No__c,ras.ExternalKey_Series_No__c); } if(ekeyMap.containsKey(ras.ExternalKey__c)){ if(ekeyMap.get(ras.ExternalKey__c) == 'true'){ continue; } i++; }else{ ekeyMap.put(ras.ExternalKey__c, 'false'); i = 1; } if(ras.Series_No__c <> i){ rasShowTHList.add(ras); ekeyMap.put(ras.ExternalKey__c, 'true'); } } if(rasShowCFList.size() > 0 ){ haveErrCF_X = true; } if(rasShowTHList.size() > 0 ){ haveErrTH_X = true; } Map esnDMap = new Map(); Map ekeyDMap = new Map(); List raesdList = [Select Id,Name, Queue_Number__c,ExternalKey__c From Rental_Apply_Equipment_Set_Detail__c where Cancel_Select__c = false and Queue_Number__c > 0 order by ExternalKey__c,Queue_Number__c]; Integer ii = 1; for(Rental_Apply_Equipment_Set_Detail__c raesd:raesdList){ String temp = raesd.ExternalKey__c + String.valueOf(raesd.Queue_Number__c); if(esnDMap.containsKey(temp)){ raesDShowCFList.add(raesd); }else{ esnDMap.put(temp,temp); } if(ekeyDMap.containsKey(raesd.ExternalKey__c)){ if(ekeyDMap.get(raesd.ExternalKey__c) == 'true'){ continue; } ii++; }else{ ekeyDMap.put(raesd.ExternalKey__c, 'false'); ii = 1; } if(raesd.Queue_Number__c <> ii){ raesDShowTHList.add(raesd); ekeyDMap.put(raesd.ExternalKey__c, 'true'); } } if(raesDShowCFList.size() > 0 ){ haveErrCF_D = true; } if(raesDShowTHList.size() > 0 ){ haveErrTH_D = true; } } @TestVisible private void test() { Integer i = 0; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; i++; } }