Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
data-center-auto
Overview
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
bltdc
data-center-auto
Commits
5eec2482
Commit
5eec2482
authored
Jul 28, 2020
by
泽锋 李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化现金流计算速度
parent
5b3fc966
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
2 deletions
+80
-2
DbHelper.cs
AutoTurnOver.DB/Base/DbHelper.cs
+59
-0
report_cash_flow_dao.cs
AutoTurnOver.DB/report_cash_flow_dao.cs
+0
-0
Program.cs
ResetOutofstock/Program.cs
+1
-2
ResetOutofstockBackgrounService.cs
ResetOutofstock/ResetOutofstockBackgrounService.cs
+20
-0
No files found.
AutoTurnOver.DB/Base/DbHelper.cs
View file @
5eec2482
...
...
@@ -3,6 +3,7 @@ using Dapper;
using
MySql.Data.MySqlClient
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
...
...
@@ -135,5 +136,63 @@ namespace AutoTurnOver.DB.Base
return
0
;
}
/// <summary>
/// 批量插入
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entities"></param>
/// <param name="exclude">排除的字段</param>
public
static
int
BatchInsert
<
T
>(
this
MySqlConnection
conn
,
List
<
T
>
entities
,
string
[]
exclude
=
null
)
{
if
(
exclude
==
null
||
exclude
.
Length
<=
0
)
exclude
=
new
[]
{
"id"
};
for
(
var
i
=
0
;
i
<
exclude
.
Length
;
i
++)
{
exclude
[
i
]
=
exclude
[
i
].
ToLower
();
}
if
(
entities
!=
null
&&
entities
.
Count
>
0
)
{
var
tbname
=
typeof
(
T
).
Name
.
TrimEnd
(
"Entity"
.
ToCharArray
());
var
colms
=
new
List
<
string
>();
var
ps
=
entities
.
First
().
GetType
().
GetProperties
().
Where
(
p
=>
!
exclude
.
Contains
(
p
.
Name
.
ToLower
()))
.
ToList
();
foreach
(
var
p
in
ps
)
{
colms
.
Add
(
$"`
{
p
.
Name
}
`"
);
}
var
paramList
=
new
DynamicParameters
();
var
paramsNames
=
new
List
<
string
>();
var
s
=
0
;
var
n
=
"a"
;
foreach
(
var
item
in
entities
)
{
var
toNames
=
new
List
<
string
>();
foreach
(
var
p
in
ps
)
{
var
pname
=
$"@
{
n
}{
s
}
"
;
var
pvalue
=
p
.
GetValue
(
item
,
null
);
toNames
.
Add
(
pname
);
paramList
.
Add
(
pname
,
pvalue
);
s
++;
}
paramsNames
.
Add
(
$"(
{
string
.
Join
(
","
,
toNames
)}
)"
);
}
var
sql
=
$"INSERT INTO
{
tbname
}
(
{
string
.
Join
(
","
,
colms
)}
) VALUES
{
string
.
Join
(
","
,
paramsNames
)}
"
;
return
conn
.
Execute
(
sql
,
paramList
);
}
throw
new
Exception
(
"传入参数先"
);
}
}
}
AutoTurnOver.DB/report_cash_flow_dao.cs
View file @
5eec2482
This diff is collapsed.
Click to expand it.
ResetOutofstock/Program.cs
View file @
5eec2482
...
...
@@ -13,9 +13,8 @@ namespace ResetOutofstock
static
async
Task
Main
(
string
[]
args
)
{
Console
.
WriteLine
(
"刷新缺货数据任务启动..."
);
var
now
=
DateTime
.
Now
;
//report_cash_flow_dao.CalculationOrderCostLogistics(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//report.ResetCashFlowData();
var
builder
=
new
HostBuilder
().
ConfigureServices
((
hostContext
,
services
)
=>
{
services
.
AddHostedService
<
ResetOutofstockBackgrounService
>();
...
...
ResetOutofstock/ResetOutofstockBackgrounService.cs
View file @
5eec2482
...
...
@@ -34,6 +34,26 @@ namespace ResetOutofstock
Thread
.
Sleep
(
240
*
60
*
60
*
1000
);
}
});
Task
.
Factory
.
StartNew
(()
=>
{
while
(
true
)
{
try
{
var
now
=
DateTime
.
Now
;
Console
.
WriteLine
(
$"开始 刷新订单尾程费 退款数据,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
report_cash_flow_dao
.
CalculationOrderCostLogistics
(
now
.
AddMonths
(-
3
),
DateTime
.
Parse
(
now
.
AddDays
(-
1
).
ToString
(
"yyyy-MM-dd 23:59:59"
)));
Console
.
WriteLine
(
$"结束 刷新订单尾程费 退款数据,线程Id:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
,
{
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)}
"
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
Thread
.
Sleep
(
240
*
60
*
60
*
1000
);
}
});
Task
.
Factory
.
StartNew
(()
=>
{
...
...
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