| | |
| | | using static HH.WCS.ZhongCeJinTan.api.ApiModel; |
| | | using static HH.WCS.ZhongCeJinTan.util.Settings; |
| | | using static HH.WCS.ZhongCeJinTan.wms.WcsModel; |
| | | using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData; |
| | | |
| | | namespace HH.WCS.ZhongCeJinTan.wms |
| | | { |
| | |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var ConnectionList = db.Queryable<Location>().Where(s => s.S_AREA_CODE == S_AREA_CODE && s.C_ENABLE == "Y").OrderBy(a => a.N_ROW).OrderBy(a => a.N_COL).ToList(); |
| | | List<string> result = new List<string>(); |
| | | foreach (var item in ConnectionList) |
| | | { |
| | | result.Add(item.S_CODE); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取货位信息,参数库区编号 |
| | | /// </summary> |
| | | internal static List<string> GetConnectionListByN(string S_AREA_CODE) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var ConnectionList = db.Queryable<Location>().Where(s => s.S_AREA_CODE == S_AREA_CODE && s.C_ENABLE == "N").OrderBy(a => a.N_ROW).OrderBy(a => a.N_COL).ToList(); |
| | | List<string> result = new List<string>(); |
| | | foreach (var item in ConnectionList) |
| | | { |
| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 物料均衡 |
| | | /// </summary> |
| | | /// <param name="lstTrueLocation"></param> |
| | | /// <returns></returns> |
| | | public static List<Location> RoadWayBalance1ByItem(List<Location> lstTrueLocation, string itemCode) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | |
| | | //指定计算后返回的实体 |
| | | List<Location> location_roadray = new List<Location>(); |
| | | |
| | | |
| | | List<connectionBalance> result = new List<connectionBalance>(); |
| | | |
| | | var newlstTrueLocation = lstTrueLocation.GroupBy(c => c.N_ROADWAY) |
| | | .Select(g => g.First()) // 或者 g.FirstOrDefault() |
| | | .ToList(); |
| | | |
| | | foreach (var item in newlstTrueLocation) |
| | | { |
| | | var ConnectionList = 0; |
| | | |
| | | var loclist = lstTrueLocation.Where(o => o.N_ROADWAY == item.N_ROADWAY && o.N_CURRENT_NUM>0).OrderBy(b => b.N_ROW).OrderBy(b => b.N_COL).ToList(); |
| | | foreach (var item1 in loclist) |
| | | { |
| | | var tp = db.Queryable<LocCntrRel>().Where(s => s.S_LOC_CODE == item1.S_CODE).First(); |
| | | |
| | | // LogHelper.Info($"ZCSendTask出库任务下发起点货位容器信息" + JsonConvert.SerializeObject(tp), "Mes任务下发"); |
| | | if (tp != null && item1.S_LOCK_STATE == "无") |
| | | { |
| | | var tp1 = db.Queryable<CntrItemRel>().Where(s => s.S_CNTR_CODE == tp.S_CNTR_CODE).First(); |
| | | //LogHelper.Info($"ZCSendTask出库任务下发起点容器物料信息" + JsonConvert.SerializeObject(tp1), "Mes任务下发"); |
| | | |
| | | if (tp1 != null && tp1.S_ITEM_CODE == itemCode) |
| | | { |
| | | ConnectionList += 1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var re = new connectionBalance(); |
| | | |
| | | var con = LocationHelper.GetLoc(item.S_CODE); |
| | | re.loc = con; |
| | | re.taskCount = ConnectionList; |
| | | result.Add(re); |
| | | } |
| | | |
| | | |
| | | |
| | | result = result.OrderBy(a=>a.taskCount).ToList(); |
| | | |
| | | foreach (var item in result) |
| | | { |
| | | location_roadray.Add(item.loc); |
| | | } |
| | | |
| | | |
| | | return location_roadray; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 返回均衡的接驳位集合 |
| | | /// </summary> |
| | | internal static List<connectionBalance> GetBalanceConnectionList3(List<string> locList) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | List<connectionBalance> result = new List<connectionBalance>(); |
| | | |
| | | foreach (var item in locList) |
| | | { |
| | | var ConnectionList = 0; |
| | | ConnectionList = db.Queryable<WMSTask>().Where(a => (a.S_END_LOC.Contains(item) || a.S_START_LOC.Contains(item)) && a.S_B_STATE != "完成" && a.S_B_STATE != "取消" && a.S_B_STATE != "失败" && a.S_B_STATE != "已完成" && a.S_B_STATE != "未执行").ToList().Count(); |
| | | var re = new connectionBalance(); |
| | | var con = LocationHelper.GetLoc(item); |
| | | re.loc = con; |
| | | re.taskCount = ConnectionList; |
| | | result.Add(re); |
| | | } |
| | | return result.OrderBy(a => a.taskCount).ToList(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 找终点可用空货位排除不可用巷道 |
| | | /// </summary> |
| | | /// <param name="locations"></param> |
| | |
| | | /// </summary> |
| | | /// <param name="locations"></param> |
| | | /// <returns></returns> |
| | | internal static Location FindStartcolByLoclistAndcntr(List<Location> locations,string startArea) { |
| | | internal static Location FindStartcolByLoclistAndcntr(List<Location> locations,string startArea, string CONNECTION = "") { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | |
| | | |
| | | var connectionList = LocationHelper.GetConnectionList(CONNECTION); |
| | | |
| | | |
| | | var balanceConnectionList = LocationHelper.GetConnectionListByst(connectionList); |
| | | |
| | | Location start = null; |
| | | var rowsStart = locations.Select(a => a.N_ROW).Distinct().ToList(); |
| | | |
| | |
| | | |
| | | var flag = false; |
| | | |
| | | var flag2 = false; |
| | | |
| | | foreach (var item in rowdwa) |
| | | { |
| | | if (rowList.Count(a => a.N_ROADWAY.ToString() == item.roadWay) > 0) |
| | |
| | | } |
| | | } |
| | | |
| | | if (flag) |
| | | foreach (var item2 in balanceConnectionList) |
| | | { |
| | | if (rowList.Count(a => a.N_ROADWAY != item2.CONNEC_ROADWAY) > 0) |
| | | { |
| | | flag2 = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (flag || flag2) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="locations"></param> |
| | | /// <returns></returns> |
| | | internal static Location FindStartcolByLoclistAndItem(List<Location> locations,string itemCode,string endArea,string rodway="") |
| | | internal static Location FindStartcolByLoclistAndItem(List<Location> locations,string itemCode,string endArea,string rodway="",string CONNECTION="") |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | Location start = null; |
| | | var rowsStart = locations.Select(a => a.N_ROW).Distinct().ToList(); |
| | | |
| | | |
| | | var connectionList = LocationHelper.GetConnectionListByN(CONNECTION); |
| | | |
| | | |
| | | var balanceConnectionList = LocationHelper.GetConnectionListByst(connectionList); |
| | | |
| | | |
| | | |
| | | LogHelper.Info($"ZCSendTask出库任务排除不可用巷道开始", "Mes任务下发"); |
| | | //作业流程的巷道 |
| | |
| | | } |
| | | else |
| | | { |
| | | //查找可用巷道 |
| | | //查找不可用巷道 |
| | | rowdwa = db.Queryable<RoadWayEnable>().Where(x => x.areaCode == endArea && x.status == "0").ToList(); |
| | | } |
| | | |
| | |
| | | |
| | | var flag = false; |
| | | var flag1 = false; |
| | | var flag2 = false; |
| | | |
| | | foreach (var item in rowdwa) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | if (flag1 || flag) |
| | | foreach (var item2 in balanceConnectionList) |
| | | { |
| | | if (rowList.Count(a => a.N_ROADWAY == item2.CONNEC_ROADWAY) > 0) |
| | | { |
| | | flag2 = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (flag1 || flag || flag2) |
| | | { |
| | | locations.RemoveAll(a => a.N_ROW == rowsStart[i]); |
| | | } |
| | |
| | | |
| | | LogHelper.Info($"ZCSendTask出库任务排除不可用巷道完成", "Mes任务下发"); |
| | | |
| | | foreach (var item in locations) { |
| | | LogHelper.Info($"ZCSendTask出库任务排除完成货位数量{locations.Count}", "Mes任务下发"); |
| | | |
| | | foreach (var item in locations) |
| | | { |
| | | if (item.N_CURRENT_NUM==0) |
| | | { |
| | | continue; |
| | |
| | | LogHelper.Info($"ZCSendTask出库任务下发起点按生产时间排序物料信息" + JsonConvert.SerializeObject(startItem), "Mes任务下发"); |
| | | if (startItem!=null) |
| | | { |
| | | |
| | | |
| | | var tp = db.Queryable<LocCntrRel>().Where(s => s.S_CNTR_CODE == startItem.S_CNTR_CODE).First(); |
| | | start = LocationHelper.GetLocOne(tp.S_LOC_CODE); |
| | | LogHelper.Info($"ZCSendTask出库任务下发起点货位信息" + JsonConvert.SerializeObject(start), "Mes任务下发"); |
| | |
| | | for (int i = 0; i < rowsStart.Count; i++) |
| | | { |
| | | var rowList = locations.Where(r => r.N_ROW == rowsStart[i]).ToList().OrderByDescending(a => a.N_COL); |
| | | |
| | | |
| | | |
| | | |
| | | //rowList.Count(a => a.S_LOCK_STATE.Trim() != "无") > 0 || |
| | | //当前排有锁并且没有满货位,排除 |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取异常库区 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | internal static bool GetErroArea(string area) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var erroArea = db.Queryable<Area>().Where(a => a.S_NAME.Contains("异常") && a.S_CODE.Contains(area)).First(); |
| | | |
| | | if (erroArea == null) |
| | | { |
| | | return false; |
| | | } |
| | | else { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 入库锁定终点,出库锁定起点 |
| | | /// </summary> |
| | | /// <param name="loc"></param> |