//整盘出库 public bool PickMaterialAllOut(string locId, ref int result) //type=0,五合一条码,1=TrSn, 2=全盘出 { try { Trace.WriteLine("Debug:----PickMaterialAllOut Start----"); int res = DBPCaller.CompletePickMaterialByLocId(MyData.GetStationId(), MyData._lastArrive.stockno, locId, MyData.GetStockNoType()); Trace.WriteLine("Debug:----PickMaterialAllOut Stop----"); Log.Error("CompletePickMaterialByLocId返回:" + res); Trace.WriteLine("Debug: CompletePickMaterialByLocId返回:" + res); if (res == 0 || res == 1 || res == 2) { result = res; return(true); } else { ShowHint("CompletePickMaterialByLocId未定义的返回:" + res.ToString(), Color.Red); } return(false); } catch (Exception ex) { result = -99; Log.Error("CompletePickMaterialByLocId异常:" + ex.Message); ShowHint("CompletePickMaterialByLocId异常:" + ex.Message, Color.Red); return(false); } }
private bool UploadCheckData(int realqty, int realcount) { try { string locid = label_pd_locid.Text.Trim(); string kpno = label_pd_kpno.Text.Trim(); int qty = int.Parse(label_pd_qty.Text.Trim()); int count = int.Parse(label_pd_count.Text.Trim()); string plant = label_pd_plant.Text.Trim(); string stockid = label_pd_stockid.Text.Trim(); string res = DBPCaller.CompleteLocCheck(locid, kpno, qty, count, realqty, realcount, plant, stockid, MyData.GetUser(), MyData.GetStockNo()); if (res.ToUpper().Trim().Equals("OK")) { AddLog("绑定成功!"); return(true); } AddLog("绑定失败:" + res); ShowHint("绑定失败:CompleteLocCheck返回:" + res, Color.Red); return(false); } catch (Exception ex) { AddLog("绑定异常: " + ex.Message); ShowHint(ex.Message, Color.Red); return(false); } }
/* * 2: 入库成功,当前站点没有待入库的料号,但是其他站点有 * 1: 入库成功,所有站点都没有待入库的料号 * 0:入库成功,且当前站点还有未入库的料号 * -1:当前站点不存在对应任务,入库失败 */ private bool CompleteReplenishMaterial(int stationId, string locId, int holderId, string stockno, ref int result) { try { result = DBPCaller.CompleteReplenishMaterial(stationId, locId, holderId, stockno); Trace.WriteLine("Debug: CompleteReplenishMaterial return " + result); if (result == 0 || result == 1 || result == 2) { return(true); } else if (result == -2) { ShowHint("周转箱编号错误,请扫描正确的周转箱!", Color.Red); } else if (result == -1) { ShowHint("入库失败,当前站点不存在对应任务!请将周转箱取下!", Color.Red); } else { ShowHint("CompleteReplenishMaterial返回:" + result, Color.Red); } return(false); } catch (Exception ex) { ShowHint("CompleteReplenishMaterial:" + ex.Message, Color.Red); return(false); } }
private bool AgvLeave(int stationId) { try { int result = DBPCaller.AgvReturn(stationId); if (result == -3) { ShowHint("当前站点还有未完成拣选的出库物料", Color.Red); return(false); } else if (result == -2) { ShowHint("当前站点还有未完成拣选的入库物料", Color.Red); return(false); } else if (result == -1) { ShowHint("当前站点没有可用任务", Color.Red); return(false); } else { //ShowHint("小车离开成功", Color.Lime); ShowMessage("小车离开成功"); return(true); } } catch (Exception ex) { ShowHint("AgvReturn: " + ex.Message, Color.Red); return(false); } }
//进行一次查询 private void QueryShelfInformation() { try { DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); int cnt = 0; dt1 = DBPCaller.AtStationPod(MyData.GetStationId()); if (dt1 != null && dt1.Rows.Count > 0) { //打印货架信息 Trace.WriteLine("Debug: PodId=" + dt1.Rows[0]["PodId"].ToString() + ", PodName=" + dt1.Rows[0]["PodName"].ToString() + ", Row=" + dt1.Rows[0]["Row"].ToString() + ", Column=" + dt1.Rows[0]["Column"].ToString() ); dt2 = DBPCaller.PickAtStationLoc(MyData.GetStationId()); _dtShelf = dt2; if (dt2 != null && dt2.Rows.Count > 0) { //打印出货储位等信息 Trace.WriteLine("Debug: StockNo=" + dt2.Rows[0]["StockNo"].ToString() + ",ShowText=" + dt2.Rows[0]["ShowText"].ToString() + ",PodId=" + dt2.Rows[0]["PodId"].ToString() + ",PodSide=" + dt2.Rows[0]["PodSide"].ToString() + ",ShelfId=" + dt2.Rows[0]["ShelfId"].ToString() + ",BoxBarcode=" + dt2.Rows[0]["BoxBarcode"].ToString() + ",BoxId=" + dt2.Rows[0]["BoxId"].ToString() + ",MaterialId=" + dt2.Rows[0]["MaterialId"].ToString() + ",MaterialName=" + dt2.Rows[0]["MaterialName"].ToString() + ",Qty=" + dt2.Rows[0]["Qty"].ToString() + ",AllOut=" + dt2.Rows[0]["AllOut"].ToString() ); //cnt = GeTrSnCnt(dt2.Rows[0]["BoxBarcode"].ToString()); } if (runFlag) { RefreshPickUI(cnt, int.Parse(dt1.Rows[0]["Column"].ToString()), _dtShelf); } } else { if (runFlag) { RefreshPickUI(0, 0, null); } } } catch (Exception ex) { Log.Error("RefreshUI:" + ex.Message); Trace.WriteLine("Debug: QueryShelfInformation : " + ex.Message); } }
private void KeepAliveThread() { int i = 0; try { DBPCaller.InitReplenishProcess(MyData.GetUser(), MyData.GetStationId()); } catch (Exception ex) { ShowHint("InitReplenishProcess:" + ex.Message, Color.Red); } while (runFlag) { try { DBPCaller.KeepAlive(MyData.GetStationId()); } catch (Exception ex) { Log.Error("KeepAlive:" + ex.Message); } while (runFlag) { if (i < 30) { i++; } else { i = 0; break; } Thread.Sleep(100); } } try { DBPCaller.DeinitProcess(MyData.GetStationId()); } catch (Exception ex) { ShowHint("DeinitProcess:" + ex.Message, Color.Red); } }
public bool PartialPickMaterial(string locId, string barcode, ref int num, ref int result) //type=0,五合一条码,1=TrSn, 2=全盘出 { try { List <string> listTrSn = new List <string>(); string trSn = barcode; if (barcode.Contains("&")) { trSn = barcode.Split('&')[0]; } listTrSn.Add(trSn); Trace.WriteLine("Debug:----PartilPickMaterial Start----"); int res = DBPCaller.CompletePartialPickByTrSn(MyData.GetStationId(), MyData._lastArrive.stockno, locId, trSn, MyData.GetStockNoType(), ref num); Trace.WriteLine("Debug:----PartilPickMaterial Stop----"); Log.Error("CompletePartialPickByTrSn返回:" + res); Trace.WriteLine("Debug: CompletePartialPickByTrSn返回:" + res); if (res == 0 || res == 1 || res == 2 || res == 3) { result = res; return(true); } else { ShowHint("CompletePartialPickByTrSn未定义的返回:" + res.ToString(), Color.Red); } return(false); } catch (Exception ex) { result = -99; Log.Error("CompletePartialPickByTrSn异常,返回:" + ex.Message); ShowHint("CompletePartialPickByTrSn异常,返回:" + ex.Message, Color.Red); return(false); } }
//调用远端接口,判断条码类型,是储位编号还是物料条码 private bool CheckBarcode(string barcode, ref int type) { try { int result = DBPCaller.CheckBarcode(barcode); Trace.WriteLine("Debug: CheckBarcode return " + result); if (result == 1 /*储位编号*/ || result == 3 /*TR_SN*/) { type = result; return(true); } else if (result == 2) { ShowHint("扫入的是周转箱编号,请扫描正确的条码!", Color.Red); } else if (result == 4) { ShowHint("扫入的是出库单号,请扫描正确的条码!", Color.Red); } else if (result == 5) { ShowHint("扫入的是入库单号,请扫描正确的条码!", Color.Red); } else { ShowHint("未知条码,请扫正确的条码", Color.Red); } return(false); } catch (Exception ex) { Log.Error("CheckBarcode: " + ex.Message); ShowHint("CheckBarcode: " + ex.Message, Color.Red); return(false); } }
//调用远端接口,判断条码类型,是储位编号还是物料条码 private bool CheckBarcode(string barcode, ref int type) { try { int result = DBPCaller.CheckBarcode(barcode); if (result == 1 /*储位编号*/ || result == 2 /*周转箱*/) { type = result; return(true); } else if (result == 3) { ShowHint("扫入的是物料唯一条码,请扫正确的条码!", Color.Red); } else if (result == 4) { ShowHint("扫入的是出库单号,请扫描正确的条码!", Color.Red); } else if (result == 5) { ShowHint("扫入的是入库单号,请扫描正确的条码!", Color.Red); } else { ShowHint("未知条码,请扫正确的条码", Color.Red); } return(false); } catch (Exception ex) { Log.Error("CheckBarcode: " + ex.Message); ShowHint("CheckBarcode: " + ex.Message, Color.Red); return(false); } }
private bool CreateStockCountTask() { Dictionary <string, object> dic = new Dictionary <string, object>(); DataTable dt = new DataTable(); string date = string.Format("{0:D4}{1:D2}{2:D2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);; string plant = ""; string stock_id = ""; //string woid = ""; int qty = 0; try { SearchMaterialPickAssign sm = new SearchMaterialPickAssign(dic); sm.ExecuteQuery(); dt = sm.GetResult(); if (dt != null && dt.Rows.Count > 0) { date = dt.Rows[0]["StockOutNo"].ToString().Trim(); qty = int.Parse(dt.Rows[0]["Qty"].ToString().Trim()); if (qty != -1) { ShowHint("请先完成单号:" + woid + " 的出库任务", Color.Red); return(false); } } if (qty == -1) //存在盘点任务 { dic.Clear(); dic.Add("check_date", date); dic.Add("status", "0"); SearchInventoryCheckByMaterialNo sc = new SearchInventoryCheckByMaterialNo(dic); sc.ExecuteQuery(); dt = sc.GetResult(); if (dt != null && dt.Rows.Count > 0) { plant = dt.Rows[0]["Plant"].ToString(); stock_id = dt.Rows[0]["Stock_Id"].ToString(); string kpno = dt.Rows[0]["KpNo"].ToString(); if (kpno.Trim().Equals("*")) { ShowHint("请先完成:" + date + " 的全部盘点任务!", Color.Red); comboBox_pd.SelectedIndex = 1; } else { ShowHint("请先完成:" + date + " 的料号盘点任务!", Color.Red); comboBox_pd.SelectedIndex = 2; } } else { ShowHint("请先完成:" + date + " 的储位盘点任务!", Color.Red); comboBox_pd.SelectedIndex = 3; } return(true); } if (comboBox_pd.SelectedIndex == 0) { ShowHint("请选择一个盘点类型!", Color.Red); comboBox_pd.Focus(); return(false); } else if (comboBox_pd.SelectedIndex == 1) //全部盘点 { using (SetStockDate ss = new SetStockDate()) { if (ss.ShowDialog() != DialogResult.OK) { return(false); } date = ss.GetDate(); plant = ss.GetPlant(); stock_id = ss.GetStockId(); } } else if (comboBox_pd.SelectedIndex == 2)//料号盘点,导入数据 { using (ImportKpNoData ic = new ImportKpNoData()) { if (ic.ShowDialog() != DialogResult.OK) { return(false); } date = ic.GetWoId(); plant = ic.GetPlant(); stock_id = ic.GetStockId(); } //查询导入数据是否需要盘点,status=0 try { dic.Clear(); dic.Add("check_date", date); dic.Add("plant", plant); dic.Add("stock_id", stock_id); dic.Add("status", "0"); SearchInventoryCheckByMaterialNo sc = new SearchInventoryCheckByMaterialNo(dic); sc.ExecuteQuery(); dt = sc.GetResult(); if (dt == null || dt.Rows.Count == 0) { ShowHint("无料号需要盘点", Color.Red); return(false); } } catch (Exception ex) { ShowHint("SearchInventoryCheckByMaterialNo:" + ex.Message, Color.Red); return(false); } } else if (comboBox_pd.SelectedIndex == 3) { using (ImportLocIdData ic = new ImportLocIdData()) { if (ic.ShowDialog() != DialogResult.OK) { return(false); } date = ic.GetWoId(); plant = ic.GetPlant(); stock_id = ic.GetStockId(); } //查询导入数据是否需要盘点,status=0 try { dic.Clear(); dic.Add("check_date", date); dic.Add("plant", plant); dic.Add("stock_id", stock_id); dic.Add("status", "0"); SearchInventoryCheckByLocId sc = new SearchInventoryCheckByLocId(dic); sc.ExecuteQuery(); dt = sc.GetResult(); if (dt == null || dt.Rows.Count == 0) { ShowHint("无料号需要盘点", Color.Red); return(false); } } catch (Exception ex) { ShowHint("SearchInventoryCheckByLocId:" + ex.Message, Color.Red); return(false); } } //生成盘点任务 string result = DBPCaller.CreateCheckTask(date, comboBox_pd.SelectedIndex - 1); if (!result.ToUpper().Trim().Equals("OK")) { AddLog("生成任务失败:" + result); ShowHint("生成盘点任务失败:" + result, Color.Red); return(false); } AddLog("盘点日期:" + date); } catch (Exception ex) { ShowHint(ex.Message, Color.Red); return(false); } try { SearchTaskCount st = new SearchTaskCount(2, MyData.GetStationId()); st.ExecuteQuery(); int result = st.GetResult(); label_pd_ShelfCnt.Text = result.ToString(); if (result > 0) { AddLog("生成盘点任务成功!"); ShowHint("生成盘点任务成功!", Color.Lime); return(true); } else { AddLog("生成任务失败,不需要搬运货架!"); ShowHint("生成任务失败,不需要搬运货架!", Color.Red); return(false); } } catch (Exception ex) { ShowHint("获取货架数目异常: " + ex.Message, Color.Red); return(false); } }
private void button1_Click(object sender, EventArgs e) { _dic.Clear(); string station = ""; string type = ""; foreach (object obj in tableLayoutPanel2.Controls) { //判断控件类型 if ((obj as CheckBox) != null) //选中 { CheckBox cb = (CheckBox)obj; if (cb.Checked) { station = cb.Text.Replace("站点", "").Trim(); } else { station = ""; } } else if ((obj as ComboBox) != null) //出A材 { ComboBox cbb = (ComboBox)obj; if (!string.IsNullOrEmpty(station)) //站点选中 { if (cbb.SelectedIndex == 0) { type = "A"; } else { type = "-"; } if (_dic.ContainsKey(station)) { _dic[station] = type; } else { _dic.Add(station, type); } station = ""; type = ""; } } } if (_dic.Count == 0) { MessageBox.Show("请至少选择一个出库站点!"); return; } bool result = false; foreach (KeyValuePair <string, string> kv in _dic) { int cnt = GetTaskCnt(kv.Key); //查看其他站点是否有任务正在出库 if (cnt == -1) { return; //异常 } if (cnt > 0) { MessageBox.Show("站点" + kv.Key + "有任务正在出库!"); return; } if (kv.Value.Equals("A")) { result = true; break; } } if (!result) { MessageBox.Show("请至少选择一个站点出A材!"); return; } //设置其他站点状态 foreach (KeyValuePair <string, string> kv in _dic) { try { DBPCaller.DeinitProcess(int.Parse(kv.Key)); if (kv.Value.Contains("A")) { DBPCaller.InitPartialPickStation(MyData.GetUser(), int.Parse(kv.Key)); } else { DBPCaller.InitPickProcess(MyData.GetUser(), int.Parse(kv.Key)); } } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } //返回 this.DialogResult = DialogResult.OK; }
//进行一次查询 private void QueryShelfInformation() { try { DataTable dt1 = new DataTable(); DataTable dt2 = new DataTable(); Trace.WriteLine("Debug: ------AtStationPod Start------"); dt1 = DBPCaller.AtStationPod(MyData.GetStationId()); Trace.WriteLine("Debug: ------AtStationPod Stop------"); if (dt1 != null && dt1.Rows.Count > 0) { //打印货架信息 Trace.WriteLine("Debug: PodId=" + dt1.Rows[0]["PodId"].ToString() + ", PodName=" + dt1.Rows[0]["PodName"].ToString() + ", Row=" + dt1.Rows[0]["Row"].ToString() + ", Column=" + dt1.Rows[0]["Column"].ToString() ); Trace.WriteLine("Debug: ------PickAtStationLoc Start------"); dt2 = DBPCaller.ReplenishAtStationLoc(MyData.GetStationId()); Trace.WriteLine("Debug: ------PickAtStationLoc Stop------"); _dtShelf = dt2; if (_dtShelf != null && _dtShelf.Rows.Count > 0) { Trace.WriteLine("Debug: StockNo=" + _dtShelf.Rows[0]["StockNo"].ToString() + ", PodId=" + _dtShelf.Rows[0]["PodId"].ToString() + ", ShelfId=" + _dtShelf.Rows[0]["ShelfId"].ToString() + ", BoxId=" + _dtShelf.Rows[0]["BoxId"].ToString() + ", MaterialId=" + _dtShelf.Rows[0]["MaterialId"].ToString() + ", MaterialName=" + _dtShelf.Rows[0]["MaterialName"].ToString() + ", BoxBarcode=" + _dtShelf.Rows[0]["BoxBarcode"].ToString() + ", HoderId=" + _dtShelf.Rows[0]["HoderId"].ToString() + ", PodSide=" + _dtShelf.Rows[0]["PodSide"].ToString() ); } if (runFlag) { Trace.WriteLine("Debug: ------RefreshUI Ready Start------"); RefreshUI(int.Parse(dt1.Rows[0]["Row"].ToString()), int.Parse(dt1.Rows[0]["Column"].ToString()), _dtShelf); Trace.WriteLine("Debug: ------RefreshUI Ready Stop------"); } } else { if (runFlag) { Trace.WriteLine("Debug: ------RefreshUI Ready Start------"); RefreshUI(0, 0, null); Trace.WriteLine("Debug: ------RefreshUI Ready Stop------"); } } } catch (Exception ex) { Log.Error("RefreshUI:" + ex.Message); //ShowHint("RefreshUI:" + ex.Message, Color.Red); } }