Browse Source

需求单No.137625

master
wugang 7 years ago
parent
commit
5de7d5747e
5 changed files with 285 additions and 1 deletions
  1. +9
    -1
      BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj
  2. +6
    -0
      BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj.user
  3. +238
    -0
      BWP.B3_YunKen.Web/Pages/B3YunKen/Reports/EmployeeExamineReport.cs
  4. +30
    -0
      BWP.B3_YunKen.Web/Pages/B3YunKen/Reports/EmployeeExamineReport.xml
  5. +2
    -0
      WebFolder/Config/Plugins/B3_YunKen.Plugin

+ 9
- 1
BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj View File

@ -158,6 +158,9 @@
<Compile Include="Pages\B3YunKen\Reports\DynamicPriceReport.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\B3YunKen\Reports\EmployeeExamineReport.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="Pages\B3YunKen\Reports\LogisticsAnalysisReport.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
@ -266,7 +269,12 @@
<EmbeddedResource Include="Pages\B3YunKen\Dialogs\ReturnApplication_CustomerAcceptDialog.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\B3YunKen\Reports\YunKenStoreDetailQuery.xml" />
<EmbeddedResource Include="Pages\B3YunKen\Reports\YunKenStoreDetailQuery.xml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\B3YunKen\Reports\EmployeeExamineReport.xml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.


+ 6
- 0
BWP.B3_YunKen.Web/BWP.B3_YunKen.Web.csproj.user View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

+ 238
- 0
BWP.B3_YunKen.Web/Pages/B3YunKen/Reports/EmployeeExamineReport.cs View File

