|
|
@@ -1792,7 +1792,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="icBoms"></param>
|
|
|
/// <param name="bomlist"></param>
|
|
|
/// <param name="bomchildlist"></param>
|
|
|
- public void GetIcBomData(List<mo_ic_bom> icBoms, List<mo_ic_bom> bomlist, List<mo_ic_bom_child> bomchildlist)
|
|
|
+ public void GetIcBomData(List<mo_ic_bom> icBoms, List<mo_ic_bom> bomlist, List<mo_ic_bom_child> bomchildlist, bool flag)
|
|
|
{
|
|
|
if (icBoms.Count == 0)
|
|
|
{
|
|
|
@@ -1806,14 +1806,22 @@ namespace Business.ResourceExamineManagement
|
|
|
bomlist.Add(ib);
|
|
|
}
|
|
|
}
|
|
|
- //获取物料bom明细数据
|
|
|
- //List<mo_ic_bom_child> childList = _ic_bom_child.GetManyByCondition(p => icBoms.Select(m => m.mysql_id).Contains(p.bom_id) && p.use_status == 1 && p.tenant_id == param.tenantId && p.factory_id == param.factoryId && !p.IsDeleted).Result.ToList();
|
|
|
- List<mo_ic_bom_child> childList = _ic_bom_child.GetListAsync(p => icBoms.Select(m => m.mysql_id).Contains(p.bom_id) && p.company_id == param.company_id && !p.IsDeleted).Result.ToList();
|
|
|
+ List<long> icBomIds = icBoms.Select(m => m.mysql_id).ToList();
|
|
|
+ int page = 1;
|
|
|
+ page = (int)Math.Ceiling(icBomIds.Count() / (decimal)1500);
|
|
|
+ List<mo_ic_bom_child> childList = new List<mo_ic_bom_child>();
|
|
|
+ for (int i = 0; i < page; i++)
|
|
|
+ {
|
|
|
+ var pageBomsIds = icBomIds.Skip(i * 1500).Take(1500).ToList();
|
|
|
+ childList.AddRange(_ic_bom_child.GetListAsync(p => pageBomsIds.Contains(p.bom_id) && p.company_id == param.company_id && !p.IsDeleted).Result);
|
|
|
+ }
|
|
|
+
|
|
|
//没有明细数据,终止
|
|
|
if (childList.Count == 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
foreach (var bchild in childList)
|
|
|
{
|
|
|
if (!bomchildlist.Exists(s => s.mysql_id == bchild.mysql_id))
|
|
|
@@ -1821,12 +1829,23 @@ namespace Business.ResourceExamineManagement
|
|
|
bomchildlist.Add(bchild);
|
|
|
}
|
|
|
}
|
|
|
+ if (flag)
|
|
|
+ { return; }
|
|
|
+ page = 1;
|
|
|
+ page = (int)Math.Ceiling(childList.Count() / (decimal)1500);
|
|
|
+ List<mo_ic_bom> boms = new List<mo_ic_bom>();
|
|
|
+ for (int i = 0; i < page; i++)
|
|
|
+ {
|
|
|
+ var pageChild = childList.Skip(i * 1500).Take(1500).ToList();
|
|
|
+ boms.AddRange(_ic_bom.GetListAsync(p => pageChild.Select(m => m.icitem_id).ToList().Contains(p.icitem_id) && p.use_status == 1 && p.company_id == param.company_id && !p.IsDeleted).Result);
|
|
|
+ }
|
|
|
+
|
|
|
//通过物料bom明细数据反查物料bom数据
|
|
|
- var boms = _ic_bom.GetListAsync(p => childList.Select(m => m.icitem_id).ToList().Contains(p.icitem_id) && p.use_status == 1 && p.company_id == param.company_id && !p.IsDeleted).Result.ToList();
|
|
|
+ // = _ic_bom.GetListAsync(p => childList.Select(m => m.icitem_id).ToList().Contains(p.icitem_id) && p.use_status == 1 && p.company_id == param.company_id && !p.IsDeleted).Result;
|
|
|
foreach (var chd in childList)
|
|
|
{
|
|
|
var curBoms = boms.Where(p => p.icitem_id == chd.icitem_id).ToList();
|
|
|
- GetIcBomData(curBoms, bomlist, bomchildlist);
|
|
|
+ GetIcBomData(curBoms, bomlist, bomchildlist, flag);
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
@@ -3555,10 +3574,10 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="sublist"></param>
|
|
|
/// <param name="suballlist"></param>
|
|
|
/// <param name="subdtllist"></param>
|
|
|
- public void IcItemPretreatment(List<mo_ic_bom> boms, List<mo_ic_bom> bomlist, List<mo_ic_bom_child> bomchildlist, List<mo_ic_item> icitemlist, List<mo_ic_substitute> sublist, List<mo_ic_substitute_group> suballlist, List<mo_ic_substitute_group_detail> subdtllist)
|
|
|
+ public void IcItemPretreatment(bool flag, List<mo_ic_bom> boms, List<mo_ic_bom> bomlist, List<mo_ic_bom_child> bomchildlist, List<mo_ic_item> icitemlist, List<mo_ic_substitute> sublist, List<mo_ic_substitute_group> suballlist, List<mo_ic_substitute_group_detail> subdtllist)
|
|
|
{
|
|
|
//获取物料bom,物料bom明细
|
|
|
- GetIcBomData(boms, bomlist, bomchildlist);
|
|
|
+ GetIcBomData(boms, bomlist, bomchildlist, flag);
|
|
|
|
|
|
//根据明细集合查出所有得替代关系表数据集合
|
|
|
List<string> codeList = bomchildlist.Select(c => c.substitute_code).Distinct().ToList();
|
|
|
@@ -3582,7 +3601,12 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
public void AutoCreateBomBill(string companyid,List<mo_ic_bom> ic_Boms = null)
|
|
|
{
|
|
|
- ic_Boms ??= _ic_bom.GetListAsync(p => p.company_id.ToString() == companyid && !p.IsDeleted).Result.ToList();
|
|
|
+ bool flag = false;
|
|
|
+ if (ic_Boms == null)
|
|
|
+ {
|
|
|
+ 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);
|
|
|
@@ -3596,7 +3620,7 @@ namespace Business.ResourceExamineManagement
|
|
|
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(ic_Boms, bomlist, bomchildlist, icitemlist, sublist, suballlist, subdtllist);
|
|
|
+ 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>();
|
|
|
@@ -3618,7 +3642,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//bom替代关系组装
|
|
|
_pretreatmentAppService.BomSubstitute(getBomList, bomlist, bomchildlist, icitemlist, sublist, suballlist, subdtllist);
|
|
|
|
|
|
- GenerateSort(getBomList);
|
|
|
+ //GenerateSort(getBomList);
|
|
|
var list = ObjectMapper.Map<List<BomChildExamineDto>, List<b_bom_pretreatment>>(getBomList);
|
|
|
list.ForEach(s =>
|
|
|
{
|