Commit 7ef26cc3 by lizefeng

自动周转列表搜索功能异常

把建议采购的算法体现出来
检查是否断货的算法准确性
parent d3ac2e29
......@@ -19,19 +19,29 @@ namespace AutoTurnOver.DB
/// <returns></returns>
public static List<dc_auto_order> List(Condition_AutoOrder m,int offset, int limit, ref int total)
{
var sql = "select * from dc_auto_order where status!=-1 ";
var sql = @"select t1.* from dc_auto_order as t1
left join dc_base_warehouse as t3 on t1.warehouse_code = t3.warehouse_code
where status!=-1 ";
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and t3.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and t3.area_id=" + m.warehousearea;
}
if (!string.IsNullOrWhiteSpace(m.sku))
{
sql += " and bailun_sku like '%" + m.sku + "%'";
sql += " and t1.bailun_sku like '%" + m.sku + "%'";
}
if (!string.IsNullOrWhiteSpace(m.warehousecode))
{
sql += " and warehouse_code='"+ m.warehousecode + "'";
sql += " and t1.warehouse_code='" + m.warehousecode + "'";
}
sql += " order by createtime desc";
sql += " order by t1.createtime desc";
try
{
......
......@@ -8,14 +8,13 @@
<ItemGroup>
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="MySql.Data" Version="8.0.13" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AutoTurnOver.Models\AutoTurnOver.Models.csproj" />
<ProjectReference Include="..\AutoTurnOver.Utility\AutoTurnOver.Utility.csproj" />
</ItemGroup>
......
......@@ -5,6 +5,7 @@ using System.Text;
using Dapper;
using System.IO;
using Microsoft.Extensions.Configuration;
using AutoTurnOver.Utility;
namespace AutoTurnOver.DB
{
......@@ -40,7 +41,7 @@ namespace AutoTurnOver.DB
{
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
var configurationRoot = builder.Build();
_connStr = configurationRoot.GetSection("cnstr").Value;
_connStr = ConfigHelper.GetValue("cnstr");
return _connStr;
}
}
......
......@@ -13,9 +13,18 @@ namespace AutoTurnOver.DB
/// </summary>
/// <param name="id">自动周转id</param>
/// <returns></returns>
public static dc_auto_sales GetByTurnOverId(int id)
public static dc_auto_sales GetByTurnOverId(int id,string sku, string warehousecode)
{
var sql = "select * from dc_auto_turnover where id="+id;
var sql = "select * from dc_auto_turnover where 1=1 ";
if (id > 0)
{
sql += " and id= "+id;
}
else
{
sql += " and bailun_sku='"+ sku+ "' and warehouse_code='"+ warehousecode+"' ";
}
var objTurnOver = _connection.QueryFirstOrDefault<Models.dc_auto_turnover>(sql);
if (objTurnOver != null)
......
......@@ -46,7 +46,7 @@ where t1.count>t2.inboundQuantity and t1.warehouse_code=@warehouse_code and t1.b
/// <param name="sku">sku</param>
/// <param name="warehouse_code">仓库编码</param>
/// <returns></returns>
public static IEnumerable<dc_realtime_purchase_daily_dto> RealtimeList(string sku, string warehouse_code,string product_inner_code,string sku_title_cn, int offset, int limit, ref int total)
public static IEnumerable<dc_realtime_purchase_daily_dto> RealtimeList(string sku, string warehouse_code, string product_inner_code, string sku_title_cn, int offset, int limit, ref int total, string warehousetype, int? warehousearea)
{
var sql = @"
select
......@@ -63,6 +63,7 @@ t3.buyer_name,t3.sku_title_cn,t3.sku_title_en,t3.product_inner_code
from dc_daily_inventory 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 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
";
......@@ -72,10 +73,27 @@ count(1)
from dc_daily_inventory 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 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
";
DynamicParameters parameters = new DynamicParameters();
parameters.Add("time", DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
if (!string.IsNullOrWhiteSpace(warehousetype))
{
sql += " and dbw.hq_type = @hq_type ";
countSql += " and dbw.hq_type = @hq_type ";
parameters.Add("hq_type", warehousetype);
}
if (warehousearea>0)
{
sql += " and dbw.area_id = @area_id ";
countSql += " and dbw.area_id = @area_id ";
parameters.Add("area_id", warehousearea);
}
if (!string.IsNullOrWhiteSpace(product_inner_code))
{
sql += " and t3.product_inner_code like @product_inner_code ";
......
......@@ -24,8 +24,17 @@ namespace AutoTurnOver.DB
try
{
var sql = @"select * from dc_auto_config_safe_inventory as dacp where 1=1 ";
var sql = @"select dacp.* from dc_auto_config_safe_inventory as dacp
left join dc_base_warehouse as dbw on dacp.warehouse_code = dbw.warehouse_code where 1 = 1 ";
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and dbw.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and dbw.area_id=" + m.warehousearea;
}
if (m.IsEffective == true)
{
sql += $" and dacp.status=1 ";
......@@ -149,8 +158,17 @@ namespace AutoTurnOver.DB
try
{
var sql = @"select * from dc_auto_config_sales_upper_limit as dacp where 1=1 ";
var sql = @"select dacp.* from dc_auto_config_sales_upper_limit as dacp
left join dc_base_warehouse as dbw on dacp.warehouse_code = dbw.warehouse_code where 1 = 1 ";
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and dbw.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and dbw.area_id=" + m.warehousearea;
}
if (m.IsEffective == true)
{
sql += $" and dacp.status=1 ";
......@@ -172,7 +190,7 @@ namespace AutoTurnOver.DB
return obj.AsList();
}
catch (Exception ex)
catch (Exception)
{
return list;
}
......
......@@ -31,8 +31,17 @@ namespace AutoTurnOver.DB
{
var sql = @"select dat.*,t2.oneday_sales,t2.forecast_oneday_sales as 'forecast_oneday_sales2' 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
where 1=1 ";
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and t3.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and t3.area_id=" + m.warehousearea;
}
if (!string.IsNullOrEmpty(m.bailun_sku))
{
sql += " and dat.bailun_sku like '%" + m.bailun_sku+"%'";
......@@ -95,8 +104,16 @@ where 1=1 ";
try
{
var sql = "select dacp.id,dacp.bailun_sku,dacp.warehouse_code,dbw.warehouse_name,dacp.promotion_time,dacp.count,dacp.bl_auditor,dacp.remark,dacp.status from dc_auto_config_promotion dacp " +
"left join dc_base_warehouse_oa dbw on dacp.warehouse_code=dbw.warehouse_code where 1 =1 ";
"left join dc_base_warehouse as dbw on dacp.warehouse_code=dbw.warehouse_code where 1 =1 ";
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and dbw.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and dbw.area_id=" + m.warehousearea;
}
if (m.IsEffective==true)
{
sql += $" and dacp.promotion_time>= '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}' ";
......@@ -343,8 +360,16 @@ where 1=1 ";
try
{
var sql = @"select dacp.id,dacp.bailun_sku,dacp.warehouse_code,dbw.warehouse_name,dacp.start_time,dacp.end_time,dacp.param,dacp.remark from dc_auto_config_correction dacp
left join dc_base_warehouse_oa dbw on dacp.warehouse_code = dbw.warehouse_code where 1 = 1 ";
left join dc_base_warehouse dbw on dacp.warehouse_code = dbw.warehouse_code where 1 = 1 ";
if (!string.IsNullOrWhiteSpace(m.warehousetype))
{
sql += " and dbw.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and dbw.area_id=" + m.warehousearea;
}
if (m.IsEffective == true)
{
var nowStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
......
......@@ -36,7 +36,7 @@ namespace AutoTurnOver.DB
{
_connection.Execute(@"
INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quantity_init_advise`,`quantity_actual`,`main_id`,
`forecast_formula`,`fit_forecast_formula`,`turnover_days`,`supplier_delivery`,`inspection_delivery`,`transfer_delivery`)
`forecast_formula`,`fit_forecast_formula`,`turnover_days`,`supplier_delivery`,`inspection_delivery`,`transfer_delivery`,`sales_upper_limit`)
(
select
t1.bailun_sku,
......@@ -49,7 +49,8 @@ INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quan
t1.turnover_days,
t1.supplier_delivery,
t1.inspection_delivery,
t1.transfer_delivery
t1.transfer_delivery,
t1.sales_upper_limit
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_init_advise>0
......@@ -126,11 +127,30 @@ INSERT into dc_auto_purchase_advise_detailed(`bailun_sku`,`warehouse_code`,`quan
{
DynamicParameters parameters = new DynamicParameters();
var sql = @"select t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name' from dc_auto_purchase_advise_detailed as t1
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
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.warehousetype))
{
sql += " and t2.hq_type=" + $"'{m.warehousetype}'";
}
if (m.warehousearea > 0)
{
sql += " and t2.area_id=" + m.warehousearea;
}
if (m.start_date != null)
{
sql += " and t4.create_time >= @start_date ";
parameters.Add("start_date", m.start_date.Value.ToString("yyyy-MM-dd 00:00:00"));
}
if (m.end_date != null)
{
sql += " and t4.create_time<= @end_date ";
parameters.Add("end_date", m.end_date.Value.ToString("yyyy-MM-dd 23:59:59"));
}
if (m.main_id > 0)
{
sql += $" and t1.main_id = @main_id ";
......@@ -164,7 +184,19 @@ where 1=1 ";
public static IEnumerable<dc_auto_purchase_advise_detailed> DetailList(int mainid)
{
return _connection.Query<dc_auto_purchase_advise_detailed>("select * from dc_auto_purchase_advise_detailed where mainid=@mainid ",new { mainid = mainid });
return _connection.Query<dc_auto_purchase_advise_detailed>("select * from dc_auto_purchase_advise_detailed where main_id=@mainid ", new { mainid = mainid });
}
/// <summary>
/// 采购建议明细
/// </summary>
/// <param name="mainid"></param>
/// <returns></returns>
public static IEnumerable<dc_auto_purchase_advise_detailed_buy_dto> BuyDetailList(int mainid)
{
return _connection.Query<dc_auto_purchase_advise_detailed_buy_dto>(@" select t1.*,t2.unit_price from dc_auto_purchase_advise_detailed as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
where t1.main_id=@mainid ", new { mainid });
}
/// <summary>
......@@ -204,5 +236,20 @@ left join dc_auto_purchase_advise as t2 on t1.main_id = t2.id where t1.bailun_sk
_connection.Execute(" update dc_auto_purchase_advise_detailed set quantity_actual=@quantity_actual where id=@id ", new { quantity_actual = quantity_actual, id = id });
}
/// <summary>
/// 查询历史采购建议
/// </summary>
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <param name="dateTime"></param>
/// <returns></returns>
public static dc_auto_purchase_advise_detailed DetailInfo(string sku, string warehousecode, DateTime dateTime)
{
string sql = @" select t1.* from dc_auto_purchase_advise_detailed as t1
left join dc_auto_purchase_advise as t2 on t1.main_id = t2.id
where t1.warehouse_code=@warehousecode and t1.bailun_sku=@sku and t2.create_time>=@b_create_time and t2.create_time<=@e_create_time order by t2.create_time desc limit 1 ";
return _connection.QueryFirstOrDefault<dc_auto_purchase_advise_detailed>(sql, new { sku, warehousecode, b_create_time = dateTime.ToString("yyyy-MM-dd 00:00:00"), e_create_time = dateTime.ToString("yyyy-MM-dd 23:59:59") });
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
public class BuyOutputResult
{
/// <summary>
/// 是否执行成功,默认为:true
/// </summary>
public bool IsSuccessed { get; set; } = true;
/// <summary>
///
/// </summary>
public string Message { get; set; }
/// <summary>
/// planNo+"|"+BuyNo 计划单编码和第一条采购单编码
/// </summary>
public string Data { get; set; }
public string planNo { get { return Data.Split('|')[0]; } }
/// <summary>
/// 总数量
/// </summary>
public int TotalCount { get; set; }
/// <summary>
/// 总页数
/// </summary>
public int TotalPages { get; set; }
}
}
......@@ -4,7 +4,7 @@ using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
class mPlanToPurchaseDto
public class mPlanToPurchaseDto
{
/// <summary>
///
......
......@@ -95,6 +95,9 @@ namespace AutoTurnOver.Models
/// 是否过期
/// </summary>
public bool? IsEffective { get; set; }
public string warehousetype { get; set; }
public int? warehousearea { get; set; }
}
......
......@@ -104,6 +104,9 @@ namespace AutoTurnOver.Models
public string sku { get; set; }
public string warehousecode { get; set; }
public string warehousetype { get; set; }
public int? warehousearea { get; set; }
}
/// <summary>
......
......@@ -88,18 +88,32 @@ namespace AutoTurnOver.Models
/// 调拨天数
/// </summary>
public int transfer_delivery { get; set; }
public int sales_upper_limit { get; set; }
}
public class dc_auto_purchase_advise_detailed_dto: dc_auto_purchase_advise_detailed
public class dc_auto_purchase_advise_detailed_buy_dto: dc_auto_purchase_advise_detailed
{
/// <summary>
/// 单价
/// </summary>
public decimal unit_price { get; set; }
}
public class dc_auto_purchase_advise_detailed_dto : dc_auto_purchase_advise_detailed
{
public string warehouse_name { get; set; }
public string sku_name { get; set; }
public DateTime create_time { get; set; }
public string create_time_str { get { return create_time.ToString("yyyy-MM-dd"); } }
}
public class dc_auto_purchase_advise_detailed_time_dto: dc_auto_purchase_advise_detailed
public class dc_auto_purchase_advise_detailed_time_dto : dc_auto_purchase_advise_detailed
{
public DateTime create_time { get; set; }
}
......@@ -125,6 +139,12 @@ namespace AutoTurnOver.Models
public string sku { get; set; }
public string warehouse_code { get; set; }
public DateTime? start_date { get; set; }
public DateTime? end_date { get; set; }
public string warehousetype { get; set; }
public int? warehousearea { get; set; }
}
}
......@@ -162,6 +162,16 @@ namespace AutoTurnOver.Models
/// </summary>
public string short_supply_details { get; set; }
/// <summary>
/// 预测建议
/// </summary>
public string advised_details { get; set; }
/// <summary>
/// 默认供应商的平均预期天数
/// </summary>
public decimal average_overdue { get; set; }
}
public class Condition_AutoTurnOver
......@@ -185,6 +195,10 @@ namespace AutoTurnOver.Models
/// 是否冗余
/// </summary>
public int? redundancy { get; set; }
public string warehousetype { get; set; }
public int? warehousearea { get; set; }
}
public class dc_auto_turnover_Extend : dc_auto_turnover
......
......@@ -44,9 +44,21 @@ namespace AutoTurnOver.Services
/// <summary>
/// 推送采购计划
/// </summary>
public static void PushBuyPlan(int mainid)
public static BuyOutputResult PushBuyPlan(mPlanToPurchaseDto data)
{
//查询采购建议明细
//查询采购建议明细
string url = ConfigHelper.GetValue("PushBuyPlan");
string resultStr = HttpHelper.Request(url, RequestType.POST, "obj="+WebUtility.UrlDecode(data.ToJson()));
var result = resultStr.ToObj<BuyOutputResult>();
if (result == null)
{
throw new Exception("推送失败");
}
if (!result.IsSuccessed)
{
throw new Exception(result.Message);
}
return result;
}
}
}
......@@ -192,6 +192,10 @@ namespace AutoTurnOver.Services
}
else if (m.type == (int)Safe_UpperLimitType.仓库_SKU_按历史计算)
{
if (m.param <= 0)
{
return "倍数必填";
}
if (string.IsNullOrWhiteSpace(m.variable_code))
{
return "Sku不能为空!";
......
......@@ -21,9 +21,9 @@ namespace AutoTurnOver.Services
return DB.daily.List(sku, warehouse_code);
}
public IEnumerable<dc_realtime_purchase_daily_dto> RealtimeList(string sku, string warehouse_code, string product_inner_code, string sku_title_cn, int offset, int limit, ref int total)
public IEnumerable<dc_realtime_purchase_daily_dto> RealtimeList(string sku, string warehouse_code, string product_inner_code, string sku_title_cn, int offset, int limit, ref int total, string warehousetype, int? warehousearea)
{
return DB.daily.RealtimeList(sku, warehouse_code,product_inner_code,sku_title_cn,offset, limit, ref total);
return DB.daily.RealtimeList(sku, warehouse_code,product_inner_code,sku_title_cn,offset, limit, ref total,warehousetype,warehousearea);
}
......
using AutoTurnOver.DB;
using AutoTurnOver.Models;
using AutoTurnOver.Models.ApiDto;
using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Linq;
namespace AutoTurnOver.Services
{
......@@ -83,10 +87,76 @@ namespace AutoTurnOver.Services
/// 设置采购数量
/// </summary>
/// <param name="id"></param>
public static void SetQuantityActual(int id,int quantity_actual)
public static void SetQuantityActual(int id, int quantity_actual)
{
purchase_advise.SetQuantityActual(id, quantity_actual);
}
/// <summary>
/// 查询历史采购建议
/// </summary>
/// <param name="id"></param>
public static dc_auto_purchase_advise_detailed DetailInfo(string sku, string warehousecode, DateTime dateTime)
{
return purchase_advise.DetailInfo(sku, warehousecode, dateTime);
}
/// <summary>
/// 把最新一批的采购单推送到采购系统
/// </summary>
/// <param name="mainId"></param>
public static void PushBuySys()
{
MySqlConnection conn = connectionHelper._connection;
conn.Open();
IDbTransaction transaction = conn.BeginTransaction();
try
{
//查询最近一个采购建议
//
var lastPurchaseAdvise = conn.QueryFirstOrDefault<dc_auto_purchase_advise>(" select * from dc_auto_purchase_advise order by id desc limit 1 ");
if (lastPurchaseAdvise.push_time != null)
{
throw new Exception("最新的一个采购建议已经推送过了,请勿重复推送");
}
DateTime now = DateTime.Now;
// 查询采购建议的明细
var detailList = purchase_advise.BuyDetailList(lastPurchaseAdvise.id);
mPlanToPurchaseDto data = new mPlanToPurchaseDto
{
bi_buyplandetail = new List<bi_buyplandetail>(),
bp_createtime = now,
bp_imporstate = 0,
bp_remark = "数据中心推送",
bp_savetime = now
};
data.bi_buyplandetail = detailList.Select(s => new bi_buyplandetail
{
bd_count = s.quantity_actual > 0 ? s.quantity_actual : s.quantity_init_advise,
bd_imporstate = 0,
bd_price = s.unit_price,
bd_sku = s.bailun_sku
}).ToList();
//把采购数量没有填的都补上 建议采购数
conn.Execute(" update dc_auto_purchase_advise_detailed set quantity_actual=quantity_init_advise where quantity_actual<=0 and main_id=@mainID ", new { mainID = lastPurchaseAdvise.id }, transaction);
var result = ApiServices.PushBuyPlan(data);
conn.Execute(" update dc_auto_purchase_advise set buy_sys_plan_no=@buy_sys_plan_no,push_time=@push_time ", new { buy_sys_plan_no = result.planNo, push_time = now }, transaction);
transaction.Commit();
}
catch (Exception)
{
transaction.Rollback();
conn.Close();
throw;
}
}
}
}
......@@ -41,7 +41,7 @@ namespace AutoTurnOver.Services
var shortsupply = DB.dc_auto_turnover.GetAutoShortSupplyBySkuWH(sku, warehousecode);
list.Add(sales != null ? sales.sales_details.ToObj<List<decimal>>().Select(s=>(int)s).ToJson() : "[]");
list.Add(sales != null ? sales.sales_details.ToObj<List<decimal>>().Select(s => (int)s).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() : "[]");
......@@ -96,20 +96,41 @@ namespace AutoTurnOver.Services
tempCorrectionStrList.Add(tempCorrectionData.param);
}
// 只查询历史
var tempPurchaseDetailData = purchaseDetailList.FirstOrDefault(s => s.create_time >= tempDateHome && s.create_time <= tempDateEnd);
if (tempPurchaseDetailData == null)
{
tempAdviseStrList.Add(0);
if (tempDateEnd < DateTime.Now)
{
tempAdviseStrList.Add(0);
}
tempActualStrList.Add(0);
}
else
{
tempAdviseStrList.Add(tempPurchaseDetailData.quantity_init_advise);
if (tempDateEnd < DateTime.Now)
{
tempAdviseStrList.Add(tempPurchaseDetailData.quantity_init_advise);
}
tempActualStrList.Add(tempPurchaseDetailData.quantity_actual);
}
}
// 预测未来采购数量
// 只预测一个周转期
if (sales.advised_details != null)
{
tempAdviseStrList.AddRange(sales.advised_details.ToObj<List<decimal>>());
}
list.Add(tempStrList != null ? tempStrList.ToJson() : "[]");
list.Add(tempCorrectionStrList != null ? tempCorrectionStrList.Select(s=>(int)s).ToJson() : "[]");
list.Add(tempCorrectionStrList != null ? tempCorrectionStrList.Select(s => (int)s).ToJson() : "[]");
list.Add(tempAdviseStrList != null ? tempAdviseStrList.Select(s => (int)s).ToJson() : "[]");
list.Add(tempActualStrList != null ? tempActualStrList.Select(s => (int)s).ToJson() : "[]");
......
......@@ -13,9 +13,9 @@ namespace AutoTurnOver.Services
/// </summary>
/// <param name="id">自动周转id</param>
/// <returns></returns>
public dc_auto_sales GetByTurnOverId(int id)
public dc_auto_sales GetByTurnOverId(int id, string sku, string warehousecode)
{
return DB.SaleVolume.GetByTurnOverId(id);
return DB.SaleVolume.GetByTurnOverId(id,sku,warehousecode);
}
......
......@@ -6,6 +6,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
</ItemGroup>
......
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace AutoTurnOver.Utility
{
public class ConfigHelper
{
public static string GetValue(string key)
{
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
var configurationRoot = builder.Build();
return configurationRoot.GetSection(key).Value;
}
}
}
......@@ -26,13 +26,15 @@ namespace AutoTurnOver.Controllers
/// <param name="IsEffective">是否有效数据</param>
/// <returns></returns>
[HttpGet]
public JsonResult InventoryList(int limit, int offset, string order, string sort, string sku, string warehousecode, bool? IsEffective = null)
public JsonResult InventoryList(int limit, int offset, string order, string sort, string sku, string warehousecode, string warehousetype, int? warehousearea, bool? IsEffective = null)
{
var m = new Condition_ConfigPromotion
{
sku = sku,
warehousecode = warehousecode,
IsEffective = IsEffective
IsEffective = IsEffective,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var total = 0;
......@@ -87,13 +89,15 @@ namespace AutoTurnOver.Controllers
/// <param name="IsEffective">是否有效数据</param>
/// <returns></returns>
[HttpGet]
public JsonResult SalesUpperLimitList(int limit, int offset, string order, string sort, string sku, string warehousecode, bool? IsEffective = null)
public JsonResult SalesUpperLimitList(int limit, int offset, string order, string sort, string sku, string warehousecode, string warehousetype, int? warehousearea, bool? IsEffective = null)
{
var m = new Condition_ConfigPromotion
{
sku = sku,
warehousecode = warehousecode,
IsEffective = IsEffective
IsEffective = IsEffective,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var total = 0;
......
......@@ -38,12 +38,12 @@ namespace AutoTurnOver.Controllers
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <returns></returns>
public JsonResult RealtimeList(string sku, string warehousecode, string product_inner_code, string sku_title_cn, int offset, int limit, string order, string sort)
public JsonResult RealtimeList(string sku, string warehousecode, string product_inner_code, string sku_title_cn, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea)
{
var services = new DailyServices();
var total = 0;
var list = services.RealtimeList(sku, warehousecode,product_inner_code, sku_title_cn, offset, limit, ref total);
var list = services.RealtimeList(sku, warehousecode,product_inner_code, sku_title_cn, offset, limit, ref total,warehousetype,warehousearea);
return new JsonResult(new
{
......@@ -58,11 +58,11 @@ namespace AutoTurnOver.Controllers
/// <param name="sku"></param>
/// <param name="warehousecode"></param>
/// <returns></returns>
public FileResult ExportRealtime(string sku, string warehousecode, string product_inner_code, string sku_title_cn)
public FileResult ExportRealtime(string sku, string warehousecode, string product_inner_code, string sku_title_cn, string warehousetype, int? warehousearea)
{
var services = new DailyServices();
var total = 0;
var list = services.RealtimeList(sku, warehousecode, product_inner_code, sku_title_cn, 0, int.MaxValue, ref total);
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", "仓库编码", "仓库名称", "可用库存", "占用库存", "预分配库存", "在途库存" };
......
......@@ -23,11 +23,13 @@ namespace AutoTurnOver.Controllers
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <returns></returns>
public JsonResult List(string sku,string warehousecode,int offset,int limit,string order,string sort)
public JsonResult List(string sku,string warehousecode,int offset,int limit,string order,string sort, string warehousetype, int? warehousearea)
{
var m = new Condition_AutoOrder {
sku = sku,
warehousecode = warehousecode,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var services = new AutoOrderServices();
......@@ -58,10 +60,10 @@ namespace AutoTurnOver.Controllers
/// </summary>
/// <param name="id">主键id</param>
/// <returns></returns>
public JsonResult GetSaleVolume(int id)
public JsonResult GetSaleVolume(int id,string sku,string warehousecode)
{
var services = new Services.SaleVolumeServices();
var result = services.GetByTurnOverId(id);
var result = services.GetByTurnOverId(id, sku, warehousecode);
var _service = new Services.SkuAutoTurnServices();
var inventory = new dc_auto_inventory();
......
......@@ -6,6 +6,7 @@ using AutoTurnOver.Models;
using AutoTurnOver.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using AutoTurnOver.Utility;
namespace AutoTurnOver.Controllers
{
......@@ -54,23 +55,27 @@ namespace AutoTurnOver.Controllers
/// <param name="start_date"></param>
/// <returns></returns>
[HttpGet]
public JsonResult DetailList(int limit, int offset, int main_id, string sort, string sku, string warehousecode)
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)
{
var m = new dc_auto_purchase_advise_detailed_search_dto
{
main_id = main_id,
sku = sku,
warehouse_code = warehousecode
warehouse_code = warehousecode,
end_date = end_date,
start_date = start_date,
warehousearea = warehousearea,
warehousetype = warehousetype
};
var total = 0;
var list = PurchaseAdviseServices.DetailList(m, offset, limit, ref total);
return new JsonResult(new
return new
{
rows = list,
total = total,
});
}.ToJson(false);
}
/// <summary>
......@@ -102,12 +107,11 @@ namespace AutoTurnOver.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public JsonResult PushBuySys(int main_id)
public JsonResult PushBuySys()
{
try
{
throw new Exception("接口对接中...");
//PurchaseAdviseServices.PushBuySys(main_id);
PurchaseAdviseServices.PushBuySys();
return new JsonResult(new
{
success = true
......@@ -122,5 +126,31 @@ namespace AutoTurnOver.Controllers
});
}
}
/// <summary>
/// 查询采购建议
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public JsonResult DetailInfo(string sku, string warehousecode,DateTime dateTime)
{
try
{
return new JsonResult(new
{
success = true,
data = PurchaseAdviseServices.DetailInfo(sku, warehousecode, dateTime)
});
}
catch (Exception ex)
{
return new JsonResult(new
{
success = false,
message = ex.Message
});
}
}
}
}
\ No newline at end of file
......@@ -43,12 +43,36 @@ 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);
var averageTargetWarehouse = PurchaseAverageTargetServices.GetWarehouse(sku, warehousecode);
return new JsonResult(new { data = result, turnoverData, saleVolumeData, days = date, names, averageTargets, averageTargetWarehouse });
DateTime turnoverDate = DateTime.Now.AddDays(turnoverData.turnover_days);
var buyFormula = new
{
turnoverDateStr = turnoverDate.ToString("yyyy-MM-dd"), // 取值日期
turnoverDateSales = int.Parse(result[0].Split(',')[turnoverData.turnover_days + 7]), // 当日预测销量
turnoverDateStock = int.Parse(result[2].Split(',')[turnoverData.turnover_days + 7]), // 当日预测库存
nowStr = DateTime.Now.ToString("yyyy-MM-dd"), // 今天的日期
nowShortage = int.Parse(result[3].Split(',')[7]), // 今天的实际缺货
cumulativeShortageDate = turnoverDate.AddDays(-1).ToString("yyyy-MM-dd"),// 一直到周转期前一天的日期
cumulativeShortage = int.Parse(result[3].Split(',')[turnoverData.turnover_days + 7 - 1]), // 一直到周转期前一天的累计缺货
average_overdue = Math.Max(0, turnoverData.average_overdue)
};
return new JsonResult(new
{
data = result,
turnoverData,
saleVolumeData,
days = date,
names,
averageTargets,
averageTargetWarehouse,
buyFormula
}
);
}
}
......
......@@ -24,7 +24,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)
public JsonResult List(int limit, int offset, string order,string sort,string sku,int? IsRedundant,int? IsStockOut,string warehousecode,string warehousetype,int? warehousearea)
{
var m = new Condition_AutoTurnOver {
......@@ -32,7 +32,8 @@ namespace AutoTurnOver.Controllers
out_of_stock = IsStockOut,
redundancy = IsRedundant,
warehouse_code = warehousecode,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var total = 0;
......@@ -85,13 +86,15 @@ namespace AutoTurnOver.Controllers
/// <param name="IsEffective">是否有效数据</param>
/// <returns></returns>
[HttpGet]
public JsonResult ListSaleSetting(int limit, int offset, string order, string sort, string sku, string warehousecode,bool? IsEffective = null)
public JsonResult ListSaleSetting(int limit, int offset, string order, string sort, string sku, string warehousecode, string warehousetype, int? warehousearea, bool? IsEffective = null)
{
var m = new Condition_ConfigPromotion
{
sku = sku,
warehousecode = warehousecode,
IsEffective = IsEffective
IsEffective = IsEffective,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var total = 0;
......@@ -191,12 +194,14 @@ namespace AutoTurnOver.Controllers
#region 预计断货Sku
public JsonResult ListOutStock(string sku,string warehousecode,int offset,int limit)
public JsonResult ListOutStock(string sku,string warehousecode,int offset,int limit, string warehousetype, int? warehousearea)
{
var m = new Condition_AutoTurnOver {
bailun_sku = sku,
warehouse_code = warehousecode,
out_of_stock = 1,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var total = 0;
......@@ -234,13 +239,15 @@ namespace AutoTurnOver.Controllers
/// <param name="IsEffective">是否有效数据</param>
/// <returns></returns>
[HttpGet]
public JsonResult ListCorrection(int limit, int offset, string order, string sort, string sku, string warehousecode, bool? IsEffective = null)
public JsonResult ListCorrection(int limit, int offset, string order, string sort, string sku, string warehousecode, string warehousetype, int? warehousearea, bool? IsEffective = null)
{
var m = new Condition_ConfigPromotion
{
sku = sku,
warehousecode = warehousecode,
IsEffective = IsEffective
IsEffective = IsEffective,
warehousetype = warehousetype,
warehousearea = warehousearea
};
var total = 0;
......
......@@ -8,7 +8,7 @@
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
......
......@@ -5,5 +5,6 @@
}
},
"AllowedHosts": "*",
"cnstr": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
"cnstr": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;",
"PushBuyPlan": "http://192.168.6.229/api/CreatePlanToPurchase"
}
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