@ -0,0 +1,238 @@
using BWP.B3Frameworks;
using BWP.B3Frameworks.BO.NamedValueTemplate;
using BWP.Web.Layout;
using BWP.Web.Utils;
using BWP.Web.WebControls;
using Forks.EnterpriseServices.DataForm;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TSingSoft.WebControls2;
using BWP.B3Butchery.BO;
using BWP.B3ProduceUnitedInfos;
using BWP.B3UnitedInfos;
using BWP.B3UnitedInfos.BO;
using BWP.B3Sale.Utils;
using BWP.B3Sale.BO;
using BWP.B3Frameworks.BO;
using Forks.Utils;
using BWP.B3Frameworks.BO.MoneyTemplate;
namespace BWP.Web.Pages.B3YunKen.Reports
{
class EmployeeExamineReport : DFBrowseGridReportPage<CustomerAccept>
{
protected override string Caption
{
get { return "业务员考核表"; }
}
protected override string QueryOptionsTabName
{
get
{
return "显示字段";
}
}
protected override string AccessRoleName
{
get { return "B3_YunKen.报表分析.业务员考核表"; }
}
readonly Dictionary<string, DFInfo> _fileInfo = new Dictionary<string, DFInfo>();
readonly List<string> _sumCol = new List<string>();
protected override void AddQueryControls(VLayoutPanel vPanel)
{
var layout = new LayoutManager("Main", mDFInfo, mQueryContainer);
layout.Add("LoadTime", new SimpleLabel("到货时间"), QueryCreator.DateRange(mDFInfo.Fields["ID"], mQueryContainer, "MinLoadTime", "MaxLoadTime"));
layout["LoadTime"].NotAutoAddToContainer = true;
layout.Add("AccountingUnit_ID", new SimpleLabel("会计单位"), QueryCreator.DFChoiceBoxEnableMultiSelection(mDFInfo.Fields["AccountingUnit_ID"], mQueryContainer, "AccountingUnit_ID", B3FrameworksConsts.DataSources.));
layout["AccountingUnit_ID"].NotAutoAddToContainer = true;
layout.Add("Employee_ID", new SimpleLabel("业务员"), QueryCreator.DFChoiceBoxEnableMultiSelection(mDFInfo.Fields["Employee_ID"], mQueryContainer, "Employee_ID", B3FrameworksConsts.DataSources.));
layout["Employee_ID"].NotAutoAddToContainer = true;
var config = new AutoLayoutConfig { Cols = 2 };
config.Add("LoadTime");
config.Add("AccountingUnit_ID");
config.Add("Employee_ID");
layout.Config = config;
vPanel.Add(layout.CreateLayout());
}
ReportDisplayOptionHelper mDisplayHelper = new ReportDisplayOptionHelper();
protected override void AddQueryOptions(VLayoutPanel vPanel)
{
mDisplayHelper.AddOptionItem("单号", "main", "ID", false);
mDisplayHelper.AddOptionItem("业务员", "main", "Employee_Name", false);
mDisplayHelper.AddOptionItem("购货客户", "main", "Customer_Name", false);
mDisplayHelper.AddOptionItem("会计单位", "main", "AccountingUnit_Name", false);
mDisplayHelper.AddOptionItem("验收金额", "main", "Money", false, false);
mDisplayHelper.AddOptionItem("发货时间", "main", "LoadTime", false);
mDisplayHelper.AddOptionItem("最近一次核销时间", "gatheringTimeData", "GatheringTime", false);
mDisplayHelper.AddOptionItem("账期天数", "cus", "CreditDays", false);
mDisplayHelper.AddOptionItem("账期阶段", () => {
return DQExpression.Snippet<int>("ceiling(cast((datediff(dd,main.LoadTime,getdate())-isNull(cus.CreditDays,0)) as decimal(18,2))/5)");
}, false);
mDisplayHelper.AddOptionItem("超期天数", () => {
return DQExpression.Snippet<int>("datediff(dd,main.LoadTime,getdate())");
}, false);
mDisplayHelper.AddOptionItem("已扣罚金额", () => { return DQExpression.Value(0); }, false,true,false);
mDisplayHelper.AddOptionItem("本次扣罚金额", () => { return DQExpression.Value(0); }, false, true, false);
mDisplayHelper.AddOptionItem("总扣罚金额", () => { return DQExpression.Value(0); }, false, true, false);
mDisplayHelper.AddOptionItem("时间段扣罚金额", () => { return DQExpression.Value(0); }, false, true, false);
AddQueryOption("选项", mDisplayHelper.GetAllDisplayNames(), mDisplayHelper.GetDefaultSelelectedDisplayNames());
base.AddQueryOptions(vPanel);
}
protected override void CreateDFBrowseGridColumns(DFBrowseGrid grid)
{
grid.Columns.Add(new DFBrowseGridAutoColumn());
grid.DataFilter = delegate(DFDataTable tbl) {
using (IDmoSession session = Dmo.NewSession()) {
var minDate = mQueryContainer.GetControl<DFDateInput>("MinLoadTime");
var maxDate = mQueryContainer.GetControl<DFDateInput>("MaxLoadTime");
for (int i = 0; i < tbl.Rows.Count; i++) {
DFDataRow row = tbl.Rows[i];
var id = (long?)row["单号"];
var money = (Money<>?)row["验收金额"];
int num = Convert.ToInt32(Math.Truncate(Convert.ToDouble(row["账期阶段"] ?? 0)));
long? days = (long?)row["账期天数"];
DateTime? loadTime = (DateTime?)row["发货时间"];
if (loadTime == null)
continue;
row["已扣罚金额"] = GetSumMoney((num - 1), money, session,id,days,loadTime, false);
row["本次扣罚金额"] = GetSumMoney(num, money, session,id,days,loadTime, true);
row["总扣罚金额"] = GetSumMoney(num, money, session,id,days,loadTime, false);
//时间段 初末 值分别是哪个账期
if(!minDate.IsEmpty){
TimeSpan ts = minDate.Value.Value - loadTime.Value;
int result = Convert.ToInt32(Math.Truncate(Convert.ToDouble((ts.Days - (days??0))/5)));
var min = GetSumMoney(result, money, session, id, days, loadTime, false);
TimeSpan ts2 = maxDate.Value.Value - loadTime.Value;
int result2 = Convert.ToInt32(Math.Truncate(Convert.ToDouble((ts2.Days - (days ?? 0)) / 5)));
var max = GetSumMoney(result2, money, session, id, days, loadTime, false);
row["时间段扣罚金额"] = (max??0) - (min??0);
}
}
GetSumValue(tbl, "已扣罚金额");
GetSumValue(tbl, "本次扣罚金额");
GetSumValue(tbl, "总扣罚金额");
GetSumValue(tbl, "时间段扣罚金额");
}
};
}
public void GetSumValue(DFDataTable tbl, string cName)
{
var sum1 = tbl.Rows.Sum(row => {
if (row[cName] == null) return 0;
return Convert.ToDecimal(row[cName]);
});
tbl.SumRow[cName] = sum1;
}
private int GetRange(long? AccountBill_ID, string date, IDmoSession session)
{
var dom = new DQueryDom(new JoinAlias(typeof(CustomerAccept)));
dom.Columns.Add(DQSelectColumn.Create(DQExpression.Snippet<int>("ceiling(cast((datediff(dd,LoadTime,'" + date + "')-isNull(Days,0)) as decimal(18,2))/5)"), "RangeNumber"));
dom.GroupBy.Expressions.Add(DQExpression.Field("LoadTime"));
dom.GroupBy.Expressions.Add(DQExpression.Field("Days"));
dom.Where.Conditions.Add(DQCondition.EQ("AccountBill_ID", AccountBill_ID));
using (var reader = session.ExecuteReader(dom)) {
if (reader.Read()) {
return Convert.ToInt32(reader[0]);
}
return 0;
}
}
/// <summary>
/// 传入参数第几个账期
/// </summary>
private Money<>? GetSumMoney(int? count, Money<>? money, IDmoSession session, long? id, long? days, DateTime? loadTime, bool isLast)
{
Money<>? sumMoney = 0;
for (int i = 0; i < (count ?? 0); i++) {
if (isLast) {
i = (count ?? 0) - 1;
}
var result = (days??0) + (i*5);
loadTime.Value.AddDays(result);
var invoiceInfo = new JoinAlias(typeof(InvoiceInfo));
var gathering = new JoinAlias(typeof(Gathering));
var dom = new DQueryDom(invoiceInfo);
dom.From.AddJoin(JoinType.Left, new DQDmoSource(gathering), DQCondition.EQ(invoiceInfo, "Gathering_ID",gathering,"ID"));
dom.Columns.Add(DQSelectColumn.Sum(invoiceInfo,"Money"));
dom.Where.Conditions.Add(DQExpression.LessThanOrEqual(DQExpression.Field(gathering,"GatheringTime"),DQExpression.Value(loadTime)));
dom.Where.Conditions.Add(DQCondition.EQ(invoiceInfo,"BillID", id));
dom.Where.Conditions.Add(DQCondition.EQ(invoiceInfo, "DmoTypeID", DmoTypeIDAttribute.GetID(typeof(CustomerAccept))));
dom.Where.Conditions.Add(DQCondition.EQ(gathering,"BillState", .));
using (var reader = session.ExecuteReader(dom)) {
decimal sum = 0;
while (reader.Read()) {
if (reader[0] != null) {
sum = Convert.ToDecimal(reader[0]);//已收款金额累计
}
}
Money<>? noCancelMoney = money - sum;
if (i == 0) {
sumMoney = sumMoney + noCancelMoney * 4 / 10000;
} else {
sumMoney = sumMoney + noCancelMoney * 1 / 10000;
}
}
}
return sumMoney;
}
private DQueryDom GetGatheringTime()
{
var bill = new JoinAlias(typeof(Gathering));
var detail = new JoinAlias(typeof(InvoiceInfo));
var query = new DQueryDom(bill);
query.From.AddJoin(JoinType.Inner, new DQDmoSource(detail), DQCondition.EQ(bill, "ID", detail, "Gathering_ID"));
query.Columns.Add(DQSelectColumn.Max("GatheringTime"));
query.Columns.Add(DQSelectColumn.Field("BillID",detail));
query.Where.Conditions.Add(DQCondition.EQ(detail, "DmoTypeID",DmoTypeIDAttribute.GetID(typeof(CustomerAccept))));
query.Where.Conditions.Add(DQCondition.EQ("BillState", .));
query.Where.Conditions.Add(DQCondition.EQ("Domain_ID", DomainContext.Current.ID));
query.GroupBy.Expressions.Add(DQExpression.Field(detail,"BillID"));
return query;
}
class GatheringTimeData
{
public DateTime? GatheringTime { get; set; }
public long? BillID { get; set; }
}
protected override DQueryDom GetQueryDom()
{
var query = base.GetQueryDom();
var main = query.From.RootSource.Alias;
mDisplayHelper.AddAlias("main", main);
var gatheringTimeData = new JoinAlias("gatheringTimeData", typeof(GatheringTimeData));
mDisplayHelper.AddAlias("gatheringTimeData", gatheringTimeData);
var cus = new JoinAlias("cus", typeof(Customer));
mDisplayHelper.AddAlias("cus", cus);
query.RegisterQueryTable(typeof(GatheringTimeData), new string[] { "GatheringTime", "BillID" }, GetGatheringTime());
query.From.AddJoin(JoinType.Left, new DQDmoSource(gatheringTimeData), DQCondition.EQ(main, "ID", gatheringTimeData, "BillID"));
query.From.AddJoin(JoinType.Left, new DQDmoSource(cus), DQCondition.EQ(main, "Customer_ID", cus, "ID"));
//query.Columns.Add(DQSelectColumn.Field("Money",main));
//query.Columns.Add(DQSelectColumn.Field("LoadTime", main));
//query.GroupBy.Expressions.Add(DQExpression.Field(main,"LoadTime"));
//query.GroupBy.Expressions.Add(DQExpression.Field(main, "Money"));
mDisplayHelper.AddSelectColumns(query, (name) => OptionIsSelected("选项", name), SumColumnIndexs);
return query;
}
}
}

