|
@ -51,14 +51,14 @@ public class InjectionMoldingRequestReader : IReader |
|
|
_logger = logger; |
|
|
_logger = logger; |
|
|
_options = options; |
|
|
_options = options; |
|
|
_httpClientFactory = httpClientFactory; |
|
|
_httpClientFactory = httpClientFactory; |
|
|
_itemService=itemService; |
|
|
_itemService = itemService; |
|
|
_locService = locService; |
|
|
_locService = locService; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 读取注塑叫料任务
|
|
|
/// 读取注塑叫料任务
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
|
public virtual async Task<List<IncomingFromExternal>> ReadAsync() |
|
|
public virtual async Task<List<IncomingFromExternal>> ReadAsync() |
|
|
{ |
|
|
{ |
|
@ -72,13 +72,10 @@ public class InjectionMoldingRequestReader : IReader |
|
|
// var sleepTime = (_options.Value.AutoRemote.TimeCycle*60/ _options.Value.AutoRemote.Interval)-10;
|
|
|
// var sleepTime = (_options.Value.AutoRemote.TimeCycle*60/ _options.Value.AutoRemote.Interval)-10;
|
|
|
var invterval = _options.Value.AutoRemote.Interval; |
|
|
var invterval = _options.Value.AutoRemote.Interval; |
|
|
|
|
|
|
|
|
var successTime = 0; |
|
|
|
|
|
|
|
|
|
|
|
var guid = DateTime.Now.ToString("yyyyMMddHHmmssfff"); |
|
|
var guid = DateTime.Now.ToString("yyyyMMddHHmmssfff"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <invterval; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
Stopwatch sw = Stopwatch.StartNew(); |
|
|
Stopwatch sw = Stopwatch.StartNew(); |
|
|
|
|
|
|
|
|
Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录
|
|
|
Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录
|
|
@ -97,25 +94,31 @@ public class InjectionMoldingRequestReader : IReader |
|
|
} |
|
|
} |
|
|
var ids = _options.Value.AutoRemote.AreaIDs.Split(","); |
|
|
var ids = _options.Value.AutoRemote.AreaIDs.Split(","); |
|
|
List<ResponCargoItem> camralist = new List<ResponCargoItem>(); |
|
|
List<ResponCargoItem> camralist = new List<ResponCargoItem>(); |
|
|
|
|
|
for (int i = 1; i <= invterval; i++) |
|
|
|
|
|
{ |
|
|
foreach (var itm in ids)//遍历区域查找所有货物
|
|
|
foreach (var itm in ids)//遍历区域查找所有货物
|
|
|
{ |
|
|
{ |
|
|
var idsList = await client.GetCargoStaticAsync(itm).ConfigureAwait(false); |
|
|
var idsList = await client.GetCargoStaticAsync(itm).ConfigureAwait(false); |
|
|
camralist.AddRange(idsList); |
|
|
//flag 1-有货 0-空闲
|
|
|
|
|
|
camralist.AddRange(idsList.Where(r => r.Flag == 0)); |
|
|
|
|
|
} |
|
|
|
|
|
_logger.LogInformation($"读取标识{guid}读取成功次数{i},耗时 {sw.ElapsedMilliseconds}毫秒"); |
|
|
} |
|
|
} |
|
|
successTime++; |
|
|
|
|
|
sw.Stop(); |
|
|
sw.Stop(); |
|
|
_logger.LogInformation($"读取标识{guid}读取成功次数{successTime},耗时 {sw.ElapsedMilliseconds}毫秒"); |
|
|
|
|
|
Thread.Sleep(1000); |
|
|
Thread.Sleep(1000); |
|
|
|
|
|
//按区域、货位号、零件、标志
|
|
|
|
|
|
var group= camralist.GroupBy(r => new { r.AreaID, r.CargoID, r.PartCode, r.Flag }); |
|
|
|
|
|
//获取和次数相等的空闲数据
|
|
|
if (successTime == invterval) |
|
|
var list = group.Where(r => r.Count() == invterval).ToList(); |
|
|
|
|
|
//如果有货位空闲
|
|
|
|
|
|
if (list.Count>0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
sw = Stopwatch.StartNew(); |
|
|
sw = Stopwatch.StartNew(); |
|
|
|
|
|
|
|
|
_logger.LogInformation($"开始标识{guid}同步WMS开始"); |
|
|
_logger.LogInformation($"开始标识{guid}同步WMS开始"); |
|
|
List<UnCompletedRequestDto> inputdetail = new List<UnCompletedRequestDto>(); |
|
|
List<UnCompletedRequestDto> inputdetail = new List<UnCompletedRequestDto>(); |
|
|
foreach (var item in camralist) |
|
|
foreach (var item in list.Select(r=>r.Key).ToList()) |
|
|
{ |
|
|
{ |
|
|
UnCompletedRequestDto jobrequestinput = new UnCompletedRequestDto(); |
|
|
UnCompletedRequestDto jobrequestinput = new UnCompletedRequestDto(); |
|
|
jobrequestinput.ItemCode = item.PartCode; |
|
|
jobrequestinput.ItemCode = item.PartCode; |
|
@ -124,9 +127,9 @@ public class InjectionMoldingRequestReader : IReader |
|
|
inputdetail.Add(jobrequestinput); |
|
|
inputdetail.Add(jobrequestinput); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var uncompletelist = await _injectionRequest.GetUnCompletedRequestAsync(inputdetail).ConfigureAwait(false);//将所有库位零件信息查找未完成记录
|
|
|
var uncompletelist = await _injectionRequest.Getlist(inputdetail).ConfigureAwait(false);//将所有库位零件信息查找未完成记录
|
|
|
|
|
|
|
|
|
var query = from itm in camralist |
|
|
var query = from itm in list.Select(r => r.Key).ToList() |
|
|
join itm1 in uncompletelist on new { locCode = itm.AreaID.ToString(), itmCode = itm.PartCode, PositionCode = itm.CargoID.ToString() } |
|
|
join itm1 in uncompletelist on new { locCode = itm.AreaID.ToString(), itmCode = itm.PartCode, PositionCode = itm.CargoID.ToString() } |
|
|
equals new { locCode = itm1.LocCode, itmCode = itm1.ItemCode, PositionCode = itm1.PositionCode } into temp |
|
|
equals new { locCode = itm1.LocCode, itmCode = itm1.ItemCode, PositionCode = itm1.PositionCode } into temp |
|
|
from tm in temp.DefaultIfEmpty() |
|
|
from tm in temp.DefaultIfEmpty() |
|
@ -181,7 +184,7 @@ public class InjectionMoldingRequestReader : IReader |
|
|
await _injectionRequest.CreateAsync(input).ConfigureAwait(false); |
|
|
await _injectionRequest.CreateAsync(input).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
_logger.LogInformation($"标识{guid}同步WMS结束,耗时{sw.ElapsedMilliseconds }毫秒"); |
|
|
_logger.LogInformation($"标识{guid}同步WMS结束,耗时{sw.ElapsedMilliseconds}毫秒"); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -189,8 +192,6 @@ public class InjectionMoldingRequestReader : IReader |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录
|
|
|
//Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录
|
|
|