Commit 5faed367 by lizefeng

新增缺货数据刷新服务

parent dcb3df55
......@@ -237,7 +237,6 @@ sum(t4.quantity_transfer) as 'realtime_quantity_transfer',
sum(t4.quantity_out_stock) as 'quantity_out_stock'
from
dc_base_stock as t1
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
left join dc_mid_transit as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
where 1=1";
......@@ -247,11 +246,11 @@ where 1=1";
sql = @"
select
(case when dbw.hq_type='fba仓' then dbw.bailun_account else dbw.warehouse_name end) as warehouse_name,
t3.sku_title_cn as 'sku_name',
t1.sku_title_cn as 'sku_name',
t4.quantity_purchase as 'purchase_daily_quantity',
t3.buyer_name,t3.sku_title_cn,t3.sku_title_en,t3.product_inner_code,
t3.buyer_name,t3.sku_title_en,t3.product_inner_code,
t4.quantity_purchase as 'realtime_quantity_purchase',t4.quantity_transfer as 'realtime_quantity_transfer',
t1.bailun_sku,t1.warehouse_code,t3.suppliers_name,t4.quantity_out_stock,t4.gmt_out_stock_modified,t3.weight,t3.unit_price,
t1.bailun_sku,t1.warehouse_code,t4.quantity_out_stock,t4.gmt_out_stock_modified,t3.weight,t3.unit_price,
t1.*
from
dc_base_stock as t1
......@@ -268,7 +267,6 @@ where 1=1
count(1)
from
dc_base_stock as t1
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
left join dc_mid_transit as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
where 1=1
......@@ -293,15 +291,15 @@ where 1=1
if (!string.IsNullOrWhiteSpace(product_inner_code))
{
sql += " and t3.product_inner_code like @product_inner_code ";
countSql += " and t3.product_inner_code like @product_inner_code ";
sql += " and t1.product_inner_code like @product_inner_code ";
countSql += " and t1.product_inner_code like @product_inner_code ";
parameters.Add("product_inner_code", $"%{product_inner_code}%");
}
if (!string.IsNullOrWhiteSpace(sku_title_cn))
{
sql += " and t3.sku_title_cn like @sku_title_cn ";
countSql += " and t3.sku_title_cn like @sku_title_cn ";
sql += " and t1.sku_title_cn like @sku_title_cn ";
countSql += " and t1.sku_title_cn like @sku_title_cn ";
parameters.Add("sku_title_cn", $"%{sku_title_cn}%");
}
......@@ -327,7 +325,7 @@ where 1=1
}
if (!string.IsNullOrWhiteSpace(supplier_name))
{
sql += " and t3.suppliers_name =@suppliers_name ";
sql += " and t1.suppliers_name =@suppliers_name ";
parameters.Add("suppliers_name", supplier_name);
}
......
......@@ -37,53 +37,49 @@ sum(dat.quantity_inventory) as 'quantity_inventory',
sum(dat.quantity_out_stock) as 'quantity_out_stock',
sum(dat.quantity_purchase) as 'quantity_purchase',
sum(dat.quantity_transfer) as 'quantity_transfer',
sum(t2.oneday_sales) as 'oneday_sales',
sum(t2.forecast_oneday_sales) as 'forecast_oneday_sales2',
-- sum(t2.oneday_sales) as 'oneday_sales',
-- sum(t2.forecast_oneday_sales) as 'forecast_oneday_sales2',
sum(dat.quantity_final_advise) as 'quantity_final_advise',
sum(dat.quantity_promotion) as 'quantity_promotion',
sum(dat.quantity_safe_inventory) as 'quantity_safe_inventory'
from dc_auto_turnover as dat
left join dc_auto_sales as t2 on t2.bailun_sku=dat.bailun_sku and dat.warehouse_code = t2.warehouse_code
left join dc_base_warehouse as t3 on dat.warehouse_code = t3.warehouse_code
left join dc_base_sku as t4 on dat.bailun_sku = t4.bailun_sku
left join dc_auto_config_sku_warehouse as t5 on dat.bailun_sku = t5.bailun_sku and dat.warehouse_code = t5.warehouse_code
where 1=1 ";
}
else
{
sql = @"select dat.*,t2.oneday_sales,t2.forecast_oneday_sales as 'forecast_oneday_sales2',
t4.product_inner_code,t4.product_code,t4.bailun_category_name,t4.buyer_name,
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status',t4.suppliers_name,
t4.bailun_category_name,
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status',
(t4.supplier_delivery - t6.virtual_delivery_days) as 'delivery_days_error',t4.weight,t4.unit_price,t7.usable_stock
from dc_auto_turnover as dat
left join dc_auto_sales as t2 on t2.bailun_sku=dat.bailun_sku and dat.warehouse_code = t2.warehouse_code
left join dc_base_warehouse as t3 on dat.warehouse_code = t3.warehouse_code
left join dc_base_sku as t4 on dat.bailun_sku = t4.bailun_sku
left join dc_auto_config_sku_warehouse as t5 on dat.bailun_sku = t5.bailun_sku and dat.warehouse_code = t5.warehouse_code
left join dc_average_purchase as t6 on dat.bailun_sku = t6.bailun_sku and dat.warehouse_code =t6.warehouse_code
left join dc_average_purchase as t6 on dat.bailun_sku = t6.bailun_sku and dat.warehouse_code =t6.warehouse_code and t4.suppliers_id = t6.supplier_id
left join dc_base_stock as t7 on dat.bailun_sku = t7.bailun_sku and dat.warehouse_code = t7.warehouse_code
where 1=1 ";
}
string sqlCount = @"select count(1)
from dc_auto_turnover as dat
-- left join dc_auto_sales as t2 on t2.bailun_sku=dat.bailun_sku and dat.warehouse_code = t2.warehouse_code
left join dc_base_warehouse as t3 on dat.warehouse_code = t3.warehouse_code
left join dc_base_sku as t4 on dat.bailun_sku = t4.bailun_sku
left join dc_auto_config_sku_warehouse as t5 on dat.bailun_sku = t5.bailun_sku and dat.warehouse_code = t5.warehouse_code
where 1=1 ";
if (m.categoryModels != null)
{
sql += " and t4.bailun_category_id in ( " + string.Join(",", m.categoryModels.Select(s => s.C_ID).Distinct()) + ")";
sqlCount += " and t4.bailun_category_id in ( " + string.Join(",", m.categoryModels.Select(s => s.C_ID).Distinct()) + ")";
sql += " and dat.bailun_category_id in ( " + string.Join(",", m.categoryModels.Select(s => s.C_ID).Distinct()) + ")";
sqlCount += " and dat.bailun_category_id in ( " + string.Join(",", m.categoryModels.Select(s => s.C_ID).Distinct()) + ")";
}
if (!string.IsNullOrWhiteSpace(m.buyer_name))
{
sql += " and t4.buyer_name = " + $"'{m.buyer_name}'";
sqlCount += " and t4.buyer_name = " + $"'{m.buyer_name}'";
sql += " and dat.buyer_name = " + $"'{m.buyer_name}'";
sqlCount += " and dat.buyer_name = " + $"'{m.buyer_name}'";
}
if (m.monitor_status == 1)
{
......@@ -106,21 +102,43 @@ where 1=1 ";
sql += " and dat.quantity_final_advise<=0 ";
sqlCount += " and dat.quantity_final_advise<=0 ";
}
if (!string.IsNullOrWhiteSpace(m.product_code))
{
sql += " and t4.product_code =" + $"'{m.product_code}'";
sqlCount += " and t4.product_code =" + $"'{m.product_code}'";
if (!string.IsNullOrWhiteSpace(m.key_words) && m.searchType > 0)
{
switch (m.searchType.Value)
{
case 1:
sql += " and dat.bailun_sku =" + $"'{m.key_words}'";
sqlCount += " and dat.bailun_sku =" + $"'{m.key_words}'";
break;
case 2:
sql += " and dat.bailun_sku like " + $"'%{m.key_words}%'";
sqlCount += " and dat.bailun_sku =" + $"'%{m.key_words}%'";
break;
case 3:
sql += " and dat.product_inner_code =" + $"'{m.key_words}'";
sqlCount += " and dat.product_inner_code =" + $"'{m.key_words}'";
break;
case 4:
sql += " and dat.product_inner_code like " + $"'%{m.key_words}%'";
sqlCount += " and dat.product_inner_code like" + $"'%{m.key_words}%'";
break;
case 5:
sql += " and dat.product_code =" + $"'{m.key_words}'";
sqlCount += " and dat.product_code =" + $"'{m.key_words}'";
break;
case 6:
sql += " and dat.product_code like " + $"'%{m.key_words}%'";
sqlCount += " and dat.product_code like" + $"'%{m.key_words}%'";
break;
case 7:
sql += " and dat.sku_title like " + $"'%{m.key_words}%'";
sqlCount += " and dat.sku_title like" + $"'%{m.key_words}%'";
break;
default: break;
}
if (!string.IsNullOrWhiteSpace(m.sku_name))
{
sql += " and dat.sku_title like" + $"'{m.sku_name}%'";
sqlCount += " and dat.sku_title like" + $"'{m.sku_name}%'";
}
if (!string.IsNullOrWhiteSpace(m.product_inner_code))
{
sql += " and t4.product_inner_code = " + $"'{m.product_inner_code}'";
sqlCount += " and t4.product_inner_code = " + $"'{m.product_inner_code}'";
}
if (m.hasDefectConfig == true)
{
sql += " and ( dat.abroad_inbound_delivery <=0 or dat.transfer_bale_delivery <=0 or dat.transfer_delivery <=0 ) ";
......@@ -141,16 +159,7 @@ where 1=1 ";
sql += " and t3.area_id=" + m.warehousearea;
sqlCount += " and t3.area_id=" + m.warehousearea;
}
if (!string.IsNullOrWhiteSpace(m.sku_prefix))
{
sql += " and dat.bailun_sku like '" + m.sku_prefix + "%'";
sqlCount += " and dat.bailun_sku like '" + m.sku_prefix + "%'";
}
if (!string.IsNullOrEmpty(m.bailun_sku))
{
sql += " and dat.bailun_sku = '" + m.bailun_sku + "'";
sqlCount += " and dat.bailun_sku = '" + m.bailun_sku + "'";
}
if (!string.IsNullOrEmpty(m.warehouse_code))
{
......@@ -165,8 +174,8 @@ where 1=1 ";
}
if (!string.IsNullOrWhiteSpace(m.supplier_name))
{
sql += " and t4.suppliers_name = '"+ m.supplier_name+"'";
sqlCount += " and t4.suppliers_name = '" + m.supplier_name + "'";
sql += " and dat.suppliers_name = '" + m.supplier_name + "'";
sqlCount += " and dat.suppliers_name = '" + m.supplier_name + "'";
}
if (isSum)
......@@ -199,7 +208,7 @@ where 1=1 ";
var obj = _connection.Query<Models.dc_auto_turnover_Extend>(sql,commandTimeout:0);
var obj = _connection.Query<Models.dc_auto_turnover_Extend>(sql, commandTimeout: 0);
return obj.AsList();
}
......
using AutoTurnOver.Models.Report;
using AutoTurnOver.Models;
using AutoTurnOver.Models.Report;
using Dapper;
using System;
using System.Collections.Generic;
......@@ -143,7 +144,7 @@ count(1)
from dc_base_oms_sku as t1
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where t1.create_time>'2019-03-01 12:00:00' and t1.bailun_picking_status!='TotalPicked' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part') and t_db.hq_type!='FBA仓'
where t1.create_time>'2019-03-01 12:00:00' and t1.bailun_picking_status!='TotalPicked' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part') and t1.platform_type!='FBA'
";
sql = @"
select
......@@ -189,19 +190,19 @@ FROM
WHERE
( ( `t2`.`hq_type` = '国内仓' and t1.warehouse_code not in('GZBLZZG','QYBLZZC','SZBLZZC') ) AND ( `t1`.`bailun_picking_status` <> 'TotalPicked' ) AND ( `t1`.`create_time` > '2019-03-01 12:00:00' ) ) and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part')
";
if(!string.IsNullOrWhiteSpace(m.bailun_sku))
if (!string.IsNullOrWhiteSpace(m.bailun_sku))
{
sql += $" and bailun_sku= '{m.bailun_sku}' ";
}
sql+= @" GROUP BY
sql += @" GROUP BY
`t1`.`bailun_sku`
) as t4 on t1.bailun_sku = t4.bailun_sku and t_db.hq_type='国内仓'
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
left join view_buy_ontheway_detail as t8 on t1.bailun_sku = t8.bailun_sku and t1.warehouse_code = t8.warehouse_code
where t1.bailun_picking_status!='TotalPicked' and t1.create_time>'2019-03-01 12:00:00' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part') and t_db.hq_type!='FBA仓'
where t1.bailun_picking_status!='TotalPicked' and t1.create_time>'2019-03-01 12:00:00' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part') and t1.platform_type!='FBA'
";
if (!string.IsNullOrWhiteSpace(m.product_inner_code))
{
......@@ -238,7 +239,7 @@ where t1.bailun_picking_status!='TotalPicked' and t1.create_time>'2019-03-01 12:
parameters.Add("buyer_name", m.purchase_user);
}
if ( limit > 10000)
if (limit > 10000)
{
total = 0;
}
......@@ -272,5 +273,41 @@ where t1.bailun_picking_status!='TotalPicked' and t1.create_time>'2019-03-01 12:
return list;
}
}
/// <summary>
/// 刷新缺货数据
/// </summary>
public static void ResetOutofstock()
{
try
{
_connection.Execute(@" -- 刷新缺货明细表
set session transaction isolation level read uncommitted;
start transaction;
-- 清空视图表的数据
Truncate table dc_base_oms_sku_outofstock;
INSERT into dc_base_oms_sku_outofstock (
select
t1.*
from dc_base_oms_sku as t1
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where t1.create_time>'2019-03-01 12:00:00' and t1.bailun_picking_status!='TotalPicked' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part') and t1.platform_type!='FBA'
)", commandTimeout: 0);
}
catch (Exception ex)
{
_connection.Insert<dc_task_error_log>(new dc_task_error_log {
date = DateTime.Now,
message = ex.Message,
stack_trace =ex.StackTrace,
task_name = "ResetOutofstock"
});
}
}
}
}
......
......@@ -265,19 +265,13 @@ namespace AutoTurnOver.Models
public class Condition_AutoTurnOver
{
/// <summary>
/// SKU
/// </summary>
public string bailun_sku { get; set; }
public string buyer_name { get; set; }
public string supplier_name { get; set; }
/// <summary>
/// sku 前缀
/// </summary>
public string sku_prefix { get; set; }
/// <summary>
/// 仓库编码
......@@ -303,21 +297,15 @@ namespace AutoTurnOver.Models
/// </summary>
public bool? hasDefectConfig { get; set; }
/// <summary>
/// 内部编码
/// </summary>
public string product_inner_code { get; set; }
/// <summary>
/// 商品中文名
/// 搜索关键词
/// </summary>
public string sku_name { get; set; }
public string key_words { get; set; }
/// <summary>
/// 商品编码
/// </summary>
public string product_code { get; set; }
public int? searchType { get; set; }
/// <summary>
/// 是否建议下单
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class dc_task_error_log
{
public int id { get; set; }
public string task_name { get; set; }
public DateTime date { get; set; }
public string message { get; set; }
public string stack_trace { get; set; }
}
}
......@@ -20,7 +20,7 @@ namespace AutoTurnOver.Purchase.AverageTarget
{
Console.WriteLine("采购平均值计算任务启动...");
// 创建采购计划
PurchaseAverageTargetServices.Calculation();
//PurchaseAverageTargetServices.Calculation();
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
......
......@@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTurnOver.Purchase.Avera
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoGeneratePurchaseAdvise", "AutoGeneratePurchaseAdvise\AutoGeneratePurchaseAdvise.csproj", "{350405A0-13DF-4F20-8B3F-0AB923BE9DFF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResetOutofstock", "ResetOutofstock\ResetOutofstock.csproj", "{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -53,6 +55,10 @@ Global
{350405A0-13DF-4F20-8B3F-0AB923BE9DFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{350405A0-13DF-4F20-8B3F-0AB923BE9DFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{350405A0-13DF-4F20-8B3F-0AB923BE9DFF}.Release|Any CPU.Build.0 = Release|Any CPU
{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -60,6 +66,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{DD5C8D24-7098-4708-A1AC-ACFBB5EBBD6C} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{350405A0-13DF-4F20-8B3F-0AB923BE9DFF} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
{6DD5D4C8-5DAC-4327-9C8A-08B6CCD6713D} = {C1F6DDE1-217D-43D6-81B5-91A7E78A7876}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {09B3C433-2F6E-498C-AB7C-2931F260C5CE}
......
......@@ -28,22 +28,19 @@ namespace AutoTurnOver.Controllers
/// <param name="pagesize">每页记录数</param>
/// <returns></returns>
[HttpGet]
public JsonResult List(int limit, int offset, string order, string sort, string sku, string sku_prefix, string buyer_name, int? IsRedundant, int? IsStockOut, string warehousecode,string supplier_name, string warehousetype, int? warehousearea, bool? hasDefectConfig, string product_inner_code, string sku_name, string product_code, bool? hasAadvise = null, string categoryIds = null, int? monitor_status = null)
public JsonResult List(int limit, int offset, string order, string sort, int? searchType, string key_words, string buyer_name, int? IsRedundant, int? IsStockOut, string warehousecode,string supplier_name, string warehousetype, int? warehousearea, bool? hasDefectConfig, bool? hasAadvise = null, string categoryIds = null, int? monitor_status = null)
{
var m = new Condition_AutoTurnOver
{
bailun_sku = sku,
sku_prefix = sku_prefix,
searchType = searchType,
key_words = key_words,
out_of_stock = IsStockOut,
redundancy = IsRedundant,
warehouse_code = warehousecode,
warehousetype = warehousetype,
warehousearea = warehousearea,
hasDefectConfig = hasDefectConfig,
product_inner_code = product_inner_code,
sku_name = sku_name,
product_code = product_code,
hasAadvise = hasAadvise,
categoryIds = categoryIds,
monitor_status = monitor_status,
......@@ -95,21 +92,18 @@ namespace AutoTurnOver.Controllers
});
}
public JsonResult ListSumFooter(string supplier_name, int limit, int offset, string order, string sort, string sku,string buyer_name, string sku_prefix, int? IsRedundant, int? IsStockOut, string warehousecode, string warehousetype, int? warehousearea, bool? hasDefectConfig, string product_inner_code, string sku_name, string product_code, bool? hasAadvise = null, string categoryIds = null, int? monitor_status = null)
public JsonResult ListSumFooter(string supplier_name, int limit, int offset, string order, string sort, int? searchType, string key_words,string buyer_name, string sku_prefix, int? IsRedundant, int? IsStockOut, string warehousecode, string warehousetype, int? warehousearea, bool? hasDefectConfig, bool? hasAadvise = null, string categoryIds = null, int? monitor_status = null)
{
var m = new Condition_AutoTurnOver
{
bailun_sku = sku,
sku_prefix = sku_prefix,
searchType = searchType,
key_words = key_words,
out_of_stock = IsStockOut,
redundancy = IsRedundant,
warehouse_code = warehousecode,
warehousetype = warehousetype,
warehousearea = warehousearea,
hasDefectConfig = hasDefectConfig,
product_inner_code = product_inner_code,
sku_name = sku_name,
product_code = product_code,
hasAadvise = hasAadvise,
categoryIds = categoryIds,
monitor_status = monitor_status,
......@@ -129,21 +123,18 @@ namespace AutoTurnOver.Controllers
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public FileResult Export(string supplier_name, int limit, int offset, string order, string sort, string sku,string buyer_name, string sku_prefix, int? IsRedundant, int? IsStockOut, string warehousecode, string warehousetype, int? warehousearea, bool? hasDefectConfig, string product_inner_code, string sku_name, string product_code, bool? hasAadvise = null, string categoryIds = null, int? monitor_status = null)
public FileResult Export(string supplier_name, int limit, int offset, string order, string sort, int? searchType, string key_words, string buyer_name, string sku_prefix, int? IsRedundant, int? IsStockOut, string warehousecode, string warehousetype, int? warehousearea, bool? hasDefectConfig, bool? hasAadvise = null, string categoryIds = null, int? monitor_status = null)
{
var m = new Condition_AutoTurnOver
{
bailun_sku = sku,
sku_prefix = sku_prefix,
searchType = searchType,
key_words = key_words,
out_of_stock = IsStockOut,
redundancy = IsRedundant,
warehouse_code = warehousecode,
warehousetype = warehousetype,
warehousearea = warehousearea,
hasDefectConfig = hasDefectConfig,
product_inner_code = product_inner_code,
sku_name = sku_name,
product_code = product_code,
hasAadvise = hasAadvise,
categoryIds = categoryIds,
monitor_status = monitor_status,
......
FROM microsoft/dotnet:2.1-runtime-alpine 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-alpine AS build
WORKDIR /src
COPY ResetOutofstock/ResetOutofstock.csproj ResetOutofstock/
COPY AutoTurnOver.DB/AutoTurnOver.DB.csproj AutoTurnOver.DB/
COPY AutoTurnOver.Utility/AutoTurnOver.Utility.csproj AutoTurnOver.Utility/
COPY AutoTurnOver.Models/AutoTurnOver.Models.csproj AutoTurnOver.Models/
RUN dotnet restore ResetOutofstock/ResetOutofstock.csproj
COPY . .
WORKDIR /src/ResetOutofstock
RUN dotnet build ResetOutofstock.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish ResetOutofstock.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ResetOutofstock.dll"]
using AutoTurnOver.DB;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;
namespace ResetOutofstock
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("刷新缺货数据任务启动...");
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<ResetOutofstockBackgrounService>();
});
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"
}
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AutoTurnOver.DB\AutoTurnOver.DB.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>
using AutoTurnOver.DB;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ResetOutofstock
{
public class ResetOutofstockBackgrounService : BackgroundService
{
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(10));
return Task.CompletedTask;
}
private void DoWork(object state)
{
try
{
Console.WriteLine($"开始刷新缺货明细数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.ResetOutofstock();
Console.WriteLine($"结束刷新缺货明细数据任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public override void Dispose()
{
base.Dispose();
_timer?.Dispose();
}
}
}
{
"ConnectionStrings": {
"Default": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
}
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
}
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
}
}
\ No newline at end of file
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