public with sharing class ConsumableAllDetController { // 订单 ID // private String orderId = ''; Set orderId = new Set(); public List allOtherDetIifo { get; set; } public String type { get; set; } //20200916 ljh add public ConsumableAllDetController() { String ordId = ApexPages.currentPage().getParameters().get('Id'); if(Test.isRunningTest()){ ordId = '1'; } if(ordId != '1'){ orderId.add(ordId); } allOtherDetIifo = new List(); type = ApexPages.currentPage().getParameters().get('type');//20200916 ljh add } // 画面初始化 public void init() { if(!(orderId.size() > 0)){ String userId = UserInfo.getUserId(); List userList = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id = :userId ]; String accountid = userList[0].accountid; String userPro_Type = userList[0].UserPro_Type__c; String userWorklocation = userList[0].Work_Location__c; // Date orderdate = Date.today().addDays(-7); String rtTypeDelivery = System.Label.RT_ConOrder_Delivery; List conorderlist = new List(); //20200916 ljh update start if(Test.isRunningTest()){ //conorderlist = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '订单' and recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c >=0 and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation]; if(type !=null && type.equals('all')){ conorderlist = [select id,Owner.Name from Consumable_order__c where Order_type__c = '订单' and recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c >= 0 or Delivery_detail_count__c >=0) and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false]; }else{ conorderlist = [select id,Owner.Name from Consumable_order__c where Order_type__c = '订单' and recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c >=0 and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false]; } }else{ //conorderlist = [select id,name,Owner.Name from Consumable_order__c where Order_type__c = '订单' and recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c >0 and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation]; if(type !=null && type.equals('all')){ conorderlist = [select id,Owner.Name from Consumable_order__c where Order_type__c = '订单' and recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0) and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false]; }else{ conorderlist = [select id,Owner.Name from Consumable_order__c where Order_type__c = '订单' and recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c >0 and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation and showFalseNotshowTrue__c = false]; } } //20200916 ljh update end // List conorderlist = [select id,Owner.Name from Consumable_order__c where Order_type__c = '订单' and recordtypeid = :rtTypeDelivery and Dealer_Info__c = :accountid and Delivery_detail_count__c > 0 and Order_ProType__c = :userPro_Type and Order_Owner_WorkLocal__c = :userWorklocation]; // System.debug('======'+conorderlist+'daxiao:'+conorderlist.size()); // for(Consumable_order__c conorder : conorderlist){ // System.debug('======'+conorder.Owner.Name+'======'); // } // Set orderId = new Set(); for(Consumable_order__c conorder : conorderlist){ String temp = (String)conorder.Id; orderId.add(temp); } System.debug('ANY o'+orderId); } List conOrderList1 = new List(); if(Test.isRunningTest()){ conOrderList1 = [SELECT Asset_Model_No__c ,Consumable_count__c FROM Consumable_Orderdetails__c]; }else{ conOrderList1 = [SELECT Asset_Model_No__c ,Consumable_count__c FROM Consumable_Orderdetails__c WHERE Consumable_order__c =:orderId]; } Map allConOrderMap = new Map(); for(Consumable_Orderdetails__c con : conOrderList1){ if(con.Consumable_count__c == null){ con.Consumable_count__c = 0; } if(allConOrderMap.containsKey(con.Asset_Model_No__c)){ allConOrderMap.put(con.Asset_Model_No__c,allConOrderMap.get(con.Asset_Model_No__c)+con.Consumable_count__c); }else{ allConOrderMap.put(con.Asset_Model_No__c, con.Consumable_count__c); } } for(String pmodel : allConOrderMap.keySet()){ if(allConOrderMap.get(pmodel) > 0){ showRecords showrecord2 = new showRecords(); showrecord2.recordCount = allConOrderMap.get(pmodel); showrecord2.prodModel = pmodel; allOtherDetIifo.add(showrecord2); } } } // Data Bean class showRecords implements Comparable { public Decimal recordCount { get; set; } public String prodModel { get; set; } // public showRecords(){ // } // public showRecords(AggregateResult e) { // recordCount =Integer.valueOf(e.get('recordCount')); // prodModel = String.valueOf(e.get('prodModel')); // } // 排序 public Integer compareTo(Object compareTo) { return null; } } }