| | |
| | | //if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.FactoryNotExistsException", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}")); |
| | | if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"岗位[{postCode}]所属的工厂[{CurWorkshop.FTY_CODE}]不存在,请先设置所属工厂", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}")); |
| | | |
| | | //加载当前产线的班制 |
| | | CurShiftSys = Biz.Db.Queryable<MES_SHIFT_SYS>().Where(q => q.SFTS_CODE == CurLine.SFTS_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Shifts).First(); |
| | | |
| | | return this; |
| | | } |
| | | |
| | |
| | | public MES_WORKSHOP CurWorkshop { get; set; } |
| | | public MES_LINE CurLine { get; set; } |
| | | public MES_POSITION CurPosition { get; set; } |
| | | public MES_SHIFT_SYS CurShiftSys { get; set; } |
| | | public WorkBatch CurBatch { get; set; } |
| | | public IWorkBatch WorkBatch => CurBatch; |
| | | public MES_WIP_DATA CurWipSN { get; set; } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前时间所属的班制班次时段 |
| | | /// </summary> |
| | | public ShiftPeriod GetShiftPeriodForNow() |
| | | { |
| | | var time = DateTime.Now.ToString("HHmm").ToInt32(); |
| | | foreach (var shift in CurShiftSys.Shifts) |
| | | { |
| | | var period = shift.Periods.Where(q => q.PRD_BEGIN <= time && time <= q.PRD_END).FirstOrDefault(); |
| | | if (!period.IsNullOrEmpty()) |
| | | { |
| | | var result = new ShiftPeriod(); |
| | | result.ShiftSys = CurShiftSys; |
| | | result.Shift = shift; |
| | | result.Period = period; |
| | | return result; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重置当前工步 |
| | | /// </summary> |
| | | public void ResetSteps() |
| | |
| | | /// <summary> |
| | | /// 添加节点的下一个行为到工步列表 |
| | | /// </summary> |
| | | /// <param name="curNode"></param> |
| | | /// <param name="parent"></param> |
| | | private void AddNextActToSteps(WorkStep parent) |
| | | { |
| | | var edges = CurBatch.Edges.Where(q => q.SRC_NODE == parent.NodeID && CurBatch.NodeActs.Any(a => a.NODE_ID == parent.Node.ID && a.ID == q.TGT_NODE)).ToList(); |
| | |
| | | { |
| | | var next = Steps.First(q => q.NodeID == act.ID); |
| | | next.Sequence = next.Sequence > parent.Sequence ? next.Sequence : (parent.Sequence + 1); |
| | | next.PrepNodeIDs.Add(parent.NodeID); |
| | | next.PrepNodeIDs.AddRange(parent.PrepNodeIDs); |
| | | next.PrepNodeIDs = next.PrepNodeIDs.Distinct().ToList(); |
| | | AddNextActToSteps(next); |
| | |
| | | NodeAct = act, |
| | | Setting = CurBatch.ActionSets.FirstOrDefault(q => q.ACT_ID == act.ID), |
| | | }; |
| | | next.PrepNodeIDs.Add(parent.NodeID); |
| | | next.PrepNodeIDs.AddRange(parent.PrepNodeIDs); |
| | | next.PrepNodeIDs = next.PrepNodeIDs.Distinct().ToList(); |
| | | Steps.Add(next); |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | #endregion Functions |
| | | |
| | | public override bool Close(bool needSaveHistoryLog = false) |