| | |
| | | { |
| | | throw new Exception("满桶请选择物料与批次"); |
| | | } |
| | | |
| | | //判断目标叫料储位状态 |
| | | var endLocateInfo = Db.Queryable<SysStorageLocat>().First(m => m.IsDel == "0" && m.LocatNo == endLocate && m.AreaNo == areaNo); |
| | | if (endLocateInfo == null) |
| | |
| | | { |
| | | if (house.WareHouseNo == "M01") |
| | | { |
| | | stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.Status == "0" && m.PalletStatus == "0" && m.Standard == standard && !string.IsNullOrWhiteSpace(m.LocatNo)).OrderBy(m => m.LocatNo).ToList(); |
| | | stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.Status == "0" && m.PalletStatus == "0" && m.WareHouseNo == "M01" && m.Standard == standard && !string.IsNullOrWhiteSpace(m.LocatNo)).OrderBy(m => m.LocatNo).ToList(); |
| | | if (stockDetail.Count() == 0) |
| | | { |
| | | stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.Status == "0" && m.PalletStatus == "0" && m.Standard == standard && !string.IsNullOrWhiteSpace(m.LocatNo)).OrderBy(m => m.LocatNo).ToList(); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | //满桶 |
| | | else if (plnStatus == "2") |
| | | { |
| | | stockDetail = stockDetail.Where(m => m.PalletStatus == "2" && m.SkuNo == skuNo && m.LotNo == lotNo).OrderBy(m => m.LocatNo).ToList(); |
| | | stockDetail = stockDetail.Where(m => m.PalletStatus == "2" && m.SkuNo == skuNo && m.LotNo == lotNo && m.InspectStatus == "1").OrderBy(m => m.LocatNo).ToList(); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | //目标仓库所有储位 |
| | | var locatList = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Flag=="0" && w.WareHouseNo == house.WareHouseNo).OrderBy(w=>w.Column).ToList(); |
| | | //目标仓库所有最外侧的储位 |
| | | var locatListWai = locatList.Where(w => string.IsNullOrEmpty(w.AisleOne)).Select(s => s.LocatNo); |
| | | |
| | | //先找不需要移库的桶 |
| | | var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo) && w.Status == "0").OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | if (palletModel == null) |
| | | var locatListWai = locatList.Where(w => string.IsNullOrEmpty(w.AisleOne) && w.Flag == "0").Select(s => s.LocatNo); |
| | | var locatListNei = locatList.Where(w => !string.IsNullOrEmpty(w.AisleOne) && w.Flag == "0").Select(s => s.LocatNo); |
| | | var palletModel = new DataStockDetail(); |
| | | if (plnStatus == "0") //净桶获取库位 |
| | | { |
| | | //找需要移库的桶 |
| | | palletModel= stockDetail.Where(w => !locatListWai.Contains(w.LocatNo)).OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | //先找不需要移库的桶 |
| | | palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo) && w.Status == "0" && w.Standard == standard).OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | if (palletModel == null) |
| | | { |
| | | throw new Exception("未找到对应桶信息"); |
| | | //找需要移库的桶 |
| | | palletModel = stockDetail.Where(w => locatListNei.Contains(w.LocatNo) && w.Standard == standard).OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | if (palletModel == null) |
| | | { |
| | | throw new Exception("未找到对应桶信息"); |
| | | } |
| | | resultYi = YikuTask(palletModel.PalletNo, taskNo, url, bindUrl); |
| | | } |
| | | resultYi = YikuTask(palletModel.PalletNo, taskNo, url,bindUrl); |
| | | } |
| | | else //满桶获取库位 |
| | | { |
| | | //先找不需要移库的桶 |
| | | palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo) && w.Status == "0").OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | if (palletModel == null) |
| | | { |
| | | //找需要移库的桶 |
| | | palletModel = stockDetail.Where(w => locatListNei.Contains(w.LocatNo)).OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | if (palletModel == null) |
| | | { |
| | | throw new Exception("未找到对应桶信息"); |
| | | } |
| | | resultYi = YikuTask(palletModel.PalletNo, taskNo, url, bindUrl); |
| | | } |
| | | } |
| | | |
| | | palletModel.Status = "2"; |
| | | Db.Updateable(palletModel).ExecuteCommand(); |
| | | #endregion |
| | | //起始储位地址信息 |
| | | var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo); |
| | | var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == palletModel.LocatNo); |
| | | if (startLoction == null) |
| | | { |
| | | throw new Exception($"起始目标储位信息不存在,桶号:{palletModel.LocatNo}"); |
| | |
| | | if (resultYi) |
| | | { |
| | | taskNo = taskNo + "-1"; |
| | | } |
| | | //检验当前托盘是否有任务未完成 |
| | | var checkTask = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && (w.Status == "1" || w.Status == "0") && w.PalletNo == palletModel.PalletNo); |
| | | if (checkTask != null) |
| | | { |
| | | throw new Exception("当前托盘有正在执行的任务!"); |
| | | } |
| | | //添加任务 |
| | | var logTaskEntry = new LogTask |
| | |
| | | { |
| | | try |
| | | { |
| | | string type = "1";//叫料模板 |
| | | #region 判断 |
| | | |
| | | if (string.IsNullOrWhiteSpace(areaNo) || string.IsNullOrWhiteSpace(StartLocate) || string.IsNullOrWhiteSpace(plnStatus)) |
| | | { |
| | | throw new Exception("区域/起始位/桶类型不能为空"); |
| | |
| | | //目标楼层 |
| | | var layer = startLoction.Layer; |
| | | var houseStr = layer == 3 ? "3楼中间站" : layer == 4 ? "4楼中间站" : ""; |
| | | if (layer == 3 && plnStatus == "2") |
| | | { |
| | | type = "2"; |
| | | } |
| | | //通过仓库名称查询仓库信息 |
| | | var house = Db.Queryable<SysWareHouse>().First(m => m.IsDel == "0" && m.WareHouseName == houseStr); |
| | | if (house == null) |
| | |
| | | Status = "2", |
| | | InspectMark = "0", |
| | | BitPalletMark = "0", |
| | | InspectStatus = "1", |
| | | InspectStatus = "0", |
| | | }; |
| | | Db.Updateable(stockDetailNew).ExecuteCommand(); |
| | | } |
| | |
| | | { |
| | | throw new Exception("没有找到合适的目标储位"); |
| | | } |
| | | |
| | | //检验当前托盘是否有任务未完成 |
| | | var checkTask = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && (w.Status == "1" || w.Status == "0") && w.PalletNo == plnNo); |
| | | if (checkTask != null) |
| | | { |
| | | throw new Exception("当前托盘有正在执行的任务!"); |
| | | } |
| | | var taskNo = new Common().GetMaxNo("TK"); |
| | | //添加任务 |
| | | var logTaskEntry = new LogTask |
| | |
| | | Startport = StartLocate,//起始位置 |
| | | Endport = endLocatInfo.LocatNo,//目标位置 |
| | | Pallno = plnNo,//桶号 |
| | | Crtype = "1",//叫桶 |
| | | Crtype = type,//叫车模板 |
| | | }; |
| | | //调用AGV接口下发任务 |
| | | string agvMsg = string.Empty; |
| | |
| | | { |
| | | throw new Exception($"起始储位信息不存在"); |
| | | } |
| | | startLocatInfo.Status = "0";//空储位 |
| | | //修改起始储位状态 |
| | | Db.Updateable(startLocatInfo).ExecuteCommand(); |
| | | //startLocatInfo.Status = "0";//空储位 |
| | | ////修改起始储位状态 |
| | | //Db.Updateable(startLocatInfo).ExecuteCommand(); |
| | | |
| | | //目标储位信息 |
| | | //任务表中目标储位信息 |
| | | var endLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == taskInfo.EndLocat && w.IsDel == "0"); |
| | | if (endLocatInfo == null) |
| | | { |
| | | throw new Exception($"目标储位信息不存在"); |
| | | } |
| | | //AGV小车返回实际存放目标储位 |
| | | var trueLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == locateNo && w.IsDel == "0"); |
| | | if (trueLocatInfo == null) |
| | | { |
| | | throw new Exception($"小车放货储位信息不存在"); |
| | | } |
| | | if (endLocatInfo.LocatNo != trueLocatInfo.LocatNo) |
| | | { |
| | | //不一致时以小车放货储位为准 |
| | | endLocatInfo = trueLocatInfo; |
| | | //var tasklocat = Db.Queryable<LogTask>().First(w => w.EndLocat == trueLocatInfo.LocatNo && (w.Status == "0" || w.Status == "1") && w.IsDel == "0"); |
| | | //if (tasklocat == null) |
| | | //{ |
| | | // trueLocatInfo.Status = "0"; |
| | | // Db.Updateable(trueLocatInfo).ExecuteCommand(); |
| | | //} |
| | | |
| | | } |
| | | //修改目标储位状态 |
| | | endLocatInfo.Status = "1";//有物品 |
| | | endLocatInfo.UpdateTime = DateTime.Now;//更新时间 |
| | | //修改目标储位状态 |
| | | Db.Updateable(endLocatInfo).ExecuteCommand(); |
| | | |
| | | //目标储位所属区域 |
| | |
| | | var startLoction = new SysStorageLocat();//起始储位信息 |
| | | var endLoction = new SysStorageLocat();//目标储位信息 |
| | | var palletModel = new DataStockDetail();//分配桶信息 |
| | | string locatno = ""; |
| | | string type = "";//叫料类型 |
| | | |
| | | //开启事务 |
| | |
| | | { |
| | | //有脏桶的话,将更改此桶状态(代表此桶正在清洗中) |
| | | var qxStock = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == endLoction.LocatNo).First(); |
| | | if (qxStock == null) |
| | | { |
| | | throw new Exception("叫料位置状态错误"); |
| | | } |
| | | qxStock.Status = "2"; |
| | | qxStock.UpdateTime = DateTime.Now;//清洗时间 |
| | | //qxStock.UpdateTime = DateTime.Now;//清洗时间 |
| | | Db.Updateable(qxStock).ExecuteCommand(); |
| | | //更改设备储位状态为空储位 |
| | | endLoction.Status = "0"; |
| | | Db.Updateable(endLoction).ExecuteCommand(); |
| | | } |
| | | //优先查找脏桶缓存车间 |
| | | palletModel = stockDetail.Where(w => w.AreaNo == "C54").FirstOrDefault(); |
| | | palletModel = stockDetail.Where(w => w.AreaNo == "C54").OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | if (palletModel == null)//脏桶缓存车间没有脏桶,再从三楼中间站脏桶区查找 |
| | | { |
| | | palletModel = stockDetail.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C26").FirstOrDefault(); |
| | | palletModel = stockDetail.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C26").OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | } |
| | | if (palletModel == null)//三楼中间站脏桶区没有脏桶,再从四楼中间站脏桶区查找 |
| | | { |
| | | palletModel = stockDetail.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C03").FirstOrDefault(); |
| | | palletModel = stockDetail.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C03").OrderByDescending(w => w.UpdateTime).FirstOrDefault(); |
| | | } |
| | | if (palletModel == null) |
| | | { |
| | |
| | | throw new Exception($"起始目标储位信息不存在,桶号:{palletModel.LocatNo}"); |
| | | } |
| | | //起始桶信息 |
| | | var startDataDetil = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.Status == "0" && w.PalletStatus == "3"); |
| | | var startDataDetil = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.Status == "0" && w.PalletStatus == "3" && w.PalletNo == palletModel.PalletNo); |
| | | if (startDataDetil == null) |
| | | { |
| | | throw new Exception($"清洗机所叫的桶状态错误,桶号:{palletModel.LocatNo}"); |
| | |
| | | startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo); |
| | | //获取清洗机上第一次叫的脏桶 |
| | | string locate = deviceID == "1002"?"1001":"1003"; |
| | | palletModel = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == locate && (w.Status == "2" || w.Status == "0")).OrderBy(o => o.CreateTime).First(); |
| | | palletModel = Db.Queryable<DataStockDetail>().Where(w => w.LocatNo == locate).OrderBy(o => o.UpdateTime).First(); |
| | | if (palletModel == null) |
| | | { |
| | | throw new Exception("未找到库存中正在清洗的脏桶"); |
| | |
| | | { |
| | | throw new Exception("没有空余的净桶储位"); |
| | | } |
| | | //优先分配四楼中间站净桶区 |
| | | endLoction = jtLocate.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C01") |
| | | .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault(); |
| | | if (endLoction == null)//四楼中间站净桶区没有空储位,再从三楼中间站净桶区查找 |
| | | //首先查找是否已有同规格同巷道的空位 |
| | | var pallnoStorage = Db.Queryable<DataStockDetail>().Where(w => w.Standard == palletModel.Standard && w.PalletStatus == "0" && w.Status == "0").OrderBy(o => o.UpdateTime).ToList(); |
| | | if (pallnoStorage.Count()>0) |
| | | { |
| | | endLoction = jtLocate.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C24") |
| | | .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault(); |
| | | foreach (var item in pallnoStorage) |
| | | { |
| | | //获取巷道列,查找列中空储位 |
| | | var pallnoRow = Db.Queryable<SysStorageLocat>().Where(w => w.LocatNo == item.LocatNo).First(); |
| | | endLoction = jtLocate.Where(w => w.AreaNo == pallnoRow.AreaNo && w.Row == pallnoRow.Row && w.Status == "0" && w.Flag == "0" && w.Column<pallnoRow.Column).FirstOrDefault(); |
| | | if (endLoction == null) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | locatno = endLoction.LocatNo; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (endLoction == null)//三楼中间站净桶区没有空储位,再从三楼清洗间缓存区查找 PS:小车现在还不支持清洗机直接送往4楼净桶区 |
| | | if (palletModel.Standard != "400L" && string.IsNullOrEmpty(locatno)) |
| | | { |
| | | //优先分配四楼中间站净桶区 |
| | | endLoction = jtLocate.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C01") |
| | | .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault(); |
| | | if (endLoction != null) |
| | | { |
| | | locatno = endLoction.LocatNo; |
| | | } |
| | | } |
| | | if (string.IsNullOrEmpty(locatno)) |
| | | { |
| | | endLoction = jtLocate.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C24") |
| | | .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault(); |
| | | if (endLoction != null) |
| | | { |
| | | locatno = endLoction.LocatNo; |
| | | } |
| | | } |
| | | if (string.IsNullOrEmpty(locatno))//三楼中间站净桶区没有空储位,再从三楼清洗间缓存区查找 |
| | | { |
| | | endLoction = jtLocate.Where(w => w.WareHouseNo == "M44" && w.AreaNo == "C55") |
| | | .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault(); |
| | | if (endLoction != null) |
| | | { |
| | | locatno = endLoction.LocatNo; |
| | | } |
| | | } |
| | | if (endLoction == null) |
| | | if (string.IsNullOrEmpty(locatno)) |
| | | { |
| | | throw new Exception("未查询到合适储位"); |
| | | } |
| | |
| | | throw new Exception("叫料点位异常"); |
| | | |
| | | } |
| | | |
| | | //检验当前托盘是否有任务未完成 |
| | | var checkTask = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && (w.Status == "1" || w.Status == "0") && w.PalletNo == palletModel.PalletNo); |
| | | if (checkTask != null) |
| | | { |
| | | throw new Exception("当前托盘有正在执行的任务!"); |
| | | } |
| | | var taskNo = new Common().GetMaxNo("TK"); |
| | | //添加任务 |
| | | var logTaskEntry = new LogTask |
| | |
| | | |
| | | endLoction.Status = "2";//入库中 |
| | | Db.Updateable(endLoction).ExecuteCommand(); |
| | | |
| | | //净桶申请成功后判断当前清洗机上是否还有桶,没有桶则清空清洗机入口工位状态 |
| | | if (deviceStation == "output") |
| | | { |
| | | var rlocat = palletModel.LocatNo == "1002" ? "1001" : "1003"; |
| | | //判断有没有正在执行的到清洗机入口的任务 |
| | | var tasklist = Db.Queryable<LogTask>().First(w => w.EndLocat == rlocat && (w.Status == "0" && w.Status == "1")); |
| | | if (tasklist == null) |
| | | { |
| | | var stocklist = Db.Queryable<DataStockDetail>().First(w => w.LocatNo == rlocat); |
| | | if (stocklist == null) |
| | | { |
| | | var rdecive = Db.Queryable<SysStorageLocat>().First(w => w.LocatNo == rlocat); |
| | | rdecive.Status = "0"; |
| | | Db.Updateable(rdecive).ExecuteCommand(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | else//失败 |
| | | { |
| | |
| | | { |
| | | throw new Exception("要移库的桶有正在执行的任务,请稍后再试"); |
| | | } |
| | | //判断要移库的桶外侧是否有桶 |
| | | var locatInfoYi = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == palletInfoYi.LocatNo); |
| | | if (locatInfo == null) |
| | | { |
| | | throw new Exception("未查询到要移库的桶所在的储位信息"); |
| | | } |
| | | var palletInfoYi2 = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == locatInfoYi.AisleOne); |
| | | if (palletInfoYi2 != null) |
| | | { |
| | | throw new Exception("所要叫料的桶无法进行移库,请联系管理员进行手动移桶"); |
| | | } |
| | | |
| | | #region#给要移库的桶先移到中转储位 |
| | | //找到中转储位所在区域 |
| | | var transfeArea = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.WareHouseNo == WareHouseNo && w.AreaName.Contains("转运区")); |
| | |
| | | Msg = $"将桶{palletInfoYi.PalletNo}从{palletInfoYi.LocatNo}移到{transferLocat.LocatNo}", //关键信息 |
| | | LotNo = ""//批次号 |
| | | }; |
| | | Db.Insertable(logTaskEntry).ExecuteCommand(); |
| | | |
| | | //组织下发小车任务信息 |
| | | var task = new TaskDetial |
| | |
| | | { |
| | | endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" && w.Row == rowItem.Row && w.AreaNo == rowItem.AreaNo && (w.WareHouseNo == "M01"||w.WareHouseNo == "M16")) |
| | | .OrderByDescending(o => o.Column).First(); |
| | | if (endLocatInfo.LocatNo != null) |
| | | if (endLocatInfo != null) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (endLocatInfo == null) |
| | | { |
| | | endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" |
| | | && (w.AreaNo == "C02" || w.AreaNo == "C25")) |
| | | .OrderBy(o => o.Layer).OrderByDescending(o => o.Column).OrderBy(o => o.Row).First(); |
| | | } |
| | | //没有找到相同物料同组的空储位 |
| | | if (endLocatInfo.LocatNo == null) |
| | |
| | | |
| | | } |
| | | else {//其他区域 |
| | | areaNo = houseNo == "M01" ? "C02" : "C25"; |
| | | //查到到满桶区域编号 |
| | | areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "1").Select(s => s.AreaNo).First(); |
| | | //分配储位 |
| | | //先查到同物料的组 |
| | | string sql = $@"select Row,AreaNo from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and Status = '0' and LocatNo in( |
| | | string sql = $@"select Row,AreaNo from SysStorageLocat where WareHouseNo='{houseNo}' and AreaNo='{areaNo}' and Status = '1' and LocatNo in( |
| | | select LocatNo from DataStockDetail where SkuNo='{skuNo}' and LotNo = '{lotNo}' and Standard='{standard}' and WareHouseNo='{houseNo}' and AreaNo='{areaNo}' |
| | | ) group by Row,AreaNo"; |
| | | |
| | |
| | | && w.WareHouseNo == houseNo && w.AreaNo == areaNo && w.Row == rowItem.Row && w.AreaNo == rowItem.AreaNo && (w.WareHouseNo == "M01" || w.WareHouseNo == "M16")) |
| | | .OrderByDescending(o => o.Column).First(); |
| | | |
| | | if (endLocatInfo.LocatNo != null) |
| | | if (endLocatInfo != null) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (endLocatInfo == null) |
| | | { |
| | | endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" |
| | | && w.WareHouseNo == houseNo && w.AreaNo == areaNo) |
| | | .OrderByDescending(o => o.Column).OrderBy(o => o.Row).First(); |
| | | } |
| | | //没有找到相同物料同组的空储位 |
| | | if (endLocatInfo.LocatNo == null) |
| | | if (endLocatInfo.LocatNo == null ) |
| | | { |
| | | |
| | | endLocatInfo = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" |
| | |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 点对点任务下发 |
| | | /// </summary> |
| | | /// <param name="beginLocate">起始位</param> |
| | | /// <param name="endLocate">终点位</param> |
| | | /// <exception cref="Exception"></exception> |
| | | public void PointToPointRequest(string id,string beginPoint, string endPoint, string url, string bindUrl) |
| | | { |
| | | try |
| | | { |
| | | //权限校验 |
| | | var user = Db.Queryable<SysUserInfor>().First(m => m.IsDel == "0" && m.UserName == id); |
| | | if (user == null) |
| | | { |
| | | throw new Exception("没有查询到用户信息"); |
| | | } |
| | | if (user.RoleNo != "01") |
| | | { |
| | | throw new Exception("当前用户没有权限使用此功能"); |
| | | } |
| | | //起始储位信息 |
| | | var startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == beginPoint); |
| | | if (startLoction == null) |
| | | { |
| | | throw new Exception("未找到输入的起始储位"); |
| | | } |
| | | if (startLoction.Status != "1") |
| | | { |
| | | throw new Exception("起始储位:"+beginPoint+"的储位状态错误,储位状态应为:‘有物品’"); |
| | | } |
| | | //目标储位信息 |
| | | var endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == endPoint); |
| | | if (endLoction == null) |
| | | { |
| | | throw new Exception("未找到输入的目标储位"); |
| | | } |
| | | if (endLoction.Status != "0") |
| | | { |
| | | throw new Exception("目标储位:" + endPoint + "的储位状态错误,储位状态应为:'空储位'"); |
| | | } |
| | | //托盘信息 |
| | | var palletModel = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == beginPoint); |
| | | if (palletModel == null) |
| | | { |
| | | throw new Exception("未找到储位对应托盘信息!"); |
| | | } |
| | | //检验当前托盘是否有任务未完成 |
| | | var checkTask = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && (w.Status == "1" || w.Status == "0") && w.PalletNo == palletModel.PalletNo); |
| | | if (checkTask != null) |
| | | { |
| | | throw new Exception("当前托盘有正在执行的任务!"); |
| | | } |
| | | |
| | | Db.BeginTran(); |
| | | var taskNo = new Common().GetMaxNo("TK"); |
| | | //添加任务 |
| | | var logTaskEntry = new LogTask |
| | | { |
| | | TaskNo = taskNo, |
| | | Sender = "WMS", |
| | | Receiver = "RCS", |
| | | IsSuccess = 0, //是否下发成功 0失败 1成功 |
| | | |
| | | StartLocat = beginPoint,//起始位置 |
| | | EndLocat = endPoint,//目标位置 |
| | | PalletNo = palletModel.PalletNo,//托盘码 |
| | | IsSend = 1,//是否可再次下发 |
| | | IsCancel = 1,//是否可取消 |
| | | IsFinish = 1,//是否可完成 |
| | | Type = "1",//任务类型 0 入库任务 1 出库任务 2 移库任务 |
| | | Status = "0",//任务状态0:等待执行1正在执行2执行完成 |
| | | OrderType = "3",//0 入库单 1 出库单 2 盘点单 3 移库单 |
| | | |
| | | CreateTime = DateTime.Now |
| | | }; |
| | | Db.Insertable(logTaskEntry).ExecuteCommand(); |
| | | |
| | | //组织下发小车任务信息 |
| | | var task = new TaskDetial |
| | | { |
| | | Taskno = taskNo,//任务号 |
| | | Startport = beginPoint,//起始位置 |
| | | Endport = endPoint,//目标位置 |
| | | Pallno = palletModel.PalletNo,//桶号 |
| | | Crtype = "1",//叫桶 |
| | | }; |
| | | |
| | | string agvMsg = string.Empty; |
| | | //给下车下发任务 |
| | | logTaskEntry.SendDate = DateTime.Now;//发送时间 |
| | | //下发载具与货位绑定 |
| | | var bind = RcsHelper.BindPalletAndSite(palletModel.PalletNo, beginPoint, bindUrl, out string agvBindMsg); |
| | | if (bind) |
| | | { |
| | | var agvResult = RcsHelper.CreateTaskForAgv(task, url, out agvMsg); |
| | | if (agvResult)//成功 |
| | | { |
| | | //请求成功修改任务表相应字段状态 |
| | | logTaskEntry.IsSuccess = 1; |
| | | logTaskEntry.IsSend = 0; |
| | | //logTaskEntry.IsCancel = 0; |
| | | logTaskEntry.BackDate = DateTime.Now; |
| | | logTaskEntry.Status = "1";//正在执行 |
| | | Db.Updateable(logTaskEntry).ExecuteCommand(); |
| | | |
| | | startLoction.Status = "3";//出库中 |
| | | Db.Updateable(startLoction).ExecuteCommand(); |
| | | |
| | | endLoction.Status = "2";//入库中 |
| | | Db.Updateable(endLoction).ExecuteCommand(); |
| | | } |
| | | else//失败 |
| | | { |
| | | throw new Exception("桶号:" + task.Pallno + ",调度小车失败"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | throw new Exception("桶号:" + task.Pallno + ",绑定货位失败"); |
| | | } |
| | | |
| | | //提交事务 |
| | | Db.CommitTran(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | //回滚事务 |
| | | Db.RollbackTran(); |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |