/// <summary> /// 更新格口与邮寄方式地区的关联 /// </summary> /// <param name="latticesetting"></param> /// <param name="posttypeslist"></param> internal void UpdateSolutionPostArea(LatticeSetting latticesetting, List <PostArea> postArealist, string PostTypeId) { try { var newData = (from pt in postArealist select new SolutionPostArea { ID = Guid.NewGuid().ToString(), SortingSolutionId = _sortingSolution, Type = pt.Type, Area = pt.Area, Flag = pt.Flag, PostTypeId = pt.PostTypeId, LactticeSettingId = latticesetting.ID, CabinetId = latticesetting.CabinetId }); using (var db = new OrderSortingDBEntities()) { var oldData = db.SolutionPostArea.Where(sp => sp.LactticeSettingId == latticesetting.ID && sp.CabinetId == latticesetting.CabinetId && sp.PostTypeId == PostTypeId && sp.SortingSolutionId == _sortingSolution); db.SolutionPostArea.RemoveRange(oldData); db.SolutionPostArea.AddRange(newData); db.SaveChanges(); } } catch (Exception) { throw; } finally { _solutionPostAreaList = GetSolutionPostAreaList(); } }
/// <summary> /// 更新格口与邮寄方式的关联 /// </summary> /// <param name="latticesetting">格口信息</param> /// <param name="posttypesList">邮寄方式</param> internal void UpdateSolutionPostType(LatticeSetting latticesetting, List <Posttypes> posttypeslist) { try { var newData = (from pt in posttypeslist select new SolutionPostType { Id = Guid.NewGuid().ToString(), SortingSolutionId = _sortingSolution, CabinetId = latticesetting.CabinetId, LatticeSettingId = latticesetting.ID, PostTypeId = pt.PostID, PostTypeName = pt.CnPostName, }); using (var db = new OrderSortingDBEntities()) { var oldData = db.SolutionPostType.Where(sp => sp.LatticeSettingId == latticesetting.ID && sp.SortingSolutionId == _sortingSolution); db.SolutionPostType.RemoveRange(oldData); db.SolutionPostType.AddRange(newData); db.SaveChanges(); } } catch (Exception) { throw; } finally { _solutionPostTypeList = GetSolutionPostTypeList(); } }
/// <summary> /// 更新格口与国家地区的关联 /// </summary> /// <param name="latticesetting">格口信息</param> /// <param name="countrysList">国家地区</param> internal void UpdateSolutionCountry(LatticeSetting latticesetting, List <Countrys> countrysList) { try { var newData = (from pt in countrysList select new SolutionCountry { Id = Guid.NewGuid().ToString(), SortingSolutionId = _sortingSolution, CabinetId = latticesetting.CabinetId, LatticeSettingId = latticesetting.ID, CountryId = pt.ID, CountryName = pt.CnName }); using (var db = new OrderSortingDBEntities()) { var oldData = db.SolutionCountry.Where(sp => sp.LatticeSettingId == latticesetting.ID && sp.SortingSolutionId == _sortingSolution); db.SolutionCountry.RemoveRange(oldData); db.SolutionCountry.AddRange(newData); db.SaveChanges(); } } catch (Exception) { throw; } finally { _solutionCountryList = GetSolutionCountryList(); } }
private OrderSortingLog NewOrderSortingLog(OrderInfo info, LatticeSetting targetLattice, LatticeSetting resultLattice, UserInfo userInfo, int operationType, int status) { var sortingLog = new OrderSortingLog() { ID = Guid.NewGuid().ToString(), OrderId = info.OrderId, TargetCabinetId = targetLattice.CabinetId.ToString(), TargetLatticeId = targetLattice.LatticeId, ResultCabinetId = "", ResultLatticeId = "", OperationType = operationType, OperationTime = DateTime.Now, Status = status, UserId = userInfo.UserId, UserName = userInfo.UserName, Weight = info.Weight }; if (resultLattice != null) { sortingLog.ResultCabinetId = resultLattice.CabinetId.ToString(); sortingLog.ResultLatticeId = resultLattice.LatticeId; } return(sortingLog); }
/// <summary> /// 断电恢复 /// </summary> private void RestoringFromPowerOff() { try { //获取最新的一条分拣记录 var log = OrderSortService.GetTheLastOrderSortingLog(); if (log != null && log.Status == 3) { switch (log.Status) { case 3: //3投递异常 Invoke((MethodInvoker) delegate() { //目标柜格,亮绿灯 _TargetLattice = _LatticesettingList.Find(s => s.CabinetId == Convert.ToInt32(log.TargetCabinetId) && s.LatticeId == log.TargetLatticeId); if (OrderSortService.SetLED(_TargetLattice, 0)) { _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(0); } //投入柜格,亮红灯 _ResultLattice = _LatticesettingList.Find(s => s.CabinetId == Convert.ToInt32(log.ResultCabinetId) && s.LatticeId == log.ResultLatticeId); if (OrderSortService.SetLED(_ResultLattice, 1)) { _ButtonList.FirstOrDefault(b => b.TabIndex == _ResultLattice.ID).BackColor = GetColor(1); } lblOrderId.Text = log.OrderId; _TargetLattice = null; _IsError = true; }); break; case 4: //4重复扫描 Invoke((MethodInvoker) delegate() { _LastSuccessOrderId = log.OrderId; _LastOrderId = string.Empty; //目标柜格,亮绿灯 _TargetLattice = _LatticesettingList.Find(s => s.CabinetId == Convert.ToInt32(log.TargetCabinetId) && s.LatticeId == log.TargetLatticeId); OrderSortService.SetLED(_TargetLattice, 1); //准备进行重复扫描异常处理 _LatticeOrdersList = OrderSortService.GetLatticeOrdersListByLatticesettingId(_TargetLattice.ID); if (_LatticeOrdersList != null && _LatticeOrdersList.Count > 0) { _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(1); _IsRepeatError = true; _TargetLattice = null; _IsError = true; return; } }); break; } } } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); MessageBox.Show(ex.Message); } }
protected new PackingLog NewPackingLog(LatticeSetting lattice, UserInfo userInfo, int operationType, List <LatticeOrdersCache> logList, decimal boxWeight) { string PackNumber = API_Helper.GetFlytPackageLabelIDBySingleFlyt(); var pkgLog = new PackingLog() { ID = Guid.NewGuid().ToString(), PackNumber = PackNumber, CabinetId = "", LatticeId = "", OrderIds = string.Join(",", logList.Select(l => l.OrderId)), OrderQty = logList.Count, Weight = boxWeight + logList.Sum(o => o.Weight), OperationType = operationType, OperationTime = DateTime.Now, UserId = userInfo.UserId, UserName = userInfo.UserName }; if (lattice != null) { pkgLog.CabinetId = lattice.CabinetId.ToString(); pkgLog.LatticeId = lattice.LatticeId; } pkgLog.PostTypeIds = string.Join(",", logList.Select(l => l.PostId).Distinct()); var postTypeNames = logList.Select(l => l.PostName).Distinct(); pkgLog.PostTypeNames = postTypeNames.Count() > 2 ? "MIX" : string.Join(",", postTypeNames); pkgLog.CountryIds = string.Join(",", logList.Select(s => s.CountryId).Distinct()); var countryNames = logList.Select(s => s.CountryName).Distinct(); pkgLog.CountryNames = countryNames.Count() > 2 ? "MIX" : string.Join(",", countryNames); return(pkgLog); }
/// <summary> /// 设置定时器的启用停用 /// </summary> /// <param name="isEnabled"></param> private void SetTimerEnabled(bool isEnabled) { try { this.CheckGratingTimer.Enabled = isEnabled; this.CheckButtonTimer.Enabled = isEnabled; this.CheckBlockTimer.Enabled = isEnabled; this.CheckUnblockTimer.Enabled = isEnabled; txtOrderId.Enabled = isEnabled; txtOrderId.Focus(); lblOrderId.Text = isEnabled ? "" : "停止分拣"; if (!isEnabled) { _ButtonList.ForEach(b => b.BackColor = GetColor(3)); _TargetLattice = null; _ResultLattice = null; _BlockLattice = null; _IsBlocked = false; _ButtonLattice = null; _Orderinfo = null; _IsCheckButtonRunning = false; _CheckBlockNumber = 0; _CheckUnblockNumber = 0; _IsRepeatError = false; } } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); MessageBox.Show(ex.Message); } }
private void 全部清除重扫ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("请先把分拣架内的货物全部取回!") != DialogResult.OK) { return; } //Task.Run(() => //{ OrderSortService.ClearLatticeOrdersCache(); OrderSortService.ReSetGratingOrButton(3); OrderSortService.ReSetLED(); OrderSortService.ReSetWarningLight(); //按钮颜色恢复 _ButtonList.ForEach(b => b.BackColor = GetColor(3)); _TargetLattice = null; _ResultLattice = null; _BlockLattice = null; _IsBlocked = false; _ButtonLattice = null; _Orderinfo = null; _IsCheckButtonRunning = false; _CheckBlockNumber = 0; _CheckUnblockNumber = 0; _IsRepeatError = false; _IsCheckGratingRunning = false; _IsCheckUnblockRunning = false; _IsCheckBlockRunning = false; _IsError = false; //Invoke((MethodInvoker)delegate () { ResetLabelTest(); }); ResetLabelTest(); //}); }
public void SetLED(LatticeSetting lattice, ushort value) { var address = modbus.ButtonStartAddress + lattice.ButtonIndex; ushort[] data = { value }; WriteRegisters((ushort)address, data); }
/// <summary> /// 根据订单号获取订单信息,并获取目标格口 /// </summary> private bool CheckOrderinfo(string orderid) { var msg = string.Empty; //根据订单号获取订单信 _Orderinfo = OrderSortService.GetOrderInfoById(orderid, _UserInfo, ref msg); if (!string.IsNullOrWhiteSpace(msg)) { ResetLabelTest(); lblMsg.Text = string.Format("获取订单数据:{0}失败,{1}", orderid, msg); return(false); } //获取目标格口 _TargetLattice = OrderSortService.GetLatticeSettingByOrderinfo(_Orderinfo); if (_TargetLattice == null) { ResetLabelTest(); lblMsg.Text = string.Format("获取目标格口信息失败,订单号:{0}", orderid); return(false); } //判断格口是否已满 if (OrderSortService.IsFullLattice(_TargetLattice.ID)) { int cabinetId = _TargetLattice.CabinetId; int index = _TargetLattice.LEDIndex; _TargetLattice = null; OrderSortService.SetLED(cabinetId, index, 1); Thread.Sleep(500); OrderSortService.SetLED(cabinetId, index, 3); lblMsg.Text = string.Format("格口:{0} 已满", _TargetLattice.CabinetId); return(false); } return(true); }
public override string CreateButtonText(LatticeSetting ls) { if (!ls.IsEnable.Equals("true", StringComparison.CurrentCultureIgnoreCase)) { return("未启用"); } var str = string.Join(",", solutionPostTypeList.Where(spt => spt.LatticeSettingId == ls.ID).Select(s => s.PostTypeName)); if (str.Length > 25) { str = str.Substring(0, 25) + ".."; } string value = string.Format("格号:{0}\r\n渠道:{1}", ls.LatticeId, str); var PostArea = string.Join(",", solutionPostAreaList.Where(sp => sp.LactticeSettingId == ls.ID).Select(o => o.Area)); if (!string.IsNullOrWhiteSpace(PostArea)) { if (value.Length > 25) { value = value.Substring(0, 25) + ".."; } value += string.Format("\r\n 地区:{0}", PostArea); } return(value); }
/// <summary> /// 创建装箱记录(operationType:1自动满格,2手动满格,3打印包牌号) /// </summary> /// <param name="lattice">柜格</param> /// <param name="userInfo">用户信息</param> /// <param name="boxWeight">箱子重量</param> /// <param name="operationType">操作类型:1自动满格,2手动满格,3打印包牌号</param> /// <returns></returns> internal override PackingLog CreatePackingLog(LatticeSetting lattice, UserInfo userInfo, decimal boxWeight, out List <LatticeOrdersCache> LatticeOrdersCacheList, int operationType = 3) { Debug.WriteLine("CreatePackingLog begin 2"); using (var db = new OrderSortingDBEntities()) { var logCache = db.LatticeOrdersCache.Where(o => o.LatticesettingId == lattice.ID); if (logCache == null || logCache.Count() < 1) { LatticeOrdersCacheList = null; return(null); } var logList = logCache.ToList(); LatticeOrdersCacheList = logList; PackingLog pkgLog = NewPackingLog(lattice, userInfo, operationType, logList, boxWeight); db.PackingLog.Add(pkgLog); db.LatticeOrdersCache.RemoveRange(logList); var response = API_Helper.BatchOutbound(userInfo, pkgLog, logList); if (response != null && !response.Success && !string.IsNullOrWhiteSpace(response.Message)) { throw new Exception(response.Message); } db.SaveChanges(); return(pkgLog); } }
/// <summary> /// 检查分拣架后的按钮是否有按压动作 /// </summary> /// <returns></returns> private Task CheckButtonAsync() { return(Task.Run(() => { try { if (IsCheckButtonSuspending) { return; } _IsCheckButtonRunning = true; foreach (var slave in _SlaveConfig) { var registersButton = OrderSortService.ReadButtonRegisters(slave.SlaveAddress); for (int i = 0; i < registersButton.Length; i++) { //是否有点击按钮 if (registersButton[i] < 15) { continue; } _ButtonLattice = _LatticesettingList.Find(lsc => lsc.CabinetId == slave.CabinetId && lsc.ButtonIndex == i); //创建打包记录 var packingLog = OrderSortService.CreatePackingLog(_ButtonLattice, _UserInfo, 3); if (packingLog != null) { //打印包牌 new PackingLabelPrintDocument().PrintSetup(packingLog); //按钮颜色恢复 //_ButtonList.ForEach(b => b.BackColor = GetColor(3)); Invoke((MethodInvoker) delegate() { //更新格口统计信息 _ButtonList.FirstOrDefault(b => b.TabIndex == _ButtonLattice.ID).Text = OrderSortService.GetLatticeNewText(_ButtonLattice); }); //_TargetLattice = null; _ResultLattice = null; _BlockLattice = null; _ButtonLattice = null; _CheckBlockNumber = 0; } //重置按钮计数器 OrderSortService.ReSetGratingOrButton(2); return; } } } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); MessageBox.Show(ex.Message); } finally { _IsCheckButtonRunning = false; } })); }
/// <summary> /// 获取界面格口按钮的定位和大小属性 /// </summary> /// <param name="ls">格口设置信息</param> /// <returns></returns> private ButtonPointModel CreateButtonPointModel(LatticeSetting ls) { return(new ButtonPointModel() { LatticesettingId = ls.ID, ButtonLocation = new Point(_sizeContext.X, _sizeContext.Y), ButtonSize = new Size(_sizeContext.BtnWidth, _sizeContext.BtnHeight), ButtonFont = new Font("微软雅黑", _sizeContext.EmSize, FontStyle.Bold, GraphicsUnit.Point, 134) }); }
/// <summary> /// 创建界面格口按钮 /// </summary> /// <param name="ls">格口设置信息</param> /// <returns></returns> private Button CreateButton(LatticeSetting ls) { return(new Button() { Name = ls.ID.ToString(), //button的命名 TabIndex = ls.ID, //按下tab的切换顺序索引 Text = GetLatticeNewText(ls), //button中text所显示的内容 Location = new Point(_sizeContext.X, _sizeContext.Y), Size = new Size(_sizeContext.BtnWidth, _sizeContext.BtnHeight), Font = new Font("微软雅黑", _sizeContext.EmSize, FontStyle.Bold, GraphicsUnit.Point, 134) }); }
/// <summary> /// 针对阻挡的格口,检测对应光栅是否有感应到有物体阻挡,如果连续两次没有感应到阻挡,则解除警报 /// </summary> private Task CheckUnblockAsync() { return(Task.Run(() => { try { if (IsCheckUnblockSuspending) { return; } _IsCheckUnblockRunning = true; if (_CheckUnblockNumber < 1) { _CheckUnblockNumber++; OrderSortService.ReSetGratingOrButton(1); return; } var registersGrating = OrderSortService.ReadGratingRegisters(_SlaveConfig.Find(sc => sc.CabinetId == _BlockLattice.CabinetId).SlaveAddress); if (registersGrating[_BlockLattice.GratingIndex] > 1) { OrderSortService.ReSetGratingOrButton(1); return; } _CheckUnblockNumber++; if (_CheckUnblockNumber > 1) { if (OrderSortService.ReSetLED()) { OrderSortService.ReSetWarningLight(); //_TargetLattice = null; _ResultLattice = null; _BlockLattice = null; _IsError = false; _IsBlocked = false; //按钮颜色恢复 _ButtonList.ForEach(b => b.BackColor = GetColor(3)); Invoke((MethodInvoker) delegate() { ResetLabelTest(); }); OrderSortService.ReSetGratingOrButton(1); } } } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); } finally { _IsCheckUnblockRunning = false; } })); }
public override string CreateButtonText(LatticeSetting ls) { if (!ls.IsEnable.Equals("true", StringComparison.CurrentCultureIgnoreCase)) { return("未启用"); } var str = string.Join(",", solutionCountryList.Where(spt => spt.LatticeSettingId == ls.ID).Select(s => s.CountryName)); if (str.Length > 25) { str = str.Substring(0, 25) + ".."; } return(string.Format("格号:{0}\r\n地区:{1}", ls.LatticeId, str)); }
/// <summary> /// 保存格口设置信息 /// </summary> /// <param name="latticesetting"></param> internal void SaveLatticeSetting(LatticeSetting latticesetting) { try { using (var db = new OrderSortingDBEntities()) { db.LatticeSetting.AddOrUpdate(latticesetting); db.SaveChanges(); } } catch (Exception) { throw; } }
/// <summary> /// 创建装箱记录(operationType:1自动满格,2手动满格,3打印包牌号) /// </summary> /// <param name="lattice">柜格</param> /// <param name="userInfo">用户信息</param> /// <param name="boxWeight">箱子重量</param> /// <param name="operationType">操作类型:1自动满格,2手动满格,3打印包牌号</param> /// <returns></returns> internal PackingLog CreatePackingLog(LatticeSetting lattice, UserInfo userInfo, decimal boxWeight, out List <LatticeOrdersCache> latticeInfo, int operationType = 3) { try { Debug.WriteLine("CreatePackingLog begin"); return(_centerContext.CreatePackingLog(lattice, userInfo, boxWeight, out latticeInfo, operationType)); } catch (Exception ex) { throw; } finally { //重新统计分拣信息 LoadTotalSortingDataList(); } }
public override string CreateButtonText(LatticeSetting ls) { string result = ""; if (!ls.IsEnable.Equals("true", StringComparison.CurrentCultureIgnoreCase)) { return("未启用"); } var soulutionZipType = curSolutionZipTypeList.Find(spt => spt.LatticeSettingId == ls.ID); result += string.Format("格号:{0}\r\n渠道:{1}", ls.LatticeId, soulutionZipType?.PostTypeName ?? ""); if (!string.IsNullOrEmpty(soulutionZipType?.ZipName)) { result += string.Format("\r\n地区:{1}", ls.LatticeId, soulutionZipType.ZipName); } return(result); }
/// <summary> /// 获取(要显示到分拣作业窗体按钮上的)格口信息 /// </summary> /// <param name="ls">格口设置信息</param> /// <returns></returns> internal string GetLatticeNewText(LatticeSetting ls) { try { //获取格口信息 var text = _sortingPattenWorker.CreateButtonText(ls); //获取统计信息 var total = _totalTotalSortingDataList.FirstOrDefault(tsd => tsd.LatticesettingId == ls.ID); if (total != null) { text += Environment.NewLine + string.Format("数量:{0}\r\n重量:{1}Kg", total.TotalNum, _boxWeight + total.TotalWeight); } return(text); } catch (Exception) { throw; } }
/// <summary> /// 创建分拣记录 /// </summary> /// <param name="info">订单信息</param> /// <param name="targetLattice">目标柜格</param> /// <param name="resultLattice">投入柜格</param> /// <param name="operationType">操作类型:1扫描,2投递,3异常恢复</param> /// <param name="status">状态:1待投递,2已投递,3投递异常,4重复扫描</param> internal bool CreateOrderSortingLog(OrderInfo info, LatticeSetting targetLattice, LatticeSetting resultLattice, UserInfo userInfo, int operationType, int status) { try { //记录分拣日志 OrderSortingLog sortingLog = NewOrderSortingLog(info, targetLattice, resultLattice, userInfo, operationType, status); using (var db = new OrderSortingDBEntities()) { db.OrderSortingLog.Add(sortingLog); //正确投入,计数 if (status == 2 && !db.LatticeOrdersCache.Any(o => o.OrderId == info.OrderId)) { var countryEnName = db.Countrys.Where(cntr => cntr.ID == info.CountryId || cntr.EnShorting == info.CountryId).Select(cnt => cnt.EnName).FirstOrDefault(); db.LatticeOrdersCache.Add(new LatticeOrdersCache() { LatticesettingId = resultLattice.ID, OrderId = info.OrderId, TraceId = info.TraceId, Weight = info.Weight, CountryId = info.CountryId, CountryName = countryEnName, PostId = info.PostId, PostName = info.PostName }); db.SaveChanges(); //重新统计分拣信息 LoadTotalSortingDataList(db); } else { db.SaveChanges(); } return(true); } } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); return(false); } }
/// <summary> /// 创建装箱记录(operationType:1自动满格,2手动满格,3打印包牌号) /// </summary> /// <param name="lattice">柜格</param> /// <param name="userInfo">用户信息</param> /// <param name="boxWeight">箱子重量</param> /// <param name="operationType">操作类型:1自动满格,2手动满格,3打印包牌号</param> /// <returns></returns> internal override PackingLog CreatePackingLog(LatticeSetting lattice, UserInfo userInfo, decimal boxWeight, out List <LatticeOrdersCache> latticeInfo, int operationType = 3) { Debug.WriteLine("CreatePackingLog begin 1"); using (var db = new OrderSortingDBEntities()) { var logCache = db.LatticeOrdersCache.Where(o => o.LatticesettingId == lattice.ID); if (logCache == null || logCache.Count() < 1) { latticeInfo = null; return(null); } var logList = logCache.ToList(); latticeInfo = logList; PackingLog pkgLog = NewPackingLog(lattice, userInfo, operationType, logList, boxWeight); db.PackingLog.Add(pkgLog); db.LatticeOrdersCache.RemoveRange(logList); db.SaveChangesAsync(); return(pkgLog); } }
//private void InitializeControl() //{ // statusList = new List<KeyValuePair<int, string>>(); // //初始化问题类型选项 // var enumArray = Enum.GetValues(typeof(SystemSetting_Status_Enum)); // foreach (var enumItem in enumArray) // { // statusList.Add(new KeyValuePair<int, string>((int)enumItem, enumItem.ToString())); // } // cbStatus.DataSource = statusList; // cbStatus.DisplayMember = "Value"; // cbStatus.ValueMember = "Key"; // cbStatus.SelectedValue = 0; //} private void frmLatticeSettingEdit_Load(object sender, EventArgs e) { try { //lattice _latticesetting = OrderSortService.GetLatticeSettingById(_latticesettingId); txtCabinetId.Text = _latticesetting.CabinetId.ToString(); txtLatticeId.Text = _latticesetting.LatticeId; //cbStatus.SelectedValue = _latticesetting.Status; txtLEDIndex.Text = _latticesetting.LEDIndex.ToString(); txtGratingIndex.Text = _latticesetting.GratingIndex.ToString(); txtButtonIndex.Text = _latticesetting.ButtonIndex.ToString(); txt_PrintNum.Text = (_latticesetting.PrintNum ?? 1).ToString(); cbIsEnable.Checked = Convert.ToBoolean(_latticesetting.IsEnable); switch (OrderSortService.GetSortingPatten()) { case 1: LoadSolutionPostType(); break; case 2: LoadSolutionCountry(); break; case 3: LoadSolutionPostType(); LoadSolutionCountry(); break; default: break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void 格口设置_Load(object sender, EventArgs e) { ls = OrderSortService.GetLatticeSettingById(_latticesettingId); sz = OrderSortService.GetSolutionZipType(_latticesettingId); cbIsEnable.Checked = Convert.ToBoolean(ls.IsEnable); var qu8Array = Enum.GetValues(typeof(qu8_Enum)); List <KeyValuePair <int, string> > qu8List = new List <KeyValuePair <int, string> >(); foreach (var enumItem in qu8Array) { qu8List.Add(new KeyValuePair <int, string>((int)enumItem, enumItem.ToString())); } cmb_qu.DataSource = qu8List; cmb_qu.DisplayMember = "Value"; cmb_qu.ValueMember = "Key"; cmb_qu.SelectedValue = 0; cmb_qu.SelectedValue = qu8List.Find(o => o.Value == sz?.ZipName).Key; //渠道初始化 txtPostTypeId.Text = sz?.PostTypeId ?? ""; txtPostTypes.Text = sz?.PostTypeName ?? ""; SettingQu(); }
/// <summary> /// 判断光栅是否遇到阻挡,如果一个格口连续2次检测到阻挡,则警告提示 /// </summary> private Task CheckBlockAsync() { return(Task.Run(() => { try { if (IsCheckBlockSuspending) { return; } _IsCheckBlockRunning = true; foreach (var slave in _SlaveConfig) { var registersGrating = OrderSortService.ReadGratingRegisters(slave.SlaveAddress); for (int gratingIndex = 0; gratingIndex < registersGrating.Length; gratingIndex++) { //是否有阻挡 if (registersGrating[gratingIndex] < 1) { //未扫描且投递 if (!_IsCheckGratingRunning && _CheckBlockNumber >= 1 && _BlockLattice != null && _BlockLattice.CabinetId == slave.CabinetId && _BlockLattice.GratingIndex == gratingIndex) { _IsNotScanAndPut = true; if (OrderSortService.SetLED(_BlockLattice, 1)) { OrderSortService.SetWarningLight(4, 1); _ButtonList.FirstOrDefault(b => b.TabIndex == _BlockLattice.ID).BackColor = GetColor(1); Invoke((MethodInvoker) delegate() { frmMessage frmMessage = new frmMessage("请先扫描后再投递!"); DialogResult result = frmMessage.ShowDialog(); if (result == DialogResult.OK) { _IsNotScanAndPut = false; txtOrderId.Focus(); if (OrderSortService.SetLED(_BlockLattice, 3)) { OrderSortService.ReSetWarningLight(); OrderSortService.ReSetGratingOrButton(1); _ButtonList.FirstOrDefault(b => b.TabIndex == _BlockLattice.ID).BackColor = GetColor(3); _CheckBlockNumber = 0; _BlockLattice = null; } } }); } } continue; } if (_BlockLattice == null || _CheckBlockNumber < 2) { if (registersGrating[gratingIndex] > 10) { if (_BlockLattice != null && _BlockLattice.CabinetId == slave.CabinetId && _BlockLattice.GratingIndex == gratingIndex) { _CheckBlockNumber++; } else { _CheckBlockNumber = 1; _BlockLattice = _LatticesettingList.FirstOrDefault(s => s.CabinetId == slave.CabinetId && s.GratingIndex == gratingIndex && s.IsEnable.Equals("true", StringComparison.CurrentCultureIgnoreCase)); if (_BlockLattice == null) { continue; } } } OrderSortService.ReSetGratingOrButton(1); } else { if (_BlockLattice.CabinetId == slave.CabinetId && _BlockLattice.GratingIndex == gratingIndex) { _IsBlocked = true; //闪红灯 if (OrderSortService.SetLED(_BlockLattice, 2)) { OrderSortService.SetWarningLight(4, 1); _CheckBlockNumber = 0; //按钮变黄 _ButtonList.FirstOrDefault(b => b.TabIndex == _BlockLattice.ID).BackColor = GetColor(2); Invoke((MethodInvoker) delegate() { lblMsg.Text = string.Format("{0}柜{1}已满格!", _BlockLattice.CabinetId, _BlockLattice.LatticeId); lblOrderId.Text = string.Format("{0}柜{1}已满格!", _BlockLattice.CabinetId, _BlockLattice.LatticeId); }); } } } return; } } } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); } finally { _IsCheckBlockRunning = false; } })); }
/// <summary> /// 检查光栅状态,检查每一个格口是否有物体通过 /// </summary> private Task CheckGratingAsync() { return(Task.Run(() => { try { if (IsCheckGratingSuspending) { return; } _IsCheckGratingRunning = true; if (_SlaveConfig == null) { SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:_SlaveConfig为Null"); } foreach (var slave in _SlaveConfig) { var registersGrating = OrderSortService.ReadGratingRegisters(slave.SlaveAddress); if (registersGrating == null) { SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:registersGrating为Null"); continue; } if (_TargetLattice == null) { SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:_TargetLattice为Null"); continue; } for (int i = 0; i < registersGrating.Length; i++) { //是否有包裹投入 if (registersGrating[i] < 1) { continue; } //投放错误 if (_TargetLattice.GratingIndex != i || slave.CabinetId != _TargetLattice.CabinetId) { if (_LatticesettingList == null) { SaveErrLogHelper.SaveErrorLog(string.Empty, "检查光栅状态时出现异常:_LatticesettingList为Null"); } _ResultLattice = _LatticesettingList.Find(lsc => lsc.GratingIndex == i && lsc.CabinetId == slave.CabinetId); //创建分拣记录 if (OrderSortService.CreateOrderSortingLog(_Orderinfo, _TargetLattice, _ResultLattice, _UserInfo, 2, 3)) { OrderSortService.SetWarningLight(4, 1); //亮红灯 OrderSortService.SetLED(_ResultLattice, 1); _LastOrderId = string.Empty; _TargetLattice = null; _BlockLattice = null; //按钮变红色 //_buttonList.ForEach(b => b.BackColor = GetColor(3)); _ButtonList.FirstOrDefault(b => b.TabIndex == _ResultLattice.ID).BackColor = GetColor(1); Invoke((MethodInvoker) delegate() { lblMsg.Text = "投放错误"; }); } } else { //创建分拣记录 if (OrderSortService.CreateOrderSortingLog(_Orderinfo, _TargetLattice, _TargetLattice, _UserInfo, 2, 2)) { OrderSortService.ReSetLED(); OrderSortService.ReSetWarningLight(); _LastSuccessOrderId = _Orderinfo.OrderId; Invoke((MethodInvoker) delegate() { //更新格口统计信息 _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).Text = OrderSortService.GetLatticeNewText(_TargetLattice); }); if (OrderSortService.IsFullLattice(_TargetLattice.ID)) { int cabinetId = _TargetLattice.CabinetId; int index = _TargetLattice.LEDIndex; OrderSortService.SetLED(cabinetId, index, 1); Thread.Sleep(500); OrderSortService.SetLED(cabinetId, index, 3); } _LastOrderId = string.Empty; _ResultLattice = null; _BlockLattice = null; _TargetLattice = null; //按钮颜色恢复 _ButtonList.ForEach(b => b.BackColor = GetColor(3)); Invoke((MethodInvoker) delegate() { ResetLabelTest(); }); OrderSortService.ReSetGratingOrButton(1); } } } } } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); } finally { _IsCheckGratingRunning = false; } })); }
/// <summary> /// 检查订单信息 /// </summary> private Task CheckOrderIdAsync() { return(Task.Run(() => { Invoke((MethodInvoker) delegate() { try { var orderid = txtOrderId.Text.Trim(); txtOrderId.Text = ""; if (!string.IsNullOrWhiteSpace(lblOrderId.Text) && lblOrderId.Text != orderid) { if (_TargetLattice != null && !string.IsNullOrWhiteSpace(_LastOrderId) && !_LastOrderId.Equals(orderid)) { //禁止同时扫两个订单 OrderSortService.SetLED(_TargetLattice, 3); _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(3); _TargetLattice = null; //_LastOrderId = string.Empty; //ResetLabelTest(); lblMsg.Text = string.Format("不可同时扫描两个订单:{0},{1}", lblOrderId.Text, orderid); } return; } else { OrderSortService.ReSetLED(); } //根据订单号获取订单信息,并获取目标格口 if (!CheckOrderinfo(orderid)) { return; } //是否连续两次重复投递 //var lastOrderLog = OrderSortService.GetTheLastOrderSortingLog(); //if (lastOrderLog != null && lastOrderLog.OrderId == orderid && lastOrderLog.Status == 2) if (_LastSuccessOrderId.Equals(orderid)) { //创建扫描记录 if (OrderSortService.CreateOrderSortingLog(_Orderinfo, _TargetLattice, null, _UserInfo, 1, 4)) { OrderSortService.SetLED(_TargetLattice, 1); //准备进行重复扫描异常处理 _LatticeOrdersList = OrderSortService.GetLatticeOrdersListByLatticesettingId(_TargetLattice.ID); if (_LatticeOrdersList != null && _LatticeOrdersList.Count > 0) { _ButtonList.FirstOrDefault(b => b.TabIndex == _TargetLattice.ID).BackColor = GetColor(1); _IsRepeatError = true; _TargetLattice = null; lblMsg.Text = string.Format("不可重复扫描,订单号:{0}", orderid); return; } } return; } //创建扫描记录,亮灯 CreateOrderSortingLogAndTurnOnGreenLight(); } catch (Exception ex) { SaveErrLogHelper.SaveErrorLog(string.Empty, ex.ToString()); MessageBox.Show(ex.Message); } }); })); }
/// <summary> /// CreatePackingLog(operationType:1自动满格,2手动满格,3打印包牌号) /// </summary> /// <param name="lattice">柜格</param> /// <param name="operationType">操作类型:1自动满格,2手动满格,3打印包牌号</param> /// <returns></returns> public static PackingLog CreatePackingLog(LatticeSetting lattice, UserInfo userInfo, out List <LatticeOrdersCache> latticeInfo, int operationType = 3) { return(sortingService.CreatePackingLog(lattice, userInfo, _systemSetting.BoxWeight, out latticeInfo, operationType)); }
/// <summary> /// 创建分拣记录 /// </summary> /// <param name="info">订单信息</param> /// <param name="targetLattice">目标柜格</param> /// <param name="resultLattice">投入柜格</param> /// <param name="operationType">操作类型:1扫描,2投递,3异常恢复</param> /// <param name="status">状态:1待投递,2已投递,3投递异常,4重复扫描</param> public static bool CreateOrderSortingLog(OrderInfo info, LatticeSetting targetLattice, LatticeSetting resultLattice, UserInfo userInfo, int operationType, int status) { return(sortingService.CreateOrderSortingLog(info, targetLattice, resultLattice, userInfo, operationType, status)); }