Commit 751a4804 by lizefeng

采购交期,遇到小数向上取整

parent c4951d3e
......@@ -189,12 +189,27 @@ select
try
{
DynamicParameters parameters = new DynamicParameters();
string sql = "";
if (m.isSum)
{
sql = @"
select
var sql = @"select t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name',t4.create_time from dc_auto_purchase_advise_detailed as t1
from dc_auto_purchase_advise_detailed as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_auto_purchase_advise as t4 on t1.main_id = t4.id
where 1=1 ";
}
else {
sql = @"
select t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name',t4.create_time from dc_auto_purchase_advise_detailed as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_auto_purchase_advise as t4 on t1.main_id = t4.id
where 1=1 ";
}
if (!string.IsNullOrWhiteSpace(m.product_inner_code))
{
......
......@@ -215,6 +215,8 @@ namespace AutoTurnOver.Models
public string supplier_name { get; set; }
public string product_inner_code { get; set; }
public bool isSum { get; set; }
}
}
......@@ -20,7 +20,7 @@ namespace AutoTurnOver.Purchase.AverageTarget
{
Console.WriteLine("采购平均值计算任务启动...");
// 创建采购计划
//PurchaseAdviseServices.Generate();
//PurchaseAverageTargetServices.Calculation();
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
......
......@@ -53,7 +53,7 @@ namespace AutoTurnOver.Services
var purchaseList = AveragePurchase.GetPurchaseList(skuItem, _seed_count).ToList();
//有相关采购单 (有不止一个单,才算平均数)
if (purchaseList != null && purchaseList.Select(s=>s.purchase_id).Distinct().Count() > 1)
if (purchaseList != null && purchaseList.Select(s => s.purchase_id).Distinct().Count() > 1)
{
data.supplier_name = purchaseList[0].supplier_name;
......@@ -71,11 +71,11 @@ namespace AutoTurnOver.Services
if (tempPurchase.pay_type == 1)
{
delivery_days += (int)(itemArrivalList.Min(s => s.update_time) - tempPurchase.pay_time).Value.TotalDays;
delivery_days += (int)Math.Ceiling((itemArrivalList.Min(s => s.update_time) - tempPurchase.pay_time).Value.TotalHours / 24);
}
else
{
delivery_days += (int)(itemArrivalList.Min(s => s.update_time) - tempPurchase.confirm_time).Value.TotalDays;
delivery_days += (int)Math.Ceiling((itemArrivalList.Min(s => s.update_time) - tempPurchase.confirm_time).Value.TotalDays / 24);
}
}
......@@ -156,7 +156,7 @@ namespace AutoTurnOver.Services
conn.Update(task_log);
}
public static IEnumerable<dc_average_purchase> GetListByWCode(string sku,string warehouse_code)
public static IEnumerable<dc_average_purchase> GetListByWCode(string sku, string warehouse_code)
{
return AveragePurchase.GetListByWCode(sku, warehouse_code);
}
......
......@@ -61,7 +61,7 @@ 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,
bool? ispush = null,int? type = null,string supplier_name = null,string purchase_user = null,string product_inner_code= null)
bool? ispush = null, int? type = null, string supplier_name = null, string purchase_user = null, string product_inner_code = null)
{
var m = new dc_auto_purchase_advise_detailed_search_dto
{
......@@ -90,6 +90,44 @@ namespace AutoTurnOver.Controllers
}
/// <summary>
/// 采购建议列表
/// </summary>
/// <param name="limit"></param>
/// <param name="offset"></param>
/// <param name="has_push"></param>
/// <param name="sort"></param>
/// <param name="end_date"></param>
/// <param name="start_date"></param>
/// <returns></returns>
[HttpGet]
public string 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)
{
var m = new dc_auto_purchase_advise_detailed_search_dto
{
main_id = main_id,
sku = sku,
warehouse_code = warehousecode,
end_date = end_date,
start_date = start_date,
warehousearea = warehousearea,
warehousetype = warehousetype,
ispush = ispush,
type = type,
supplier_name = supplier_name,
purchase_user = purchase_user,
product_inner_code = product_inner_code,
isSum = true
};
var total = 0;
var list = PurchaseAdviseServices.DetailList(m, offset, limit, ref total);
return (list == null || list.Count <= 0 ? new dc_auto_purchase_advise_detailed_dto() : list[0]).ToJson(true);
}
/// <summary>
/// 导出实时库存
/// </summary>
/// <param name="sku"></param>
......@@ -195,12 +233,12 @@ namespace AutoTurnOver.Controllers
var total = 0;
var list = PurchaseAdviseServices.DetailList(m, 0, int.MaxValue, ref total);
foreach (var item in list.GroupBy(s=>s.type))
foreach (var item in list.GroupBy(s => s.type))
{
PurchaseAdviseServices.PushBuySys(item.ToList(), item.Key);
}
return new JsonResult(new
{
success = true
......
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