/// <summary> /// 循环动作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tMain_Elapsed(object sender, EventArgs e) { tMain.Stop(); if (Golbal.DSStep == 0 && Golbal.WaterStep == 0) { if (Golbal.MyQueueList.Count > 0) { lock (Golbal.MyQueueList) { if (Golbal.MyQueueList.Count > 0) { View_FormulaInfoModel model = Golbal.MyQueueList[0]; Golbal.Excute(model, model.PotCode); } //foreach (View_FormulaInfoModel model in Golbal.MyQueueList) //{ // //foreach (DS_PotModel potModel in Golbal.potList.Where(s => s.DeviceId == model.DeviceId).ToList()) // //{ // // if (Golbal.ParamClass.IsAlarming(potModel.PotCode)) // // { // Golbal.Excute(model, model.PotCode); // // } // //} //} } } } tMain.Start(); }
//开始执行 public static void Excute(View_FormulaInfoModel model, string potCode) { DSStep = 1; WaterStep = 1; CurrentFormulaModel = model; CurrentPotCode = potCode; Golbal.CurrentPotName = potList.FirstOrDefault(s => s.PotCode == Golbal.CurrentPotCode).PotName; MaterialQueue.Clear(); decimal minus = 0; foreach (View_FormulaDetailInfoModel detailModel in model.list.OrderBy(s => s.Sort)) { DsMaterial dsmaterial = new DsMaterial(); dsmaterial.MaterialId = detailModel.MaterialId.ToString(); dsmaterial.MaterialCode = detailModel.MaterialCode; dsmaterial.MaterialName = detailModel.MaterialName; dsmaterial.MaterialQuantity = detailModel.MaterialQuantity; dsmaterial.Unit = detailModel.Unit; dsmaterial.Price = detailModel.Price.Value; MaterialQueue.Enqueue(dsmaterial); minus += dsmaterial.MaterialQuantity + IntervalWater; } CurrentCabinetWaterQuantity = model.Quantity - minus - CleanWater; formulaStatus.FormulaStart(ParamClass);//开始写入配方状态 0; }
public void AddPanel(View_FormulaInfoModel model) { Panel currentPanel = new Panel(); currentPanel.Dock = DockStyle.Top; currentPanel.Height = (int)this.Font.GetHeight() + 20; currentPanel.BackColor = Color.Transparent; currentPanel.BorderStyle = LabelBorderStyle; currentPanel.Tag = model.BarCode; this.Controls.Add(currentPanel); currentPanel.BringToFront(); if (!dcPanel.ContainsKey(model.BarCode)) { dcPanel.Add(model.BarCode, currentPanel); } for (int i = 0; i < 6; i++) { Label lbl = new Label(); lbl.Width = this.Width / 7 + 1; lbl.AutoSize = false; lbl.ForeColor = this.ForeColor; switch (i) { case 0: lbl.Text = model.BarCode; break; case 1: lbl.Text = model.DeviceName; break; case 2: lbl.Text = model.Customer; break; case 3: lbl.Text = model.ProductSpecification; break; case 4: lbl.Text = model.CylinderNum.ToString(); break; case 5: lbl.Text = model.CompleteCylinderNum.ToString(); break; } lbl.TextAlign = ContentAlignment.MiddleCenter; lbl.Dock = DockStyle.Left; lbl.Font = this.Font; lbl.BorderStyle = LabelBorderStyle; currentPanel.Controls.Add(lbl); lbl.BringToFront(); } ButtonEx btn = new ButtonEx(); btn.Text = "删除"; btn.Font = this.Font; btn.Click += btn_Click; btn.Dock = DockStyle.Left; btn.Width = this.Width / 7 + 1; btn.Tag = model.BarCode; currentPanel.Controls.Add(btn); btn.BringToFront(); }
private void DistributionRequest(string deviceCode, string id, string cylinderNum, string potcode, IPAddress remoteIP) { Guid gid; if (Guid.TryParse(id, out gid)) { View_FormulaInfoModel model = Golbal.MyQueueList.FirstOrDefault(s => s.DeviceCode == deviceCode); if (model != null) { tcpclass.SendString(remoteIP, "请稍后再试!"); } else { // ls[0]请求 ls[1] 机缸编号 ls[2] 配方Id ls[3] 请求量 DSW_FormulaDetailDAL formulaDetailDAL = new DSW_FormulaDetailDAL(); View_FormulaInfoModel formulaDetailModel = formulaDetailDAL.GetModelById(gid); if (formulaDetailModel != null) { formulaDetailModel.ClientIP = remoteIP.ToString(); formulaDetailModel.CylinderNum = int.Parse(cylinderNum); formulaDetailModel.list = formulaDetailDAL.GetFormulaDetailInfoList(formulaDetailModel.BarCode); if (formulaDetailModel.list == null) { tcpclass.SendString(remoteIP, "请求失败!"); } else { formulaDetailModel.PotCode = potcode; formulaDetailModel.CompleteCylinderNum = 0; //初始完成缸数 Golbal.MyQueueList.Add(formulaDetailModel); tcpclass.SendString(remoteIP, "请求成功!"); } } else { tcpclass.SendString(remoteIP, "配方无效!"); } } } else { tcpclass.SendString(remoteIP, "请求失败!"); } }
private void btnSure_Click(object sender, EventArgs e) { //if (combStandard.Text == "请选择") //{ // MessageBox.ShowTip("请选择标准配方"); return; //} //if (comboDevice.Text == "请选择") //{ // MessageBox.ShowTip("请选择机台"); return; //} View_DeviceInfoModel deviceModel = deviceInfoModelList.SingleOrDefault(s => s.PotCode == comboPot.SelectedValue.ToString()); View_FormulaInfoModel formulaDetailModel = new View_FormulaInfoModel(); DSW_FormulaStandardModel standardModel = standardModelList.SingleOrDefault(s => s.Id == new Guid(combStandard.SelectedValue.ToString())); formulaDetailModel.Id = Guid.NewGuid(); formulaDetailModel.BarCode = DateTime.Now.ToString("yyMMddHHmmss"); formulaDetailModel.Quantity = decimal.Parse(lblStandardQuantity.Text); formulaDetailModel.StandardQuantity = decimal.Parse(lblStandardQuantity.Text); formulaDetailModel.CylinderNum = 1; formulaDetailModel.DeviceId = deviceModel.DeviceId; formulaDetailModel.DeviceName = deviceModel.DeviceName; formulaDetailModel.DeviceType = deviceModel.Type; formulaDetailModel.PotCode = deviceModel.PotCode; formulaDetailModel.IsManualFeed = IsChecked; formulaDetailModel.Remark = standardModel.Remark; formulaDetailModel.ManufactureOrderId = Guid.Empty; formulaDetailModel.FormulaName = "手动配送"; formulaDetailModel.ManufactureOrderCode = "***"; formulaDetailModel.Customer = "***";; formulaDetailModel.Color = "***"; formulaDetailModel.ProductName = "***"; formulaDetailModel.ProductSpecification = "***"; formulaDetailModel.ProductWidth = "***"; formulaDetailModel.Meter = "***"; formulaDetailModel.LatestDate = DateTime.Now.AddYears(1); formulaDetailModel.Status = 0; formulaDetailModel.ClientIP = deviceModel.IP; formulaDetailModel.CompleteCylinderNum = 0; List <View_FormulaDetailInfoModel> list = new List <View_FormulaDetailInfoModel>(); for (int i = 0; i < dataView1.Rows.Count; i++) { DataGridViewRow dgvr = dataView1.Rows[i]; View_FormulaDetailInfoModel detailInfoModel = new View_FormulaDetailInfoModel(); detailInfoModel.Id = Guid.NewGuid(); detailInfoModel.BarCode = formulaDetailModel.BarCode; detailInfoModel.MaterialId = new Guid(dgvr.Cells["MaterialId"].Value.ToString()); detailInfoModel.MaterialName = dgvr.Cells["MaterialName"].Value.ToString(); detailInfoModel.MaterialCode = dgvr.Cells["MaterialCode"].Value.ToString(); detailInfoModel.MaterialQuantity = decimal.Parse(dgvr.Cells["MaterialQuantity"].Value.ToString()); detailInfoModel.Sort = i; detailInfoModel.Unit = dgvr.Cells["Unit"].Value.ToString(); detailInfoModel.Price = decimal.Parse(dgvr.Cells["Price"].Value.ToString()); detailInfoModel.DeviceId = deviceModel.Id; list.Add(detailInfoModel); } formulaDetailModel.list = list; if (formulaDetailModel.list.Count == 0) { MessageBox.ShowTip("请先添加助剂"); return; } decimal materialSum = list.Sum(s => s.MaterialQuantity); decimal minStandardQuantity = Golbal.CleanWater + Golbal.IntervalWater * dataView1.RowCount + materialSum; decimal maxStandardQuantity = deviceModel.StandardQuantity.Value; if (decimal.Parse(lblStandardQuantity.Text) < minStandardQuantity) { MessageBox.ShowTip("机台缸量不能小于" + minStandardQuantity + ""); return; } if (decimal.Parse(lblStandardQuantity.Text) > maxStandardQuantity) { MessageBox.ShowTip("机台缸量不能大于" + maxStandardQuantity + ""); return; } try { Golbal.MyQueueList.Add(formulaDetailModel); MessageBox.ShowTip("添加到队列成功"); } catch { MessageBox.ShowTip("添加到队列失败"); } }