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
611b1c9e
Commit
611b1c9e
authored
Aug 23, 2021
by
zhouminghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
月销售利润同步任务
parent
cb59d780
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
142 additions
and
18 deletions
+142
-18
FinanceService.cs
Bailun.DC.Services/WebApiService/FinanceService.cs
+20
-17
Bailun.DC.SyncMonthSalesProfitNew.csproj
...thSalesProfitNew/Bailun.DC.SyncMonthSalesProfitNew.csproj
+19
-0
Dockerfile
Bailun.DC.SyncMonthSalesProfitNew/Dockerfile
+20
-0
Program.cs
Bailun.DC.SyncMonthSalesProfitNew/Program.cs
+20
-0
Services.cs
Bailun.DC.SyncMonthSalesProfitNew/Services.cs
+55
-0
FinanceController.cs
Bailun.DC.WebApi/Controllers/FinanceController.cs
+1
-1
Bailun.DC.sln
Bailun.DC.sln
+7
-0
No files found.
Bailun.DC.Services/WebApiService/FinanceService.cs
View file @
611b1c9e
...
...
@@ -1316,14 +1316,14 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
/// <summary>
/// 同步生成销售额和成本的汇总数据
/// </summary>
public
bool
SyncMonthSalesProfiOrderDetail
(
DateTime
?
date
)
public
bool
SyncMonthSalesProfiOrderDetail
(
string
date
)
{
try
{
var
time
=
string
.
Empty
;
if
(
date
.
HasValue
)
if
(
!
string
.
IsNullOrWhiteSpace
(
date
)
)
{
time
=
date
.
Value
.
ToString
(
"yyyy-MM"
);
time
=
Convert
.
ToDateTime
(
date
)
.
ToString
(
"yyyy-MM"
);
}
else
{
...
...
@@ -1365,25 +1365,28 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
summary_type
=
1
}));
}
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
)
)
if
(
list
.
Count
>
0
)
{
if
(
cn
.
State
==
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
foreach
(
var
item
in
list
)
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
{
var
querySql
=
$@"SELECT id FROM dc_month_sales_profit_order_summary WHERE month = '
{
item
.
month
}
'
AND platform_type = '
{
item
.
platform_type
}
' AND financecategoryname = '
{
item
.
financecategoryname
}
' AND summary_type =
{
item
.
summary_type
}
"
;
var
exist
=
cn
.
Query
<
int
>(
querySql
).
FirstOrDefault
();
if
(
exist
>
0
)
if
(
cn
.
State
==
ConnectionState
.
Closed
)
{
item
.
id
=
exist
;
cn
.
Update
(
item
);
cn
.
Open
();
}
else
foreach
(
var
item
in
list
)
{
cn
.
Insert
(
item
);
var
querySql
=
$@"SELECT id FROM dc_month_sales_profit_order_summary WHERE month = '
{
item
.
month
}
'
AND platform_type = '
{
item
.
platform_type
}
' AND financecategoryname = '
{
item
.
financecategoryname
}
' AND summary_type =
{
item
.
summary_type
}
"
;
var
exist
=
cn
.
Query
<
int
>(
querySql
).
FirstOrDefault
();
if
(
exist
>
0
)
{
item
.
id
=
exist
;
cn
.
Update
(
item
);
}
else
{
cn
.
Insert
(
item
);
}
}
}
}
...
...
Bailun.DC.SyncMonthSalesProfitNew/Bailun.DC.SyncMonthSalesProfitNew.csproj
0 → 100644
View file @
611b1c9e
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.0.0" />
<PackageReference Include="MySql.Data" Version="8.0.18" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bailun.DC.Services\Bailun.DC.Services.csproj" />
</ItemGroup>
</Project>
Bailun.DC.SyncMonthSalesProfitNew/Dockerfile
0 → 100644
View file @
611b1c9e
FROM
microsoft/dotnet:2.1-runtime AS base
WORKDIR
/app
RUN
/bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
&&
echo
'Asia/Shanghai'
>
/etc/timezone
FROM
microsoft/dotnet:2.1-sdk AS build
WORKDIR
/src
COPY
Bailun.DC.SyncMonthSalesProfitNew/Bailun.DC.SyncMonthSalesProfitNew.csproj Bailun.DC.SyncMonthSalesProfitNew/
COPY
Bailun.DC.Service/Bailun.DC.Service.csproj Bailun.DC.Service/
RUN
dotnet restore Bailun.DC.SyncMonthSalesProfitNew/Bailun.DC.SyncMonthSalesProfitNew.csproj
COPY
. .
WORKDIR
/src/Bailun.DC.SyncMonthSalesProfitNew
RUN
dotnet build Bailun.DC.SyncMonthSalesProfitNew.csproj
-c
Release
-o
/app
FROM
build AS publish
RUN
dotnet publish Bailun.DC.SyncMonthSalesProfitNew.csproj
-c
Release
-o
/app
FROM
base AS final
WORKDIR
/app
COPY
--from=publish /app .
ENTRYPOINT
["dotnet", "Bailun.DC.SyncMonthSalesProfitNew.dll"]
Bailun.DC.SyncMonthSalesProfitNew/Program.cs
0 → 100644
View file @
611b1c9e
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
System
;
using
System.Threading.Tasks
;
namespace
Bailun.DC.SyncMonthSalesProfitNew
{
class
Program
{
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
();
}
}
}
Bailun.DC.SyncMonthSalesProfitNew/Services.cs
0 → 100644
View file @
611b1c9e
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
MySql.Data.MySqlClient
;
using
Dapper
;
using
Bailun.DC.Models
;
using
Bailun.DC.Common
;
using
System.Threading
;
using
Microsoft.Extensions.Hosting
;
using
System.Threading.Tasks
;
using
System.Linq
;
using
Bailun.DC.Services.WebApiService
;
namespace
Bailun.DC.SyncMonthSalesProfitNew
{
public
class
Services
:
BackgroundService
{
private
Timer
_timer
;
protected
override
Task
ExecuteAsync
(
CancellationToken
stoppingToken
)
{
_timer
=
new
Timer
(
DoWork
,
null
,
TimeSpan
.
Zero
,
TimeSpan
.
FromHours
(
1
));
return
Task
.
CompletedTask
;
}
private
void
DoWork
(
object
state
)
{
try
{
var
now
=
DateTime
.
Now
;
if
(
now
.
Hour
==
1
)
{
Console
.
WriteLine
(
"同步月利润销售报告开始启动 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
new
FinanceService
().
SyncMonthSalesProfit
(
""
);
Console
.
WriteLine
(
"同步月利润销售报告任务运行完成 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
}
else
if
(
now
.
Hour
==
2
)
{
Console
.
WriteLine
(
"同步生成销售额和成本的汇总数据开始启动 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
new
FinanceService
().
SyncMonthSalesProfiOrderDetail
(
""
);
Console
.
WriteLine
(
"同步生成销售额和成本的汇总数据任务运行完成 "
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
}
else
{
Console
.
WriteLine
(
$"现在是 【
{
now
.
Hour
}
点】,未到同步时间,本次同步结束~"
);
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
$"同步月销售利润错误,堆栈信息:
{
ex
.
Message
}
"
);
}
}
}
}
Bailun.DC.WebApi/Controllers/FinanceController.cs
View file @
611b1c9e
...
...
@@ -560,7 +560,7 @@ namespace Bailun.DC.WebApi.Controllers
/// <param name="date"></param>
/// <returns></returns>
[
HttpGet
(
"syncMonthSalesProfiOrderDetail"
)]
public
bool
SyncMonthSalesProfiOrderDetail
(
DateTime
?
date
)
public
bool
SyncMonthSalesProfiOrderDetail
(
string
date
)
=>
new
FinanceService
().
SyncMonthSalesProfiOrderDetail
(
date
);
[
HttpGet
(
"testRedis"
)]
public
object
TestRedis
()
...
...
Bailun.DC.sln
View file @
611b1c9e
...
...
@@ -89,6 +89,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncSemiStock", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.WebApi", "Bailun.DC.WebApi\Bailun.DC.WebApi.csproj", "{757BC915-50BE-4D38-9F82-436D384213E8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncMonthSalesProfitNew", "Bailun.DC.SyncMonthSalesProfitNew\Bailun.DC.SyncMonthSalesProfitNew.csproj", "{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
@@ -263,6 +265,10 @@ Global
{757BC915-50BE-4D38-9F82-436D384213E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{757BC915-50BE-4D38-9F82-436D384213E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{757BC915-50BE-4D38-9F82-436D384213E8}.Release|Any CPU.Build.0 = Release|Any CPU
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
...
...
@@ -303,6 +309,7 @@ Global
{09E1882E-CF92-449C-8C70-5BD4E33EB355} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{2215D072-9F97-45DD-AD4D-2691581B5305} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{B0E4B05A-2330-46E1-8CF7-C6D69DBB7850} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61} = {AE2CE86A-8538-4142-920F-684DCF47C064}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E53AF28-A282-4FB0-A769-EAEA9769C02A}
...
...
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