| | |
| | | { |
| | | public class RcsServer:IRcsServer |
| | | { |
| | | private readonly object RcsLock = new object(); |
| | | private readonly object GetPalleLock = new object(); |
| | | private readonly object ApplyLocatLock = new object(); |
| | | |
| | | private static readonly SqlSugarScope Db = DataContext.Db; |
| | | /// <summary> |
| | |
| | | /// <exception cref="Exception"></exception> |
| | | public void GetPalletNo(Pallnetmsg model, string url, out string taskNo) |
| | | { |
| | | lock (RcsLock) |
| | | lock (GetPalleLock) |
| | | { |
| | | try |
| | | { |
| | |
| | | /// <exception cref="Exception"></exception> |
| | | public void ApplyLocatNo(Pallnetmsg model, string url, out string taskNo) |
| | | { |
| | | lock (RcsLock) |
| | | lock (ApplyLocatLock) |
| | | { |
| | | try |
| | | { |
| | |
| | | var taskIng= Db.Queryable<LogTask>().First(w => w.IsDel == "0" && (w.Status == "0" || w.Status == "1") && w.PalletNo == palletNo); |
| | | if (taskIng != null) |
| | | { |
| | | throw new Exception("分配的桶有正在执行的任务,请稍后再试"); |
| | | throw new Exception($"分配的桶{palletNo}有正在执行的任务,请稍后再试"); |
| | | } |
| | | //分配桶的储位信息 |
| | | var locatInfo = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == palletInfo.LocatNo); |
| | |
| | | { |
| | | //public static readonly DataContext Db = new DataContext(); |
| | | |
| | | |
| | | private readonly object GetMaxNoLock = new object(); |
| | | /// <summary> |
| | | /// 获取深度为1的储位号(根据深度为2的储位号) |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | public string GetMaxNo(string codeFlag) |
| | | { |
| | | try |
| | | { |
| | | var maxNo = ""; |
| | | //获取异常号 |
| | | maxNo = SelectMaxNo(codeFlag); |
| | | if (!string.IsNullOrEmpty(maxNo)) |
| | | lock (GetMaxNoLock) |
| | | { |
| | | try |
| | | { |
| | | maxNo = maxNo.Substring(codeFlag.Length); |
| | | } |
| | | //获取数据库时间八位 |
| | | string date = DateTime.Now.ToString("yyyyMMdd").Trim(); |
| | | string no = ""; |
| | | if (string.IsNullOrEmpty(maxNo)) |
| | | { |
| | | no = codeFlag + date + "00001"; |
| | | } |
| | | else |
| | | { |
| | | if (maxNo.Substring(0, 8) == date) |
| | | var maxNo = ""; |
| | | //获取异常号 |
| | | maxNo = SelectMaxNo(codeFlag); |
| | | if (!string.IsNullOrEmpty(maxNo)) |
| | | { |
| | | int lastNo = Convert.ToInt32(maxNo.Substring(8, 5)) + 1; |
| | | no = codeFlag + date + (lastNo.ToString().PadLeft(5, '0')); |
| | | maxNo = maxNo.Substring(codeFlag.Length); |
| | | } |
| | | else |
| | | //获取数据库时间八位 |
| | | string date = DateTime.Now.ToString("yyyyMMdd").Trim(); |
| | | string no = ""; |
| | | if (string.IsNullOrEmpty(maxNo)) |
| | | { |
| | | no = codeFlag + date + "00001"; |
| | | } |
| | | else |
| | | { |
| | | if (maxNo.Substring(0, 8) == date) |
| | | { |
| | | int lastNo = Convert.ToInt32(maxNo.Substring(8, 5)) + 1; |
| | | no = codeFlag + date + (lastNo.ToString().PadLeft(5, '0')); |
| | | } |
| | | else |
| | | { |
| | | no = codeFlag + date + "00001"; |
| | | } |
| | | } |
| | | return no; |
| | | } |
| | | return no; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Console.WriteLine(e); |
| | | throw; |
| | | catch (Exception e) |
| | | { |
| | | Console.WriteLine(e); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |