|
|
@ -18,8 +18,9 @@ using Win_in.Sfs.Wms.DataExchange.WMS.PCK; |
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
|
using System.Text.Json.Serialization; |
|
|
|
using System.IdentityModel.Tokens.Jwt; |
|
|
|
using Volo.Abp; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Incoming; |
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming; |
|
|
|
|
|
|
|
public class InjectionMoldingRequestReader : IReader |
|
|
|
{ |
|
|
@ -27,21 +28,19 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
private readonly IInjectionRequestAppService _injectionRequest; |
|
|
|
private readonly IItemBasicAppService _itemService; |
|
|
|
private readonly ILocationAppService _locService; |
|
|
|
|
|
|
|
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|
|
|
private readonly ILogger<InjectionMoldingRequestReader> _logger; |
|
|
|
private readonly IOptions<InjectionMoldingTaskOptions> _options; |
|
|
|
private readonly IHttpClientFactory _httpClientFactory; |
|
|
|
|
|
|
|
|
|
|
|
public InjectionMoldingRequestReader( |
|
|
|
IInjectionRequestAppService injectionRequest |
|
|
|
, IIncomingFromExternalManager incomingFromExternalManager |
|
|
|
, ILogger<InjectionMoldingRequestReader> logger |
|
|
|
,IOptions<InjectionMoldingTaskOptions> options |
|
|
|
, IOptions<InjectionMoldingTaskOptions> options |
|
|
|
, IHttpClientFactory httpClientFactory |
|
|
|
,IItemBasicAppService itemService |
|
|
|
,ILocationAppService locService |
|
|
|
, IItemBasicAppService itemService |
|
|
|
, ILocationAppService locService |
|
|
|
|
|
|
|
) |
|
|
|
{ |
|
|
@ -63,9 +62,9 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
Filter filter = new Filter() |
|
|
|
{ |
|
|
|
Action = "<>", |
|
|
|
Column = "JobStatus", |
|
|
|
Column = "RequestStatus", |
|
|
|
Logic = EnumFilterLogic.And.ToString(), |
|
|
|
Value = ((int)EnumJobStatus.Done).ToString() |
|
|
|
Value = ((int)EnumRequestStatus.Completed).ToString() |
|
|
|
}; |
|
|
|
jobCondition.Condition.Filters.Add(filter); |
|
|
|
var jobs = await _injectionRequest.GetAllListByFilterAsync(jobCondition).ConfigureAwait(false); |
|
|
@ -81,12 +80,8 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
_logger.LogError($"没有读取到摄像头信息{DateTime.Now},请检查网络"); |
|
|
|
return new List<IncomingFromExternal>(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cameraList = System.Text.Json.JsonSerializer.Deserialize<List<InjectionRequest>>(camera);//camera转注塑叫料明细任务数据
|
|
|
|
|
|
|
|
|
|
|
|
InjectionRequestEditInput input=new InjectionRequestEditInput(); |
|
|
|
List<InjectionRequestDetailInput> injectionRequestDetails = new List<InjectionRequestDetailInput>(); |
|
|
|
|
|
|
@ -113,29 +108,37 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
await _injectionRequest.CreateAsync(input).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (AbpException ex) |
|
|
|
{ |
|
|
|
_logger.LogError(ex.Message); |
|
|
|
} |
|
|
|
catch (JsonException ex) |
|
|
|
{ |
|
|
|
_logger.LogError(ex.Message); |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
_logger.LogError(ex.Message); |
|
|
|
} |
|
|
|
return new List<IncomingFromExternal>(); |
|
|
|
} |
|
|
|
|
|
|
|
private async Task<List<string>> BindAsync(List<InjectionRequestDetailInput> p_list) |
|
|
|
{ |
|
|
|
List<string> errors = new List<string>(); |
|
|
|
|
|
|
|
foreach (var request in p_list) |
|
|
|
{ |
|
|
|
var itm =await _itemService.GetByCodeAsync(request.ItemCode).ConfigureAwait(false); |
|
|
|
if(itm == null) { errors.Add($"编号:{request.ItemCode}零件表中没找到!" ); }else |
|
|
|
if(itm == null) { errors.Add($"编号:{request.ItemCode}零件表中没找到!" ); } |
|
|
|
else |
|
|
|
{ |
|
|
|
request.ItemDesc1 = itm.Desc1; |
|
|
|
request.ItemDesc2 = itm.Desc2; |
|
|
|
request.ItemName = itm.Name; |
|
|
|
|
|
|
|
} |
|
|
|
var loc = await _locService.GetByCodeAsync(request.ToLocationCode).ConfigureAwait(false); |
|
|
|
if (loc == null) { errors.Add($"编号:{request.ToLocationCode}库位表中没找到!"); }else |
|
|
|
if (loc == null) { errors.Add($"编号:{request.ToLocationCode}库位表中没找到!"); } |
|
|
|
else |
|
|
|
{ |
|
|
|
request.ToLocationCode = loc.Code; |
|
|
|
request.ToLocationGroup = loc.LocationGroupCode; |
|
|
@ -143,18 +146,11 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
request.ToWarehouseCode= loc.WarehouseCode; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return errors; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// 读取摄像头API
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_type"></param>
|
|
|
|
/// <returns></returns>
|
|
|
@ -168,7 +164,7 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
var client = _httpClientFactory.CreateClient(); |
|
|
|
var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")); |
|
|
|
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials); |
|
|
|
var response = await client.GetAsync("https://example.com/api/data").ConfigureAwait(false); |
|
|
|
var response = await client.GetAsync(address).ConfigureAwait(false); |
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
return await response.Content.ReadAsStringAsync().ConfigureAwait(false); |
|
|
@ -180,7 +176,7 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
public class InjectionRequest |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// 零件吗
|
|
|
|
/// 零件M
|
|
|
|
/// </summary>
|
|
|
|
public string ItemCode { get; set; } |
|
|
|
/// <summary>
|
|
|
@ -200,10 +196,6 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
/// </summary>
|
|
|
|
public decimal Qty { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|