Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Biz.Finances.V2.0
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶然
Kivii.Biz.Finances.V2.0
Commits
e75d3231
Commit
e75d3231
authored
Sep 04, 2023
by
陶然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化使用到了Cache的接口
parent
cf5a051b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
87 deletions
+145
-87
AssemblyInfo.cs
Src/Properties/AssemblyInfo.cs
+2
-2
RestfulInvoice.cs
Src/Transforms/RestfulInvoice.cs
+24
-14
RestfulPay.cs
Src/Transforms/RestfulPay.cs
+25
-17
RestfulPayment.Accept.cs
Src/Transforms/RestfulPayment.Accept.cs
+24
-14
RestfulPayment.Split.cs
Src/Transforms/RestfulPayment.Split.cs
+45
-27
RestfulSettlement.cs
Src/Transforms/RestfulSettlement.cs
+25
-13
No files found.
Src/Properties/AssemblyInfo.cs
View file @
e75d3231
...
...
@@ -33,5 +33,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2023.
419
0")]
[assembly: AssemblyFileVersion("5.4.2023.
419
0")]
[assembly: AssemblyVersion("5.4.2023.
904
0")]
[assembly: AssemblyFileVersion("5.4.2023.
904
0")]
Src/Transforms/RestfulInvoice.cs
View file @
e75d3231
...
...
@@ -264,6 +264,22 @@ namespace Kivii.Finances.Transforms
(
Payments
.
Exists
(
o
=>
o
.
Amount
<=
0
)).
ThrowIfTrue
(
"未指定到账开票金额!"
);
(
Payments
.
Sum
(
o
=>
o
.
Amount
)
!=
Items
.
Sum
(
o
=>
o
.
Amount
)).
ThrowIfTrue
(
"到账开票金额和发票金额不一致!"
);
}
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
int
?>(
cacheKey
);
if
(
cacheValue
!=
null
)
{
if
(
cacheValue
<
0
)
throw
new
Exception
(
$"仍在处理中,请稍后查看结果!"
);
else
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
}
条,请稍后查看结果!"
);
}
int
?
caches
=
Items
.
Count
;
//caches.AddRange(Items.ConvertAll(o => o.SerialNumber));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
try
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Invoice
>();
//var exists = conn.Select<Invoice>(o => Sql.In(o.SerialNumber, Items.ConvertAll(p => p.SerialNumber)));
//(conn.Exists<Invoice>(o => Sql.In(o.SerialNumber, Items.ConvertAll(p => p.SerialNumber)))).ThrowIfTrue("存在重复录入的发票信息");
...
...
@@ -321,7 +337,7 @@ namespace Kivii.Finances.Transforms
invoice
.
Type
=
info
.
Type
;
invoice
.
Category
=
info
.
Category
.
IsNullOrEmpty
()
?
category
.
ToString
()
:
info
.
Category
;
invoice
.
OperateTime
=
info
.
OperateTime
;
invoice
.
SerialCode
=
info
.
SerialCode
;
invoice
.
SerialCode
=
info
.
SerialCode
;
invoice
.
SerialNumber
=
info
.
SerialNumber
;
//invoice.Status = 1;
invoice
.
TaxRate
=
info
.
TaxRate
;
...
...
@@ -380,18 +396,6 @@ namespace Kivii.Finances.Transforms
}
var
rtns
=
new
RestfulUpdateResponse
<
Invoice
>();
rtns
.
Results
=
new
List
<
Invoice
>();
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
insertInvoices
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
var
trans
=
conn
.
OpenTransaction
();
try
{
...
...
@@ -402,7 +406,7 @@ namespace Kivii.Finances.Transforms
if
(
item
.
Type
==
"Relation"
)
item
.
SerialNumber
=
item
.
GetSubSerialNumber
(
conn
);
conn
.
Insert
(
item
);
if
(
item
.
Type
!=
"Relation"
)
rtns
.
Results
.
Add
(
item
);
caches
.
Remove
(
item
.
SerialNumber
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
}
...
...
@@ -426,5 +430,11 @@ namespace Kivii.Finances.Transforms
throw
ex
;
}
}
catch
(
Exception
ex
)
{
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
}
}
Src/Transforms/RestfulPay.cs
View file @
e75d3231
...
...
@@ -27,7 +27,22 @@ namespace Kivii.Finances.Transforms
PayingMethods
.
Exists
(
o
=>
o
.
Kvid
==
Guid
.
Empty
).
ThrowIfTrue
(
"付款登记Kvid不能为空!"
);
(
PayingMethods
.
Count
(
o
=>
o
.
Type
==
PayType
.
Discount
)
>
1
).
ThrowIfTrue
(
"金额抵扣登记方式超过限制次数,仅可使用一次"
);
var
amountMethod
=
PayingMethods
.
Sum
(
o
=>
o
.
Amount
);
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
int
?>(
cacheKey
);
if
(
cacheValue
!=
null
)
{
if
(
cacheValue
<
0
)
throw
new
Exception
(
$"仍在处理中,请稍后查看结果!"
);
else
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
}
条,请稍后查看结果!"
);
}
int
?
caches
=
SettlementKvids
.
Count
;
//caches.AddRange(Items.ConvertAll(o => o.SerialNumber));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
try
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Pay
>();
var
settlements
=
conn
.
Select
<
Settlement
>(
o
=>
Sql
.
In
(
o
.
Kvid
,
SettlementKvids
));
settlements
.
ThrowIfNullOrEmpty
(
"未找到结算单!"
);
...
...
@@ -49,19 +64,6 @@ namespace Kivii.Finances.Transforms
var
accountBiz
=
currency
.
GetBizAccount
();
//conn.Single<Account>(o => o.OwnerKvid == KiviiContext.CurrentMember.OrganizationKvid && o.Type == AccountType.Biz && o.Currency == Item.Currency);
accountBiz
.
ThrowIfNull
(
$"未能正确获取系统
{
currency
}
业务账户!请联系管理员!"
);
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
settlements
.
ConvertAll
(
o
=>
o
.
BizId
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
if
(
PayingMethods
.
Count
==
1
)
//单笔付款登记
{
using
(
KiviiContext
.
Profiler
(
"单个方式收款"
))
...
...
@@ -100,7 +102,7 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了AmountPayment
caches
.
Remove
(
item
.
BizId
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
...
...
@@ -159,7 +161,7 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
caches
.
Remove
(
item
.
BizId
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
...
...
@@ -216,7 +218,7 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
caches
.
Remove
(
item
.
BizId
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
...
...
@@ -368,7 +370,7 @@ namespace Kivii.Finances.Transforms
foreach
(
var
item
in
settlements
)
{
if
(!
item
.
OnlyProperties
.
IsNullOrEmpty
())
conn
.
UpdateOnly
(
item
);
//更新了Paykvid和AmountPayment
caches
.
Remove
(
item
.
BizId
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
var
groupSettlement
=
settlements
.
GroupBy
(
o
=>
o
.
BizType
);
...
...
@@ -402,6 +404,12 @@ namespace Kivii.Finances.Transforms
return
rtns
;
}
}
catch
(
Exception
ex
)
{
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
private
IDbTransaction
onExecution
<
T
>(
IDbConnection
conn
,
List
<
Settlement
>
settlements
)
where
T
:
IEntity
{
...
...
Src/Transforms/RestfulPayment.Accept.cs
View file @
e75d3231
...
...
@@ -31,6 +31,22 @@ namespace Kivii.Finances.Transforms
//if (Items.Exists(o => o.PayerAccountKvid == Guid.Empty && o.PayeeAccountKvid == Guid.Empty)) throw new Exception("收付款账户不能同时为空!");
//if (Items.Exists(o => o.PayerAccountKvid != Guid.Empty && o.PayeeAccountKvid != Guid.Empty)) throw new Exception("收付款账户不能同时指定!");
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
int
?>(
cacheKey
);
if
(
cacheValue
!=
null
)
{
if
(
cacheValue
<
0
)
throw
new
Exception
(
$"仍在处理中,请稍后查看结果!"
);
else
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
}
条,请稍后查看结果!"
);
}
int
?
caches
=
Items
.
Count
;
//caches.AddRange(Items.ConvertAll(o => o.SerialNumber));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
try
{
var
typeBanks
=
Items
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Bank
).
ToList
();
var
typeCashs
=
Items
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Cash
).
ToList
();
var
typePoss
=
Items
.
Where
(
o
=>
o
.
Type
==
PaymentType
.
Pos
).
ToList
();
...
...
@@ -201,19 +217,6 @@ namespace Kivii.Finances.Transforms
var
rtns
=
new
RestfulCreateResponse
<
Payment
>();
rtns
.
Results
=
new
List
<
Payment
>();
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
allAcceptPayments
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
var
trans
=
conn
.
OpenTransaction
();
try
...
...
@@ -225,7 +228,7 @@ namespace Kivii.Finances.Transforms
conn
.
Insert
(
item
);
item
.
RemoveAllOnlyProperties
();
rtns
.
Results
.
Add
(
item
);
caches
.
Remove
(
item
.
SerialNumber
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
}
...
...
@@ -248,6 +251,13 @@ namespace Kivii.Finances.Transforms
}
return
rtns
;
}
catch
(
Exception
ex
)
{
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
}
}
Src/Transforms/RestfulPayment.Split.cs
View file @
e75d3231
...
...
@@ -177,7 +177,22 @@ namespace Kivii.Finances.Transforms
public
override
object
OnExecution
(
IRequest
req
,
IResponse
res
)
{
if
(
Kvids
.
IsNullOrEmpty
())
throw
new
Exception
(
"请选择要认领的收款!"
);
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
int
?>(
cacheKey
);
if
(
cacheValue
!=
null
)
{
if
(
cacheValue
<
0
)
throw
new
Exception
(
$"仍在处理中,请稍后查看结果!"
);
else
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
}
条,请稍后查看结果!"
);
}
int
?
caches
=
Kvids
.
Count
;
//caches.AddRange(Items.ConvertAll(o => o.SerialNumber));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
try
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Payment
>();
var
payments
=
conn
.
SelectByIds
<
Payment
>(
Kvids
);
...
...
@@ -267,18 +282,6 @@ namespace Kivii.Finances.Transforms
var
rtns
=
new
RestfulExecutionResponse
<
Payment
>();
rtns
.
Results
=
new
List
<
Payment
>();
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
splits
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
//开启事务进行数据库操作
var
trans
=
conn
.
OpenTransaction
();
...
...
@@ -288,7 +291,7 @@ namespace Kivii.Finances.Transforms
{
conn
.
Insert
(
split
);
rtns
.
Results
.
Add
(
split
);
caches
.
Remove
(
split
.
SerialNumber
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
foreach
(
var
item
in
splitsSetOwner
)
...
...
@@ -316,6 +319,12 @@ namespace Kivii.Finances.Transforms
}
return
rtns
;
}
catch
(
Exception
ex
)
{
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
}
[
Api
(
Description
=
"认领撤销"
)]
...
...
@@ -619,6 +628,22 @@ namespace Kivii.Finances.Transforms
{
if
(
Kvids
.
IsNullOrEmpty
())
throw
new
Exception
(
"请选择要划转的收款!"
);
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
int
?>(
cacheKey
);
if
(
cacheValue
!=
null
)
{
if
(
cacheValue
<
0
)
throw
new
Exception
(
$"仍在处理中,请稍后查看结果!"
);
else
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
}
条,请稍后查看结果!"
);
}
int
?
caches
=
Kvids
.
Count
;
//caches.AddRange(Items.ConvertAll(o => o.SerialNumber));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
try
{
var
conn
=
KiviiContext
.
GetOpenedDbConnection
<
Payment
>();
var
payments
=
conn
.
SelectByIds
<
Payment
>(
Kvids
);
...
...
@@ -673,19 +698,6 @@ namespace Kivii.Finances.Transforms
var
rtns
=
new
RestfulExecutionResponse
<
Payment
>();
rtns
.
Results
=
new
List
<
Payment
>();
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
assigns
.
ConvertAll
(
o
=>
o
.
SerialNumber
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
//开启事务进行数据库操作
var
trans
=
conn
.
OpenTransaction
();
try
...
...
@@ -694,7 +706,7 @@ namespace Kivii.Finances.Transforms
{
conn
.
Insert
(
assign
);
rtns
.
Results
.
Add
(
assign
);
caches
.
Remove
(
assign
.
SerialNumber
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
foreach
(
var
item
in
spliteds
)
...
...
@@ -712,6 +724,12 @@ namespace Kivii.Finances.Transforms
}
return
rtns
;
}
catch
(
Exception
ex
)
{
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
}
[
Api
(
Description
=
"划转撤销"
)]
...
...
Src/Transforms/RestfulSettlement.cs
View file @
e75d3231
...
...
@@ -31,6 +31,24 @@ namespace Kivii.Finances.Transforms
bizKvids
.
RemoveAll
(
o
=>
o
==
Guid
.
Empty
);
var
bizids
=
Items
.
ConvertAll
(
p
=>
p
.
BizId
).
Distinct
().
ToList
();
bizids
.
RemoveAll
(
o
=>
o
.
IsNullOrEmpty
());
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
int
?>(
cacheKey
);
if
(
cacheValue
!=
null
)
{
if
(
cacheValue
<
0
)
throw
new
Exception
(
$"仍在处理中,请稍后查看结果!"
);
else
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
}
条,请稍后查看结果!"
);
}
int
?
caches
=
Items
.
Count
;
//caches.AddRange(Items.ConvertAll(o => o.SerialNumber));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
try
{
var
connF
=
KiviiContext
.
GetOpenedDbConnection
<
Settlement
>();
//foreach (var bizId in bizids)
//{
...
...
@@ -47,18 +65,6 @@ namespace Kivii.Finances.Transforms
//var detailBizids = allDetails.ConvertAll(p => p.BizId);
//detailBizids.RemoveAll(o => o.IsNullOrEmpty());
//if (connE.Exists<EntitySettlementDetail<G>>(o => o.OffsetKvid != Guid.Empty && (Sql.In(o.BizKvid, detailBizKvids) || Sql.In(o.BizId, detailBizids)))) throw new Exception("存在重复结算的明细项目!");
#
region
启用缓存
,
将当前人创建批次数据存入
,
处理完毕或者接口报错后清除
,
确保不会重复创建
var
cache
=
KiviiContext
.
GetCacheClient
();
var
cacheKey
=
KiviiContext
.
GetUrnKey
(
$"
{
this
.
GetType
().
FullName
}
_Request_
{
KiviiContext
.
CurrentMember
.
FullName
}
_
{
KiviiContext
.
CurrentMember
.
Kvid
}
"
);
var
cacheValue
=
cache
.
Get
<
List
<
string
>>(
cacheKey
);
if
(!
cacheValue
.
IsNullOrEmpty
())
{
throw
new
Exception
(
$"当前正在处理中,剩余
{
cacheValue
.
Count
}
条,请稍后再试!"
);
}
var
caches
=
new
List
<
string
>();
caches
.
AddRange
(
Items
.
ConvertAll
(
o
=>
o
.
BizId
));
cache
.
Set
(
cacheKey
,
caches
,
TimeSpan
.
FromMinutes
(
5
));
#
endregion
var
rtns
=
new
RestfulCreateResponse
<
Settlement
>();
rtns
.
Results
=
new
List
<
Settlement
>();
...
...
@@ -192,7 +198,7 @@ namespace Kivii.Finances.Transforms
}
connF
.
Insert
(
policyRecord
);
}
caches
.
Remove
(
item
.
BizId
)
;
caches
--
;
cache
.
Replace
(
cacheKey
,
caches
);
}
}
...
...
@@ -210,6 +216,12 @@ namespace Kivii.Finances.Transforms
return
rtns
;
}
catch
(
Exception
ex
)
{
cache
.
Remove
(
cacheKey
);
throw
ex
;
}
}
}
[
Api
(
Description
=
"泛型结算更新"
)]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment