Ejemplo n.º 1
0
        public EKanbanResponse(IDbName _database, int _ekanbanDeviceId)
        {
            EKanbanTaskQuery eKanbanTaskQuery = new EKanbanTaskQuery(_database);
            SequenceQuery    sequenceQuery    = new SequenceQuery(_database);
            ComponentQuery   componentQuery   = new ComponentQuery(_database);

            var ekanbanDevice = eKanbanTaskQuery.GetEKanbanDevice(_ekanbanDeviceId);

            var _Interface = eKanbanTaskQuery.GetLastEKanbanInterface(_ekanbanDeviceId);

            SizeList = new List <SizeInfo>();
            PartList = new List <PartInfo>();
            List <OriginalSize> originalSizes = new List <OriginalSize>();

            foreach (var item in _Interface.EKanbanLoadings)
            {
                var Seq = sequenceQuery.GetOriginalSequence(ShareFuncs.GetInt(item.OriginalSequence_Id));
                TotalCartQty += ShareFuncs.GetInt(Seq.Quantity);
                foreach (var size in Seq.OriginalSizes)
                {
                    originalSizes.Add(size);
                }
            }

            foreach (var item in originalSizes)
            {
                var foundSizes = SizeList.Where(i => i.SizeId == item.SizeId);
                if (foundSizes.Count() > 0)
                {
                    foundSizes.First().SizeQty += ShareFuncs.GetInt(item.Quantity);
                }
                else
                {
                    SizeList.Add(new SizeInfo(ShareFuncs.GetInt(item.SizeId), ShareFuncs.GetInt(item.Quantity)));
                }
            }

            Interface = new InterfaceInfo(_Interface);

            foreach (var item in _Interface.EkanbanComponents)
            {
                var Component = componentQuery.GetShoeComponent(ShareFuncs.GetInt(item.ShoeComponent_Id));
                PartList.Add(new PartInfo(ShareFuncs.ConvertToUnSign(Component.Reference)));
            }

            //if (DateTime.Now.Hour == 17)
            //{
            //    if (DateTime.Now.Minute > 50)
            //    {
            //        ScreenOff = true;
            //        ekanbanDevice.ScreenOff = true;
            //    }
            //}
            //else
            //{
            //    if (DateTime.Now.Hour > 17)
            //    {
            //        ScreenOff = true;
            //        ekanbanDevice.ScreenOff = true;
            //    }
            //}

            //if (DateTime.Now.Hour == 6 && DateTime.Now.Minute < 45)
            //{
            //    ScreenOff = false;
            //    ekanbanDevice.ScreenOff = false;
            //}

            ekanbanDevice.NetworkStatus = (int)SYS_MODELS._ENUM.SysActionCode.ONLINE;
            ekanbanDevice.LastOnline    = DateTime.Now;
            eKanbanTaskQuery.UpdateEKanbanDevice(ekanbanDevice);

            if (ekanbanDevice.ScreenOff == null)
            {
                ScreenOff = false;
            }
            else
            {
                ScreenOff = (bool)ekanbanDevice.ScreenOff;
            }
        }
Ejemplo n.º 2
0
        public BLastCut(IDbName database, int bdeviceId, int bInterfaceId)
        {
            BeamCutQuery   = new BeamCutQuery(database);
            StockQuery     = new StockQuery(database);
            EmployeeQuery  = new EmployeeQuery(database);
            SequenceQuery  = new SequenceQuery(database);
            ScheduleQuery  = new ScheduleQuery(database);
            ComponentQuery = new ComponentQuery(database);

            try
            {
                var bInterface = BeamCutQuery.GetLastInterface(bdeviceId);

                if (bInterface == null)
                {
                    Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);

                    bInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId);
                    if (bInterface == null)
                    {
                        Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
                        return;
                    }
                }

                var bpo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(bInterface.BeamCutPo_Id));

                if (bpo == null)
                {
                    Exception = new RespException(true, "Can not find clone Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
                    return;
                }

                var originalPo = SequenceQuery.GetOriginalPo(ShareFuncs.GetInt(bInterface.OriginalPo_Id));

                if (originalPo == null)
                {
                    Exception = new RespException(true, "Can not find Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
                    return;
                }

                BinterfaceId = bInterface.id;
                PoNumber     = originalPo.PoNumber;
                StartSeq     = ShareFuncs.GetInt(bInterface.StartSeqNo);
                StopSeq      = ShareFuncs.GetInt(bInterface.StopSeqNo);

                if (bInterface.StartCutTime != null)
                {
                    StartTime = ((DateTime)bInterface.StartCutTime).ToString("hh:mm tt, dd/MM/yyyy");
                }

                if (bInterface.StopCutTime != null)
                {
                    StopTime = ((DateTime)bInterface.StopCutTime).ToString("hh:mm tt, dd/MM/yyyy");
                }

                CutQty             = ShareFuncs.GetInt(bInterface.CuttingQty);
                CutTime            = ShareFuncs.GetInt(bInterface.BeamCutCounter);
                Employee_Id        = ShareFuncs.GetInt(bInterface.Employee_Id);
                Schedule_Id        = ShareFuncs.GetInt(bInterface.Schedule_Id);
                BeamCutPo_Id       = ShareFuncs.GetInt(bInterface.BeamCutPo_Id);
                BeamCutStartSeq_Id = ShareFuncs.GetInt(bInterface.BeamCutStartSeq_Id);
                Component_Id       = ShareFuncs.GetInt(bpo.Component_Id);
                BeamCutStopSeq_Id  = ShareFuncs.GetInt(bInterface.BeamCutStopSeq_Id);
                Finish             = bInterface.Finish != null ? (bool)bInterface.Finish : false;
                PoQty         = ShareFuncs.GetInt(originalPo.Quantity);
                OriginalPo_Id = ShareFuncs.GetInt(bInterface.OriginalPo_Id);

                var component = ComponentQuery.GetShoeComponent(ShareFuncs.GetInt(bpo.Component_Id));
                if (component != null)
                {
                    string comp = ShareFuncs.ConvertToUnSign(component.Reference);
                    Component = comp;
                }
                Exception = new RespException(false, "Get last cut: OK", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_LAST_CUT);
            }
        }
