| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Numerics; |
| | | using System.Reflection; |
| | | using System.Security.Policy; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | |
| | | stockDetail.PalletStatus = "0"; |
| | | stockDetail.Status = "0";//待分配 |
| | | } |
| | | else if (endAreaInfo.Type == "1")//预混区 |
| | | { |
| | | stockDetail.PalletStatus = "1"; |
| | | stockDetail.Status = "0";//待分配 |
| | | } |
| | | else if (endAreaInfo.Type == "2")//半成品区 |
| | | else if (endAreaInfo.Type == "1")//满桶 |
| | | { |
| | | stockDetail.PalletStatus = "2"; |
| | | stockDetail.Status = "0";//待分配 |
| | | } |
| | | else if (endAreaInfo.Type == "3")//脏桶区 |
| | | else if (endAreaInfo.Type == "2")//脏桶区 |
| | | { |
| | | stockDetail.PalletStatus = "3"; |
| | | stockDetail.LotNo = "";//批次 |
| | |
| | | } |
| | | locatEnd.Status = "0"; //空储位 |
| | | Db.Updateable(locatEnd).ExecuteCommand(); |
| | | |
| | | if (task.Type == "1")//出库任务 |
| | | |
| | | //修改库存明细 |
| | | var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == task.PalletNo); |
| | | if (stockDetail == null) |
| | | { |
| | | //修改库存明细 |
| | | var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == task.PalletNo && w.Status == "2"); |
| | | if (stockDetail == null) |
| | | { |
| | | throw new Exception("未查询到该桶库存信息,请检查!"); |
| | | } |
| | | stockDetail.Status = "0";//待分配 |
| | | Db.Updateable(stockDetail).ExecuteCommand(); |
| | | throw new Exception("未查询到该桶库存信息,请检查!"); |
| | | } |
| | | stockDetail.Status = "0";//待分配 |
| | | Db.Updateable(stockDetail).ExecuteCommand(); |
| | | |
| | | //添加操作日志记录 |
| | | var k = new OperationCrServer().AddLogOperationCr("库内作业", "库内日志", taskNo, "取消", $"点击取消按钮、取消了任务号为:{taskNo}的任务", userId); |
| | | Db.CommitTran(); |
| | |
| | | /// <param name="taskNo"></param> |
| | | /// <param name="userId"></param> |
| | | /// <exception cref="Exception"></exception> |
| | | public void DownTask(string taskNo, int userId,string url) |
| | | public void DownTask(string taskNo, int userId,string url,string bindUrl) |
| | | { |
| | | try |
| | | { |
| | |
| | | throw new Exception("只有等待执行的任务才可手动下发"); |
| | | } |
| | | //查找该桶有没有正在执行的任务 |
| | | var tasking = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "1" && w.PalletNo == logTaskEntry.PalletNo); |
| | | var tasking = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.Status == "1" && w.PalletNo == logTaskEntry.PalletNo); |
| | | if (tasking != null) |
| | | { |
| | | throw new Exception($"该桶有正在执行的任务"); |
| | |
| | | { |
| | | throw new Exception($"未查询到起始储位信息"); |
| | | } |
| | | if (startLocatInfo.Status != "1") |
| | | { |
| | | throw new Exception($"起始储位状态异常"); |
| | | } |
| | | //if (startLocatInfo.Status != "1") |
| | | //{ |
| | | // throw new Exception($"起始储位状态异常"); |
| | | //} |
| | | //目标储位信息 |
| | | var endLocatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == logTaskEntry.EndLocat); |
| | | if (endLocatInfo == null) |
| | | { |
| | | throw new Exception($"未查询到目标储位信息"); |
| | | } |
| | | if (endLocatInfo.Status != "0") |
| | | { |
| | | throw new Exception($"目标储位状态异常"); |
| | | } |
| | | //if (endLocatInfo.Status != "0") |
| | | //{ |
| | | // throw new Exception($"目标储位状态异常"); |
| | | //} |
| | | //组织给小车下发任务信息 |
| | | var task = new TaskDetial |
| | | { |
| | |
| | | string agvMsg = string.Empty; |
| | | //给下车下发任务 |
| | | logTaskEntry.SendDate = DateTime.Now;//发送时间 |
| | | var agvResult = CreateTaskForAgv(task, url, out agvMsg); |
| | | if (agvResult)//成功 |
| | | //先给货位绑定载具 |
| | | var bind = RcsHelper.BindPalletAndSite(logTaskEntry.PalletNo, logTaskEntry.StartLocat, bindUrl, out string agvBindMsg); |
| | | if (bind) |
| | | { |
| | | //请求成功修改任务表相应字段状态 |
| | | logTaskEntry.IsSuccess = 1; |
| | | logTaskEntry.IsSend = 0; |
| | | logTaskEntry.IsCancel = 0; |
| | | logTaskEntry.BackDate = DateTime.Now; |
| | | logTaskEntry.Status = "1";//正在执行 |
| | | Db.Insertable(logTaskEntry).ExecuteCommand(); |
| | | var agvResult = CreateTaskForAgv(task, url, out agvMsg); |
| | | if (agvResult)//成功 |
| | | { |
| | | //请求成功修改任务表相应字段状态 |
| | | logTaskEntry.IsSuccess = 1; |
| | | logTaskEntry.IsSend = 1; |
| | | logTaskEntry.IsCancel = 1; |
| | | logTaskEntry.BackDate = DateTime.Now; |
| | | Db.Updateable(logTaskEntry).ExecuteCommand(); |
| | | |
| | | startLocatInfo.Status = "3";//出库中 |
| | | Db.Updateable(startLocatInfo).ExecuteCommand(); |
| | | startLocatInfo.Status = "3";//出库中 |
| | | Db.Updateable(startLocatInfo).ExecuteCommand(); |
| | | |
| | | endLocatInfo.Status = "2";//入库中 |
| | | Db.Updateable(endLocatInfo).ExecuteCommand(); |
| | | endLocatInfo.Status = "2";//入库中 |
| | | Db.Updateable(endLocatInfo).ExecuteCommand(); |
| | | } |
| | | else//失败 |
| | | { |
| | | logTaskEntry.IsSuccess = 0; |
| | | logTaskEntry.Information = agvMsg; |
| | | Db.Updateable(logTaskEntry).ExecuteCommand(); |
| | | } |
| | | } |
| | | else//失败 |
| | | { |
| | | logTaskEntry.IsSuccess = 0; |
| | | logTaskEntry.Information = agvMsg; |
| | | Db.Insertable(logTaskEntry).ExecuteCommand(); |
| | | } |
| | | |
| | | //添加操作日志记录 |
| | | var k = new OperationCrServer().AddLogOperationCr("库内作业", "库内日志", taskNo, "下发", $"点击下发按钮、任务号为:{taskNo}的任务", userId); |
| | | Db.CommitTran(); |