Beispiel #1
0
        public static void WriteStopLog()
        {
            try
            {
                DateTime?starttime = null;
                double   second    = 0;
                double   passt     = 0;

                double pnum     = 0;
                double totolnum = 0;
                int    ordernum = 0;
                double waittime = 0;

                string currPath = System.AppDomain.CurrentDomain.BaseDirectory + "Log\\";
                if (!Directory.Exists(currPath))
                {
                    Directory.CreateDirectory(currPath);
                }
                string logfilename = currPath + DateTime.Today.ToString("yyyyMMdd") + "_log.log";

                List <PrintInfo> printinfos = PrintBarCodes.GetAVGPrintEffice();


                if (File.Exists(logfilename) && printinfos.Count > 0)
                {
                    File.Delete(logfilename);
                }

                //Dictionary<string, double> effice = new Dictionary<string, double>();
                foreach (PrintInfo printinfo in printinfos)
                {
                    if (starttime == null)
                    {
                        pnum      = printinfo.allnum;
                        starttime = printinfo.starttime;
                    }
                    else
                    {
                        second = Convert.ToDouble(ExecDateDiff(Convert.ToDateTime(starttime), printinfo.starttime));
                        if (second > 120)
                        {
                            waittime += second;
                            AppUtility.AppUtil.WriteTxtLog(logfilename, starttime.GetValueOrDefault() + "至" + printinfo.starttime, "停止时间 " + second + "秒");
                        }

                        pnum      = printinfo.allnum;
                        starttime = printinfo.starttime;
                    }
                }


                //MessageBox.Show("停机日志生成成功!");
            }
            catch (Exception ex)
            {
                //MessageBox.Show("停机日志生成失败!");
            }
        }
Beispiel #2
0
        private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                //获取当前,上一个,下一个客户的基本信息
                GetOutPortInfo();
                GetPOutPortInfo();
                GetNOutPortInfo();

                //获取平均效率的列表(当天所有打完码的客户)
                List <PrintInfo> printinfos = PrintBarCodes.GetAVGPrintEffice();
                //获取当前效率的列表(现在系统所有打完码的客户)
                List <PrintInfo> cutprintinfos = PrintBarCodes.GetCUTPrintEffice();

                //计算当前效率
                double tzeff = SetEff(cutprintinfos);

                labavgeffice.Text = tzeff.ToString() + "条/小时";

                if (labavgeffice.Text.Contains("非数字"))
                {
                    labavgeffice.Text = "0" + "条/小时";
                }

                using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
                {
                    cn.Open();
                    using (var cm = cn.CreateCommand())
                    {
                        cm.CommandText = "select MaxcutEFFICIENCY from t_sortline_process WHERE ORDERDATE = '" + SortingLineTask.GetSortingLineTaskDate() + "' AND PICKLINECODE = '" + SortingLine.GetSortingLineCode() + "' AND SORTINGTASKNO = '" + SortingLineTask.GetMinSortingLineTask().SORTINGTASKNO + "'";
                        using (var dr = new SafeDataReader(cm.ExecuteReader()))
                        {
                            while (dr.Read())
                            {
                                labcuteffice.Text = dr.GetDouble("MaxcutEFFICIENCY").ToString() + "条/小时";
                            }
                        }
                    }
                }

                //计算平均效率
                //tzeff = SetEff(printinfos);

                //labavgeffice.Text = tzeff.ToString() + "条/小时";;

                //if (labavgeffice.Text.Contains("非数字"))
                //    labavgeffice.Text = "0" + "条/小时";

                //计算分拣进度
                SortingProgress sortingprogress = SortingProgress.GetSortingTaskProgress();
                prosorting.Maximum = sortingprogress.TotQty;
                prosorting.Value   = sortingprogress.Qty;
                prosorting.Text    = (sortingprogress.Qty + "/" + sortingprogress.TotQty).PadRight(15, ' ') +
                                     Math.Round(
                    Convert.ToDouble(sortingprogress.Qty) / Convert.ToDouble(sortingprogress.TotQty), 3) *
                                     100 + "%";
            }
            catch
            {
            }
        }
