|
|
@@ -467,7 +467,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//库存初始化
|
|
|
BomStock(getBomList, bangid, input.factoryId);
|
|
|
//
|
|
|
- calcTest(getBomList, bangid, o.Id, o.qty.Value);
|
|
|
+ calcTest(getBomList, bangid, o.Id, o.qty.Value, input, o.plan_date);
|
|
|
|
|
|
//最晚开工时间
|
|
|
dtl.latest_times = o.plan_date.GetValueOrDefault();
|
|
|
@@ -1362,7 +1362,8 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
|
|
|
//计算库存
|
|
|
- public void calcTest(List<BomChildExamineDto> returnlist, long bangid, long orderid,decimal count)
|
|
|
+ public void calcTest(List<BomChildExamineDto> returnlist, long bangid, long orderid,decimal count, SeorderentryDto input,DateTime
|
|
|
+ ? plan_date)
|
|
|
{
|
|
|
//占用情况
|
|
|
List<ic_item_stockoccupy> sklist = new List<ic_item_stockoccupy>();
|
|
|
@@ -1411,11 +1412,32 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
//如果有替代关系,根据群组来明确使用哪个群组的替代料。按整批和混用逻辑来算
|
|
|
// 如果有群组替代,就移除掉被检查过的记录 item.icitem_ids
|
|
|
- CalcStrategy(item, returnlist, bangid, sklist);
|
|
|
+ CalcStrategy(item, returnlist, bangid, sklist, input, plan_date);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //直接占用库存,缺料就生成采购
|
|
|
+ if (item.erp_cls == 1)
|
|
|
+ {
|
|
|
+ //走自制
|
|
|
+ }
|
|
|
+ else if (item.erp_cls == 2 || item.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //直接占用库存,缺料就生成采购
|
|
|
+ ic_item_stockoccupy itemStockoccupyDto = new ic_item_stockoccupy();
|
|
|
+ itemStockoccupyDto.bang_id = bangid;
|
|
|
+ itemStockoccupyDto.icitem_id = item.item_id;
|
|
|
+ itemStockoccupyDto.quantity = item.sqty;
|
|
|
+ sklist.Add(itemStockoccupyDto);
|
|
|
+ var leadTimeList = GetLeadTime(new List<BomChildExamineDto> { item }, 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列表
|
|
|
+ CreateSRMPR(item, input.tenantId, input.factoryId, bangid, item.erp_cls, leadTimeList, supplierList, planList, plan_date.Value);
|
|
|
+ if (item.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //生成委外工单
|
|
|
+ CreateMesOOder(item, input.tenantId, input.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1455,7 +1477,8 @@ namespace Business.ResourceExamineManagement
|
|
|
item.stock_state = item.lack_qty > 0 ? 0 : 1;
|
|
|
}
|
|
|
|
|
|
- public void CalcStrategy(BomChildExamineDto item, List<BomChildExamineDto> returnlist, long bangid, List<ic_item_stockoccupy> sklist)
|
|
|
+ public void CalcStrategy(BomChildExamineDto item, List<BomChildExamineDto> returnlist, long bangid, List<ic_item_stockoccupy> sklist, SeorderentryDto input, DateTime
|
|
|
+ ? plan_date)
|
|
|
{
|
|
|
//提取群组关系
|
|
|
var sublist = returnlist.Where(s => s.parent_id == item.parent_id && s.num == item.num && s.level == item.level).OrderBy(c => c.substitute_all_num).ToList();
|
|
|
@@ -1466,22 +1489,22 @@ namespace Business.ResourceExamineManagement
|
|
|
case 0://整批
|
|
|
WholeBatchCheck(sublist, returnlist, sklist, select);
|
|
|
//如果都需要采购的情况下,则默认使用优先级最高的
|
|
|
- WholeBatch(item,sublist, returnlist, sklist, select, bangid, parent);
|
|
|
+ WholeBatch(item,sublist, returnlist, sklist, select, bangid, parent, input, plan_date);
|
|
|
break;
|
|
|
case 1://混用
|
|
|
- MixedUse(item,sublist, returnlist, sklist, bangid, parent);
|
|
|
+ MixedUse(item,sublist, returnlist, sklist, bangid, parent, input, plan_date);
|
|
|
break;
|
|
|
case 2://整批加混用
|
|
|
WholeBatchCheck(sublist, returnlist, sklist, select);
|
|
|
if (select.Count() == 0)
|
|
|
{
|
|
|
//走混用
|
|
|
- MixedUse(item,sublist, returnlist, sklist, bangid, parent);
|
|
|
+ MixedUse(item,sublist, returnlist, sklist, bangid, parent, input, plan_date);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//走整批
|
|
|
- WholeBatch(item,sublist, returnlist, sklist, select, bangid, parent);
|
|
|
+ WholeBatch(item,sublist, returnlist, sklist, select, bangid, parent, input, plan_date);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -1515,7 +1538,8 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
//整批占用
|
|
|
- public void WholeBatch(BomChildExamineDto item, List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, List<BomChildExamineDto> select, long bangid, BomChildExamineDto parent) {
|
|
|
+ public void WholeBatch(BomChildExamineDto item, List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, List<BomChildExamineDto> select, long bangid, BomChildExamineDto parent, SeorderentryDto input, DateTime
|
|
|
+ ? plan_date) {
|
|
|
if (select.Count() == 0)
|
|
|
{
|
|
|
//如果为空,则默认使用优先级为0的集合作为替代关系
|
|
|
@@ -1538,6 +1562,7 @@ namespace Business.ResourceExamineManagement
|
|
|
itemStockoccupyDto.icitem_id = slt.item_id;
|
|
|
if (slt.lack_qty > 0)
|
|
|
{
|
|
|
+
|
|
|
itemStockoccupyDto.quantity = slt.sqty;
|
|
|
//库存不够的时候,根据属性生成采购和委外。
|
|
|
if (slt.erp_cls == 1)
|
|
|
@@ -1549,15 +1574,19 @@ namespace Business.ResourceExamineManagement
|
|
|
CalcStrategy(slt, returnlist, bangid, sklist);
|
|
|
}*/
|
|
|
}
|
|
|
- else if (slt.erp_cls == 2)
|
|
|
- {
|
|
|
- //生成委外工单
|
|
|
- slt.Subcontracting_qty = slt.lack_qty;
|
|
|
- }
|
|
|
- else if (slt.erp_cls == 3)
|
|
|
- {
|
|
|
- //生成采购订单
|
|
|
- slt.purchase_qty = slt.lack_qty;
|
|
|
+ else if (slt.erp_cls == 2 || slt.erp_cls == 3)
|
|
|
+ { //生成采购订单
|
|
|
+ //slt.purchase_qty = slt.lack_qty;
|
|
|
+ var leadTimeList = GetLeadTime(new List<BomChildExamineDto> { slt }, input.tenantId, input.factoryId);//提前期列表
|
|
|
+ var supplierList = GetSupplier(new List<BomChildExamineDto> { slt }, input.tenantId, input.factoryId);//供应商列表
|
|
|
+ var planList = GetICPlan(new List<BomChildExamineDto> { slt }, input.tenantId, input.factoryId);//plan列表
|
|
|
+
|
|
|
+ CreateSRMPR(slt, input.tenantId, input.factoryId, bangid, slt.erp_cls, leadTimeList, supplierList, planList, plan_date.Value);
|
|
|
+ if (item.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //生成委外工单
|
|
|
+ CreateMesOOder(item, input.tenantId, input.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -1574,7 +1603,8 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
|
|
|
//混用占用数据
|
|
|
- public void MixedUse(BomChildExamineDto item, List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, long bangid, BomChildExamineDto parent) {
|
|
|
+ public void MixedUse(BomChildExamineDto item, List<BomChildExamineDto> sublist, List<BomChildExamineDto> returnlist, List<ic_item_stockoccupy> sklist, long bangid, BomChildExamineDto parent, SeorderentryDto input, DateTime
|
|
|
+ ? plan_date) {
|
|
|
|
|
|
decimal parent_lack = 0;
|
|
|
if (parent != null)
|
|
|
@@ -1651,15 +1681,17 @@ namespace Business.ResourceExamineManagement
|
|
|
//自制
|
|
|
//GenerateMorder()
|
|
|
}
|
|
|
- else if (sct.erp_cls == 2)
|
|
|
+ else if (sct.erp_cls == 2 || sct.erp_cls == 3)
|
|
|
{
|
|
|
- //委外
|
|
|
- //CreateMesOOder(returnlist,)
|
|
|
- }
|
|
|
- else if (sct.erp_cls == 3)
|
|
|
- {
|
|
|
- //外购
|
|
|
- //CreateSRMPR(returnlist,)
|
|
|
+ var leadTimeList = GetLeadTime(new List<BomChildExamineDto> { sct }, input.tenantId, input.factoryId);//提前期列表
|
|
|
+ var supplierList = GetSupplier(new List<BomChildExamineDto> { sct }, input.tenantId, input.factoryId);//供应商列表
|
|
|
+ var planList = GetICPlan(new List<BomChildExamineDto> { sct }, input.tenantId, input.factoryId);//plan列表
|
|
|
+ CreateSRMPR(sct, input.tenantId, input.factoryId, bangid, sct.erp_cls, leadTimeList, supplierList, planList, plan_date.Value);
|
|
|
+ if (item.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //生成委外工单
|
|
|
+ CreateMesOOder(item, input.tenantId, input.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2166,7 +2198,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
/// <param name="returnlist"></param>
|
|
|
/// <param name="factoryid"></param>
|
|
|
- /// <param name="orderType">1委外采购申请单,2采购申请单</param>
|
|
|
+ /// <param name="orderType">2委外采购申请单,3采购申请单</param>
|
|
|
private DateTime CreateSRMPR(BomChildExamineDto returnlist, long tenantId, long factoryid, long bangId, int orderType, List<ICItemLeadTimeDto> iCItemLeadTimes, List<ic_item_pur> supplierList, List<ic_plan> planList, DateTime deliveryDate)
|
|
|
{
|
|
|
var leadTime = iCItemLeadTimes.Find(x => x.item_id == returnlist.item_id);
|