|
|
@@ -575,10 +575,6 @@ namespace Business.ResourceExamineManagement
|
|
|
//删除同步Mysql后旧数据
|
|
|
await DeleteMySqlOldData(sentrys);
|
|
|
|
|
|
-
|
|
|
- //数据库快照-同步mysql库数据到mongoDB中
|
|
|
- await DbSnapShot(input.tenantId, input.factoryId, bangid);
|
|
|
-
|
|
|
//通过订单行的产品代码获取物料BOM数据
|
|
|
List<mo_ic_bom> boms = _ic_bom.Find(p => sentrys.Select(m => m.item_number).Contains(p.item_number) && p.factory_id == input.factoryId && p.tenant_id == input.tenantId && !p.IsDeleted).Result.ToList();
|
|
|
//物料信息
|
|
|
@@ -602,6 +598,10 @@ namespace Business.ResourceExamineManagement
|
|
|
AutoCreateBomBill(autoCreates);
|
|
|
pretreatments = _mysql_b_bom_pretreatment.GetListAsync(s => boms.Select(c => c.mysql_id).ToList().Contains(s.sourceid)).Result;
|
|
|
}
|
|
|
+
|
|
|
+ //数据库快照-同步mysql库数据到mongoDB中
|
|
|
+ await DbSnapShot(input.tenantId, input.factoryId, bangid, pretreatments);
|
|
|
+
|
|
|
//记录订单行的物料齐套时间
|
|
|
List<KittingTimeDto> kittingTimes = new List<KittingTimeDto>();
|
|
|
DataInitialization(boms, bangid, icitemlist, stocklist, pretreatments);
|
|
|
@@ -755,7 +755,7 @@ namespace Business.ResourceExamineManagement
|
|
|
return e.Message;
|
|
|
};
|
|
|
}
|
|
|
-
|
|
|
+ #region
|
|
|
//using (TransactionScope scope = new TransactionScope())
|
|
|
//{
|
|
|
// try
|
|
|
@@ -823,6 +823,7 @@ namespace Business.ResourceExamineManagement
|
|
|
// return e.Message;
|
|
|
// }
|
|
|
//}
|
|
|
+ #endregion
|
|
|
List<mo_srm_pr_main> prmainlist = new List<mo_srm_pr_main>();
|
|
|
if (_CalcBomViewAppService.SRMPRDtoList.Any())
|
|
|
{
|
|
|
@@ -1084,7 +1085,7 @@ namespace Business.ResourceExamineManagement
|
|
|
return e.Message;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ #region
|
|
|
//using (TransactionScope scope = new TransactionScope())
|
|
|
//{
|
|
|
// try
|
|
|
@@ -1126,7 +1127,7 @@ namespace Business.ResourceExamineManagement
|
|
|
// return e.Message;
|
|
|
// }
|
|
|
//}
|
|
|
-
|
|
|
+ #endregion
|
|
|
//清空快照数据
|
|
|
await ClearSnapShot(bangid);
|
|
|
//return JsonConvert.SerializeObject(rtn);
|
|
|
@@ -1250,14 +1251,24 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 数据库快照
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public async Task DbSnapShot(long tenantId, long factoryId, long bangid)
|
|
|
+ public async Task DbSnapShot(long tenantId, long factoryId, long bangid,List<b_bom_pretreatment> pretreatments)
|
|
|
{
|
|
|
- //同步物料库存数据
|
|
|
- var icitemStokc = _mysql_ic_item_stock.GetListAsync(p => p.tenant_id == tenantId && p.factory_id == factoryId).Result;
|
|
|
+ //同步物料库存数据 根据预处理,来只找出部分数据同步。
|
|
|
+ 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;
|
|
|
if (icitemStokc.Count > 0)
|
|
|
{
|
|
|
+ List<string> numbers = pretreatments.Select(s => s.item_number).ToList();
|
|
|
+ var locStock = _locationDetail.Select(a => numbers.Contains(a.ItemNum) && a.IsActive && a.Domain == factoryId.ToString());
|
|
|
//设置当前计算bangid
|
|
|
- icitemStokc.ForEach(item => { item.bang_id = bangid; });
|
|
|
+ icitemStokc.ForEach(item => {
|
|
|
+ item.bang_id = bangid;
|
|
|
+ var pret = pretreatments.Find(s => s.item_id == item.icitem_id);
|
|
|
+ if(pret != null) {
|
|
|
+ item.sqty = locStock.Where(s => s.ItemNum == pret.item_number).Sum(p => p.QtyOnHand.GetValueOrDefault());
|
|
|
+ }
|
|
|
+ });
|
|
|
var moIcitemStokc = ObjectMapper.Map<List<ic_item_stock>, List<mo_ic_item_stock>>(icitemStokc);
|
|
|
moIcitemStokc.ForEach(item => { item.id = help.NextId(); });
|
|
|
//插入数据
|
|
|
@@ -2244,9 +2255,7 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
//删除同步Mysql后旧数据
|
|
|
await DeleteMySqlOldData(sentrys);
|
|
|
- //数据库快照-同步mysql库数据到mongoDB中
|
|
|
- await DbSnapShot(input.tenantId, input.factoryId, bangid);
|
|
|
-
|
|
|
+
|
|
|
List<mo_ic_bom> boms = _ic_bom.Find(p => mo_Mes_Morders.Select(m => m.bom_number).Contains(p.bom_number) && p.factory_id == input.factoryId && p.tenant_id == input.tenantId && !p.IsDeleted).Result.ToList();
|
|
|
|
|
|
//物料bom
|
|
|
@@ -2280,6 +2289,9 @@ namespace Business.ResourceExamineManagement
|
|
|
pretreatments = _mysql_b_bom_pretreatment.GetListAsync(s => boms.Select(c => c.mysql_id).ToList().Contains(s.sourceid)).Result;
|
|
|
}
|
|
|
|
|
|
+ //数据库快照-同步mysql库数据到mongoDB中
|
|
|
+ await DbSnapShot(input.tenantId, input.factoryId, bangid, pretreatments);
|
|
|
+
|
|
|
DataInitialization(boms, bangid, icitemlist, stocklist, pretreatments);
|
|
|
_morderAppService.param = param;
|
|
|
_purchaseOrderAppService.param = param;
|