Browse Source

需求单No.141724 万福模块新增定制报表【销售统计表】

master^2
yibo 7 years ago
parent
commit
da8d8ea1ec
3 changed files with 302 additions and 0 deletions
  1. +7
    -0
      B3QingDaoWanFu.Web/B3QingDaoWanFu.Web.csproj
  2. +293
    -0
      B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Reports/SaleSummaryReport_/SaleSummaryReport.cs
  3. +2
    -0
      WebFolder/config/plugins/B3QingDaoWanFu.plugin

+ 7
- 0
B3QingDaoWanFu.Web/B3QingDaoWanFu.Web.csproj View File

@ -84,6 +84,10 @@
<HintPath>..\..\..\tsref\Debug\B3Sale.Web.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="B3SaleInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3a973053c7ebf11c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\B3SaleInterface.dll</HintPath>
</Reference>
<Reference Include="B3UnitedInfos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a04fa581c0f74d43, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\BwpB3Project\tsref\Debug\B3UnitedInfos.dll</HintPath>
@ -201,6 +205,9 @@
<Compile Include="Pages\B3QingDaoWanFu\Overlays\WeightBillEdit_Ext.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\B3QingDaoWanFu\Reports\SaleSummaryReport_\SaleSummaryReport.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\B3QingDaoWanFu\TrustPay_\TrustPayList.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>


+ 293
- 0
B3QingDaoWanFu.Web/Pages/B3QingDaoWanFu/Reports/SaleSummaryReport_/SaleSummaryReport.cs View File

