public without sharing class ConsumableOtherArrDetController {
|
// 订单 ID
|
private String orderId = '';
|
public List<Consumable_Orderdetails__c> otherArrDetIifo { get; set; }
|
public ConsumableOtherArrDetController() {
|
orderId = ApexPages.currentPage().getParameters().get('Id');
|
otherArrDetIifo = new List<Consumable_Orderdetails__c>();
|
}
|
|
// 画面初始化
|
public void init() {
|
List<showRecords> arrDetIifo = new List<showRecords>();
|
List<showRecords> notArrDetIifo = new List<showRecords>();
|
List<showRecords> allArrDetIifo = new List<showRecords>();
|
// List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Dealer_Arrive__c = true AND Consumable_order_minor__c = :orderId];
|
List<Consumable_order_details2__c> conList = [SELECT id,Bar_Code__c FROM Consumable_order_details2__c WHERE Consumable_order_minor__c = :orderId];
|
Map<String,String> srtMap = new Map<String,String>();
|
for(Consumable_order_details2__c con : conList){
|
srtMap.put(con.Bar_Code__c, con.Id);
|
}
|
List<String> str = new List<String>();
|
for(String s : srtMap.keySet()){
|
str.add(srtMap.get(s));
|
}
|
List<AggregateResult> arrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
|
WHERE Id =: str AND Dealer_Arrive__c = true
|
GROUP BY Asset_Model_No__c];
|
for(Integer i = 0 ; i< arrDetList.size();i++){
|
arrDetIifo.add(new showRecords(arrDetList[i]));
|
}
|
|
List<AggregateResult> notArrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
|
WHERE Dealer_Arrive__c = false
|
AND Consumable_order_minor__c = :orderId
|
GROUP BY Asset_Model_No__c];
|
for(Integer i = 0 ; i< notArrDetList.size();i++){
|
notArrDetIifo.add(new showRecords(notArrDetList[i]));
|
}
|
|
// List<AggregateResult> allArrDetList = [SELECT Asset_Model_No__c prodModel,count(Id) recordCount FROM Consumable_order_details2__c
|
// WHERE Id =: str
|
// GROUP BY Asset_Model_No__c];
|
List<Consumable_Orderdetails__c> allArrDetList = [SELECT Asset_Model_No__c,Consumable_count__c FROM Consumable_Orderdetails__c
|
WHERE Consumable_order__c =: orderId];
|
// for(Integer i = 0 ; i< allArrDetList.size();i++){
|
// allArrDetIifo.add(new showRecords(notArrDetList[i]));
|
// }
|
Map<String,Decimal> arrDetMap = new Map<String,Decimal>();
|
for(showRecords arr : arrDetIifo){
|
arrDetMap.put(arr.prodModel, arr.recordCount);
|
}
|
for(showRecords notarr : notArrDetIifo){
|
if(arrDetMap.containsKey(notarr.prodModel)){
|
arrDetMap.put(notarr.prodModel, arrDetMap.get(notarr.prodModel)+notarr.recordCount);
|
}else{
|
arrDetMap.put(notarr.prodModel, notarr.recordCount);
|
}
|
}
|
List<String> AssetModelNoEdList = new List<String>();//20200904 ljh add
|
for(Consumable_Orderdetails__c allarr : allArrDetList){
|
for(String promodel : arrDetMap.keySet()){
|
if(allarr.Asset_Model_No__c == promodel){
|
if((allarr.Consumable_count__c - arrDetMap.get(promodel)) > 0){
|
allarr.Consumable_count__c = (allarr.Consumable_count__c - arrDetMap.get(promodel));
|
otherArrDetIifo.add(allarr);
|
}
|
AssetModelNoEdList.add(promodel);//20200904 ljh add
|
}
|
}
|
}
|
//20200904 ljh add start
|
for(Consumable_Orderdetails__c allarr1 : allArrDetList){
|
if(!AssetModelNoEdList.contains(allarr1.Asset_Model_No__c)){
|
otherArrDetIifo.add(allarr1);
|
}
|
}
|
//20200904 ljh add end
|
// for(Consumable_Orderdetails__c allarr : allArrDetIifo){
|
// for(String promodel : arrDetMap.keySet()){
|
// if(allarr.prodModel == promodel){
|
// if((allarr.recordCount - arrDetMap.get(promodel)) >= 0){
|
// allarr.recordCount = (allarr.recordCount - arrDetMap.get(promodel));
|
// otherArrDetIifo.add(allarr);
|
// }
|
// }
|
// }
|
// }
|
}
|
|
// 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;
|
}
|
}
|
}
|