| | |
| | | /// <param name="workorder"></param> |
| | | /// <param name="lineCode"></param> |
| | | /// <returns></returns> |
| | | public static WorkBatch GetBatch(string workorder, string lineCode) |
| | | public static WorkBatch GetBatch(string workorder, string lineCode, string batchNo = "") |
| | | { |
| | | if (ExistsBatch(workorder, lineCode)) |
| | | if (ExistsBatch(workorder, lineCode, batchNo)) |
| | | { |
| | | return WoBatchDic.FirstOrDefault(q => q.Value.Batch.ORDER_NO == workorder && q.Value.Batch.ACT_LINE == lineCode).Value; |
| | | return WoBatchDic.FirstOrDefault(q => q.Value.Batch.ORDER_NO == workorder && q.Value.Batch.ACT_LINE == lineCode && (batchNo.IsNullOrEmpty() || q.Value.Batch.BATCH_NO == batchNo)).Value; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | /// <param name="workorder"></param> |
| | | /// <param name="lineCode"></param> |
| | | /// <returns></returns> |
| | | public static bool ExistsBatch(string workorder, string lineCode) |
| | | public static bool ExistsBatch(string workorder, string lineCode, string batchNo = "") |
| | | { |
| | | return WoBatchDic.Any(q => q.Value.Batch.ORDER_NO == workorder && q.Value.Batch.ACT_LINE == lineCode); |
| | | return WoBatchDic.Any(q => q.Value.Batch.ORDER_NO == workorder && q.Value.Batch.ACT_LINE == lineCode && (batchNo.IsNullOrEmpty() || q.Value.Batch.BATCH_NO == batchNo)); |
| | | } |
| | | |
| | | /// 从工单批次字典中删除一个工单批次对象 |
| | |
| | | if (CurBatch?.Batch?.ORDER_NO != wosns.First().Batch.ORDER_NO) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO }); |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO }, wosns.First().Batch.BATCH_NO); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.Data.ShortMsg = new("工单异常", ShortMessage.Types.Error); |
| | |
| | | if (CurBatch?.Batch?.ORDER_NO != wosns.First().Batch.ORDER_NO) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO }); |
| | | if (!result.IsSuccessed) |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO }, wosns.First().Batch.BATCH_NO); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.Data.ShortMsg = new("工单异常", ShortMessage.Types.Error); |
| | | action.Data.OperInfo = new(); |
| | |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> SelectOrder(WoInput input) |
| | | public async Task<ApiAction> SelectOrder(WoInput input, string batchNo = "") |
| | | { |
| | | var action = new ApiAction(); |
| | | try |
| | | { |
| | | if (!WoContext.ExistsBatch(input.OrderNo, CurLine.LINE_CODE)) |
| | | if (!WoContext.ExistsBatch(input.OrderNo, CurLine.LINE_CODE, batchNo)) |
| | | { |
| | | var wo = await Biz.Db.Queryable<BIZ_MES_WO>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo).FirstAsync(); |
| | | //验证明细是否正确 |
| | |
| | | action.LocaleMsg = new("MES.Transaction.Position.SelectOrder.StatusException", input.OrderNo, wo.STATUS.GetEnum<BIZ_MES_WO.STATUSs>().GetName()); |
| | | return action; |
| | | } |
| | | var batch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption).Where(q => q.ORDER_NO == input.OrderNo && q.ACT_LINE == CurLine.LINE_CODE).OrderBy(q => q.STATUS).FirstAsync(); |
| | | var batch = await Biz.Db.Queryable<BIZ_MES_WO_BATCH>().ByAuth(input.AuthOption) |
| | | .Where(q => q.ORDER_NO == input.OrderNo && q.ACT_LINE == CurLine.LINE_CODE) |
| | | .WhereIF(!batchNo.IsNullOrEmpty(), q => q.BATCH_NO == batchNo) |
| | | .OrderBy(q => q.STATUS).FirstAsync(); |
| | | if (batch.IsNullOrEmpty()) |
| | | { |
| | | action.IsSuccessed = false; |
| | |
| | | var wb = new WorkBatch(input.OrderNo).Init(CurLine.LINE_CODE); |
| | | WoContext.WoBatchDic.Add(wb.Batch.BATCH_NO, wb); |
| | | } |
| | | CurBatch = WoContext.GetBatch(input.OrderNo, CurLine.LINE_CODE); |
| | | CurBatch = WoContext.GetBatch(input.OrderNo, CurLine.LINE_CODE, batchNo); |
| | | if (!OperInfoDic.ContainsKey(CurBatch.Batch.BATCH_NO)) |
| | | { |
| | | OperInfoDic.Add(CurBatch.Batch.BATCH_NO, new()); |
| | |
| | | if (CurBatch?.Batch?.ORDER_NO != wosns.First().Batch.ORDER_NO) |
| | | { |
| | | //条码已绑定的工单不等于当前工单则重新选择工单 |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO }); |
| | | var result = await SelectOrder(new() { AuthOption = input.AuthOption, OrderNo = wosns.First().Batch.ORDER_NO }, wosns.First().Batch.BATCH_NO); |
| | | if (!result.IsSuccessed) |
| | | { |
| | | action.Data.ShortMsg = new("工单异常", ShortMessage.Types.Error); |
| | |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public Task<ApiAction> SelectOrder(WoInput input); |
| | | public Task<ApiAction> SelectOrder(WoInput input, string batchNo = ""); |
| | | /// <summary> |
| | | /// 采集工序:提交操作数据 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public Task<ApiAction> SelectOrder(WoInput input); |
| | | public Task<ApiAction> SelectOrder(WoInput input, string batchNo = ""); |
| | | /// <summary> |
| | | /// 包装工序:提交操作数据 |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | public Task<ApiAction> SelectOrder(WoInput input); |
| | | public Task<ApiAction> SelectOrder(WoInput input, string batchNo = ""); |
| | | /// <summary> |
| | | /// 测试工序:提交操作数据 |
| | | /// </summary> |