@ -0,0 +1,293 @@
using BWP.B3Frameworks;
using BWP.B3Frameworks.BO;
using BWP.B3Frameworks.BO.NamedValueTemplate;
using BWP.B3Sale.BO;
using BWP.Web.Utils;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using Forks.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using TSingSoft.WebControls2;
using TSingSoft.WebPluginFramework;
namespace BWP.Web.Pages.B3QingDaoWanFu.Reports.SaleSummaryReport_
{
class SaleSummaryReport : ClickQueryReportPage
{
protected override string AccessRoleName
{
get { return "B3QingDaoWanFu.报表.销售统计表"; }
}
protected override string Caption
{
get { return "销售统计表"; }
}
protected override void InitDFGrid(DFGrid mDfGrid)
{
base.InitDFGrid(mDfGrid);
mDfGrid.AllowRowGroup = true;
mDfGrid.AllowColGroup = true;
mDfGrid.AllowSorting = true;
mDfGrid.HeaderPagerLock = true;
}
protected override void CreateQueryPanel(VLayoutPanel vPanel)
{
var list = new List<Tuple<string, string>>();
list.Add(new Tuple<string, string>("First", "一级部门"));
list.Add(new Tuple<string, string>("Second", "二级部门"));
var dic = list.Select((item) => item.Item1).EToHashSet();
var tablePanel = vPanel.Add(new TableLayoutPanel(1, 2), new VLayoutOption(System.Web.UI.WebControls.HorizontalAlign.Justify));
tablePanel.Add(0, 1, 0, 1, CreateFirstDept());
tablePanel.Add(0, 1, 1, 2, CreateSecondDept());
}
List<Tuple<long, string>> FirstDepts
{
get
{
if (ViewState["FirstDepts"] == null)
ViewState["FirstDepts"] = GetFirstDepts();
return (List<Tuple<long, string>>)ViewState["FirstDepts"];
}
set { ViewState["FirstDepts"] = value; }
}
List<Tuple<long, string>> GetFirstDepts()
{
var dept = SaleDepartmentInfo;
var query = new DQueryDom(new JoinAlias(typeof(Department)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("Name"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Domain_ID", DomainContext.Current.ID), DQCondition.EQ("Stopped", false), DQCondition.EQ("Depth", dept.Item2 + 1)));
query.Where.Conditions.Add(DQCondition.EQ(string.Format("TreeDeep{0}ID", dept.Item2), dept.Item1));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
return query.EExecuteList<long, string>();
}
Tuple<long, int> SaleDepartmentInfo
{
get
{
if (ViewState["SaleDepartmentInfo"] == null)
{
var dept = WebBLUtil.GetSingleDmo<Department>("Name", "销售部", "ID", "Depth");
if (dept == null)
throw new Exception("没有名称为销售部的部门");
ViewState["SaleDepartmentInfo"] = new Tuple<long, int>(dept.ID, dept.Depth);
}
return (Tuple<long, int>)ViewState["SaleDepartmentInfo"];
}
}
List<Tuple<long, string>> SecondDepts
{
get
{
if (ViewState["SecondDepts"] == null)
ViewState["SecondDepts"] = GetSecondDepts();
return (List<Tuple<long, string>>)ViewState["SecondDepts"];
}
set { ViewState["SecondDepts"] = value; }
}
List<Tuple<long, string>> GetSecondDepts()
{
var depth = SaleDepartmentInfo.Item2;
var selectedItem = firstFilterTree.GetSelecteItem();
if (!selectedItem.Selected || string.IsNullOrEmpty(selectedItem.Value))
return new List<Tuple<long, string>>();
var query = new DQueryDom(new JoinAlias(typeof(Department)));
query.Columns.Add(DQSelectColumn.Field("ID"));
query.Columns.Add(DQSelectColumn.Field("Name"));
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Domain_ID", DomainContext.Current.ID), DQCondition.EQ("Stopped", false), DQCondition.EQ("Depth", depth + 2)));
query.Where.Conditions.Add(DQCondition.EQ(string.Format("TreeDeep{0}ID", depth + 1), long.Parse(firstFilterTree.GetSelecteItem().Value)));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create("ID"));
return query.EExecuteList<long, string>();
}
static FilterTree firstFilterTree;
private Control CreateFirstDept()
{
firstFilterTree = new FilterTree() { AllLinkOnFirst = true };
firstFilterTree.HorizontalRepeatColumns = 10;
this.Load += delegate
{
if (!IsPostBack)
{
firstFilterTree.DataSource.Childs.Clear();
foreach (var item in FirstDepts)
{
var node = new FilterTreeNode(item.Item2, item.Item1.ToString());
firstFilterTree.DataSource.Childs.Add(node);
}
}
};
mTreeContainer.Add("First", firstFilterTree);
firstFilterTree.Select += (sender, e) =>
{
SecondDepts = GetSecondDepts();
BuildSecond();
};
firstFilterTree.FilterAction = (query, node) =>
{
if (!string.IsNullOrEmpty(node.Value))
{
query.Where.Conditions.Add(DQCondition.EQ(JoinAlias.Create("dept"), "TreeDeep1ID", long.Parse(node.Value)));
}
};
return firstFilterTree;
}
void BuildSecond()
{
secondFilterTree.DataSource.Childs.Clear();
foreach (var item in SecondDepts)
{
var node = new FilterTreeNode(item.Item2, item.Item1.ToString());
secondFilterTree.DataSource.Childs.Add(node);
}
}
static FilterTree secondFilterTree;
private Control CreateSecondDept()
{
secondFilterTree = new FilterTree() { AllLinkOnFirst = true };
secondFilterTree.HorizontalRepeatColumns = 10;
this.Load += delegate
{
if (!IsPostBack)
BuildSecond();
};
mTreeContainer.Add("Second", secondFilterTree);
secondFilterTree.FilterAction = (query, node) =>
{
if (!string.IsNullOrEmpty(node.Value))
{
query.Where.Conditions.Add(DQCondition.EQ(JoinAlias.Create("dept"), "TreeDeep2ID", long.Parse(node.Value)));
}
};
return secondFilterTree;
}
readonly string[] goodsBrand = new string[] { "条类", "分割品", "副产品", "冻品" };
protected override DQueryDom GetQueryDom()
{
var main = new JoinAlias(typeof(TempClass));
var dept = new JoinAlias("dept", typeof(Department));
var _3Dept = new JoinAlias("_3Dept", typeof(Department));
var customer = new JoinAlias(typeof(Customer));
var goods = new JoinAlias(typeof(SaleGoods));
var query = new DQueryDom(main);
TempClass.Register(query);
query.From.AddJoin(JoinType.Left, new DQDmoSource(dept), DQCondition.EQ(main, "Department_ID", dept, "ID"));
query.From.AddJoin(JoinType.Left, new DQDmoSource(_3Dept), DQCondition.EQ(dept, "TreeDeep3ID", _3Dept, "ID"));
query.From.AddJoin(JoinType.Left, new DQDmoSource(customer), DQCondition.EQ(main, "Customer_ID", customer, "ID"));
query.From.AddJoin(JoinType.Left, new DQDmoSource(goods), DQCondition.EQ(main, "Goods_ID", goods, "ID"));
query.Columns.Add(DQSelectColumn.Field("Name", _3Dept, "销售部门"));
query.GroupBy.Expressions.Add(DQExpression.Field(_3Dept, "Name"));
query.Columns.Add(DQSelectColumn.Field("CustomerCatalog_Name", customer));
query.GroupBy.Expressions.Add(DQExpression.Field(customer, "CustomerCatalog_Name"));
query.GroupBy.Expressions.Add(DQExpression.Field(customer, "CustomerCatalog_ID"));
query.OrderBy.Expressions.Add(DQOrderByExpression.Create(customer, "CustomerCatalog_ID"));
foreach (var item in goodsBrand)
{
if (item == "条类")
{
query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.EQ(goods, "Brand", item), DQCondition.EQ("Type", 2)), DQExpression.Field("SecondNumber"), DQExpression.NULL)), DQExpression.Value(7)), item + "|上周日均头数"));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.EQ(goods, "Brand", item), DQCondition.EQ("Type", 1)), DQExpression.Field("SecondNumber"), DQExpression.NULL)), item + "|头数"));
}
query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.EQ(goods, "Brand", item), DQCondition.EQ("Type", 2)), DQExpression.Field("MainNumber"), DQExpression.NULL)), DQExpression.Value(7)), item + "|上周日均重量"));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.And(DQCondition.EQ(goods, "Brand", item), DQCondition.EQ("Type", 1)), DQExpression.Field("MainNumber"), DQExpression.NULL)), item + "|重量"));
}
query.Columns.Add(DQSelectColumn.Create(DQExpression.Divide(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("Type", 2), DQExpression.Field("MainNumber"), DQExpression.NULL)), DQExpression.Value(7)), "上周日均重量"));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Sum(DQExpression.LogicCase(DQCondition.EQ("Type", 1), DQExpression.Field("MainNumber"), DQExpression.NULL)), "当日重量合计"));
var idx = 0;
foreach (var col in query.Columns)
{
ColumnNames.Add(col.Name);
if (idx > 1)
{
SumColumnNames.Add(col.Name);
GroupSumColumnNamnes.Add(col.Name);
}
idx++;
}
return query;
}
class TempClass
{
public long? Department_ID { get; set; }
public long? Customer_ID { get; set; }
public long? Goods_ID { get; set; }
public int Type { get; set; }
public Money<decimal>? MainNumber { get; set; }
public Money<decimal>? SecondNumber { get; set; }
public static void Register(DQueryDom root)
{
var q1 = GetSaleOutStore(true);
q1.UnionNext.Select = GetSaleOutStore(false);
root.RegisterQueryTable(typeof(TempClass), new string[] { "Department_ID", "Customer_ID", "Goods_ID", "Type", "MainNumber", "SecondNumber" }, q1);
}
static DQueryDom GetSaleOutStore(bool today)
{
var main = new JoinAlias(today + "M", typeof(SaleOutStore));
var detail = new JoinAlias(today + "D", typeof(SaleOutStore_Detail));
//var dept = new JoinAlias("dept", typeof(Department));
var query = new DQueryDom(main);
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(main, "ID", detail, "SaleOutStore_ID"));
// query.From.AddJoin(JoinType.Left, new DQDmoSource(dept), DQCondition.EQ(main, "Department_ID", dept, "ID"));
query.Columns.Add(DQSelectColumn.Field("Department_ID", main));
query.Columns.Add(DQSelectColumn.Field("Customer_ID", main));
query.Columns.Add(DQSelectColumn.Field("SaleGoods_ID", detail));
query.Columns.Add(DQSelectColumn.Create(DQExpression.Value(today ? 1 : 2), "Type"));
query.Columns.Add(DQSelectColumn.Field("UnitNum", detail));
query.Columns.Add(DQSelectColumn.Field("SecondNumber", detail));
var timeRange = GetDateRange(today);
query.Where.Conditions.Add(DQCondition.And(DQCondition.EQ("Domain_ID", DomainContext.Current.ID), DQCondition.GreaterThanOrEqual("BillState", .), DQCondition.Between("LoadTime", timeRange.Item1, timeRange.Item2)));
return query;
}
static Tuple<DateTime, DateTime> GetDateRange(bool today)
{
if (today)
return new Tuple<DateTime, DateTime>(DateTime.Today, DateTime.Today + new TimeSpan(23, 59, 59));
var d = (int)DateTime.Today.DayOfWeek;
if (DateTime.Today.DayOfWeek == DayOfWeek.Sunday)
d = 7;
var date = DateTime.Today.AddDays(-d);
return new Tuple<DateTime, DateTime>(date.AddDays(-6), date);
}
}
}
}

+ 2
- 0
WebFolder/config/plugins/B3QingDaoWanFu.plugin View File

@ -29,6 +29,7 @@
<Function index="2" name="付款清单导出"/>
<Function index="3" name="结算单分析"/>
<Function index="4" name="销售出库分析"/>
<Function index="5" name="销售统计表"/>
</FunctionGroup>
<FunctionGroup name="配置" roleSchemas="employee">
<Function index="0" name="结账客户设备配置"/>
@ -82,6 +83,7 @@
<Menu id="0007" name="/B3青岛万福/报表/万福销售出库分析" roles="B3QingDaoWanFu.报表.销售出库分析" url="B3QingDaoWanFu/SaleOutStore_/SaleOutStoreSimpleAnayse.aspx"/>
<Menu id="0008" name="/B3青岛万福/农行付款" roles="B3QingDaoWanFu.农行付款.访问" url="B3QingDaoWanFu/TrustPay_/TrustPayList.aspx"/>
<Menu id="0009" name="/B3青岛万福/业务单据/产品出厂记录" roles="B3QingDaoWanFu.产品出厂记录.访问" url="B3QingDaoWanFu/Bills/OutFactoryRecord_/OutFactoryRecordList.aspx"/>
<Menu id="0010" name="/B3青岛万福/报表/销售统计表" roles="B3QingDaoWanFu.报表.销售统计表" url="B3QingDaoWanFu/Reports/SaleSummaryReport_/SaleSummaryReport.aspx"/>
</Menus>
<Features>


Loading…
Cancel
Save