public List <MixInfos> GroupList(List <MixInfos> list) { string s = DateTime.Now.ToString(); if (list != null) { List <MixInfos> temp = new List <MixInfos>(); MixInfos tempview = null; int count = 0; //定义pokelist的长度为混合道poke的个数 List <string> pokeidlist = new List <string>(); foreach (var item in list)//遍历取到的数据(名称、编码、通道号) { count++; if (tempview == null)//如果tempview没有数据 赋值当前遍历的值 { tempview = item; pokeidlist.Add(item.PokeID.ToString()); tempview.PokeIDList = pokeidlist; } else if (item.CigCode != tempview.CigCode)//如果当前遍历的数据的香烟编码不等于上一次遍历 { temp.Add(tempview); tempview = new MixInfos(); //存pokeid的集合 pokeidlist = new List <string>(); pokeidlist.Add(item.PokeID.ToString()); tempview.CigName = item.CigName; tempview.PokeNum = item.PokeNum; tempview.ThroughNum = item.ThroughNum; tempview.CigCode = item.CigCode; tempview.PokeIDList = pokeidlist; tempview.SortNum = item.SortNum; } else { pokeidlist.Add(item.PokeID.ToString()); tempview.PokeNum += item.PokeNum; //数量相加 // tempview.TROUGHNUM += item.TROUGHNUM;//将编码拼接 } if (count == list.Count) { temp.Add(tempview); tempview.PokeIDList = pokeidlist; } //if (temp.Count > 15)//如果连续品牌超过15 //{ // break; //} } string s2 = DateTime.Now.ToString(); WriteLog.GetLog().Write("组合开始时间" + s); WriteLog.GetLog().Write("组合完成时间" + s2); return(temp); } else { return(null); } }
void PullCigarette(string stri) { MixInfos info = MixedClass.GetMixCig2(machineSeq, groupNo, 0)[0]; WriteLog.GetLog().Write("扫到条码" + stri); if (info.CigCode.Trim().Contains(str) || info.CigCode.Trim() == str || info.CigCode.Trim().Substring(info.CigCode.Trim().Length - 7) == stri.Trim().Substring(info.CigCode.Trim().Length - 7) || info.CigCode.Trim().Contains(stri.Trim().Substring(info.CigCode.Trim().Length - 7))) { if (MixedClass.UpdatePullStatus2Put2(machineSeq, info.PokeID)) { WriteLog.GetLog().Write("<扫码放烟成功>"); GetData(); str = ""; } } else { WriteLog.GetLog().Write("放烟品牌错误:扫描到条码" + str[0]); MessageBox.Show("放烟错误,请重放" + str); str = ""; } }