| | |
| | | using HH.WCS.QingXigongchang.util; |
| | | using HH.WCS.QingXigongchang.wms; |
| | | using Newtonsoft.Json; |
| | | using NLog.Fluent; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data.SqlClient; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Reflection.Emit; |
| | | using System.Runtime.ConstrainedExecution; |
| | | using System.Security.Cryptography; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Web.Http; |
| | | using System.Web.Security; |
| | | using static HH.WCS.QingXigongchang.api.ApiModel; |
| | | using static HH.WCS.QingXigongchang.dispatch.NDC; |
| | | |
| | | namespace HH.WCS.QingXigongchang.api |
| | | { |
| | |
| | | } |
| | | } |
| | | } |
| | | if (!string.IsNullOrEmpty(item.Trim())) |
| | | if (!"J,F".Contains(SQL_UsingNow) || String.IsNullOrEmpty(SQL_UsingNow)) |
| | | { |
| | | if (locd.S_AREA_CODE.StartsWith("PP")) |
| | | { |
| | | SQL_UsingNow = "F"; |
| | | } |
| | | else if (locd.S_AREA_CODE.Contains("JCJY")) |
| | | { |
| | | SQL_UsingNow = "J"; |
| | | } |
| | | else |
| | | return SimpleResult.Error("指明 即产和非即产的参数 JF 没有明确" + SQL_UsingNow); |
| | | } |
| | | //if (!string.IsNullOrEmpty(item.Trim())) |
| | | // if (!"J,F".Contains(SQL_UsingNow) || String.IsNullOrEmpty(SQL_UsingNow)) |
| | | // { |
| | | // if (locd.S_AREA_CODE.StartsWith("PP")) |
| | | // { |
| | | // SQL_UsingNow = "F"; |
| | | // } |
| | | // else if (locd.S_AREA_CODE.Contains("JCJY")) |
| | | // { |
| | | // SQL_UsingNow = "J"; |
| | | // } |
| | | // else |
| | | // return SimpleResult.Error("指明 即产和非即产的参数 JF 没有明确" + SQL_UsingNow); |
| | | // } |
| | | |
| | | result.resultCode = 0; |
| | | //LocationHelper.BindingLoc(loc.Trim(), "1".Split(',').ToList()); |
| | |
| | | { |
| | | return SimpleResult.Error(loc + " 货位 arco a,r,c,o 指定不明"); |
| | | } |
| | | |
| | | var row = _locs.FindAll(x => x.S_AREA_CODE == locd.S_AREA_CODE && x.N_ROW == locd.N_ROW && x.S_LOCK_STATE != "无" && x.S_LOCK_STATE != "报废"); |
| | | //var rowloc = row.Find(x => x.S_LOCK_STATE != "无"); |
| | | if (row.Any()) |
| | | { |
| | | var row = _locs.FindAll(x => x.S_AREA_CODE == locd.S_AREA_CODE && x.N_ROW == locd.N_ROW && x.S_LOCK_STATE != "无" && x.S_LOCK_STATE != "报废"); |
| | | //var rowloc = row.Find(x => x.S_LOCK_STATE != "无"); |
| | | if (row.Any()) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"所选区域{row.FirstOrDefault().S_LOC_CODE}排有{row.FirstOrDefault().S_LOCK_STATE}状态, 不能进行绑定"; |
| | | return result; |
| | | } |
| | | if (BindORUnbind) |
| | | { |
| | | Location e = _locs.FindAll(x => x.S_AREA_CODE == locd.S_AREA_CODE && x.N_ROW == locd.N_ROW && x.N_CURRENT_NUM > 0).LastOrDefault();//从左往右最后一个满位。 |
| | | if (e != null) |
| | | { |
| | | var rel = LocationHelper.GetLocCntrRel(e.S_LOC_CODE); |
| | | if (rel.FirstOrDefault()?.S_TYPE != item) |
| | | { |
| | | LogHelper.Info($"{e.S_LOC_CODE} 位置的 物料{rel.FirstOrDefault()?.S_TYPE} 与本次绑定{item} 不符。 终止绑定"); |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"{e.S_LOC_CODE} 位置的 物料{rel.FirstOrDefault()?.S_TYPE} 与本次绑定{item} 不符。 终止绑定"; |
| | | return result; |
| | | } |
| | | } |
| | | LocationHelper.DoAction(db => |
| | | { |
| | | var s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| | | int li = 0; |
| | | foreach (var __loc in _locs) |
| | | { |
| | | if (__loc.N_CAPACITY <= __loc.N_CURRENT_NUM) |
| | | continue; |
| | | if (li >= s.Length) |
| | | li = 0; |
| | | string end = s[li].ToString(); |
| | | db.Insertable<LocCntrRel>(new LocCntrRel |
| | | { |
| | | S_LOC_CODE = __loc.S_LOC_CODE.Trim(), |
| | | S_CNTR_CODE = SQL_UsingNow + Settings.GetTimeStamp() + end, |
| | | S_TYPE = item |
| | | }).ExecuteCommand(); |
| | | __loc.N_CURRENT_NUM++; |
| | | if (__loc.N_CURRENT_NUM > __loc.N_CAPACITY) |
| | | __loc.N_CURRENT_NUM = __loc.N_CAPACITY; |
| | | __loc.T_FULL_TIME = DateTime.Now; |
| | | |
| | | db.Updateable<Location>(__loc).UpdateColumns(it => new { it.N_CURRENT_NUM, it.T_FULL_TIME }).ExecuteCommand(); |
| | | li++; |
| | | } |
| | | return true; |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | LocationHelper.DoAction(db => |
| | | { |
| | | foreach (var __loc in _locs) |
| | | { |
| | | if (0 == __loc.N_CURRENT_NUM) |
| | | continue; |
| | | db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE == __loc.S_LOC_CODE.Trim()).ExecuteCommand(); |
| | | |
| | | __loc.N_CURRENT_NUM = 0; |
| | | __loc.T_FULL_TIME = null; |
| | | __loc.T_EMPTY_TIME = DateTime.Now; |
| | | db.Updateable<Location>(__loc).UpdateColumns(it => new { it.N_CURRENT_NUM, it.T_EMPTY_TIME, it.T_FULL_TIME }).ExecuteCommand(); |
| | | } |
| | | return true; |
| | | }); |
| | | } |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"所选区域{row.FirstOrDefault().S_LOC_CODE}排有{row.FirstOrDefault().S_LOCK_STATE}状态, 不能进行绑定"; |
| | | return result; |
| | | } |
| | | if (BindORUnbind) |
| | | { |
| | | Location e = _locs.FindAll(x => x.S_AREA_CODE == locd.S_AREA_CODE && x.N_ROW == locd.N_ROW && x.N_CURRENT_NUM > 0).LastOrDefault();//从左往右最后一个满位。 |
| | | if (e != null) |
| | | { |
| | | var rel = LocationHelper.GetLocCntrRel(e.S_LOC_CODE); |
| | | if (rel.FirstOrDefault()?.S_TYPE != item) |
| | | { |
| | | LogHelper.Info($"{e.S_LOC_CODE} 位置的 物料{rel.FirstOrDefault()?.S_TYPE} 与本次绑定{item} 不符。 终止绑定"); |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"{e.S_LOC_CODE} 位置的 物料{rel.FirstOrDefault()?.S_TYPE} 与本次绑定{item} 不符。 终止绑定"; |
| | | return result; |
| | | } |
| | | } |
| | | LocationHelper.DoAction(db => |
| | | { |
| | | var s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| | | int li = 0; |
| | | foreach (var __loc in _locs) |
| | | { |
| | | if (__loc.N_CAPACITY <= __loc.N_CURRENT_NUM) |
| | | continue; |
| | | if (li >= s.Length) |
| | | li = 0; |
| | | string end = s[li].ToString(); |
| | | db.Insertable<LocCntrRel>(new LocCntrRel |
| | | { |
| | | S_LOC_CODE = __loc.S_LOC_CODE.Trim(), |
| | | S_CNTR_CODE = SQL_UsingNow + Settings.GetTimeStamp() + end, |
| | | S_TYPE = item |
| | | }).ExecuteCommand(); |
| | | __loc.N_CURRENT_NUM++; |
| | | if (__loc.N_CURRENT_NUM > __loc.N_CAPACITY) |
| | | __loc.N_CURRENT_NUM = __loc.N_CAPACITY; |
| | | __loc.T_FULL_TIME = DateTime.Now; |
| | | |
| | | db.Updateable<Location>(__loc).UpdateColumns(it => new { it.N_CURRENT_NUM, it.T_FULL_TIME }).ExecuteCommand(); |
| | | li++; |
| | | } |
| | | return true; |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | LocationHelper.DoAction(db => |
| | | { |
| | | foreach (var __loc in _locs) |
| | | { |
| | | if (0 == __loc.N_CURRENT_NUM) |
| | | continue; |
| | | db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE == __loc.S_LOC_CODE.Trim()).ExecuteCommand(); |
| | | |
| | | __loc.N_CURRENT_NUM = 0; |
| | | __loc.T_FULL_TIME = null; |
| | | __loc.T_EMPTY_TIME = DateTime.Now; |
| | | db.Updateable<Location>(__loc).UpdateColumns(it => new { it.N_CURRENT_NUM, it.T_EMPTY_TIME, it.T_FULL_TIME }).ExecuteCommand(); |
| | | } |
| | | return true; |
| | | }); |
| | | } |
| | | |
| | | } |
| | | lable_end: |
| | | return result; |
| | |
| | | } |
| | | } |
| | | if (startBit == null) |
| | | return SimpleResult.Error("") ; |
| | | return SimpleResult.Error(""); |
| | | locList = LocationHelper.GetAreaNormalLocList("入库区"); |
| | | foreach (var item in locList.GroupBy(x => x.N_ROW).OrderByDescending(x => x.Count(y => y.N_CURRENT_NUM > 0)).ThenBy(x => x.Key)) |
| | | { |