|
|
@@ -49,6 +49,7 @@ using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
|
using Hangfire.Server;
|
|
|
using WkHtmlToPdfDotNet;
|
|
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
|
|
+using Microsoft.AspNetCore.SignalR;
|
|
|
|
|
|
namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
@@ -253,9 +254,9 @@ namespace Business.ResourceExamineManagement
|
|
|
IMongoDB<srm_po_occupy> srm_po_occupy,
|
|
|
IMongoDB<ic_item_pur> ic_item_pur,
|
|
|
IMongoDB<ic_plan> ic_plan,
|
|
|
- //IMongoDB<ic_substitute> ic_substitute,
|
|
|
- //IMongoDB<ic_substitute_all> ic_substitute_all,
|
|
|
- //IMongoDB<ic_substitute_all_dtl> ic_substitute_all_dtl,
|
|
|
+ IMongoDB<ic_substitute> ic_substitute,
|
|
|
+ IMongoDB<ic_substitute_all> ic_substitute_all,
|
|
|
+ IMongoDB<ic_substitute_all_dtl> ic_substitute_all_dtl,
|
|
|
IMongoDB<mes_morder> mes_morder,
|
|
|
IMongoDB<mes_moentry> mes_moentry,
|
|
|
IMongoDB<mes_mooccupy> mes_mooccupy,
|
|
|
@@ -301,9 +302,9 @@ namespace Business.ResourceExamineManagement
|
|
|
_srm_po_occupy= srm_po_occupy;
|
|
|
_ic_item_pur= ic_item_pur;
|
|
|
_ic_plan= ic_plan;
|
|
|
- //_ic_substitute = ic_substitute;
|
|
|
- //_ic_substitute_all = ic_substitute_all;
|
|
|
- //_ic_substitute_all_dtl = ic_substitute_all_dtl;
|
|
|
+ _ic_substitute = ic_substitute;
|
|
|
+ _ic_substitute_all = ic_substitute_all;
|
|
|
+ _ic_substitute_all_dtl = ic_substitute_all_dtl;
|
|
|
_mes_morder = mes_morder;
|
|
|
_mes_moentry = mes_moentry;
|
|
|
_mes_mooccupy = mes_mooccupy;
|
|
|
@@ -410,6 +411,24 @@ namespace Business.ResourceExamineManagement
|
|
|
input.tenantId = 102;
|
|
|
input.factoryId = 10201;
|
|
|
|
|
|
+ #region
|
|
|
+ var bomlist = _ic_bom.GetAll().Result;
|
|
|
+ var bomchildlist = _ic_bom_child.GetAll().Result;
|
|
|
+ var icitemlist = _ic_item.GetAll().Result;
|
|
|
+ foreach (var o in sentrys)
|
|
|
+ {
|
|
|
+ //bom层级组装
|
|
|
+ var returnlist = BomPretreatment(o.Id, 160162, o.qty.GetInt(), bomlist, bomchildlist, icitemlist);
|
|
|
+ //bom替代关系组装
|
|
|
+ BomSubstitute(returnlist, bomlist, bomchildlist, icitemlist);
|
|
|
+ //库存初始化
|
|
|
+ BomStock(returnlist, bangid, input.factoryId);
|
|
|
+ //
|
|
|
+ calcTest(returnlist, bangid, o.Id, o.qty.Value);
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
//数据准备
|
|
|
//await SaveChangesCompletedEventData()
|
|
|
|
|
|
@@ -928,7 +947,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="orderid"></param>
|
|
|
/// <param name="BomId"></param>
|
|
|
/// <param name="Quantity"></param>
|
|
|
- public void BomPretreatment(long? orderid, long? BomId, int Quantity)
|
|
|
+ public List<BomChildExamineDto> BomPretreatment(long? orderid, long? BomId, int Quantity, List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist)
|
|
|
{
|
|
|
if (orderid == null)
|
|
|
{
|
|
|
@@ -941,9 +960,7 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
//var query = (await _ic_bom.GetQueryableAsync()).WhereIf(true, a => a.bom_id == BomId).ToList();
|
|
|
var help = new SnowFlake();
|
|
|
- var bomlist = _ic_bom.GetAll().Result;
|
|
|
- var bomchildlist = _ic_bom_child.GetAll().Result;
|
|
|
- var icitemlist = _ic_item.GetAll().Result;
|
|
|
+
|
|
|
List<BomChildExamineDto> returnlist = new List<BomChildExamineDto>();
|
|
|
var dto = new BomChildExamineDto();
|
|
|
dto.bom_id = BomId.Value;
|
|
|
@@ -959,6 +976,7 @@ namespace Business.ResourceExamineManagement
|
|
|
dto.icitem_ids = "";
|
|
|
int type = 0;
|
|
|
GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist, type);
|
|
|
+ return returnlist;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1187,7 +1205,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 计算物料库存量
|
|
|
/// </summary>
|
|
|
/// <param name="returnlist"></param>
|
|
|
- public void BomStock(List<BomChildExamineDto> returnlist, long bangid, long orderid, long orderentryid, long factoryid)
|
|
|
+ public void BomStock(List<BomChildExamineDto> returnlist, long bangid, long factoryid)
|
|
|
{
|
|
|
returnlist = returnlist.OrderBy(s => s.num).ToList();
|
|
|
//获取当前工厂下物料库存数据
|
|
|
@@ -1213,7 +1231,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //计算库存
|
|
|
public void calcTest(List<BomChildExamineDto> returnlist, long bangid, long orderid,decimal count)
|
|
|
{
|
|
|
//占用情况
|
|
|
@@ -1316,21 +1334,21 @@ namespace Business.ResourceExamineManagement
|
|
|
case 0://整批
|
|
|
WholeBatchCheck(sublist, returnlist, sklist, select);
|
|
|
//如果都需要采购的情况下,则默认使用优先级最高的
|
|
|
- WholeBatch(sublist, returnlist, sklist, select, bangid, parent);
|
|
|
+ WholeBatch(item,sublist, returnlist, sklist, select, bangid, parent);
|
|
|
break;
|
|
|
case 1://混用
|
|
|
- MixedUse(sublist, returnlist, sklist, bangid, parent);
|
|
|
+ MixedUse(item,sublist, returnlist, sklist, bangid, parent);
|
|
|
break;
|
|
|
case 2://整批加混用
|
|
|
WholeBatchCheck(sublist, returnlist, sklist, select);
|
|
|
if (select.Count() == 0)
|
|
|
{
|
|
|
//走混用
|
|
|
- MixedUse(sublist, returnlist, sklist, bangid, parent);
|
|
|
+ MixedUse(item,sublist, returnlist, sklist, bangid, parent);
|
|
|
}
|
|
|
else {
|
|
|
//走整批
|
|
|
- WholeBatch(sublist, returnlist, sklist, select, bangid, parent);
|
|
|
+ WholeBatch(item,sublist, returnlist, sklist, select, bangid, parent);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -1362,14 +1380,21 @@ namespace Business.ResourceExamineManagement
|
|
|
idx = 99;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
//整批占用
|
|
|
- public void WholeBatch(List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, List<BomChildExamineDto> select, long bangid, BomChildExamineDto parent) {
|
|
|
+ public void WholeBatch(BomChildExamineDto item, List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, List<BomChildExamineDto> select, long bangid, BomChildExamineDto parent) {
|
|
|
if (select.Count() == 0)
|
|
|
{
|
|
|
//如果为空,则默认使用优先级为0的集合作为替代关系
|
|
|
- select = sublist.Where(s => s.substitute_all_num == 0).ToList();
|
|
|
+ if (item.substitute_mode == 0)
|
|
|
+ {
|
|
|
+ //替代
|
|
|
+ select = sublist.Where(s => s.type == 0).ToList();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //取代
|
|
|
+ select = sublist.Where(s => s.substitute_all_num == 0).ToList();
|
|
|
+ }
|
|
|
select.ForEach(s => { s.is_use = true; });
|
|
|
}
|
|
|
//占用库存
|
|
|
@@ -1417,7 +1442,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
|
|
|
//混用占用数据
|
|
|
- public void MixedUse(List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, long bangid, BomChildExamineDto parent) {
|
|
|
+ public void MixedUse(BomChildExamineDto item, List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, long bangid, BomChildExamineDto parent) {
|
|
|
|
|
|
decimal parent_lack = 0;
|
|
|
if (parent != null)
|
|
|
@@ -1471,6 +1496,41 @@ namespace Business.ResourceExamineManagement
|
|
|
idx++;
|
|
|
}
|
|
|
}
|
|
|
+ if (parent_lack > 0)
|
|
|
+ {
|
|
|
+ var select = new List<BomChildExamineDto>();
|
|
|
+ if (item.substitute_mode == 0)
|
|
|
+ {
|
|
|
+ //替代
|
|
|
+ select = sublist.Where(s => s.type == 0).ToList();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //取代
|
|
|
+ select = sublist.Where(s => s.substitute_all_num == 0).ToList();
|
|
|
+ }
|
|
|
+ //对select执行采购
|
|
|
+ foreach (var sct in select)
|
|
|
+ {
|
|
|
+ //找到当前物料的占用记录
|
|
|
+ var itemSockoccupy = sklist.Where(s => s.icitem_id == sct.item_id).ToList();
|
|
|
+ var num = parent_lack * sct.qty - itemSockoccupy.Sum(m => m.quantity);
|
|
|
+ if (sct.erp_cls == 1)
|
|
|
+ {
|
|
|
+ //自制
|
|
|
+ //GenerateMorder()
|
|
|
+ }
|
|
|
+ else if (sct.erp_cls == 2)
|
|
|
+ {
|
|
|
+ //委外
|
|
|
+ //CreateMesOOder(returnlist,)
|
|
|
+ }
|
|
|
+ else if (sct.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //外购
|
|
|
+ //CreateSRMPR(returnlist,)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|