Commit 0dad9369 by 泽锋 李

fix

parent dba00e9e
......@@ -74,7 +74,35 @@ namespace AutoTurnOver.DB
}
public static List<LmsShipLogisticsDto> RealTimeShipLogisticsCompanyList()
{
return RealTimeShipLogisticsList().GroupBy(s => new { s.Company_Code }).Select(s=>new LmsShipLogisticsDto { Company_Code = s.Key.Company_Code,Company_Name = s.Max(v=>v.Company_Name)}).ToList();
return RealTimeShipLogisticsList().GroupBy(s => new { s.Company_Code }).Select(s => new LmsShipLogisticsDto { Company_Code = s.Key.Company_Code, Company_Name = s.Max(v => v.Company_Name) }).ToList();
}
/// <summary>
/// 抓取sku 刊登状态
/// </summary>
/// <returns></returns>
public static List<api_pps_sku_status_response_dto.sku_dto> GetPPSSkuStatus(api_pps_sku_status_request_dto data)
{
try
{
//查询采购建议明细
string url = ConfigHelper.GetValue("PPSSkuStatus");
string resultStr = HttpHelper.Request(url, RequestType.POST, data.ToJson(), "application/json", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<api_pps_sku_status_response_dto>();
if (result == null)
{
return new List<api_pps_sku_status_response_dto.sku_dto>() { };
}
else
{
return result.result;
}
}
catch (Exception ex)
{
throw new Exception("pps sku 刊登状态接口异常: " + ex.Message);
throw new Exception("pps sku 刊登状态接口异常: " + ex.StackTrace);
}
}
}
}
......@@ -4,6 +4,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using AutoTurnOver.Models.ApiDto;
using MySql.Data.MySqlClient;
using System.Text;
namespace AutoTurnOver.DB
{
......@@ -246,8 +248,8 @@ UNION ALL
/// <param name="sku">sku</param>
/// <param name="warehouse_code">仓库编码</param>
/// <returns></returns>
public static List<dc_base_stock_dto> RealtimeList(int? monitor_status,int? searchType, string key_words, string warehouse_code,string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea, bool isSum = false, string order = null, string sort = null,int? has_tort = null, List<bailun_category_new_dto> categoryModels = null,string buyer_name = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null,int? product_type = null)
public static List<dc_base_stock_dto> RealtimeList(int? monitor_status, int? searchType, string key_words, string warehouse_code, string supplier_name, int offset, int limit, ref int total, string warehousetype, int? warehousearea, bool isSum = false, string order = null, string sort = null, int? has_tort = null, List<bailun_category_new_dto> categoryModels = null, string buyer_name = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null, int? product_type = null)
{
DynamicParameters parameters = new DynamicParameters();
var sql = "";
......@@ -346,7 +348,7 @@ left join dc_auto_sales as t8 on t1.bailun_sku=t8.bailun_sku and t1.warehouse_co
var storage_quantity_sql = @" left join (
select bailun_sku_warehouse_code,sum(quantity_stock) as 'storage_quantity' from dc_base_stock_record_effective where 1=1 ";
if(start_date != null && end_date != null)
if (start_date != null && end_date != null)
{
storage_quantity_sql += " and stock_time>=@start_date and stock_time<=@end_date ";
}
......@@ -365,7 +367,7 @@ from
dc_base_stock as t1
left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
";
if ((categoryModels != null && categoryModels.Count >= 1 ) || !string.IsNullOrWhiteSpace(buyer_name) || product_type>0)
if ((categoryModels != null && categoryModels.Count >= 1) || !string.IsNullOrWhiteSpace(buyer_name) || product_type > 0)
{
countSql += " left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku ";
}
......@@ -403,7 +405,7 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
parameters.Add("start_date", start_date.Value.ToString("yyyy-MM-dd 00:00:00"));
parameters.Add("end_date", end_date.Value.ToString("yyyy-MM-dd 23:59:59"));
}
if (categoryModels != null && categoryModels.Count>=1)
if (categoryModels != null && categoryModels.Count >= 1)
{
sql += " and t3.category_simple_id in ( " + string.Join(",", categoryModels.Select(s => s.id).Distinct()) + ")";
countSql += " and t3.category_simple_id in ( " + string.Join(",", categoryModels.Select(s => s.id).Distinct()) + ")";
......@@ -414,7 +416,7 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
countSql += " and t3.buyer_name = @buyer_name ";
parameters.Add("buyer_name", buyer_name);
}
if (product_type>0)
if (product_type > 0)
{
sql += " and t3.product_type = @product_type ";
countSql += " and t3.product_type = @product_type ";
......@@ -457,9 +459,9 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
parameters.Add("area_id", warehousearea);
}
if(searchType>0 && !string.IsNullOrWhiteSpace(key_words))
if (searchType > 0 && !string.IsNullOrWhiteSpace(key_words))
{
switch(searchType)
switch (searchType)
{
case 1:
sql += " and t1.bailun_sku in @bailun_skus ";
......@@ -542,7 +544,7 @@ left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
/// 缺货推送记录
/// </summary>
/// <returns></returns>
public static List<dc_auto_shortage_push_route_dto> ShortagePushList(string platform,string bailun_sku, int offset, int limit, ref int total, DateTime? start_date, DateTime? end_date, string warehousecode, string warehousetype, int? warehousearea)
public static List<dc_auto_shortage_push_route_dto> ShortagePushList(string platform, string bailun_sku, int offset, int limit, ref int total, DateTime? start_date, DateTime? end_date, string warehousecode, string warehousetype, int? warehousearea)
{
var sql = @"select t1.id, t1.platform, t1.bailun_sku,t3.warehouse_name, t1.warehouse_code, t1.push_date,t2.push_time from dc_auto_shortage_push as t1
left join dc_return_goods_push as t2 on t1.id =t2.shortage_push_id
......@@ -604,11 +606,11 @@ where 1=1 ";
public static string MapField(string sort)
{
sort = sort.Replace("-","");
sort = sort.Replace("-", "");
switch (sort)
{
case "quantity_out_stock":return "t4.quantity_out_stock";
default:return sort;
case "quantity_out_stock": return "t4.quantity_out_stock";
default: return sort;
}
}
......@@ -659,5 +661,110 @@ where bailun_sku in @skus", new { skus = skus.Split(',').ToList() });
{
return _connection.Query<product_type_dto>(" select DISTINCT product_type as 'id',product_type_desc as 'name' from dc_base_sku ").ToList();
}
/// <summary>
/// 同步 pps的刊登状态
/// </summary>
public static void SynchroPPSSkuStatus()
{
int page = 1;
int rows = 1000;
var conn = _connection;
conn.Execute(" Truncate table dc_base_listing_status_temp; ");
while (true)
{
var now = DateTime.Now;
List<dc_base_listing_status> add_datas = new List<dc_base_listing_status>();
List<dc_base_listing_status> update_datas = new List<dc_base_listing_status>();
var skus = conn.Query<string>($" select * from bailun_sku limit {(page - 1) * rows},{rows} ").ToList();
if (skus == null || skus.Count <= 0)
{
break;
}
else
{
var pps_skus = ApiUtility.GetPPSSkuStatus(new api_pps_sku_status_request_dto { sku = skus });
if (pps_skus != null && pps_skus.Count >= 1)
{
foreach (var item in pps_skus)
{
var item_data = new dc_base_listing_status
{
bailun_sku = item.sku,
platform = item.platformDesc,
localtion = "",
platform_sku = "",
status = item.statusDesc == "上架" ? 1 : 0,
sys_update_date = now,
update_date = now,
web_site = item.site ?? ""
};
add_datas.Add(item_data);
//item_data.id = conn.QueryFirstOrDefault<int?>(" select id from dc_base_listing_status where platform=@platform and web_site=@web_site and bailun_sku=@bailun_sku ", new
//{
// platform = item_data.platform,
// web_site = item_data.web_site,
// bailun_sku = item_data.bailun_sku
//}) ?? 0;
//if (item_data.id > 0)
//{
// update_datas.Add(item_data);
//}
//else
//{
// add_datas.Add(item_data);
//}
}
if (add_datas != null && add_datas.Count >= 1)
{
BatchInsertDatas(conn, add_datas);
}
if (add_datas != null && add_datas.Count >= 1)
{
BatchUpdateDatas(conn, update_datas);
}
}
}
}
conn.Execute(@"
alter table dc_base_listing_status rename dc_base_listing_statusTemp;
alter table dc_base_listing_status_temp rename dc_base_listing_status;
alter table dc_base_listing_statusTemp rename dc_base_listing_status_temp;
truncate table dc_base_listing_status_temp; ");
}
public static void BatchUpdateDatas(MySqlConnection conn, List<dc_base_listing_status> datas)
{
var sql = @"UPDATE dc_base_listing_status_temp SET bailun_sku=@bailun_sku,platform=@platform,`localtion`=@localtion,platform_sku=@platform_sku,`status`=@status,sys_update_date=@sys_update_date,update_date=@update_date,web_site=@web_site WHERE id = @id ;";
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();//开始计时
var res = conn.Execute(sql, datas);
Console.WriteLine($" 更新 {datas.Count} 条数据,耗时 {watch.ElapsedMilliseconds} 毫秒 ");
}
public static void BatchInsertDatas(MySqlConnection conn, List<dc_base_listing_status> datas)
{
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();//开始计时
StringBuilder sqlSb = new StringBuilder(@" insert into dc_base_listing_status_temp(`bailun_sku`,`platform`,`localtion`,`platform_sku`,`status`,`sys_update_date`,`update_date`,`web_site`) value ");
foreach (var item in datas)
{
sqlSb.Append($"('{item.bailun_sku}','{item.platform}','{item.localtion}','{item.platform_sku}',{item.status},'{item.sys_update_date.ToString("yyyy-MM-dd HH:mm:ss")}','{item.update_date.ToString("yyyy-MM-dd HH:mm:ss")}','{item.web_site}' ),");
}
var sql = sqlSb.ToString();
sql = sql.Substring(0, sql.Length - 1);
var res = conn.Execute(sql.ToString());
Console.WriteLine($" 新增 {datas.Count} 条数据,耗时 {watch.ElapsedMilliseconds} 毫秒 ");
}
}
}
......@@ -2582,5 +2582,10 @@ where 1=1
{
return _connection.Query<platform_type_website_dto>(" select DISTINCT platform_type,website from dc_base_oms_order ").AsList();
}
public static List<string> BrandList()
{
return _connection.Query<string>(" SELECT DISTINCT brand FROM `dc_base_sku` ").AsList();
}
}
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
/// <summary>
/// sku 刊登状态
/// </summary>
public class api_pps_sku_status_response_dto
{
public List<sku_dto> result { get; set; }
public class sku_dto
{
public string sku { get; set; }
/// <summary>
/// 平台
/// </summary>
public string platformDesc { get; set; }
/// <summary>
/// 站点
/// </summary>
public string site { get; set; }
/// <summary>
/// 状态 【上架 下架】
/// </summary>
public string statusDesc { get; set; }
}
}
public class api_pps_sku_status_request_dto
{
public List<string> sku { get; set; }
}
}
using AutoTurnOver.Services;
using AutoTurnOver.DB;
using AutoTurnOver.Services;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
......@@ -24,6 +25,12 @@ namespace AutoTurnOver.Purchase.AverageTarget
{
var now = DateTime.Now;
// 判断是不是指定的时间
if (now.Hour == 23 && now.Minute == 58)
{
Console.WriteLine($"开始同步sku刊登状态,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
daily.SynchroPPSSkuStatus();
Console.WriteLine($"结束同步sku刊登状态,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
if (now.Hour == 23 && now.Minute == 59)
{
Console.WriteLine($"开始采购平均值统计任务,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
......
using AutoTurnOver.Services;
using AutoTurnOver.DB;
using AutoTurnOver.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AutoTurnOver.Purchase.AverageTarget
......@@ -20,7 +22,9 @@ namespace AutoTurnOver.Purchase.AverageTarget
{
Console.WriteLine("采购平均值计算任务启动...");
// 创建采购计划
PurchaseAverageTargetServices.Calculation();
Console.WriteLine($"开始同步sku刊登状态,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
daily.SynchroPPSSkuStatus();
Console.WriteLine($"结束同步sku刊登状态,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{
......
{
"ConnectionStrings": {
"Default": "server=gz-cdb-kp7s5i79.sql.tencentcdb.com;port=61691;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
}
},
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus"
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
}
},
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus"
}
{
"ConnectionStrings": {
"Default": "server=10.0.8.15;port=3306;database=bailun_datacenter;uid=root;password=#7kfnymAM$Y9-Ntf;"
}
},
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus"
}
\ No newline at end of file
......@@ -34,6 +34,11 @@ namespace AutoTurnOver.Services
return DB.common.SearchPurchaseUser(name);
}
public List<string> BrandList()
{
return report.BrandList();
}
}
}
......@@ -176,6 +176,12 @@ namespace AutoTurnOver.Controllers
return new JsonResult(datas);
}
public JsonResult BrandList()
{
var datas = new CommonServices().BrandList();
return new JsonResult(datas);
}
/// <summary>
/// crm 自定义出信模板
/// </summary>
......
......@@ -62,14 +62,14 @@ namespace AutoTurnOver.Controllers
/// <returns></returns>
[UseAction]
public JsonResult RealtimeList(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null,DateTime? end_date =null,DateTime? f_start_date = null, DateTime? f_end_date = null,int? product_type = null)
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null, int? product_type = null)
{
try
{
var services = new DailyServices();
var total = 0;
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, order: order, sort: sort, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name,start_date:start_date,end_date:end_date,f_start_date:f_start_date,f_end_date:f_end_date, product_type: product_type);
var list = services.RealtimeList(monitor_status, searchType, key_words, warehousecode, supplier_name, offset, limit, ref total, warehousetype, warehousearea, order: order, sort: sort, has_tort: has_tort, categoryIds: categoryIds, buyer_name: buyer_name, start_date: start_date, end_date: end_date, f_start_date: f_start_date, f_end_date: f_end_date, product_type: product_type);
return new JsonResult(new
{
......@@ -89,7 +89,7 @@ namespace AutoTurnOver.Controllers
}
public JsonResult RealtimeListSumFooter(int? monitor_status, int? searchType, string key_words, string warehousecode, string buyer_name, string supplier_name, int offset, int limit, string order, string sort, string warehousetype, int? warehousearea, int? has_tort = null, string categoryIds = null,
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null,int? product_type = null)
DateTime? start_date = null, DateTime? end_date = null, DateTime? f_start_date = null, DateTime? f_end_date = null, int? product_type = null)
{
var services = new DailyServices();
......@@ -114,7 +114,7 @@ namespace AutoTurnOver.Controllers
{
var services = new DailyServices();
var total = 0;
var list = services.ShortagePushList(platform, bailun_sku, offset, limit, ref total, start_date,end_date,warehousecode, warehousetype, warehousearea);
var list = services.ShortagePushList(platform, bailun_sku, offset, limit, ref total, start_date, end_date, warehousecode, warehousetype, warehousearea);
return new JsonResult(new
{
rows = list,
......@@ -228,12 +228,28 @@ namespace AutoTurnOver.Controllers
}
public JsonResult GetListingStatusPage(int offset, int limit, string order, string sort,
DateTime? end_date, DateTime? start_date,string brand,int? has_tort,int? listing_status,int? warehousearea,int? source,string warehousetype,string warehouse_code)
DateTime? end_date, DateTime? start_date, string brand, int? has_tort, int? listing_status, int? warehousearea, int? source, string warehousetype, string warehouse_code, int? product_type)
{
try
{
var services = new StockMonitorService();
var page_data = services.GetListingStatusPage(new listing_status_view_search_dto {warehouse_code = warehouse_code, warehousetype = warehousetype, source = source, warehousearea = warehousearea, listing_status = listing_status, brand = brand, has_tort = has_tort, page = offset + 1, rows = limit, sidx = sort, sord = order, start_date = start_date, end_date = end_date });
var page_data = services.GetListingStatusPage(new listing_status_view_search_dto
{
product_type= product_type,
source = source,
warehouse_code = warehouse_code,
warehousetype = warehousetype,
warehousearea = warehousearea,
listing_status = listing_status,
brand = brand,
has_tort = has_tort,
page = offset + 1,
rows = limit,
sidx = sort,
sord = order,
start_date = start_date,
end_date = end_date
});
return new JsonResult(new
{
......
......@@ -23,7 +23,7 @@ namespace ResetOutofstock
// throw;
//}
report.ResetCashFlowData();
//report.ResetCashFlowData();
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
......
......@@ -10,5 +10,6 @@
"Defaultdatabase": "0"
},
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics"
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus"
}
......@@ -11,5 +11,6 @@
},
"PPS_ShortagePush": "http://bltpro.bailuntec.com/api/EbayTask/PushSkuEditQtyTask",
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics"
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus"
}
......@@ -10,5 +10,6 @@
"Defaultdatabase": 0
},
"WipStockUrl": "http://mjzz.bailuntec.com/api/FullStockPageList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics"
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"PPSSkuStatus": "http://pps.bailuntec.com/Api/Centre/Publish/External/SkuStatus"
}
\ No newline at end of file
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