Commit 608d31e4 by lizefeng

周转表锁定前3列,新增商品编码,新增汇总行

parent e52b7484
......@@ -25,16 +25,43 @@ namespace AutoTurnOver.DB
/// <param name="order">排序类型</param>
/// <param name="sort">排序字段</param>
/// <returns></returns>
public static List<Models.dc_auto_turnover_Extend> List(Condition_AutoTurnOver m,int offset, int limit, ref int total,string order="",string sort= "")
public static List<Models.dc_auto_turnover_Extend> List(Condition_AutoTurnOver m,int offset, int limit, ref int total,string order="",string sort= "",bool isSum=false)
{
try
{
var sql = @"select dat.*,t2.oneday_sales,t2.forecast_oneday_sales as 'forecast_oneday_sales2',t4.product_inner_code from dc_auto_turnover as dat
var sql = "";
if (isSum)
{
sql = @"select
sum(dat.quantity_inventory) as 'quantity_inventory',
sum(dat.quantity_inventory) 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(dat.quantity_final_advise) as 'quantity_final_advise',
sum(dat.quantity_promotion) as 'quantity_promotion'
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
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 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
where 1=1 ";
}
if (!string.IsNullOrWhiteSpace(m.product_code))
{
sql += " and t4.product_code like" + $"'%{m.product_code}%'";
}
if (!string.IsNullOrWhiteSpace(m.sku_name))
{
sql += " and dat.sku_title like" + $"'%{m.sku_name}%'";
......@@ -74,31 +101,43 @@ where 1=1 ";
sql += " and dat.status=1";
}
total = _connection.ExecuteScalar<int>("select count(0) from ("+sql+") tb1");
//设置默认排序字段
if (string.IsNullOrWhiteSpace(sort)) sort = "quantity_init_advise";
if (!string.IsNullOrEmpty(sort))
if (isSum)
{
total = 0;
}
else
{
sql += " order by " + sort;
total = _connection.ExecuteScalar<int>("select count(0) from (" + sql + ") tb1");
if (!string.IsNullOrEmpty(order))
{
sql += " " + order;
}
else
//设置默认排序字段
if (string.IsNullOrWhiteSpace(sort)) sort = "quantity_init_advise";
if (!string.IsNullOrEmpty(sort))
{
sql += " asc";
sql += " order by " + sort;
if (!string.IsNullOrEmpty(order))
{
sql += " " + order;
}
else
{
sql += " asc";
}
}
sql += " limit " + offset + "," + limit;
}
var obj = _connection.Query<Models.dc_auto_turnover_Extend>(sql+ " limit " + offset + "," + limit);
var obj = _connection.Query<Models.dc_auto_turnover_Extend>(sql);
return obj.AsList();
}
catch (Exception)
{
{
return new List<Models.dc_auto_turnover_Extend>();
}
......
......@@ -240,6 +240,11 @@ namespace AutoTurnOver.Models
/// 商品中文名
/// </summary>
public string sku_name { get; set; }
/// <summary>
/// 商品编码
/// </summary>
public string product_code { get; set; }
}
public class dc_auto_turnover_Extend : dc_auto_turnover
......
......@@ -19,9 +19,9 @@ namespace AutoTurnOver.Services
/// <param name = "order" > 排序类型 </ param >
/// <param name="sort">排序字段</param>
/// <returns></returns>
public List<dc_auto_turnover_Extend> List(Condition_AutoTurnOver m,int offset, int limit, ref int total,string order="",string sort="")
public List<dc_auto_turnover_Extend> List(Condition_AutoTurnOver m,int offset, int limit, ref int total,string order="",string sort="",bool isSum = false)
{
return DB.dc_auto_turnover.List(m,offset, limit, ref total,order,sort);
return DB.dc_auto_turnover.List(m,offset, limit, ref total,order,sort, isSum);
}
#region 特殊销售设置
......
......@@ -27,7 +27,7 @@ namespace AutoTurnOver.Controllers
/// <param name="pagesize">每页记录数</param>
/// <returns></returns>
[HttpGet]
public JsonResult List(int limit, int offset, string order,string sort,string sku,int? IsRedundant,int? IsStockOut,string warehousecode,string warehousetype,int? warehousearea,bool? hasDefectConfig,string product_inner_code,string sku_name)
public JsonResult List(int limit, int offset, string order,string sort,string sku,int? IsRedundant,int? IsStockOut,string warehousecode,string warehousetype,int? warehousearea,bool? hasDefectConfig,string product_inner_code,string sku_name,string product_code)
{
var m = new Condition_AutoTurnOver {
......@@ -39,7 +39,8 @@ namespace AutoTurnOver.Controllers
warehousearea = warehousearea,
hasDefectConfig = hasDefectConfig,
product_inner_code = product_inner_code,
sku_name = sku_name
sku_name = sku_name,
product_code = product_code
};
var total = 0;
......@@ -78,6 +79,28 @@ namespace AutoTurnOver.Controllers
});
}
public JsonResult ListSumFooter(int limit, int offset, string order, string sort, string sku, int? IsRedundant, int? IsStockOut, string warehousecode, string warehousetype, int? warehousearea, bool? hasDefectConfig, string product_inner_code, string sku_name, string product_code)
{
var m = new Condition_AutoTurnOver
{
bailun_sku = sku,
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
};
var total = 0;
var service = new Services.SkuAutoTurnServices();
var list = service.List(m, offset, limit, ref total, order, sort,true);
return new JsonResult(list[0]);
}
/// <summary>
/// 导出
/// </summary>
......
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