public without sharing class ConsumableArrDetController { // 订单 ID private String orderId = ''; public List arrDetIifo { get; set; } public ConsumableArrDetController() { orderId = ApexPages.currentPage().getParameters().get('Id'); arrDetIifo = new List(); } // 画面初始化 public void init() { List conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId]; Map srtMap = new Map(); for(Consumable_order_details2__c con : conList){ srtMap.put(con.Bar_Code__c, con.Id); } List str = new List(); for(String s : srtMap.keySet()){ str.add(srtMap.get(s)); } List arrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c WHERE Id =: str GROUP BY Asset_Model_No__c]; for(Integer i = 0 ; i< arrDetList.size();i++){ arrDetIifo.add(new showRecords(arrDetList[i])); } } // Data Bean class showRecords implements Comparable { public Decimal recordCount { get; set; } public String prodModel { get; set; } public showRecords(AggregateResult e) { recordCount =Integer.valueOf(e.get('recordCount')); prodModel = String.valueOf(e.get('prodModel')); } // 排序 public Integer compareTo(Object compareTo) { return null; } } }