|
|
@@ -3715,60 +3715,67 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
public void AutoCreateBomBill(string companyid,List<mo_ic_bom> ic_Boms = null)
|
|
|
{
|
|
|
- bool flag = false;
|
|
|
- if (ic_Boms == null)
|
|
|
+ try
|
|
|
{
|
|
|
- flag = true;
|
|
|
- ic_Boms = _ic_bom.GetListAsync(p => p.company_id.ToString() == companyid && !p.IsDeleted).Result.ToList();
|
|
|
- }
|
|
|
- var pretreatment = _mysql_b_bom_pretreatment.GetListAsync(s => ic_Boms.Select(c => c.mysql_id).ToList().Contains(s.sourceid)).Result;
|
|
|
-
|
|
|
- param.company_id = long.Parse(companyid);
|
|
|
-
|
|
|
- //物料bom
|
|
|
- List<mo_ic_bom> bomlist = new List<mo_ic_bom>();
|
|
|
- List<mo_ic_bom_child> bomchildlist = new List<mo_ic_bom_child>();
|
|
|
- //物料信息
|
|
|
- List<mo_ic_item> icitemlist = new List<mo_ic_item>();
|
|
|
- //替代关系
|
|
|
- List<mo_ic_substitute> sublist = new List<mo_ic_substitute>();
|
|
|
- List<mo_ic_substitute_group> suballlist = new List<mo_ic_substitute_group>();
|
|
|
- List<mo_ic_substitute_group_detail> subdtllist = new List<mo_ic_substitute_group_detail>();
|
|
|
- IcItemPretreatment(flag, ic_Boms, bomlist, bomchildlist, icitemlist, sublist, suballlist, subdtllist);
|
|
|
-
|
|
|
- List<b_bom_pretreatment> deleteList = new List<b_bom_pretreatment>();
|
|
|
- List<b_bom_pretreatment> addList = new List<b_bom_pretreatment>();
|
|
|
- foreach (var bom in ic_Boms)
|
|
|
- {
|
|
|
- var pret = pretreatment.Where(s => s.sourceid == bom.mysql_id).ToList();
|
|
|
- if (pret.Any())
|
|
|
+ bool flag = false;
|
|
|
+ if (ic_Boms == null)
|
|
|
{
|
|
|
- //版本不同则重新生成
|
|
|
- deleteList.AddRange(pret);
|
|
|
+ flag = true;
|
|
|
+ ic_Boms = _ic_bom.GetListAsync(p => p.company_id.ToString() == companyid && !p.IsDeleted).Result.ToList();
|
|
|
}
|
|
|
- //bom层级组装
|
|
|
- var getBomList = _pretreatmentAppService.BomPretreatment(bom.mysql_id, bomlist, bomchildlist, icitemlist);
|
|
|
- //bom替代关系组装
|
|
|
- _pretreatmentAppService.BomSubstitute(getBomList, bomlist, bomchildlist, icitemlist, sublist, suballlist, subdtllist);
|
|
|
-
|
|
|
- //GenerateSort(getBomList);
|
|
|
- var list = ObjectMapper.Map<List<BomChildExamineDto>, List<b_bom_pretreatment>>(getBomList);
|
|
|
- list.ForEach(s =>
|
|
|
+ var pretreatment = _mysql_b_bom_pretreatment.GetListAsync(s => ic_Boms.Select(c => c.mysql_id).ToList().Contains(s.sourceid)).Result;
|
|
|
+
|
|
|
+ param.company_id = long.Parse(companyid);
|
|
|
+
|
|
|
+ //物料bom
|
|
|
+ List<mo_ic_bom> bomlist = new List<mo_ic_bom>();
|
|
|
+ List<mo_ic_bom_child> bomchildlist = new List<mo_ic_bom_child>();
|
|
|
+ //物料信息
|
|
|
+ List<mo_ic_item> icitemlist = new List<mo_ic_item>();
|
|
|
+ //替代关系
|
|
|
+ List<mo_ic_substitute> sublist = new List<mo_ic_substitute>();
|
|
|
+ List<mo_ic_substitute_group> suballlist = new List<mo_ic_substitute_group>();
|
|
|
+ List<mo_ic_substitute_group_detail> subdtllist = new List<mo_ic_substitute_group_detail>();
|
|
|
+ IcItemPretreatment(flag, ic_Boms, bomlist, bomchildlist, icitemlist, sublist, suballlist, subdtllist);
|
|
|
+
|
|
|
+ List<b_bom_pretreatment> deleteList = new List<b_bom_pretreatment>();
|
|
|
+ List<b_bom_pretreatment> addList = new List<b_bom_pretreatment>();
|
|
|
+ foreach (var bom in ic_Boms)
|
|
|
{
|
|
|
- s.sourceid = bom.mysql_id;
|
|
|
- s.company_id = bom.company_id;
|
|
|
- s.tenant_id = bom.tenant_id;
|
|
|
- s.factory_id = bom.factory_id;
|
|
|
- });
|
|
|
- addList.AddRange(list);
|
|
|
- }
|
|
|
- if (deleteList.Any())
|
|
|
- {
|
|
|
- _businessDbContext.BulkDelete(deleteList);
|
|
|
+ var pret = pretreatment.Where(s => s.sourceid == bom.mysql_id).ToList();
|
|
|
+ if (pret.Any())
|
|
|
+ {
|
|
|
+ //版本不同则重新生成
|
|
|
+ deleteList.AddRange(pret);
|
|
|
+ }
|
|
|
+ //bom层级组装
|
|
|
+ var getBomList = _pretreatmentAppService.BomPretreatment(bom.mysql_id, bomlist, bomchildlist, icitemlist);
|
|
|
+ //bom替代关系组装
|
|
|
+ _pretreatmentAppService.BomSubstitute(getBomList, bomlist, bomchildlist, icitemlist, sublist, suballlist, subdtllist);
|
|
|
+
|
|
|
+ //GenerateSort(getBomList);
|
|
|
+ var list = ObjectMapper.Map<List<BomChildExamineDto>, List<b_bom_pretreatment>>(getBomList);
|
|
|
+ list.ForEach(s =>
|
|
|
+ {
|
|
|
+ s.sourceid = bom.mysql_id;
|
|
|
+ s.company_id = bom.company_id;
|
|
|
+ s.tenant_id = bom.tenant_id;
|
|
|
+ s.factory_id = bom.factory_id;
|
|
|
+ });
|
|
|
+ addList.AddRange(list);
|
|
|
+ }
|
|
|
+ if (deleteList.Any())
|
|
|
+ {
|
|
|
+ _businessDbContext.BulkDelete(deleteList);
|
|
|
+ }
|
|
|
+ if (addList.Any())
|
|
|
+ {
|
|
|
+ _businessDbContext.BulkInsert(addList);
|
|
|
+ }
|
|
|
}
|
|
|
- if (addList.Any())
|
|
|
+ catch (Exception e)
|
|
|
{
|
|
|
- _businessDbContext.BulkInsert(addList);
|
|
|
+ new NLogHelper("ResourceExamineAppService").WriteLog("AutoCreateBomBill", "自动生成BOM预处理清单:" + e.Message, _currentTenant.Id.ToString());
|
|
|
}
|
|
|
}
|
|
|
|