public without sharing class ArriveGoodsMainController {
|
/*****************検索用******************/
|
//经销商产品分类
|
public String agencyProType {get;set;}
|
public Consumable_order__c coc { get; set; }
|
public String category1 { get; set; }
|
private String cate1ForSort = null;
|
private Date cate2ForSort = Date.today();
|
private Date cate2 = Date.today();
|
private String[] columus = new String[]{ 'Product2__c.Name'};
|
// 产品 ID
|
private String ESetId = '';
|
private String accountid = null;
|
// 订单 字段标签
|
public List<String> title { get; private set; }
|
// 订单 字段名
|
public List<String> column;
|
public List<List<String>> columns { get; private set; }
|
// 画面显示数据
|
public List<Consumable_order__c> raesList { get; private set; }
|
|
// 登录者工作地
|
private String userWorkLocation;
|
|
// 20200904 ljh 汇总使用 start
|
public Integer Total_num {get; set;}
|
public Integer OrderNumber_arrived {get; set;}
|
public Integer Delivery_detail_count {get; set;}
|
public Integer OrderNumber_notarrive {get; set;}
|
public Integer More_than_seven_days {get; set;}
|
// 20200904 ljh 汇总使用 start
|
|
public ArriveGoodsMainController() {
|
ESetId = ApexPages.currentPage().getParameters().get('esetId');
|
}
|
//========20160311======ADD_Start================================
|
// 将订单明细以字段SET 方式显示
|
//========20160311======ADD_Start================================
|
public void init1() {
|
System.debug('123456789');
|
coc = new Consumable_order__c();
|
String userId = UserInfo.getUserId();
|
List<user> Useracc = New List<user>();
|
Useracc = [select accountid, Work_Location__c,UserPro_Type__c from user where id =:userId];
|
accountid = Useracc[0].accountid;
|
userWorkLocation = Useracc[0].Work_Location__c;
|
agencyProType = Useracc[0].UserPro_Type__c;
|
if(String.isBlank(Useracc[0].UserPro_Type__c)){
|
agencyProType = 'ET';
|
}
|
// 获得订单一览
|
Map<String, Schema.FieldSet> fsMap = Schema.getGlobalDescribe().get('Consumable_order__c').getDescribe().fieldSets.getMap();
|
Schema.FieldSet fs = fsMap.get('arrive_view');
|
// 获得订单中的所有项目
|
List<FieldSetMember> fsmList = fs.getFields();
|
// 获得字段标签和字段名
|
title = new List<String>();
|
column = new List<String>();
|
columns = new List<List<String>>();
|
for (FieldSetMember fsm : fsmList) {
|
title.add(fsm.getLabel());
|
column.add(fsm.getFieldPath());
|
columns.add(fsm.getFieldPath().split('\\.'));
|
}
|
// 获得显示数据
|
raesList = new List<Consumable_order__c>();
|
String soql = 'select Id';
|
for (String s : column) {
|
soql += ',' + s;
|
}
|
soql += ' from Consumable_order__c where Order_type__c = \''+'订单'+'\' and recordtypeid =\'' + System.Label.RT_ConOrder_Delivery + '\' and Dealer_Info__c =\'' + accountid +'\' and Order_ProType__c =\'' + agencyProType +'\' and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0) and Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' and showFalseNotshowTrue__c = false order by Deliver_date__c'; //
|
raesList = Database.query(soql);
|
//20200904 ljh add start
|
Total_num = 0;
|
OrderNumber_arrived = 0;
|
Delivery_detail_count = 0;
|
OrderNumber_notarrive = 0;
|
More_than_seven_days = 0;
|
System.debug('-----1------'+raesList);
|
for(Consumable_order__c conorder :raesList){
|
Total_num += (Integer)conorder.Total_num__c;
|
OrderNumber_arrived += (Integer)conorder.OrderNumber_arrived__c;
|
Delivery_detail_count += (Integer)conorder.Delivery_detail_count__c;
|
OrderNumber_notarrive += (Integer)conorder.OrderNumber_notarrive__c;
|
More_than_seven_days += (Integer)conorder.More_than_seven_days__c;
|
}
|
//20200904 ljh add end
|
}
|
//========20160311======ADD_End================================
|
// 检索
|
public void searchConsumableorderdetails() {
|
//coc = new Consumable_order__c();
|
cate2 = coc.Shipment_date__c;
|
// 获得订单一览
|
Map<String, Schema.FieldSet> fsMap = Schema.getGlobalDescribe().get('Consumable_order__c').getDescribe().fieldSets.getMap();
|
Schema.FieldSet fs = fsMap.get('arrive_view');
|
// 获得订单中的所有项目
|
List<FieldSetMember> fsmList = fs.getFields();
|
// 获得字段标签和字段名
|
title = new List<String>();
|
column = new List<String>();
|
columns = new List<List<String>>();
|
for (FieldSetMember fsm : fsmList) {
|
title.add(fsm.getLabel());
|
column.add(fsm.getFieldPath());
|
columns.add(fsm.getFieldPath().split('\\.'));
|
}
|
// 获得显示数据
|
raesList = new List<Consumable_order__c>();
|
String soql = 'select Id';
|
for (String s : column) {
|
soql += ',' + s;
|
}
|
soql += ' from Consumable_order__c where Order_type__c = \''+'订单'+'\' and recordtypeid =\'' + System.Label.RT_ConOrder_Delivery + '\' and Dealer_Info__c =\'' + accountid +'\' and (OrderNumber_notarrive__c > 0 or Delivery_detail_count__c >0) ';
|
soql += 'and Order_Owner_WorkLocal__c = \'' + userWorkLocation + '\' ';
|
soql += 'and showFalseNotshowTrue__c = false';
|
if (!String.isBlank(category1)) {
|
soql += ' and Name like \'%' + String.escapeSingleQuotes(category1.replaceAll('%', '\\%')) + '%\' ';
|
}
|
if(cate2 != null){
|
soql += ' and Shipment_date__c = :cate2 ';
|
}
|
soql += ' and Order_ProType__c =\'' + agencyProType +'\'';
|
soql += ' order by Deliver_date__c';
|
system.debug('====soql:' + soql);
|
raesList = Database.query(soql);
|
if(raesList.size()>0){
|
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '共有' + raesList.size() + '个订单'));
|
}else{
|
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO, '没有搜索到相关订单。'));
|
}
|
}
|
//到货查询重定向
|
public PageReference orderArrive() {
|
// 返回备品set
|
PageReference ref = new Pagereference('/apex/ArriveGoods?ArrType=Arr');
|
ref.setRedirect(true);
|
return ref;
|
}
|
//返品查询重定向
|
public PageReference orderReturn() {
|
// 返回备品set
|
PageReference ref = new Pagereference('/apex/ArriveGoods?ArrType=ReG');
|
ref.setRedirect(true);
|
return ref;
|
}
|
}
|