public bool AllocateCarrier(StockTrans trans, out uint carrierid, out string result) { result = ""; carrierid = 0; if (Monitor.TryEnter(_obj, TimeSpan.FromSeconds(10))) { try { #region 分配职责 //if (DevList.Exists(c => c.IsEnable && c.CarrierDuty == CarrierDutyE.未知)) //{ // foreach (CarrierTask car in DevList.FindAll(c => c.IsEnable)) // { // Track t = PubTask.Carrier.GetCarrierTrack(car.ID); // if (t == null) // { // PubMaster.Device.SetDuty(car.ID, CarrierDutyE.未知); // } // else // { // switch (t.Type) // { // case TrackTypeE.上砖轨道: // case TrackTypeE.储砖_出: // case TrackTypeE.摆渡车_出: // PubMaster.Device.SetDuty(car.ID, CarrierDutyE.上砖); // break; // case TrackTypeE.下砖轨道: // case TrackTypeE.储砖_入: // case TrackTypeE.摆渡车_入: // PubMaster.Device.SetDuty(car.ID, CarrierDutyE.下砖); // break; // default: // break; // } // } // } //} #endregion switch (trans.TransType) { case TransTypeE.入库: case TransTypeE.手动入库: return(GetTransInOutCarrier(trans, DeviceTypeE.摆渡, out carrierid, out result)); case TransTypeE.出库: case TransTypeE.手动出库: return(GetTransInOutCarrier(trans, DeviceTypeE.摆渡, out carrierid, out result)); case TransTypeE.倒库: return(GetTransSortCarrier(trans, out carrierid, out result)); } } finally { Monitor.Exit(_obj); } } return(false); }
/// <summary> /// 倒库专用:找到上砖摆渡轨道 /// </summary> /// <param name="trans"></param> /// <returns></returns> public List <uint> GetFerryTrackSortIds(StockTrans trans, bool istrackid) { List <uint> list = new List <uint>(); List <AreaDevice> ferrys = AreaDevList.FindAll(c => c.area_id == trans.area_id && c.DevType == DeviceTypeE.摆渡); if (ferrys != null && ferrys.Count > 0) { foreach (AreaDevice device in ferrys) { if (AreaDevTraList.Exists(c => c.device_id == device.device_id && c.area_id == device.area_id && c.track_id == trans.give_track_id)) { if (istrackid) { uint trackid = PubMaster.Device.GetFerryTrackId(device.device_id); if (trackid > 0) { list.Add(trackid); } } else { list.Add(device.device_id); } } } } return(list); }
public void AddTransWithoutLock(uint areaid, uint lifterid, TransTypeE type, uint goodsid, uint stocksid, uint taketrackid, uint givetrackid, TransStatusE initstatus = TransStatusE.调度设备, uint carrierid = 0) { uint newid = PubMaster.Dic.GenerateID(DicTag.NewTranId); StockTrans trans = new StockTrans() { id = newid, area_id = areaid, TransStaus = initstatus, TransType = type, tilelifter_id = lifterid, goods_id = goodsid, stock_id = stocksid, take_track_id = taketrackid, give_track_id = givetrackid, create_time = DateTime.Now, carrier_id = carrierid, }; TransList.Add(trans); PubMaster.Mod.GoodSql.AddStockTrans(trans); SendMsg(trans); }
public bool EditStockTrans(StockTrans trans, TransUpdateE updateE) { string sql = "UPDATE `stock_trans` SET "; switch (updateE) { case TransUpdateE.Status: sql += string.Format("`trans_status` = {0}", trans.trans_status); break; case TransUpdateE.CarrierId: sql += string.Format("`carrier_id` = {0}", trans.carrier_id); break; case TransUpdateE.TakeFerryId: sql += string.Format("`take_ferry_id` = {0}", trans.take_ferry_id); break; case TransUpdateE.GiveFerryId: sql += string.Format("`give_ferry_id` = {0}", trans.give_ferry_id); break; case TransUpdateE.LoadTime: sql += string.Format("`load_time` = {0}", GetTimeOrNull(trans.load_time)); break; case TransUpdateE.UnLoadTime: sql += string.Format("`unload_time` = {0}", GetTimeOrNull(trans.unload_time)); break; case TransUpdateE.Finish: sql += string.Format("`finish` = {0}, `finish_time` = {1}", trans.finish, GetTimeOrNull(trans.finish_time)); break; case TransUpdateE.TakeSite: sql += string.Format("`take_track_id` = {0}", trans.take_track_id); break; case TransUpdateE.GiveSite: sql += string.Format("`give_track_id` = {0}", trans.give_track_id); break; case TransUpdateE.Stock: sql += string.Format("`stock_id` = {0}", trans.stock_id); break; case TransUpdateE.Cancel: sql += string.Format("`cancel` = {0}", trans.cancel); break; case TransUpdateE.ReTake: sql += string.Format("`take_track_id` = {0}, `stock_id` = {1}, " + "`carrier_id` = {2}, `trans_status` = {3}", trans.take_track_id, trans.stock_id, trans.carrier_id, trans.trans_status); break; } sql += string.Format(" WHERE `id` = {0}", trans.id); int row = mSql.ExcuteSql(sql); return(row >= 1); }
internal bool DeleteStockTrans(StockTrans trans) { string sql = string.Format("DELETE FROM `stock_trans` where id = '{0}'", trans.id); int row = mSql.ExcuteSql(sql); return(row >= 1); }
//public void DoCarrierStop(uint devid) //{ // if (Monitor.TryEnter(_obj, TimeSpan.FromSeconds(1))) // { // try // { // CarrierTask task = DevList.Find(c => c.ID == devid); // if (task != null) // { // task.DoStop(); // } // } // finally { Monitor.Exit(_obj); } // } //} #endregion #region [分配-运输车] public bool AllocateCarrier(StockTrans trans, out uint carrierid, out string result) { result = ""; carrierid = 0; if (Monitor.TryEnter(_obj, TimeSpan.FromSeconds(10))) { try { switch (trans.TransType) { case TransTypeE.入库: case TransTypeE.手动入库: return(GetTransInOutCarrier(trans, DeviceTypeE.摆渡, out carrierid, out result)); case TransTypeE.出库: case TransTypeE.手动出库: return(GetTransInOutCarrier(trans, DeviceTypeE.摆渡, out carrierid, out result)); case TransTypeE.倒库: return(GetTransSortCarrier(trans, out carrierid, out result)); } } finally { Monitor.Exit(_obj); } } return(false); }
protected void SetStock(StockTrans trans, uint stockid) { if (trans.stock_id != stockid) { trans.stock_id = stockid; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.Stock); } }
protected void SetReTake(StockTrans trans, uint taketraid, uint stockid, uint carrierid, TransStatusE status) { trans.take_track_id = taketraid; trans.stock_id = stockid; trans.carrier_id = carrierid; trans.TransStaus = status; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.ReTake); }
// GET: Stock/Details/5 public ActionResult Details(int id) { StockTrans stock = _stockTransRepo.GetStockTrans(id); StockViewModel stockview = new StockViewModel(); stockview.userJournalId = stock.StockUserId; stockview.Stock = stock; return(View(stockview)); }
protected void SetCancel(StockTrans trans) { if (!trans.cancel) { mLog.Status(true, string.Format("任务:{0},任务取消:{1}", trans.id, DateTime.Now.ToString())); trans.cancel = true; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.Cancel); } }
internal void SetGiveFerry(StockTrans trans, uint ferryid) { if (trans.give_ferry_id != ferryid) { mLog.Status(true, string.Format("任务:{0},分配G摆渡车:{1}", trans.id, PubMaster.Device.GetDeviceName(ferryid))); trans.give_ferry_id = ferryid; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.GiveFerryId); SendMsg(trans); } }
internal void SetUnLoadTime(StockTrans trans) { if (trans.unload_time == null) { mLog.Status(true, string.Format("任务:{0},卸货时间:{1}", trans.id, DateTime.Now.ToString())); trans.unload_time = DateTime.Now; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.UnLoadTime); SendMsg(trans); } }
internal void SetCarrier(StockTrans trans, uint carrierid) { if (trans.carrier_id != carrierid) { mLog.Status(true, string.Format("任务:{0},分配小车:{1}", trans.id, PubMaster.Device.GetDeviceName(carrierid))); trans.carrier_id = carrierid; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.CarrierId); SendMsg(trans); } }
public StockTrans GetTrans(int transid) { StockTrans stock = TransList.Find(c => c.id == transid); if (stock == null) { stock = PubMaster.Mod.GoodSql.QueryStockTransById(transid); } return(stock); }
// GET: Stock/Edit/5 public ActionResult Edit(int id) { StockViewModel newStockView = new StockViewModel(); StockTrans stock = _stockTransRepo.GetStockTrans(id); var newStockId = stock.StockUserId; newStockView.Stock = stock; newStockView.userJournalId = newStockId; return(View(newStockView)); }
protected bool SetTakeSite(StockTrans trans, uint traid) { if (trans.take_track_id != traid) { trans.take_track_id = traid; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.TakeSite); SendMsg(trans); return(true); } return(false); }
internal void SetFinish(StockTrans trans) { if (trans.finish_time == null) { mLog.Status(true, string.Format("任务:{0},任务完成:{1}", trans.id, DateTime.Now.ToString())); trans.finish = true; trans.finish_time = DateTime.Now; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.Finish); SendMsg(trans); } }
protected bool SetGiveSite(StockTrans trans, uint traid) { if (trans.give_track_id != traid) { mLog.Status(true, string.Format("任务:{0},卸货轨道:{1}", trans.id, PubMaster.Track.GetTrackName(traid))); trans.give_track_id = traid; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.GiveSite); SendMsg(trans); return(true); } return(false); }
public bool AddStockTrans(StockTrans stotran) { string str = "INSERT INTO `stock_trans`(`id`, `trans_type`, `trans_status`, `area_id`, `goods_id`, `stock_id`," + " `tilelifter_id`, `take_track_id`, `give_track_id`, `create_time`,`carrier_id`)" + " VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', {9}, {10})"; string sql = string.Format(@str, stotran.id, stotran.trans_type, stotran.trans_status, stotran.area_id, stotran.goods_id, stotran.stock_id, stotran.tilelifter_id, stotran.take_track_id, stotran.give_track_id, GetTimeOrNull(stotran.create_time), stotran.carrier_id); int row = mSql.ExcuteSql(sql); return(row >= 1); }
internal void SetStatus(StockTrans trans, TransStatusE status, string memo = "") { if (trans.TransStaus != status) { mLog.Status(true, string.Format("任务:{0},原状态:{1}, 新状态:{2}, 备注:{3}", trans.id, trans.TransStaus, status, memo)); trans.TransStaus = status; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.Status); if (status == TransStatusE.取消) { SetCancel(trans); } SendMsg(trans); } }
internal void SetFinish(StockTrans trans) { if (trans.finish_time == null) { mLog.Status(true, string.Format("任务:{0},任务完成:{1}", trans.id, DateTime.Now.ToString())); trans.finish = true; trans.finish_time = DateTime.Now; // 防止设备保存指令,手动后继续执行 //PubTask.Carrier.DoTask(trans.carrier_id, DevCarrierTaskE.终止); //PubTask.Ferry.StopFerry(trans.take_ferry_id, out string res); //PubTask.Ferry.StopFerry(trans.give_ferry_id, out res); PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.Finish); SendMsg(trans); } }
internal void SetStatus(StockTrans trans, TransStatusE status, string memo = "") { if (trans.TransStaus != status) { mLog.Status(true, string.Format("任务[ {0} ], 状态[ {1} -> {2} ], 备注[ {3} ], 持续[ {4} ]", trans.id, trans.TransStaus, status, memo, trans.GetStatusTimeStr())); trans.TransStaus = status; trans.TransStausStayTime = DateTime.Now; PubMaster.Mod.GoodSql.EditStockTrans(trans, TransUpdateE.Status); if (status == TransStatusE.取消) { SetCancel(trans); } SendMsg(trans); } }
// GET: Stock public ActionResult Index(int userId) { StockViewModel stock = new StockViewModel(); List <StockTrans> stockTransIndex = new List <StockTrans>(); stockTransIndex = _stockTransRepo.ListAllTrans(userId); StockTrans stockFiller = new StockTrans(); //stockFiller.StockUserId = userId; //stockTransIndex.Add(stockFiller); //foreach (StockTrans item in stockTransIndex) //{ // item.StockUserId = userId; //} //stock.userJournalId = userId; //stock.Stock.AddRange(stocks); return(View(stockTransIndex)); }
public StockTrans AddStockTrans(StockTrans stock) { int dayNumber = DateTime.Now.DayOfYear; int year = DateTime.Now.Year; DateTime theDate = new DateTime(year, 1, 1).AddDays(dayNumber - 1); //30 days DateTime month = DateTime.Today.AddDays(-29); //7 days DateTime week = DateTime.Today.AddDays(-6); //today DateTime present = DateTime.Today; _dbStockContext.Stock.Add(stock); _dbStockContext.SaveChanges(); return(stock); //throw new NotImplementedException(); }
internal bool UnlockFerry(StockTrans trans, uint ferryid) { if (!Monitor.TryEnter(_obj, TimeSpan.FromSeconds(2))) { return(false); } try { FerryTask task = DevList.Find(c => c.ID == ferryid); if (task != null) { task.SetFerryUnlock(trans.id); } return(true); } finally { Monitor.Exit(_obj); } }
internal bool TryLock(StockTrans trans, uint ferryid, uint carriertrackid) { if (!Monitor.TryEnter(_obj, TimeSpan.FromSeconds(2))) { return(false); } try { FerryTask task = DevList.Find(c => c.ID == ferryid); if (task == null) { return(false); } //小车在摆渡车上,直接锁定 if (task.LeftTrackId == carriertrackid) { if (!task.IsStillLockInTrans(trans.id)) { task.SetFerryLock(trans.id); } return(true); } if (task.IsStillLockInTrans(trans.id)) { return(true); } if (task.IsFerryFree()) { task.SetFerryLock(trans.id); } return(false); } finally { Monitor.Exit(_obj); } }
public ActionResult Delete(int id, IFormCollection collection) { try { StockTrans stock = _stockTransRepo.GetStockTrans(id); StockViewModel stockview = new StockViewModel(); stockview.userJournalId = stock.StockUserId; //stockview.Stock = stock; if (ModelState.IsValid) { _stockTransRepo.DeleteStock(_stockTransRepo.GetStockTrans(id)); ModelState.Clear(); } return(View(stockview)); //return RedirectToAction(nameof(Index), new { id = stockview.userJournalId }); } catch { return(View()); } }
/// <summary> /// 判断是否需要加入流程超时报警 /// 1.超时则添加报警Warning36 /// 2.没超时则删除报警 /// </summary> /// <param name="trans"></param> public void CheckAndAddTransStatusOverTimeWarn(StockTrans trans) { int overtime = PubMaster.Dic.GetDtlIntCode(DicTag.StepOverTime); // 倒库中的流程超时2小时,才报警 if (trans.TransStaus == TransStatusE.倒库中) { overtime = PubMaster.Dic.GetDtlIntCode(DicTag.SortingStockStepOverTime); if (trans.IsInStatusOverTime(trans.TransStaus, overtime)) { PubMaster.Warn.AddTaskWarn(trans.area_id, WarningTypeE.Warning36, 0, trans.id, string.Format("{0}[ {1} ]-[ {2} ]流程已超过2小时,请检查任务相关的设备是否正常", trans.TransType, trans.id, trans.TransStaus)); return; } } //流程超过10分钟,就报警 else if (trans.IsInStatusOverTime(trans.TransStaus, overtime)) { PubMaster.Warn.AddTaskWarn(trans.area_id, WarningTypeE.Warning36, 0, trans.id, string.Format("{0}[ {1} ]-[ {2} ]流程已超过10分钟,请检查任务相关的设备是否正常", trans.TransType, trans.id, trans.TransStaus)); return; } PubMaster.Warn.RemoveTaskWarn(WarningTypeE.Warning36, trans.id); }
public void DeleteStock(StockTrans deletedStock) { _dbStockContext.Stock.Remove(deletedStock); _dbStockContext.SaveChanges(); }
public void UpdateStock(StockTrans changedStock) { _dbStockContext.Entry <StockTrans>(changedStock).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _dbStockContext.SaveChanges(); }