+ 30
- 0
BWP.B3_YunKen.Web/Pages/B3YunKen/Reports/EmployeeExamineReport.xml View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<Select xmlns="urn:XDQuery">
<Columns>
<Field name="ID"/>
</Columns>
<From>
<DmoClass class="BWP.B3Sale.BO.CustomerAccept, B3Sale" alias="main"/>
</From>
<Where>
<And>
<QBEIn>
<Field name="AccountingUnit_ID"/>
<QBE paramName="AccountingUnit_ID"/>
</QBEIn>
<QBEIn>
<Field name="Employee_ID"/>
<QBE paramName="Employee_ID"/>
</QBEIn>
<GreaterThanOrEqual>
<Field name="LoadTime"/>
<QBE paramName="MinLoadTime" />
</GreaterThanOrEqual>
<LessThanOrEqual>
<Field name="LoadTime"/>
<QBE paramName="MaxLoadTime"/>
</LessThanOrEqual>
</And>
</Where>
</Select>

+ 2
- 0
WebFolder/Config/Plugins/B3_YunKen.Plugin View File

@ -44,6 +44,7 @@
<Function index="3" name="变价关系表" />
<Function index="4" name="去运费净价表_验收" />
<Function index="5" name="耘垦库存查询" />
<Function index="6" name="业务员考核表" />
</FunctionGroup>
<FunctionGroup name="耘垦销售出库转验收单" roleSchemas="employee">
<Function index="0" name="访问" />
@ -62,6 +63,7 @@
<Menu id="0010" name="/B3耘垦模块/报表分析/变价关系表" roles="B3_YunKen.报表分析.变价关系表" url="B3YunKen/Reports/DynamicPriceReport.aspx"/>
<Menu id="0011" name="/B3耘垦模块/报表分析/去运费净价表_验收" roles="B3_YunKen.报表分析.去运费净价表_验收" url="B3YunKen/Reports/ToFreightNetPriceReport2.aspx"/>
<Menu id="0012" name="/B3耘垦模块/报表分析/耘垦库存查询" roles="B3_YunKen.报表分析.耘垦库存查询" url="B3YunKen/Reports/YunKenStoreDetailQuery.aspx"/>
<Menu id="0013" name="/B3耘垦模块/报表分析/业务员考核表" roles="B3_YunKen.报表分析.业务员考核表" url="B3YunKen/Reports/EmployeeExamineReport.aspx"/>
</Menus>
</Plugin>

Loading…
Cancel
Save