Commit 2c53f93f by 泽锋 李

新增调拨单当前节点的抓取服务

parent f5b8f580
......@@ -644,8 +644,36 @@ namespace AutoTurnOver.DB
}
catch (Exception ex)
{
throw new Exception("pps sku 刊登状态接口异常: " + ex.Message);
throw new Exception("pps sku 刊登状态接口异常: " + ex.StackTrace);
throw new Exception("生产系统接口异常: " + ex.Message);
throw new Exception("生产系统接口异常: " + ex.StackTrace);
}
}
/// <summary>
/// 抓取生产系统订单
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static List<api_order_transfer_current_node_dto.data_dto> GetLmsTransferOrderNode(int page ,int rows,DateTime btime,DateTime etime)
{
try
{
string url = ConfigHelper.GetValue("lms-sys:transfer-node");
string resultStr = HttpHelper.Request(url + $"?page={page}&rows={rows}&btime={btime}&etime={etime}", RequestType.GET, timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<api_order_transfer_current_node_dto>();
if (result == null)
{
return new List<api_order_transfer_current_node_dto.data_dto>() { };
}
else
{
return result.data;
}
}
catch (Exception ex)
{
throw new Exception("lms系统接口异常: " + ex.Message);
throw new Exception("lms系统接口异常: " + ex.StackTrace);
}
}
}
......
......@@ -81,5 +81,94 @@ where t1.stateid!=5 and t1.isdeleted=0 and t2.deliverycount>t2.storagecount").To
public string transporttype { get; set; }
public string logisticsname { get; set; }
}
/// <summary>
/// 抓取调拨单当前节点
/// </summary>
public static void SynchroLmsTransferOrder()
{
var task_name = "SynchroLmsTransferOrder_v1";
var conn = _connection;
// 查询最后一次成功抓取的记录
var last_task_synchro_log = conn.QuerySingleOrDefault<task_synchro_log>(" select * from task_synchro_log where task_name=@task_name and status=1 order by end_time desc limit 1 ", new { task_name = task_name });
var new_task_synchro_log = new task_synchro_log
{
create_date = DateTime.Now,
end_time = DateTime.Now.AddMinutes(-3),
status = 0,
task_name = task_name
};
if (last_task_synchro_log != null)
{
new_task_synchro_log.start_time = last_task_synchro_log.end_time.AddMinutes(-1);
}
else
{
new_task_synchro_log.start_time = new DateTime(2020, 05, 14);
}
new_task_synchro_log.id = conn.Insert(new_task_synchro_log) ?? 0;
int count = 0;
var page = 1;
var rows = 1000;
while (true)
{
var datas = ApiUtility.GetLmsTransferOrderNode(page,rows, new_task_synchro_log.start_time, new_task_synchro_log.end_time);
if (datas == null || datas.Count <= 0)
{
break;
}
page++;
foreach (var item in datas)
{
var db_data = new dc_lms_order_transfer_current_node()
{
box_id = item.box_id??"",
data_id = item.data_id,
node_date =item.node_date,
lms_update_date = item.update_date,
node_name = item.node_name??"",
sign_exe =item.sign_exe,
system_order_no =item.system_order_no,
trackingno = item.trackingno??"",
transfer_no = item.transfer_no??""
};
db_data.id = MyMySqlConnection._connection.QueryFirstOrDefault<int?>(" select id from dc_lms_order_transfer_current_node where `data_id`=@data_id and box_id=@box_id ", new
{
data_id = db_data.data_id,
box_id = db_data.box_id,
})??0;
if (db_data.id>0)
{
conn.Update(db_data);
}
else
{
conn.Insert(db_data);
}
count++;
}
// 如果抓到箱子号了,则把之前没有箱子号的数据删了
var dataIds = datas.Where(s => !string.IsNullOrWhiteSpace(s.box_id)).Select(s=>s.data_id).ToList();
if (dataIds!=null && dataIds.Count>=1)
{
_connection.Execute(" delete from dc_lms_order_transfer_current_node where box_id='' and data_id in @data_ids ",new {
data_ids = dataIds
});
}
}
new_task_synchro_log.count = count;
new_task_synchro_log.status = 1;
conn.Update(new_task_synchro_log);
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
public class api_order_transfer_current_node_dto
{
public bool success { get; set; }
public List<data_dto> data { get; set; }
public class data_dto
{
public DateTime update_date { get; set; }
public DateTime node_date { get; set; }
public string node_name { get; set; }
/// <summary>
/// 调拨单号
/// </summary>
public string system_order_no { get; set; }
/// <summary>
/// 转单号
/// </summary>
public string transfer_no { get; set; }
/// <summary>
/// 跟踪号
/// </summary>
public string trackingno { get; set; }
/// <summary>
/// 箱子号
/// </summary>
public string box_id { get; set; }
public int data_id { get; set; }
/// <summary>
/// 是否异常
/// </summary>
public int sign_exe { get; set; }
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
/// <summary>
/// 调拨单当前节点
/// </summary>
public class dc_lms_order_transfer_current_node
{
public int id { get; set; }
public int data_id { get; set; }
public DateTime lms_update_date { get; set; }
public DateTime node_date { get; set; }
public string node_name { get; set; }
public string system_order_no { get; set; }
public string transfer_no { get; set; }
public string trackingno { get; set; }
public string box_id { get; set; }
public int sign_exe { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
/// <summary>
/// 调拨在途全链路监控
/// </summary>
public class order_transfer_full_link_dto
{
public string sku { get; set; }
public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
public string sku_name { get; set; }
public decimal? stock { get; set; }
public decimal not_storage { get; set; }
public decimal? history_sevenday_sales { get; set; }
public decimal? history_fourteenday_sales { get; set; }
public decimal? history_thirtyday_sales { get; set; }
public string buyer_name { get; set; }
public string product_type_desc { get; set; }
public int? forecast_type { get; set; }
public string order_no { get; set; }
public string trackingno { get; set; }
public string transporttype { get; set; }
public string dataid { get; set; }
public string channelname { get; set; }
}
}
......@@ -30,7 +30,7 @@ namespace AutoTurnOver.Purchase.AverageTarget
//PurchaseAverageTargetServices.CalculationTransfer();
//report.ResetTransExpectArrivaltime();
dc_auto_return_goods_config_dao.NewCalculation();
}
catch (Exception ex)
......
......@@ -31,7 +31,7 @@ namespace ResetOutofstock
//daily.ResetFbaExtendSales(DateTime.Now);
//dc_aims_transfer_warehouse_dao.TransferWarehouseTask();
//daily.ResetFbaExtendReview(DateTime.Now);
}
catch (Exception ex)
......
......@@ -86,6 +86,25 @@ namespace ResetOutofstock
}
});
Task.Factory.StartNew(() =>
{
while (true)
{
try
{
Console.WriteLine($"开始 同步调拨单当前节点 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
dc_base_transfer_extend_dao.SynchroLmsTransferOrder();
Console.WriteLine($"结束 同步调拨单当前节点 ,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
Thread.Sleep(10 * 60 * 1000);
}
});
Task.Factory.StartNew(() =>
......
......@@ -32,5 +32,8 @@
},
"prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList"
},
"lms-sys": {
"transfer-node": "http://lms.bailuntec.com/api/order/transfer/ApiOrderTransferCurrentNode"
}
}
......@@ -33,5 +33,8 @@
},
"prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList"
},
"lms-sys": {
"transfer-node": "http://lms.bailuntec.com/api/order/transfer/ApiOrderTransferCurrentNode"
}
}
......@@ -32,5 +32,8 @@
},
"prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList"
},
"lms-sys": {
"transfer-node": "http://lms.bailuntec.com/api/order/transfer/ApiOrderTransferCurrentNode"
}
}
\ 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