Beispiel #3
0
        public static void UpdateEfficincy()
        {
            DateTime?starttime = null;
            double   second    = 0;
            double   passt     = 0;

            double pnum     = 0;
            double totolnum = 0;
            int    ordernum = 0;

            try
            {
                List <PrintInfo> printinfos    = PrintBarCodes.GetAVGPrintEffice();
                List <PrintInfo> cutprintinfos = PrintBarCodes.GetCUTPrintEffice();

                //Dictionary<string, double> effice = new Dictionary<string, double>();
                foreach (PrintInfo printinfo in printinfos)
                {
                    if (starttime == null)
                    {
                        pnum      = printinfo.allnum;
                        starttime = printinfo.starttime;
                    }
                    else
                    {
                        second = Convert.ToDouble(ExecDateDiff(Convert.ToDateTime(starttime), printinfo.starttime));
                        if (second < AppUtility.AppUtil._IgnoreSecond)
                        {
                            totolnum += pnum;
                            passt    += second;
                            ordernum++;
                        }
                        pnum      = printinfo.allnum;
                        starttime = printinfo.starttime;
                    }
                }

                double efficincy = Math.Round((Math.Round((totolnum / passt), 9) * 3600), 0);

                using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
                {
                    cn.Open();
                    using (var cm = cn.CreateCommand())
                    {
                        cm.CommandText = "UPDATE t_sortline_process set EFFICIENCY = " + efficincy + " WHERE ORDERDATE = '" + SortingLineTask.GetSortingLineTaskDate() + "' AND PICKLINECODE = '" + SortingLine.GetSortingLineCode() + "' AND SORTINGTASKNO = '" + SortingLineTask.GetMinSortingLineTask().SORTINGTASKNO + "'";
                        cm.ExecuteNonQuery();
                    }
                }



                double maxavgeffic = 0;
                double maxcuteffic = 0;
                using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
                {
                    cn.Open();
                    using (var cm = cn.CreateCommand())
                    {
                        cm.CommandText = "select MaxavgEFFICIENCY from t_sortline_process WHERE ORDERDATE = '" + SortingLineTask.GetSortingLineTaskDate() + "' AND PICKLINECODE = '" + SortingLine.GetSortingLineCode() + "' AND SORTINGTASKNO = '" + SortingLineTask.GetMinSortingLineTask().SORTINGTASKNO + "'";
                        using (var dr = new SafeDataReader(cm.ExecuteReader()))
                        {
                            while (dr.Read())
                            {
                                maxavgeffic = dr.GetDouble("MaxavgEFFICIENCY");
                            }
                        }
                    }
                }

                if (efficincy > maxavgeffic)
                {
                    using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
                    {
                        cn.Open();
                        using (var cm = cn.CreateCommand())
                        {
                            cm.CommandText = "UPDATE t_sortline_process set MaxavgEFFICIENCY = " + efficincy + ",MaxavgEFFICIENCYTime = '" + DateTime.Now + "'  WHERE ORDERDATE = '" + SortingLineTask.GetSortingLineTaskDate() + "' AND PICKLINECODE = '" + SortingLine.GetSortingLineCode() + "' AND SORTINGTASKNO = '" + SortingLineTask.GetMinSortingLineTask().SORTINGTASKNO + "'";
                            cm.ExecuteNonQuery();
                        }
                    }
                }



                starttime = null;
                second    = 0;
                passt     = 0;

                pnum     = 0;
                totolnum = 0;
                ordernum = 0;
                foreach (PrintInfo printinfo in cutprintinfos)
                {
                    if (starttime == null)
                    {
                        pnum      = printinfo.allnum;
                        starttime = printinfo.starttime;
                    }
                    else
                    {
                        second = Convert.ToDouble(ExecDateDiff(Convert.ToDateTime(starttime), printinfo.starttime));
                        if (second < AppUtility.AppUtil._IgnoreSecond)
                        {
                            totolnum += pnum;
                            passt    += second;
                            ordernum++;
                        }
                        pnum      = printinfo.allnum;
                        starttime = printinfo.starttime;
                    }
                }

                efficincy = Math.Round((Math.Round((totolnum / passt), 9) * 3600), 0);


                using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
                {
                    cn.Open();
                    using (var cm = cn.CreateCommand())
                    {
                        cm.CommandText = "select MaxcutEFFICIENCY from t_sortline_process WHERE ORDERDATE = '" + SortingLineTask.GetSortingLineTaskDate() + "' AND PICKLINECODE = '" + SortingLine.GetSortingLineCode() + "' AND SORTINGTASKNO = '" + SortingLineTask.GetMinSortingLineTask().SORTINGTASKNO + "'";
                        using (var dr = new SafeDataReader(cm.ExecuteReader()))
                        {
                            while (dr.Read())
                            {
                                maxcuteffic = dr.GetDouble("MaxcutEFFICIENCY");
                            }
                        }
                    }
                }

                if (efficincy > maxcuteffic)
                {
                    using (var cn = new MySqlConnection(AppUtility.AppUtil._LocalConnectionString))
                    {
                        cn.Open();
                        using (var cm = cn.CreateCommand())
                        {
                            cm.CommandText = "UPDATE t_sortline_process set MaxcutEFFICIENCY = " + efficincy + ",MaxcutEFFICIENCYTime = '" + DateTime.Now + "'  WHERE ORDERDATE = '" + SortingLineTask.GetSortingLineTaskDate() + "' AND PICKLINECODE = '" + SortingLine.GetSortingLineCode() + "' AND SORTINGTASKNO = '" + SortingLineTask.GetMinSortingLineTask().SORTINGTASKNO + "'";
                            cm.ExecuteNonQuery();
                        }
                    }
                }
            }
            catch
            { }
        }