| | |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | try |
| | | { |
| | | LogHelper.Info($"BindingLoc:开始解绑容器:{JsonConvert.SerializeObject(cntrs)}"); |
| | | db.BeginTran(); |
| | | var lcrList = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).ToList(); |
| | | //if (!string.IsNullOrEmpty(location.S_NOTE) && lcrList.Count > 0) |
| | |
| | | { |
| | | cntrs = lcrList.Select(a => a.S_CNTR_CODE).ToList(); |
| | | } |
| | | LogHelper.Info($"BindingLoc:开始解绑容器:{cntrs}"); |
| | | var count = db.Deleteable<LocCntrRel>().Where(it => cntrs.Contains(it.S_CNTR_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(); |
| | | LogHelper.Info($"BindingLoc:解绑容器:{cntrs},成功"); |
| | | LogHelper.Info($"BindingLoc:解绑容器:{JsonConvert.SerializeObject(cntrs)}成功"); |
| | | db.CommitTran(); |
| | | res = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"BindingLoc Error:{ex}"); |
| | | db.RollbackTran(); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 库位清空 |
| | | /// </summary> |
| | | /// <param name="loc"></param> |
| | | /// <param name="cntrs"></param> |
| | | /// <returns></returns> |
| | | public static bool Clear(string loc, List<string> cntrs) |
| | | { |
| | | var res = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | try |
| | | { |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location == null) |
| | | { |
| | | LogHelper.Info($"Clear:货位:{loc}货位表查询错误,请假查货位表"); |
| | | return res; |
| | | } |
| | | LogHelper.Info($"Clear:开始解绑容器:{JsonConvert.SerializeObject(cntrs)}"); |
| | | db.BeginTran(); |
| | | var lcrList = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).ToList(); |
| | | if (lcrList.Count > 0) |
| | | { |
| | | cntrs = lcrList.Select(a => a.S_CNTR_CODE).ToList(); |
| | | } |
| | | var count = db.Deleteable<LocCntrRel>().Where(it => cntrs.Contains(it.S_CNTR_CODE.Trim()) && it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); |
| | | LogHelper.Info($"Clear:开始删除容器:{JsonConvert.SerializeObject(cntrs)}"); |
| | | db.Deleteable<Container>().Where(it => cntrs.Contains(it.S_CODE)).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(); |
| | | LogHelper.Info($"Clear:开始删除容器物料:{JsonConvert.SerializeObject(cntrs)}"); |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => cntrs.Contains(a.S_CNTR_CODE.Trim())).First(); |
| | | if (CntrItem != null) |
| | | { |
| | | db.Deleteable<CntrItemDetail>().Where(it => cntrs.Contains(it.S_CNTR_CODE)).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"Clear=》托盘:{JsonConvert.SerializeObject(cntrs)}无物料数据"); |
| | | |
| | | } |
| | | LogHelper.Info($"BindingLoc:解绑容器:{JsonConvert.SerializeObject(cntrs)}成功"); |
| | | db.CommitTran(); |
| | | res = true; |
| | | } |