| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080 | using LiveChartsCore.SkiaSharpView.Extensions;using LiveChartsCore;using LogoForceTestApp.Modules.MainModule.Models;using Prism.Events;using Prism.Mvvm;using System;using System.Collections.Generic;using System.Linq;using System.Timers;using LiveChartsCore.SkiaSharpView.Painting;using SkiaSharp;using LiveChartsCore.Measure;using Repository;using Repository.Entiies;using LiveChartsCore.SkiaSharpView;using System.Collections.ObjectModel;using LiveChartsCore.SkiaSharpView.VisualElements;using LiveChartsCore.Defaults;using FontFamily = System.Windows.Media.FontFamily;using AutoMapper;using System.Windows;using ZXing.Maxicode;using System.Numerics;using System.Windows.Documents;using LiveChartsCore.ConditionalDraw;using LiveChartsCore.Themes;using System.Threading.Tasks;using System.Data.SqlTypes;using System.Threading;using Timer = System.Timers.Timer;namespace LogoForceTestApp.Modules.MainModule.ViewModels{    public class KBWindowViewModel : BindableBase    {        #region        IRepository repository;        private readonly IEventAggregator _eventAggregator;        public ObservableCollection<HouseDto> MyHouse { get; set; }        private readonly IMapper _mapper;        //private readonly List<House> _myHouse;        private string timeNow = DateTime.Now.ToString();        public string TimeNow        {            get => timeNow;            set { SetProperty(ref timeNow, value); }        }        private System.Timers.Timer _timer;        public IEnumerable<ISeries> Series { get; set; }        int[] outwork = new int[3];        public string TotalPer { get; set; }        public string ActualPer { get; set; }        public string FallIllPer { get; set; }        public string AbsenPer { get; set; }        #region 产量        public string BillNo { get; set; }        public double AuxQty { get; set; }        public double Finished { get; set; }        private double _finishRate;        public double FinishRate        {            get { return (Finished / Convert.ToDouble(AuxQty)) * 100; }            set { SetProperty(ref _finishRate, value); }        }        #endregion        #region 灯        public string ImgLight1 { get; set; }//1号机        public string ImgLight2 { get; set; }        public string ImgLight3 { get; set; }        public string ImgLight4 { get; set; }        public string ImgLight5 { get; set; }        public string ImgLight6 { get; set; }        public string ImgLight7 { get; set; }        public string ImgLight8 { get; set; }        public string ImgLight9 { get; set; }        public string ImgLight10 { get; set; }        public string ImgLight11 { get; set; }        public string ImgLight12 { get; set; }        public string ImgLight13 { get; set; }        public string ImgLight14 { get; set; }        public string ImgLight15 { get; set; }//螺丝机        public string ImgLight16 { get; set; }        public string ImgLight17 { get; set; }        public string ImgLight18 { get; set; }        public string ImgLight19 { get; set; }        public string ImgLight20 { get; set; }        public string ImgLight21 { get; set; }//提升机        public string ImgLight22 { get; set; }//检测机        public string ImgLight23 { get; set; }//返修机        #endregion        public double TotalNum { get; set; }        public double PassNum { get; set; }        public string FirstName { get; set; }        public string SecondName { get; set; }        public string ThirdName { get; set; }        public string Fix { get; set; }        #endregion        public KBWindowViewModel(IRepository repository, IEventAggregator eventAggregator, IMapper mapper)        {            this.repository = repository;            this._eventAggregator = eventAggregator;            Series = new List<ISeries>();            #region timer            _timer = new Timer();            _timer.Interval = 1000;            _timer.Elapsed += _timer_Elapsed;            _timer.Start();            #endregion            #region chart显示文字            string name = "微软雅黑";            SKTypeface skTypeface = SKTypeface.FromFamilyName(name);            if (skTypeface.FamilyName != name)            {                // 字体加载失败了                skTypeface.Dispose();            }            FontFamily fontFamily = new(name);            foreach (string familyNamesValue in fontFamily.FamilyNames.Values)            {                skTypeface = SKTypeface.FromFamilyName(familyNamesValue);                if (skTypeface.FamilyName == familyNamesValue)                    break;                else                {                    skTypeface.Dispose();                }            }            LiveChartsSkiaSharp.DefaultSKTypeface = skTypeface;            #endregion            _eventAggregator.GetEvent<AlarmEvent>().Subscribe(GetAlarmMessage);//接收另一个viewmodel的信息            MyHouse = new ObservableCollection<HouseDto>();            _mapper = mapper;            _eventAggregator.GetEvent<OperatorNameEvent>().Subscribe(ShowPeope);            _eventAggregator.GetEvent<QuestEvent>().Subscribe(ShowOrder);            Task.Factory.StartNew(Main, TaskCreationOptions.LongRunning);        }        private void Main()        {            while (true)            {                try                {                    ShowHouse();                    ShowQuality();                    ShowOutWork();                    AlarmOK();                    double d = Convert.ToDouble(((PassNum / TotalNum) * 100).ToString("0.00"));                    PassRate(d);                    ShowNowProcess();                    ShowProcess();                }                catch (ObjectDisposedException ex)                {                }                finally                {                    Thread.Sleep(5000);                }            }        }        private void _timer_Elapsed(object sender, ElapsedEventArgs e)        {            TimeNow = DateTime.Now.ToString();            DateTime currentDate = DateTime.Now;            if (currentDate.Day == 25)            {                Fix = "保养提醒:整线需要保养";            }        }        #region 合格率        public void PassRate(double passRate)        {            Series = GaugeGenerator.BuildSolidGauge(            new GaugeItem(passRate, series =>           {               series.Fill = new SolidColorPaint(SKColors.YellowGreen);               series.DataLabelsSize = 23;               series.DataLabelsPaint = new SolidColorPaint(SKColors.LightPink);               series.DataLabelsPosition = PolarLabelsPosition.ChartCenter;               series.InnerRadius = 40;           }),           new GaugeItem(GaugeItem.Background, series =>           {               series.InnerRadius = 40;               series.Fill = new SolidColorPaint(new SKColor(100, 181, 246, 90));           }));        }        #endregion        #region 出勤率        public void ShowOutWork()        {            try            {                var list = repository.GetFirstDefault<OutofWork>(c => c.DateOutWork == DateTime.Today);                if (list != null)                {                    outwork[0] = list.Actual;                    outwork[1] = list.FallIll;                    outwork[2] = list.Absenteeism;                    int total = outwork[2] + outwork[1] + outwork[0];                    OutWork(outwork[2], outwork[1], outwork[0], total);                    string a = ((double)outwork[0] / (double)total).ToString("P");                    string b = ((double)outwork[1] / (double)total).ToString("P");                    string c = ((double)outwork[2] / (double)total).ToString("P");                    TotalPer = $"应到人数:{total}";                    ActualPer = $"实到人数:{outwork[0]}【{a}】";                    FallIllPer = $"请假人数:{outwork[1]}【{b}】";                    AbsenPer = $"旷工人数:{outwork[2]}【{c}】";                }            }            catch (Exception ex)            {            }        }        public IEnumerable<ISeries> Series12 { get; set; }        public double GaugeTotal12 { get; set; }        public double InitialRotation12 { get; set; }        public double MaxAngle12 { get; set; }        /// <summary>        /// "旷工人数","请假人数" ,"实到人数","应到人数"        /// </summary>        /// <param name="a"></param>        /// <param name="b"></param>        /// <param name="c"></param>        /// <param name="d"></param>        public void OutWork(int a, int b, int c, int d)        {            GaugeTotal12 = d;//最大数            InitialRotation12 = 90;            MaxAngle12 = 270;            void SetStyle12(string name, PieSeries<ObservableValue> series)            {                series.Name = name;                series.DataLabelsPosition = PolarLabelsPosition.Start;                series.DataLabelsFormatter =                    point => $"{point.Context.Series.Name} {point.Coordinate.PrimaryValue}";                series.DataLabelsSize = 16;                series.InnerRadius = 20;                series.RelativeInnerRadius = 4;                series.RelativeOuterRadius = 4;                series.DataLabelsPaint = new SolidColorPaint(new SKColor(150, 150, 150));            }            Series12 = GaugeGenerator.BuildSolidGauge(                new GaugeItem(a, series => SetStyle12("旷工人数", series)),                new GaugeItem(b, series => SetStyle12("请假人数", series)),                new GaugeItem(c, series => SetStyle12("实到人数", series)),                new GaugeItem(d, series => SetStyle12("应到人数", series)),                new GaugeItem(GaugeItem.Background, series =>                {                    series.InnerRadius = 20;                    series.RelativeInnerRadius = 10;                    series.RelativeOuterRadius = 10;                }));        }        //public IEnumerable<ISeries> SeriesOutWork { get; set; }        //private static int _index = 0;        //private static string[] _names = new[] { "实到", "请假", "旷工" };        //public void OutWork(int[] val)        //{        //    SeriesOutWork = val.AsPieSeries((value, series) =>        //    {        //        series.Name = _names[_index++ % _names.Length];        //        series.DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Outer; // mark        //        series.DataLabelsSize = 10;        //        series.DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180));        //        //series.DataLabelsFormatter =        //        //   point =>        //        //       $"This slide takes {point.Coordinate.PrimaryValue} " +        //        //       $"out of {point.StackedValue!.Total} parts";        //        //series.ToolTipLabelFormatter = point => $"{point.StackedValue!.Share:P2}";        //        series.ToolTipLabelFormatter =        //           point =>        //           {        //               var pv = point.Coordinate.PrimaryValue;        //               var sv = point.StackedValue!;        //               var a = $"{pv}/{sv.Total}{Environment.NewLine}{sv.Share:P2}";        //               return a;        //           };        //        series.DataLabelsFormatter =        //            point =>        //            {        //                var pv = point.Coordinate.PrimaryValue;        //                var sv = point.StackedValue!;        //                var a = $"{series.Name}{Environment.NewLine}{sv.Share:P2}";        //                return a;        //            };        //    });        //}        #endregion        #region 质量        int[] qua1 = new int[10]; int[] qua2 = new int[10]; int[] qua3 = new int[10];        public void ShowQuality()        {            try            {                //string str = DateTime.Now.ToString("yyyy/MM/dd");                DateTime dt = DateTime.Today;                var list = repository.GetFirstDefault<Quality>(c => c.DateQuality == dt);                if (list != null)                {                    qua1[0] = list.Q1; qua1[1] = list.Q2; qua1[2] = list.Q3; qua1[3] = list.Q4; qua1[4] = list.Q5;                    qua1[5] = list.Q6; qua1[6] = list.Q7; qua1[7] = list.Q8; qua1[8] = list.Q9; qua1[9] = list.Q10;                    qua2[0] = list.Q11; qua2[1] = list.Q12; qua2[2] = list.Q13; qua2[3] = list.Q14; qua2[4] = list.Q15;                    qua2[5] = list.Q16; qua2[6] = list.Q17; qua2[7] = list.Q18; qua2[8] = list.Q19; qua2[9] = list.Q20;                    qua3[0] = list.Q21; qua3[1] = list.Q22; qua3[2] = list.Q23; qua3[3] = list.Q24; qua3[4] = list.Q25;                    qua3[5] = list.Q26; qua3[6] = list.Q27; qua3[7] = list.Q28; qua3[8] = list.Q29; qua3[9] = list.Q30;                    SerQuality1(qua1);                    SerQuality2(qua2);                    SerQuality3(qua3);                }            }            catch (Exception)            {            }        }        #region 生产问题        public void SerQuality1(int[] val)        {            SeriesQuality1[0].Values = val;        }        public ISeries[] SeriesQuality1 { get; set; } = new ISeries[]        {            new ColumnSeries<int>            {                Name = "数量",                //Values = new[] {23, 27, 22, 29, 24 ,21,11,45,32,19},                Stroke = null,                DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180)),                DataLabelsPosition = DataLabelsPosition.Top,                Padding = 3,//每个条之间的距离                //Fill = new LinearGradientPaint(                //    new [] { new SKColor(255, 140, 148), new SKColor(220, 237, 194) },                //    new SKPoint(0.5f, 0),                //    new SKPoint(0.5f, 1))                Fill = new LinearGradientPaint(new[]{new SKColor(255, 140, 148), new SKColor(220, 237, 194) })            }        };        public Axis[] XAxes1 { get; set; } =        {            new Axis            {                Labels = new string[] { "螺丝未上紧","3D人脸无效" ,"螺丝漏打" ,"显示屏幕漏光" ,"胶体未打好",                    "对讲喇叭无声","执手过于松紧" ,"螺丝打变形" ,"理线错乱" ,"弹簧未装好" },                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                LabelsRotation = 90,                TextSize = 12,                ForceStepToMin = true,                MinStep = 1            }        };        public Axis[] YAxes1 { get; set; } =        {            new Axis            {                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                MinLimit=0,                //最小步长                //ForceStepToMin = true,                //MinStep = 5            }        };        #endregion        #region 工艺问题        public void SerQuality2(int[] val)        {            SeriesQuality2[0].Values = val;        }        public ISeries[] SeriesQuality2 { get; set; } = new ISeries[]        {            new ColumnSeries<int>            {                Name = "数量",                //Values = new[] {23, 27, 22, 29, 24 ,21,11,45,32,19},                Stroke = null,                DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180)),                DataLabelsPosition = DataLabelsPosition.Top,                Padding = 3,//每个条之间的距离                //Fill = new LinearGradientPaint(                //    new [] { new SKColor(255, 140, 148), new SKColor(220, 237, 194) },                //    new SKPoint(0.5f, 0),                //    new SKPoint(0.5f, 1))                Fill = new LinearGradientPaint(new[]{new SKColor(255, 140, 148), new SKColor(220, 237, 194) })            }        };        public Axis[] XAxes2 { get; set; } =        {            new Axis            {                Labels = new string[] {"对讲无声","执手问题" ,"壳体脚位不平衡" ,"前板锁芯两孔位不一致" ,"后板显示屏水印",                    "电池异常耗电","喷漆过厚导致组装困难" ,"设计线路太长" ,"执手靠垫片改善" ,"锁芯顶杆没固定位置"},                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                LabelsRotation = 90,                TextSize = 12,                ForceStepToMin = true,                MinStep = 1            }        };        public Axis[] YAxes2 { get; set; } =        {            new Axis            {                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                MinLimit=0,                //最小步长                //ForceStepToMin = true,                //MinStep = 5            }        };        #endregion        #region 物料问题        public void SerQuality3(int[] val)        {            SeriesQuality3[0].Values = val;        }        public ISeries[] SeriesQuality3 { get; set; } = new ISeries[]        {            new ColumnSeries<int>            {                Name = "数量",                //Values = new[] {23, 27, 22, 29, 24 ,21,11,45,32,19},                Stroke = null,                DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180)),                DataLabelsPosition = DataLabelsPosition.Top,                Padding = 3,//每个条之间的距离                //Fill = new LinearGradientPaint(                //    new [] { new SKColor(255, 140, 148), new SKColor(220, 237, 194) },                //    new SKPoint(0.5f, 0),                //    new SKPoint(0.5f, 1))                Fill = new LinearGradientPaint(new[]{new SKColor(255, 140, 148), new SKColor(220, 237, 194) })            }        };        public Axis[] XAxes3 { get; set; } =        {            new Axis            {                Labels = new string[] {"面板变形","电机异常" ,"屏幕异常" ,"物料毛刺" ,"大屏上支架变形",                    "壳料划痕","显示屏水印" , "壳体脚位不平横" ,"装饰圈气泡脱皮" ,"电池异常"},                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                LabelsRotation = 90,                TextSize = 12,                ForceStepToMin = true,                MinStep = 1            }        };        public Axis[] YAxes3 { get; set; } =        {            new Axis            {                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                MinLimit=0,                //最小步长                //ForceStepToMin = true,                //MinStep = 5            }        };        #endregion        #endregion        #region 人员管理        //int nums;        //private void ShowPeope(string opername)        //{        //    var value = repository.GetAllQuery<Information>(c => c.OperatorCode == opername && c.CreateTime == DateTime.Today);        //    if (value.Count != 0)        //    {        //        nums = value.Count();        //        PerManagement(opername, nums);        //    }        //}        int[] nums = new int[30];                private void ShowPeope(string[] opername)        {            PerManage = new List<Person>();            PerManage1 = new List<Person>();            PerManage2 = new List<Person>();            for (int i = 0; i < opername.Length; i++)            {                if (opername[i] == null || string.IsNullOrEmpty(opername[i]))                {                    continue;                }                var value = repository.GetAllQuery<Information>(c => c.OperatorCode == opername[i] && c.CreateTime == DateTime.Today);                if (value.Count != 0)                {                    nums[i] = value.Count();                    PerManagement(opername[i], nums[i]);                }                var num= repository.GetAllQuery<Information>(c => c.OperatorCode == opername[i] && c.CreateTime <= DateTime.Today&& c.CreateTime >= DateTime.Today.AddDays(-9));                if (num.Count != 0)                {                    nums[i] = value.Count();                    PerManagement2(opername[i], nums[i]);                }            }        }        public List<Person> PerManage { get; set; }        private List<Person> PerManage1 { get; set; }        private List<Person> PerManage2 { get; set; }        public void PerManagement(string ename, int yield)        {            //PerManage = new List<Person>();//放在外面就累加,放这里就不累加一直刷            PerManage1.Add(new Person { Id = new Guid(), EmployeeName = ename, Yield = yield });            var m = PerManage1.OrderByDescending(x => x.Yield).ToList();//降序            PerManage = m;            //if (m.Count >= 3)            //{            //    FirstName = PerManage[0].EmployeeName;            //    SecondName = PerManage[1].EmployeeName;            //    ThirdName = PerManage[2].EmployeeName;            //}        }        public void PerManagement2(string ename, int yield)        {            PerManage2.Add(new Person { Id = new Guid(), EmployeeName = ename, Yield = yield });            var m = PerManage2.OrderByDescending(x => x.Yield).ToList();//降序            PerManage = m;            if (m.Count >= 3)            {                FirstName = PerManage[0].EmployeeName;                SecondName = PerManage[1].EmployeeName;                ThirdName = PerManage[2].EmployeeName;            }        }        #endregion        #region 仓库        public void ShowHouse()        {            try            {                //var list = repository.GetAllQuery<House>(c => c.DateH == str);//查一个集合                var list = repository.GetFirstDefault<House>(c => c.DateH == DateTime.Today);                if (list != null)                {                    var dto = _mapper.Map<HouseDto>(list);                    Application.Current.Dispatcher.Invoke(new Action(() =>                    {                        MyHouse.Clear();                        MyHouse.Add(dto);                        SerHouse(double.Parse(list.LackH), double.Parse(list.UsedH), double.Parse(list.TotalH));                    }));                }            }            catch (Exception ex)            {            }        }        public IEnumerable<ISeries> Series13 { get; set; }        public double GaugeTotal13 { get; set; }        public double InitialRotation13 { get; set; }        public double MaxAngle13 { get; set; }        /// <summary>        /// "缺料订单数","已领料订单数" ,"当日订单数"        /// </summary>        /// <param name="a">小</param>        /// <param name="b">中</param>        /// <param name="c">最大</param>        public void SerHouse(double a, double b, double c)        {            GaugeTotal13 = c;//最大数            InitialRotation13 = 90;            MaxAngle13 = 270;            void SetStyle13(string name, PieSeries<ObservableValue> series)            {                series.Name = name;                series.DataLabelsPosition = PolarLabelsPosition.Start;                series.DataLabelsFormatter =                    point => $"{point.Context.Series.Name} {point.Coordinate.PrimaryValue}";                series.DataLabelsSize = 16;                series.InnerRadius = 20;                series.RelativeInnerRadius = 4;                series.RelativeOuterRadius = 4;                series.DataLabelsPaint = new SolidColorPaint(new SKColor(150, 150, 150));            }            Series13 = GaugeGenerator.BuildSolidGauge(                new GaugeItem(a, series => SetStyle13("缺料订单数", series)),                new GaugeItem(b, series => SetStyle13("已领料订单数", series)),                new GaugeItem(c, series => SetStyle13("当日订单数", series)),                new GaugeItem(GaugeItem.Background, series =>                {                    series.InnerRadius = 20;                    series.RelativeInnerRadius = 10;                    series.RelativeOuterRadius = 10;                }));        }        #endregion        #region 设备状态        public void AlarmOK()        {            ImgLight1 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight2 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight3 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight4 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight5 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight6 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight7 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight8 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight9 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight10 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight11 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight12 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight13 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight14 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight21 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight22 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";            ImgLight23 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";        }        private void GetAlarmMessage(Dictionary<string, string> dictionary)//dictionary 就是接收到的信息        {            var keys = new List<string>(dictionary.Keys);            for (int i = 0; i < keys.Count; i++)            {                var key = keys[i];                var value = dictionary[key];                #region 号机                //1号机                if ((key == "1101" && value == "报警"))                {                    ImgLight1 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1141.15" && value == "缺料"))                {                    ImgLight1 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //2号机                if ((key == "1102" && value == "报警"))                {                    ImgLight2 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1142.15" && value == "缺料"))                {                    ImgLight2 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //3号机                if ((key == "1103" && value == "报警"))                {                    ImgLight3 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1143.15" && value == "缺料"))                {                    ImgLight3 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //4号机                if ((key == "1104" && value == "报警"))                {                    ImgLight4 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1144.15" && value == "缺料"))                {                    ImgLight4 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //5号机                if ((key == "1105" && value == "报警"))                {                    ImgLight5 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1145.15" && value == "缺料"))                {                    ImgLight5 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //6号机                if ((key == "1106" && value == "报警"))                {                    ImgLight6 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1146.15" && value == "缺料"))                {                    ImgLight6 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //7号机                if ((key == "1110" && value == "报警"))                {                    ImgLight7 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1150.15" && value == "缺料"))                {                    ImgLight7 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //8号机                if ((key == "1111" && value == "报警"))                {                    ImgLight8 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1151.15" && value == "缺料"))                {                    ImgLight8 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //9号机                if ((key == "1112" && value == "报警"))                {                    ImgLight9 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1152.15" && value == "缺料"))                {                    ImgLight9 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //10号机                if ((key == "1113" && value == "报警"))                {                    ImgLight10 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1153.15" && value == "缺料"))                {                    ImgLight10 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //11号机                if ((key == "1117" && value == "报警"))                {                    ImgLight11 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1157.15" && value == "缺料"))                {                    ImgLight11 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //12号机                if ((key == "1118" && value == "报警"))                {                    ImgLight12 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1158.15" && value == "缺料"))                {                    ImgLight12 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //13号机                if ((key == "1119" && value == "报警"))                {                    ImgLight13 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1159.15" && value == "缺料"))                {                    ImgLight13 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //14号机                if ((key == "1120" && value == "报警"))                {                    ImgLight14 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1160.15" && value == "缺料"))                {                    ImgLight14 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                #endregion                #region 螺丝机                //螺丝机1                if ((key == "1107" && value == "报警"))                {                    ImgLight15 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1107" && value == "正常"))                {                    ImgLight15 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";                }                //螺丝机2                if ((key == "1108" && value == "报警"))                {                    ImgLight16 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1108" && value == "正常"))                {                    ImgLight16 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";                }                //螺丝机3                if ((key == "1115" && value == "报警"))                {                    ImgLight17 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1115" && value == "正常"))                {                    ImgLight17 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";                }                //螺丝机4                if ((key == "1116" && value == "报警"))                {                    ImgLight18 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1116" && value == "正常"))                {                    ImgLight18 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";                }                //螺丝机5                if ((key == "1121" && value == "报警"))                {                    ImgLight19 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1121" && value == "正常"))                {                    ImgLight19 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";                }                //螺丝机6                if ((key == "1122" && value == "报警"))                {                    ImgLight20 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                if ((key == "1122" && value == "正常"))                {                    ImgLight20 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";                }                #endregion                //提升机                if ((key == "1100" && value == "报警") || (key == "1124" && value == "报警") || (key == "D1125" && value == "报警"))                {                    ImgLight21 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";                }                //检测                if ((key == "1166.0" && value == "缺料") || (key == "1166.1" && value == "缺料") || (key == "D1166.2" && value == "缺料") || (key == "D1166.3" && value == "缺料"))                {                    ImgLight22 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }                //返修                if ((key == "1166.4" && value == "缺料") || (key == "1166.5" && value == "缺料") || (key == "D1166.6" && value == "缺料"))                {                    ImgLight23 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";                }            }        }        #endregion        #region 生产进度        double changeDay; double okrate;        List<string> xlabel = new List<string>();        List<double> listval1 = new List<double>();        List<double> listval2 = new List<double>();        public void ShowProcess()        {            try            {                listval1.Clear();                listval2.Clear();                xlabel.Clear();                //for (int i = 1; i < 20; i++)                //{                //    changeDay = -i;                //    var list = repository.GetFirstDefault<AllNumber>(c => c.DateA == DateTime.Today.AddDays(changeDay));                //    if (list != null)                //    {                //        if (list.RealityA!=0)                //        {                //            listval1.Add(list.RealityA);                //            okrate = Math.Round((list.OkA / list.RealityA) * 100, 2);                //            listval2.Add(okrate);                //            xlabel.Add(list.DateA.ToString("MM-dd"));                //            if (listval1.Count >= 7)                //            {                //                break;                //            }                //        }                //    }                //}                DateTime start = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek - 1));                DateTime end = start.AddDays(7);                start = new DateTime(start.Year, start.Month, start.Day, 0, 0, 0);                end = new DateTime(end.Year, end.Month, end.Day, 0, 0, 0);                var list = repository.GetAllQuery<AllNumber>(c => c.DateA >=start&&c.DateA<end);                if (list != null)                {                    for (int i = 0; i < list.Count; i++)                    {                        listval1.Add(list[i].RealityA);                        okrate = Math.Round((list[i].OkA / list[i].RealityA) * 100, 2);                        listval2.Add(okrate);                        xlabel.Add(list[i].DateA.ToString("MM-dd"));                    }                }                SerLine(listval1, listval2, xlabel);            }            catch (Exception)            {            }        }        public void SerLine(List<double> val1, List<double> val2, List<string> list)        {            SeriesLine[0].Values = val1;            SeriesLine[1].Values = val2;            XAxesLine[0].Labels = list;        }        public ISeries[] SeriesLine { get; set; } =        {            new LineSeries<double>            {            Name = "产量",            //Values = new []{ 4, 2, 8, 5, 3 },            GeometrySize = 12,            Stroke = new LinearGradientPaint(new[]{ new SKColor(100, 135, 15), new SKColor(255, 212, 96)}) { StrokeThickness = 5 },            GeometryStroke = new LinearGradientPaint(new[]{ new SKColor(100, 135, 15), new SKColor(255, 212, 96)}) { StrokeThickness = 5 },            Fill = null,            ScalesYAt = 0            //Fill = new SolidColorPaint(new SKColor(255, 212, 96, 90))            },             new LineSeries<double>            {            Name = "合格率(%)",            GeometrySize = 12,            Stroke = new LinearGradientPaint(new[]{ new SKColor(100, 62, 99), new SKColor(255, 137, 219) }) { StrokeThickness = 5 },            GeometryStroke = new LinearGradientPaint(new[]{ new SKColor(100, 62, 99), new SKColor(255, 137, 219)}) { StrokeThickness = 5 },            Fill = null,            ScalesYAt = 1            }        };        public LabelVisual PcTitle { get; set; } =        new LabelVisual        {            Text = "近一周产量趋势",            TextSize = 16,            Padding = new LiveChartsCore.Drawing.Padding(15),            Paint = new SolidColorPaint(new SKColor(47, 152, 255))        };        public DrawMarginFrame DrawMarginFrame => new()        {            Stroke = new SolidColorPaint(new SKColor(45, 64, 89), 2)        };        public Axis[] XAxesLine { get; set; } =        {            new Axis            {                //Labels = new string[] { "1","2" ,"3" ,"4" ,"5","6","7"},                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                LabelsRotation = 0,                ForceStepToMin = true,                MinLimit=0,                MinStep = 1            }        };        public Axis[] YAxesLine { get; set; } =        {            new Axis            {                Name = "产量",                NameTextSize = 14,                NamePaint = new SolidColorPaint(new SKColor(153, 194, 40)),                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                MinLimit=0,                //最小步长                //ForceStepToMin = true,                //MinStep = 5            },            new Axis            {                Name = "合格率(%)",                NameTextSize = 14,                NamePaint = new SolidColorPaint(new SKColor(255, 137, 219)),                LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),                MinLimit=0,                MaxLimit=150,                Position = LiveChartsCore.Measure.AxisPosition.End            }        };        #endregion        #region 当前订单情况        public void ShowOrder(string str)        {            var customRepo = new CustomRepository();            try            {                //DateTime max = DateTime.Today.AddDays(1);                //DateTime min = DateTime.Today.AddDays(-1);                DateTime d = DateTime.Today;                var list = customRepo.GetFirstDefault<ICMO>(c => c.FBillNo == str);                if (list != null)                {                    BillNo = str;                    AuxQty = (double)list.FAuxQty;                }            }            catch (Exception ex)            {            }            try            {                var ps = repository.GetFirstDefault<ProStatus>(c => c.OrdNoS==str);                if (ps != null)                {                    Finished = ps.RealityS;                }            }            catch (Exception)            {            }        }        #endregion        #region 实时产量        public void ShowNowProcess()        {            try            {                var allnumbers = repository.GetFirstDefault<AllNumber>(c => c.DateA == DateTime.Today);                if (allnumbers != null)                {                    TotalNum = allnumbers.RealityA;                    if (allnumbers.OkA <= 0)                    {                        allnumbers.OkA= 0;                        repository.Update(allnumbers);                    }                    PassNum = allnumbers.OkA;                }            }            catch (Exception)            {            }        }        #endregion    }}
 |