Commit 10862009 by guanzhenshan

增加自产采购发货在途服务

parent dbd76a5f
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.35" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.5" />
<PackageReference Include="MySql.Data" Version="8.0.20" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bailun.DC.Common\Bailun.DC.Common.csproj" />
</ItemGroup>
</Project>
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.DailySelfProduceDeliver/Bailun.DC.DailySelfProducePurchaseDeliver.csproj Bailun.DC.DailySelfProduceDeliver/
COPY Bailun.DC.Common/Bailun.DC.Common.csproj Bailun.DC.Common/
RUN dotnet restore Bailun.DC.DailySelfProduceDeliver/Bailun.DC.DailySelfProducePurchaseDeliver.csproj
COPY . .
WORKDIR /src/Bailun.DC.DailySelfProduceDeliver
RUN dotnet build Bailun.DC.DailySelfProducePurchaseDeliver.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish Bailun.DC.DailySelfProducePurchaseDeliver.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Bailun.DC.DailySelfProducePurchaseDeliver.dll"]
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;
namespace Bailun.DC.DailySelfProducePurchaseDeliver
{
/// <summary>
/// 自产采购发货在途
/// </summary>
class Program
{
/// <summary>
/// 自产采购发货在途
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
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();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using Dapper;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace Bailun.DC.DailySelfProducePurchaseDeliver
{
public class Services : BackgroundService
{
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
return Task.CompletedTask;
}
private void DoWork(object state)
{
try
{
var now = DateTime.Now;
if (now.Hour == 2 && now.Minute == 11) //02:11分启动
{
Console.WriteLine("开始启动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Init();
Console.WriteLine("任务运行完成 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
/// <summary>
/// 保存昨天的自产采购发货在途明细
/// </summary>
public void Init()
{
var sql = $@"insert into dc_daily_purchase_semi_deliveronway (purchase_id,bailun_sku,count,price,createtime,day)
select t1.purchase_id,t1.bailun_sku,t1.count-t2.count as count,t5.price,NOW() as createtime,date_format(date_add(now(), interval -1 day),'%Y-%m-%d') as day from dc_base_purchase_delivery t1
join dc_base_purchase t5 on t1.parent_id=t5.parent_id and t1.bailun_sku=t5.bailun_sku and t5.buy_status=3
left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku and t3.buyer_name in ('张莹霞','张莹霞1')
left join dc_base_purchase_inbound t2 on t1.parent_id=t2.parent_id and t1.bailun_sku=t2.bailun_sku and t2.status=1
where t1.count>t2.count and t1.`status`=1;";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
//删除昨天的数据
cn.Execute("delete from dc_daily_purchase_semi_deliveronway where day='" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "'");
//保存最新数据
cn.Execute(sql);
}
}
}
}
...@@ -45,7 +45,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.DailyPlatformRece ...@@ -45,7 +45,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.DailyPlatformRece
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.MonthSalePutin", "Bailun.DC.MonthSalePutin\Bailun.DC.MonthSalePutin.csproj", "{08F12342-13D8-4FB3-B3EC-D35B4E738F35}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.MonthSalePutin", "Bailun.DC.MonthSalePutin\Bailun.DC.MonthSalePutin.csproj", "{08F12342-13D8-4FB3-B3EC-D35B4E738F35}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bailun.DC.DailyLogisticSupplierTransaction", "Bailun.DC.DailyLogisticSupplierTransaction\Bailun.DC.DailyLogisticSupplierTransaction.csproj", "{5163B1E9-43F8-4E5A-B4A9-546F5375515E}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.DailyLogisticSupplierTransaction", "Bailun.DC.DailyLogisticSupplierTransaction\Bailun.DC.DailyLogisticSupplierTransaction.csproj", "{5163B1E9-43F8-4E5A-B4A9-546F5375515E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bailun.DC.DailySelfProducePurchaseDeliver", "Bailun.DC.DailySelfProduceDeliver\Bailun.DC.DailySelfProducePurchaseDeliver.csproj", "{A8E6DCD5-9F45-41D3-9297-FB104772B11C}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -137,6 +139,10 @@ Global ...@@ -137,6 +139,10 @@ Global
{5163B1E9-43F8-4E5A-B4A9-546F5375515E}.Debug|Any CPU.Build.0 = Debug|Any CPU {5163B1E9-43F8-4E5A-B4A9-546F5375515E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5163B1E9-43F8-4E5A-B4A9-546F5375515E}.Release|Any CPU.ActiveCfg = Release|Any CPU {5163B1E9-43F8-4E5A-B4A9-546F5375515E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5163B1E9-43F8-4E5A-B4A9-546F5375515E}.Release|Any CPU.Build.0 = Release|Any CPU {5163B1E9-43F8-4E5A-B4A9-546F5375515E}.Release|Any CPU.Build.0 = Release|Any CPU
{A8E6DCD5-9F45-41D3-9297-FB104772B11C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8E6DCD5-9F45-41D3-9297-FB104772B11C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8E6DCD5-9F45-41D3-9297-FB104772B11C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8E6DCD5-9F45-41D3-9297-FB104772B11C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -157,6 +163,7 @@ Global ...@@ -157,6 +163,7 @@ Global
{BFD01F3A-DEF2-4DEC-BC7C-3AAB7FBE3188} = {AE2CE86A-8538-4142-920F-684DCF47C064} {BFD01F3A-DEF2-4DEC-BC7C-3AAB7FBE3188} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{08F12342-13D8-4FB3-B3EC-D35B4E738F35} = {AE2CE86A-8538-4142-920F-684DCF47C064} {08F12342-13D8-4FB3-B3EC-D35B4E738F35} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{5163B1E9-43F8-4E5A-B4A9-546F5375515E} = {AE2CE86A-8538-4142-920F-684DCF47C064} {5163B1E9-43F8-4E5A-B4A9-546F5375515E} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{A8E6DCD5-9F45-41D3-9297-FB104772B11C} = {AE2CE86A-8538-4142-920F-684DCF47C064}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E53AF28-A282-4FB0-A769-EAEA9769C02A} SolutionGuid = {6E53AF28-A282-4FB0-A769-EAEA9769C02A}
......
...@@ -104,3 +104,10 @@ services: ...@@ -104,3 +104,10 @@ services:
context: . context: .
dockerfile: Bailun.DC.DailyLogisticSupplierTransaction/Dockerfile dockerfile: Bailun.DC.DailyLogisticSupplierTransaction/Dockerfile
bailun.dc.dailyselfproducepurchasedeliver:
image: ${DOCKER_REGISTRY}bailundcdailyselfproducepurchasedeliver
build:
context: .
dockerfile: Bailun.DC.DailySelfProduceDeliver/Dockerfile
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