KBWindowViewModel.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. using LiveChartsCore.SkiaSharpView.Extensions;
  2. using LiveChartsCore;
  3. using LogoForceTestApp.Modules.MainModule.Models;
  4. using Prism.Events;
  5. using Prism.Mvvm;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Timers;
  10. using LiveChartsCore.SkiaSharpView.Painting;
  11. using SkiaSharp;
  12. using LiveChartsCore.Measure;
  13. using Repository;
  14. using Repository.Entiies;
  15. using LiveChartsCore.SkiaSharpView;
  16. using System.Collections.ObjectModel;
  17. using LiveChartsCore.SkiaSharpView.VisualElements;
  18. using LiveChartsCore.Defaults;
  19. using FontFamily = System.Windows.Media.FontFamily;
  20. using AutoMapper;
  21. using System.Windows;
  22. using ZXing.Maxicode;
  23. namespace LogoForceTestApp.Modules.MainModule.ViewModels
  24. {
  25. public class KBWindowViewModel : BindableBase
  26. {
  27. #region
  28. IRepository repository;
  29. private readonly IEventAggregator _eventAggregator;
  30. public ObservableCollection<HouseDto> MyHouse { get; set; }
  31. private readonly IMapper _mapper;
  32. //private readonly List<House> _myHouse;
  33. private string timeNow = DateTime.Now.ToString();
  34. public string TimeNow
  35. {
  36. get => timeNow;
  37. set { SetProperty(ref timeNow, value); }
  38. }
  39. private Timer _timer;
  40. public IEnumerable<ISeries> Series { get; set; }
  41. int[] outwork = new int[3];
  42. public string TotalPer { get; set; }
  43. public string ActualPer { get; set; }
  44. public string FallIllPer { get; set; }
  45. public string AbsenPer { get; set; }
  46. #region 产量
  47. public string BillNo { get; set; }
  48. public double AuxQty { get; set; }
  49. public double Finished { get; set; }
  50. private double _finishRate;
  51. public double FinishRate
  52. {
  53. get { return (Finished / Convert.ToDouble(AuxQty)) * 100;}
  54. set { SetProperty(ref _finishRate, value); }
  55. }
  56. #endregion
  57. #region 灯
  58. public string ImgLight1 { get; set; }//1号机
  59. public string ImgLight2 { get; set; }
  60. public string ImgLight3 { get; set; }
  61. public string ImgLight4 { get; set; }
  62. public string ImgLight5 { get; set; }
  63. public string ImgLight6 { get; set; }
  64. public string ImgLight7 { get; set; }
  65. public string ImgLight8 { get; set; }
  66. public string ImgLight9 { get; set; }
  67. public string ImgLight10 { get; set; }
  68. public string ImgLight11 { get; set; }
  69. public string ImgLight12 { get; set; }
  70. public string ImgLight13 { get; set; }
  71. public string ImgLight14 { get; set; }
  72. public string ImgLight15 { get; set; }//螺丝机
  73. public string ImgLight16 { get; set; }
  74. public string ImgLight17 { get; set; }
  75. public string ImgLight18 { get; set; }
  76. public string ImgLight19 { get; set; }
  77. public string ImgLight20 { get; set; }
  78. public string ImgLight21 { get; set; }//提升机
  79. public string ImgLight22 { get; set; }//检测机
  80. public string ImgLight23 { get; set; }//返修机
  81. #endregion
  82. public double TotalNum { get; set; } = 100;
  83. public double PassNum { get; set; } = 33;
  84. #endregion
  85. public KBWindowViewModel(IRepository repository, IEventAggregator eventAggregator,IMapper mapper)
  86. {
  87. this.repository = repository;
  88. this._eventAggregator = eventAggregator;
  89. Series = new List<ISeries>();
  90. #region timer
  91. _timer = new Timer();
  92. _timer.Interval = 3000;
  93. _timer.Elapsed += _timer_Elapsed;
  94. _timer.Start();
  95. this.repository = repository;
  96. #endregion
  97. #region chart显示文字
  98. string name = "微软雅黑";
  99. SKTypeface skTypeface = SKTypeface.FromFamilyName(name);
  100. if (skTypeface.FamilyName != name)
  101. {
  102. // 字体加载失败了
  103. skTypeface.Dispose();
  104. }
  105. FontFamily fontFamily = new(name);
  106. foreach (string familyNamesValue in fontFamily.FamilyNames.Values)
  107. {
  108. skTypeface = SKTypeface.FromFamilyName(familyNamesValue);
  109. if (skTypeface.FamilyName == familyNamesValue)
  110. break;
  111. else
  112. {
  113. skTypeface.Dispose();
  114. }
  115. }
  116. LiveChartsSkiaSharp.DefaultSKTypeface = skTypeface;
  117. #endregion
  118. _eventAggregator.GetEvent<AlarmEvent>().Subscribe(GetAlarmMessage);//接收另一个viewmodel的信息
  119. MyHouse = new ObservableCollection<HouseDto>();
  120. _mapper = mapper;
  121. }
  122. private void _timer_Elapsed(object sender, ElapsedEventArgs e)
  123. {
  124. TimeNow = DateTime.Now.ToString();
  125. var ename = new string[10] { "张", "王", "李", "赵", "刘", "张", "王", "李", "赵", "刘" };
  126. ShowPerson(ename);
  127. double[] dou = new double[] { 500, 200, 600, 800, 100, 200, 300 };
  128. SerLine(dou);
  129. _eventAggregator.GetEvent<QuestEvent>().Subscribe(ShowProcess);
  130. ShowHouse();
  131. ShowQuality();
  132. ShowOutWork();
  133. AlarmOK();
  134. double d = Convert.ToDouble(((PassNum / TotalNum) * 100).ToString("0.00"));
  135. PassRate(d);
  136. }
  137. #region 合格率
  138. public void PassRate(double passRate)
  139. {
  140. Series = GaugeGenerator.BuildSolidGauge(
  141. new GaugeItem(passRate, series =>
  142. {
  143. series.Fill = new SolidColorPaint(SKColors.YellowGreen);
  144. series.DataLabelsSize = 23;
  145. series.DataLabelsPaint = new SolidColorPaint(SKColors.LightPink);
  146. series.DataLabelsPosition = PolarLabelsPosition.ChartCenter;
  147. series.InnerRadius = 40;
  148. }),
  149. new GaugeItem(GaugeItem.Background, series =>
  150. {
  151. series.InnerRadius = 40;
  152. series.Fill = new SolidColorPaint(new SKColor(100, 181, 246, 90));
  153. }));
  154. }
  155. #endregion
  156. #region 出勤率
  157. public void ShowOutWork()
  158. {
  159. try
  160. {
  161. string str = DateTime.Now.ToString("yyyy/MM/dd");
  162. var list = repository.GetFirstDefault<OutofWork>(c => c.DateOutWork == str);
  163. if (list != null)
  164. {
  165. outwork[0] = list.Actual;
  166. outwork[1] = list.FallIll;
  167. outwork[2] = list.Absenteeism;
  168. int total = outwork[2] + outwork[1] + outwork[0];
  169. OutWork(outwork[2], outwork[1], outwork[0],total);
  170. string a = ((double)outwork[0] / (double)total).ToString("P");
  171. string b = ((double)outwork[1] / (double)total).ToString("P");
  172. string c = ((double)outwork[2] / (double)total).ToString("P");
  173. TotalPer = $"应到人数:{total}";
  174. ActualPer = $"实到人数:{outwork[0]}【{a}】";
  175. FallIllPer = $"请假人数:{outwork[1]}【{b}】";
  176. AbsenPer = $"旷工人数:{outwork[2]}【{c}】";
  177. }
  178. }
  179. catch (Exception ex)
  180. {
  181. }
  182. }
  183. public IEnumerable<ISeries> Series12 { get; set; }
  184. public double GaugeTotal12 { get; set; }
  185. public double InitialRotation12 { get; set; }
  186. public double MaxAngle12 { get; set; }
  187. /// <summary>
  188. /// "旷工人数","请假人数" ,"实到人数","应到人数"
  189. /// </summary>
  190. /// <param name="a"></param>
  191. /// <param name="b"></param>
  192. /// <param name="c"></param>
  193. /// <param name="d"></param>
  194. public void OutWork(int a, int b, int c,int d)
  195. {
  196. GaugeTotal12 = d;//最大数
  197. InitialRotation12 = 90;
  198. MaxAngle12 = 270;
  199. void SetStyle12(string name, PieSeries<ObservableValue> series)
  200. {
  201. series.Name = name;
  202. series.DataLabelsPosition = PolarLabelsPosition.Start;
  203. series.DataLabelsFormatter =
  204. point => $"{point.Context.Series.Name} {point.Coordinate.PrimaryValue}";
  205. series.DataLabelsSize = 16;
  206. series.InnerRadius = 20;
  207. series.RelativeInnerRadius = 4;
  208. series.RelativeOuterRadius = 4;
  209. series.DataLabelsPaint = new SolidColorPaint(new SKColor(150, 150, 150));
  210. }
  211. Series12 = GaugeGenerator.BuildSolidGauge(
  212. new GaugeItem(a, series => SetStyle12("旷工人数", series)),
  213. new GaugeItem(b, series => SetStyle12("请假人数", series)),
  214. new GaugeItem(c, series => SetStyle12("实到人数", series)),
  215. new GaugeItem(d, series => SetStyle12("应到人数", series)),
  216. new GaugeItem(GaugeItem.Background, series =>
  217. {
  218. series.InnerRadius = 20;
  219. series.RelativeInnerRadius = 10;
  220. series.RelativeOuterRadius = 10;
  221. }));
  222. }
  223. //public IEnumerable<ISeries> SeriesOutWork { get; set; }
  224. //private static int _index = 0;
  225. //private static string[] _names = new[] { "实到", "请假", "旷工" };
  226. //public void OutWork(int[] val)
  227. //{
  228. // SeriesOutWork = val.AsPieSeries((value, series) =>
  229. // {
  230. // series.Name = _names[_index++ % _names.Length];
  231. // series.DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Outer; // mark
  232. // series.DataLabelsSize = 10;
  233. // series.DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180));
  234. // //series.DataLabelsFormatter =
  235. // // point =>
  236. // // $"This slide takes {point.Coordinate.PrimaryValue} " +
  237. // // $"out of {point.StackedValue!.Total} parts";
  238. // //series.ToolTipLabelFormatter = point => $"{point.StackedValue!.Share:P2}";
  239. // series.ToolTipLabelFormatter =
  240. // point =>
  241. // {
  242. // var pv = point.Coordinate.PrimaryValue;
  243. // var sv = point.StackedValue!;
  244. // var a = $"{pv}/{sv.Total}{Environment.NewLine}{sv.Share:P2}";
  245. // return a;
  246. // };
  247. // series.DataLabelsFormatter =
  248. // point =>
  249. // {
  250. // var pv = point.Coordinate.PrimaryValue;
  251. // var sv = point.StackedValue!;
  252. // var a = $"{series.Name}{Environment.NewLine}{sv.Share:P2}";
  253. // return a;
  254. // };
  255. // });
  256. //}
  257. #endregion
  258. #region 质量
  259. int[] qua1 = new int[10];int[] qua2 = new int[10]; int[] qua3 = new int[10];
  260. public void ShowQuality()
  261. {
  262. try
  263. {
  264. string str = DateTime.Now.ToString("yyyy/MM/dd");
  265. var list = repository.GetFirstDefault<Quality>(c => c.DateQuality == str);
  266. if (list != null)
  267. {
  268. qua1[0] = list.Q1; qua1[1] = list.Q2; qua1[2] = list.Q3; qua1[3] = list.Q4; qua1[4] = list.Q5;
  269. qua1[5] = list.Q6; qua1[6] = list.Q7; qua1[7] = list.Q8; qua1[8] = list.Q9; qua1[9] = list.Q10;
  270. qua2[0] = list.Q11; qua2[1] = list.Q12; qua2[2] = list.Q13; qua2[3] = list.Q14; qua2[4] = list.Q15;
  271. qua2[5] = list.Q16; qua2[6] = list.Q17; qua2[7] = list.Q18; qua2[8] = list.Q19; qua2[9] = list.Q20;
  272. qua3[0] = list.Q21; qua3[1] = list.Q22; qua3[2] = list.Q23; qua3[3] = list.Q24; qua3[4] = list.Q25;
  273. qua3[5] = list.Q26; qua3[6] = list.Q27; qua3[7] = list.Q28; qua3[8] = list.Q29; qua3[9] = list.Q30;
  274. SerQuality1(qua1);
  275. SerQuality2(qua2);
  276. SerQuality3(qua3);
  277. }
  278. }
  279. catch (Exception)
  280. {
  281. }
  282. }
  283. #region 生产问题
  284. public void SerQuality1(int[] val)
  285. {
  286. SeriesQuality1[0].Values = val;
  287. }
  288. public ISeries[] SeriesQuality1 { get; set; } = new ISeries[]
  289. {
  290. new ColumnSeries<int>
  291. {
  292. Name = "数量",
  293. //Values = new[] {23, 27, 22, 29, 24 ,21,11,45,32,19},
  294. Stroke = null,
  295. DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180)),
  296. DataLabelsPosition = DataLabelsPosition.Top,
  297. Padding = 3,//每个条之间的距离
  298. //Fill = new LinearGradientPaint(
  299. // new [] { new SKColor(255, 140, 148), new SKColor(220, 237, 194) },
  300. // new SKPoint(0.5f, 0),
  301. // new SKPoint(0.5f, 1))
  302. Fill = new LinearGradientPaint(new[]{new SKColor(255, 140, 148), new SKColor(220, 237, 194) })
  303. }
  304. };
  305. public Axis[] XAxes1 { get; set; } =
  306. {
  307. new Axis
  308. {
  309. Labels = new string[] { "螺丝未上紧","3D人脸无效" ,"螺丝漏打" ,"显示屏幕漏光" ,"胶体未打好",
  310. "对讲喇叭无声","执手过于松紧" ,"螺丝打变形" ,"理线错乱" ,"弹簧未装好" },
  311. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  312. LabelsRotation = 90,
  313. TextSize = 12,
  314. ForceStepToMin = true,
  315. MinStep = 1
  316. }
  317. };
  318. public Axis[] YAxes1 { get; set; } =
  319. {
  320. new Axis
  321. {
  322. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  323. MinLimit=0,
  324. //最小步长
  325. //ForceStepToMin = true,
  326. //MinStep = 5
  327. }
  328. };
  329. #endregion
  330. #region 工艺问题
  331. public void SerQuality2(int[] val)
  332. {
  333. SeriesQuality2[0].Values = val;
  334. }
  335. public ISeries[] SeriesQuality2 { get; set; } = new ISeries[]
  336. {
  337. new ColumnSeries<int>
  338. {
  339. Name = "数量",
  340. //Values = new[] {23, 27, 22, 29, 24 ,21,11,45,32,19},
  341. Stroke = null,
  342. DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180)),
  343. DataLabelsPosition = DataLabelsPosition.Top,
  344. Padding = 3,//每个条之间的距离
  345. //Fill = new LinearGradientPaint(
  346. // new [] { new SKColor(255, 140, 148), new SKColor(220, 237, 194) },
  347. // new SKPoint(0.5f, 0),
  348. // new SKPoint(0.5f, 1))
  349. Fill = new LinearGradientPaint(new[]{new SKColor(255, 140, 148), new SKColor(220, 237, 194) })
  350. }
  351. };
  352. public Axis[] XAxes2 { get; set; } =
  353. {
  354. new Axis
  355. {
  356. Labels = new string[] {"对讲无声","执手问题" ,"壳体脚位不平衡" ,"前板锁芯两孔位不一致" ,"后板显示屏水印",
  357. "电池异常耗电","喷漆过厚导致组装困难" ,"设计线路太长" ,"执手靠垫片改善" ,"锁芯顶杆没固定位置"},
  358. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  359. LabelsRotation = 90,
  360. TextSize = 12,
  361. ForceStepToMin = true,
  362. MinStep = 1
  363. }
  364. };
  365. public Axis[] YAxes2 { get; set; } =
  366. {
  367. new Axis
  368. {
  369. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  370. MinLimit=0,
  371. //最小步长
  372. //ForceStepToMin = true,
  373. //MinStep = 5
  374. }
  375. };
  376. #endregion
  377. #region 物料问题
  378. public void SerQuality3(int[] val)
  379. {
  380. SeriesQuality3[0].Values = val;
  381. }
  382. public ISeries[] SeriesQuality3 { get; set; } = new ISeries[]
  383. {
  384. new ColumnSeries<int>
  385. {
  386. Name = "数量",
  387. //Values = new[] {23, 27, 22, 29, 24 ,21,11,45,32,19},
  388. Stroke = null,
  389. DataLabelsPaint = new SolidColorPaint(new SKColor(180, 180, 180)),
  390. DataLabelsPosition = DataLabelsPosition.Top,
  391. Padding = 3,//每个条之间的距离
  392. //Fill = new LinearGradientPaint(
  393. // new [] { new SKColor(255, 140, 148), new SKColor(220, 237, 194) },
  394. // new SKPoint(0.5f, 0),
  395. // new SKPoint(0.5f, 1))
  396. Fill = new LinearGradientPaint(new[]{new SKColor(255, 140, 148), new SKColor(220, 237, 194) })
  397. }
  398. };
  399. public Axis[] XAxes3 { get; set; } =
  400. {
  401. new Axis
  402. {
  403. Labels = new string[] {"面板变形","电机异常" ,"屏幕异常" ,"物料毛刺" ,"大屏上支架变形",
  404. "壳料划痕","显示屏水印" , "壳体脚位不平横" ,"装饰圈气泡脱皮" ,"电池异常"},
  405. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  406. LabelsRotation = 90,
  407. TextSize = 12,
  408. ForceStepToMin = true,
  409. MinStep = 1
  410. }
  411. };
  412. public Axis[] YAxes3 { get; set; } =
  413. {
  414. new Axis
  415. {
  416. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  417. MinLimit=0,
  418. //最小步长
  419. //ForceStepToMin = true,
  420. //MinStep = 5
  421. }
  422. };
  423. #endregion
  424. #endregion
  425. #region 人员管理
  426. public List<Person> PerManage { get; set; }
  427. private List<Person> PerManage1 { get; set; }
  428. public void PerManagement(string ename, string proce, string wtime, int ling)
  429. {
  430. //PerManage = new List<Person>();//放在外面就累加,放这里就不累加一直刷
  431. PerManage1.Add(new Person { Id = new Guid(), EmployeeName = ename, ProProcess = proce, WorkTime = wtime, Yield = ling });
  432. var m = PerManage1.OrderByDescending(x => x.Yield).ToList();//降序
  433. PerManage = m;
  434. }
  435. public void ShowPerson(string[] ename)
  436. {
  437. PerManage = new List<Person>();
  438. PerManage1 = new List<Person>();
  439. Random ran = new Random();
  440. for (int i = 0; i < ename.Length; i++)
  441. {
  442. int n = ran.Next(500);
  443. PerManagement(ename[i], "工序1", DateTime.Now.Second.ToString(), n);
  444. }
  445. }
  446. #endregion
  447. #region 仓库
  448. public void ShowHouse()
  449. {
  450. try
  451. {
  452. string str = DateTime.Now.ToString("yyyy/MM/dd");
  453. //var list = repository.GetAllQuery<House>(c => c.DateH == str);//查一个集合
  454. var list = repository.GetFirstDefault<House>(c => c.DateH == str);
  455. if (list!=null)
  456. {
  457. var dto = _mapper.Map<HouseDto>(list);
  458. Application.Current.Dispatcher.Invoke(new Action(() =>
  459. {
  460. MyHouse.Clear();
  461. MyHouse.Add(dto);
  462. SerHouse(double.Parse(list.LackH), double.Parse(list.UsedH), double.Parse(list.TotalH));
  463. }));
  464. }
  465. }
  466. catch (Exception ex)
  467. {
  468. }
  469. }
  470. public IEnumerable<ISeries> Series13 { get; set; }
  471. public double GaugeTotal13 { get; set; }
  472. public double InitialRotation13 { get; set; }
  473. public double MaxAngle13 { get; set; }
  474. /// <summary>
  475. /// "缺料订单数","已领料订单数" ,"当日订单数"
  476. /// </summary>
  477. /// <param name="a">小</param>
  478. /// <param name="b">中</param>
  479. /// <param name="c">最大</param>
  480. public void SerHouse(double a, double b, double c)
  481. {
  482. GaugeTotal13 = c;//最大数
  483. InitialRotation13 = 90;
  484. MaxAngle13 = 270;
  485. void SetStyle13(string name, PieSeries<ObservableValue> series)
  486. {
  487. series.Name = name;
  488. series.DataLabelsPosition = PolarLabelsPosition.Start;
  489. series.DataLabelsFormatter =
  490. point => $"{point.Context.Series.Name} {point.Coordinate.PrimaryValue}";
  491. series.DataLabelsSize = 16;
  492. series.InnerRadius = 20;
  493. series.RelativeInnerRadius = 4;
  494. series.RelativeOuterRadius = 4;
  495. series.DataLabelsPaint = new SolidColorPaint(new SKColor(150, 150, 150));
  496. }
  497. Series13 = GaugeGenerator.BuildSolidGauge(
  498. new GaugeItem(a, series => SetStyle13("缺料订单数", series)),
  499. new GaugeItem(b, series => SetStyle13("已领料订单数", series)),
  500. new GaugeItem(c, series => SetStyle13("当日订单数", series)),
  501. new GaugeItem(GaugeItem.Background, series =>
  502. {
  503. series.InnerRadius = 20;
  504. series.RelativeInnerRadius = 10;
  505. series.RelativeOuterRadius = 10;
  506. }));
  507. }
  508. #endregion
  509. #region 设备状态
  510. public void AlarmOK()
  511. {
  512. ImgLight1 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  513. ImgLight2 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  514. ImgLight3 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  515. ImgLight4 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  516. ImgLight5 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  517. ImgLight6 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  518. ImgLight7 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  519. ImgLight8 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  520. ImgLight9 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  521. ImgLight10 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  522. ImgLight11 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  523. ImgLight12 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  524. ImgLight13 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  525. ImgLight14 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  526. }
  527. private void GetAlarmMessage(Dictionary<string, string> dictionary)//dictionary 就是接收到的信息
  528. {
  529. var keys = new List<string>(dictionary.Keys);
  530. for (int i = 0; i < keys.Count; i++)
  531. {
  532. var key = keys[i];
  533. var value = dictionary[key];
  534. #region 号机
  535. //1号机
  536. if ((key == "D1101" && value == "报警"))
  537. {
  538. ImgLight1 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  539. }
  540. if ((key == "D1141.15" && value == "缺料"))
  541. {
  542. ImgLight1 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  543. }
  544. //2号机
  545. if ((key == "D1102" && value == "报警"))
  546. {
  547. ImgLight2 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  548. }
  549. if ((key == "D1142.15" && value == "缺料"))
  550. {
  551. ImgLight2 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  552. }
  553. //3号机
  554. if ((key == "D1103" && value == "报警"))
  555. {
  556. ImgLight3 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  557. }
  558. if ((key == "D1143.15" && value == "缺料"))
  559. {
  560. ImgLight3 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  561. }
  562. //4号机
  563. if ((key == "D1104" && value == "报警"))
  564. {
  565. ImgLight4 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  566. }
  567. if ((key == "D1144.15" && value == "缺料"))
  568. {
  569. ImgLight4 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  570. }
  571. //5号机
  572. if ((key == "D1105" && value == "报警"))
  573. {
  574. ImgLight5 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  575. }
  576. if ((key == "D1145.15" && value == "缺料"))
  577. {
  578. ImgLight5 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  579. }
  580. //6号机
  581. if ((key == "D1106" && value == "报警"))
  582. {
  583. ImgLight6 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  584. }
  585. if ((key == "D1146.15" && value == "缺料"))
  586. {
  587. ImgLight6 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  588. }
  589. //7号机
  590. if ((key == "D1110" && value == "报警"))
  591. {
  592. ImgLight7 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  593. }
  594. if ((key == "D1150.15" && value == "缺料"))
  595. {
  596. ImgLight7 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  597. }
  598. //8号机
  599. if ((key == "D1111" && value == "报警"))
  600. {
  601. ImgLight8 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  602. }
  603. if ((key == "D1151.15" && value == "缺料"))
  604. {
  605. ImgLight8 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  606. }
  607. //9号机
  608. if ((key == "D1112" && value == "报警"))
  609. {
  610. ImgLight9 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  611. }
  612. if ((key == "D1152.15" && value == "缺料"))
  613. {
  614. ImgLight9 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  615. }
  616. //10号机
  617. if ((key == "D1113" && value == "报警"))
  618. {
  619. ImgLight10 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  620. }
  621. if ((key == "D1153.15" && value == "缺料"))
  622. {
  623. ImgLight10 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  624. }
  625. //11号机
  626. if ((key == "D1117" && value == "报警"))
  627. {
  628. ImgLight11 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  629. }
  630. if ((key == "D1157.15" && value == "缺料"))
  631. {
  632. ImgLight11 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  633. }
  634. //12号机
  635. if ((key == "D1118" && value == "报警"))
  636. {
  637. ImgLight12 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  638. }
  639. if ((key == "D1158.15" && value == "缺料"))
  640. {
  641. ImgLight12 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  642. }
  643. //13号机
  644. if ((key == "D1119" && value == "报警"))
  645. {
  646. ImgLight13 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  647. }
  648. if ((key == "D1159.15" && value == "缺料"))
  649. {
  650. ImgLight13 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  651. }
  652. //14号机
  653. if ((key == "D1120" && value == "报警"))
  654. {
  655. ImgLight14 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  656. }
  657. if ((key == "D1160.15" && value == "缺料"))
  658. {
  659. ImgLight14 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  660. }
  661. #endregion
  662. #region 螺丝机
  663. //螺丝机1
  664. if ((key == "D1107" && value == "报警"))
  665. {
  666. ImgLight15 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  667. }
  668. if ((key == "D1107" && value == "正常"))
  669. {
  670. ImgLight15 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  671. }
  672. //螺丝机2
  673. if ((key == "D1108" && value == "报警"))
  674. {
  675. ImgLight16 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  676. }
  677. if ((key == "D1108" && value == "正常"))
  678. {
  679. ImgLight16 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  680. }
  681. //螺丝机3
  682. if ((key == "D1115" && value == "报警"))
  683. {
  684. ImgLight17 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  685. }
  686. if ((key == "D1115" && value == "正常"))
  687. {
  688. ImgLight17 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  689. }
  690. //螺丝机4
  691. if ((key == "D1116" && value == "报警"))
  692. {
  693. ImgLight18 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  694. }
  695. if ((key == "D1116" && value == "正常"))
  696. {
  697. ImgLight18 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  698. }
  699. //螺丝机5
  700. if ((key == "D1121" && value == "报警"))
  701. {
  702. ImgLight19 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  703. }
  704. if ((key == "D1121" && value == "正常"))
  705. {
  706. ImgLight19 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  707. }
  708. //螺丝机6
  709. if ((key == "D1122" && value == "报警"))
  710. {
  711. ImgLight20 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  712. }
  713. if ((key == "D1122" && value == "正常"))
  714. {
  715. ImgLight20 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  716. }
  717. #endregion
  718. //提升机
  719. if ((key == "D1100" && value == "报警") || (key == "D1124" && value == "报警") || (key == "D1125" && value == "报警"))
  720. {
  721. ImgLight21 = System.Windows.Forms.Application.StartupPath + @"\image\红灯.png";
  722. }
  723. if ((key == "D1100" && value == "正常") || (key == "D1124" && value == "正常") || (key == "D1125" && value == "正常"))
  724. {
  725. ImgLight21 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  726. }
  727. //检测
  728. if ((key == "D1166.0" && value == "缺料") || (key == "D1166.1" && value == "缺料") || (key == "D1166.2" && value == "缺料") || (key == "D1166.3" && value == "缺料"))
  729. {
  730. ImgLight22 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  731. }
  732. if ((key == "D1166.0" && value == "正常") || (key == "D1166.1" && value == "正常") || (key == "D1166.2" && value == "正常") || (key == "D1166.3" && value == "正常"))
  733. {
  734. ImgLight22 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  735. }
  736. //返修
  737. if ((key == "D1166.4" && value == "缺料") || (key == "D1166.5" && value == "缺料") || (key == "D1166.6" && value == "缺料"))
  738. {
  739. ImgLight23 = System.Windows.Forms.Application.StartupPath + @"\image\黄灯.png";
  740. }
  741. if ((key == "D1166.4" && value == "正常") || (key == "D1166.5" && value == "正常") || (key == "D1166.6" && value == "正常"))
  742. {
  743. ImgLight23 = System.Windows.Forms.Application.StartupPath + @"\image\绿灯.png";
  744. }
  745. }
  746. }
  747. #endregion
  748. #region 生产进度
  749. public void SerLine(double[] val)
  750. {
  751. SeriesLine[0].Values = val.ToArray();
  752. }
  753. public ISeries[] SeriesLine { get; set; } =
  754. {
  755. new LineSeries<double>
  756. {
  757. Name = "产量",
  758. //Values = new []{ 4, 2, 8, 5, 3 },
  759. GeometrySize = 12,
  760. Stroke = new LinearGradientPaint(new[]{ new SKColor(45, 64, 89), new SKColor(255, 212, 96)}) { StrokeThickness = 5 },
  761. GeometryStroke = new LinearGradientPaint(new[]{ new SKColor(45, 64, 89), new SKColor(255, 212, 96)}) { StrokeThickness = 5 },
  762. Fill = null
  763. //Fill = new SolidColorPaint(new SKColor(255, 212, 96, 90))
  764. }
  765. };
  766. public LabelVisual PcTitle { get; set; } =
  767. new LabelVisual
  768. {
  769. Text = "近一周产量趋势",
  770. TextSize = 16,
  771. Padding = new LiveChartsCore.Drawing.Padding(15),
  772. Paint = new SolidColorPaint(new SKColor(47,152,255))
  773. };
  774. public DrawMarginFrame DrawMarginFrame => new()
  775. {
  776. Stroke = new SolidColorPaint(new SKColor(45, 64, 89), 2)
  777. };
  778. public Axis[] XAxesLine { get; set; } =
  779. {
  780. new Axis
  781. {
  782. Labels = new string[] { "1","2" ,"3" ,"4" ,"5","6","7"},
  783. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  784. LabelsRotation = 0,
  785. ForceStepToMin = true,
  786. MinLimit=0,
  787. MinStep = 1
  788. }
  789. };
  790. public Axis[] YAxesLine { get; set; } =
  791. {
  792. new Axis
  793. {
  794. LabelsPaint = new SolidColorPaint(new SKColor(100, 100, 100)),
  795. MinLimit=0,
  796. //最小步长
  797. //ForceStepToMin = true,
  798. //MinStep = 5
  799. }
  800. };
  801. #endregion
  802. public void ShowProcess(string str)
  803. {
  804. var customRepo = new CustomRepository();
  805. try
  806. {
  807. //DateTime max = DateTime.Today.AddDays(1);
  808. //DateTime min = DateTime.Today.AddDays(-1);
  809. DateTime d = DateTime.Today;
  810. var list = customRepo.GetFirstDefault<ICMO>(c => c.FDate == d && c.FBillNo == str);
  811. if (list != null)
  812. {
  813. BillNo = str;
  814. AuxQty=(double)list.FAuxQty;
  815. }
  816. }
  817. catch (Exception ex)
  818. {
  819. }
  820. }
  821. }
  822. }