|
|
@@ -50,6 +50,7 @@ using Hangfire.Server;
|
|
|
using WkHtmlToPdfDotNet;
|
|
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
+using System.Diagnostics;
|
|
|
|
|
|
namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
@@ -384,6 +385,33 @@ namespace Business.ResourceExamineManagement
|
|
|
//await _ic_item_stock.DeleteAll();
|
|
|
}
|
|
|
|
|
|
+ public void GetMongoDb(ic_bom bom,List<ic_bom> bomlist,List<ic_bom_child> bomchildlist,List<ic_item> icitemlist) {
|
|
|
+
|
|
|
+ if (bom != null)
|
|
|
+ {
|
|
|
+ bomlist.Add(bom);
|
|
|
+ var item = _ic_item.Find(s => s.Id == bom.icitem_id).Result.FirstOrDefault();
|
|
|
+ if (item != null)
|
|
|
+ {
|
|
|
+ icitemlist.Add(item);
|
|
|
+ }
|
|
|
+ List<ic_bom_child> childList = _ic_bom_child.GetManyByCondition(p => p.bom_id == bom.Id && p.IsDeleted == false).Result.ToList();
|
|
|
+ bomchildlist.AddRange(childList);
|
|
|
+ foreach (var childd in childList)
|
|
|
+ {
|
|
|
+ List<long> itemids = childList.Select(s => s.icitem_id).ToList();
|
|
|
+ var itemlist = _ic_item.GetManyByCondition(p => itemids.Contains(p.Id) && p.IsDeleted == false).Result;
|
|
|
+ var childBom = _ic_bom.GetManyByCondition(p => p.icitem_id == childd.icitem_id).Result.FirstOrDefault();
|
|
|
+ icitemlist.AddRange(itemlist);
|
|
|
+ if (childBom != null)
|
|
|
+ {
|
|
|
+ GetMongoDb(childBom, bomlist, bomchildlist, icitemlist);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 资源检查
|
|
|
/// </summary>
|
|
|
@@ -412,9 +440,14 @@ namespace Business.ResourceExamineManagement
|
|
|
input.factoryId = 10201;
|
|
|
|
|
|
#region
|
|
|
- var bomlist = _ic_bom.GetAll().Result;
|
|
|
- var bomchildlist = _ic_bom_child.GetAll().Result;
|
|
|
- var icitemlist = _ic_item.GetAll().Result;
|
|
|
+ List<ic_bom> bomlist = new List<ic_bom>();
|
|
|
+ List<ic_bom_child> bomchildlist = new List<ic_bom_child>();
|
|
|
+ List<ic_item> icitemlist = new List<ic_item>();
|
|
|
+ var childBom = _ic_bom.GetManyByCondition(p => p.bom_number == bom_number).Result.FirstOrDefault();
|
|
|
+ GetMongoDb(childBom, bomlist, bomchildlist, icitemlist);
|
|
|
+ //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层级组装
|
|
|
@@ -433,9 +466,9 @@ namespace Business.ResourceExamineManagement
|
|
|
//await SaveChangesCompletedEventData()
|
|
|
|
|
|
//数据库快照-同步mysql库数据到mongoDB中
|
|
|
- await SyncData(input.tenantId, input.factoryId, bangid);
|
|
|
+ //await SyncData(input.tenantId, input.factoryId, bangid);
|
|
|
|
|
|
- List<BomChildExamineDto> returnlist = new List<BomChildExamineDto>();
|
|
|
+ /*List<BomChildExamineDto> returnlist = new List<BomChildExamineDto>();
|
|
|
BomChildExamineDto bomChild = new BomChildExamineDto();
|
|
|
bomChild.id = 4331979;
|
|
|
bomChild.item_id = 809914;
|
|
|
@@ -455,7 +488,7 @@ namespace Business.ResourceExamineManagement
|
|
|
bomChild2.erp_cls = 2;
|
|
|
returnlist.Add(bomChild2);
|
|
|
DateTime dateTime = DateTime.Now.AddDays(5);
|
|
|
- CheckOnOrder(returnlist, 102, 10201, dateTime, bangid);
|
|
|
+ CheckOnOrder(returnlist, 102, 10201, dateTime, bangid);*/
|
|
|
|
|
|
//产能检查
|
|
|
await ProductiveExamine(bom_number, packages);
|
|
|
@@ -996,8 +1029,8 @@ namespace Business.ResourceExamineManagement
|
|
|
dto.item_id = bom.icitem_id;
|
|
|
dto.bom_id = BomId.Value;
|
|
|
dto.level = 1;
|
|
|
- dto.id = help.NextId();
|
|
|
- dto.parent_id = help.NextId();
|
|
|
+ dto.id = Guid.NewGuid();
|
|
|
+ dto.parent_id = Guid.NewGuid();
|
|
|
dto.qty = 1;
|
|
|
dto.num = "1";
|
|
|
dto.isbom = 1;
|
|
|
@@ -1059,7 +1092,7 @@ namespace Business.ResourceExamineManagement
|
|
|
if (childBom != null)
|
|
|
{
|
|
|
var cdto = new BomChildExamineDto();
|
|
|
- cdto.id = help.NextId();
|
|
|
+ cdto.id = Guid.NewGuid();
|
|
|
cdto.level = level;
|
|
|
cdto.parent_id = dto.id;
|
|
|
cdto.bom_child_id = c.Id;
|
|
|
@@ -1072,6 +1105,8 @@ namespace Business.ResourceExamineManagement
|
|
|
cdto.substitute_code = c.substitute_code;
|
|
|
cdto.icitem_ids = c.icitem_ids;
|
|
|
cdto.type = type;
|
|
|
+ cdto.item_id = childBom.icitem_id;
|
|
|
+ cdto.bom_id = childBom.Id;
|
|
|
//递归寻找子级
|
|
|
GetBomList(bomlist, bomchildlist, icitemlist, cdto, returnlist, type);
|
|
|
}
|
|
|
@@ -1083,7 +1118,7 @@ namespace Business.ResourceExamineManagement
|
|
|
childDto.level = level++;
|
|
|
childDto.bom_id = dto.bom_id;
|
|
|
childDto.bom_child_id = c.Id;
|
|
|
- childDto.id = help.NextId();
|
|
|
+ childDto.id = Guid.NewGuid();
|
|
|
childDto.parent_id = dto.id;
|
|
|
childDto.item_id = icitem.Id;
|
|
|
childDto.item_name = icitem.name;
|
|
|
@@ -1115,12 +1150,20 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
public void BomSubstitute(List<BomChildExamineDto> returnlist, List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist)
|
|
|
{
|
|
|
- var sublist = _ic_substitute.GetManyByCondition(s => s.substitute_code.IsIn(returnlist.Select(c => c.substitute_code))).Result.ToList();
|
|
|
- var suballlist = _ic_substitute_all.GetManyByCondition(s => s.substitute_id.IsIn(sublist.Select(c => c.Id))).Result.ToList();
|
|
|
- var subdtllist = _ic_substitute_all_dtl.GetManyByCondition(s => s.substitute_allid.IsIn(suballlist.Select(c => c.Id))).Result.ToList();
|
|
|
+ List<string> codeList = returnlist.Select(c => c.substitute_code).ToList();
|
|
|
+ var sublist = _ic_substitute.GetManyByCondition(p => codeList.Contains(p.substitute_code) && p.IsDeleted == false).Result;
|
|
|
+
|
|
|
+ List<long> subidlist = sublist.Select(c => c.Id).ToList();
|
|
|
+ var suballlist = _ic_substitute_all.GetManyByCondition(p => subidlist.Contains(p.substitute_id) && p.IsDeleted == false).Result;
|
|
|
+
|
|
|
+ List<long> suballidlist = suballlist.Select(c => c.Id).ToList();
|
|
|
+ var subdtllist = _ic_substitute_all_dtl.GetManyByCondition(p => suballidlist.Contains(p.substitute_allid) && p.IsDeleted == false).Result;
|
|
|
+
|
|
|
List<long> childidList = new List<long>();
|
|
|
var help = new SnowFlake();
|
|
|
int type = 1;
|
|
|
+ List<BomChildExamineDto> addlist = new List<BomChildExamineDto>();
|
|
|
+
|
|
|
//除顶级外,其他层级关系全带出来。生成平铺
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
@@ -1152,12 +1195,15 @@ namespace Business.ResourceExamineManagement
|
|
|
foreach (var sal in sall)
|
|
|
{
|
|
|
var sadl = subdtllist.Where(s => s.substitute_allid == sal.Id).ToList();
|
|
|
+ List<long> dtlItemId = sadl.Select(m => m.icitem_id).ToList();
|
|
|
+ var dtlitemlist = _ic_item.GetManyByCondition(p => dtlItemId.Contains(p.Id) && p.IsDeleted == false).Result;
|
|
|
+ icitemlist.AddRange(dtlitemlist);
|
|
|
foreach (var dtl in sadl)
|
|
|
{
|
|
|
if (dtl.ismain != 0)//替代关系里,已经将BOM料当成主料存放于替代群组里了。
|
|
|
{
|
|
|
//递归将替代关系组装出来。
|
|
|
- SubstitutePretreatment(sl, sal, dtl, item, returnlist, icitemlist, bomlist, bomchildlist, type);
|
|
|
+ SubstitutePretreatment(sl, sal, dtl, item, addlist, icitemlist, bomlist, bomchildlist, type);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -1171,6 +1217,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ returnlist.AddRange(addlist);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1196,7 +1243,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- dto.id = help.NextId();
|
|
|
+ dto.id = Guid.NewGuid();
|
|
|
dto.level = toDto.level;
|
|
|
dto.parent_id = toDto.parent_id;
|
|
|
dto.item_id = icitem.Id;
|
|
|
@@ -1210,20 +1257,20 @@ namespace Business.ResourceExamineManagement
|
|
|
dto.backflush = toDto.backflush;
|
|
|
//dto.qty = toDto.qty;
|
|
|
//dto.replace_amount = dtl.replace_amount.Value;
|
|
|
- dto.qty = dtl.replace_amount.Value;
|
|
|
+ dto.qty = dtl.replace_amount == null ? 1 : dtl.replace_amount.Value;
|
|
|
dto.is_replace = 0;
|
|
|
dto.haveicsubs = 0;
|
|
|
dto.substitute_code = "";
|
|
|
dto.icitem_ids = "";
|
|
|
- dto.substitute_strategy = sl.substitute_strategy.Value;//替代策略
|
|
|
- dto.substitute_mode = sl.substitute_mode.Value;//替代方式
|
|
|
+ dto.substitute_strategy = sl.substitute_strategy == null ? 0 : sl.substitute_strategy.Value;//替代策略
|
|
|
+ dto.substitute_mode = sl.substitute_mode == null ? 0 : sl.substitute_mode.Value;//替代方式
|
|
|
dto.type = type;
|
|
|
dto.substitute_all_num = sal.order_num;//群组优先级
|
|
|
if (bom != null)
|
|
|
{
|
|
|
dto.bom_id = bom.Id;
|
|
|
|
|
|
- dto.qty = dtl.replace_amount.Value;
|
|
|
+ dto.qty = dtl.replace_amount == null ? 1 : dtl.replace_amount.Value;
|
|
|
dto.isbom = 1;
|
|
|
dto.is_replace = 0;
|
|
|
dto.haveicsubs = 0;
|
|
|
@@ -1448,10 +1495,9 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
itemStockoccupyDto.quantity = slt.sqty;
|
|
|
//库存不够的时候,根据属性生成采购和委外。
|
|
|
- var lack_qty = slt.lack_qty - itemStockoccupyDto.quantity;
|
|
|
if (slt.erp_cls == 1)
|
|
|
{
|
|
|
- slt.make_qty = lack_qty;
|
|
|
+ slt.make_qty = slt.lack_qty;
|
|
|
/*var childList = returnlist.Where(s => s.parent_id == slt.id).ToList();
|
|
|
if (childList.Count() > 0)
|
|
|
{
|
|
|
@@ -1461,12 +1507,12 @@ namespace Business.ResourceExamineManagement
|
|
|
else if (slt.erp_cls == 2)
|
|
|
{
|
|
|
//生成委外工单
|
|
|
- slt.Subcontracting_qty = lack_qty;
|
|
|
+ slt.Subcontracting_qty = slt.lack_qty;
|
|
|
}
|
|
|
else if (slt.erp_cls == 3)
|
|
|
{
|
|
|
//生成采购订单
|
|
|
- slt.purchase_qty = lack_qty;
|
|
|
+ slt.purchase_qty = slt.lack_qty;
|
|
|
}
|
|
|
}
|
|
|
else
|