|
|
@@ -205,6 +205,12 @@ namespace Business.ResourceExamineManagement
|
|
|
/// 工单App
|
|
|
/// </summary>
|
|
|
private readonly MorderAppService _morderAppService;
|
|
|
+
|
|
|
+ private List<ICItemLeadTimeDto> leadTimeList;
|
|
|
+
|
|
|
+ private List<ic_item_pur> supplierList;
|
|
|
+
|
|
|
+ private List<ic_plan> planList;
|
|
|
#endregion
|
|
|
|
|
|
#region 构造函数
|
|
|
@@ -357,20 +363,19 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
List<long> suballidlist = suballlist.Select(c => c.Id).ToList();
|
|
|
var subdtllist = _ic_substitute_all_dtl.GetManyByCondition(p => suballidlist.Contains(p.substitute_allid) && !p.IsDeleted).Result;
|
|
|
-
|
|
|
-
|
|
|
|
|
|
//物料占用记录
|
|
|
List<ic_item_stockoccupy> sklist = new List<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;
|
|
|
|
|
|
//物料提前期
|
|
|
- var leadTimeList = GetLeadTime(itemIds, input.tenantId, input.factoryId);//提前期列表
|
|
|
- var supplierList = GetSupplier(itemIds, input.tenantId, input.factoryId);//供应商列表
|
|
|
- var planList = GetICPlan(itemIds, input.tenantId, input.factoryId);//plan列表
|
|
|
+ leadTimeList = GetLeadTime(itemIds, input.tenantId, input.factoryId);//提前期列表
|
|
|
+ supplierList = GetSupplier(itemIds, input.tenantId, input.factoryId);//供应商列表
|
|
|
+ planList = GetICPlan(itemIds, input.tenantId, input.factoryId);//plan列表
|
|
|
|
|
|
foreach (var item in sentrys)
|
|
|
{
|
|
|
@@ -701,55 +706,57 @@ namespace Business.ResourceExamineManagement
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
//最顶级、虚拟件
|
|
|
- if (item.level != 1 && item.erp_cls != 4 && !childidList.Contains(item.bom_child_id.GetValueOrDefault()))
|
|
|
+ if (item.level == 1 || item.erp_cls == 4 ||!childidList.Contains(item.bom_child_id.GetValueOrDefault()))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //有替代关系
|
|
|
+ if (item.haveicsubs == 1)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty(item.icitem_ids))
|
|
|
{
|
|
|
- //有替代关系
|
|
|
- if (item.haveicsubs == 1)
|
|
|
+ long cid = 1;
|
|
|
+ var cids = item.icitem_ids.Split(',');
|
|
|
+ foreach (var c in cids)
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(item.icitem_ids))
|
|
|
+ if (long.TryParse(c, out cid))
|
|
|
{
|
|
|
- long cid = 1;
|
|
|
- var cids = item.icitem_ids.Split(',');
|
|
|
- foreach (var c in cids)
|
|
|
- {
|
|
|
- if (long.TryParse(c, out cid))
|
|
|
- {
|
|
|
- childidList.Add(cid);
|
|
|
- }
|
|
|
- }
|
|
|
+ childidList.Add(cid);
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- //找到当前物料的替代群组关系集
|
|
|
- var sl = sublist.Find(s => s.substitute_code == item.substitute_code);
|
|
|
- if (sl != null)
|
|
|
+ //找到当前物料的替代群组关系集
|
|
|
+ var sl = sublist.Find(s => s.substitute_code == item.substitute_code);
|
|
|
+ if (sl != null)
|
|
|
+ {
|
|
|
+ var sall = suballlist.Where(s => s.substitute_id == sl.Id).ToList();
|
|
|
+ foreach (var sal in sall)
|
|
|
+ {
|
|
|
+ var sadl = subdtllist.Where(s => s.substitute_allid == sal.Id).ToList();
|
|
|
+ List<long> dtlItemId = sadl.Select(m => m.icitem_id).ToList();
|
|
|
+ var dtlitemlist = _ic_item.GetManyByCondition(p => dtlItemId.Contains(p.Id) && !p.IsDeleted).Result;
|
|
|
+ icitemlist.AddRange(dtlitemlist);
|
|
|
+ foreach (var dtl in sadl)
|
|
|
{
|
|
|
- var sall = suballlist.Where(s => s.substitute_id == sl.Id).ToList();
|
|
|
- foreach (var sal in sall)
|
|
|
+ if (sal.main_material.GetValueOrDefault() != 1)
|
|
|
{
|
|
|
- var sadl = subdtllist.Where(s => s.substitute_allid == sal.Id).ToList();
|
|
|
- List<long> dtlItemId = sadl.Select(m => m.icitem_id).ToList();
|
|
|
- var dtlitemlist = _ic_item.GetManyByCondition(p => dtlItemId.Contains(p.Id) && !p.IsDeleted).Result;
|
|
|
- icitemlist.AddRange(dtlitemlist);
|
|
|
- foreach (var dtl in sadl)
|
|
|
- {
|
|
|
- if (sal.MainMaterial.Value != 1)
|
|
|
- {
|
|
|
- //递归将替代关系组装出来。
|
|
|
- SubstitutePretreatment(sl, sal, dtl, item, addlist, icitemlist, bomlist, bomchildlist, type);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //将主料赋值上属性
|
|
|
- var dtlitem = returnlist.Find(s => s.item_id == dtl.icitem_id && s.level == item.level);
|
|
|
- dtlitem.substitute_all_num = sal.order_num;//群组优先级
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ //递归将替代关系组装出来。
|
|
|
+ SubstitutePretreatment(sl, sal, dtl, item, addlist, icitemlist, bomlist, bomchildlist, type);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //将主料赋值上属性
|
|
|
+ var dtlitem = returnlist.Find(s => s.item_id == dtl.icitem_id && s.level == item.level);
|
|
|
+ dtlitem.substitute_all_num = sal.order_num;//群组优先级
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -997,21 +1004,32 @@ namespace Business.ResourceExamineManagement
|
|
|
var Day = minute.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
|
|
|
item.kitting_time = item.kitting_time.Value.AddDays((double)Day);
|
|
|
}
|
|
|
- else if (item.erp_cls == 2 || item.erp_cls == 3)
|
|
|
+ else if (item.erp_cls == 2)
|
|
|
{
|
|
|
- /*var leadTimeList = GetLeadTime(new List<long> { item.item_id }, input.tenantId, input.factoryId);//提前期列表
|
|
|
- var supplierList = GetSupplier(new List<BomChildExamineDto> { item }, input.tenantId, input.factoryId);//供应商列表
|
|
|
- var planList = GetICPlan(new List<BomChildExamineDto> { item }, input.tenantId, input.factoryId);//plan列表
|
|
|
- item.kitting_time = CreateSRMPR(item, input.tenantId, input.factoryId, bangid, item.erp_cls, leadTimeList, supplierList, planList, plan_date.Value);
|
|
|
+ //采购申请
|
|
|
+ var SRMPRDto = CreateSRMPR(item, input.tenantId, input.factoryId, bangid, item.erp_cls, leadTimeList, supplierList, planList, plan_date.Value);
|
|
|
+ item.kitting_time = SRMPRDto.lastStartTmie;
|
|
|
+ }
|
|
|
+ else if (item.erp_cls == 3)
|
|
|
+ {
|
|
|
+
|
|
|
if (item.erp_cls == 3)
|
|
|
{
|
|
|
- //生成委外工单
|
|
|
- CreateMesOOder(item, input.tenantId, input.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
//1.先生成委外工单。
|
|
|
- //2.再根据委外工单需要检查库存材料,然后提供给第三方组装。
|
|
|
+ CreateMesOOder(item, input.tenantId, input.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
+ //2.再根据委外工单需要检查库存材料,然后提供给第三方组装(委外生产)。
|
|
|
//3.如果委外工单的物料库存不够,先生成物料采购申请单,再生成物料的采购订单,到货后再走委外流程。
|
|
|
+ /*foreach (var cl in cilList)
|
|
|
+ {
|
|
|
+ if (cl.stock_state == 0 || cl.stock_state == 2)
|
|
|
+ {
|
|
|
+ //采购申请
|
|
|
+ var SRMPRDto = CreateSRMPR(item, input.tenantId, input.factoryId, bangid, item.erp_cls, leadTimeList, supplierList, planList, plan_date.Value);
|
|
|
+ item.kitting_time = SRMPRDto.lastStartTmie;
|
|
|
+ }
|
|
|
+ }*/
|
|
|
//4.再生成委外的采购申请单。
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|