Ejemplo n.º 3
0
        public RespPoInfo(IDbName _database, int scheduleId, int originalPoId, int componentId)
        {
            try
            {
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(_database);
                SequenceQuery  sequenceQuery  = new SequenceQuery(_database);
                BeamCutQuery   beamCutQuery   = new BeamCutQuery(_database);
                SequenceQuery  SequenceQuery  = new SequenceQuery(_database);
                ComponentQuery componentQuery = new ComponentQuery(_database);

                var schedule = scheduleQuery.GetSchedule(scheduleId);

                var originalPo = SequenceQuery.GetOriginalPo(originalPoId);

                var shoeComponent = componentQuery.GetShoeComponent(componentId);

                if (schedule == null)
                {
                    if (originalPo == null)
                    {
                        Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }

                    schedule = scheduleQuery.GetSchedule(originalPo);

                    if (schedule == null)
                    {
                        Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }
                }

                if (shoeComponent == null)
                {
                    Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                    return;
                }

                PoInfo = new PoInfo(_database, schedule);

                if (originalPo == null)
                {
                    Exception = new RespException(true, "Empty sequence file", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                    return;
                }

                var clonePo = beamCutQuery.FindClonePo(originalPo.id, componentId);

                if (clonePo != null)
                {
                    ClonePoId = clonePo.id;

                    SeqList = new List <SeqInfo>();
                    foreach (var item in clonePo.BeamCutSeqs)
                    {
                        SeqList.Add(new SeqInfo
                        {
                            id         = item.id,
                            CuttingQty = ShareFuncs.GetInt(item.CutQty),
                            SeqNo      = ShareFuncs.GetInt(item.SequenceNo),
                            SeqQty     = ShareFuncs.GetInt(item.SequenceQty),
                            Finish     = item.Finish == true ? true : false,
                        });
                    }
                }
                else
                {
                    var bClonePo = beamCutQuery.CloneOriginalPo(originalPo, shoeComponent);

                    if (bClonePo == null)
                    {
                        Exception = new RespException(true, "An error occured while requesting po information", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }

                    ClonePoId = bClonePo.id;

                    SeqList = new List <SeqInfo>();
                    foreach (var item in bClonePo.BeamCutSeqs)
                    {
                        SeqList.Add(new SeqInfo
                        {
                            id         = item.id,
                            CuttingQty = ShareFuncs.GetInt(item.CutQty),
                            SeqNo      = ShareFuncs.GetInt(item.SequenceNo),
                            SeqQty     = ShareFuncs.GetInt(item.SequenceQty),
                            Finish     = item.Finish == true ? true : false,
                        });
                    }
                }

                Exception = new RespException(false, "Get Poinfo: OK", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
            }
        }
Ejemplo n.º 4
0
        public OrderResult(BeamCutPo beamCutPo)
        {
            try
            {
                InitializeComponent();
                BeamCutPo = new BeamCutPo();
                BeamCutPo = beamCutPo;
                BeamCutQuery   beamCutQuery   = new BeamCutQuery(_SERVER.ServerName.Database);
                ComponentQuery componentQuery = new ComponentQuery(_SERVER.ServerName.Database);
                SequenceQuery  sequenceQuery  = new SequenceQuery(_SERVER.ServerName.Database);
                var            originalPo     = sequenceQuery.GetOriginalPo(beamCutPo.OriginalPo_Id);
                var            component      = componentQuery.GetShoeComponent(BeamCutPo.Component_Id);
                label2.Text = component != null ? component.Reference : "";
                var Binterface = beamCutQuery.GetBeamInterface(beamCutPo.id);

                int totalCutQty  = 0;
                int totalCutTime = 0;

                bool first = false;
                bool last  = false;

                double   totalTime = 0;
                DateTime?start = null, stop = null, last_update = null;

                foreach (var item in Binterface)
                {
                    if (!first)
                    {
                        if (item.StartCutTime != null)
                        {
                            start       = (DateTime)item.StartCutTime;
                            label9.Text = start != null?start.ToString() : "";
                        }
                        first = true;
                    }

                    totalCutTime += ShareFuncs.GetInt(item.BeamCutCounter);
                    totalCutQty  += ShareFuncs.GetInt(item.CuttingQty);
                    if (item.StopCutTime != null)
                    {
                        label7.Text = item.StopCutTime.ToString();
                    }

                    try
                    {
                        if (item.StopCutTime != null)
                        {
                            stop = (DateTime)item.StopCutTime;
                        }
                        else
                        {
                            stop = (DateTime)item.LastConfirmSize;
                        }
                        label11.Text = stop != null ? ((DateTime)stop).ToString() : "";

                        totalTime    = ((DateTime)stop - (DateTime)start).TotalSeconds;
                        label13.Text = $"{((int)totalTime / 60)}min {(int)totalTime % 60}sec";

                        label15.Text = $"{(int)(totalCutQty * 60 / totalTime)} c/min";
                    }
                    catch { }
                }

                label3.Text = totalCutQty.ToString();
                label5.Text = totalCutTime.ToString();
                TotalCutQty = totalCutQty;
            }
            catch { }
        }
Ejemplo n.º 5
0
        // start cutting construction
        public RespCutting(IDbName database, int deviceId, int workerId, int clonePoId, int seq1Id, int seq2Id, int binterfaceId)
        {
            BeamCutQuery   = new BeamCutQuery(database);
            StockQuery     = new StockQuery(database);
            EmployeeQuery  = new EmployeeQuery(database);
            SequenceQuery  = new SequenceQuery(database);
            ScheduleQuery  = new ScheduleQuery(database);
            ComponentQuery = new ComponentQuery(database);
            try
            {
                var worker = EmployeeQuery.GetEmployee(workerId);
                if (worker == null)
                {
                    Exception = new RespException(true, "Invalid worker Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                var bdevice = BeamCutQuery.GetBeamCutDevice(deviceId);
                if (bdevice == null)
                {
                    Exception = new RespException(true, "Invalid device Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                var clonePo = BeamCutQuery.GetBeamCutPo(clonePoId);
                if (clonePo == null)
                {
                    Exception = new RespException(true, "Invalid clone Po Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                var originalPo = SequenceQuery.GetOriginalPo(clonePo.OriginalPo_Id);

                if (originalPo == null)
                {
                    Exception = new RespException(true, "Can not find original po", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                var component = ComponentQuery.GetShoeComponent(clonePo.Component_Id);

                if (component == null)
                {
                    Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                var schedule = ScheduleQuery.GetSchedule(originalPo);

                if (schedule == null)
                {
                    Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                var order = BeamCutQuery.GetBDeviceOrder(originalPo, deviceId);

                var startSeq = BeamCutQuery.GetBeamCutSeq(seq1Id);

                var stopSeq = BeamCutQuery.GetBeamCutSeq(seq2Id);

                if (startSeq == null || stopSeq == null)
                {
                    Exception = new RespException(true, "Invalid clone Seq Id", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                    return;
                }

                int[] qty = BeamCutQuery.GetTotalSelectSequenceQty(startSeq, stopSeq);

                if (qty == null)
                {
                    qty = new int[] { 0, 0 }
                }
                ;

                int bId = binterfaceId;
                BeamCutInterface binterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId);

                int scheduleId = 0;
                if (schedule != null)
                {
                    scheduleId = schedule.id;
                }

                if (binterface == null)
                {
                    binterface = new BeamCutInterface
                    {
                        Employee_Id        = workerId,
                        BeamCutDevice_Id   = deviceId,
                        BeamCutPo_Id       = clonePoId,
                        OriginalPo_Id      = clonePo.OriginalPo_Id,
                        BeamCutStartSeq_Id = seq1Id,
                        BeamCutStopSeq_Id  = seq2Id,
                        TotalSelectedQty   = qty[0],
                        TotalSelectCutQty  = qty[1],
                        Schedule_Id        = scheduleId,
                        StartSeqNo         = startSeq.SequenceNo,
                        StopSeqNo          = stopSeq.SequenceNo,
                        StartCutTime       = DateTime.Now,
                        CuttingQty         = 0,
                        BeamCutCounter     = 0,
                        BDeviceOrder_Id    = order != null ? order.id : 0,
                    };

                    var beamInterface = BeamCutQuery.AddNewBeamCutInterface(binterface);
                    if (beamInterface == null)
                    {
                        Exception = new RespException(true, "Add new BInterface error", EKB_SYS_REQUEST.BEAM_START_CUTTING);
                        return;
                    }
                    bId = beamInterface.id;
                }

                StockMeasure stockMeasure = StockQuery.GetStockMeasure(schedule);

                if (stockMeasure == null)
                {
                    var stock = StockQuery.AddNewStockMeasure(schedule);
                }

                Exception = new RespException(false, "Start cutting: OK", EKB_SYS_REQUEST.BEAM_START_CUTTING);

                InterfaceId = bId;
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_START_CUTTING);
            }
        }