Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
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
DataCenter_Core2.1_20190520
Commits
38a3bf2e
Commit
38a3bf2e
authored
Dec 14, 2020
by
guanzhenshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加物流费用基础信息的汇率和人民币金额
parent
11b3e035
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
182 additions
and
21 deletions
+182
-21
Program.cs
Bailun.DC.DailyLogisticSupplierTransaction/Program.cs
+20
-20
dc_base_logistics.cs
Bailun.DC.SyncLogisticInfo/Models/dc_base_logistics.cs
+4
-0
response_Exchange.cs
Bailun.DC.SyncLogisticInfo/Models/response_Exchange.cs
+15
-0
Program.cs
Bailun.DC.SyncLogisticInfo/Program.cs
+2
-1
Services.cs
Bailun.DC.SyncLogisticInfo/Services.cs
+141
-0
No files found.
Bailun.DC.DailyLogisticSupplierTransaction/Program.cs
View file @
38a3bf2e
...
@@ -12,28 +12,28 @@ namespace Bailun.DC.DailyLogisticSupplierTransaction
...
@@ -12,28 +12,28 @@ namespace Bailun.DC.DailyLogisticSupplierTransaction
/// </summary>
/// </summary>
/// <param name="args"></param>
/// <param name="args"></param>
/// <returns></returns>
/// <returns></returns>
static
async
Task
Main
(
string
[]
args
)
//static async Task Main(string[] args)
{
Console
.
WriteLine
(
"启动服务 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
var
builder
=
new
HostBuilder
().
ConfigureServices
((
hostContext
,
services
)
=>
{
services
.
AddHostedService
<
Services
>();
});
await
builder
.
RunConsoleAsync
();
}
//static void Main(string[] args)
//{
//{
// var _services = new Services();
// Console.WriteLine("启动服务 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
// var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
// var start = DateTime.Parse("2020-06-01");
// while (start.AddDays(1) < DateTime.Now)
// {
// {
//
Console.WriteLine(start
);
//
services.AddHostedService<Services>(
);
//
_services.Init(start
);
//
}
);
// start = start.AddDays(1);
//
}
//
await builder.RunConsoleAsync();
//}
//}
static
void
Main
(
string
[]
args
)
{
var
_services
=
new
Services
();
var
start
=
DateTime
.
Parse
(
"2020-09-01"
);
while
(
start
.
AddDays
(
1
)
<
DateTime
.
Now
)
{
Console
.
WriteLine
(
start
);
_services
.
Init
(
start
);
start
=
start
.
AddDays
(
1
);
}
}
}
}
}
}
Bailun.DC.SyncLogisticInfo/Models/dc_base_logistics.cs
View file @
38a3bf2e
...
@@ -61,5 +61,9 @@ namespace Bailun.DC.SyncLogisticInfo.Models
...
@@ -61,5 +61,9 @@ namespace Bailun.DC.SyncLogisticInfo.Models
public
DateTime
gmt_modify_time
{
get
;
set
;
}
public
DateTime
gmt_modify_time
{
get
;
set
;
}
public
string
currencytype
{
get
;
set
;
}
public
string
currencytype
{
get
;
set
;
}
public
decimal
?
exchangerate
{
get
;
set
;
}
public
decimal
?
amount_rmb
{
get
;
set
;
}
}
}
}
}
Bailun.DC.SyncLogisticInfo/Models/response_Exchange.cs
0 → 100644
View file @
38a3bf2e
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.DC.SyncLogisticInfo.Models
{
public
class
response_Exchange
{
public
decimal
rate
{
get
;
set
;
}
public
string
toCurName
{
get
;
set
;
}
public
string
createTime
{
get
;
set
;
}
}
}
Bailun.DC.SyncLogisticInfo/Program.cs
View file @
38a3bf2e
...
@@ -29,8 +29,9 @@ namespace Bailun.DC.SyncLogisticInfo
...
@@ -29,8 +29,9 @@ namespace Bailun.DC.SyncLogisticInfo
// Console.WriteLine("Hello World!");
// Console.WriteLine("Hello World!");
// var _service = new Services();
// var _service = new Services();
// _service.Init();
//
//
_service.Init();
// _service.UpdateRMBAmount();
//}
//}
...
...
Bailun.DC.SyncLogisticInfo/Services.cs
View file @
38a3bf2e
...
@@ -8,6 +8,7 @@ using Dapper;
...
@@ -8,6 +8,7 @@ using Dapper;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Linq
;
namespace
Bailun.DC.SyncLogisticInfo
namespace
Bailun.DC.SyncLogisticInfo
{
{
...
@@ -15,6 +16,7 @@ namespace Bailun.DC.SyncLogisticInfo
...
@@ -15,6 +16,7 @@ namespace Bailun.DC.SyncLogisticInfo
{
{
private
static
bool
isRuning
=
false
;
private
static
bool
isRuning
=
false
;
private
Timer
_timer
;
private
Timer
_timer
;
private
static
List
<
Tuple
<
DateTime
,
string
,
decimal
>>
listMonthExchange
=
new
List
<
Tuple
<
DateTime
,
string
,
decimal
>>();
protected
override
Task
ExecuteAsync
(
CancellationToken
stoppingToken
)
protected
override
Task
ExecuteAsync
(
CancellationToken
stoppingToken
)
{
{
...
@@ -32,6 +34,11 @@ namespace Bailun.DC.SyncLogisticInfo
...
@@ -32,6 +34,11 @@ namespace Bailun.DC.SyncLogisticInfo
{
{
Console
.
WriteLine
(
"开始启动 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
Console
.
WriteLine
(
"开始启动 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
Init
();
Init
();
//更新汇率
Console
.
WriteLine
(
"开始更新汇率 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
UpdateRMBAmount
();
Console
.
WriteLine
(
"任务运行完成 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
Console
.
WriteLine
(
"任务运行完成 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
}
}
...
@@ -144,6 +151,7 @@ namespace Bailun.DC.SyncLogisticInfo
...
@@ -144,6 +151,7 @@ namespace Bailun.DC.SyncLogisticInfo
private
void
Save
(
List
<
DataInfo
>
list
)
private
void
Save
(
List
<
DataInfo
>
list
)
{
{
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
{
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
...
@@ -192,6 +200,50 @@ namespace Bailun.DC.SyncLogisticInfo
...
@@ -192,6 +200,50 @@ namespace Bailun.DC.SyncLogisticInfo
currencytype
=
item
.
currencyType
,
currencytype
=
item
.
currencyType
,
};
};
//获取相应汇率 取当月顺延第一日的汇率
if
(
m
.
currencytype
.
ToLower
()==
"cny"
)
{
m
.
amount_rmb
=
m
.
merchant_shipment_cost_cny
;
m
.
exchangerate
=
1
;
}
else
if
(
m
.
merchant_reconciliation_time
.
HasValue
)
{
var
objRate
=
listMonthExchange
.
Where
(
a
=>
a
.
Item1
.
Year
==
m
.
merchant_reconciliation_time
.
Value
.
Year
&&
a
.
Item1
.
Month
==
m
.
merchant_reconciliation_time
.
Value
.
Month
&&
a
.
Item2
==
m
.
currencytype
.
ToUpper
()).
FirstOrDefault
();
if
(
objRate
!=
null
)
{
m
.
exchangerate
=
objRate
.
Item3
;
m
.
amount_rmb
=
m
.
merchant_shipment_cost_cny
*
objRate
.
Item3
;
}
else
{
//获取当月汇率
try
{
var
_url_exchange
=
$"http://oa.bailuntec.com/Api/ExchangeRate/GetMonthlyExchangeRateByDate?date=
{
m
.
merchant_reconciliation_time
.
Value
.
ToString
(
"yyyy-MM"
)}
&toCur=CNY&fromCur="
+
m
.
currencytype
.
ToUpper
();
var
result_Exchange
=
Common
.
HttpHelper
.
NetHelper
.
Request
(
_url_exchange
);
if
(!
string
.
IsNullOrEmpty
(
result_Exchange
))
{
var
json
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
Models
.
response_Exchange
>(
result_Exchange
);
objRate
=
new
Tuple
<
DateTime
,
string
,
decimal
>(
DateTime
.
Parse
(
m
.
merchant_reconciliation_time
.
Value
.
ToString
(
"yyyy-MM"
)+
"-01"
),
m
.
currencytype
.
ToUpper
(),
json
.
rate
);
listMonthExchange
.
Add
(
objRate
);
m
.
exchangerate
=
objRate
.
Item3
;
m
.
amount_rmb
=
objRate
.
Item3
*
m
.
merchant_shipment_cost_cny
;
}
}
catch
(
Exception
ex
)
{
}
}
}
cn
.
Insert
<
dc_base_logistics
>(
m
);
cn
.
Insert
<
dc_base_logistics
>(
m
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
@@ -205,5 +257,94 @@ namespace Bailun.DC.SyncLogisticInfo
...
@@ -205,5 +257,94 @@ namespace Bailun.DC.SyncLogisticInfo
}
}
public
void
UpdateRMBAmount
()
{
var
list
=
new
List
<
dc_base_logistics
>();
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString_read
))
{
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
list
=
cn
.
Query
<
dc_base_logistics
>(
"select * from dc_base_logistics where merchant_reconciliation_time>='2020-09-01' and amount_rmb is null"
,
null
,
null
,
true
,
6
*
60
).
ToList
();
}
if
(
list
.
Count
>
0
)
{
//
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
{
foreach
(
var
item
in
list
)
{
if
(
item
.
currencytype
.
ToLower
()
==
"cny"
)
{
item
.
amount_rmb
=
item
.
merchant_shipment_cost_cny
;
item
.
exchangerate
=
1
;
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
cn
.
Execute
(
$"update dc_base_logistics set exchangerate=
{
item
.
exchangerate
}
,amount_rmb=
{
item
.
amount_rmb
}
where id=
{
item
.
id
}
"
);
}
else
{
var
objRate
=
listMonthExchange
.
Where
(
a
=>
a
.
Item1
.
Year
==
item
.
merchant_reconciliation_time
.
Value
.
Year
&&
a
.
Item1
.
Month
==
item
.
merchant_reconciliation_time
.
Value
.
Month
&&
a
.
Item2
==
item
.
currencytype
.
ToUpper
()).
FirstOrDefault
();
if
(
objRate
!=
null
)
{
item
.
exchangerate
=
objRate
.
Item3
;
item
.
amount_rmb
=
item
.
merchant_shipment_cost_cny
*
objRate
.
Item3
;
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
cn
.
Execute
(
$"update dc_base_logistics set exchangerate=
{
item
.
exchangerate
}
,amount_rmb=
{
item
.
amount_rmb
}
where id=
{
item
.
id
}
"
);
}
else
{
//获取当月汇率
try
{
var
_url_exchange
=
$"http://oa.bailuntec.com/Api/ExchangeRate/GetMonthlyExchangeRateByDate?date=
{
item
.
merchant_reconciliation_time
.
Value
.
ToString
(
"yyyy-MM"
)}
&toCur=CNY&fromCur="
+
item
.
currencytype
.
ToUpper
();
var
result_Exchange
=
Common
.
HttpHelper
.
NetHelper
.
Request
(
_url_exchange
);
if
(!
string
.
IsNullOrEmpty
(
result_Exchange
))
{
var
json
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
Models
.
response_Exchange
>(
result_Exchange
);
objRate
=
new
Tuple
<
DateTime
,
string
,
decimal
>(
DateTime
.
Parse
(
item
.
merchant_reconciliation_time
.
Value
.
ToString
(
"yyyy-MM"
)
+
"-01"
),
item
.
currencytype
.
ToUpper
(),
json
.
rate
);
listMonthExchange
.
Add
(
objRate
);
item
.
exchangerate
=
objRate
.
Item3
;
item
.
amount_rmb
=
objRate
.
Item3
*
item
.
merchant_shipment_cost_cny
;
if
(
cn
.
State
==
System
.
Data
.
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
cn
.
Execute
(
$"update dc_base_logistics set exchangerate=
{
item
.
exchangerate
}
,amount_rmb=
{
item
.
amount_rmb
}
where id=
{
item
.
id
}
"
);
}
}
catch
(
Exception
ex
)
{
}
}
}
}
}
Console
.
WriteLine
(
"本次更新"
+
list
.
Count
+
"条记录"
);
}
}
}
}
}
}
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