|
|
@ -62,34 +62,17 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
|
|
|
|
public virtual async Task<List<IncomingFromExternal>> ReadAsync() |
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
// 创建 SfsStoreRequestInputBase 对象以设定作业条件
|
|
|
|
var jobCondition = new SfsStoreRequestInputBase(); |
|
|
|
Filter filter = new Filter() |
|
|
|
{ |
|
|
|
Action = "<>", |
|
|
|
Column = "RequestStatus", |
|
|
|
Logic = EnumFilterLogic.And.ToString(), |
|
|
|
Value = (EnumRequestStatus.Completed).ToString() |
|
|
|
}; |
|
|
|
// 添加筛选条件:请求状态不等于已完成
|
|
|
|
jobCondition.Condition.Filters.Add(filter); |
|
|
|
filter = new Filter() |
|
|
|
{ |
|
|
|
Action = "==", |
|
|
|
Column = "Type", |
|
|
|
Logic = EnumFilterLogic.And.ToString(), |
|
|
|
Value = "Vision" |
|
|
|
}; |
|
|
|
// 添加筛选条件:类型为 Vision
|
|
|
|
jobCondition.Condition.Filters.Add(filter); |
|
|
|
// 通过筛选条件获取作业列表
|
|
|
|
var jobs = await _injectionRequest.GetAllListByFilterAsync(jobCondition).ConfigureAwait(false); |
|
|
|
// 获取注塑叫料任务数量
|
|
|
|
var count = await _injectionRequest.GetCountAsync().ConfigureAwait(false); |
|
|
|
List<InjectionRequestEditInput> joblist = new List<InjectionRequestEditInput>(); |
|
|
|
if (jobs.Count == 0) |
|
|
|
if (count == 0) |
|
|
|
{ |
|
|
|
// 调用 ReaderCameraApi 方法获取摄像头信息
|
|
|
|
|
|
|
|
|
|
|
|
string camera = await ReaderCameraApi().ConfigureAwait(false); |
|
|
|
|
|
|
|
List<InjectionRequest> cameraList = new List<InjectionRequest>(); |
|
|
@ -97,23 +80,40 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
if (camera == "Error occured") |
|
|
|
{ |
|
|
|
// 记录错误日志并返回空列表
|
|
|
|
_logger.LogError($"没有读取到摄像头信息{DateTime.Now},请检查网络"); |
|
|
|
_logger.LogInformation($"没有读取到摄像头信息{DateTime.Now},请检查网络"); |
|
|
|
return new List<IncomingFromExternal>(); |
|
|
|
} |
|
|
|
// 将摄像头信息转换为注塑叫料明细任务数据
|
|
|
|
//将摄像头信息转换为注塑叫料明细任务数据
|
|
|
|
cameraList = System.Text.Json.JsonSerializer.Deserialize<List<InjectionRequest>>(camera); |
|
|
|
|
|
|
|
//测试数据
|
|
|
|
//var cameraList = new List<InjectionRequest>()
|
|
|
|
//{
|
|
|
|
// new InjectionRequest() { ItemCode = "THILDD0A542AG", ToLocCode = "ZSXB2", Qty = 100 },
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
InjectionRequestEditInput input = new InjectionRequestEditInput(); |
|
|
|
input.Worker = "Vision"; |
|
|
|
input.Type = "Vision"; |
|
|
|
input.AutoSubmit = true; |
|
|
|
input.ActiveDate = DateTime.Now; |
|
|
|
input.UseOnTheWayLocation = false; |
|
|
|
input.Remark = "视觉叫料"; |
|
|
|
List<InjectionRequestDetailInput> injectionRequestDetails = new List<InjectionRequestDetailInput>(); |
|
|
|
|
|
|
|
foreach (var job in cameraList) |
|
|
|
{ |
|
|
|
|
|
|
|
var detailInput = new InjectionRequestDetailInput() |
|
|
|
{ |
|
|
|
|
|
|
|
ItemCode = job.ItemCode, |
|
|
|
ToLocationCode = job.ToLocCode, |
|
|
|
Qty = job.Qty, |
|
|
|
RecommendType = EnumRecommendType.W, |
|
|
|
IssuedQty = 0, |
|
|
|
ReceivedQty = 0, |
|
|
|
Status = EnumStatus.Open, |
|
|
|
RequestStatus = EnumRequestStatus.New, |
|
|
|
}; |
|
|
|
// 添加注塑叫料明细任务数据
|
|
|
|
injectionRequestDetails.Add(detailInput); |
|
|
@ -126,7 +126,7 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
// 记录错误日志并返回空列表
|
|
|
|
foreach (var error in errors) |
|
|
|
{ |
|
|
|
_logger.LogError(error); |
|
|
|
_logger.LogInformation(error); |
|
|
|
} |
|
|
|
return new List<IncomingFromExternal>(); |
|
|
|
|
|
|
@ -134,19 +134,16 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
// 创建新的注塑请求并将数据写入数据库
|
|
|
|
await _injectionRequest.CreateAsync(input).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogInformation("注塑叫料任务已存在,无需读取"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 捕获特定异常并记录日志
|
|
|
|
catch (AbpException ex) |
|
|
|
{ |
|
|
|
_logger.LogError(ex.Message); |
|
|
|
} |
|
|
|
catch (JsonException ex) |
|
|
|
{ |
|
|
|
_logger.LogError(ex.Message); |
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
_logger.LogError(ex.Message); |
|
|
|
_logger.LogInformation(ex.Message); |
|
|
|
} |
|
|
|
// 返回空列表
|
|
|
|
return new List<IncomingFromExternal>(); |
|
|
@ -173,6 +170,7 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
request.ItemDesc1 = itm.Desc1; |
|
|
|
request.ItemDesc2 = itm.Desc2; |
|
|
|
request.ItemName = itm.Name; |
|
|
|
request.Uom = itm.BasicUom; |
|
|
|
} |
|
|
|
// 获取对应库位信息
|
|
|
|
var loc = await _locService.GetByCodeAsync(request.ToLocationCode).ConfigureAwait(false); |
|
|
@ -184,6 +182,7 @@ public class InjectionMoldingRequestReader : IReader |
|
|
|
request.ToLocationGroup = loc.LocationGroupCode; |
|
|
|
request.ToLocationErpCode = loc.ErpLocationCode; |
|
|
|
request.ToWarehouseCode = loc.WarehouseCode; |
|
|
|
request.ToLocationArea = loc.AreaCode; |
|
|
|
} |
|
|
|
} |
|
|
|
// 返回错误列表
|
|
|
|