Commit 17169819 by zhoujinhui

up

parent 03100caf
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bailun.DC.Services\Bailun.DC.Services.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</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.SyncMonthStockWeighting/Bailun.DC.SyncMonthStockWeighting.csproj Bailun.DC.SyncMonthStockWeighting/
COPY Bailun.DC.Services/Bailun.DC.Services.csproj Bailun.DC.Services/
COPY Bailun.DC.Common/Bailun.DC.Common.csproj Bailun.DC.Common/
RUN dotnet restore Bailun.DC.SyncMonthStockWeighting/Bailun.DC.SyncMonthStockWeighting.csproj
COPY . .
WORKDIR /src/Bailun.DC.SyncMonthStockWeighting
RUN dotnet build Bailun.DC.SyncMonthStockWeighting.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish Bailun.DC.SyncMonthStockWeighting.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Bailun.DC.SyncMonthStockWeighting.dll"]
using Bailun.DC.Models.Dtos.Stock;
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.SyncMonthStockWeighting.Model
{
public class WMSDataResponseDto
{
/// <summary>
/// 指示是否成功
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
/// 消息
/// </summary>
public string Message { get; set; }
public ProductStockFlowPagesOutputDto Data { get; set; }
}
public class ProductStockFlowPagesOutputDto
{
public List<ProductStockFlowApiResponseDto> Items { get; set; }
}
}
using Bailun.DC.Models.Stock;
namespace Bailun.DC.SyncMonthStockWeighting.Model
{
public class WMSRequestDto
{
/// <summary>
///
/// </summary>
public ProductStockFlowPagesInputDto Data { get; set; }
}
public class ProductStockFlowPagesInputDto
{
/// <summary>
/// 交易流水号
/// </summary>
public string SysSerialNumber { get; set; }
/// <summary>
/// 产品sku
/// </summary>
public string Sku { get; set; }
/// <summary>
/// 仓库编码
/// </summary>
public string WarehouseCode { get; set; }
/// <summary>
/// 第三方单号
/// </summary>
public string ThirdSysOrderNo { get; set; }
/// <summary>
/// 第三方单号类型
/// </summary>
public ThirdSysOrderType? ThirdSysOrderType { get; set; }
/// <summary>
/// 第三方单创建时间
/// </summary>
public string[] OrderCreationTimes { get; set; }
/// <summary>
/// 交易流水记录生成时间
/// </summary>
public string[] CreationTimes { get; set; }
/// <summary>
/// 分页信息
/// </summary>
public Pagination Page { get; set; }
}
public class Pagination
{
/// <summary>
///
/// </summary>
public int Page { get; set; }
/// <summary>
///
/// </summary>
public int Rows { get; set; }
}
}
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;
namespace Bailun.DC.SyncMonthStockWeighting
{
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<SyncMonthStockWeightingServices>();
services.AddHostedService<SyncWmsStockFlowServices>();
});
await builder.RunConsoleAsync();
}
}
}
using Bailun.DC.Services.WebApiService;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Bailun.DC.SyncMonthStockWeighting
{
public class SyncMonthStockWeightingServices : BackgroundService
{
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
new FinanceService().SynchMonthStockWeighting();
return Task.CompletedTask;
}
private void DoWork(object state)
{
}
}
}
using Bailun.DC.Models.Stock;
using Bailun.DC.Services;
using Bailun.DC.SyncMonthStockWeighting.Model;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static Bailun.DC.Common.HttpHelper;
namespace Bailun.DC.SyncMonthStockWeighting
{
public class SyncWmsStockFlowServices : 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)
{
var now = DateTime.Now;
if (now.Day == 1 && now.Hour == 1 && now.Minute == 1)
{
SynchWmsData();
}
}
private void SynchWmsData()
{
try
{
Console.WriteLine($"SynchWmsData--{DateTime.Now}");
string url = "http://api.wms.bailuntec.com/api/services/app/ProductStockFlowService/GetProductStockFlowPages";
var requestData = new WMSRequestDto
{
Data = new ProductStockFlowPagesInputDto { OrderCreationTimes = new string[] { "2021-06-30", DateTime.Now.Date.ToString() }, Page = new Pagination { Rows = 50 } }
};
var inventoryServices = new InventoryServices();
for (int i = 1; i < 1000000; i++)
{
requestData.Data.Page.Page = i;
var str = NetHelper.HttpPostJson(url, Newtonsoft.Json.JsonConvert.SerializeObject(requestData));
if (string.IsNullOrWhiteSpace(str)) break;
var resopnse = Newtonsoft.Json.JsonConvert.DeserializeObject<WMSDataResponseDto>(str);
if (resopnse == null || resopnse.Data == null || resopnse.Data.Items.Count <= 0) return;
foreach (var item in resopnse.Data.Items)
{
var insertModel = new dc_base_wms_stock_flow(item);
var isSuccess = inventoryServices.InsertWmsStockFlow(insertModel);
if (!isSuccess) break;
Console.WriteLine($"{item.SysSerialNumber}--{DateTime.Now}");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
......@@ -93,7 +93,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncMonthSalesPro
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.ExportTask", "Bailun.DC.ExportTask\Bailun.DC.ExportTask.csproj", "{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bailun.DC.SyncMonthStockWeighting", "..\Bailun.DC.SyncMonthStockWeighting\Bailun.DC.SyncMonthStockWeighting.csproj", "{ED1647F9-6EA3-41A8-805F-DC46B8AD8835}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncMonthStockWeighting", "Bailun.DC.SyncMonthStockWeighting\Bailun.DC.SyncMonthStockWeighting.csproj", "{66D159A3-63A6-4900-AB21-C04ADE5A3D01}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -277,10 +277,10 @@ Global
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94}.Release|Any CPU.Build.0 = Release|Any CPU
{ED1647F9-6EA3-41A8-805F-DC46B8AD8835}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED1647F9-6EA3-41A8-805F-DC46B8AD8835}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED1647F9-6EA3-41A8-805F-DC46B8AD8835}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED1647F9-6EA3-41A8-805F-DC46B8AD8835}.Release|Any CPU.Build.0 = Release|Any CPU
{66D159A3-63A6-4900-AB21-C04ADE5A3D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66D159A3-63A6-4900-AB21-C04ADE5A3D01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66D159A3-63A6-4900-AB21-C04ADE5A3D01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66D159A3-63A6-4900-AB21-C04ADE5A3D01}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -323,7 +323,7 @@ Global
{B0E4B05A-2330-46E1-8CF7-C6D69DBB7850} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{DEAD70F9-01C4-4178-AB0B-1C4874AA7A61} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{C4C4990D-14DC-4B76-A7EB-6F3FC5BE8B94} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{ED1647F9-6EA3-41A8-805F-DC46B8AD8835} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{66D159A3-63A6-4900-AB21-C04ADE5A3D01} = {AE2CE86A-8538-4142-920F-684DCF47C064}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E53AF28-A282-4FB0-A769-EAEA9769C02A}
......
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