Commit 5ec2f2d4 by lizefeng

新增取消监控功能

parent 01686b99
......@@ -66,7 +66,7 @@ where 1=1
select
count(1)
from dc_base_stock as t1
left join ( select * from dc_daily_purchase where record_time>=@time and type=1) as t2 on t1.warehouse_code = t2.warehouse_code and t1.bailun_sku = t2.bailun_sku
-- left join ( select * from dc_daily_purchase where record_time>=@time and type=1) as t2 on t1.warehouse_code = t2.warehouse_code and t1.bailun_sku = t2.bailun_sku
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
where 1=1
......@@ -118,7 +118,7 @@ where 1=1
}
var obj = _connection.Query<dc_base_stock_dto>(sql + " limit " + offset + "," + limit, parameters);
var obj = _connection.Query<dc_base_stock_dto>(sql + " limit " + offset + "," + limit, parameters,buffered:false,commandTimeout:0);
total = _connection.QueryFirst<int>(countSql, parameters);
return obj.AsList();
}
......
......@@ -400,5 +400,65 @@ where 1 = 1 ";
#endregion
/// <summary>
/// 修改监控状态
/// </summary>
/// <param name="bailun_sku"></param>
/// <param name="warehouse_code"></param>
/// <param name="monitor_status"></param>
/// <returns></returns>
public static string MonitorStatus(string bailun_sku, string warehouse_code, int monitor_status)
{
if(monitor_status!=1 && monitor_status!=0)
{
throw new Exception("状态异常");
}
// 先检查当前状态
var oldData = _connection.QueryFirstOrDefault<dc_auto_config_sku_warehouse>($"select * from dc_auto_config_sku_warehouse where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ",new { bailun_sku,warehouse_code });
if (oldData == null || oldData.status == 0)
{
if (monitor_status == 0)
{
return "该数据当前已经正常监控,请勿重复操作";
}
}
if (oldData != null && oldData.status == 1)
{
if (monitor_status == 1)
{
return "该数据当前已经停止监控,请勿重复操作";
}
}
DateTime now = DateTime.Now;
if (oldData == null)
{
var newData = new dc_auto_config_sku_warehouse {
bailun_sku = bailun_sku,
warehouse_code =warehouse_code,
status = monitor_status,
gmt_create =now,
bl_operator ="",
sku_title = "",
warehouse_name ="",
gmt_modified =now
};
_connection.Insert<dc_auto_config_sku_warehouse>(newData);
}
else
{
_connection.Execute(" update dc_auto_config_sku_warehouse set status=@monitor_status where id=@id",new { monitor_status ,id= oldData.id});
}
return "";
}
}
}
......@@ -45,71 +45,110 @@ 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 from dc_auto_turnover as dat
t4.product_inner_code,t4.product_code,t4.bailun_category_name,
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status'
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 ";
}
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()) + ")";
}
if (m.monitor_status == 1)
{
sql += " and t5.`status`=1 ";
sqlCount += " and t5.`status`=1 ";
}
if (m.monitor_status == 0)
{
sql += " and ( t5.`status`=0 or t5.`status` is null ) ";
sqlCount += " and ( t5.`status`=0 or t5.`status` is null ) ";
}
if (m.hasAadvise == true)
{
sql = " and dat.quantity_final_advise>0 ";
sql += " and dat.quantity_final_advise>0 ";
sqlCount += " and dat.quantity_final_advise>0 ";
}
if (m.hasAadvise == false)
{
sql = " and dat.quantity_final_advise<=0 ";
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 like" + $"'%{m.product_code}%'";
sqlCount += " and t4.product_code like" + $"'%{m.product_code}%'";
}
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 like " + $"'%{m.product_inner_code}%'";
sqlCount += " and t4.product_inner_code like " + $"'%{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 ) ";
sqlCount += " and ( dat.abroad_inbound_delivery <=0 or dat.transfer_bale_delivery <=0 or dat.transfer_delivery <=0 ) ";
}
if(m.hasDefectConfig == false)
{
sql += " and ( dat.abroad_inbound_delivery >0 and dat.transfer_bale_delivery >0 and dat.transfer_delivery >0 ) ";
sqlCount += " and ( dat.abroad_inbound_delivery >0 and dat.transfer_bale_delivery >0 and dat.transfer_delivery >0 ) ";
}
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and t3.hq_type=" + $"'{m.warehousetype}'";
sqlCount += " and t3.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and t3.area_id=" + m.warehousearea;
sqlCount += " and t3.area_id=" + m.warehousearea;
}
if (!string.IsNullOrEmpty(m.bailun_sku))
{
sql += " and dat.bailun_sku like '%" + m.bailun_sku+"%'";
sqlCount += " and dat.bailun_sku like '%" + m.bailun_sku + "%'";
}
if (!string.IsNullOrEmpty(m.warehouse_code))
{
sql += " and dat.warehouse_code='" + m.warehouse_code+"'";
sqlCount += " and dat.warehouse_code='" + m.warehouse_code + "'";
}
if (m.out_of_stock.HasValue)
{
sql += " and dat.status=1";
sqlCount += " and dat.status=1";
}
if (isSum)
......@@ -118,7 +157,7 @@ where 1=1 ";
}
else
{
total = _connection.ExecuteScalar<int>("select count(0) from (" + sql + ") tb1");
total = _connection.ExecuteScalar<int>(sqlCount);
//设置默认排序字段
if (string.IsNullOrWhiteSpace(sort)) sort = "quantity_init_advise";
......
......@@ -54,7 +54,8 @@ INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quan
0 as 'ispush'
from dc_auto_turnover as t1
left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
where t1.quantity_final_advise>0
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where t1.quantity_final_advise>0 and ( t5.`status`=0 or t5.`status` is null )
)
", new { main_id = mainID });
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class dc_auto_config_sku_warehouse
{
public int id { get; set; }
public string bailun_sku { get; set; }
public string sku_title { get; set; }
public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
public DateTime gmt_create { get; set; }
public DateTime gmt_modified { get; set; }
public int status { get; set; }
public string bl_operator { get; set; }
}
}
......@@ -208,6 +208,11 @@ namespace AutoTurnOver.Models
/// </summary>
public decimal history_fourteenday_sales { get; set; }
/// <summary>
/// 销量预测算法
/// </summary>
public string sales_explain_details { get; set; }
}
public class Condition_AutoTurnOver
......@@ -263,6 +268,13 @@ namespace AutoTurnOver.Models
public bool? hasAadvise { get; set; }
/// <summary>
/// 监控状态
/// 1= 停止监控
/// 0 = 开启监控
/// </summary>
public int? monitor_status { get; set; }
/// <summary>
///百伦分类
/// </summary>
public string categoryIds { get; set; }
......@@ -297,6 +309,11 @@ namespace AutoTurnOver.Models
/// </summary>
public string bailun_category_name { get; set; }
/// <summary>
/// 是否停止监控
/// </summary>
public int monitor_status { get; set; }
}
......
......@@ -165,7 +165,7 @@ namespace AutoTurnOver.Models
/// <summary>
/// 内部系统采购在途
/// </summary>
public int purchase_daily_quantity { get; set; }
public int? purchase_daily_quantity { get; set; }
/// <summary>
/// 采购员名称
......
......@@ -345,5 +345,15 @@ namespace AutoTurnOver.Services
}
#endregion
/// <summary>
/// 获取安全库存规则设置详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public string MonitorStatus(string bailun_sku, string warehouse_code, int monitor_status)
{
return DB.db_config.MonitorStatus(bailun_sku, warehouse_code, monitor_status);
}
}
}
......@@ -42,6 +42,7 @@ namespace AutoTurnOver.Services
list.Add(sales != null ? sales.sales_details.ToObj<List<decimal>>().Select(s => (int)s).ToJson() : "[]");
list.Add(sales != null ? sales.sales_explain_details.Replace("[","").Replace("]","").Split(',').ToJson() : "[]");
//list.Add(buyputin != null ? buyputin.details : "[]");
//list.Add(allotputin != null ? allotputin.details : "[]");
list.Add(sales != null ? sales.inbound_details.ToObj<List<decimal>>().Select(s => (int)s).ToJson() : "[]");
......
......@@ -200,5 +200,17 @@ namespace AutoTurnOver.Controllers
}
#endregion
/// <summary>
/// 监控状态修改
/// </summary>
/// <returns></returns>
[HttpGet]
public JsonResult MonitorStatus(string bailun_sku,string warehouse_code,int monitor_status)
{
var result = new Services.ConfigServices().MonitorStatus(bailun_sku, warehouse_code, monitor_status);
return new JsonResult(result);
}
}
}
\ No newline at end of file
......@@ -65,7 +65,7 @@ namespace AutoTurnOver.Controllers
var list = services.RealtimeList(sku, warehousecode, product_inner_code, sku_title_cn, 0, int.MaxValue, ref total,warehousetype,warehousearea);
DataTable table = new DataTable();
string[] cols = new string[] { "Sku", "采购名称", "中文名", "英文名称", "仓库编码", "仓库名称", "货主编码"
string[] cols = new string[] { "Sku", "采购名称", "中文名", "英文名称","内部编码", "仓库编码", "仓库名称", "货主编码"
,"订货数量","运输在途","中转仓库存","冻结库存","供应商库存","预售库存","不良品库存","在途库存","收货待检"
,"待上架","可配库存","销售可用库存(聚合)","销售可用库存(私有)","销售可用库存(共享)","在仓库存(共享)","在仓库存(私有)","在仓库存(聚合)","仓库占用(共享)"
,"仓库占用(私有)","仓库占用(聚合)","活动占用","单占用(私有)","订单占用(共享)","订单占用(聚合)","环球更新时间"
......
......@@ -44,7 +44,7 @@ namespace AutoTurnOver.Controllers
date.Add(today.AddDays(i).ToString("MM/dd"));
}
var names = new List<string>() { "销量", "预计入库", "可用库存", "预计缺货数量", "特殊销量", "市场因素", "建议下单数量", "人工下单数量" };
var names = new List<string>() { "销量","计算规则", "预计入库", "可用库存", "预计缺货数量", "特殊销量", "市场因素", "建议下单数量", "人工下单数量" };
var turnoverData = new Services.SkuAutoTurnServices().GetModel(sku, warehousecode);
var saleVolumeData = new Services.SaleVolumeServices().GetBySkuWarehouseCode(sku, warehousecode);
var averageTargets = PurchaseAverageTargetServices.GetList(sku);
......@@ -62,7 +62,7 @@ namespace AutoTurnOver.Controllers
// 累计预计到货
decimal turnoverDatepurchase = 0;
var purchaseList = result[1].ToObj<List<decimal>>();
var purchaseList = result[2].ToObj<List<decimal>>();
for (int i = 7; i < turnoverData.turnover_days + 7; i++)
{
turnoverDatepurchase += purchaseList[i];
......@@ -74,14 +74,14 @@ namespace AutoTurnOver.Controllers
{
turnoverDateStr = turnoverDate.ToString("yyyy-MM-dd"), // 取值日期
turnoverDateSales = turnoverDateSales, // 当日预测销量
turnoverDateStock = (int)result[2].ToObj<List<decimal>>()[turnoverData.turnover_days + 7-1], // 当日预测库存,
turnoverDateStock = (int)result[3].ToObj<List<decimal>>()[turnoverData.turnover_days + 7-1], // 当日预测库存,
turnoverDatecumulativeSales = (int)turnoverDatecumulativeSales, // 累计销量
nowStr = DateTime.Now.ToString("yyyy-MM-dd"), // 今天的日期
nowShortage = (int)result[3].ToObj<List<decimal>>()[7], // 今天的实际缺货
nowShortage = (int)result[4].ToObj<List<decimal>>()[7], // 今天的实际缺货
cumulativeShortageDate = turnoverDate.AddDays(-1).ToString("yyyy-MM-dd"),// 一直到周转期前一天的日期
cumulativeShortage = (int)result[3].ToObj<List<decimal>>()[turnoverData.turnover_days + 7 - 1], // 一直到周转期前一天的累计缺货
cumulativeShortage = (int)result[4].ToObj<List<decimal>>()[turnoverData.turnover_days + 7 - 1], // 一直到周转期前一天的累计缺货
average_overdue = Math.Max(0, turnoverData.average_overdue),
nowDateStock = (int)result[2].ToObj<List<decimal>>()[7], // 今天的预测库存
nowDateStock = (int)result[3].ToObj<List<decimal>>()[7], // 今天的预测库存
turnoverDatepurchase = turnoverDatepurchase // 累计预计到货
};
return new JsonResult(new
......
......@@ -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, string product_code, bool? hasAadvise = null, string categoryIds = null)
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, bool? hasAadvise = null, string categoryIds = null,int? monitor_status = null)
{
var m = new Condition_AutoTurnOver
......@@ -43,7 +43,9 @@ namespace AutoTurnOver.Controllers
sku_name = sku_name,
product_code = product_code,
hasAadvise = hasAadvise,
categoryIds = categoryIds
categoryIds = categoryIds,
monitor_status = monitor_status,
};
var total = 0;
......@@ -76,7 +78,8 @@ namespace AutoTurnOver.Controllers
p.product_code,
p.bailun_category_name,
p.history_fourteenday_sales,
p.history_sevenday_sales
p.history_sevenday_sales,
p.monitor_status
});
return new JsonResult(new
......@@ -87,7 +90,7 @@ 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, bool? hasAadvise = null, string categoryIds = null)
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, bool? hasAadvise = null, string categoryIds = null, int? monitor_status = null)
{
var m = new Condition_AutoTurnOver
{
......@@ -102,7 +105,8 @@ namespace AutoTurnOver.Controllers
sku_name = sku_name,
product_code = product_code,
hasAadvise = hasAadvise,
categoryIds = categoryIds
categoryIds = categoryIds,
monitor_status = monitor_status
};
var total = 0;
var service = new Services.SkuAutoTurnServices();
......@@ -117,7 +121,7 @@ namespace AutoTurnOver.Controllers
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public FileResult Export(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, bool? hasAadvise = null, string categoryIds = null)
public FileResult Export(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, bool? hasAadvise = null, string categoryIds = null,int? monitor_status = null)
{
var m = new Condition_AutoTurnOver
{
......@@ -132,7 +136,8 @@ namespace AutoTurnOver.Controllers
sku_name = sku_name,
product_code = product_code,
hasAadvise = hasAadvise,
categoryIds = categoryIds
categoryIds = categoryIds,
monitor_status = monitor_status
};
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