/// <summary>
/// 取客户对账报表数据
/// </summary>
/// <param name="ctx"></param>
/// <param name="fcustid"></param>
/// <param name="dateTime"></param>
public static void getReportData(Context ctx, long fcustid, DateTime dateTime, DynamicObject Customer,long orgID)
{
String nowTime = dateTime.ToString("yyyy-MM-dd", DateTimeFormatInfo.InvariantInfo);//当前日期
ISysReportService sysReporSservice = ServiceFactory.GetSysReportService(ctx);
IPermissionService permissionService = ServiceFactory.GetPermissionService(ctx);
var filterMetadata = FormMetaDataCache.GetCachedFilterMetaData(ctx);//加载字段比较条件元数据。
var reportMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, "HL_ReconciliationRpt");//加载对账报表元数据。
var reportFilterMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, "HL_ReconciliationFilter");//加载对账报表过滤条件元数据。
var reportFilterServiceProvider = reportFilterMetadata.BusinessInfo.GetForm().GetFormServiceProvider();
var model = new SysReportFilterModel();
model.SetContext(ctx, reportFilterMetadata.BusinessInfo, reportFilterServiceProvider);
model.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id;
model.FilterObject.FilterMetaData = filterMetadata;
model.InitFieldList(reportMetadata, reportFilterMetadata);
model.GetSchemeList();
//正式FSCHEMEID 5e16dc7adec326
//本地 5e169d3eec7e1e
var entity = model.Load("5e16dc7adec326");//过滤方案的主键值,可通过该SQL语句查询得到:SELECT * FROM T_BAS_FILTERSCHEME
//model.SetValue("FCUSTOMERNAME", fcustid,0);
var filter = model.GetFilterParameter();
//拼接过滤条件
if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(Customer))
{
//FilterRow FilterRow =
// FilterRow.CompareType = new CompareType();
filter.FilterRows[0].Value = Convert.ToString(Customer["Name"]);
//filter.FilterString =;
if (orgID>0)
{
filter.IsolationOrgList = new List<long>() { orgID };
}
filter.FilterString = "( FCUSTOMERNAME = N'"+ Convert.ToString(Customer["Name"]) + "' )";
// filter.FilterRows.Add(FilterRow);
}
//拼接过滤条件
//if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(Customer))
//{
// DynamicObject objFilter = new DynamicObject(filter.CustomFilter.DynamicObjectType);
// objFilter["chkscheme"] = false;
// objFilter["FCustID_Id"] = fcustid;
// objFilter["FCUSTID"] = Customer;
// filter.CustomFilter = objFilter;
//}
IRptParams p = new RptParams();
p.FormId = reportFilterMetadata.BusinessInfo.GetForm().Id;
p.StartRow = 1;
p.EndRow = int.MaxValue;//StartRow和EndRow是报表数据分页的起始行数和截至行数,一般取所有数据,所以EndRow取int最大值。
p.FilterParameter = filter;
p.FilterFieldInfo = model.FilterFieldInfo;
p.BaseDataTempTable.AddRange(permissionService.GetBaseDataTempTable(ctx, reportMetadata.BusinessInfo.GetForm().Id));
using (DataTable dt = sysReporSservice.GetData(ctx, reportMetadata.BusinessInfo, p))
{
string filterStr = string.Format("FCUSTOMERID ={0} and FAMOUNT> 0 and FPAYDATE<='{1}'", fcustid, nowTime);
DataRow[] rows = dt.Select(filterStr);
if (rows.Length>0)//标识到期有欠款
{
//考虑临时解锁日期
string SQL = @"/*dialect*/ select max(FUNLOCKENDDATE) FLSUNLOCKDATE from T_BOS_CustStatusEntry where FCUSTID =" + fcustid;
var dateDays = DBServiceHelper.ExecuteDynamicObject(ctx, SQL);//恢复供货申请表
if (dateDays.Count > 0)
{
DateTime LSJSDate = Convert.ToDateTime(dateDays[0]["FLSUNLOCKDATE"]);//临时解锁日期
if (LSJSDate.Date>= dateTime.Date)//则不锁定
{
return;
}
else
{
//进入黑名单
updateCustomerStuts(ctx, fcustid);
}
}
else//没有做过临时解锁
{
//进入黑名单
updateCustomerStuts(ctx, fcustid);
}
}
else
{
//客户解锁
string updateSql = " UPDATE T_BD_CUSTOMER SET FCUSTSTATUS = 1 WHERE FCUSTID = '" + fcustid + "'";
DBServiceHelper.ExecuteDynamicObject(ctx, updateSql);
}
// DataRowCollection rowColl = dt.Rows;
// string FCustomer = Convert.ToString(row["FCustomer"]);//报表字段
//string FCustomerNum= Convert.ToString(row ["FCustomerNum"]); //报表字段
// Int64 FOrgNumID = Convert.ToInt64(row ["FOrgNumID"]);//报表字段
//dt就是报表数据,接下来就是你发挥的时间。
// rowColl.Find();
}
ServiceFactory.CloseService(sysReporSservice);
ServiceFactory.CloseService(permissionService);
}
推荐阅读