在下面的代码中/ 在本节中我遇到了问题。 /我无法虚假其他条件。可以告诉我怎么办?我是salesforce的新手。请帮帮我。
public class SaaSFocus_Distribute_appointment
{
public List<Broker__c>Broker_special_lst;
public list<AggregateResult> counter_list;
public list<AggregateResult> counter_list1;
public list<Counter__c> clist;
/*Method which takes broker list through parameter and distributes appointment to
desire brokers and increase/decrease counters*/
public ID Compensatory_appointment(set<ID> Broker_ID)
{
//list which sorts parametrs list order by compensatory Appointment
Broker_special_lst=[select id, Compensatory_Appointment__c from Broker__c where id in:Broker_ID order by Compensatory_Appointment__c desc ];
ID Allocatedbrokerid ;
if(Broker_special_lst[0].Compensatory_Appointment__c>0) /*Here we are checking the compensatory appointement greater than zero*/
{
Allocatedbrokerid = Broker_special_lst[0].id;
Broker_special_lst[0].Compensatory_Appointment__c--;
update Broker_special_lst[0];
System.debug('before if COmpen VT Bingo;;;;;'+Broker_special_lst[0].Compensatory_Appointment__c);
}
else //if compenstory appointment have null value it assigns zero
{
if(Broker_special_lst[0].Compensatory_Appointment__c==null)
Broker_special_lst[0].Compensatory_Appointment__c=0;
System.debug('else COmpen VT Bingo;;;;;'+Broker_special_lst[0].Compensatory_Appointment__c);
list<Market_Broker_Association__c> masterbrkerlist=[select id, Priority__c, Broker__r.id from Market_Broker_Association__c where Broker__c in :Broker_ID];
Map<String, set<id>> map_Broker = new Map<String, set<id>>();
for(Market_Broker_Association__c mba:masterbrkerlist) //here is the map where map key has priority__c and value have set of id's.
{
if(map_Broker.get(mba.Priority__c) == null) // if map's Priority__c comes null than map put method works.
map_Broker.put(mba.Priority__c,new set<id>());
map_Broker.get(mba.Priority__c).add(mba.Broker__r.id );
}
system.debug('PM***'+map_Broker.get('Primary Market'));
system.debug('SM***'+map_Broker.get('Secondary Market'));
//在本节我面临问题。
if(map_Broker.get('Primary Market')==null)
{
clist=[select Count__c,Broker__c from Counter__c where Broker__c in:map_Broker.get('Secondary Market') order by Count__c desc];
}
else if(map_Broker.get('Secondary Market')==null)
{
clist= [select Count__c,Broker__c from Counter__c where Broker__c in:map_Broker.get('Primary Market') order by Count__c desc];
}
else
{
/*Here we are execuitng aggregate query for counter object*/
counter_list=[select min (Count__c)cnt from Counter__c where Broker__c in :map_Broker.get('Primary Market')];
counter_list1=[select max(Count__c)cnt1 from Counter__c where Broker__c in :map_Broker.get('Secondary Market')];
Decimal intdata = 0;
Decimal intdata1 = 0;
Decimal num = 0;
intdata =(Decimal)counter_list[0].get('cnt');
intdata1 =(Decimal)counter_list1[0].get('cnt1');
//This is the custom setting where secondary appointment lag field set default as a constant
Google_API_Setting__c obj_Lag=[select Secondary_Appointment_Lag__c from Google_API_Setting__c ];
num = intdata - intdata1 ;
if(num>obj_Lag.Secondary_Appointment_Lag__c)
{
clist=[select Count__c,Broker__c from Counter__c where Broker__c in:map_Broker.get('Secondary Market') order by Count__c desc];
}
else
{
clist=[select Count__c ,Broker__c from Counter__c where Broker__c in:map_Broker.get('Primary Market') order by Count__c desc];
}
}
Allocatedbrokerid = clist[0].broker__c;
clist[0].count__c ++;
update clist[0];
update Broker_special_lst[0];
}
return Allocatedbrokerid ;
}
}