Commit f1a27ec2 by lizefeng

新增突增异常配置

parent 90770c83
......@@ -24,12 +24,12 @@ namespace AutoGeneratePurchaseAdvise
{
var now = DateTime.Now;
if (now.Day==11 && now.Hour == 20 && now.Minute == 29)
{
Console.WriteLine($"开始推送 jit甲油采购建议 任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
PurchaseAdviseServices.AutoPushBuySys(1);
Console.WriteLine($"结束推送 jit甲油采购建议 任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
//if (now.Day==11 && now.Hour == 20 && now.Minute == 29)
//{
// Console.WriteLine($"开始推送 jit甲油采购建议 任务,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
// PurchaseAdviseServices.AutoPushBuySys(1);
// Console.WriteLine($"结束推送 jit甲油采购建议 任务,线程Id:{Thread.CurrentThread.ManagedThreadId},{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
//}
if (now.Hour == 5 && now.Minute == 29)
{
......
......@@ -12,7 +12,7 @@ namespace AutoGeneratePurchaseAdvise
static async Task Main(string[] args)
{
Console.WriteLine("采购建议计算任务启动...");
//PurchaseAdviseServices.AutoPushBuySys(1);
//PurchaseAdviseServices.Generate();
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<GeneratePurchaseAdviseBackgroundService>();
......
......@@ -1328,5 +1328,95 @@ and start_date<=@end_date and end_date>=@start_date
}
#endregion
#region 暴增配置
public static List<dc_auto_uprush_config_dto> UprushConfigList(dc_auto_uprush_config_search_dto m, int offset, int limit, ref int total)
{
var list = new List<dc_auto_uprush_config_dto>();
try
{
var sql = @"select t1.*,t3.warehouse_name from dc_auto_uprush_config as t1 left join dc_base_warehouse as t3 on t1.warehouse_code = t3.warehouse_code where 1 = 1 ";
if (!string.IsNullOrEmpty(m.warehouse_code))
{
sql += " and t1.warehouse_code='" + m.warehouse_code + "'";
}
else
{
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and t3.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and t3.area_id=" + m.warehousearea;
}
}
total = _connection.ExecuteScalar<int>("select count(0) from (" + sql + ") tb1");
var obj = _connection.Query<dc_auto_uprush_config_dto>(sql + " limit " + offset + "," + limit);
return obj.AsList();
}
catch (Exception)
{
return list;
}
}
public static string SaveUprushConfig(Models.dc_auto_uprush_config m, string username)
{
var obj = _connection.QueryFirstOrDefault<Models.dc_auto_uprush_config>("select * from dc_auto_uprush_config where id=" + m.id);
if (obj == null)
{
obj = new dc_auto_uprush_config
{
};
}
obj.id = m.id;
obj.warehouse_code = m.warehouse_code;
obj.percentage = m.percentage;
// 检查该数据是否有存在
var oldData = _connection.QueryFirstOrDefault(" select * from dc_auto_uprush_config where warehouse_code=@warehouse_code and id!=@id ", new { m.warehouse_code, m.id });
if (oldData != null)
{
return $" 仓库:【{m.warehouse_code}】已经配置过了 ";
}
try
{
if (obj.id > 0)
{
var result = _connection.Update<Models.dc_auto_uprush_config>(obj);
return result > 0 ? "" : "保存异常,请重试!";
}
else
{
var result = _connection.Insert<Models.dc_auto_uprush_config>(obj);
return result.HasValue && result.Value > 0 ? "" : "提交异常,请重试!";
}
}
catch (Exception ex)
{
return ex.Message;
}
}
public static dc_auto_uprush_config GetUprushConfigById(int id)
{
return _connection.QueryFirstOrDefault<dc_auto_uprush_config>("select * from dc_auto_uprush_config where id=" + id);
}
#endregion
}
}
......@@ -14,4 +14,13 @@ namespace AutoTurnOver.Models
public string platform_type { get; set; }
}
public class dc_auto_uprush_config_search_dto
{
public string warehouse_code { get; set; }
public string warehousetype { get; set; }
public int? warehousearea { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class dc_auto_uprush_config
{
public int id { get; set; }
/// <summary>
/// 仓库
/// </summary>
public string warehouse_code { get; set; }
/// <summary>
/// 增长百分比
/// </summary>
public decimal percentage { get; set; }
}
public class dc_auto_uprush_config_dto : dc_auto_uprush_config
{
public string warehouse_name { get; set; }
}
}
......@@ -706,5 +706,35 @@ namespace AutoTurnOver.Services
}
#endregion
#region 暴增
public List<dc_auto_uprush_config_dto> UprushConfigList(dc_auto_uprush_config_search_dto m, int offset, int limit, ref int total)
{
return DB.db_config.UprushConfigList(m, offset, limit, ref total);
}
public string SaveUprushConfig(Models.dc_auto_uprush_config m, string username)
{
if (string.IsNullOrWhiteSpace(m.warehouse_code))
{
return "请选择仓库!";
}
// 查询百伦sku
var objWarehouse = DB.common.GetWareHouseByCode(m.warehouse_code);
if (objWarehouse == null)
{
return "系统找不到该仓库。";
}
return DB.db_config.SaveUprushConfig(m, username);
}
public dc_auto_uprush_config GetUprushConfigById(int id)
{
return DB.db_config.GetUprushConfigById(id);
}
#endregion
}
}
......@@ -652,5 +652,51 @@ namespace AutoTurnOver.Controllers
}
#endregion
#region 暴增配置
[HttpGet]
public JsonResult UprushConfigList(int limit, int offset, string order, string sort, string warehousecode, string warehousetype, int? warehousearea)
{
var m = new dc_auto_uprush_config_search_dto
{
warehouse_code = warehousecode,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var total = 0;
var service = new Services.ConfigServices();
var list = service.UprushConfigList(m, offset, limit, ref total);
return new JsonResult(new
{
rows = list,
total = total,
});
}
[HttpPost]
public JsonResult SaveUprushConfig([FromBody]dc_auto_uprush_config m)
{
try
{
var result = new Services.ConfigServices().SaveUprushConfig(m, "");
return new JsonResult(result);
}
catch (Exception ex)
{
return new JsonResult(ex.Message);
}
}
[HttpGet]
public JsonResult GetUprushConfigById(int id)
{
var m = new Services.ConfigServices().GetUprushConfigById(id);
return new JsonResult(m);
}
#endregion
}
}
\ 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