| | |
| | | using Microsoft.AspNetCore.Http; |
| | | using Rhea.Common; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | { |
| | | #region 工单管理 |
| | | /// <summary> |
| | | /// 工单批次字典 |
| | | /// |
| | | /// </summary> |
| | | public static Dictionary<string, WorkBatch> WoBatchDic { get; set; } = new Dictionary<string, WorkBatch>(); |
| | | |
| | | /// <summary> |
| | | /// 从工单批次字典中获取一个工单批次对象 |
| | | /// </summary> |
| | | /// <param name="workOrder"></param> |
| | | /// <param name="batchNo"></param> |
| | | /// <param name="lineCode"></param> |
| | | /// <returns></returns> |
| | | public static WorkBatch GetBatch(string workOrder, string lineCode) |
| | | public static WorkBatch GetBatch(string batchNo, string lineCode = null) |
| | | { |
| | | return WoBatchDic.FirstOrDefault(q => q.Value.Batch.ORDER_NO == workOrder && q.Value.Batch.ACT_LINE == lineCode).Value; |
| | | return WoBatchDic.FirstOrDefault(q => q.Value.Batch.BATCH_NO == batchNo && (lineCode.IsNullOrEmpty() || q.Value.Batch.ACT_LINE == lineCode)).Value; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断工单批次是否存在于工单批次字典中 |
| | | /// </summary> |
| | | /// <param name="workOrder"></param> |
| | | /// <param name="batchNo"></param> |
| | | /// <param name="lineCode"></param> |
| | | /// <returns></returns> |
| | | public static bool ExistsBatch(string workOrder, string lineCode) |
| | | public static bool ExistsBatch(string batchNo, string lineCode = null) |
| | | { |
| | | return WoBatchDic.Any(q => q.Value.Batch.ORDER_NO == workOrder && q.Value.Batch.ACT_LINE == lineCode); |
| | | return WoBatchDic.Any(q => q.Value.Batch.BATCH_NO == batchNo && (lineCode.IsNullOrEmpty() || q.Value.Batch.ACT_LINE == lineCode)); |
| | | } |
| | | |
| | | /// 从工单批次字典中删除一个工单批次对象 |
| | | /// </summary> |
| | | /// <param name="batchNo"></param> |
| | | /// <param name="lineCode"></param> |
| | | /// <returns></returns> |
| | | public static bool RemoveWo(string workorder) |
| | | { |
| | | try |
| | | { |
| | | var list = WoBatchDic.Keys.ToList().Where(q => q.Contains(workorder)); |
| | | foreach (var batch in list) |
| | | { |
| | | WoBatchDic.Remove(batch); |
| | | } |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Logger.Default.Fatal(ex, $"从工单批次字典中删除一个工单[{workorder}]对象异常"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// 从工单批次字典中删除一个工单批次对象 |
| | | /// </summary> |
| | | /// <param name="batchNo"></param> |
| | | /// <param name="lineCode"></param> |
| | | /// <returns></returns> |
| | | public static bool RemoveBatch(string batchNo) |
| | | { |
| | | try |
| | | { |
| | | if (WoBatchDic.ContainsKey(batchNo)) |
| | | { |
| | | WoBatchDic.Remove(batchNo); |
| | | } |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Logger.Default.Fatal(ex, $"从工单批次字典中删除一个工单批次[{batchNo}]对象异常"); |
| | | return false; |
| | | } |
| | | } |
| | | #endregion |
| | | } |