|
|
@@ -559,7 +559,8 @@ namespace Business.ResourceExamineManagement
|
|
|
dto.haveicsubs = 0;
|
|
|
dto.substitute_code = "";
|
|
|
dto.icitem_ids = "";
|
|
|
- GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist);
|
|
|
+ int type = 0;
|
|
|
+ GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist, type);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -570,7 +571,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="icitemlist"></param>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <param name="returnlist"></param>
|
|
|
- public void GetBomList(List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist, BomChildExamineDto dto, List<BomChildExamineDto> returnlist)
|
|
|
+ public void GetBomList(List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist, BomChildExamineDto dto, List<BomChildExamineDto> returnlist,int type)
|
|
|
{
|
|
|
int level = dto.level++;//初始化定义level层级
|
|
|
var help = new SnowFlake();
|
|
|
@@ -581,11 +582,6 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
|
|
|
}
|
|
|
- //var dto = new BomChildExamineDto();
|
|
|
- //dto.level = level;
|
|
|
- //dto.bom_id = bomId;
|
|
|
- //dto.id = help.NextId();
|
|
|
- //dto.parent_id = parent_id;
|
|
|
dto.item_id = bom.icitem_id;
|
|
|
dto.item_name = bom.item_name;
|
|
|
dto.item_code = bom.item_number;
|
|
|
@@ -593,7 +589,7 @@ namespace Business.ResourceExamineManagement
|
|
|
dto.unit = bom.unit;
|
|
|
dto.erp_cls = item.erp_cls;
|
|
|
dto.erp_cls_name = item.erp_cls_name;
|
|
|
-
|
|
|
+ dto.type = type;
|
|
|
|
|
|
//var bdto = ObjectMapper.Map<ic_bom,BomChildExamineDto>(bom);
|
|
|
returnlist.Add(dto);
|
|
|
@@ -622,7 +618,9 @@ namespace Business.ResourceExamineManagement
|
|
|
cdto.haveicsubs = c.haveicsubs;
|
|
|
cdto.substitute_code = c.substitute_code;
|
|
|
cdto.icitem_ids = c.icitem_ids;
|
|
|
- GetBomList(bomlist, bomchildlist, icitemlist, cdto, returnlist);
|
|
|
+ cdto.type = type;
|
|
|
+ //递归寻找子级
|
|
|
+ GetBomList(bomlist, bomchildlist, icitemlist, cdto, returnlist, type);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -649,6 +647,7 @@ namespace Business.ResourceExamineManagement
|
|
|
childDto.haveicsubs = c.haveicsubs;
|
|
|
childDto.substitute_code = c.substitute_code;
|
|
|
childDto.icitem_ids = c.icitem_ids;
|
|
|
+ childDto.type = type;
|
|
|
returnlist.Add(childDto);
|
|
|
}
|
|
|
}
|
|
|
@@ -661,7 +660,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <summary>
|
|
|
/// BOM替代关系预处理
|
|
|
/// </summary>
|
|
|
- public void BomSubstitute(List<BomChildExamineDto> returnlist, List<ic_item> icitemlist)
|
|
|
+ public void BomSubstitute(List<BomChildExamineDto> returnlist, List<ic_bom> bomlist, List<ic_bom_child> bomchildlist, List<ic_item> icitemlist)
|
|
|
{
|
|
|
var sublist = _ic_substitute.GetManyByCondition(s => s.substitute_code.IsIn(returnlist.Select(c => c.substitute_code))).Result.ToList();
|
|
|
var suballlist = _ic_substitute_all.GetManyByCondition(s => s.substitute_id.IsIn(sublist.Select(c => c.Id))).Result.ToList();
|
|
|
@@ -669,6 +668,7 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
List<long> dicIds = new List<long>();
|
|
|
var help = new SnowFlake();
|
|
|
+ int type = 1;
|
|
|
//除顶级外,其他层级关系全带出来。生成平铺
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
@@ -678,23 +678,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//有替代关系
|
|
|
if (item.haveicsubs == 1)
|
|
|
{
|
|
|
- /*//群组替代
|
|
|
- if (item.is_replace == 1)
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(item.icitem_ids))
|
|
|
- {
|
|
|
- var ids = item.icitem_ids.Split(',');
|
|
|
- foreach (var i in ids)
|
|
|
- {
|
|
|
- long id = 0;
|
|
|
- if (long.TryParse(i, out id))
|
|
|
- {
|
|
|
- dicIds.Add(id);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
+ //找到当前物料的替代群组关系集
|
|
|
var sl = sublist.Find(s => s.substitute_code == item.substitute_code);
|
|
|
if (sl != null)
|
|
|
{
|
|
|
@@ -704,35 +688,8 @@ namespace Business.ResourceExamineManagement
|
|
|
var sadl = subdtllist.Where(s => s.substitute_allid == sal.Id).ToList();
|
|
|
foreach (var dtl in sadl)
|
|
|
{
|
|
|
- SubstitutePretreatment(sal, dtl, item, returnlist, icitemlist);
|
|
|
- //var sitem = icitemlist.Find(s => s.Id == dtl.icitem_id);
|
|
|
- //if (sitem != null)
|
|
|
- //{
|
|
|
- // var childDto = new BomChildExamineDto();
|
|
|
- // childDto.level = item.level;
|
|
|
- // childDto.bom_id = item.bom_id;
|
|
|
- // childDto.id = help.NextId();
|
|
|
- // childDto.parent_id = item.parent_id;
|
|
|
- // childDto.item_id = sitem.Id;
|
|
|
- // childDto.item_name = sitem.name;
|
|
|
- // childDto.item_code = sitem.number;
|
|
|
- // childDto.num = item.num;
|
|
|
- // childDto.model = sitem.model;
|
|
|
- // childDto.unit = sitem.unit;
|
|
|
- // childDto.erp_cls = sitem.erp_cls;
|
|
|
- // childDto.erp_cls_name = sitem.erp_cls_name;
|
|
|
- // childDto.backflush = item.backflush;
|
|
|
- // childDto.replace_amount = dtl.use_amount.Value;
|
|
|
- // childDto.replace_amount = dtl.replace_amount.Value;
|
|
|
-
|
|
|
- // childDto.isbom = 0;
|
|
|
- // childDto.is_replace = c.is_replace;
|
|
|
- // childDto.haveicsubs = c.haveicsubs;
|
|
|
- // childDto.substitute_code = c.substitute_code;
|
|
|
- // childDto.icitem_ids = c.icitem_ids;
|
|
|
- // returnlist.Add(childDto);
|
|
|
- //}
|
|
|
-
|
|
|
+ //递归将替代关系组装出来。
|
|
|
+ SubstitutePretreatment(sl, sal, dtl, item, returnlist, icitemlist, bomlist, bomchildlist,type);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -741,11 +698,68 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void SubstitutePretreatment(ic_substitute_all sal, ic_substitute_all_dtl dtl, BomChildExamineDto toDto, List<BomChildExamineDto> returnlist, List<ic_item> icitemlist)
|
|
|
+ /// <summary>
|
|
|
+ /// 替代关系递归组装出来
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="sal"></param>
|
|
|
+ /// <param name="dtl"></param>
|
|
|
+ /// <param name="toDto"></param>
|
|
|
+ /// <param name="returnlist"></param>
|
|
|
+ /// <param name="icitemlist"></param>
|
|
|
+ /// <param name="bomlist"></param>
|
|
|
+ /// <param name="bomchildlist"></param>
|
|
|
+ public void SubstitutePretreatment(ic_substitute sl, ic_substitute_all sal, ic_substitute_all_dtl dtl,BomChildExamineDto toDto,List<BomChildExamineDto> returnlist, List<ic_item> icitemlist, List<ic_bom> bomlist, List<ic_bom_child> bomchildlist,int type)
|
|
|
{
|
|
|
- //生成sal层级dto,是toDto的替代关系,类似R6-K50的BOM的层级1.1.1
|
|
|
//循环生成dtl层级dto,明细
|
|
|
//如果dtl对应的icitem是BOM,还需要向下继续展开。
|
|
|
+ var help = new SnowFlake();
|
|
|
+
|
|
|
+ //List<BomChildExamineDto> returnlist = new List<BomChildExamineDto>();
|
|
|
+ var dto = new BomChildExamineDto();
|
|
|
+ var bom = bomlist.WhereIf(true, s => s.icitem_id == dtl.icitem_id).FirstOrDefault();
|
|
|
+ var icitem = icitemlist.Find(s => s.Id == dtl.icitem_id);
|
|
|
+ if (icitem == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ dto.id = help.NextId();
|
|
|
+ dto.level = toDto.level;
|
|
|
+ dto.parent_id = toDto.parent_id;
|
|
|
+ dto.item_id = icitem.Id;
|
|
|
+ dto.item_name = icitem.name;
|
|
|
+ dto.item_code = icitem.number;
|
|
|
+ dto.num = toDto.num;
|
|
|
+ dto.model = icitem.model;
|
|
|
+ dto.unit = icitem.unit;
|
|
|
+ dto.erp_cls = icitem.erp_cls;
|
|
|
+ dto.erp_cls_name = icitem.erp_cls_name;
|
|
|
+ dto.backflush = toDto.backflush;
|
|
|
+ dto.qty = toDto.qty;
|
|
|
+ dto.replace_amount = dtl.replace_amount.Value;
|
|
|
+ dto.is_replace = 0;
|
|
|
+ dto.haveicsubs = 0;
|
|
|
+ dto.substitute_code = "";
|
|
|
+ dto.icitem_ids = "";
|
|
|
+ dto.substitute_strategy = sl.substitute_strategy.Value;
|
|
|
+ dto.substitute_mode = sl.substitute_mode.Value;
|
|
|
+ dto.type = type;
|
|
|
+ if (bom != null)
|
|
|
+ {
|
|
|
+ dto.bom_id = bom.Id;
|
|
|
+
|
|
|
+ dto.qty = dtl.replace_amount.Value;
|
|
|
+ dto.isbom = 1;
|
|
|
+ dto.is_replace = 0;
|
|
|
+ dto.haveicsubs = 0;
|
|
|
+ dto.substitute_code = "";
|
|
|
+ dto.icitem_ids = "";
|
|
|
+ GetBomList(bomlist, bomchildlist, icitemlist, dto, returnlist, type);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ dto.bom_id = null;
|
|
|
+ dto.isbom = 0;
|
|
|
+ returnlist.Add(dto);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|