|
@@ -1,7 +1,6 @@
|
|
|
using AutoMapper;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Newtonsoft.Json;
|
|
|
-using NPOI.SS.Formula.Functions;
|
|
|
using SqlSugar;
|
|
|
using SqlSugar.Extensions;
|
|
|
using System;
|
|
@@ -1602,7 +1601,7 @@ namespace wms.service.Service
|
|
|
|
|
|
// 获取各楼层当前任务数
|
|
|
var floorTasks = _taskrepository.AsQueryable()
|
|
|
- .Where(p => p.Type == TaskType.EnterDepot && p.Status < TaskStatus.Finish&&p.BusType== "帘线工字轮入库")
|
|
|
+ .Where(p => p.Type == TaskType.EnterDepot && p.Status < TaskStatus.Finish && p.BusType == "帘线工字轮入库")
|
|
|
.ToList()
|
|
|
.GroupBy(p => p.Floor).ToDictionary(x => x.Key, x => x.Count());
|
|
|
|
|
@@ -3464,8 +3463,7 @@ namespace wms.service.Service
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
-
|
|
|
- _db.RollbackTran();
|
|
|
+ _db.RollbackTran();
|
|
|
_logger.LogInformation(ex.ToString());
|
|
|
res.ResCode = ResponseStatusCodeEnum.InnerServerErr.GetHashCode();
|
|
|
res.ResMsg = "完成码垛任务异常" + ex.Message;
|
|
@@ -7798,99 +7796,18 @@ namespace wms.service.Service
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- var wbgrouplist = invlist.Where(p => p.SkuCode == rule.SkuCode).OrderBy(p => p.ProductTime).GroupBy(p => p.WbGroupCode);
|
|
|
- if (!wbgrouplist.Any())
|
|
|
+ if (rule.SkuCode == "6210010401")
|
|
|
{
|
|
|
- RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut12", new RedisErrorInfo() { Equip = "NoControlOut12", Con = "SKU:" + rule.SkuCode + "下的库存机器组不能为空", Time = DateTime.Now });
|
|
|
- WreTimeOutRecord(invlist.Where(p => p.SkuCode == rule.SkuCode).Select(p => p.ContGrpBarCode).ToList(), "条码信息机器组为空");
|
|
|
-
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- #region 重绕盘老规则
|
|
|
-
|
|
|
- //找到重绕盘,拼接进去,重绕盘不需要扭转
|
|
|
- //var invlistchongrao = from loc in _basewarecellrepository.GetList(p => p.IsStop == LocationStop.LocationInvoke.GetHashCode() && p.StateNum == LocationState.LocationState_Full)
|
|
|
- // join stock in _billInvnowrepository.GetList(p => p.InvStateCode == InvState.InvEcecState_In.ToString() && p.ExecStateCode == InvLockState.InvState_Normal.ToString() && p.Grade == "A" && (p.InDocsNo.StartsWith("CHA")) && string.IsNullOrEmpty(p.PreStock) && p.ContUsageQty <= 0
|
|
|
- // && item.Key.StartsWith(p.MatCode) && p.Wind == rule.Wind && (DateTime.Now - p.OneInTime).TotalHours < timeOutHoldHours)
|
|
|
- // on loc.ContGrpBarCode equals stock.ContGrpBarCode
|
|
|
- // where rule.SkuCode.StartsWith(stock.MatCode) && stock.HWTypeCode == rule.SpoolType
|
|
|
- // select new StockTemp
|
|
|
- // {
|
|
|
- // MatCode = stock.MatCode,
|
|
|
- // InvBarCode = stock.InvBarCode,
|
|
|
- // Grade = stock.Grade,
|
|
|
- // InvStateCode = stock.InvStateCode,
|
|
|
- // ProductTime = stock.ProductTime,
|
|
|
- // WbGroupCode = stock.WbGroupCode,
|
|
|
- // IsTorsChk = stock.IsTorsChk,
|
|
|
- // TorsChkQty = stock.TorsChkQty,
|
|
|
- // TorsChkValue = stock.TorsChkValue,
|
|
|
- // HoldTime = stock.HoldTime,
|
|
|
- // InDocsNo = stock.InDocsNo,
|
|
|
- // ProductMachCode = stock.ProductMachCode,
|
|
|
- // IsControlpanel = stock.IsControlpanel,
|
|
|
- // HWTypeCode = stock.HWTypeCode,
|
|
|
- // SolderCount = stock.SolderCount,
|
|
|
- // IsRework = stock.IsRework,
|
|
|
- // IsBlack = stock.IsBlack,
|
|
|
- // Col = loc.Col,
|
|
|
- // Layer = loc.Layer,
|
|
|
- // Shelf = loc.Shelf,
|
|
|
- // Depth = loc.Depth,
|
|
|
- // Code = loc.Code,
|
|
|
- // Tunnel = loc.Tunnel,
|
|
|
- // SCRel = loc.SCRel,
|
|
|
- // Floor = loc.Floor,
|
|
|
- // WarehouseCode = loc.WarehouseCode,
|
|
|
- // ContGrpBarCode = loc.ContGrpBarCode,
|
|
|
- // ContGrpId = loc.ContGrpId,
|
|
|
- // Id = loc.Id,
|
|
|
- // StateNum = loc.StateNum,
|
|
|
- // SkuCode = "",
|
|
|
- // Wind = stock.Wind
|
|
|
- // };
|
|
|
- //过滤重饶盘被禁用的巷道
|
|
|
- //invlistchongrao = invlistchongrao.Distinct();
|
|
|
- //if (tunlist.Any())
|
|
|
- //{
|
|
|
- // if (tunlist.Where(p => p.Default2 == "1").Any())
|
|
|
- // {
|
|
|
- // var inv1 = invlistchongrao.Where(p => p.Floor == 1 && tunlist.Where(x => x.Default2 == "1").Select(x => x.Default1).ToList().Contains(p.Tunnel.ToString()));
|
|
|
- // var inv2 = inv1.Select(p => p.ContGrpBarCode).ToList();
|
|
|
- // invlistchongrao = invlistchongrao.Where(p => !inv2.Contains(p.ContGrpBarCode)); //过滤1层被禁用的出库巷道
|
|
|
- // }
|
|
|
- // if (tunlist.Where(p => p.Default2 == "2").Any())
|
|
|
- // {
|
|
|
- // var inv1 = invlistchongrao.Where(p => p.Floor == 2 && tunlist.Where(x => x.Default2 == "2").Select(x => x.Default1).ToList().Contains(p.Tunnel.ToString()));
|
|
|
- // var inv2 = inv1.Select(p => p.ContGrpBarCode).ToList();
|
|
|
- // invlistchongrao = invlistchongrao.Where(p => !inv2.Contains(p.ContGrpBarCode)); //过滤2层被禁用的出库巷道
|
|
|
- // }
|
|
|
- // if (tunlist.Where(p => p.Default2 == "3").Any())
|
|
|
- // {
|
|
|
- // var inv1 = invlistchongrao.Where(p => p.Floor == 3 && tunlist.Where(x => x.Default2 == "3").Select(x => x.Default1).ToList().Contains(p.Tunnel.ToString()));
|
|
|
- // var inv2 = inv1.Select(p => p.ContGrpBarCode).ToList();
|
|
|
- // invlistchongrao = invlistchongrao.Where(p => !inv2.Contains(p.ContGrpBarCode)); //过滤3层被禁用的出库巷道
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //重绕盘数量限制BS80 10个(30%);BS60 21个(30%);BS40 21个(30%)
|
|
|
- //if (rule.SpoolType == "BS60" || rule.SpoolType == "BS40")
|
|
|
- //{
|
|
|
- // invlistchongrao = invlistchongrao.Take(21);
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // invlistchongrao = invlistchongrao.Take(10);
|
|
|
- //}
|
|
|
+ var wbgroup = invlist.Where(p => p.SkuCode == rule.SkuCode).OrderBy(p => p.ProductTime);
|
|
|
+ if (!wbgroup.Any())
|
|
|
+ {
|
|
|
+ RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut12", new RedisErrorInfo() { Equip = "NoControlOut12", Con = "SKU:" + rule.SkuCode + "下的库存机器组不能为空1", Time = DateTime.Now });
|
|
|
+ WreTimeOutRecord(invlist.Where(p => p.SkuCode == rule.SkuCode).Select(p => p.ContGrpBarCode).ToList(), "条码信息机器组为空1");
|
|
|
|
|
|
- #endregion 重绕盘老规则
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
-;
|
|
|
- //机器组循环
|
|
|
- foreach (var wbgroup in wbgrouplist)
|
|
|
- {
|
|
|
- invlist2 = invlist.Where(p => p.SkuCode == item.Key && p.WbGroupCode == wbgroup.Key && p.HWTypeCode == rule.SpoolType && p.Wind == rule.Wind);
|
|
|
+ invlist2 = invlist.Where(p => p.SkuCode == item.Key && p.HWTypeCode == rule.SpoolType && p.Wind == rule.Wind);
|
|
|
|
|
|
//invlist2 = invlistchongrao.Union(invlist2);
|
|
|
|
|
@@ -7899,7 +7816,7 @@ namespace wms.service.Service
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- WreTimeOutRecord(invlist2.Select(p => p.ContGrpBarCode).ToList(), "不满足装箱数量,数量为" + invlist2.Count() + ",SKU:" + item.Key + ",机器组;" + wbgroup.Key + ",型号:" + rule.SpoolType + ",绕向:" + rule.Wind);
|
|
|
+ WreTimeOutRecord(invlist2.Select(p => p.ContGrpBarCode).ToList(), "不满足装箱数量,数量为" + invlist2.Count() + ",SKU:" + item.Key + ",机器组;" + "999999999999" + ",型号:" + rule.SpoolType + ",绕向:" + rule.Wind);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -7950,13 +7867,13 @@ namespace wms.service.Service
|
|
|
RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut15", new RedisErrorInfo() { Equip = "NoControlOut15", Con = msg, Time = DateTime.Now });
|
|
|
_logger.LogInformation("非控制不满足装箱:" + msg);
|
|
|
res.ResMsg = msg;
|
|
|
- WreTimeOutRecord(tempoutrecord.Select(p => p.ContGrpBarCode).ToList(), "焊点不满足," + "SKU:" + rule.SkuCode + ",机器组:" + tempoutrecord.First().WbGroupCode + ",绕向:" + rule.Wind);
|
|
|
+ WreTimeOutRecord(tempoutrecord.Select(p => p.ContGrpBarCode).ToList(), "焊点不满足," + "SKU:" + rule.SkuCode + ",机器组:" + "999999999999" + ",绕向:" + rule.Wind);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if ((invlist2.Count() + solderinvlist.Count + returninvlist.Count) < rule.FullCountQty)
|
|
|
{
|
|
|
- string msg = "sku:" + rule.SkuCode + ",机器组:" + invlist2.First().WbGroupCode + ",绕向:" + rule.Wind + ",型号:" + invlist2.First().HWTypeCode + ",SPC非控制箱不满足装箱数量,需要装" + rule.FullCountQty + "实际数量:" + (invlist2.Count() + solderinvlist.Count + returninvlist.Count) + ";普通盘" + invlist2.Count() + ",焊点盘" + solderinvlist.Count + ",返工盘" + returninvlist.Count;
|
|
|
+ string msg = "sku:" + rule.SkuCode + ",机器组:" + "999999999999" + ",绕向:" + rule.Wind + ",型号:" + invlist2.First().HWTypeCode + ",SPC非控制箱不满足装箱数量,需要装" + rule.FullCountQty + "实际数量:" + (invlist2.Count() + solderinvlist.Count + returninvlist.Count) + ";普通盘" + invlist2.Count() + ",焊点盘" + solderinvlist.Count + ",返工盘" + returninvlist.Count;
|
|
|
RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut16", new RedisErrorInfo() { Equip = "NoControlOut16", Con = msg, Time = DateTime.Now });
|
|
|
_logger.LogInformation("非控制不满足装箱:" + msg);
|
|
|
res.ResMsg = msg;
|
|
@@ -8047,11 +7964,11 @@ namespace wms.service.Service
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (finstocks.Where(p => !string.IsNullOrWhiteSpace(p.WbGroupCode) && !p.InDocsNo.Contains("CHA")).Select(p => p.WbGroupCode).Distinct().Count() > 1)
|
|
|
- {
|
|
|
- _logger.LogInformation("非控制盘最终检查装箱机器组大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
- continue;
|
|
|
- }
|
|
|
+ //if (finstocks.Where(p => !string.IsNullOrWhiteSpace(p.WbGroupCode) && !p.InDocsNo.Contains("CHA")).Select(p => p.WbGroupCode).Distinct().Count() > 1)
|
|
|
+ //{
|
|
|
+ // _logger.LogInformation("非控制盘最终检查装箱机器组大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ // continue;
|
|
|
+ //}
|
|
|
if (finstocks.Select(p => p.HWTypeCode).Distinct().Count() > 1)
|
|
|
{
|
|
|
_logger.LogInformation("非控制盘最终检查装箱轮子种类大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
@@ -8130,6 +8047,341 @@ namespace wms.service.Service
|
|
|
|
|
|
#endregion Mes箱号校验
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var wbgrouplist = invlist.Where(p => p.SkuCode == rule.SkuCode).OrderBy(p => p.ProductTime).GroupBy(p => p.WbGroupCode);
|
|
|
+ if (!wbgrouplist.Any())
|
|
|
+ {
|
|
|
+ RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut12", new RedisErrorInfo() { Equip = "NoControlOut12", Con = "SKU:" + rule.SkuCode + "下的库存机器组不能为空", Time = DateTime.Now });
|
|
|
+ WreTimeOutRecord(invlist.Where(p => p.SkuCode == rule.SkuCode).Select(p => p.ContGrpBarCode).ToList(), "条码信息机器组为空");
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 重绕盘老规则
|
|
|
+
|
|
|
+ //找到重绕盘,拼接进去,重绕盘不需要扭转
|
|
|
+ //var invlistchongrao = from loc in _basewarecellrepository.GetList(p => p.IsStop == LocationStop.LocationInvoke.GetHashCode() && p.StateNum == LocationState.LocationState_Full)
|
|
|
+ // join stock in _billInvnowrepository.GetList(p => p.InvStateCode == InvState.InvEcecState_In.ToString() && p.ExecStateCode == InvLockState.InvState_Normal.ToString() && p.Grade == "A" && (p.InDocsNo.StartsWith("CHA")) && string.IsNullOrEmpty(p.PreStock) && p.ContUsageQty <= 0
|
|
|
+ // && item.Key.StartsWith(p.MatCode) && p.Wind == rule.Wind && (DateTime.Now - p.OneInTime).TotalHours < timeOutHoldHours)
|
|
|
+ // on loc.ContGrpBarCode equals stock.ContGrpBarCode
|
|
|
+ // where rule.SkuCode.StartsWith(stock.MatCode) && stock.HWTypeCode == rule.SpoolType
|
|
|
+ // select new StockTemp
|
|
|
+ // {
|
|
|
+ // MatCode = stock.MatCode,
|
|
|
+ // InvBarCode = stock.InvBarCode,
|
|
|
+ // Grade = stock.Grade,
|
|
|
+ // InvStateCode = stock.InvStateCode,
|
|
|
+ // ProductTime = stock.ProductTime,
|
|
|
+ // WbGroupCode = stock.WbGroupCode,
|
|
|
+ // IsTorsChk = stock.IsTorsChk,
|
|
|
+ // TorsChkQty = stock.TorsChkQty,
|
|
|
+ // TorsChkValue = stock.TorsChkValue,
|
|
|
+ // HoldTime = stock.HoldTime,
|
|
|
+ // InDocsNo = stock.InDocsNo,
|
|
|
+ // ProductMachCode = stock.ProductMachCode,
|
|
|
+ // IsControlpanel = stock.IsControlpanel,
|
|
|
+ // HWTypeCode = stock.HWTypeCode,
|
|
|
+ // SolderCount = stock.SolderCount,
|
|
|
+ // IsRework = stock.IsRework,
|
|
|
+ // IsBlack = stock.IsBlack,
|
|
|
+ // Col = loc.Col,
|
|
|
+ // Layer = loc.Layer,
|
|
|
+ // Shelf = loc.Shelf,
|
|
|
+ // Depth = loc.Depth,
|
|
|
+ // Code = loc.Code,
|
|
|
+ // Tunnel = loc.Tunnel,
|
|
|
+ // SCRel = loc.SCRel,
|
|
|
+ // Floor = loc.Floor,
|
|
|
+ // WarehouseCode = loc.WarehouseCode,
|
|
|
+ // ContGrpBarCode = loc.ContGrpBarCode,
|
|
|
+ // ContGrpId = loc.ContGrpId,
|
|
|
+ // Id = loc.Id,
|
|
|
+ // StateNum = loc.StateNum,
|
|
|
+ // SkuCode = "",
|
|
|
+ // Wind = stock.Wind
|
|
|
+ // };
|
|
|
+ //过滤重饶盘被禁用的巷道
|
|
|
+ //invlistchongrao = invlistchongrao.Distinct();
|
|
|
+ //if (tunlist.Any())
|
|
|
+ //{
|
|
|
+ // if (tunlist.Where(p => p.Default2 == "1").Any())
|
|
|
+ // {
|
|
|
+ // var inv1 = invlistchongrao.Where(p => p.Floor == 1 && tunlist.Where(x => x.Default2 == "1").Select(x => x.Default1).ToList().Contains(p.Tunnel.ToString()));
|
|
|
+ // var inv2 = inv1.Select(p => p.ContGrpBarCode).ToList();
|
|
|
+ // invlistchongrao = invlistchongrao.Where(p => !inv2.Contains(p.ContGrpBarCode)); //过滤1层被禁用的出库巷道
|
|
|
+ // }
|
|
|
+ // if (tunlist.Where(p => p.Default2 == "2").Any())
|
|
|
+ // {
|
|
|
+ // var inv1 = invlistchongrao.Where(p => p.Floor == 2 && tunlist.Where(x => x.Default2 == "2").Select(x => x.Default1).ToList().Contains(p.Tunnel.ToString()));
|
|
|
+ // var inv2 = inv1.Select(p => p.ContGrpBarCode).ToList();
|
|
|
+ // invlistchongrao = invlistchongrao.Where(p => !inv2.Contains(p.ContGrpBarCode)); //过滤2层被禁用的出库巷道
|
|
|
+ // }
|
|
|
+ // if (tunlist.Where(p => p.Default2 == "3").Any())
|
|
|
+ // {
|
|
|
+ // var inv1 = invlistchongrao.Where(p => p.Floor == 3 && tunlist.Where(x => x.Default2 == "3").Select(x => x.Default1).ToList().Contains(p.Tunnel.ToString()));
|
|
|
+ // var inv2 = inv1.Select(p => p.ContGrpBarCode).ToList();
|
|
|
+ // invlistchongrao = invlistchongrao.Where(p => !inv2.Contains(p.ContGrpBarCode)); //过滤3层被禁用的出库巷道
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //重绕盘数量限制BS80 10个(30%);BS60 21个(30%);BS40 21个(30%)
|
|
|
+ //if (rule.SpoolType == "BS60" || rule.SpoolType == "BS40")
|
|
|
+ //{
|
|
|
+ // invlistchongrao = invlistchongrao.Take(21);
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // invlistchongrao = invlistchongrao.Take(10);
|
|
|
+ //}
|
|
|
+
|
|
|
+ #endregion 重绕盘老规则
|
|
|
+
|
|
|
+;
|
|
|
+ //机器组循环
|
|
|
+ foreach (var wbgroup in wbgrouplist)
|
|
|
+ {
|
|
|
+ invlist2 = invlist.Where(p => p.SkuCode == item.Key && p.WbGroupCode == wbgroup.Key && p.HWTypeCode == rule.SpoolType && p.Wind == rule.Wind);
|
|
|
+
|
|
|
+ //invlist2 = invlistchongrao.Union(invlist2);
|
|
|
+
|
|
|
+ if (invlist2.Any() && invlist2.Count() >= rule.FullCountQty)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ WreTimeOutRecord(invlist2.Select(p => p.ContGrpBarCode).ToList(), "不满足装箱数量,数量为" + invlist2.Count() + ",SKU:" + item.Key + ",机器组;" + wbgroup.Key + ",型号:" + rule.SpoolType + ",绕向:" + rule.Wind);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(rule.SpoolType))
|
|
|
+ {
|
|
|
+ invlist2 = invlist2.Where(p => p.HWTypeCode == rule.SpoolType);
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty(rule.Wind))
|
|
|
+ {
|
|
|
+ invlist2 = invlist2.Where(p => p.Wind == rule.Wind);
|
|
|
+ }
|
|
|
+
|
|
|
+ //焊点属性筛选
|
|
|
+ var tempoutrecord = invlist2.ToList();
|
|
|
+
|
|
|
+ var solderinvlist = new List<StockTemp>();
|
|
|
+ if (rule.PerSolderMaxCount > 0) //允许焊点盘
|
|
|
+ {
|
|
|
+ int rulemaxcount = rule.FullCountQty / ((rule.SpoolType == "BS60" || rule.SpoolType == "BS40") ? 72 : 36) * rule.SolderMaxCount;
|
|
|
+ var solcount = rulemaxcount;
|
|
|
+ if (solcount <= 0)
|
|
|
+ {
|
|
|
+ solcount = 0;
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ solderinvlist = invlist2.Where(p => p.SolderCount <= rule.PerSolderMaxCount && p.SolderCount > 0).OrderBy(p => p.ProductTime).ThenByDescending(p => p.SolderCount).Take(solcount).ToList();
|
|
|
+ invlist2 = invlist2.Where(p => p.SolderCount == 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //不允许焊点盘
|
|
|
+ invlist2 = invlist2.Where(p => p.SolderCount == 0).OrderBy(p => p.ProductTime);
|
|
|
+ }
|
|
|
+ var returninvlist = new List<StockTemp>();
|
|
|
+ if (rule.ReturnCount > 0)
|
|
|
+ {
|
|
|
+ returninvlist = invlist2.Where(p => p.IsRework == true).Take(rule.ReturnCount).ToList();
|
|
|
+ invlist2 = invlist2.Where(p => p.IsRework == false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ invlist2 = invlist2.Where(p => p.IsRework == false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!invlist2.Any())
|
|
|
+ {
|
|
|
+ string msg = "SPC非控制箱不满足装箱规则,箱号:" + rule.PBoxCode + "sku:" + rule.SkuCode;
|
|
|
+ RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut15", new RedisErrorInfo() { Equip = "NoControlOut15", Con = msg, Time = DateTime.Now });
|
|
|
+ _logger.LogInformation("非控制不满足装箱:" + msg);
|
|
|
+ res.ResMsg = msg;
|
|
|
+ WreTimeOutRecord(tempoutrecord.Select(p => p.ContGrpBarCode).ToList(), "焊点不满足," + "SKU:" + rule.SkuCode + ",机器组:" + tempoutrecord.First().WbGroupCode + ",绕向:" + rule.Wind);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((invlist2.Count() + solderinvlist.Count + returninvlist.Count) < rule.FullCountQty)
|
|
|
+ {
|
|
|
+ string msg = "sku:" + rule.SkuCode + ",机器组:" + invlist2.First().WbGroupCode + ",绕向:" + rule.Wind + ",型号:" + invlist2.First().HWTypeCode + ",SPC非控制箱不满足装箱数量,需要装" + rule.FullCountQty + "实际数量:" + (invlist2.Count() + solderinvlist.Count + returninvlist.Count) + ";普通盘" + invlist2.Count() + ",焊点盘" + solderinvlist.Count + ",返工盘" + returninvlist.Count;
|
|
|
+ RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut16", new RedisErrorInfo() { Equip = "NoControlOut16", Con = msg, Time = DateTime.Now });
|
|
|
+ _logger.LogInformation("非控制不满足装箱:" + msg);
|
|
|
+ res.ResMsg = msg;
|
|
|
+ WreTimeOutRecord(invlist2.Select(p => p.ContGrpBarCode).ToList(), msg);
|
|
|
+ WreTimeOutRecord(returninvlist.Select(p => p.ContGrpBarCode).ToList(), msg);
|
|
|
+ WreTimeOutRecord(solderinvlist.Select(p => p.ContGrpBarCode).ToList(), msg);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ var firstproducttime = invlist2.OrderBy(p => p.ProductTime).First().ProductTime;
|
|
|
+ var invlist2temp6hours = invlist2.ToList().Where(p => (p.ProductTime - firstproducttime).TotalHours <= 72); //72小时之内的按堆垛机平均分
|
|
|
+
|
|
|
+ #region 按照堆垛机平均分配任务,6小时之内
|
|
|
+
|
|
|
+ var tempcount = rule.FullCountQty - (solderinvlist.Count + returninvlist.Count);//符合条件的普通盘数量
|
|
|
+ var mastinvlist = solderinvlist.Union(returninvlist);
|
|
|
+ var tempinvlist = invlist2temp6hours.Union(mastinvlist);
|
|
|
+ var srmlist = tempinvlist.Select(p => p.SCRel).Distinct();//总共多少个堆垛机
|
|
|
+
|
|
|
+ var mustsrmtasktobe = from x in mastinvlist.GroupBy(p => p.SCRel)
|
|
|
+ select new SrmTaskTmep
|
|
|
+ {
|
|
|
+ Srm = x.Key,
|
|
|
+ TaskCount = x.Count(),
|
|
|
+ LocList = x.Select(q => q.Code).ToList()
|
|
|
+ };
|
|
|
+ var srmtasktobe = new List<SrmTaskTmep>();
|
|
|
+
|
|
|
+ foreach (var srmlistitem in srmlist)
|
|
|
+ {
|
|
|
+ if (!mustsrmtasktobe.Where(p => p.Srm == srmlistitem).Any())
|
|
|
+ {
|
|
|
+ srmtasktobe.Add(new SrmTaskTmep()
|
|
|
+ {
|
|
|
+ Srm = srmlistitem,
|
|
|
+ TaskCount = 0,
|
|
|
+ LocList = new List<string>()
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ srmtasktobe.AddRange(mustsrmtasktobe);//所有堆垛机任务数量,接占用的库位数
|
|
|
+ var srmtasktobetemplocs = new List<string>();
|
|
|
+ for (int i = 0; i < tempcount; i++)
|
|
|
+ {
|
|
|
+ srmtasktobe = srmtasktobe.OrderBy(p => p.LocList.Count).ToList();//堆垛机任务排序,少的优先
|
|
|
+ var templocs = srmtasktobe.SelectMany(q => q.LocList);
|
|
|
+ foreach (var srmtasktobeitem in srmtasktobe)
|
|
|
+ {
|
|
|
+ if (tempinvlist.Where(p => !templocs.Contains(p.Code) && srmtasktobeitem.Srm == p.SCRel).Any())
|
|
|
+ {
|
|
|
+ var first = tempinvlist.Where(p => !templocs.Contains(p.Code) && srmtasktobeitem.Srm == p.SCRel).OrderBy(p => p.Depth).ThenBy(p => p.ProductTime).First();
|
|
|
+ srmtasktobe.Where(p => p.Srm == srmtasktobeitem.Srm).First().LocList.Add(first.Code);
|
|
|
+ srmtasktobetemplocs.Add(first.Code);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 按照堆垛机平均分配任务,6小时之内
|
|
|
+
|
|
|
+ var tempbuchong = new List<StockTemp>();
|
|
|
+ if (tempcount > srmtasktobetemplocs.Count())
|
|
|
+ {
|
|
|
+ tempbuchong = invlist2.Where(p => !srmtasktobetemplocs.Contains(p.Code)).OrderBy(p => p.Depth).ThenBy(p => p.ProductTime).Take(tempcount - srmtasktobetemplocs.Count()).ToList();
|
|
|
+ }
|
|
|
+ invlist2 = invlist2.Where(p => srmtasktobetemplocs.Contains(p.Code)).OrderBy(p => p.Depth).ThenBy(p => p.ProductTime).Take(rule.FullCountQty - (solderinvlist.Count + returninvlist.Count));
|
|
|
+ invlist2 = invlist2.Union(solderinvlist).Union(returninvlist);
|
|
|
+ invlist2 = invlist2.Union(tempbuchong);
|
|
|
+
|
|
|
+ var finstocks = invlist2.ToList();
|
|
|
+ //最后验证数据
|
|
|
+
|
|
|
+ #region 最后验证数据
|
|
|
+
|
|
|
+ if (finstocks.Select(p => p.ContGrpBarCode).Distinct().Count() != 36 && finstocks.Select(p => p.ContGrpBarCode).Distinct().Count() != 72)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("非控制盘最终检查装箱数量不配置ContGrpBarCode" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (finstocks.Select(p => p.ContGrpId).Distinct().Count() != 36 && finstocks.Select(p => p.ContGrpId).Distinct().Count() != 72)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("非控制盘最终检查装箱数量不配置ContGrpId" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (finstocks.Select(p => p.Wind).Distinct().Count() > 1)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("非控制盘最终检查装箱绕向大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (finstocks.Where(p => !string.IsNullOrWhiteSpace(p.WbGroupCode) && !p.InDocsNo.Contains("CHA")).Select(p => p.WbGroupCode).Distinct().Count() > 1)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("非控制盘最终检查装箱机器组大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (finstocks.Select(p => p.HWTypeCode).Distinct().Count() > 1)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("非控制盘最终检查装箱轮子种类大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (finstocks.Select(p => p.MatCode).Distinct().Count() > 1)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("非控制盘最终检查物料种类大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ var docs = finstocks.Select(p => p.InDocsNo).Distinct().ToList();
|
|
|
+ if (_boxrulerepository.AsQueryable().With(SqlWith.NoLock).Where(p => p.PackRule == "SPC" && docs.Contains(p.DocsNo)).Select(p => p.SkuCode).Distinct().Count() > 1)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("非控制盘最终检查SKU种类大于1" + string.Format("{0},{1},{2},{3}", invlist2.First().WbGroupCode, invlist2.First().Wind, invlist2.First().SkuCode, invlist2.First().HWTypeCode));
|
|
|
+ _logger.LogInformation("非控制盘最终检查SKU种类大于1" + JsonConvert.SerializeObject(finstocks.Select(p => p.ContGrpBarCode).Distinct().ToList()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 最后验证数据
|
|
|
+
|
|
|
+ #region Mes箱号校验
|
|
|
+
|
|
|
+ var boxmes = new MesBoxVerify() { HuNr = rule.PBoxCode, Batch = rule.BatchNo };
|
|
|
+ var url = wms.util.AppSettings.GetConfig("EsbMesPushUrl");
|
|
|
+ var reqids = Guid.NewGuid().ToString();
|
|
|
+ var reqs = new EsbReq() { headers = new HeadersReq() { serviceCode = "163K162003", requestId = reqids, TrackId = reqids, sourceCode = "163K" } };
|
|
|
+ var str = HttpUtil.PostRequest(url, JsonConvert.SerializeObject(boxmes), 30000, "UTF-8", "application/json", reqids, reqs.headers.sourceCode, reqs.headers.serviceCode);
|
|
|
+ var mesresponse = JsonConvert.DeserializeObject<TorschMesResponse>(str);
|
|
|
+ _logger.LogInformation("非控制装箱:申请箱号mes返回" + str);
|
|
|
+
|
|
|
+ if (mesresponse.success == false)
|
|
|
+ {
|
|
|
+ _boxrulerepository.UpdateSetColumnsTrue(p => new BillPboxrule()
|
|
|
+ {
|
|
|
+ ZXStateCode = 2,
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ Memo = mesresponse.message
|
|
|
+ }, p => p.Id == rule.Id);
|
|
|
+ RedisHelper.Set("Sx:WMSErrorInfo:NoControlOut17", new RedisErrorInfo() { Equip = "NoControlOut17", Con = "非控制装箱mes申请箱号返回:" + mesresponse.message, Time = DateTime.Now });
|
|
|
+ res.ResCode = ResponseStatusCodeEnum.ErrParam.GetHashCode();
|
|
|
+ res.ResMsg = "非控制装箱:申请箱号mes返回" + mesresponse.message;
|
|
|
+ _logger.LogInformation(res.ResMsg);
|
|
|
+ WreTimeOutRecord(invlist2.Select(p => p.ContGrpBarCode).ToList(), "非控制装箱:申请箱号mes返回" + mesresponse.message);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var listid = finstocks.Select(p => p.ContGrpId).ToList();
|
|
|
+ _db.BeginTran();
|
|
|
+ //非控制箱预占状态更新成4
|
|
|
+ _boxrulerepository.UpdateSetColumnsTrue(p => new BillPboxrule()
|
|
|
+ {
|
|
|
+ ZXStateCode = 4,
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ Memo = mesresponse.message
|
|
|
+ }, p => p.Id == rule.Id);
|
|
|
+ var presign = rule.Id.ToString();
|
|
|
+ _billInvnowrepository.UpdateSetColumnsTrue(p => new BillInvnow()
|
|
|
+ {
|
|
|
+ PreStock = presign,
|
|
|
+ EditTime = DateTime.Now,
|
|
|
+ Memo = "箱号预占用:" + rule.PBoxCode
|
|
|
+ }, p => listid.Contains(p.ContGrpId));
|
|
|
+ _db.CommitTran();
|
|
|
+ _logger.LogInformation(rule.PBoxCode + "预占:" + JsonConvert.SerializeObject(listid));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ _logger.LogInformation("箱号预占用异常" + ex.ToString());
|
|
|
+ _db.RollbackTran();
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion Mes箱号校验
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return res;
|
|
@@ -13315,7 +13567,7 @@ namespace wms.service.Service
|
|
|
cell = cell.Where(p => !disids.Contains(p.Id)).ToList();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const int MinAvailableCells = 30;// 最小有效货位数量,用于保留移库
|
|
|
var forbidLayer = wms.util.AppSettings.GetConfig("ForbidLayer");
|
|
|
// 定义楼层信息结构
|