|
|
@@ -21,6 +21,7 @@ using Volo.Abp.Application.Services;
|
|
|
using Volo.Abp.DependencyInjection;
|
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
using Volo.Abp.MultiTenancy;
|
|
|
+using Volo.Abp.ObjectMapping;
|
|
|
using Volo.Abp.Uow;
|
|
|
|
|
|
namespace Business.ResourceExamineManagement
|
|
|
@@ -617,7 +618,7 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
//记录订单行的物料齐套时间
|
|
|
List<KittingTimeDto> kittingTimes = new List<KittingTimeDto>();
|
|
|
- DataInitialization(boms, bangid, icitemlist, stocklist, pretreatments);
|
|
|
+ DataInitialization(boms, bangid, icitemlist, stocklist, pretreatments, sklist);
|
|
|
foreach (var sorder in sorders)
|
|
|
{
|
|
|
param.sorderId = sorder.Id;
|
|
|
@@ -745,7 +746,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
if (_CalcBomViewAppService.mooccupyAllInsertList.Any())
|
|
|
{
|
|
|
- _CalcBomViewAppService.mooccupyAllInsertList.ForEach(s => { s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
+ _CalcBomViewAppService.mooccupyAllInsertList.ForEach(s => { s.tenant_id = param.company_id.GetValueOrDefault(); s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
await _mes_mooccupy.InsertManyAsync(_CalcBomViewAppService.mooccupyAllInsertList);
|
|
|
/*var moOccupy = ObjectMapper.Map<List<mo_mes_mooccupy>, List<mes_mooccupy>>(_CalcBomViewAppService.mooccupyAllInsertList);
|
|
|
_businessDbContext.BulkInsert(moOccupy);*/
|
|
|
@@ -753,14 +754,14 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
if (_CalcBomViewAppService.moentriesInsertList.Any())
|
|
|
{
|
|
|
- _CalcBomViewAppService.moentriesInsertList.ForEach(s => { s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
+ _CalcBomViewAppService.moentriesInsertList.ForEach(s => { s.tenant_id = param.company_id.GetValueOrDefault(); s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
await _mes_moentry.InsertManyAsync(_CalcBomViewAppService.moentriesInsertList);
|
|
|
/*var mesmoentrys = ObjectMapper.Map<List<mo_mes_moentry>, List<mes_moentry>>(_CalcBomViewAppService.moentriesInsertList);
|
|
|
_businessDbContext.BulkInsert(mesmoentrys);*/
|
|
|
}
|
|
|
if (_CalcBomViewAppService.orderList.Any())
|
|
|
{
|
|
|
- _CalcBomViewAppService.orderList.ForEach(s => { s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
+ _CalcBomViewAppService.orderList.ForEach(s => { s.tenant_id = param.company_id.GetValueOrDefault(); s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
await _mes_oorder.InsertManyAsync(_CalcBomViewAppService.orderList);
|
|
|
/*var ooders = ObjectMapper.Map<List<mo_mes_oorder>, List<mes_oorder>>(_CalcBomViewAppService.orderList);
|
|
|
_businessDbContext.BulkInsert(ooders);*/
|
|
|
@@ -768,12 +769,12 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
if (_CalcBomViewAppService.newStockOccList.Any())
|
|
|
{
|
|
|
- _CalcBomViewAppService.newStockOccList.ForEach(s => {s.GenerateNewId(help.NextId()); s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
+ _CalcBomViewAppService.newStockOccList.ForEach(s => { s.GenerateNewId(help.NextId()); s.tenant_id = param.company_id.GetValueOrDefault(); s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
await _ic_item_stockoccupy.InsertManyAsync(_CalcBomViewAppService.newStockOccList);
|
|
|
}
|
|
|
if (_CalcBomViewAppService.srm_Po_OccupiesInsert.Any())
|
|
|
{
|
|
|
- _CalcBomViewAppService.srm_Po_OccupiesInsert.ForEach(s => { s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
+ _CalcBomViewAppService.srm_Po_OccupiesInsert.ForEach(s => { s.tenant_id = param.company_id.GetValueOrDefault(); s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
await _srm_po_occupy.InsertManyAsync(_CalcBomViewAppService.srm_Po_OccupiesInsert);
|
|
|
/*var poOccupies = ObjectMapper.Map<List<mo_srm_po_occupy>, List<srm_po_occupy>>(_CalcBomViewAppService.srm_Po_OccupiesInsert);
|
|
|
_businessDbContext.BulkInsert(poOccupies);*/
|
|
|
@@ -1526,6 +1527,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//PO占用记录
|
|
|
List<mo_srm_po_occupy> po_occupy = await _srm_po_occupy.GetListAsync(s => seIds.Contains(s.eid.Value) && bangidList.Contains(s.bang_id.Value));
|
|
|
List<mo_srm_pr_main> prmainlist = await _srm_pr_main.GetListAsync(s => seIds.Contains(s.sentry_id.Value) && bangidList.Contains(s.bang_id.Value));
|
|
|
+ List<mo_ic_item_stockoccupy> item_stockoccupy = await _ic_item_stockoccupy.GetListAsync(s => seIds.Contains(s.orderentry_id.Value) && bangidList.Contains(s.bang_id));
|
|
|
|
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
|
|
|
{
|
|
|
@@ -1566,12 +1568,13 @@ namespace Business.ResourceExamineManagement
|
|
|
var ooders = ObjectMapper.Map<List<mo_mes_oorder>, List<mes_oorder>>(oorderList);
|
|
|
_businessDbContext.BulkInsert(ooders);
|
|
|
}
|
|
|
- //沟通方老师与何腾,库存与库存占用,使用方老师得locationDetail和workorddetital 做需求数量和已发数量来实现库存占用和已扣减库存?
|
|
|
- /*if (sklist.Any())
|
|
|
+
|
|
|
+ if (item_stockoccupy.Any())
|
|
|
{
|
|
|
- sklist.ForEach(s => { s.id = help.NextId(); s.tenant_id = param.tenantId; s.factory_id = param.factoryId; });
|
|
|
- await _ic_item_stockoccupy.InsertMany(sklist);
|
|
|
- }*/
|
|
|
+ var sklist = ObjectMapper.Map<List<mo_ic_item_stockoccupy>, List<ic_item_stockoccupy>>(item_stockoccupy);
|
|
|
+ sklist.ForEach(s => { s.create_time = DateTime.Now; });
|
|
|
+ _businessDbContext.BulkInsert(sklist);
|
|
|
+ }
|
|
|
if (po_occupy.Any())
|
|
|
{
|
|
|
po_occupy.ForEach(s => { s.create_time = DateTime.Now; });
|
|
|
@@ -1712,7 +1715,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//同步物料库存数据 根据预处理,来只找出部分数据同步。
|
|
|
List<long> itemIds = pretreatments.Select(s => s.item_id.GetValueOrDefault()).ToList();
|
|
|
//var icitemStokc = _mysql_ic_item_stock.GetListAsync(p => p.tenant_id == tenantId && p.factory_id == factoryId).Result;
|
|
|
- var icitemStokc = _mysql_ic_item_stock.GetListAsync(p => itemIds.Contains(p.icitem_id)).Result;
|
|
|
+ var icitemStokc = _mysql_ic_item_stock.GetListAsync(p => p.company_id == companyId && itemIds.Contains(p.icitem_id)).Result;
|
|
|
if (icitemStokc.Count > 0)
|
|
|
{
|
|
|
List<string> numbers = pretreatments.Select(s => s.item_number).ToList();
|
|
|
@@ -1730,34 +1733,76 @@ namespace Business.ResourceExamineManagement
|
|
|
//插入数据
|
|
|
await _ic_item_stock.InsertManyAsync(moIcitemStokc);
|
|
|
}
|
|
|
- //在制工单占用记录表
|
|
|
- var mes_mooccupy = _mysql_mes_mooccupy.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId).Result;
|
|
|
- if (mes_mooccupy.Count > 0)
|
|
|
- {
|
|
|
- mes_mooccupy.ForEach(item => { item.bang_id = bangid; });
|
|
|
- var moMes_mooccupy = ObjectMapper.Map<List<mes_mooccupy>, List<mo_mes_mooccupy>>(mes_mooccupy);
|
|
|
- moMes_mooccupy.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
- await _mes_mooccupy.InsertManyAsync(moMes_mooccupy);
|
|
|
- }
|
|
|
- //工单主表
|
|
|
- var mes_morder = _mysql_mes_morder.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId).Result;
|
|
|
- if (mes_morder.Count > 0)
|
|
|
- {
|
|
|
- mes_morder.ForEach(item => { item.bang_id = bangid; });
|
|
|
- var moMes_morder = ObjectMapper.Map<List<mes_morder>, List<mo_mes_morder>>(mes_morder);
|
|
|
- moMes_morder.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
- await _mes_morder.InsertManyAsync(moMes_morder);
|
|
|
- }
|
|
|
- //工单子表
|
|
|
- var mes_moentry = _mysql_mes_moentry.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId).Result;
|
|
|
- if (mes_moentry.Count > 0)
|
|
|
+
|
|
|
+ var workordmsters = _workOrdMaster.Select(s => s.Domain == factoryId.ToString() && s.Status.ToLower() != "c");
|
|
|
+ if (workordmsters.Any())
|
|
|
{
|
|
|
- mes_moentry.ForEach(item => { item.bang_id = bangid; });
|
|
|
- var moMes_moentry = ObjectMapper.Map<List<mes_moentry>, List<mo_mes_moentry>>(mes_moentry);
|
|
|
- moMes_moentry.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
- await _mes_moentry.InsertManyAsync(moMes_moentry);
|
|
|
- }
|
|
|
+ //根据工单表找到工单明细,然后根据DOP工单占用记录,对比工单明细发货数量,来做冲销。
|
|
|
+ var workdetails = _workOrdDetail.Select(s => workordmsters.Select(c => c.WorkOrd).Contains(s.WorkOrd));
|
|
|
|
|
|
+ //物料库存占用记录表
|
|
|
+ var item_occupy = _mysql_ic_item_stockoccupy.GetListAsync(p => p.company_id == companyId && itemIds.Contains(p.icitem_id)&& workordmsters.Select(c => c.WorkOrd).Contains(p.morder_mo)).Result;
|
|
|
+ if (item_occupy.Any())
|
|
|
+ {
|
|
|
+ item_occupy.ForEach(s =>
|
|
|
+ {
|
|
|
+ //TODO:对发布数量和占用数量进行对冲,因为目前没有处理不同层级下使用相同物料的占用的问题。dop占用有项次号,而wms的发布数量明细没有项次号
|
|
|
+ var wdtl = workdetails.Where(x => x.WorkOrd == s.morder_mo && x.ItemNum == s.icitem_number).ToList();
|
|
|
+ if (wdtl.Any())
|
|
|
+ {
|
|
|
+ foreach (var dtl in wdtl)
|
|
|
+ {
|
|
|
+ if (s.quantity - dtl.QtyPosted > 0)
|
|
|
+ {
|
|
|
+ s.quantity -= dtl.QtyPosted;
|
|
|
+ dtl.QtyPosted = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dtl.QtyPosted -= s.quantity;
|
|
|
+ s.quantity = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ item_occupy = item_occupy.Where(s => s.quantity > 0).ToList();
|
|
|
+ if (item_occupy.Count > 0)
|
|
|
+ {
|
|
|
+ var mo_item_occupy = ObjectMapper.Map<List<ic_item_stockoccupy>, List<mo_ic_item_stockoccupy>>(item_occupy);
|
|
|
+ mo_item_occupy.ForEach(item => { item.GenerateNewId(help.NextId()); item.bang_id = bangid; });
|
|
|
+ await _ic_item_stockoccupy.InsertManyAsync(mo_item_occupy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //工单主表
|
|
|
+ var mes_morder = _mysql_mes_morder.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId && workordmsters.Select(c => c.WorkOrd).Contains(x.morder_no)).Result;
|
|
|
+ if (mes_morder.Count > 0)
|
|
|
+ {
|
|
|
+ mes_morder.ForEach(item => { item.bang_id = bangid; });
|
|
|
+ var moMes_morder = ObjectMapper.Map<List<mes_morder>, List<mo_mes_morder>>(mes_morder);
|
|
|
+ moMes_morder.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
+ await _mes_morder.InsertManyAsync(moMes_morder);
|
|
|
+ }
|
|
|
+ //工单子表
|
|
|
+ var mes_moentry = _mysql_mes_moentry.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId).Result;
|
|
|
+ if (mes_moentry.Count > 0)
|
|
|
+ {
|
|
|
+ mes_moentry.ForEach(item => { item.bang_id = bangid; });
|
|
|
+ var moMes_moentry = ObjectMapper.Map<List<mes_moentry>, List<mo_mes_moentry>>(mes_moentry);
|
|
|
+ moMes_moentry.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
+ await _mes_moentry.InsertManyAsync(moMes_moentry);
|
|
|
+ }
|
|
|
+
|
|
|
+ //在制工单占用记录表
|
|
|
+ var mes_mooccupy = _mysql_mes_mooccupy.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId && mes_morder.Select(c => c.morder_no).Contains(x.moo_mo)).Result;
|
|
|
+ if (mes_mooccupy.Count > 0)
|
|
|
+ {
|
|
|
+ mes_mooccupy.ForEach(item => { item.bang_id = bangid; });
|
|
|
+ var moMes_mooccupy = ObjectMapper.Map<List<mes_mooccupy>, List<mo_mes_mooccupy>>(mes_mooccupy);
|
|
|
+ moMes_mooccupy.ForEach(item => { item.GenerateNewId(help.NextId()); });
|
|
|
+ await _mes_mooccupy.InsertManyAsync(moMes_mooccupy);
|
|
|
+ }
|
|
|
+ }
|
|
|
//TODO:要不要根据某些条件只同步有效的数据
|
|
|
//采购订单
|
|
|
var srm_po_main = _mysql_srm_po_main.GetListAsync(x => x.company_id == companyId && x.factory_id == factoryId).Result;
|
|
|
@@ -1800,7 +1845,7 @@ namespace Business.ResourceExamineManagement
|
|
|
await _ic_item_stock.DeleteAsync(p => p.bang_id == bangid);
|
|
|
|
|
|
//清除工单占用记录表
|
|
|
- await _mes_mooccupy.DeleteAsync(p => p.bang_id == bangid);
|
|
|
+ //await _mes_mooccupy.DeleteAsync(p => p.bang_id == bangid);
|
|
|
|
|
|
//清除工单主表
|
|
|
//await _mes_morder.Delete(p => p.bang_id == bangid);
|
|
|
@@ -1815,7 +1860,7 @@ namespace Business.ResourceExamineManagement
|
|
|
await _srm_po_list.DeleteAsync(p => p.bang_id == bangid);
|
|
|
|
|
|
//清除采购订单占用详情
|
|
|
- await _srm_po_occupy.DeleteAsync(p => p.bang_id == bangid);
|
|
|
+ //await _srm_po_occupy.DeleteAsync(p => p.bang_id == bangid);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -2223,7 +2268,12 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
_businessDbContext.BulkDelete(dellist);
|
|
|
}
|
|
|
-
|
|
|
+ //清理掉库存占用
|
|
|
+ var itemstockoccupy = _mysql_ic_item_stockoccupy.GetListAsync(s => monolist.Contains(s.morder_mo)).Result;
|
|
|
+ if (itemstockoccupy.Any())
|
|
|
+ {
|
|
|
+ _businessDbContext.BulkDelete(itemstockoccupy);
|
|
|
+ }
|
|
|
//清理锁定期外的排程数据.
|
|
|
var periodList = _periodSequenceDet.Select(s => monolist.Contains(s.WorkOrds));
|
|
|
if (periodList.Any())
|
|
|
@@ -2661,7 +2711,7 @@ namespace Business.ResourceExamineManagement
|
|
|
List<mo_ic_item_stock> stocklist = new List<mo_ic_item_stock>();
|
|
|
//物料占用记录
|
|
|
List<mo_ic_item_stockoccupy> sklist = new List<mo_ic_item_stockoccupy>();
|
|
|
-
|
|
|
+
|
|
|
//sorder=null 是因为齐套检查不需要生成工单、采购、委外等信息,所以不需要关联的工单信息传递进去。
|
|
|
var pretreatments = _mysql_b_bom_pretreatment.GetListAsync(s => boms.Select(c => c.mysql_id).ToList().Contains(s.sourceid)).Result;
|
|
|
List<mo_ic_bom> autoCreates = new List<mo_ic_bom>();
|
|
|
@@ -2681,7 +2731,12 @@ namespace Business.ResourceExamineManagement
|
|
|
//数据库快照-同步mysql库数据到mongoDB中
|
|
|
await DbSnapShot(input.company_id, input.factoryId, bangid, pretreatments);
|
|
|
|
|
|
- DataInitialization(boms, bangid, icitemlist, stocklist, pretreatments);
|
|
|
+ DataInitialization(boms, bangid, icitemlist, stocklist, pretreatments, sklist);
|
|
|
+ if (!planCheck)
|
|
|
+ {
|
|
|
+ //如果是齐套检查,则不考虑其他数据的占用,只看原材料库存
|
|
|
+ sklist = new List<mo_ic_item_stockoccupy>();
|
|
|
+ }
|
|
|
_morderAppService.param = param;
|
|
|
_purchaseOrderAppService.param = param;
|
|
|
_CalcBomViewAppService.param = param;
|
|
|
@@ -2803,7 +2858,6 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(false, true))
|
|
|
{
|
|
|
try
|
|
|
@@ -2814,6 +2868,12 @@ namespace Business.ResourceExamineManagement
|
|
|
var pr_mainlist = ObjectMapper.Map<List<mo_srm_pr_main>, List<srm_pr_main>>(prmainlist);
|
|
|
_businessDbContext.BulkInsert(pr_mainlist);
|
|
|
}
|
|
|
+ if (_CalcBomViewAppService.newStockOccList.Any())
|
|
|
+ {
|
|
|
+ var stockoccupylist = ObjectMapper.Map<List<mo_ic_item_stockoccupy>, List<ic_item_stockoccupy>>(_CalcBomViewAppService.newStockOccList);
|
|
|
+ stockoccupylist.ForEach(s => { s.create_time = DateTime.Now; s.tenant_id = param.company_id.GetValueOrDefault(); s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
+ _businessDbContext.BulkInsert(stockoccupylist);
|
|
|
+ }
|
|
|
if (_CalcBomViewAppService.srm_Po_OccupiesInsert.Any())
|
|
|
{
|
|
|
_CalcBomViewAppService.srm_Po_OccupiesInsert.ForEach(s => { s.company_id = param.company_id; s.factory_id = param.factoryId; });
|
|
|
@@ -2851,7 +2911,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="stocklist"></param>
|
|
|
/// <param name="sklist"></param>
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
- public void DataInitialization(List<mo_ic_bom> boms, long bangid, List<mo_ic_item> icitemlist, List<mo_ic_item_stock> stocklist, List<b_bom_pretreatment> pretreatments)
|
|
|
+ public void DataInitialization(List<mo_ic_bom> boms, long bangid, List<mo_ic_item> icitemlist, List<mo_ic_item_stock> stocklist, List<b_bom_pretreatment> pretreatments, List<mo_ic_item_stockoccupy> sklist)
|
|
|
{
|
|
|
List<long> itemIds = pretreatments.Select(p => p.item_id.GetValueOrDefault()).ToList();
|
|
|
icitemlist.AddRange(_ic_item.GetListAsync(p => itemIds.Contains(p.mysql_id) && !p.IsDeleted).Result);
|
|
|
@@ -2890,6 +2950,8 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
//物料库存
|
|
|
stocklist.AddRange(_ic_item_stock.GetListAsync(p => p.factory_id == param.factoryId && p.bang_id == bangid && itemIds.Contains(p.icitem_id)).Result);
|
|
|
+ //物料库存占用表
|
|
|
+ sklist.AddRange(_ic_item_stockoccupy.GetListAsync(x => x.bang_id == bangid && !x.IsDeleted).Result);
|
|
|
|
|
|
//物料提前期
|
|
|
leadTimeList = GetLeadTime(icitemlist, param.company_id, param.factoryId);//提前期列表
|
|
|
@@ -3038,9 +3100,10 @@ namespace Business.ResourceExamineManagement
|
|
|
foreach (var workord in workOrdMasters)
|
|
|
{
|
|
|
Dictionary<string, decimal> dictItemQty = new Dictionary<string, decimal>();
|
|
|
+ decimal QtyOrdSum = workord.QtyOrded;
|
|
|
List<string> lines = dbPeriodSequences.Where(a => a.WorkOrds == workord.WorkOrd).Select(a => a.Line).Distinct().ToList();
|
|
|
List<LineMaster> lineMasters = AllLineMasters.Where(p => lines.Contains(p.Line) && p.Domain == workord.Domain && p.IsActive).ToList();
|
|
|
- List<ProductStructureMaster> itemList = GetProductStructure(dbPeriodSequences.First(a => a.WorkOrds == workord.WorkOrd).ItemNum);
|
|
|
+ List<ProductStructureMaster> itemList = GetProductStructure(dbPeriodSequences.First(a => a.WorkOrds == workord.WorkOrd).ItemNum, QtyOrdSum, workord.Domain);
|
|
|
var childrenList = itemList.Select(a => a.ComponentItem).Distinct().ToList();
|
|
|
List<ItemMaster> itemLocList = _itemMaster.Select(p => childrenList.Contains(p.ItemNum) && p.Domain == workord.Domain && p.IsActive).Distinct().ToList();
|
|
|
var dopIcitems = _ic_item.GetListAsync(s => itemLocList.Select(c => c.ItemNum).Contains(s.number)).Result;
|
|
|
@@ -3052,8 +3115,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
List<ItemPackMaster> itemPackList = _itemPackMaster.Select(p => childrenList.Contains(p.ItemNum) && p.Domain == workord.Domain && p.IsActive).Distinct().ToList();
|
|
|
var Nbr = GetMaxSerialNumber(417416915624005);
|
|
|
- //根据某一产线汇总即该工单的总数
|
|
|
- decimal QtyOrdSum = dbPeriodSequences.Where(a => a.WorkOrds == workord.WorkOrd && a.Line == lines[0]).Sum(a => a.OrdQty.GetValueOrDefault());
|
|
|
+
|
|
|
string LocationTo= lineMasters.FirstOrDefault()?.Location;
|
|
|
DateTime eff = workord.OrdDate.GetValueOrDefault().Date.AddDays(-1);
|
|
|
DateTime start = eff.AddDays((double)(0 - cleanTime - 1));
|
|
|
@@ -3107,8 +3169,8 @@ namespace Business.ResourceExamineManagement
|
|
|
LocationFrom = LocationFrom,
|
|
|
LocationTo = LocationTo,//现在这几条线是同一线边仓,暂时不考虑多个线边仓
|
|
|
WorkOrd = workord.WorkOrd,
|
|
|
- QtyOrd = QtyOrdSum * a.Qty,
|
|
|
- CurrQtyOpened = QtyOrdSum * a.Qty,
|
|
|
+ QtyOrd = a.Qty,
|
|
|
+ CurrQtyOpened = a.Qty,
|
|
|
Line = i,
|
|
|
IsActive = true,
|
|
|
CreateTime = DateTime.Now,
|
|
|
@@ -3121,11 +3183,12 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- nbrDetailList.First(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem).QtyOrd = itemComponent.QtyOrd + QtyOrdSum * a.Qty;
|
|
|
- nbrDetailList.First(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem).CurrQtyOpened = itemComponent.CurrQtyOpened + QtyOrdSum * a.Qty;
|
|
|
+ nbrDetailList.First(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem).QtyOrd = itemComponent.QtyOrd + a.Qty;
|
|
|
+ nbrDetailList.First(b => b.Nbr == Nbr && b.ItemNum == a.ComponentItem).CurrQtyOpened = itemComponent.CurrQtyOpened + a.Qty;
|
|
|
}
|
|
|
});
|
|
|
- nbrDetailList.ForEach(a =>
|
|
|
+ //先屏蔽备料单扣除库存的DEMO演示。
|
|
|
+ /*nbrDetailList.ForEach(a =>
|
|
|
{
|
|
|
if (a.Nbr == Nbr)
|
|
|
{
|
|
|
@@ -3167,7 +3230,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- _locationDetail.Update(locStock);
|
|
|
+ _locationDetail.Update(locStock);*/
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -3424,7 +3487,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
//添加工单数据
|
|
|
workOrd = new WorkOrdMaster();
|
|
|
- workOrd.Domain = "1001";
|
|
|
+ workOrd.Domain = item.factory_id.ToString();
|
|
|
workOrd.OrdDate = item.moentry_sys_stime;
|
|
|
workOrd.ReleaseDate = Convert.ToDateTime(item.moentry_sys_stime.GetValueOrDefault().ToString("u"));
|
|
|
workOrd.WorkOrd = item.morder_no;
|
|
|
@@ -3446,7 +3509,7 @@ namespace Business.ResourceExamineManagement
|
|
|
foreach (var dtl in curRoutings)
|
|
|
{
|
|
|
woRouting = new WorkOrdRouting();
|
|
|
- woRouting.Domain = "1001";
|
|
|
+ woRouting.Domain = item.factory_id.ToString();
|
|
|
woRouting.Descr = dtl.Descr;
|
|
|
woRouting.MilestoneOp = dtl.MilestoneOp;
|
|
|
woRouting.WorkOrd = item.morder_no;
|
|
|
@@ -3463,16 +3526,16 @@ namespace Business.ResourceExamineManagement
|
|
|
workOrdRoutings.Add(woRouting);
|
|
|
}
|
|
|
|
|
|
- List<ProductStructureMaster> curStructures = GetProductStructure(item.product_code);
|
|
|
+ List<ProductStructureMaster> curStructures = GetProductStructure(item.product_code, workOrd.QtyOrded, item.factory_id.ToString());
|
|
|
foreach (var structure in curStructures)
|
|
|
{
|
|
|
//添加工单的物料信息
|
|
|
woDetail = new WorkOrdDetail();
|
|
|
- woDetail.Domain = "1001";
|
|
|
+ woDetail.Domain = item.factory_id.ToString();
|
|
|
woDetail.WorkOrd = item.morder_no;
|
|
|
woDetail.Op = structure.Op;
|
|
|
woDetail.ItemNum = structure.ComponentItem;
|
|
|
- woDetail.QtyRequired = item.need_number.GetValueOrDefault() * structure.Qty;
|
|
|
+ woDetail.QtyRequired = structure.Qty;
|
|
|
woDetail.QtyPosted = 0m;
|
|
|
woDetail.QtyReturned = 0m;
|
|
|
woDetail.FrozenBOMQty = structure.Qty;
|
|
|
@@ -3489,11 +3552,12 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
/// <param name="itenNum">产品物料编码</param>
|
|
|
/// <returns></returns>
|
|
|
- public List<ProductStructureMaster> GetProductStructure(string itenNum)
|
|
|
+ public List<ProductStructureMaster> GetProductStructure(string itenNum,decimal QtyOrdSum, string domain)
|
|
|
{
|
|
|
List<ProductStructureMaster> rtnStructures = new List<ProductStructureMaster>();
|
|
|
//根据itemNum获取bom数据
|
|
|
- var productStructures = _productStructureMaster.Select(p => itenNum == p.ParentItem && p.Domain == "1001" && p.IsActive);
|
|
|
+ var productStructures = _productStructureMaster.Select(p => itenNum == p.ParentItem && p.Domain == domain && p.IsActive);
|
|
|
+ productStructures.ForEach(s => { s.Qty = s.Qty * QtyOrdSum; });
|
|
|
//添加非虚拟件
|
|
|
rtnStructures.AddRange(productStructures.Where(p => p.StructureType.ToUpper() != "X").ToList());
|
|
|
|
|
|
@@ -3504,7 +3568,7 @@ namespace Business.ResourceExamineManagement
|
|
|
return rtnStructures;
|
|
|
}
|
|
|
//递归获取所有虚拟件对应的子物料
|
|
|
- RecursionProductStructure(itenNum, curPhantoms, rtnStructures);
|
|
|
+ RecursionProductStructure(curPhantoms, rtnStructures);
|
|
|
|
|
|
return rtnStructures;
|
|
|
}
|
|
|
@@ -3515,17 +3579,18 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="parentItem">产品的物料编码</param>
|
|
|
/// <param name="structures">当前产品的虚拟件</param>
|
|
|
/// <param name="rtnStructures"></param>
|
|
|
- public void RecursionProductStructure(string parentItem, List<ProductStructureMaster> structures, List<ProductStructureMaster> rtnStructures)
|
|
|
+ public void RecursionProductStructure(List<ProductStructureMaster> structures, List<ProductStructureMaster> rtnStructures)
|
|
|
{
|
|
|
//获取虚拟件的子物料
|
|
|
List<ProductStructureMaster> chdStructures = _productStructureMaster.Select(p => structures.Select(m => m.ComponentItem).Contains(p.ParentItem) && p.Domain == "1001" && p.IsActive);
|
|
|
+ chdStructures.ForEach(s =>
|
|
|
+ {
|
|
|
+ var parent = structures.Find(x => x.ComponentItem == s.ParentItem);
|
|
|
+ s.Qty = parent.Qty * s.Qty;
|
|
|
+ });
|
|
|
+
|
|
|
//非虚拟件
|
|
|
var notPhantoms = chdStructures.Where(p => p.StructureType.ToUpper() != "X").ToList();
|
|
|
- //存在非虚拟件
|
|
|
- foreach (var item in notPhantoms)
|
|
|
- {
|
|
|
- item.ParentItem = parentItem;
|
|
|
- }
|
|
|
rtnStructures.AddRange(notPhantoms);
|
|
|
|
|
|
//虚拟件
|
|
|
@@ -3533,7 +3598,7 @@ namespace Business.ResourceExamineManagement
|
|
|
if (phantoms.Count > 0)
|
|
|
{
|
|
|
//递归
|
|
|
- RecursionProductStructure(parentItem, phantoms, rtnStructures);
|
|
|
+ RecursionProductStructure(phantoms, rtnStructures);
|
|
|
}
|
|
|
}
|
|
|
|