| | |
| | | using HH.WCS.XiaoMi.util; |
| | | using Opc.Ua; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | } |
| | | return res; |
| | | } |
| | | public static bool UnBindingLocHj(string loc, string frame) |
| | | { |
| | | var res = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var lcrList = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).ToList(); |
| | | var count = db.Deleteable<LocCntrRel>().Where(it => frame==it.S_FRAME_CODE.Trim() && it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); |
| | | location.N_CURRENT_NUM = lcrList.Count - count; |
| | | location.S_LOCK_STATE = "无"; |
| | | location.N_LOCK_STATE = 0; |
| | | db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM, it.S_LOCK_STATE, it.N_LOCK_STATE }).ExecuteCommand(); |
| | | db.CommitTran(); |
| | | res = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.RollbackTran(); |
| | | } |
| | | return res; |
| | | } |
| | | /// <summary> |
| | | /// 货位绑定容器 |
| | | /// </summary> |
| | |
| | | } |
| | | return res; |
| | | } |
| | | /// <summary> |
| | | /// 货位绑定货架 小米 |
| | | /// </summary> |
| | | /// <param name="loc"></param> |
| | | /// <param name="cntrs"></param> |
| | | /// <returns></returns> |
| | | public static bool BindingLocHj(string loc, string frame) |
| | | { |
| | | var res = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | try |
| | | { |
| | | var lcrList = db.Queryable<LocCntrRel>().Includes(a => a.Container).Where(a => a.S_LOC_CODE.Trim() == loc).ToList(); |
| | | db.BeginTran(); |
| | | int count = 0; |
| | | if (lcrList.Count(b => b.S_CNTR_CODE.Trim() == frame) == 0) |
| | | { |
| | | db.Insertable<LocCntrRel>(new LocCntrRel { S_LOC_CODE = loc, S_FRAME_CODE = frame }).ExecuteCommand(); |
| | | count++; |
| | | } |
| | | location.N_CURRENT_NUM = lcrList.Count + count; |
| | | location.N_LOCK_STATE = 0; |
| | | location.S_LOCK_STATE = "无"; |
| | | db.Updateable(location).UpdateColumns(it => new { it.N_CURRENT_NUM, it.S_LOCK_STATE, it.N_LOCK_STATE }).ExecuteCommand(); |
| | | |
| | | db.CommitTran(); |
| | | res = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.Message); |
| | | db.RollbackTran(); |
| | | } |
| | | return res; |
| | | } |
| | | /// <summary> |
| | | /// 判断逻辑库区是否有可用货位 |
| | | /// </summary> |