Commit c4392fab by lizefeng

异常提醒页面新增 建议下单次数字段

parent 32b696fe
......@@ -12,7 +12,7 @@ namespace AutoGeneratePurchaseAdvise
{
Console.WriteLine("采购建议计算任务启动...");
// 创建采购计划
PurchaseAdviseServices.Generate();
//PurchaseAdviseServices.Generate();
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
services.AddHostedService<GeneratePurchaseAdviseBackgroundService>();
......
......@@ -14,7 +14,7 @@ namespace AutoTurnOver.DB
/// <param name="sku"></param>
/// <param name="warehouse_code"></param>
/// <returns></returns>
public static IEnumerable<AutoTurnOver.Models.dc_auto_forecast_fluctuation> List(dc_auto_forecast_fluctuation_search_dto data, int offset, int limit, ref int total,string order = "", string sort = "")
public static IEnumerable<AutoTurnOver.Models.dc_auto_forecast_fluctuation_dto> List(dc_auto_forecast_fluctuation_search_dto data, int offset, int limit, ref int total,string order = "", string sort = "")
{
var sql = @"
select t1.* from dc_auto_forecast_fluctuation as t1
......@@ -99,7 +99,15 @@ where 1 = 1
}
}
var obj = _connection.Query<Models.dc_auto_forecast_fluctuation>(sql + " limit " + offset + "," + limit, parameters);
var obj = _connection.Query<Models.dc_auto_forecast_fluctuation_dto>(sql + " limit " + offset + "," + limit, parameters);
if (obj != null)
{
foreach (var item in obj)
{
item.purchase_advise_count = _connection.QuerySingleOrDefault<int>(" select count(1) from dc_auto_purchase_advise_detailed where warehouse_code=@warehouse_code and bailun_sku=@bailun_sku ",new { item.warehouse_code,item.bailun_sku});
}
}
return obj.AsList();
}
......
......@@ -101,8 +101,8 @@ where 1=1 ";
}
if (!string.IsNullOrWhiteSpace(m.product_code))
{
sql += " and t4.product_code like" + $"'%{m.product_code}%'";
sqlCount += " and t4.product_code like" + $"'%{m.product_code}%'";
sql += " and t4.product_code =" + $"'{m.product_code}'";
sqlCount += " and t4.product_code =" + $"'{m.product_code}'";
}
if (!string.IsNullOrWhiteSpace(m.sku_name))
{
......@@ -111,8 +111,8 @@ where 1=1 ";
}
if (!string.IsNullOrWhiteSpace(m.product_inner_code))
{
sql += " and t4.product_inner_code like " + $"'%{m.product_inner_code}%'";
sqlCount += " and t4.product_inner_code like " + $"'%{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)
{
......@@ -136,8 +136,8 @@ where 1=1 ";
}
if (!string.IsNullOrEmpty(m.bailun_sku))
{
sql += " and dat.bailun_sku like '%" + m.bailun_sku + "%'";
sqlCount += " and dat.bailun_sku like '%" + 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))
......
......@@ -237,7 +237,8 @@ where 1=1 ";
if (!string.IsNullOrWhiteSpace(m.product_inner_code))
{
sql += " and t3.product_inner_code=" + m.product_inner_code;
sql += " and t3.product_inner_code=@product_inner_code ";
parameters.Add("product_inner_code", m.product_inner_code);
}
if (m.type != null)
{
......@@ -292,6 +293,16 @@ where 1=1 ";
sql += " and t3.buyer_name =@buyer_name ";
parameters.Add("buyer_name", m.purchase_user);
}
if (m.quantity_final_advise_price_min > 0)
{
sql += " and (t3.unit_price * t1.quantity_final_advise)>=@quantity_final_advise_price_min ";
parameters.Add("quantity_final_advise_price_min", m.quantity_final_advise_price_min);
}
if (m.quantity_final_advise_price_max > 0)
{
sql += " and (t3.unit_price * t1.quantity_final_advise)<=@quantity_final_advise_price_max ";
parameters.Add("quantity_final_advise_price_max", m.quantity_final_advise_price_max);
}
if (m.is_multiple_warehouse)
{
......
......@@ -79,6 +79,13 @@ namespace AutoTurnOver.Models
public decimal avg_sales_three { get; set; }
}
public class dc_auto_forecast_fluctuation_dto: dc_auto_forecast_fluctuation {
/// <summary>
/// 出过采购建议的数量
/// </summary>
public int purchase_advise_count { get; set; }
}
public class dc_auto_forecast_fluctuation_search_dto
{
public string sku { get; set; }
......
......@@ -254,6 +254,10 @@ namespace AutoTurnOver.Models
/// 是否是同区多仓的sku
/// </summary>
public bool is_multiple_warehouse { get; set; }
public decimal? quantity_final_advise_price_min { get; set; }
public decimal? quantity_final_advise_price_max { get; set; }
}
}
......@@ -10,7 +10,7 @@ namespace AutoTurnOver.Services
/// </summary>
public class ExceptionReminderServices
{
public IEnumerable<dc_auto_forecast_fluctuation> List(dc_auto_forecast_fluctuation_search_dto data, int offset, int limit, ref int total, string order = "", string sort = "")
public IEnumerable<dc_auto_forecast_fluctuation_dto> List(dc_auto_forecast_fluctuation_search_dto data, int offset, int limit, ref int total, string order = "", string sort = "")
{
return DB.dc_auto_forecast_fluctuation.List(data, offset, limit, ref total, order, sort);
}
......
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using AutoTurnOver.Common;
......@@ -40,6 +42,67 @@ namespace AutoTurnOver.Controllers
});
}
public FileResult Export(int limit, int offset, string order, string sort, string sku, string warehousecode, string warehousetype, int? warehousearea,
bool? has_overdue = null, bool? has_confirm = null, bool? has_solve = null, int? err_type = null)
{
var m = new dc_auto_forecast_fluctuation_search_dto
{
sku = sku,
warehouse_code = warehousecode,
has_overdue = has_overdue,
has_confirm = has_confirm,
has_solve = has_solve,
warehousetype = warehousetype,
warehousearea = warehousearea,
err_type = err_type
};
var total = 0;
var service = new Services.ExceptionReminderServices();
var list = service.List(m, 0, int.MaxValue, ref total, order, sort);
DataTable table = new DataTable();
string[] cols = new string[] { "建议下单次数","Sku","仓库编码","仓库名称","最近3日日均","异常类型","开始时间","结束时间","是否确认","确认人","预计解决时间",
"处理方案","是否解决"
};
foreach (var item in cols)
{
table.Columns.Add(item);
}
foreach (var itemData in list)
{
DataRow row = table.NewRow();
row["建议下单次数"] = itemData.purchase_advise_count;
row["Sku"] = itemData.bailun_sku;
row["仓库编码"] = itemData.warehouse_code;
row["仓库名称"] = itemData.warehouse_name;
row["最近3日日均"] = itemData.avg_sales_three;
row["异常类型"] = itemData.bailun_sku;
row["开始时间"] = itemData.typeStr;
row["结束时间"] = itemData.end_time;
row["是否确认"] = itemData.has_confirm==1?"是":"否";
row["确认人"] = itemData.bl_operator;
row["预计解决时间"] = itemData.forecast_solve_time;
row["处理方案"] = itemData.remark;
row["是否解决"] = itemData.has_solve == 1 ? "是" : "否";
table.Rows.Add(row);
}
var fileName = AppContext.BaseDirectory + @"Result\RealtimeStock\异常提醒.csv";
DataTableHelper.SaveCSV(table, fileName);
var memory = new MemoryStream();
using (var stream = new FileStream(fileName, FileMode.Open))
{
stream.CopyTo(memory);
}
memory.Position = 0;
return File(memory, "text/csv", "异常提醒.csv");
}
/// <summary>
/// 异常提醒详情
/// </summary>
......
......@@ -61,7 +61,8 @@ namespace AutoTurnOver.Controllers
[HttpGet]
public string DetailList(int limit, int offset, int main_id, string sort, string sku, string warehousecode,
DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea, string order,
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool? is_multiple_warehouse = false)
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool? is_multiple_warehouse = false,
decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null)
{
var m = new dc_auto_purchase_advise_detailed_search_dto
{
......@@ -77,7 +78,9 @@ namespace AutoTurnOver.Controllers
supplier_name = supplier_name,
purchase_user = purchase_user,
product_inner_code = product_inner_code,
is_multiple_warehouse = is_multiple_warehouse.Value
is_multiple_warehouse = is_multiple_warehouse.Value,
quantity_final_advise_price_max = quantity_final_advise_price_max,
quantity_final_advise_price_min = quantity_final_advise_price_min
};
var total = 0;
......@@ -103,7 +106,8 @@ namespace AutoTurnOver.Controllers
[HttpGet]
public JsonResult DetailListSumFooter(int limit, int offset, int main_id, string sort, string sku, string warehousecode,
DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea,
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null,bool is_multiple_warehouse = false
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null,bool is_multiple_warehouse = false,
decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null
)
{
var m = new dc_auto_purchase_advise_detailed_search_dto
......@@ -121,7 +125,9 @@ namespace AutoTurnOver.Controllers
purchase_user = purchase_user,
product_inner_code = product_inner_code,
isSum = true,
is_multiple_warehouse = is_multiple_warehouse
is_multiple_warehouse = is_multiple_warehouse,
quantity_final_advise_price_max = quantity_final_advise_price_max,
quantity_final_advise_price_min = quantity_final_advise_price_min
};
var total = 0;
......@@ -136,7 +142,11 @@ namespace AutoTurnOver.Controllers
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public FileResult Export(int main_id, string sort, string sku, string warehousecode, DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea, bool? ispush = null,bool is_multiple_warehouse = false)
public FileResult Export(int limit, int offset, int main_id, string sort, string sku, string warehousecode,
DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea,
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool is_multiple_warehouse = false,
decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null
)
{
var m = new dc_auto_purchase_advise_detailed_search_dto
{
......@@ -148,7 +158,14 @@ namespace AutoTurnOver.Controllers
warehousearea = warehousearea,
warehousetype = warehousetype,
ispush = ispush,
is_multiple_warehouse = is_multiple_warehouse
type = type,
supplier_name = supplier_name,
purchase_user = purchase_user,
product_inner_code = product_inner_code,
isSum = false,
is_multiple_warehouse = is_multiple_warehouse,
quantity_final_advise_price_max = quantity_final_advise_price_max,
quantity_final_advise_price_min = quantity_final_advise_price_min
};
var total = 0;
......@@ -266,7 +283,8 @@ namespace AutoTurnOver.Controllers
/// <returns></returns>
public JsonResult PushBuySys(int limit, int offset, int main_id, string sort, string sku, string warehousecode,
DateTime? end_date, DateTime? start_date, string warehousetype, int? warehousearea, string order,
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool? is_multiple_warehouse = false)
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null, bool? is_multiple_warehouse = false,
decimal? quantity_final_advise_price_max = null, decimal? quantity_final_advise_price_min = null)
{
try
{
......@@ -284,7 +302,9 @@ namespace AutoTurnOver.Controllers
supplier_name = supplier_name,
purchase_user = purchase_user,
product_inner_code = product_inner_code,
is_multiple_warehouse = is_multiple_warehouse.Value
is_multiple_warehouse = is_multiple_warehouse.Value,
quantity_final_advise_price_max = quantity_final_advise_price_max,
quantity_final_advise_price_min = quantity_final_advise_price_min
};
var total = 0;
......
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