Commit 93020b66 by 陶然

优化

parent 83a477b1
...@@ -21,6 +21,7 @@ namespace Kivii.Finances.Entities ...@@ -21,6 +21,7 @@ namespace Kivii.Finances.Entities
public decimal AmountPayment { get; set; } public decimal AmountPayment { get; set; }
public decimal AmountNotSplit { get; set; }
public decimal AmountSplit { get; set; } public decimal AmountSplit { get; set; }
public decimal AmountRefund { get; set; } public decimal AmountRefund { get; set; }
...@@ -46,6 +47,7 @@ namespace Kivii.Finances.Entities ...@@ -46,6 +47,7 @@ namespace Kivii.Finances.Entities
public int QuantityPayment { get; set; } public int QuantityPayment { get; set; }
public int QuantityNotSplit { get; set; }
public int QuantitySplit { get; set; } public int QuantitySplit { get; set; }
public int QuantityRefund { get; set; } public int QuantityRefund { get; set; }
...@@ -59,13 +61,17 @@ namespace Kivii.Finances.Entities ...@@ -59,13 +61,17 @@ namespace Kivii.Finances.Entities
public int QuantityOffset { get; set; } public int QuantityOffset { get; set; }
public AnalysisType Type { get; set; } public AnalysisType AnalysisType { get; set; }
public DateTime BeginTime { get; set; } public DateTime BeginTime { get; set; }
public DateTime EndTime { get; set; } public DateTime EndTime { get; set; }
public string Type { get; set; }
public string Summary { get; set; } public string Summary { get; set; }
public string Remark { get; set; }
} }
/// <summary> /// <summary>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>..\..\..\..\njzj.k5\appextend\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
...@@ -31,14 +31,17 @@ ...@@ -31,14 +31,17 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Kivii.Common.V4.5, Version=5.6.2022.7200, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Kivii.Common.V4.5, Version=5.6.2022.10000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Kivii.Common.5.6.2022.7200\lib\net45\Kivii.Common.V4.5.dll</HintPath> <HintPath>..\..\..\..\njzj.k5\packages\Kivii.Common.5.6.2022.10000\lib\net45\Kivii.Common.V4.5.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="Kivii.Core.V4.5, Version=5.6.2022.7200, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Kivii.Core.V4.5, Version=5.6.2022.10250, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Kivii.Core.5.6.2022.7200\lib\net45\Kivii.Core.V4.5.dll</HintPath> <HintPath>..\..\..\..\njzj.k5\packages\Kivii.Core.5.6.2022.10250\lib\net45\Kivii.Core.V4.5.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="Kivii.Linq.V4.5, Version=5.6.2022.7000, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Kivii.Linq.V4.5, Version=5.6.2022.12000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Kivii.Linq.5.6.2022.7000\lib\net45\Kivii.Linq.V4.5.dll</HintPath> <HintPath>..\..\..\..\njzj.k5\packages\Kivii.Linq.5.6.2022.12000\lib\net45\Kivii.Linq.V4.5.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
...@@ -249,7 +252,6 @@ ...@@ -249,7 +252,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Content\Kivii.Biz.Finances.lnk" /> <EmbeddedResource Include="Content\Kivii.Biz.Finances.lnk" />
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Content\codes\Classic.Control.Kivii.Finances.Account.Pay.List.js" /> <EmbeddedResource Include="Content\codes\Classic.Control.Kivii.Finances.Account.Pay.List.js" />
...@@ -270,5 +272,8 @@ ...@@ -270,5 +272,8 @@
<EmbeddedResource Include="Content\Scripts\element-ui.js" /> <EmbeddedResource Include="Content\Scripts\element-ui.js" />
<EmbeddedResource Include="Content\Scripts\vue_2_6_14.js" /> <EmbeddedResource Include="Content\Scripts\vue_2_6_14.js" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -3,4 +3,9 @@ ...@@ -3,4 +3,9 @@
<PropertyGroup> <PropertyGroup>
<ProjectView>ProjectFiles</ProjectView> <ProjectView>ProjectFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartAction>Program</StartAction>
<StartProgram>D:\njzj.k5\Startup.exe</StartProgram>
<StartArguments>-debug</StartArguments>
</PropertyGroup>
</Project> </Project>
\ No newline at end of file
...@@ -33,5 +33,5 @@ using System.Runtime.InteropServices; ...@@ -33,5 +33,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2021.12280")] [assembly: AssemblyVersion("5.4.2022.12070")]
[assembly: AssemblyFileVersion("5.4.2021.12280")] [assembly: AssemblyFileVersion("5.4.2022.12070")]
...@@ -393,4 +393,101 @@ namespace Kivii.Finances.Transforms ...@@ -393,4 +393,101 @@ namespace Kivii.Finances.Transforms
return rtns; return rtns;
} }
} }
[Api(Description = "到账所属")]
[RequiresAnyRole(SystemRoles.Everyone)]
public class PaymentSetOwner : RestfulExecution<Payment>
{
public OwnerType OwnerType { get; set; } = OwnerType.Department;
public Guid OwnerKvid { get; set; }
public string OwnerName { get; set; }
public List<Guid> Kvids { get; set; }
public string Remark { get; set; }
public override object OnExecution(IRequest req, IResponse res)
{
if (Kvids.IsNullOrEmpty()) throw new Exception("请选择要标记所属部门的收款!");
var conn = KiviiContext.GetOpenedDbConnection<Payment>();
var payments = conn.SelectByIds<Payment>(Kvids);
if (payments == null) throw new Exception("收款不存在!");
if (payments.Exists(o => o.Type != PaymentType.Bank)) throw new Exception("非银行到账不可继续操作!");
if (payments.Exists(o => o.OffsetKvid != Guid.Empty)) throw new Exception("已作废收款不可继续操作!");
var paymentKvids = payments.ConvertAll(o => o.Kvid);
if (OwnerKvid == Guid.Empty)
{
switch (OwnerType)
{
case OwnerType.Department:
{
OwnerKvid = KiviiContext.CurrentMember.DepartmentKvid;
OwnerName = KiviiContext.CurrentMember.DepartmentName;
break;
}
case OwnerType.Organization:
{
OwnerKvid = KiviiContext.CurrentMember.OrganizationKvid;
OwnerName = KiviiContext.CurrentMember.OrganizationName;
break;
}
case OwnerType.Member:
{
OwnerKvid = KiviiContext.CurrentMember.Kvid;
OwnerName = KiviiContext.CurrentMember.FullName;
break;
}
}
}
var rtns = new RestfulExecutionResponse<Payment>();
rtns.Results = new List<Payment>();
var updateLamda = conn.From<Payment>();
updateLamda = updateLamda.Update(o => new { o.OwnerKvid, o.OwnerName, o.BizId });
updateLamda = updateLamda.Where(o => Sql.In(o.Kvid, paymentKvids));
conn.UpdateOnly(new Payment { OwnerKvid = OwnerKvid, OwnerName = OwnerName, BizId = Remark }, updateLamda);
foreach (var item in payments)
{
item.OwnerName = OwnerName;
item.OwnerKvid = OwnerKvid;
item.BizId = Remark;
}
rtns.Results.AddRange(payments);
return rtns;
}
}
[Api(Description = "清除到账所属")]
[RequiresAnyRole(SystemRoles.Everyone)]
public class PaymentCleanOwner : RestfulExecution<Payment>
{
public List<Guid> Kvids { get; set; }
public override object OnExecution(IRequest req, IResponse res)
{
if (Kvids.IsNullOrEmpty()) throw new Exception("请选择要标记所属部门的收款!");
var conn = KiviiContext.GetOpenedDbConnection<Payment>();
var payments = conn.SelectByIds<Payment>(Kvids);
if (payments == null) throw new Exception("收款不存在!");
if (payments.Exists(o => o.Type != PaymentType.Bank)) throw new Exception("非银行到账不可继续操作!");
if (payments.Exists(o => o.OffsetKvid != Guid.Empty)) throw new Exception("已作废收款不可继续操作!");
var paymentKvids = payments.ConvertAll(o => o.Kvid);
var rtns = new RestfulExecutionResponse<Payment>();
rtns.Results = new List<Payment>();
var updateLamda = conn.From<Payment>();
updateLamda = updateLamda.Update(o => new { o.OwnerKvid, o.OwnerName});
updateLamda = updateLamda.Where(o => Sql.In(o.Kvid, paymentKvids));
conn.UpdateOnly(new Payment { OwnerKvid = Guid.Empty, OwnerName = string.Empty }, updateLamda);
foreach (var item in payments)
{
item.OwnerName = string.Empty;
item.OwnerKvid = Guid.Empty;
}
rtns.Results.AddRange(payments);
return rtns;
}
}
} }
...@@ -27,19 +27,19 @@ namespace Kivii.Finances.Transforms ...@@ -27,19 +27,19 @@ namespace Kivii.Finances.Transforms
Items.Exists(o => o.PayerName.IsNullOrEmpty()).ThrowIfTrue("付款单位不能为空!"); Items.Exists(o => o.PayerName.IsNullOrEmpty()).ThrowIfTrue("付款单位不能为空!");
Items.Exists(o => o.Currency == CurrencyUnit.Unsupported).ThrowIfTrue("不支持的货币单位!"); Items.Exists(o => o.Currency == CurrencyUnit.Unsupported).ThrowIfTrue("不支持的货币单位!");
Items.Exists(o => o.Details.IsNullOrEmpty()).ThrowIfTrue("结算明细不能为空!"); Items.Exists(o => o.Details.IsNullOrEmpty()).ThrowIfTrue("结算明细不能为空!");
//var bizKvids = Items.ConvertAll(p => p.BizKvid); var bizKvids = Items.ConvertAll(p => p.BizKvid);
//bizKvids.RemoveAll(o => o == Guid.Empty); bizKvids.RemoveAll(o => o == Guid.Empty);
var bizids = Items.ConvertAll(p => p.BizId); var bizids = Items.ConvertAll(p => p.BizId).Distinct().ToList();
bizids.RemoveAll(o => o.IsNullOrEmpty()); bizids.RemoveAll(o => o.IsNullOrEmpty());
var connF = KiviiContext.GetOpenedDbConnection<Settlement>(); var connF = KiviiContext.GetOpenedDbConnection<Settlement>();
foreach (var bizId in bizids) //foreach (var bizId in bizids)
{ //{
if (connF.Exists<Settlement>(o => o.OffsetKvid == Guid.Empty && o.BizId == bizId)) throw new Exception($"{bizId}重复结算的对象!"); // if (connF.Exists<Settlement>(o => o.OffsetKvid == Guid.Empty && o.BizId == bizId)) throw new Exception($"{bizId}重复结算的对象!");
} //}
//if (connF.Exists<Settlement>(o => o.OffsetKvid == Guid.Empty && (Sql.In(o.BizKvid, bizKvids) || Sql.In(o.BizId, bizids)))) throw new Exception("存在重复结算的对象!"); if (connF.Exists<Settlement>(o => o.OffsetKvid == Guid.Empty && (Sql.In(o.BizKvid, bizKvids) || Sql.In(o.BizId, bizids)))) throw new Exception("存在重复结算的对象!");
var connE = KiviiContext.GetOpenedDbConnection<G>(); var connE = KiviiContext.GetOpenedDbConnection<G>();
////如果泛型类型不是Settlement本身就需要判断 //如果泛型类型不是Settlement本身就需要判断
//if (typeof(G) != typeof(Settlement)) connE.Exists<EntitySettlement<G>>(o => o.OffsetKvid == Guid.Empty && Sql.In(o.BizId, bizids)).ThrowIfTrue("存在重复结算的对象!"); if (typeof(G) != typeof(Settlement)) connE.Exists<EntitySettlement<G>>(o => o.OffsetKvid == Guid.Empty && Sql.In(o.BizId, bizids)).ThrowIfTrue("存在重复结算的对象!");
//var allDetails = new List<SettlementDetail>(); //var allDetails = new List<SettlementDetail>();
//Items.ForEach(o => allDetails.AddRange(o.Details)); //Items.ForEach(o => allDetails.AddRange(o.Details));
//var detailBizKvids = allDetails.ConvertAll(p => p.BizKvid); //var detailBizKvids = allDetails.ConvertAll(p => p.BizKvid);
...@@ -371,8 +371,8 @@ namespace Kivii.Finances.Transforms ...@@ -371,8 +371,8 @@ namespace Kivii.Finances.Transforms
var sqlExpress = autoQuery.CreateQuery(Request, conn, request, dynamicParams); var sqlExpress = autoQuery.CreateQuery(Request, conn, request, dynamicParams);
if (IsPayed != null) if (IsPayed != null)
{ {
if (IsPayed.Value) sqlExpress.And(o => o.AmountPayment == o.Amount); if (IsPayed.Value) sqlExpress.And(o => o.AmountPayment == o.Amount || o.Amount == 0);
else sqlExpress.And(o => o.AmountPayment < o.Amount || o.AmountPayment <= 0); else sqlExpress.And(o => o.Amount != 0 && (o.AmountPayment < o.Amount || o.AmountPayment <= 0));
} }
if (IsBilled != null) if (IsBilled != null)
{ {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using Kivii.Linq; using Kivii.Linq;
using Kivii.Web; using Kivii.Web;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -202,4 +203,96 @@ namespace Kivii.Finances.Transforms ...@@ -202,4 +203,96 @@ namespace Kivii.Finances.Transforms
return rtns; return rtns;
} }
} }
[Api(Description = "部门流水划拨分析")]
[RequiresAnyRole(SystemRoles.Everyone)]
public class PaymentOwneSplitedAnalysis : RestfulExecution<Payment>
{
public Guid OwnerKvid { get; set; }
public List<Guid> OwnerKvids { get; set; }
public DateTime BeginTime { get; set; }
public DateTime EndTime { get; set; }
public bool IsDetail { get; set; }//如果是查询明细,就按照部门把划拨到各个部门的流水列出来,如果不是查明细就查当前部门流水的划拨情况,划拨了多少,待划拨多少
public override object OnExecution(IRequest req, IResponse res)
{
//(OwnerKvid == Guid.Empty).ThrowIfTrue("请传入部门信息以统计划拨统计");
int monthDay = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
if (BeginTime == DateTime.MinValue) BeginTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
if (EndTime == DateTime.MinValue) EndTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, monthDay);
var beginTime = DateTime.Parse(BeginTime.ToString("yyyy-MM-dd"));
var endTime = DateTime.Parse(EndTime.ToString("yyyy-MM-dd"));
if (endTime < beginTime) throw new Exception("查询结束日期不可小于开始日期!");
if (endTime == beginTime) endTime = endTime.AddDays(1);
var rtns = new StatisticResponse<Analysis>();
rtns.BeginTime = BeginTime;
rtns.EndTime = EndTime;
if (OwnerKvids.IsNullOrEmpty()) OwnerKvids = new List<Guid>();
if (OwnerKvid != Guid.Empty) OwnerKvids.Add(OwnerKvid);
if (OwnerKvids.IsNullOrEmpty()) OwnerKvids.AddRange(KiviiContext.CurrentMember.DepartmentKvids);
var conn = KiviiContext.GetOpenedDbConnection<Payment>();
var queryAccount = conn.From<Account>();
queryAccount.Where(o => o.OrganizationKvid == KiviiContext.CurrentMember.OrganizationKvid && Sql.In(o.Type, AccountType.Balance, AccountType.Cash, AccountType.Pos));
queryAccount.Select(o => o.Kvid);
var queryRoot = conn.From<Payment>();
queryRoot.Where(o => o.OffsetKvid == Guid.Empty && o.Type == PaymentType.Bank && Sql.In(o.OwnerKvid, OwnerKvids) && Sql.In(o.PayerAccountKvid, queryAccount) && o.OperateTime >= beginTime && o.OperateTime < endTime);
//如果是查询明细,就按照部门把划拨到各个部门的流水列出来,如果不是查明细就查当前部门流水的划拨情况,划拨了多少,待划拨多少
if (IsDetail)
{
queryRoot.Select(o => o.Kvid);
var query = conn.From<Payment>();
query.Where(o => o.OffsetKvid == Guid.Empty && Sql.In(o.Type, PaymentType.Refund, PaymentType.UnBiz, PaymentType.Split) && Sql.In(o.ParentKvid, queryRoot));
query.GroupBy(o => new { o.OwnerName, o.Type });
query.Select(o => new
{
Summary = o.OwnerName,
Type = o.Type,
Quantity = Sql.Count(o.Kvid),
Amount = Sql.Sum(o.Amount),
AmountInvoice = Sql.Sum(o.AmountInvoice),
QuantityInvoice = Sql.Sum(o.Amount == o.AmountInvoice ? 1 : 0),
AmountNotInvoice = Sql.Sum(o.Amount - o.AmountInvoice),
QuantityNotInvoice = Sql.Sum(o.AmountInvoice < o.Amount ? 1 : 0),
AmountUsed = Sql.Sum(o.AmountUsed),
QuantityUsed = Sql.Sum(o.Amount == o.AmountUsed ? 1 : 0),
AmountNotUsed = Sql.Sum(o.Amount - o.AmountUsed),
QuantityNotUsed = Sql.Sum(o.AmountUsed < o.Amount ? 1 : 0)
});
rtns.Results = conn.Select<Analysis>(query);
}
else
{
queryRoot.GroupBy(o => o.OwnerName);
queryRoot.Select(o => new
{
Summary = o.OwnerName,
Quantity = Sql.Count(o.Kvid),
Amount = Sql.Sum(o.Amount),
AmountSplit = Sql.Sum(o.AmountSplited),
QuantitySplit = Sql.Sum(o.Amount == o.AmountSplited ? 1 : 0),
AmountNotSplit = Sql.Sum(o.Amount - o.AmountSplited),
QuantityNotSplit = Sql.Sum(o.AmountSplited < o.Amount ? 1 : 0),
AmountInvoice = Sql.Sum(o.AmountInvoice),
QuantityInvoice = Sql.Sum(o.Amount == o.AmountInvoice ? 1 : 0),
AmountNotInvoice = Sql.Sum(o.Amount - o.AmountInvoice),
QuantityNotInvoice = Sql.Sum(o.AmountInvoice < o.Amount ? 1 : 0),
AmountUsed = Sql.Sum(o.AmountUsed),
QuantityUsed = Sql.Sum(o.Amount == o.AmountUsed ? 1 : 0),
AmountNotUsed = Sql.Sum(o.Amount - o.AmountUsed),
QuantityNotUsed = Sql.Sum(o.AmountUsed < o.Amount ? 1 : 0)
});
rtns.Results = conn.Select<Analysis>(queryRoot);
}
rtns.Total = rtns.Results.Count();
return rtns;
}
}
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Kivii.Common" version="5.6.2022.7200" targetFramework="net45" /> <package id="Kivii.Common" version="5.6.2022.10000" targetFramework="net45" />
<package id="Kivii.Core" version="5.6.2022.7200" targetFramework="net45" /> <package id="Kivii.Core" version="5.6.2022.10250" targetFramework="net45" />
<package id="Kivii.Linq" version="5.6.2022.7000" targetFramework="net45" /> <package id="Kivii.Linq" version="5.6.2022.12000" targetFramework="net45" />
</packages> </packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment