heteng пре 3 година
родитељ
комит
18ec08f217

+ 43 - 6
MicroServices/Business/Business.Application/ResourceExamineManagement/ResourceExamineAppService.cs

@@ -369,12 +369,12 @@ namespace Business.ResourceExamineManagement
             //通过订单行的产品代码获取物料BOM数据
             //FilterDefinition<ic_bom> filter = Builders<ic_bom>.Filter.In(s => s.bom_number, sentrys.Select(m => m.bom_number).ToList());
             //List<ic_bom> boms = _ic_bom.GetManyByIds(filter).Result.Where(p => p.factory_id == input.factoryId && p.tenant_id == input.tenantId && !p.IsDeleted).ToList();
-            List<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();
+            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();
 
             //物料bom
-            List<ic_bom> bomlist = new List<ic_bom>();
+            List<mo_ic_bom> bomlist = new List<mo_ic_bom>();
             //物料bom明细
-            List<ic_bom_child> bomchildlist = new List<ic_bom_child>();
+            List<mo_ic_bom_child> bomchildlist = new List<mo_ic_bom_child>();
             //获取物料bom,物料bom明细
             GetIcBomData(boms, bomlist, bomchildlist);
 
@@ -382,7 +382,7 @@ namespace Business.ResourceExamineManagement
             List<string> codeList = bomchildlist.Select(c => c.substitute_code).ToList();
             var sublist = _ic_substitute.GetManyByCondition(p => codeList.Contains(p.substitute_code) && !p.IsDeleted).Result;
 
-            List<long> subidlist = sublist.Select(c => c.Id).ToList();
+            List<long> subidlist = sublist.Select(c => c.mysql_id.GetValueOrDefault()).ToList();
             var suballlist = _ic_substitute_all.GetManyByCondition(p => subidlist.Contains(p.substitute_id) && !p.IsDeleted).Result;
 
             List<long> suballidlist = suballlist.Select(c => c.Id).ToList();
@@ -391,12 +391,12 @@ namespace Business.ResourceExamineManagement
 
 
             //物料占用记录
-            List<ic_item_stockoccupy> sklist = new List<ic_item_stockoccupy>();
+            List<mo_ic_item_stockoccupy> sklist = new List<mo_ic_item_stockoccupy>();
             //获取物料数据
             List<long> itemIds = bomlist.Select(p => p.icitem_id).ToList();
             itemIds.AddRange(bomchildlist.Select(p => p.icitem_id).ToList());
             itemIds.AddRange(subdtllist.Select(p => p.icitem_id).ToList());
-            List<ic_item> icitemlist = _ic_item.GetManyByCondition(p => itemIds.Contains(p.Id) && !p.IsDeleted).Result;
+            List<mo_ic_item> icitemlist = _ic_item.GetManyByCondition(p => itemIds.Contains(p.Id) && !p.IsDeleted).Result;
 
             //物料库存
             var stocklist = _ic_item_stock.GetManyByCondition(p => p.factory_id == param.factoryId && itemIds.Contains(p.icitem_id)).Result;
@@ -590,6 +590,43 @@ namespace Business.ResourceExamineManagement
             }
         }
 
+        /// <summary>
+        /// 清处数据库快照
+        /// </summary>
+        /// <returns></returns>
+        public async Task ClearSnapShot(long bangid)
+        {
+            //清除物料库存数据
+            await _ic_item_stock.Delete(p => p.bang_id == bangid);
+
+            //清除工单占用记录表
+            await _mes_mooccupy.Delete(p => p.bang_id == bangid);
+
+            //清除工单主表
+            await _mes_morder.Delete(p => p.bang_id == bangid);
+
+            //清除工单子表
+            await _mes_moentry.Delete(p => p.bang_id == bangid);
+
+            //清除采购订单
+            await _srm_po_main.Delete(p => p.bang_id == bangid);
+
+            //清除采购订单明细
+            await _srm_po_list.Delete(p => p.bang_id == bangid);
+
+            //清除采购订单占用详情
+            await _srm_po_occupy.Delete(p => p.bang_id == bangid);
+
+            //清除工厂物料明细表
+            await _ic_factory_details.Delete(p => p.bang_id == bangid);
+
+            //清除物料采购计划表
+            await _ic_plan.Delete(p => p.bang_id == bangid);
+
+            //清除物料采购报价单
+            await _ic_item_pur.Delete(p => p.bang_id == bangid);
+        }
+
         /// <summary>
         /// 根据物料id获取物料4个提前期
         /// </summary>