| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using Model.InterFaceModel; |
| | | using Model.ModelDto.BllCheckDto; |
| | | using Model.ModelDto.PdaDto; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | | using Utility.Tools; |
| | | using WMS.BLL.LogServer; |
| | | using WMS.DAL; |
| | | using WMS.Entity.BllAsnEntity; |
| | |
| | | var storageArea = new List<SysStorageArea>(); |
| | | if (string.IsNullOrEmpty(palletNo)) |
| | | { |
| | | storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o=>o.AreaNo).ToList(); |
| | | storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | throw new Exception("储位信息不存在,请检查!"); |
| | | } |
| | | |
| | | |
| | | if (storageLocat.AreaNo.Contains("B0")) |
| | | { |
| | | storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B0") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); |
| | |
| | | { |
| | | storageArea = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.Status == "0" && w.AreaNo.Contains("B1") && w.WareHouseNo == "W02").OrderBy(o => o.AreaNo).ToList(); |
| | | } |
| | | } |
| | | } |
| | | return storageArea; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | /// <param name="palletNo"></param> |
| | | /// <param name="areaNo"></param> |
| | | /// <param name="ruku"></param> |
| | | public void AgvTransport(string palletNo, string areaNo, string ruku, int userId) |
| | | public void AgvTransport(string palletNo, string areaNo, string ruku, int userId, string url) |
| | | { |
| | | if (string.IsNullOrEmpty(palletNo)) |
| | | { |
| | |
| | | if (!string.IsNullOrEmpty(areaNo) && !string.IsNullOrEmpty(ruku)) |
| | | { |
| | | throw new Exception("目标区域和入库口不能同时选择!"); |
| | | } |
| | | } |
| | | try |
| | | { |
| | | string EndLocat = string.Empty;//目标位置 |
| | |
| | | if (log != null) |
| | | { |
| | | throw new Exception("该托盘已有小车等待执行或正在执行的任务!"); |
| | | } |
| | | } |
| | | var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo); |
| | | if (stockDetail == null) |
| | | { |
| | |
| | | { |
| | | throw new Exception("所选区域信息不存在,请检查!"); |
| | | } |
| | | EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo); |
| | | EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo, palletNo); |
| | | } |
| | | else |
| | | { |
| | |
| | | throw new Exception("目标储位信息不存在,请检查!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | //开启事务 |
| | | Db.BeginTran(); |
| | | |
| | |
| | | { |
| | | storageLocatEnd.Status = "4";//0:空储位 1:有物品 2:入库中 3:出库中 4:移入中 5:移出中 |
| | | Db.Updateable(storageLocatEnd).ExecuteCommand(); |
| | | } |
| | | } |
| | | //添加操作日志记录 |
| | | var k = new OperationCrServer().AddLogOperationCr("PDA模块", "AGV转运", palletNo, "移库", $"PDA呼叫小车对托盘号:{palletNo}发起转运", userId); |
| | | //提交事务 |
| | | Db.CommitTran(); |
| | | |
| | | #region 呼叫小车代码 |
| | | |
| | | |
| | | List<AgvSchedulingTask> agvTaskList = new List<AgvSchedulingTask>(); |
| | | |
| | | AgvSchedulingTask agvTask = new AgvSchedulingTask(); |
| | | agvTask.ReqCode = taskNo; |
| | | agvTask.TaskTyp = "F01"; |
| | | agvTask.WbCode = ""; |
| | | agvTask.PositionCodePath = null; |
| | | agvTask.PodCode = "-1"; |
| | | |
| | | agvTaskList.Add(agvTask); |
| | | |
| | | var IsTrue = false; |
| | | while (IsTrue == true) |
| | | { |
| | | // 正式运行程序放开 |
| | | string str = ""; |
| | | var list2 = agvTaskList.Select(m => m.ReqCode).ToList(); |
| | | var jsonData = JsonConvert.SerializeObject(agvTaskList); |
| | | string response = ""; |
| | | |
| | | try |
| | | { |
| | | var time1 = DateTime.Now;//发送时间 .ToString("yyyy-MM-dd HH:mm:ss") |
| | | response = HttpHelper.DoPost(url, jsonData, "下发给AGV转运命令", "AGV"); |
| | | var time2 = DateTime.Now;//返回时间 .ToString("yyyy-MM-dd HH:mm:ss") |
| | | |
| | | //////解析返回数据 |
| | | var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response); |
| | | if (agvModel.Code == "0") |
| | | { |
| | | //更改任务的发送返回时间// |
| | | new TaskServer().EditTaskIssueOk(list2, time1, time2); |
| | | str += "下发成功"; |
| | | IsTrue = true; |
| | | } |
| | | if (agvModel.Code == "1") |
| | | { |
| | | new TaskServer().EditTaskIssueNo(list2, time1, time2, agvModel.Message); |
| | | throw new Exception(agvModel.Message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | //提交事务 |
| | | Db.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// <param name="palletNo"></param> |
| | | /// <param name="areaNo"></param> |
| | | /// <param name="userId"></param> |
| | | public void AgvTransport2(string soNo,string palletNo, string areaNo, int userId) |
| | | public void AgvTransport2(string soNo, string palletNo, string areaNo, int userId, string url) |
| | | { |
| | | if (string.IsNullOrEmpty(soNo)) |
| | | { |
| | |
| | | { |
| | | //开启事务 |
| | | Db.BeginTran(); |
| | | List<AgvSchedulingTask> agvTaskList = new List<AgvSchedulingTask>(); |
| | | |
| | | //出库单信息 |
| | | var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo); |
| | | if (notice == null) |
| | |
| | | string sqlStr = $"select * from DataStockDetail where PalletNo in (select PalletNo from BllExportAllot where IsDel='0' and SONo='{soNo}')"; |
| | | stockDetailList = Db.Ado.SqlQuery<DataStockDetail>(sqlStr).ToList(); |
| | | } |
| | | if (stockDetailList.Count<=0) |
| | | if (stockDetailList.Count <= 0) |
| | | { |
| | | throw new Exception("托盘明细不存在,请检查!"); |
| | | } |
| | |
| | | foreach (var item in stockDetailList) |
| | | { |
| | | //任务信息 |
| | | var logInfo = log.First(w =>w.PalletNo == item.PalletNo); |
| | | var logInfo = log.First(w => w.PalletNo == item.PalletNo); |
| | | if (logInfo != null) |
| | | { |
| | | throw new Exception($"托盘号:{item.PalletNo}已有小车等待执行或正在执行的任务!"); |
| | |
| | | }; |
| | | Db.Insertable(exTask).ExecuteCommand(); |
| | | |
| | | AgvSchedulingTask agvTask = new AgvSchedulingTask(); |
| | | agvTask.ReqCode = taskNo; |
| | | agvTask.TaskTyp = "F01"; |
| | | agvTask.WbCode = ""; |
| | | agvTask.PositionCodePath = null; |
| | | agvTask.PodCode = "-1"; |
| | | |
| | | agvTaskList.Add(agvTask); |
| | | |
| | | //修改库存明细信息 |
| | | item.Status = "4";//移库锁定 |
| | | item.LockQty = item.Qty;//锁定库存数量 |
| | |
| | | //添加操作日志记录 |
| | | var k = new OperationCrServer().AddLogOperationCr("PDA模块", "AGV转运", palletNo, "移库", $"PDA呼叫小车对托盘号:{palletNo}发起转运", userId); |
| | | } |
| | | //提交事务 |
| | | Db.CommitTran(); |
| | | |
| | | #region 呼叫小车代码 |
| | | |
| | | |
| | | |
| | | var IsTrue = false; |
| | | while (IsTrue == true) |
| | | { |
| | | // 正式运行程序放开 |
| | | string str = ""; |
| | | var list2 = agvTaskList.Select(m => m.ReqCode).ToList(); |
| | | var jsonData = JsonConvert.SerializeObject(agvTaskList); |
| | | string response = ""; |
| | | |
| | | try |
| | | { |
| | | var time1 = DateTime.Now;//发送时间 .ToString("yyyy-MM-dd HH:mm:ss") |
| | | response = HttpHelper.DoPost(url, jsonData, "下发给AGV转运取货命令", "AGV"); |
| | | var time2 = DateTime.Now;//返回时间 .ToString("yyyy-MM-dd HH:mm:ss") |
| | | |
| | | //////解析返回数据 |
| | | var agvModel = JsonConvert.DeserializeObject<OutCommanAgvDto>(response); |
| | | if (agvModel.Code == "0") |
| | | { |
| | | //更改任务的发送返回时间// |
| | | new TaskServer().EditTaskIssueOk(list2, time1, time2); |
| | | str += "下发成功"; |
| | | IsTrue = true; |
| | | } |
| | | if (agvModel.Code == "1") |
| | | { |
| | | new TaskServer().EditTaskIssueNo(list2, time1, time2, agvModel.Message); |
| | | throw new Exception(agvModel.Message); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | //提交事务 |
| | | Db.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// <param name="skuNo"></param> |
| | | /// <param name="lotNo"></param> |
| | | /// <returns></returns> |
| | | private string GetLocat(string areaNo,string skuNo,string lotNo,string palletNo,string hasLocatNoList="") |
| | | private string GetLocat(string areaNo, string skuNo, string lotNo, string palletNo, string hasLocatNoList = "") |
| | | { |
| | | try |
| | | { |
| | | string endLocat = string.Empty;//目标储位 |
| | | //当然区域所有储位信息 |
| | | //当然区域所有储位信息 |
| | | var storageLocatList = Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W02" && w.AreaNo == areaNo).ToList(); |
| | | //同区域同批次物料的储位信息 |
| | | List<string> locatList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SkuNo == skuNo && w.LotNo == lotNo && w.WareHouseNo == "W02" && w.AreaNo == areaNo && w.PalletNo != palletNo) |
| | | .OrderByDescending(o=>o.LocatNo).Select(s=>s.LocatNo).Distinct().ToList(); |
| | | .OrderByDescending(o => o.LocatNo).Select(s => s.LocatNo).Distinct().ToList(); |
| | | foreach (var item in locatList) |
| | | { |
| | | var locatInfo = storageLocatList.Where(w => w.LocatNo == item).First(); |
| | |
| | | if (string.IsNullOrEmpty(endLocat)) |
| | | { |
| | | var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0" && !hasLocatNoList.Contains(w.LocatNo)) |
| | | .OrderByDescending(m => m.Layer).OrderByDescending(m=>m.Column).OrderByDescending(m=> m.Row).First(); |
| | | .OrderByDescending(m => m.Layer).OrderByDescending(m => m.Column).OrderByDescending(m => m.Row).First(); |
| | | |
| | | if (locatInfo3 != null) |
| | | { |