Browse Source

更新版本

dev_DY_CC
赵新宇 11 months ago
parent
commit
0a39d710fe
  1. 44
      be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs

44
be/DataExchange/Fawtyg/Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent/Incoming/InjectionMoldingRequestReader.cs

@ -67,55 +67,68 @@ public class InjectionMoldingRequestReader : IReader
#if DEBUG
_options.Value.AutoRemote.TimeCycle = 1;
_options.Value.AutoRemote.Interval = 2;
#endif
// var sleepTime = (_options.Value.AutoRemote.TimeCycle*60/ _options.Value.AutoRemote.Interval)-10;
var invterval = _options.Value.AutoRemote.Interval;
var guid = DateTime.Now.ToString("yyyyMMddHHmmssfff");
Stopwatch sw = Stopwatch.StartNew();
Client client = new Client(_options.Value.AutoRemote.IpAddress, _httpClientFactory.CreateClient());//调用客户记录
var flag = await client.GetMacStaticAsync().ConfigureAwait(false);
if (flag != 1)
{
// 记录错误日志并返回空列表
_logger.LogInformation($"读取到摄像头信息为不可用{DateTime.Now},请检查摄像头");
return new List<IncomingFromExternal>();
}
if (string.IsNullOrEmpty(_options.Value.AutoRemote.AreaIDs))
{
_logger.LogInformation($"没有设置指定区域AutoRemote->AreaIDs");
return new List<IncomingFromExternal>();
}
var ids = _options.Value.AutoRemote.AreaIDs.Split(",");
List<ResponCargoItem> camralist = new List<ResponCargoItem>();
for (int i = 1; i <= invterval; i++)
{
foreach (var itm in ids)//遍历区域查找所有货物
{
var idsList = await client.GetCargoStaticAsync(itm).ConfigureAwait(false);
//flag 1-有货 0-空闲
camralist.AddRange(idsList.Where(r => r.Flag == 0));
}
_logger.LogInformation($"读取标识{guid}读取成功次数{i},耗时 {sw.ElapsedMilliseconds}毫秒");
}
_logger.LogInformation($"标识{guid}读取全部空闲内容:{System.Text.Json.JsonSerializer.Serialize(camralist)}");
sw.Stop();
Thread.Sleep(1000);
//按区域、货位号、零件、标志
var group= camralist.GroupBy(r => new { r.AreaID, r.CargoID, r.PartCode, r.Flag });
//获取和次数相等的空闲数据
var list = group.Where(r => r.Count() == invterval).ToList();
var errorlist= group.Where(r => r.Count() != invterval).ToList();
if (errorlist.Count > 0)
{
_logger.LogInformation($"标识{guid}不能在规定次数内完成读取的{System.Text.Json.JsonSerializer.Serialize(errorlist.Select(r => r.Key).ToList())}");
}
//如果有货位空闲
if (list.Count>0)
{
sw = Stopwatch.StartNew();
sw = Stopwatch.StartNew();
_logger.LogInformation($"开始标识{guid}同步WMS开始");
List<UnCompletedRequestDto> inputdetail = new List<UnCompletedRequestDto>();
foreach (var item in list.Select(r=>r.Key).ToList())
@ -137,11 +150,18 @@ public class InjectionMoldingRequestReader : IReader
select itm;
var injectionList = query.ToList();//已经完成的记录
_logger.LogInformation($"标识{guid}同步WMS未完成记录:{System.Text.Json.JsonSerializer.Serialize(injectionList)}");
foreach (var inject in injectionList)
{
List<InjectionRequest> cameraList = new List<InjectionRequest>();
InjectionIssueRequestEditInput input = new InjectionIssueRequestEditInput();
input.Worker = "Vision";
input.IssueRequestType = EnumIssueRequestType.Vision;
@ -249,7 +269,7 @@ public class InjectionMoldingRequestReader : IReader
{
// 获取对应零件信息
var itm = await _itemService.GetByCodeAsync(request.ItemCode).ConfigureAwait(false);
if (itm == null) { errors.Add($"编号:{request.ItemCode}零件表中没找到!"); }
if (itm == null) { errors.Add($"编号:{request.ItemCode}零件表中没找到,请维护零件表!"); }
else
{
// 更新请求中的零件描述和名称
@ -260,7 +280,7 @@ public class InjectionMoldingRequestReader : IReader
}
// 获取对应库位信息
var loc = await _locService.GetByCodeAsync(request.ToLocationCode).ConfigureAwait(false);
if (loc == null) { errors.Add($"编号:{request.ToLocationCode}库位表中没找到!"); }
if (loc == null) { errors.Add($"编号:{request.ToLocationCode}库位表中没找到,请维护库位表!"); }
else
{

Loading…
Cancel
Save