Commit cc8a85f4 by 泽锋 李

完善预测销量配置

parent 641beeb1
...@@ -44,6 +44,7 @@ namespace AutoTurnOver.Models ...@@ -44,6 +44,7 @@ namespace AutoTurnOver.Models
public class dc_auto_sales_forecast_stage_config public class dc_auto_sales_forecast_stage_config
{ {
public int id { get; set; }
public int config_id { get; set; } public int config_id { get; set; }
public int index { get; set; } public int index { get; set; }
/// <summary> /// <summary>
......
...@@ -755,6 +755,52 @@ namespace AutoTurnOver.Services ...@@ -755,6 +755,52 @@ namespace AutoTurnOver.Services
public void SaveSalesForecastConfig(Models.dc_auto_sales_forecast_config_dto m, string username) public void SaveSalesForecastConfig(Models.dc_auto_sales_forecast_config_dto m, string username)
{ {
if (m.screen_type <=0)
{
throw new Exception("筛选类型必选");
}
if (string.IsNullOrWhiteSpace(m.warehouse_area_id)|| string.IsNullOrWhiteSpace(m.warehouse_code)|| string.IsNullOrWhiteSpace(m.warehouse_type))
{
throw new Exception("仓库类型、国家、仓库 中,至少选择一种");
}
if (string.IsNullOrWhiteSpace(m.title))
{
throw new Exception("规则标题必填");
}
foreach (var item in m.stages)
{
if (item.index == 1
||
(m.screen_type==1 && (item.duration_upper_limit>0 || item.duration_lower_limit>0))
||
(m.screen_type == 2 && (item.sales_upper_limit > 0 || item.sales_lower_limit > 0))
)
{
if (item.one_ratio + item.two_ratio + item.three_ratio != 1)
{
throw new Exception($" 第 {item.index} 阶段的 三个时间段范围比例相加不等 1 ");
}
}
else
{
if (item.index == 1)
{
throw new Exception($"第1阶段的 {(m.screen_type==1?"入库时长":"销量范围")} 必填");
}
}
if(item.one_n2+ item.one_n4 + item.one_n6!=1)
{
throw new Exception($" 第 {item.index} 阶段的 底 1 个时间段范围 的 3个加权值相加不等与1 ");
}
if (item.two_n2 + item.two_n4 + item.two_n6 != 1)
{
throw new Exception($" 第 {item.index} 阶段的 底 2 个时间段范围 的 3个加权值相加不等与1 ");
}
if (item.three_n2 + item.three_n4 + item.three_n6 != 1)
{
throw new Exception($" 第 {item.index} 阶段的 底 3 个时间段范围 的 3个加权值相加不等与1 ");
}
}
DB.db_config.SaveSalesForecastConfig(m, username); DB.db_config.SaveSalesForecastConfig(m, username);
} }
......
...@@ -765,11 +765,11 @@ namespace AutoTurnOver.Controllers ...@@ -765,11 +765,11 @@ namespace AutoTurnOver.Controllers
try try
{ {
new Services.ConfigServices().SaveSalesForecastConfig(m, ""); new Services.ConfigServices().SaveSalesForecastConfig(m, "");
return new JsonResult(""); return Json(new { success = true });
} }
catch (Exception ex) catch (Exception ex)
{ {
return new JsonResult(ex.Message); return Json(new { success =false,message = ex.Message });
} }
} }
......
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