|
|
@@ -112,6 +112,8 @@ namespace Business.ResourceExamineManagement
|
|
|
public decimal ProductionTimeDay;
|
|
|
//是否虚拟计算
|
|
|
public bool LongPeriod = false;
|
|
|
+ //是否虚拟计算
|
|
|
+ public bool ScheduleAgreement = false;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 构造函数
|
|
|
@@ -279,7 +281,7 @@ namespace Business.ResourceExamineManagement
|
|
|
else
|
|
|
{
|
|
|
//占用不够,占用后减少缺料数量
|
|
|
- level1Dto.lack_qty -= moo_qty;
|
|
|
+ //level1Dto.lack_qty -= moo_qty;
|
|
|
//level1Dto.needCount = level1Dto.lack_qty;
|
|
|
//平铺需要数量
|
|
|
CaclMaterialShortage(returnlist);
|
|
|
@@ -288,25 +290,19 @@ namespace Business.ResourceExamineManagement
|
|
|
level1Dto.stock_state = 0;
|
|
|
if (param.checkflag || (!param.checkflag && param.checkPlan))
|
|
|
{
|
|
|
- ProdExamineParamDto prodExamine = new ProdExamineParamDto()
|
|
|
- {
|
|
|
- ItemNum = level1Dto.item_number,
|
|
|
- PlanStart = plan_date.GetValueOrDefault(),
|
|
|
- QtyOrd = level1Dto.lack_qty,
|
|
|
- Domain = param.factoryId.ToString()
|
|
|
- };
|
|
|
- int make_time = _productExamineAppService.ProductTime(prodExamine);
|
|
|
- /*if (make_time < level1Dto.PurLT)
|
|
|
- {
|
|
|
- //如果生产时长小于供应提前期,则按供应提前期算
|
|
|
- make_time = level1Dto.PurLT;
|
|
|
- }*/
|
|
|
//根据成品属性来判断是自制还是委外还是外购,需要考虑这种场景
|
|
|
if (level1Dto.erp_cls == 1 && param.checkflag)
|
|
|
{
|
|
|
+ level1Dto.make_qty = level1Dto.lack_qty - level1Dto.mo_qty;
|
|
|
+ ProdExamineParamDto prodExamine = new ProdExamineParamDto()
|
|
|
+ {
|
|
|
+ ItemNum = level1Dto.item_number,
|
|
|
+ PlanStart = plan_date.GetValueOrDefault(),
|
|
|
+ QtyOrd = level1Dto.make_qty,
|
|
|
+ Domain = param.factoryId.ToString()
|
|
|
+ };
|
|
|
+ int make_time = _productExamineAppService.ProductTime(prodExamine);
|
|
|
//设置成品的生产时长为子物料的提前准备期
|
|
|
- //param.checkflag=true 销售订单产生工单
|
|
|
- level1Dto.make_qty = level1Dto.lack_qty;
|
|
|
string order_mo = "";
|
|
|
if (GenerateMoList.Any())
|
|
|
{
|
|
|
@@ -322,7 +318,7 @@ namespace Business.ResourceExamineManagement
|
|
|
BomNumber = level1Dto.bom_number,
|
|
|
version = level1Dto.version,
|
|
|
number = level1Dto.item_number,
|
|
|
- Quantity = level1Dto.lack_qty,
|
|
|
+ Quantity = level1Dto.make_qty,
|
|
|
morder_type = morder_type,
|
|
|
work_order_type = MorderEnum.CgMorder,
|
|
|
morder_state = MorderEnum.Initial_state,
|
|
|
@@ -334,7 +330,7 @@ namespace Business.ResourceExamineManagement
|
|
|
else if (level1Dto.erp_cls == 3)
|
|
|
{
|
|
|
//先找在途
|
|
|
- decimal occqty = CalcInTransit(sentrys, level1Dto, bangid, plan_date.GetValueOrDefault());
|
|
|
+ decimal occqty = CalcInTransit(sentrys, level1Dto, bangid, plan_date.GetValueOrDefault(), level1Dto.lack_qty, null);
|
|
|
if (level1Dto.lack_qty - occqty > 0)
|
|
|
{
|
|
|
decimal itemPRQty = srm_Pr_Mains.Where(x => x.icitem_id.Value == level1Dto.item_id && x.pr_sarrive_date <= plan_date).Sum(y => y.pr_aqty.GetValueOrDefault());
|
|
|
@@ -343,21 +339,21 @@ namespace Business.ResourceExamineManagement
|
|
|
//level1Dto.lack_qty = level1Dto.lack_qty - itemPRQty;
|
|
|
decimal lack_qty = level1Dto.lack_qty - itemPRQty;
|
|
|
//采购申请
|
|
|
- PackageSRMPR(level1Dto, bangid, sentrys, plan_date, lack_qty);
|
|
|
+ PackageSRMPR(level1Dto, bangid, sentrys, plan_date, lack_qty, null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (level1Dto.erp_cls == 2)
|
|
|
{
|
|
|
//先找在途
|
|
|
- decimal occqty = CalcInTransit(sentrys, level1Dto, bangid, plan_date.GetValueOrDefault());
|
|
|
+ decimal occqty = CalcInTransit(sentrys, level1Dto, bangid, plan_date.GetValueOrDefault(), level1Dto.lack_qty, null);
|
|
|
decimal lack_qty = level1Dto.lack_qty - occqty;
|
|
|
if (lack_qty > 0)
|
|
|
{
|
|
|
//1.先生成委外工单。
|
|
|
var mesorder = CreateMesOOder(level1Dto, lack_qty, param.company_id, param.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
mesorder.ooentry_etime = plan_date.GetValueOrDefault().AddDays(-1);
|
|
|
- var srmprDto = PackageSRMPR(level1Dto, bangid, sentrys, plan_date, lack_qty);
|
|
|
+ var srmprDto = PackageSRMPR(level1Dto, bangid, sentrys, plan_date, lack_qty, null);
|
|
|
mesorder.ooentry_stime = plan_date.GetValueOrDefault().AddDays(-srmprDto.totalLeadTime.GetValueOrDefault());
|
|
|
|
|
|
//先计算末级数据的齐套时间。
|
|
|
@@ -619,7 +615,7 @@ namespace Business.ResourceExamineManagement
|
|
|
else
|
|
|
{
|
|
|
//判断缺料数量
|
|
|
- item.self_lack_qty = Math.Ceiling(parent.lack_qty * item.qty * (1 + (item.scrap.GetValueOrDefault() / 100)) + item.wastage.GetValueOrDefault());
|
|
|
+ item.self_lack_qty = Math.Ceiling((parent.lack_qty - parent.mo_qty - parent.purchase_occupy_qty) * item.qty * (1 + (item.scrap.GetValueOrDefault() / 100)) + item.wastage.GetValueOrDefault());
|
|
|
item.lack_qty = item.self_lack_qty - item.sqty;
|
|
|
item.lack_qty = item.lack_qty < 0 ? 0 : item.lack_qty;
|
|
|
//判断状态
|
|
|
@@ -756,17 +752,18 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
else if (!LongPeriod)
|
|
|
{
|
|
|
- item.lack_qty -= moo_qty;
|
|
|
+ //item.lack_qty -= moo_qty;
|
|
|
item.stock_state = 0;
|
|
|
item.kitting_time = plan_date.GetValueOrDefault();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- item.lack_qty -= moo_qty;
|
|
|
+ //item.lack_qty -= moo_qty;
|
|
|
List<string> tsWork = new List<string> { "试制工单", "TCN工单", "返工工单" };
|
|
|
//如果是特殊工单,只判断自制件的库存和在制,而不生成自制
|
|
|
if (!tsWork.Contains(mes_morder.morder_type))
|
|
|
{
|
|
|
+ item.make_qty = item.lack_qty - item.mo_qty;
|
|
|
string order_mo = "";
|
|
|
if (GenerateMoList.Any())
|
|
|
{
|
|
|
@@ -781,7 +778,7 @@ namespace Business.ResourceExamineManagement
|
|
|
BomNumber = item.bom_number,
|
|
|
version = item.version,
|
|
|
number = item.item_number,
|
|
|
- Quantity = item.lack_qty,
|
|
|
+ Quantity = item.make_qty,
|
|
|
morder_type = morder_type,
|
|
|
work_order_type = MorderEnum.CgMorder,
|
|
|
morder_state = MorderEnum.Initial_state,
|
|
|
@@ -795,7 +792,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
ItemNum = item.item_number,
|
|
|
PlanStart = plan_date.GetValueOrDefault(),
|
|
|
- QtyOrd = item.lack_qty,
|
|
|
+ QtyOrd = item.make_qty,
|
|
|
Domain = param.factoryId.ToString()
|
|
|
};
|
|
|
int make = _productExamineAppService.ProductTime(prodExamine);
|
|
|
@@ -804,14 +801,14 @@ namespace Business.ResourceExamineManagement
|
|
|
//如果生产时长小于供应提前期,则按供应提前期算
|
|
|
make = item.PurLT;
|
|
|
}*/
|
|
|
- item.make_qty = item.lack_qty;
|
|
|
+
|
|
|
if (mes_MorderDto != null)
|
|
|
{
|
|
|
//主工单最后计算满足日期
|
|
|
var mes_Morders = mes_MorderDto.mes_Morders.FirstOrDefault();
|
|
|
if (mes_Morders != null)
|
|
|
{
|
|
|
- var generateMooccupy = _morderAppService.GetMooccupies(sentrys, ic_item, mes_Morders, item.lack_qty, bangid);
|
|
|
+ var generateMooccupy = _morderAppService.GetMooccupies(sentrys, ic_item, mes_Morders, item.make_qty, bangid);
|
|
|
mooccupyAllList.Add(generateMooccupy);
|
|
|
mooccupyAllInsertList.Add(generateMooccupy);
|
|
|
|
|
|
@@ -864,24 +861,69 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
- else if (item.erp_cls == 3)
|
|
|
+ else if (item.erp_cls == 3 || item.erp_cls == 2)
|
|
|
{
|
|
|
if (param.checkflag || param.checkPlan)
|
|
|
{
|
|
|
- //先找在途
|
|
|
- decimal occqty = CalcInTransit(sentrys, item, bangid, plan_date.GetValueOrDefault());
|
|
|
- decimal lack_qty = item.lack_qty - occqty;
|
|
|
- if (lack_qty > 0)
|
|
|
+ var supplist = supplierList.Where(s => s.icitem_id == item.item_id && s.quota_rate.GetValueOrDefault() > 0).ToList();
|
|
|
+ if (!supplist.Any())
|
|
|
{
|
|
|
- //采购申请
|
|
|
- PackageSRMPR(item, bangid, sentrys, plan_date, lack_qty);
|
|
|
+ item.stock_state = 99;
|
|
|
+ item.kitting_time = plan_date.GetValueOrDefault().AddDays(-1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var maxLeadTime = supplist.Max(x => x.lead_time.GetValueOrDefault());
|
|
|
+
|
|
|
+ var wwPlan_data = plan_date.GetValueOrDefault().AddDays(-(int)maxLeadTime);
|
|
|
+ decimal wwCount = 0;
|
|
|
+ foreach (var sup in supplist)
|
|
|
+ {
|
|
|
+ decimal suplack_qty = Math.Ceiling(item.lack_qty * sup.quota_rate.GetValueOrDefault() / 100);
|
|
|
+ //先找在途
|
|
|
+ decimal occqty = CalcInTransit(sentrys, item, bangid, plan_date.GetValueOrDefault(), suplack_qty, sup.supplier_id.GetValueOrDefault());
|
|
|
+ decimal lack_qty = suplack_qty - occqty;
|
|
|
+ if (lack_qty > 0)
|
|
|
+ {
|
|
|
+ wwCount += lack_qty;//记录缺料数量
|
|
|
+ if (item.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //采购申请
|
|
|
+ PackageSRMPR(item, bangid, sentrys, plan_date, lack_qty, sup.supplier_id.GetValueOrDefault());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //1.先生成委外工单。
|
|
|
+ var mesorder = CreateMesOOder(item, lack_qty, param.company_id, param.factoryId, bangid, leadTimeList, supplierList, plan_date.GetValueOrDefault());
|
|
|
+ mesorder.ooentry_etime = plan_date.GetValueOrDefault().AddDays(-1);
|
|
|
+ var srmprDto = PackageSRMPR(item, bangid, sentrys, plan_date, lack_qty, sup.supplier_id.GetValueOrDefault());
|
|
|
+ mesorder.ooentry_stime = mesorder.ooentry_etime.GetValueOrDefault().AddDays(-(srmprDto.totalLeadTime.GetValueOrDefault() - 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.erp_cls == 2 && wwCount > 0)
|
|
|
+ {
|
|
|
+ //先计算末级数据的齐套时间。
|
|
|
+ if (cilList.Count > 0)
|
|
|
+ {
|
|
|
+ CalcIcitem(cilList, returnlist, bangid, sklist, wwPlan_data, icitemlist, sentrys, childidList);
|
|
|
+ var itemTime = cilList.Max(s => s.kitting_time).GetValueOrDefault().AddDays((int)maxLeadTime);//加上物料的采购提前期
|
|
|
+ if (LongPeriod)
|
|
|
+ {
|
|
|
+ item.kitting_time = itemTime;
|
|
|
+ }
|
|
|
+ else if (itemTime > item.kitting_time)
|
|
|
+ {
|
|
|
+ item.kitting_time = itemTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.subcontracting_qty = wwCount;
|
|
|
+ item.subcontracting_list = new List<ooder>();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (item.erp_cls == 2)
|
|
|
+ /*else if (item.erp_cls == 2)
|
|
|
{
|
|
|
|
|
|
if (param.checkflag || param.checkPlan)
|
|
|
@@ -932,7 +974,7 @@ namespace Business.ResourceExamineManagement
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
else
|
|
|
{
|
|
|
item.kitting_time = DateTime.Now;
|
|
|
@@ -1072,7 +1114,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//占用库存
|
|
|
foreach (var slt in select)
|
|
|
{
|
|
|
- slt.self_lack_qty = parent.lack_qty * slt.qty;
|
|
|
+ slt.self_lack_qty = (parent.lack_qty- parent.mo_qty - parent.purchase_occupy_qty) * slt.qty;
|
|
|
mo_ic_item_stockoccupy itemStockoccupyDto = new mo_ic_item_stockoccupy();
|
|
|
itemStockoccupyDto.bang_id = bangid;
|
|
|
itemStockoccupyDto.icitem_id = slt.item_id;
|
|
|
@@ -1112,7 +1154,7 @@ namespace Business.ResourceExamineManagement
|
|
|
decimal parent_lack = 0;
|
|
|
if (parent != null)
|
|
|
{
|
|
|
- parent_lack = parent.lack_qty;
|
|
|
+ parent_lack = parent.lack_qty - parent.mo_qty - parent.purchase_occupy_qty;
|
|
|
}
|
|
|
|
|
|
List<int> orderNum = sublist.Select(s => s.substitute_all_num.GetValueOrDefault()).ToList();
|
|
|
@@ -1327,18 +1369,19 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
else if (!LongPeriod)
|
|
|
{
|
|
|
- sct.lack_qty -= moo_qty;
|
|
|
+ //sct.lack_qty -= moo_qty;
|
|
|
sct.stock_state = 0;
|
|
|
sct.kitting_time = dateTime;
|
|
|
}
|
|
|
else {
|
|
|
- sct.lack_qty -= moo_qty;
|
|
|
+ //sct.lack_qty -= moo_qty;
|
|
|
List<string> tsWork = new List<string> { "试制工单", "TCN工单", "返工工单" };
|
|
|
//如果是特殊工单,只判断自制件的库存和在制,而不生成自制
|
|
|
if (!tsWork.Contains(mes_morder.morder_type))
|
|
|
{
|
|
|
//TODO:需要按标准UPH来计算生产时长
|
|
|
//生成主工单
|
|
|
+ sct.make_qty = sct.lack_qty - sct.mo_qty;
|
|
|
string order_mo = "";
|
|
|
if (GenerateMoList.Any())
|
|
|
{
|
|
|
@@ -1353,7 +1396,7 @@ namespace Business.ResourceExamineManagement
|
|
|
BomNumber = sct.bom_number,
|
|
|
version = sct.version,
|
|
|
number = sct.item_number,
|
|
|
- Quantity = sct.lack_qty,
|
|
|
+ Quantity = sct.make_qty,
|
|
|
morder_type = morder_type,
|
|
|
work_order_type = MorderEnum.CgMorder,
|
|
|
morder_state = MorderEnum.Initial_state,
|
|
|
@@ -1366,23 +1409,18 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
ItemNum = sct.item_number,
|
|
|
PlanStart = dateTime,
|
|
|
- QtyOrd = sct.lack_qty,
|
|
|
+ QtyOrd = sct.make_qty,
|
|
|
Domain = param.factoryId.ToString()
|
|
|
};
|
|
|
int make = _productExamineAppService.ProductTime(prodExamine);
|
|
|
- /*if (make < sct.PurLT)
|
|
|
- {
|
|
|
- //如果生产时长小于供应提前期,则按供应提前期算
|
|
|
- make = sct.PurLT;
|
|
|
- }*/
|
|
|
- sct.make_qty = sct.lack_qty;
|
|
|
+
|
|
|
if (mes_MorderDto != null)
|
|
|
{
|
|
|
//主工单最后计算满足日期
|
|
|
var mes_Morders = mes_MorderDto.mes_Morders.FirstOrDefault();
|
|
|
if (mes_Morders != null)
|
|
|
{
|
|
|
- var generateMooccupy = _morderAppService.GetMooccupies(sentrys, ic_item, mes_Morders, sct.lack_qty, bangid);
|
|
|
+ var generateMooccupy = _morderAppService.GetMooccupies(sentrys, ic_item, mes_Morders, sct.make_qty, bangid);
|
|
|
mooccupyAllList.Add(generateMooccupy);
|
|
|
mooccupyAllInsertList.Add(generateMooccupy);
|
|
|
|
|
|
@@ -1442,17 +1480,62 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
if (param.checkflag || param.checkPlan)
|
|
|
{
|
|
|
- //先找在途
|
|
|
- decimal occqty = CalcInTransit(sentrys, sct, bangid, plan_date.GetValueOrDefault());
|
|
|
- decimal lack_qty = sct.lack_qty - occqty;
|
|
|
- if (lack_qty > 0)
|
|
|
+ var supplist = supplierList.Where(s => s.icitem_id == sct.item_id && s.quota_rate.GetValueOrDefault() > 0).ToList();
|
|
|
+ if (!supplist.Any())
|
|
|
{
|
|
|
- //采购申请
|
|
|
- PackageSRMPR(sct, bangid, sentrys, plan_date, lack_qty);
|
|
|
+ sct.stock_state = 99;
|
|
|
+ sct.kitting_time = plan_date.GetValueOrDefault().AddDays(-1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var maxLeadTime = supplist.Max(x => x.lead_time.GetValueOrDefault());
|
|
|
+ var wwPlan_data = plan_date.GetValueOrDefault().AddDays(-(int)maxLeadTime);
|
|
|
+ decimal wwCount = 0;
|
|
|
+
|
|
|
+ foreach (var sup in supplist)
|
|
|
+ {
|
|
|
+ decimal suplack_qty = Math.Ceiling(sct.lack_qty * sup.quota_rate.GetValueOrDefault() / 100);
|
|
|
+ //先找在途
|
|
|
+ decimal occqty = CalcInTransit(sentrys, sct, bangid, plan_date.GetValueOrDefault(), suplack_qty, sup.supplier_id.GetValueOrDefault());
|
|
|
+ decimal lack_qty = suplack_qty - occqty;
|
|
|
+ if (lack_qty > 0)
|
|
|
+ {
|
|
|
+ wwCount += lack_qty;//记录缺料数量
|
|
|
+ if (sct.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //采购申请
|
|
|
+ PackageSRMPR(sct, bangid, sentrys, plan_date, lack_qty, sup.supplier_id.GetValueOrDefault());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //1.先生成委外工单。
|
|
|
+ var mesorder = CreateMesOOder(sct, lack_qty, param.company_id, param.factoryId, bangid, leadTimeList, supplierList, plan_date.GetValueOrDefault());
|
|
|
+ mesorder.ooentry_etime = plan_date.GetValueOrDefault().AddDays(-1);
|
|
|
+ var srmprDto = PackageSRMPR(sct, bangid, sentrys, plan_date, lack_qty, sup.supplier_id);
|
|
|
+ mesorder.ooentry_stime = mesorder.ooentry_etime.GetValueOrDefault().AddDays(-(srmprDto.totalLeadTime.GetValueOrDefault() - 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sct.erp_cls == 2 && wwCount > 0)
|
|
|
+ {
|
|
|
+ //先计算末级数据的齐套时间。
|
|
|
+ if (cilList.Count > 0)
|
|
|
+ {
|
|
|
+ CalcIcitem(cilList, returnlist, bangid, sklist, wwPlan_data, icitemlist, sentrys, childidList);
|
|
|
+ var itemTime = cilList.Max(s => s.kitting_time).GetValueOrDefault().AddDays((int)maxLeadTime);//加上物料的采购提前期
|
|
|
+ if (LongPeriod)
|
|
|
+ {
|
|
|
+ sct.kitting_time = itemTime;
|
|
|
+ }
|
|
|
+ else if (itemTime > sct.kitting_time)
|
|
|
+ {
|
|
|
+ sct.kitting_time = itemTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sct.subcontracting_qty = wwCount;
|
|
|
+ sct.subcontracting_list = new List<ooder>();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (sct.erp_cls == 2)
|
|
|
+ /*else if (sct.erp_cls == 2)
|
|
|
{
|
|
|
if (param.checkflag || param.checkPlan)
|
|
|
{
|
|
|
@@ -1503,7 +1586,7 @@ namespace Business.ResourceExamineManagement
|
|
|
orderList.Add(mesorder);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
else
|
|
|
{
|
|
|
if (cilList.Count > 0)
|
|
|
@@ -1540,7 +1623,7 @@ namespace Business.ResourceExamineManagement
|
|
|
decimal stockQty = sklist.Where(s => s.icitem_id == item.item_id && s.bang_id == bangid).Sum(p => p.quantity);
|
|
|
item.sqty -= stockQty;
|
|
|
item.sqty = item.sqty < 0 ? 0 : item.sqty;
|
|
|
- item.lack_qty = parent.lack_qty * item.qty - item.sqty;
|
|
|
+ item.lack_qty = (parent.lack_qty - parent.mo_qty- parent.purchase_occupy_qty) * item.qty - item.sqty;
|
|
|
item.lack_qty = item.lack_qty > 0 ? item.lack_qty : 0;
|
|
|
item.self_lack_qty = item.lack_qty;
|
|
|
item.stock_state = item.lack_qty > 0 ? 0 : 1;
|
|
|
@@ -1553,12 +1636,16 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="returnlist"></param>
|
|
|
/// <param name="factoryid"></param>
|
|
|
/// <param name="orderType">2委外采购申请单,3采购申请单</param>
|
|
|
- private SRMPRDto CreateSRMPR(BomChildExamineDto returnlist, decimal lack_qty, long? companyId, long factoryid, long bangId, int orderType, List<ICItemLeadTimeDto> iCItemLeadTimes, List<mo_srm_purchase> supplierList, List<mo_ic_item> planList, crm_seorderentry sentrys, DateTime? plan_date)
|
|
|
+ private SRMPRDto CreateSRMPR(BomChildExamineDto returnlist, decimal lack_qty, long? companyId, long factoryid, long bangId, int orderType, List<ICItemLeadTimeDto> iCItemLeadTimes, List<mo_srm_purchase> supplierList, List<mo_ic_item> planList, crm_seorderentry sentrys, DateTime? plan_date, long? supplier_id)
|
|
|
{
|
|
|
SRMPRDto sRMPR = new SRMPRDto();
|
|
|
//mo_srm_purchase supplier = null;
|
|
|
var plan = planList.Find(x => x.mysql_id == returnlist.item_id);
|
|
|
var supplist = supplierList.Where(s => s.icitem_id == returnlist.item_id && s.quota_rate.GetValueOrDefault() > 0).ToList();
|
|
|
+ if (supplier_id != null)
|
|
|
+ {
|
|
|
+ supplist = supplist.Where(s => s.supplier_id == supplier_id).ToList();
|
|
|
+ }
|
|
|
if (!supplist.Any() || plan == null)
|
|
|
{
|
|
|
returnlist.stock_state = 99;
|
|
|
@@ -1591,18 +1678,26 @@ namespace Business.ResourceExamineManagement
|
|
|
srm_Pr.pr_purchaser = supplier.order_rector_name;//采购员
|
|
|
srm_Pr.pr_purchaser_num = supplier.order_rector_num;//采购员工号(采购信息表)
|
|
|
|
|
|
-
|
|
|
- srm_Pr.pr_rqty = Math.Ceiling(lack_qty * supplier.quota_rate.GetValueOrDefault() / 100);//需求数量
|
|
|
-
|
|
|
+ if (supplier_id != null)
|
|
|
+ {
|
|
|
+ srm_Pr.pr_rqty = Math.Ceiling(lack_qty);//需求数量
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ srm_Pr.pr_rqty = Math.Ceiling(lack_qty * supplier.quota_rate.GetValueOrDefault() / 100);//需求数量
|
|
|
+ }
|
|
|
srm_Pr.pr_aqty = srm_Pr.pr_rqty;//申请数量
|
|
|
srm_Pr.pr_sqty = srm_Pr.pr_rqty;//建议数量
|
|
|
srm_Pr.icitem_id = returnlist.item_id;//物料id
|
|
|
srm_Pr.icitem_name = returnlist.item_name;//物料名称
|
|
|
srm_Pr.num = returnlist.num;
|
|
|
+ if (ScheduleAgreement)
|
|
|
+ {
|
|
|
+ supplier.lead_time = 7;//启用计划协议时,默认为7天。
|
|
|
+ }
|
|
|
if (plan_date != null)
|
|
|
{
|
|
|
//-1为提前一天准备
|
|
|
- srm_Pr.pr_sarrive_date = plan_date.GetValueOrDefault().AddDays(-1 - (int)(Math.Ceiling(plan.clean_leadtime.GetValueOrDefault())));
|
|
|
+ srm_Pr.pr_sarrive_date = plan_date.GetValueOrDefault().AddDays(-1 - (int)(Math.Ceiling(plan.clean_leadtime.GetValueOrDefault() + plan.self_inspection_date.GetValueOrDefault())));
|
|
|
/*if (LongPeriod)
|
|
|
{
|
|
|
//提前一个月
|
|
|
@@ -1978,9 +2073,9 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <summary>
|
|
|
/// 计算在途
|
|
|
/// </summary>
|
|
|
- public decimal CalcInTransit(crm_seorderentry sentrys, BomChildExamineDto item, long bangid, DateTime plan_date)
|
|
|
+ public decimal CalcInTransit(crm_seorderentry sentrys, BomChildExamineDto item, long bangid, DateTime plan_date,decimal suplack_qty,long? supplier_id)
|
|
|
{
|
|
|
- if (!LongPeriod)
|
|
|
+ if (LongPeriod)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -1988,16 +2083,25 @@ namespace Business.ResourceExamineManagement
|
|
|
_purchaseOrderAppService.srm_Po_Occupies = srm_Po_Occupies; //采购明细
|
|
|
_purchaseOrderAppService.srm_Pr_Mains = srm_Pr_Mains;//在途PR
|
|
|
_purchaseOrderAppService.mes_morder = mes_morder;//当前工单传递进去。
|
|
|
-
|
|
|
- var occupylist = _purchaseOrderAppService.CheckPurchaseOrder(sentrys, item.item_id, item.lack_qty, plan_date, ic_item_List, bangid);
|
|
|
+ DateTime endTime = plan_date;
|
|
|
+ if (ScheduleAgreement)
|
|
|
+ {
|
|
|
+ //启用计划协议时,默认修改时间为最大
|
|
|
+ endTime = plan_date.AddYears(100);
|
|
|
+ }
|
|
|
+ var occupylist = _purchaseOrderAppService.CheckPurchaseOrder(sentrys, item.item_id, suplack_qty, endTime, ic_item_List, supplier_id, bangid);
|
|
|
decimal occqty = 0;
|
|
|
if (occupylist.Any())
|
|
|
{
|
|
|
occqty = occupylist.Sum(s => s.qty.GetValueOrDefault());
|
|
|
- item.purchase_occupy_qty = occqty;
|
|
|
+ item.purchase_occupy_qty += occqty;
|
|
|
//item.lack_qty -= occqty;
|
|
|
- item.purchase_occupy_list = new List<purchase_occupy>();
|
|
|
- item.kitting_time = occupylist[0].etime;
|
|
|
+ //item.kitting_time = occupylist[0].etime;
|
|
|
+ if (occupylist[0].etime > item.kitting_time)
|
|
|
+ {
|
|
|
+ item.kitting_time = occupylist[0].etime;
|
|
|
+ }
|
|
|
+ /*item.purchase_occupy_list = new List<purchase_occupy>();
|
|
|
occupylist.ForEach(s => {
|
|
|
if (mes_morder != null)
|
|
|
{
|
|
|
@@ -2016,17 +2120,17 @@ namespace Business.ResourceExamineManagement
|
|
|
ocp.po_billno = polist.po_billno;
|
|
|
}
|
|
|
item.purchase_occupy_list.Add(ocp);
|
|
|
- });
|
|
|
+ });*/
|
|
|
srm_Po_Occupies.AddRange(occupylist);
|
|
|
srm_Po_OccupiesInsert.AddRange(occupylist);
|
|
|
}
|
|
|
return occqty;
|
|
|
}
|
|
|
|
|
|
- public SRMPRDto PackageSRMPR(BomChildExamineDto item,long bangid, crm_seorderentry sentrys, DateTime? plan_date, decimal lack_qty)
|
|
|
+ public SRMPRDto PackageSRMPR(BomChildExamineDto item,long bangid, crm_seorderentry sentrys, DateTime? plan_date, decimal lack_qty, long? supplier_id)
|
|
|
{
|
|
|
//采购申请
|
|
|
- var SRMPRDto = CreateSRMPR(item, lack_qty, param.company_id, param.factoryId, bangid, item.erp_cls, leadTimeList, supplierList, ic_item_List, sentrys, plan_date);
|
|
|
+ var SRMPRDto = CreateSRMPR(item, lack_qty, param.company_id, param.factoryId, bangid, item.erp_cls, leadTimeList, supplierList, ic_item_List, sentrys, plan_date, supplier_id);
|
|
|
item.purchase_list = new List<purchase>();
|
|
|
if (SRMPRDto.srm_Pr_Main != null)
|
|
|
{
|
|
|
@@ -2053,7 +2157,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
if (item.erp_cls == 3)
|
|
|
{
|
|
|
- item.purchase_qty = lack_qty;
|
|
|
+ item.purchase_qty += lack_qty;
|
|
|
item.purchase_list = new List<purchase>();
|
|
|
}
|
|
|
if (LongPeriod)//虚拟计算不调整齐套时间
|