| | |
| | | ItemInfo = info, |
| | | RuleCode = assy.RULE_CODE, |
| | | LoadQty = assy.QTY, |
| | | IsBatchItem = assy.IsBatchItem, |
| | | }; |
| | | var bom = Boms.FirstOrDefault(q => q.ITEM_CODE == assy.ITEM_CODE); |
| | | if (!bom.IsNullOrEmpty()) |
| | |
| | | { |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | if (input.SN != CurPosition.CurWipSN.SN) |
| | | if (!CurPosition.CurWipSNs.Any(w => w.SN == input.SN)) |
| | | { |
| | | action = SaveAssembly(input, action); |
| | | return action; |
| | |
| | | |
| | | //如果返回成功则认为当前行为可以开始执行,否则返回失败 |
| | | action.IsSuccessed = false; |
| | | action.Data.ShortMsg = new("等待上料", ShortMessage.Types.Normal); |
| | | return action; |
| | | } |
| | | |
| | |
| | | //验证通过则保存上料信息 |
| | | if (isOK) |
| | | { |
| | | var record = new MES_WIP_ASSY() |
| | | //批次物料则只记录一次,非批次物料则要按个数验证数量 |
| | | if (item.IsBatchItem) |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | SN = input.SN, |
| | | PROD_SN = CurPosition.CurWipSN.SN, |
| | | ITEM_CODE = item.ItemInfo.ITEM_CODE, |
| | | QTY = 1, |
| | | UNIT = item.ItemInfo.UNIT, |
| | | WORK_ORDER = CurPosition.CurWipSN.WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSN.BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSN.ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSN.NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSN.NODE_NAME, |
| | | FTY_CODE = CurPosition.CurWipSN.FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSN.WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSN.LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSN.POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSN.OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSN.SEGMENT, |
| | | }; |
| | | item.Records.Add(record); |
| | | if (item.Records.Sum(q => q.QTY) >= item.LoadQty) |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | var record = new MES_WIP_ASSY() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | WIP_ID = wipSn.ID, |
| | | SN = input.SN, |
| | | PROD_SN = wipSn.SN, |
| | | ITEM_CODE = item.ItemInfo.ITEM_CODE, |
| | | QTY = 1, |
| | | UNIT = item.ItemInfo.UNIT, |
| | | WORK_ORDER = wipSn.WORK_ORDER, |
| | | BATCH_NO = wipSn.BATCH_NO, |
| | | ROT_CODE = wipSn.ROT_CODE, |
| | | NODE_ID = wipSn.NODE_ID, |
| | | NODE_NAME = wipSn.NODE_NAME, |
| | | FTY_CODE = wipSn.FTY_CODE, |
| | | WS_CODE = wipSn.WS_CODE, |
| | | LINE_CODE = wipSn.LINE_CODE, |
| | | POST_CODE = wipSn.POST_CODE, |
| | | OPER_CODE = wipSn.OPER_CODE, |
| | | SEGMENT = wipSn.SEGMENT, |
| | | }; |
| | | item.Records.Add(record); |
| | | } |
| | | item.IsFinished = true; |
| | | } |
| | | else |
| | | { |
| | | item.IsFinished = true; |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | var record = new MES_WIP_ASSY() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | WIP_ID = wipSn.ID, |
| | | SN = input.SN, |
| | | PROD_SN = wipSn.SN, |
| | | ITEM_CODE = item.ItemInfo.ITEM_CODE, |
| | | QTY = 1, |
| | | UNIT = item.ItemInfo.UNIT, |
| | | WORK_ORDER = wipSn.WORK_ORDER, |
| | | BATCH_NO = wipSn.BATCH_NO, |
| | | ROT_CODE = wipSn.ROT_CODE, |
| | | NODE_ID = wipSn.NODE_ID, |
| | | NODE_NAME = wipSn.NODE_NAME, |
| | | FTY_CODE = wipSn.FTY_CODE, |
| | | WS_CODE = wipSn.WS_CODE, |
| | | LINE_CODE = wipSn.LINE_CODE, |
| | | POST_CODE = wipSn.POST_CODE, |
| | | OPER_CODE = wipSn.OPER_CODE, |
| | | SEGMENT = wipSn.SEGMENT, |
| | | }; |
| | | item.Records.Add(record); |
| | | } |
| | | |
| | | if (item.Records.Sum(q => q.QTY) / item.Records.Count >= item.LoadQty * CurPosition.CurWipSNs.Count) |
| | | { |
| | | item.IsFinished = true; |
| | | } |
| | | } |
| | | |
| | | action.IsSuccessed = true; |
| | | action.Data.Data = CurAssembly; |
| | | action.Data.ShortMsg = new("上料成功", ShortMessage.Types.Success); |
| | | action.Data.Data = CurAssembly; |
| | | //action.LocaleMsg = new Locale($"扫描物料[{item.ItemInfo.ITEM_NAME}({item.ItemInfo.ITEM_CODE})的条码[{input.SN}]成功,请继续上料"); |
| | | action.LocaleMsg = new Locale("MES.WorkAction.Assembly.LoadSuccess", item.ItemInfo.ITEM_NAME, item.ItemInfo.ITEM_CODE); |
| | | |
| | |
| | | } |
| | | //都没有物料验证通过,则返回错误信息 |
| | | action.IsSuccessed = false; |
| | | action.Data.ShortMsg = new("上料失败", ShortMessage.Types.Failed); |
| | | //action.LocaleMsg = new($"条码[{input.SN}]验证失败,不是以下物料的条码:{string.Join(",", CurAssembly.Items.Where(q => !q.IsFinished).Select(q => $"{q.ItemInfo.ITEM_NAME}({q.ItemInfo.ITEM_CODE})"))}"); |
| | | action.LocaleMsg = new("MES.WorkAction.Assembly.LoadFail", input.SN, string.Join(",", CurAssembly.Items.Where(q => !q.IsFinished).Select(q => $"{q.ItemInfo.ITEM_NAME}({q.ItemInfo.ITEM_CODE})"))); |
| | | } |
| | | catch (System.Exception ex) |
| | | { |
| | | action.Data.ShortMsg = new("上料异常", ShortMessage.Types.Exception); |
| | | action.CatchExceptionWithLog(ex, $"上料行为:验证条码[{input.SN}]并保存数据异常"); |
| | | action.IsSuccessed = false; |
| | | //action.LocaleMsg = new($"验证条码[{input.SN}]并保存数据异常,工序已重置,请重新扫描进站产品条码"); |
| | |
| | | var action = new ApiAction<SubmitOutput>(new SubmitOutput()); |
| | | |
| | | //记录行为操作记录 |
| | | var wipAct = new MES_WIP_ACT() |
| | | var wipActs = new List<MES_WIP_ACT>(); |
| | | foreach (var wipSn in CurPosition.CurWipSNs) |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | HIS_ID = CurPosition.CurWipSNHis.ID, |
| | | SN = CurPosition.CurWipSN.SN, |
| | | STATUS = CurPosition.CurWipSN.STATUS, |
| | | ITEM_CODE = CurPosition.CurWipSN.ITEM_CODE, |
| | | WORK_ORDER = CurPosition.CurWipSN.WORK_ORDER, |
| | | BATCH_NO = CurPosition.CurWipSN.BATCH_NO, |
| | | ROT_CODE = CurPosition.CurWipSN.ROT_CODE, |
| | | NODE_ID = CurPosition.CurWipSN.NODE_ID, |
| | | NODE_NAME = CurPosition.CurWipSN.NODE_NAME, |
| | | ACT_ID = NodeAct.ID, |
| | | ACT_NAME = NodeAct.ACT_NAME, |
| | | FTY_CODE = CurPosition.CurWipSN.FTY_CODE, |
| | | WS_CODE = CurPosition.CurWipSN.WS_CODE, |
| | | LINE_CODE = CurPosition.CurWipSN.LINE_CODE, |
| | | POST_CODE = CurPosition.CurWipSN.POST_CODE, |
| | | OPER_CODE = CurPosition.CurWipSN.OPER_CODE, |
| | | SEGMENT = CurPosition.CurWipSN.SEGMENT, |
| | | TRAY_SN = CurPosition.CurWipSN.TRAY_SN, |
| | | OPERATION_TIME = DateTime.Now, |
| | | SFTS_CODE = CurPosition.CurWipSN.SFTS_CODE, |
| | | SFT_CODE = CurPosition.CurWipSN.SFT_CODE, |
| | | PRD_CODE = CurPosition.CurWipSN.PRD_CODE, |
| | | ACT_TYPE = NodeAct.ACT_TYPE, |
| | | ACT_SN = CurPosition.CurWipSN.SN, |
| | | ACT_VALUE_1 = CurAssembly.ToJson(), |
| | | ACT_RESULT = "Y", |
| | | TRACE_INFO = $"以下物料上料完成:{string.Join(",", CurAssembly.Items.Select(q => $"{q.ItemInfo.ITEM_NAME}({q.ItemInfo.ITEM_CODE})"))}", |
| | | }; |
| | | var records = new List<MES_WIP_ASSY>(); |
| | | foreach (var item in CurAssembly.Items) |
| | | { |
| | | records.AddRange(item.Records); |
| | | var wipAct = new MES_WIP_ACT() |
| | | { |
| | | AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, |
| | | AUTH_PROD = CurPosition.CurLine.LINE_CODE, |
| | | WIP_ID = wipSn.ID, |
| | | HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, |
| | | SN = wipSn.SN, |
| | | STATUS = wipSn.STATUS, |
| | | ITEM_CODE = wipSn.ITEM_CODE, |
| | | WORK_ORDER = wipSn.WORK_ORDER, |
| | | BATCH_NO = wipSn.BATCH_NO, |
| | | ROT_CODE = wipSn.ROT_CODE, |
| | | NODE_ID = wipSn.NODE_ID, |
| | | NODE_NAME = wipSn.NODE_NAME, |
| | | ACT_ID = NodeAct.ID, |
| | | ACT_NAME = NodeAct.ACT_NAME, |
| | | FTY_CODE = wipSn.FTY_CODE, |
| | | WS_CODE = wipSn.WS_CODE, |
| | | LINE_CODE = wipSn.LINE_CODE, |
| | | POST_CODE = wipSn.POST_CODE, |
| | | OPER_CODE = wipSn.OPER_CODE, |
| | | SEGMENT = wipSn.SEGMENT, |
| | | FLOW_SN = wipSn.FLOW_SN, |
| | | TRAY_SN = wipSn.TRAY_SN, |
| | | INNER_SN = wipSn.INNER_SN, |
| | | CARTON_SN = wipSn.CARTON_SN, |
| | | PALLET_SN = wipSn.PALLET_SN, |
| | | OPERATION_TIME = DateTime.Now, |
| | | SFTS_CODE = wipSn.SFTS_CODE, |
| | | SFT_CODE = wipSn.SFT_CODE, |
| | | PRD_CODE = wipSn.PRD_CODE, |
| | | ACT_TYPE = NodeAct.ACT_TYPE, |
| | | ACT_SN = wipSn.SN, |
| | | ACT_VALUE_1 = CurAssembly.ToJson(), |
| | | ACT_RESULT = "Y", |
| | | TRACE_INFO = $"以下物料上料完成:{string.Join(",", CurAssembly.Items.Select(q => $"{q.ItemInfo.ITEM_NAME}({q.ItemInfo.ITEM_CODE})"))}", |
| | | }; |
| | | wipActs.Add(wipAct); |
| | | } |
| | | |
| | | |
| | | //创建变量克隆对象用于传入DBSubmitAction中保存当前需要暂存的数据值 |
| | | var _wipActs = wipActs.Clone(); |
| | | //整理上料记录 |
| | | var _records = new List<MES_WIP_ASSY>(); |
| | | foreach (var item in CurAssembly.Items) |
| | | { |
| | | _records.AddRange(item.Records.Clone()); |
| | | } |
| | | //保存数据 |
| | | CurStep.DBSubmitAction = () => |
| | | { |
| | | var db = CurPosition.GetCommitDB(); |
| | | db.Storageable(wipAct, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Insertable(records, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); |
| | | db.Insertable(_records, CurPosition.UserCode).ExecuteCommand(); |
| | | }; |
| | | |
| | | IsFinished = true; |
| | | action.Data.ShortMsg = new("上料完成", ShortMessage.Types.Success); |
| | | //action.LocaleMsg = new($"以下物料上料完成:{string.Join(",", CurAssembly.Items.Select(q => $"{q.ItemInfo.ITEM_NAME}({q.ItemInfo.ITEM_CODE})"))}"); |
| | | action.LocaleMsg = new("MES.WorkAction.Assembly.LoadFinish", string.Join(",", CurAssembly.Items.Select(q => $"{q.ItemInfo.ITEM_NAME}({q.ItemInfo.ITEM_CODE})"))); |
| | | return action; |