Commit 3dc5cdaf by lizefeng

亚马逊仓储费解析,改成队列形式。提升吞吐能力

parent 0a432dee
using AutoTurnOver.DB;
using AutoTurnOver.Models;
using AutoTurnOver.Services;
using AutoTurnOver.Utility;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace ResetOutofstock
{
class AnaFbaStorageFeeRabbitBackgroundService : RabbitWorkerBase<t_task_queue>
{
public AnaFbaStorageFeeRabbitBackgroundService() : base("解析亚马逊服务费", "aims:AnaFbaStorageFee:input", 3)
{
}
protected override async Task DoWork(t_task_queue taskDto)
{
try
{
var pars = taskDto.id.Split("_");
new AmazonDataSynchroService().AnaFbaStorageFeeReport(int.Parse(pars[0]), pars[1]);
Console.WriteLine($"解析亚马逊服务费 完成 ");
}
catch (Exception e)
{
RabbitMQHelper.EnqueneMsg("aims:deviation-v3:input", taskDto);
Console.WriteLine($"解析亚马逊服务费 数据异常,异常原因为:{e.Message},异常堆栈为:{e.StackTrace}");
}
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AutoTurnOver.DB\AutoTurnOver.DB.csproj" />
<ProjectReference Include="..\AutoTurnOver.Services\AutoTurnOver.Services.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.dev.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.prod.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/runtime:3.1 AS base
WORKDIR /app
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["AutoTurnOver.RabbitMqService/AutoTurnOver.RabbitMqService.csproj", "AutoTurnOver.RabbitMqService/"]
COPY ["AutoTurnOver.DB/AutoTurnOver.DB.csproj", "AutoTurnOver.DB/"]
COPY ["AutoTurnOver.Utility/AutoTurnOver.Utility.csproj", "AutoTurnOver.Utility/"]
COPY ["AutoTurnOver.Models/AutoTurnOver.Models.csproj", "AutoTurnOver.Models/"]
COPY ["AutoTurnOver.Services/AutoTurnOver.Services.csproj", "AutoTurnOver.Services/"]
COPY ["FikaAmazonAPI/FikaAmazonAPI.csproj", "FikaAmazonAPI/"]
RUN dotnet restore "AutoTurnOver.RabbitMqService/AutoTurnOver.RabbitMqService.csproj"
COPY . .
WORKDIR "/src/AutoTurnOver.RabbitMqService"
RUN dotnet build "AutoTurnOver.RabbitMqService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "AutoTurnOver.RabbitMqService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AutoTurnOver.RabbitMqService.dll"]
\ No newline at end of file
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ResetOutofstock;
using System;
using System.Threading.Tasks;
namespace AutoTurnOver.RabbitMqService
{
internal class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("队列启动...");
try
{
var now = DateTime.Now;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if ("amazon_storage_fee".Equals(environmentName))
{
services.AddHostedService<AnaFbaStorageFeeRabbitBackgroundService>();
}
});
await builder.RunConsoleAsync();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PublishDir>bin\Release\netcoreapp2.1\publish\</PublishDir>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"profiles": {
"ResetOutofstock": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "dev",
"QueryName": "amazon_storage_fee"
}
},
"Docker": {
"commandName": "Docker"
}
}
}
\ No newline at end of file
{
"ConnectionStrings": {
"Default": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"ReadOnly": "server=gz-cdbrg-qdyec2j3.sql.tencentcdb.com;port=59667;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "127.0.0.1",
"Port": "6379",
"Password": "SpaceHorse1",
"Defaultdatabase": "0"
},
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://api.lms2.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus",
"transfer_cost_real": "http://api.wms.bailuntec.com/api/services/app/OrderLogisticCostService/GetOrderLogisticCostPageList",
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
},
"distribution_sys": {
"getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes",
"InsertAimsUpSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertAimsUpSkuInfo"
},
"supplier_sys": {
"list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime"
},
"api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody",
"api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList",
"pps-sys": {
"review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy",
"pps_sell_product": "http://pps.bailuntec.com/WalmartApi/Publish/GetWithSellProductAsync",
"GetSkus": "https://pps.bailuntec.com/Api/ShopifyPublish/PublishDetail/GetShopifySkuStocks"
},
"prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList"
},
"lms-sys": {
"transfer-node": "http://api.lms2.bailuntec.com/api/order/transfer/ApiOrderTransferSkuCurrentNode",
"channel": "http://api.lms2.bailuntec.com/api/order/transfer/ApiChannelList"
},
"Order": {
"Bailun_TransferLog": "http://api.wms.bailuntec.com/api/services/app/AllotOrderService/SearchOrderSkuRecord"
},
"Sku": {
"base": "http://api.skums.bailuntec.com/api/sku/productsku/gmtproductskus",
"character": "http://api.skums.bailuntec.com/api/sku/productsku/productskubyskus",
"character_list": "http://api.skums.bailuntec.com/api/sku/productcommon/getproductdictionarybycode?code=TagsProCharacter"
},
"Trans": {
"AimsCreateAllotSchedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/AimsCreateAllotSchedule"
},
"btm-sys": {
"ad-fee": "http://btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeDayFull",
"order-refund": "http://btm.bailuntec.com/ScrmApi/api/ApiGetOrderRefundLog"
},
"NewDateCenter": {
"ProjectData": "https://web.bailuntec.com/gateway/system/api/visualdev/ComponentTable/ListData"
},
"RabbitMQ": {
"Host": "rabbitmq.bailuntec.com",
"Port": "6783",
"UserName": "bailun",
"Password": "bailun2022"
}
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"ReadOnly": "server=gz-cdbrg-qdyec2j3.sql.tencentcdb.com;port=59667;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
},
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"redis": {
"HostName": "10.0.2.11",
"Port": "6379",
"Password": "",
"Defaultdatabase": 0
},
"PPS_ShortagePush": "http://bltpro.bailuntec.com/api/EbayTask/PushSkuEditQtyTask",
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://api.lms2.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus",
"transfer_cost_real": "http://api.wms.bailuntec.com/api/services/app/OrderLogisticCostService/GetOrderLogisticCostPageList",
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
},
"distribution_sys": {
"getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes",
"InsertAimsUpSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertAimsUpSkuInfo"
},
"supplier_sys": {
"list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime"
},
"api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody",
"api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList",
"pps-sys": {
"review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy",
"pps_sell_product": "http://pps.bailuntec.com/WalmartApi/Publish/GetWithSellProductAsync",
"GetSkus": "https://pps.bailuntec.com/Api/ShopifyPublish/PublishDetail/GetShopifySkuStocks"
},
"prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList"
},
"lms-sys": {
"transfer-node": "http://api.lms2.bailuntec.com/api/order/transfer/ApiOrderTransferSkuCurrentNode",
"channel": "http://api.lms2.bailuntec.com/api/order/transfer/ApiChannelList"
},
"Order": {
"Bailun_TransferLog": "http://api.wms.bailuntec.com/api/services/app/AllotOrderService/SearchOrderSkuRecord"
},
"Sku": {
"base": "http://api.skums.bailuntec.com/api/sku/productsku/gmtproductskus",
"character": "http://api.skums.bailuntec.com/api/sku/productsku/productskubyskus",
"character_list": "http://api.skums.bailuntec.com/api/sku/productcommon/getproductdictionarybycode?code=TagsProCharacter"
},
"Trans": {
"AimsCreateAllotSchedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/AimsCreateAllotSchedule"
},
"btm-sys": {
"ad-fee": "http://btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeDayFull",
"order-refund": "http://btm.bailuntec.com/ScrmApi/api/ApiGetOrderRefundLog"
},
"NewDateCenter": {
"ProjectData": "https://web.bailuntec.com/gateway/system/api/visualdev/ComponentTable/ListData"
},
"RabbitMQ": {
"Host": "10.0.6.36",
"UserName": "bailun",
"Password": "bailun2022",
"Port": "6783"
}
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"ReadOnly": "server=10.0.8.21;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;SslMode=None;"
},
"Pams_GetAccountToken": "http://pams.bailuntec.com/Api/GetAccountToken",
"PPS_ShortagePush": "http://bltpro.bailuntec.com/api/EbayTask/PushSkuEditQtyTask",
"redis": {
"HostName": "10.0.2.11",
"Port": "6379",
"Password": "",
"Defaultdatabase": 0
},
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://api.lms2.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus",
"transfer_cost_real": "http://api.wms.bailuntec.com/api/services/app/OrderLogisticCostService/GetOrderLogisticCostPageList",
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
},
"distribution_sys": {
"getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes",
"InsertAimsUpSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertAimsUpSkuInfo"
},
"supplier_sys": {
"list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime"
},
"api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody",
"api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList",
"pps-sys": {
"review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy",
"pps_sell_product": "http://pps.bailuntec.com/WalmartApi/Publish/GetWithSellProductAsync",
"GetSkus": "https://pps.bailuntec.com/Api/ShopifyPublish/PublishDetail/GetShopifySkuStocks"
},
"prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList"
},
"lms-sys": {
"transfer-node": "http://api.lms2.bailuntec.com/api/order/transfer/ApiOrderTransferSkuCurrentNode",
"channel": "http://api.lms2.bailuntec.com/api/order/transfer/ApiChannelList"
},
"Order": {
"Bailun_TransferLog": "http://api.wms.bailuntec.com/api/services/app/AllotOrderService/SearchOrderSkuRecord"
},
"Sku": {
"base": "http://10.0.6.41:8000/api/sku/productsku/gmtproductskus",
"character": "http://10.0.6.41:8000/api/sku/productsku/productskubyskus",
"character_list": "http://10.0.6.41:8000/api/sku/productcommon/getproductdictionarybycode?code=TagsProCharacter"
},
"Trans": {
"AimsCreateAllotSchedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/AimsCreateAllotSchedule"
},
"btm-sys": {
"ad-fee": "http://btm.bailuntec.com/ScrmApi/api/ApiGetAdFeeDayFull",
"order-refund": "http://btm.bailuntec.com/ScrmApi/api/ApiGetOrderRefundLog"
},
"NewDateCenter": {
"ProjectData": "https://web.bailuntec.com/gateway/system/api/visualdev/ComponentTable/ListData"
},
"RabbitMQ": {
"Host": "10.0.6.36",
"UserName": "bailun",
"Password": "bailun2022",
"Port": "6783"
}
}
\ No newline at end of file
......@@ -946,6 +946,29 @@ namespace AutoTurnOver.Services
MyMySqlConnection._connection.Update(ana_task);
}
public class report_log_dto
{
public int Id { get; set; }
public string report_id { get; set; }
}
/// <summary>
/// 提交费用解析任务
/// </summary>
public void AnaFbaStorageFeeReportSubmit(string report_type, string queryName)
{
var datas = MyMySqlConnection._connection.Query<report_log_dto>(" select Id,report_id from dc_base_amazon_fee_report_log where report_type=@report_type and ana_status in (0,-1) ", new { report_type = report_type }).ToList();
if(datas!=null && datas.Count >= 1)
{
foreach (var item in datas)
{
RabbitMQHelper.EnqueneMsg(queryName, new t_task_queue { id =$"3_{item.Id}", create_time = DateTime.Now });
}
MyMySqlConnection._connection.Execute("update dc_base_amazon_fee_report_log set ana_status=3 where id in @ids ",new { ids = datas.Select(s=>s.Id).ToList()});
}
}
/// <summary>
/// 长期仓储费
/// </summary>
......
......@@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTurnOver.WeeklyStatisti
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FikaAmazonAPI", "FikaAmazonAPI\FikaAmazonAPI.csproj", "{B9DCEF46-A045-4CBB-A8CD-827363A7A0A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoTurnOver.RabbitMqService", "AutoTurnOver.RabbitMqService\AutoTurnOver.RabbitMqService.csproj", "{8BB12624-6C1B-433F-86B3-51F1331C41CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -83,6 +85,10 @@ Global
{B9DCEF46-A045-4CBB-A8CD-827363A7A0A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9DCEF46-A045-4CBB-A8CD-827363A7A0A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9DCEF46-A045-4CBB-A8CD-827363A7A0A1}.Release|Any CPU.Build.0 = Release|Any CPU
{8BB12624-6C1B-433F-86B3-51F1331C41CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BB12624-6C1B-433F-86B3-51F1331C41CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BB12624-6C1B-433F-86B3-51F1331C41CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BB12624-6C1B-433F-86B3-51F1331C41CC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -94,6 +100,7 @@ Global
{87123947-1F13-4EBE-8667-AEB2CFB07738} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{1DEF4053-DDCA-4AFF-94E6-25FA4F16CDB4} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{488A6BF1-04F2-4FE2-A811-3F097BFA3E3B} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{8BB12624-6C1B-433F-86B3-51F1331C41CC} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {09B3C433-2F6E-498C-AB7C-2931F260C5CE}
......
......@@ -792,10 +792,10 @@ namespace ResetOutofstock
try
{
Console.WriteLine($"开始 解析月度仓储费,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new AmazonDataSynchroService().AnaFbaStorageFeeReport();
new AmazonDataSynchroService().AnaFbaStorageFeeReport(-1);
Console.WriteLine($"结束 解析月度仓储费,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Console.WriteLine($"开始 提交解析月度仓储费任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new AmazonDataSynchroService().AnaFbaStorageFeeReportSubmit("GET_FBA_STORAGE_FEE_CHARGES_DATA", "aims:AnaFbaStorageFee:input");
//new AmazonDataSynchroService().AnaFbaStorageFeeReport(-1);
Console.WriteLine($"结束 提交解析月度仓储费任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
Thread.Sleep(500);
}
catch (Exception ex)
......
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