Commit f75329a5 by guanzhenshan

调整wms物流基础数据

parent 30b63a09
......@@ -13,7 +13,7 @@ namespace Bailun.DC.SyncLogisticInfo
{
public class Services : BackgroundService
{
private static bool isRuning = false;
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
......@@ -28,7 +28,7 @@ namespace Bailun.DC.SyncLogisticInfo
{
var now = DateTime.Now;
if (now.Minute%30==0) //每30分钟同步一次
if (now.Minute%10==0 && !isRuning) //每30分钟同步一次
{
Console.WriteLine("开始启动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Init();
......@@ -45,6 +45,9 @@ namespace Bailun.DC.SyncLogisticInfo
public void Init()
{
try
{
isRuning = true;
Dapper.SimpleCRUD.SetDialect(SimpleCRUD.Dialect.MySQL);
var starttime = DateTime.Parse("2020-01-01");
......@@ -63,8 +66,8 @@ namespace Bailun.DC.SyncLogisticInfo
var m = cn.QueryFirstOrDefault<DateTime?>("select end_time from job_point_log where job_name='dc-base-logisticinfo'");
if (m != null && m.HasValue)
{
starttime = m.Value.AddMinutes(-3);
endtime = starttime.AddHours(1);
starttime = m.Value.AddMinutes(-2);
endtime = starttime.AddHours(2);
}
}
......@@ -77,7 +80,7 @@ namespace Bailun.DC.SyncLogisticInfo
}
while (total == -1 || total>((page-1)*pagesize))
while (total == -1 || total > ((page - 1) * pagesize))
{
var j = new
{
......@@ -92,16 +95,16 @@ namespace Bailun.DC.SyncLogisticInfo
var str = Common.HttpHelper.NetHelper.HttpPostJson(url, JsonConvert.SerializeObject(j));
var json = Newtonsoft.Json.JsonConvert.DeserializeObject<mResult>(str);
if (json!=null && json.success && json.result.result.Count > 0)
if (json != null && json.success && json.result.result.Count > 0)
{
Save(json.result.result);
Console.WriteLine("总记录数:"+ json.result.total + ",当前页记录数:" + json.result.result.Count + "条记录。"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
Console.WriteLine("总记录数:" + json.result.total + ",当前页记录数:" + json.result.result.Count + "条记录。" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
total = json.result.total;
page++;
}
else
{
page=1;
page = 1;
total = 0;
endtime = endtime.AddDays(1);
}
......@@ -114,10 +117,17 @@ namespace Bailun.DC.SyncLogisticInfo
cn.Open();
}
cn.Execute("update job_point_log start_time='"+starttime.ToString("yyyy-MM-dd HH:mm:ss")+"',end_time='"+endtime.ToString("yyyy-MM-dd HH:mm:ss")+"' where job_name='dc-base-logisticinfo'");
cn.Execute("update job_point_log start_time='" + starttime.ToString("yyyy-MM-dd HH:mm:ss") + "',end_time='" + endtime.ToString("yyyy-MM-dd HH:mm:ss") + "' where job_name='dc-base-logisticinfo'");
}
isRuning = false;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
isRuning = false;
}
}
......
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