| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 清洗机叫料状态 |
| | | /// </summary> |
| | | /// <param name="deviceID">清洗机编号</param> |
| | | /// <param name="deviceStation">叫料点位:”input”-入口(叫脏桶),”output”-出口(净桶申请储位)</param> |
| | | /// <param name="status"></param> |
| | | /// <exception cref="Exception"></exception> |
| | | public void RCSCleanRequest(string deviceID,string deviceStation,string status,string url) |
| | | { |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(deviceID)) |
| | | { |
| | | throw new Exception("清洗机编号不能为空"); |
| | | } |
| | | if (status != "1") |
| | | { |
| | | throw new Exception("非叫料状态"); |
| | | } |
| | | //通过设备号查找到所属设备(区域) |
| | | var deviceInfo = Db.Queryable<SysStorageArea>().First(w => w.IsDel == "0" && w.DeviceCode == deviceID); |
| | | if (deviceInfo == null) |
| | | { |
| | | throw new Exception("设备信息不存在"); |
| | | } |
| | | var houseNo = deviceInfo.WareHouseNo;//叫桶设备所属车间编号 |
| | | |
| | | var startLoction = new SysStorageLocat();//起始储位信息 |
| | | var endLoction = new SysStorageLocat();//目标储位信息 |
| | | var palletModel = new DataStockDetail();//分配桶信息 |
| | | |
| | | //开启事务 |
| | | Db.BeginTran(); |
| | | |
| | | //叫料点位 |
| | | switch (deviceStation) |
| | | { |
| | | case "input"://叫脏桶 |
| | | //叫桶设备所在储位信息(目标储位) |
| | | endLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo); |
| | | |
| | | // 所有待分配的脏桶 |
| | | var stockDetail = Db.Queryable<DataStockDetail>().Where(w => w.Status == "0" && w.PalletStatus == "3"); |
| | | |
| | | //优先查找脏桶缓存车间 |
| | | palletModel = stockDetail.Where(w => w.AreaNo == "C43").OrderByDescending(o => o.UpdateTime).First(); |
| | | if (palletModel == null)//脏桶缓存车间没有脏桶,再从三楼中间站脏桶区查找 |
| | | { |
| | | palletModel = stockDetail.Where(w =>w.WareHouseNo=="M16" && w.AreaNo == "C26").OrderByDescending(o => o.UpdateTime).First(); |
| | | } |
| | | if (palletModel == null)//三楼中间站脏桶区没有脏桶,再从四楼中间站脏桶区查找 |
| | | { |
| | | palletModel = stockDetail.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C03").OrderByDescending(o => o.UpdateTime).First(); |
| | | } |
| | | if (palletModel == null) |
| | | { |
| | | throw new Exception("无脏桶可分配"); |
| | | } |
| | | //起始储位地址信息 |
| | | startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.Status == "1" && w.LocatNo == palletModel.LocatNo); |
| | | if (startLoction == null) |
| | | { |
| | | throw new Exception($"起始目标储位信息不存在,桶号:{palletModel.LocatNo}"); |
| | | } |
| | | |
| | | break; |
| | | |
| | | case "output"://净桶申请储位 |
| | | //叫桶设备所在储位信息(起始储位) |
| | | startLoction = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.AreaNo == deviceInfo.AreaNo); |
| | | //桶信息 |
| | | palletModel = Db.Queryable<DataStockDetail>().Where(w => w.WareHouseNo==houseNo && w.AreaNo==deviceInfo.AreaNo && w.LocatNo==startLoction.LocatNo).First(); |
| | | if (palletModel == null) |
| | | { |
| | | throw new Exception("未查询到净桶信息"); |
| | | } |
| | | //分配储位 |
| | | //优先分配四楼中间站净桶区 |
| | | endLoction= Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" |
| | | && w.WareHouseNo == "M01" && w.AreaNo == "C01") |
| | | .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First(); |
| | | if (endLoction == null)//四楼中间站净桶区没有空储位,再从三楼中间站净桶区查找 |
| | | { |
| | | endLoction = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" |
| | | && w.WareHouseNo == "M16" && w.AreaNo == "C24") |
| | | .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First(); |
| | | } |
| | | if (endLoction == null)//三楼中间站净桶区没有空储位,再从三楼清洗间缓存区查找 |
| | | { |
| | | endLoction = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Status == "0" && w.Flag == "0" |
| | | && w.WareHouseNo == "M44" && w.AreaNo == "C55") |
| | | .OrderBy(o => o.Row).OrderByDescending(o => o.Column).First(); |
| | | } |
| | | if (endLoction == null) |
| | | { |
| | | throw new Exception("未查询到合适储位"); |
| | | } |
| | | break; |
| | | |
| | | default: |
| | | throw new Exception("叫料点位异常"); |
| | | |
| | | } |
| | | var taskNo = new Common().GetMaxNo("TK"); |
| | | //添加任务 |
| | | var logTaskEntry = new LogTask |
| | | { |
| | | TaskNo = taskNo, |
| | | Sender = "WMS", |
| | | Receiver = "RCS", |
| | | IsSuccess = 0, //是否下发成功 0失败 1成功 |
| | | |
| | | StartLocat = "",//起始位置 |
| | | EndLocat = endLoction.LocatNo,//目标位置 |
| | | 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 = palletModel.LocatNo,//起始位置 |
| | | Endport = endLoction.LocatNo,//目标位置 |
| | | Pallno = palletModel.PalletNo,//桶号 |
| | | Crtype = "1",//叫桶 |
| | | }; |
| | | |
| | | string agvMsg = string.Empty; |
| | | //给下车下发任务 |
| | | logTaskEntry.SendDate = DateTime.Now;//发送时间 |
| | | 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.Insertable(logTaskEntry).ExecuteCommand(); |
| | | |
| | | startLoction.Status = "3";//出库中 |
| | | Db.Updateable(startLoction).ExecuteCommand(); |
| | | |
| | | endLoction.Status = "2";//入库中 |
| | | Db.Updateable(endLoction).ExecuteCommand(); |
| | | } |
| | | else//失败 |
| | | { |
| | | logTaskEntry.IsSuccess = 0; |
| | | logTaskEntry.Information = agvMsg; |
| | | Db.Insertable(logTaskEntry).ExecuteCommand(); |
| | | } |
| | | //提交事务 |
| | | Db.CommitTran(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | //回滚事务 |
| | | Db.RollbackTran(); |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | private bool YikuTask(string palletNo, string taskNo, string url) |
| | | { |