|
|
@@ -702,7 +702,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="number">物料编码</param>
|
|
|
/// <param name="Quantity"></param>
|
|
|
/// <param name="ParentId"></param>
|
|
|
- public void GenerateMorder(crm_seorderentry seorderentry, string BomNumber, string number, decimal? Quantity, long? ParentId)
|
|
|
+ public void GenerateMorder(crm_seorderentry seorderentry, string BomNumber, string number, decimal? Quantity, long? ParentId = null)
|
|
|
{
|
|
|
//1.库存、在制工单检查完成后 当前BOM需要自制时 产生工单。
|
|
|
|
|
|
@@ -953,6 +953,7 @@ namespace Business.ResourceExamineManagement
|
|
|
var dto = new BomChildExamineDto();
|
|
|
dto.item_id = bom.icitem_id;
|
|
|
dto.bom_id = BomId.Value;
|
|
|
+ dto.bom_number = bom.bom_number;
|
|
|
dto.level = 1;
|
|
|
dto.id = help.NextId();
|
|
|
dto.parent_id = help.NextId();
|
|
|
@@ -1002,6 +1003,7 @@ namespace Business.ResourceExamineManagement
|
|
|
dto.erp_cls = item.erp_cls;
|
|
|
dto.erp_cls_name = item.erp_cls_name;
|
|
|
dto.type = type;
|
|
|
+ dto.item_number = item.number;
|
|
|
|
|
|
//var bdto = ObjectMapper.Map<ic_bom,BomChildExamineDto>(bom);
|
|
|
returnlist.Add(dto);
|
|
|
@@ -1032,6 +1034,7 @@ namespace Business.ResourceExamineManagement
|
|
|
cdto.type = type;
|
|
|
cdto.item_id = childBom.icitem_id;
|
|
|
cdto.bom_id = childBom.Id;
|
|
|
+ cdto.bom_number = childBom.bom_number;
|
|
|
//递归寻找子级
|
|
|
GetBomList(bomlist, bomchildlist, icitemlist, cdto, returnlist, type);
|
|
|
}
|
|
|
@@ -1061,6 +1064,7 @@ namespace Business.ResourceExamineManagement
|
|
|
childDto.substitute_code = c.substitute_code;
|
|
|
childDto.icitem_ids = c.icitem_ids;
|
|
|
childDto.type = type;
|
|
|
+ childDto.item_number = icitem.number;
|
|
|
returnlist.Add(childDto);
|
|
|
}
|
|
|
}
|
|
|
@@ -1265,12 +1269,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//先处理下最顶级的产品需要数量
|
|
|
returnlist[0].needCount = returnlist[0].qty * count;
|
|
|
returnlist[0].lack_qty = returnlist[0].needCount - returnlist[0].sqty;
|
|
|
- if (returnlist[0].lack_qty > 0)
|
|
|
- {
|
|
|
- var seorderentry = _mysql_crm_seorderentry.FindAsync(x => x.Id == orderid).Result;
|
|
|
- //生成自制工单
|
|
|
- GenerateMorder(seorderentry, returnlist[0].lack_qty);
|
|
|
- }
|
|
|
+
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
if (item.level == 1)
|
|
|
@@ -1285,9 +1284,14 @@ namespace Business.ResourceExamineManagement
|
|
|
calcTest2(returnlist[0], childList, returnlist, sklist);
|
|
|
//returnlist[0].kz = childList.Min(s => s.kz);//得到最小可制数量。
|
|
|
//再加个循环,来根据替代关系里的检查结果,根据规则明确使用和生成占用关系。
|
|
|
-
|
|
|
CalcIcitem(childList, returnlist, bangid, orderid, input, sklist, plan_date);
|
|
|
|
|
|
+ if (returnlist[0].lack_qty > 0)
|
|
|
+ {
|
|
|
+ var seorderentry = _mysql_crm_seorderentry.FindAsync(x => x.Id == orderid).Result;
|
|
|
+ //生成自制工单
|
|
|
+ GenerateMorder(seorderentry, returnlist[0].bom_number, returnlist[0].item_number, returnlist[0].lack_qty);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1300,7 +1304,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="input"></param>
|
|
|
/// <param name="sklist"></param>
|
|
|
/// <param name="plan_date"></param>
|
|
|
- public void CalcIcitem(List<BomChildExamineDto> childList, List<BomChildExamineDto> returnlist, long bangid, long orderid, SeorderentryDto input, List<ic_item_stockoccupy> sklist, DateTime
|
|
|
+ public void CalcIcitem(List<BomChildExamineDto> childList, List<BomChildExamineDto> returnlist, long bangid, long orderid, SeorderentryDto input, List<ic_item_stockoccupy> sklist, DateTime
|
|
|
? plan_date)
|
|
|
{
|
|
|
foreach (var item in childList)
|
|
|
@@ -1315,38 +1319,65 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ var parent = returnlist.Find(s => s.id == item.parent_id);
|
|
|
+ Calczykc(item, parent, sklist);
|
|
|
+
|
|
|
//直接占用库存,缺料就生成采购
|
|
|
ic_item_stockoccupy itemStockoccupyDto = new ic_item_stockoccupy();
|
|
|
itemStockoccupyDto.bang_id = bangid;
|
|
|
itemStockoccupyDto.icitem_id = item.item_id;
|
|
|
- //修改:根据是否缺料判断使用库存,还是使用需要数量needcount
|
|
|
- itemStockoccupyDto.quantity = item.sqty;
|
|
|
- sklist.Add(itemStockoccupyDto);
|
|
|
- item.is_use = true;
|
|
|
- CalcIcitem(cilList, returnlist, bangid, orderid, input, sklist, plan_date);
|
|
|
-
|
|
|
- if (item.erp_cls == 1)
|
|
|
+ item.kitting_time = DateTime.Now;
|
|
|
+ if (cilList.Count() > 0)
|
|
|
{
|
|
|
- //走自制
|
|
|
- //走子物料
|
|
|
- //foreach()
|
|
|
+ CalcIcitem(cilList, returnlist, bangid, orderid, input, sklist, plan_date);
|
|
|
+ item.kitting_time = cilList.Max(s => s.kitting_time);
|
|
|
}
|
|
|
- else if (item.erp_cls == 2 || item.erp_cls == 3)
|
|
|
+
|
|
|
+ if (item.lack_qty > 0)
|
|
|
{
|
|
|
- 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);
|
|
|
- if (item.erp_cls == 3)
|
|
|
+ //如果缺料,占用库存,然后走采购或自制
|
|
|
+ itemStockoccupyDto.quantity = item.sqty;
|
|
|
+ item.use_qty = item.sqty;
|
|
|
+ sklist.Add(itemStockoccupyDto);
|
|
|
+ if (item.erp_cls == 1)
|
|
|
{
|
|
|
- //生成委外工单
|
|
|
- CreateMesOOder(item, input.tenantId, input.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
- //1.先生成委外工单。
|
|
|
- //2.再根据委外工单需要检查库存材料,然后提供给第三方组装。
|
|
|
- //3.如果委外工单的物料库存不够,先生成物料采购申请单,再生成物料的采购订单,到货后再走委外流程。
|
|
|
- //4.再生成委外的采购申请单。
|
|
|
+ //走自制
|
|
|
+ var minute = ProductiveExamine(item.bom_number, item.lack_qty.GetInt());
|
|
|
+ //var ProductiveDate = ProductiveExamine(BomNumber, (int)(Quantity.Value));
|
|
|
+ //系统建议完工日期为 开工日期+产能检查时间=完工日期
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ if (item.erp_cls == 3)
|
|
|
+ {
|
|
|
+ //生成委外工单
|
|
|
+ CreateMesOOder(item, input.tenantId, input.factoryId, bangid, leadTimeList, supplierList, plan_date.Value);
|
|
|
+ //1.先生成委外工单。
|
|
|
+ //2.再根据委外工单需要检查库存材料,然后提供给第三方组装。
|
|
|
+ //3.如果委外工单的物料库存不够,先生成物料采购申请单,再生成物料的采购订单,到货后再走委外流程。
|
|
|
+ //4.再生成委外的采购申请单。
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ item.use_qty = 0;
|
|
|
+ if (parent.stock_state == 1)
|
|
|
+ {
|
|
|
+ //如果父级缺料,则本级等于父级缺料*本级使用数量
|
|
|
+ item.use_qty = parent.lack_qty * item.qty;
|
|
|
+ itemStockoccupyDto.quantity = item.use_qty;
|
|
|
+ sklist.Add(itemStockoccupyDto);
|
|
|
}
|
|
|
}
|
|
|
+ item.is_use = true;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1512,12 +1543,16 @@ namespace Business.ResourceExamineManagement
|
|
|
slt.is_use = true;
|
|
|
if (slt.lack_qty > 0)
|
|
|
{
|
|
|
-
|
|
|
itemStockoccupyDto.quantity = slt.sqty;
|
|
|
//库存不够的时候,根据属性生成采购和委外。
|
|
|
if (slt.erp_cls == 1)
|
|
|
{
|
|
|
slt.make_qty = slt.lack_qty;
|
|
|
+ //走自制
|
|
|
+ var minute = ProductiveExamine(item.bom_number, item.lack_qty.GetInt());
|
|
|
+ //系统建议完工日期为 开工日期+产能检查时间=完工日期
|
|
|
+ var Day = minute.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
|
|
|
+ slt.kitting_time = slt.kitting_time.Value.AddDays((double)Day);
|
|
|
/*var childList = returnlist.Where(s => s.parent_id == slt.id).ToList();
|
|
|
if (childList.Count() > 0)
|
|
|
{
|
|
|
@@ -1541,6 +1576,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ slt.kitting_time = DateTime.Now;
|
|
|
itemStockoccupyDto.quantity = slt.needCount;
|
|
|
if (parent != null)
|
|
|
{ //如果不缺料的情况下,则占用掉父级缺料乘以当前子集使用料数量
|
|
|
@@ -1729,7 +1765,8 @@ namespace Business.ResourceExamineManagement
|
|
|
else
|
|
|
{
|
|
|
//根据占用情况计算库存
|
|
|
- Calczykc(item, sockoccupyList);
|
|
|
+ Calczykc(item, parent, sockoccupyList);
|
|
|
+
|
|
|
//如果有子集,则丢入循环,判断下库存可制等信息。
|
|
|
calcTest2(item, childList, returnlist, sockoccupyList);
|
|
|
/*item.kz = childList.Min(s => s.kz);
|
|
|
@@ -1760,8 +1797,9 @@ namespace Business.ResourceExamineManagement
|
|
|
//如果替代料库存不够,但是可制够,则也考虑使用优先级最高
|
|
|
foreach (var g in group)
|
|
|
{
|
|
|
+ var parent = returnlist.Find(s => s.id == g.parent_id);
|
|
|
//根据占用情况计算库存
|
|
|
- Calczykc(g, sockoccupyList);
|
|
|
+ Calczykc(parent, g, sockoccupyList);
|
|
|
/*if (g.stock_state != 1)
|
|
|
{
|
|
|
//判断此料是否BOM,如果是BOM,就考虑自制是否足够,此处递归检查子集
|
|
|
@@ -1821,7 +1859,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// </summary>
|
|
|
/// <param name="item"></param>
|
|
|
/// <param name="sockoccupyList"></param>
|
|
|
- public void Calczykc(BomChildExamineDto item, List<ic_item_stockoccupy> sockoccupyList)
|
|
|
+ public void Calczykc(BomChildExamineDto item, BomChildExamineDto parent, List<ic_item_stockoccupy> sockoccupyList)
|
|
|
{
|
|
|
//找到当前物料的占用记录
|
|
|
var itemSockoccupy = sockoccupyList.Where(s => s.icitem_id == item.item_id).ToList();
|
|
|
@@ -1829,10 +1867,17 @@ namespace Business.ResourceExamineManagement
|
|
|
item.sqty -= itemSockoccupy.Sum(s => s.quantity);
|
|
|
//如果库存
|
|
|
item.sqty = item.sqty < 0 ? 0 : item.sqty;
|
|
|
- //判断缺料数量
|
|
|
- item.lack_qty = item.needCount - item.sqty;
|
|
|
- //判断状态
|
|
|
- item.stock_state = item.lack_qty > 0 ? 0 : 1;
|
|
|
+ if (parent.stock_state == 1 || parent.stock_state == -1)
|
|
|
+ {
|
|
|
+ item.stock_state = parent.stock_state;
|
|
|
+ item.lack_qty = 0;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //判断缺料数量
|
|
|
+ item.lack_qty = parent.lack_qty * item.qty - item.sqty;
|
|
|
+ //判断状态
|
|
|
+ item.stock_state = item.lack_qty > 0 ? 0 : 1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#region 替代检查第一版,屏蔽
|