public with sharing class TransferApplyDetailController { //OCSM_BP5-35 邮件模板 公用调拨明细 public Id taId{get;set;} public String varType{get;set;} public List tadList {get;set;} public String gatherName{get;set;} public List title{get;set;} public List column {get;set;} private static final Map FSMAP = Schema.SObjectType.TransferApplyDetail__c.fieldSets.getMap(); public String getInit(){ Schema.FieldSet fs = FSMAP.get(gatherName);//TransferEmail List fsmList = fs.getFields(); // 获得字段集中的字段名 title = new List(); column = new List(); for (FieldSetMember fsm : fsmList) { if(fsm.getLabel().contains('(Sys)')){ title.add(fsm.getLabel().replace('(Sys)','')); }else{ title.add(fsm.getLabel()); } column.add(fsm.getFieldPath()); } List tadTempList = new List(); String soql = 'SELECT Asset__c,TransferApplySummary__c,TransferType__c,Add_Request_demo_time__c '; for (Integer i=0;i addList = new List(); for (TransferApplyDetail__c tt : tadTempList) { if (t == null) { t = tt; } if (t.Add_Request_demo_time__c != tt.Add_Request_demo_time__c) { break; } addList.add(tt); } //if(addList != null && addList.size()>0){ tadTempList = null; tadTempList = addList; //} } Map tempMap = new Map(); for(TransferApplyDetail__c temp:tadTempList){ String tempKey = temp.TransferApplySummary__c; if(String.isNotBlank(temp.Fixture_Model_No_F__c)){ tempKey += temp.Fixture_Model_No_F__c; } if(String.isNotBlank(temp.SerialNumber__c)){ tempKey += temp.SerialNumber__c; } if(tempMap.containsKey(tempKey)){ TransferApplyDetail__c tad = tempMap.get(tempKey); //调拨数量 待废弃调拨数 待修理调拨数 丢失调拨数 if(String.isNotBlank(temp.TransferType__c) && temp.TransferType__c == '待废弃'){ tad.VF_TransferCount_Abandoned__c += 1; }else if(String.isNotBlank(temp.TransferType__c) && temp.TransferType__c == '待修理'){ tad.VF_TransferCount_Repair__c += 1; }else if(String.isNotBlank(temp.TransferType__c) && temp.TransferType__c == '丢失找回'){ tad.VF_TransferCount_Lost__c += 1; }else{ tad.VF_TransferCount__c += 1; } tempMap.put(tempKey,tad); }else{ temp.VF_TransferCount_Abandoned__c = 0; temp.VF_TransferCount_Repair__c = 0; temp.VF_TransferCount_Lost__c = 0; temp.VF_TransferCount__c = 0; if(String.isNotBlank(temp.TransferType__c) && temp.TransferType__c == '待废弃'){ temp.VF_TransferCount_Abandoned__c = 1; }else if(String.isNotBlank(temp.TransferType__c) && temp.TransferType__c == '待修理'){ temp.VF_TransferCount_Repair__c = 1; }else if(String.isNotBlank(temp.TransferType__c) && temp.TransferType__c == '丢失找回'){ temp.VF_TransferCount_Lost__c = 1; }else{ temp.VF_TransferCount__c = 1; } tempMap.put(tempKey,temp); } } tadList = (List)tempMap.values(); return ''; } }