Commit 7afd1f0e by guanzhenshan

增加监控头程费是否异常的服务

parent f559c51b
<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.8" />
<PackageReference Include="MySql.Data" Version="8.0.21" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bailun.DC.Common\Bailun.DC.Common.csproj" />
<ProjectReference Include="..\Bailun.DC.Models\Bailun.DC.Models.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.CostFirstMonitoring/Bailun.DC.CostFirstMonitoring.csproj Bailun.DC.CostFirstMonitoring/
COPY Bailun.DC.Common/Bailun.DC.Common.csproj Bailun.DC.Common/
COPY Bailun.DC.Models/Bailun.DC.Models.csproj Bailun.DC.Models/
RUN dotnet restore Bailun.DC.CostFirstMonitoring/Bailun.DC.CostFirstMonitoring.csproj
COPY . .
WORKDIR /src/Bailun.DC.CostFirstMonitoring
RUN dotnet build Bailun.DC.CostFirstMonitoring.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish Bailun.DC.CostFirstMonitoring.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Bailun.DC.CostFirstMonitoring.dll"]
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.CostFirstMonitoring
{
public class mCostFirstFinish
{
public int id { get; set; }
public decimal pre_avl_sku_cost_first { get; set; }
public decimal after_avl_sku_cost_first { get; set; }
public decimal diff { get; set; }
}
}
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;
namespace Bailun.DC.CostFirstMonitoring
{
class Program
{
/// <summary>
/// 监控是否有异常的头程费数据
/// </summary>
/// <param name="args"></param>
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)
//{
// Console.WriteLine("Hello World!");
// var _service = new Services();
// _service.Init();
//}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using Bailun.DC.Common;
using Bailun.DC.Models;
using MySql.Data.MySqlClient;
using Dapper;
using Microsoft.Extensions.Hosting;
using System.Threading;
using System.Threading.Tasks;
namespace Bailun.DC.CostFirstMonitoring
{
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 == 23 && now.Minute==55) //每天晚上23:55分跑一次
{
Init();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public void Init()
{
var sql = "select id,pre_avl_sku_cost_first,after_avl_sku_cost_first,(after_avl_sku_cost_first-pre_avl_sku_cost_first) as diff from dc_base_cost_first_finish where change_rate=0 and pre_avl_sku_cost_first>0;";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if(cn.State== System.Data.ConnectionState.Closed)
{
cn.Open();
}
var list = cn.Query<mCostFirstFinish>(sql).AsList();
foreach(var item in list)
{
sql = "update dc_base_cost_first_finish set change_rate="+(item.diff*100/item.pre_avl_sku_cost_first)+ ",exception_type="+(item.diff>0?1:(item.diff<0?2:0))+" where id="+item.id;
cn.Execute(sql);
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models
{
/// <summary>
/// 百伦头程费信息, 是WMS根据线路估算而来 根据完成时间同步
/// </summary>
public class dc_base_cost_first_finish
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
/// 物流单号,一个物流单可能多个调拨单
/// </summary>
public string channel_order_id { get; set; }
/// <summary>
/// 物流主键ID, 用来判断唯一
/// </summary>
public int channel_id { get; set; }
/// <summary>
/// 箱号
/// </summary>
public string box_id { get; set; }
/// <summary>
/// 调拨单号
/// </summary>
public string transfer_order_id { get; set; }
/// <summary>
/// 根据物流主键id分组的 头程费_RMB(总)
/// </summary>
public decimal cost_first { get; set; }
/// <summary>
/// 报关费
/// </summary>
public decimal cost_goods_clearance { get; set; }
/// <summary>
/// 关税预付
/// </summary>
public decimal cost_duty { get; set; }
/// <summary>
/// 清关费
/// </summary>
public decimal cost_customs_clearance { get; set; }
/// <summary>
/// 原始重量邮费
/// </summary>
public decimal cost_weight { get; set; }
/// <summary>
/// 燃油附加费
/// </summary>
public decimal cost_fuel { get; set; }
/// <summary>
/// 仓库编码
/// </summary>
public string warehouse_code { get; set; }
/// <summary>
/// 区域Id
/// </summary>
public int area_id { get; set; }
/// <summary>
/// 公司ID, 0和1是百伦
/// </summary>
public int company_id { get; set; }
/// <summary>
/// 百伦SKU
/// </summary>
public string bailun_sku { get; set; }
/// <summary>
/// 数量
/// </summary>
public int quantity { get; set; }
/// <summary>
/// 单个SKU重量,需要按重量计算比例
/// </summary>
public decimal sku_weight { get; set; }
/// <summary>
/// SKU重量占比
/// </summary>
public decimal sku_weight_ratio { get; set; }
/// <summary>
/// SKU重量加权平均头程费用
/// </summary>
public decimal sku_cost_first { get; set; }
/// <summary>
/// 计算时 sku的实时库存
/// </summary>
public int sku_stock_quantity { get; set; }
/// <summary>
/// 计算前 sku平均头程费 dc_mid_cost_first.cost_first
/// </summary>
public decimal pre_avl_sku_cost_first { get; set; }
/// <summary>
/// 计算后 sku平均头程费 dc_mid_cost_first.cost_first
/// </summary>
public decimal after_avl_sku_cost_first { get; set; }
/// <summary>
/// 是否 需要计算平均头程费
/// </summary>
public int has_calculation { get; set; }
/// <summary>
/// 调拨单完成时间
/// </summary>
public DateTime operation_time { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime bj_create_time { get; set; }
}
}
......@@ -7414,6 +7414,21 @@ namespace Bailun.DC.Services
}
/// <summary>
/// 获取头程费
/// </summary>
/// <param name="request"></param>
/// <param name="bailun_sku"></param>
/// <param name="warehousecode"></param>
/// <param name="type"></param>
/// <returns></returns>
public List<dc_base_cost_first_finish> ListCostFirstJson(BtTableParameter request, string bailun_sku, string warehousecode, int type)
{
}
#endregion
......
......@@ -3820,6 +3820,25 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
rows = obj
});
}
/// <summary>
/// 头程费用更改记录
/// </summary>
/// <returns></returns>
public ActionResult ListCostFirstFinish()
{
return View();
}
public string ListCostFirstFinishJson(BtTableParameter request, string bailun_sku, string warehousecode, int type)
{
var _service =
}
#endregion
......
var baseUrl = 'http://data.bailuntec.com'; //'http://localhost:59628/';//
var baseUrl = 'http://localhost:59628/';//'http://data.bailuntec.com'; //
var globalOrderSort='';
var globalOrderType = '';
......
......@@ -61,11 +61,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncWarehouseInfo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.DailyPurchaseOnWay", "Bailun.DC.DailyPurchaseOnWay\Bailun.DC.DailyPurchaseOnWay.csproj", "{6B9F7624-DE1C-4A54-9947-19124022DEE1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bailun.DC.SyncSkuFinanceCategory", "Bailun.DC.SyncSkuFinanceCategory\Bailun.DC.SyncSkuFinanceCategory.csproj", "{47F8A4B4-D549-4E93-80F7-1B6B8035F7F9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SyncSkuFinanceCategory", "Bailun.DC.SyncSkuFinanceCategory\Bailun.DC.SyncSkuFinanceCategory.csproj", "{47F8A4B4-D549-4E93-80F7-1B6B8035F7F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bailun.DC.SkuStatistics", "Bailun.DC.SkuStatistics\Bailun.DC.SkuStatistics.csproj", "{08962ABF-57F6-4B3A-B46E-32B57C1BE126}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SkuStatistics", "Bailun.DC.SkuStatistics\Bailun.DC.SkuStatistics.csproj", "{08962ABF-57F6-4B3A-B46E-32B57C1BE126}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bailun.DC.SemiSkuWarehouseSales", "Bailun.DC.SemiSkuWarehouseSales\Bailun.DC.SemiSkuWarehouseSales.csproj", "{39AFD398-27D0-4C3D-98C7-7BDDC7A7BCBA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bailun.DC.SemiSkuWarehouseSales", "Bailun.DC.SemiSkuWarehouseSales\Bailun.DC.SemiSkuWarehouseSales.csproj", "{39AFD398-27D0-4C3D-98C7-7BDDC7A7BCBA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bailun.DC.CostFirstMonitoring", "Bailun.DC.CostFirstMonitoring\Bailun.DC.CostFirstMonitoring.csproj", "{2FF9E656-0E88-4A0E-84EC-4FBB26001580}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -197,6 +199,10 @@ Global
{39AFD398-27D0-4C3D-98C7-7BDDC7A7BCBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39AFD398-27D0-4C3D-98C7-7BDDC7A7BCBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39AFD398-27D0-4C3D-98C7-7BDDC7A7BCBA}.Release|Any CPU.Build.0 = Release|Any CPU
{2FF9E656-0E88-4A0E-84EC-4FBB26001580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FF9E656-0E88-4A0E-84EC-4FBB26001580}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FF9E656-0E88-4A0E-84EC-4FBB26001580}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FF9E656-0E88-4A0E-84EC-4FBB26001580}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -227,6 +233,7 @@ Global
{47F8A4B4-D549-4E93-80F7-1B6B8035F7F9} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{08962ABF-57F6-4B3A-B46E-32B57C1BE126} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{39AFD398-27D0-4C3D-98C7-7BDDC7A7BCBA} = {AE2CE86A-8538-4142-920F-684DCF47C064}
{2FF9E656-0E88-4A0E-84EC-4FBB26001580} = {AE2CE86A-8538-4142-920F-684DCF47C064}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6E53AF28-A282-4FB0-A769-EAEA9769C02A}
......
......@@ -174,3 +174,10 @@ services:
context: .
dockerfile: Bailun.DC.SemiSkuWarehouseSales/Dockerfile
bailun.dc.costfirstmonitoring:
image: ${DOCKER_REGISTRY}bailundccostfirstmonitoring
build:
context: .
dockerfile: Bailun.DC.CostFirstMonitoring/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