using Community; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model { /// /// 载具对象 /// public class VehicleModel : NotificationObject { #region 穴位1 private ShowInfo acupoint1; /// /// 穴位1 /// public ShowInfo Acupoint1 { get { return acupoint1; } set { acupoint1 = value; this.RaisePropertyChanged("Acupoint1"); } } #endregion #region 穴位2 private ShowInfo acupoint2; /// /// 穴位2 /// public ShowInfo Acupoint2 { get { return acupoint2; } set { acupoint2 = value; this.RaisePropertyChanged("Acupoint2"); } } #endregion #region 本载具对应的字符串含义 private string vehicleStr; /// /// 本载具对应的字符串含义 /// public string VehicleStr { get { return vehicleStr; } set { vehicleStr = value; if (!string.IsNullOrEmpty(value)) { ReductionStatu(value); } } } #endregion public VehicleModel() { Acupoint1 = new ShowInfo(); Acupoint2 = new ShowInfo(); } #region 获取当前载具穴位指定状态相同的个数 /// /// 获取当前载具穴位指定状态相同的个数 /// /// /// public int GetColorNumber(string clostrStr) { int a = 0; if (Acupoint1.StatusBackground == clostrStr) { a++; } if (Acupoint2.StatusBackground == clostrStr) { a++; } return a; } #endregion #region 获取当前载具二维码为空的个数 /// /// 获取当前载具二维码为空的个数 /// /// public int GetCodeIsNullNumber() { int a = 0; if (string.IsNullOrEmpty(Acupoint1.StatuInfo)) { a++; } if (string.IsNullOrEmpty(Acupoint2.StatuInfo)) { a++; } return a; } #endregion #region 还原载具状态 List NewsList { get; set; } /// /// 还原载具状态 /// /// public void ReductionStatu(string statuStr) { try { NewsList = statuStr.Split(':').ToList(); if (NewsList[0] == "V") { Acupoint1.StatusBackground = StrToColor(NewsList[1]); Acupoint2.StatusBackground = StrToColor(NewsList[2]); Acupoint1.StatuInfo = NewsList[3]; Acupoint2.StatuInfo = NewsList[4]; Acupoint1.StatuValue = NewsList[5]; Acupoint2.StatuValue = NewsList[6]; } } catch (Exception) { } } #endregion #region 获取载具字符 /// /// 获取载具字符 /// /// public string GetVechicleStr() { string str = "V:"; str = str + ColorToStr(Acupoint1.StatusBackground) + ":"; str = str + ColorToStr(Acupoint2.StatusBackground) + ":"; if (string.IsNullOrEmpty(Acupoint1.StatuInfo)) { Acupoint1.StatuInfo = " "; } str = str + Acupoint1.StatuInfo + ":"; if (string.IsNullOrEmpty(Acupoint2.StatuInfo)) { Acupoint2.StatuInfo = " "; } str = str + Acupoint2.StatuInfo + ":"; if (string.IsNullOrEmpty(Acupoint1.StatuValue)) { Acupoint1.StatuValue = " "; } str = str + Acupoint1.StatuValue + ":"; if (string.IsNullOrEmpty(Acupoint2.StatuValue)) { Acupoint2.StatuValue = " "; } str = str + Acupoint2.StatuValue + ":"; return str; } #endregion #region 字符转颜色 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具) 5:红色(清理载具) /// /// 字符转颜色 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具) 5:红色(清理载具) /// /// /// private string StrToColor(string str) { string colorstr = ""; switch (str) { case "0": colorstr = ColorStr.Gray; break; case "1": colorstr = ColorStr.Blue; break; case "2": colorstr = ColorStr.Green; break; case "3": colorstr = ColorStr.Yellow; break; case "4": colorstr = ColorStr.White; break; case "5": colorstr = ColorStr.Red; break; default: colorstr = ColorStr.Gray; break; } return colorstr; } #endregion #region 颜色转字符 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具)5:红色(清理载具) /// /// 颜色转字符 0:灰色(无料) 1:蓝色(有料) 2:绿色(良品) 3:黄色(不良或未知)4:白色(无载具) 5:红色(清理载具) /// /// /// private string ColorToStr(string colorStr) { string str = 0.ToString(); if (colorStr == ColorStr.Gray) { str = 0.ToString(); } else if (colorStr == ColorStr.Blue) { str = 1.ToString(); } else if (colorStr == ColorStr.Green) { str = 2.ToString(); } else if (colorStr == ColorStr.Yellow) { str = 3.ToString(); } else if (colorStr == ColorStr.White) { str = 4.ToString(); } else if (colorStr == ColorStr.Red) { str = 5.ToString(); } else { str = 0.ToString(); } return str; } #endregion } }