|
|
@@ -373,7 +373,7 @@ namespace Business.ResourceExamineManagement
|
|
|
throw new NotImplementedException("订单数据不存在!");
|
|
|
}
|
|
|
//获取订单行数据
|
|
|
- List<crm_seorderentry> sentrys =await _mysql_crm_seorderentry.GetListAsync(p => p.tenant_id == input.tenantId && p.factory_id == input.factoryId && p.seorder_id == input.sorderId && !p.IsDeleted);
|
|
|
+ List<crm_seorderentry> sentrys = await _mysql_crm_seorderentry.GetListAsync(p => p.tenant_id == input.tenantId && p.factory_id == input.factoryId && p.seorder_id == input.sorderId && !p.IsDeleted);
|
|
|
|
|
|
//数据库快照-同步mysql库数据到mongoDB中
|
|
|
//await SyncData(input.tenantId, input.factoryId, bangid);
|
|
|
@@ -381,7 +381,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//通过订单行的产品代码获取物料BOM数据
|
|
|
//FilterDefinition<ic_bom> filter = Builders<ic_bom>.Filter.In(s => s.bom_number, sentrys.Select(m => m.bom_number).ToList());
|
|
|
//List<ic_bom> boms = _ic_bom.GetManyByIds(filter).Result.Where(p => p.factory_id == input.factoryId && p.tenant_id == input.tenantId && !p.IsDeleted).ToList();
|
|
|
- List<ic_bom> boms = _ic_bom.Find(p=>sentrys.Select(m=>m.item_number).Contains(p.item_number) && p.factory_id == input.factoryId && p.tenant_id == input.tenantId && !p.IsDeleted).Result.ToList();
|
|
|
+ List<ic_bom> boms = _ic_bom.Find(p => sentrys.Select(m => m.item_number).Contains(p.item_number) && p.factory_id == input.factoryId && p.tenant_id == input.tenantId && !p.IsDeleted).Result.ToList();
|
|
|
//通过物料id获取产品提前期
|
|
|
List<ICItemLeadTimeDto> leadTimes = GetLeadTime(boms.Select(p => p.icitem_id).ToList(), input.tenantId, input.factoryId);
|
|
|
|
|
|
@@ -451,7 +451,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//添加物料bom数据
|
|
|
bomlist.AddRange(icBoms);
|
|
|
//获取物料bom明细数据
|
|
|
- List<ic_bom_child> childList = _ic_bom_child.GetManyByCondition(p => icBoms.Select(m=>m.Id).Contains(p.bom_id) && p.use_status == 1 && p.tenant_id == param.tenantId && p.factory_id == param.factoryId && !p.IsDeleted).Result.ToList();
|
|
|
+ List<ic_bom_child> childList = _ic_bom_child.GetManyByCondition(p => icBoms.Select(m => m.Id).Contains(p.bom_id) && p.use_status == 1 && p.tenant_id == param.tenantId && p.factory_id == param.factoryId && !p.IsDeleted).Result.ToList();
|
|
|
//没有明细数据,终止
|
|
|
if (childList.Count == 0)
|
|
|
{
|
|
|
@@ -459,7 +459,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
bomchildlist.AddRange(childList);
|
|
|
//通过物料bom明细数据反查物料bom数据
|
|
|
- var boms = _ic_bom.GetManyByCondition(p => childList.Select(m=>m.icitem_id).ToList().Contains(p.icitem_id) && p.fse_status == 1 && p.tenant_id == param.tenantId && p.factory_id == param.factoryId && !p.IsDeleted).Result.ToList();
|
|
|
+ var boms = _ic_bom.GetManyByCondition(p => childList.Select(m => m.icitem_id).ToList().Contains(p.icitem_id) && p.fse_status == 1 && p.tenant_id == param.tenantId && p.factory_id == param.factoryId && !p.IsDeleted).Result.ToList();
|
|
|
foreach (var chd in childList)
|
|
|
{
|
|
|
var curBoms = boms.Where(p => p.icitem_id == chd.icitem_id).ToList();
|
|
|
@@ -759,7 +759,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
//当前工序生产时间
|
|
|
decimal takeTiem = 0.00m;
|
|
|
-
|
|
|
+
|
|
|
if (proc.wctype == 1)//人工型:数量/uph(一小时生产数量)*60(小时转换为分钟)/wsinuse(工位数)
|
|
|
{
|
|
|
takeTiem = packages / proc.uph.Value * 60 / proc.wsinuse.Value;
|
|
|
@@ -784,7 +784,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 version, string number, decimal? Quantity, long? ParentId=null)
|
|
|
+ public Mes_MorderDto GenerateMorder(crm_seorderentry seorderentry, string BomNumber, string version, string number, decimal? Quantity, long? ParentId = null)
|
|
|
{
|
|
|
//1.库存、在制工单检查完成后 当前BOM需要自制时 产生工单。
|
|
|
|
|
|
@@ -810,16 +810,16 @@ namespace Business.ResourceExamineManagement
|
|
|
mes_Morder.fmodel = ic_item.model;
|
|
|
//最早的开工时间3天后、 最晚时间为订单承诺时间-采购提前期-质检提前期-入库提前期-发料提前期 =最晚开工时间 最早或最晚为系统建议开工日期
|
|
|
//根绝系统配置参数 取最早或者最晚开始日期
|
|
|
- var StartDate = DateTime.Now.Date.AddDays(3);
|
|
|
- mes_Morder.moentry_sys_stime = StartDate;
|
|
|
- if (!string.IsNullOrEmpty(BomNumber))
|
|
|
- {
|
|
|
- var ProductiveDate = ProductiveExamine(BomNumber, version,(int)(Quantity.Value));
|
|
|
- //系统建议完工日期为 开工日期+产能检查时间=完工日期
|
|
|
- var Day = ProductiveDate.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
|
|
|
- mes_Morder.moentry_sys_etime = StartDate.AddDays((double)Day);
|
|
|
- mes_Morder.morder_need_time = ProductiveDate.Result;
|
|
|
- }
|
|
|
+ //var StartDate = DateTime.Now.Date.AddDays(3);
|
|
|
+ //mes_Morder.moentry_sys_stime = StartDate;
|
|
|
+ //if (!string.IsNullOrEmpty(BomNumber))
|
|
|
+ //{
|
|
|
+ // var ProductiveDate = ProductiveExamine(BomNumber, version, (int)(Quantity.Value));
|
|
|
+ // //系统建议完工日期为 开工日期+产能检查时间=完工日期
|
|
|
+ // var Day = ProductiveDate.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
|
|
|
+ // mes_Morder.moentry_sys_etime = StartDate.AddDays((double)Day);
|
|
|
+ // mes_Morder.morder_need_time = ProductiveDate.Result;
|
|
|
+ //}
|
|
|
mes_Morder.moentry_startup_status = 0;
|
|
|
mes_Morder.tenant_id = seorderentry.tenant_id;
|
|
|
mes_Morder.factory_id = seorderentry.factory_id;
|
|
|
@@ -854,10 +854,17 @@ namespace Business.ResourceExamineManagement
|
|
|
mes_Moentry.need_number = Quantity;
|
|
|
mes_Moentry.remaining_number = 0;
|
|
|
mes_Moentry.factory_id = seorderentry.factory_id;
|
|
|
+
|
|
|
+ Mes_MorderDto mes_MorderDto = new Mes_MorderDto();
|
|
|
+ mes_MorderDto.mes_Morders.Add(mes_Morder);
|
|
|
+ mes_MorderDto.mes_Moentries.Add(mes_Moentry);
|
|
|
+
|
|
|
+ return mes_MorderDto;
|
|
|
+
|
|
|
//using (TransactionScope scope = new TransactionScope())
|
|
|
// {
|
|
|
- _mes_morder.InsertOne(mes_Morder);
|
|
|
- _mes_moentry.InsertOne(mes_Moentry);
|
|
|
+ //_mes_morder.InsertOne(mes_Morder);
|
|
|
+ //_mes_moentry.InsertOne(mes_Moentry);
|
|
|
//scope.Complete();
|
|
|
//}
|
|
|
}
|
|
|
@@ -1025,7 +1032,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//throw new bu
|
|
|
}
|
|
|
List<BomChildExamineDto> returnlist = new List<BomChildExamineDto>();
|
|
|
-
|
|
|
+
|
|
|
var bom = bomlist.Find(s => s.Id == BomId);
|
|
|
if (bom == null)
|
|
|
{
|
|
|
@@ -1347,7 +1354,7 @@ namespace Business.ResourceExamineManagement
|
|
|
//先处理下最顶级的产品需要数量
|
|
|
returnlist[0].needCount = returnlist[0].qty * count;
|
|
|
returnlist[0].lack_qty = returnlist[0].needCount - returnlist[0].sqty;
|
|
|
-
|
|
|
+
|
|
|
foreach (var item in returnlist)
|
|
|
{
|
|
|
if (item.level == 1)
|
|
|
@@ -1357,12 +1364,12 @@ namespace Business.ResourceExamineManagement
|
|
|
//循环平铺整个资源检查的物料库存情况、缺料情况,子集缺料需要用父级缺料*子集使用数量-
|
|
|
CaclMaterialShortage(returnlist, item, count);
|
|
|
}
|
|
|
-
|
|
|
+ Mes_MorderDto mes_MorderDto = new Mes_MorderDto();
|
|
|
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].version, returnlist[0].item_number, returnlist[0].lack_qty);
|
|
|
+ mes_MorderDto = GenerateMorder(seorderentry, returnlist[0].bom_number, returnlist[0].version, returnlist[0].item_number, returnlist[0].lack_qty);
|
|
|
}
|
|
|
|
|
|
//这是从上往下展开计算缺料和可制
|
|
|
@@ -1372,7 +1379,28 @@ namespace Business.ResourceExamineManagement
|
|
|
CalcIcitem(childList, returnlist, bangid, orderid, input, sklist, plan_date);
|
|
|
returnlist[0].kitting_time = childList.Max(s => s.kitting_time);
|
|
|
//这里更新产品得满足时间。
|
|
|
+ if (mes_MorderDto != null)
|
|
|
+ {
|
|
|
+ //TODO:目前不考虑子工单 只存在单条数据先这样取值;
|
|
|
+ var mes_Morders = mes_MorderDto.mes_Morders.FirstOrDefault();
|
|
|
+ var mes_Moentry = mes_MorderDto.mes_Moentries.FirstOrDefault();
|
|
|
+ if (mes_Morders != null)
|
|
|
+ {
|
|
|
+ mes_Morders.moentry_sys_stime = returnlist[0].kitting_time;
|
|
|
+ if (!string.IsNullOrEmpty(mes_Morders.bom_number))
|
|
|
+ {
|
|
|
+ var ProductiveDate = ProductiveExamine(mes_Morders.bom_number, returnlist[0].version, (int)mes_Morders.morder_production_number.Value);
|
|
|
+ //系统建议完工日期为 开工日期+产能检查时间=完工日期
|
|
|
+ var Day = ProductiveDate.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
|
|
|
+ mes_Morders.moentry_sys_etime = returnlist[0].kitting_time.Value.AddDays((double)Day);
|
|
|
+ mes_Morders.morder_need_time = ProductiveDate.Result;
|
|
|
+ returnlist[0].satisfy_time = mes_Morders.moentry_sys_etime;
|
|
|
+ }
|
|
|
|
|
|
+ _mes_morder.InsertOne(mes_Morders);
|
|
|
+ _mes_moentry.InsertOne(mes_Moentry);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -1385,7 +1413,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)
|
|
|
@@ -1423,7 +1451,7 @@ namespace Business.ResourceExamineManagement
|
|
|
if (item.erp_cls == 1)
|
|
|
{
|
|
|
//走自制
|
|
|
- var minute = ProductiveExamine(item.bom_number,"1.0", item.lack_qty.GetInt());
|
|
|
+ var minute = ProductiveExamine(item.bom_number, "1.0", item.lack_qty.GetInt());
|
|
|
//var ProductiveDate = ProductiveExamine(BomNumber, (int)(Quantity.Value));
|
|
|
//系统建议完工日期为 开工日期+产能检查时间=完工日期
|
|
|
var Day = minute.Result / (60 * 10); //返回的分钟除以十个小时得出工作天数;
|
|
|
@@ -1446,7 +1474,8 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
item.use_qty = 0;
|
|
|
if (parent.stock_state == 1)
|
|
|
{
|
|
|
@@ -1458,7 +1487,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
item.is_use = true;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1847,7 +1876,7 @@ namespace Business.ResourceExamineManagement
|
|
|
{
|
|
|
//根据占用情况计算库存
|
|
|
Calczykc(item, parent, sockoccupyList);
|
|
|
-
|
|
|
+
|
|
|
//如果有子集,则丢入循环,判断下库存可制等信息。
|
|
|
calcTest2(item, childList, returnlist, sockoccupyList);
|
|
|
/*item.kz = childList.Min(s => s.kz);
|
|
|
@@ -1953,7 +1982,8 @@ namespace Business.ResourceExamineManagement
|
|
|
item.stock_state = parent.stock_state;
|
|
|
item.lack_qty = 0;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
//判断缺料数量
|
|
|
item.lack_qty = parent.lack_qty * item.qty - item.sqty;
|
|
|
//判断状态
|
|
|
@@ -2315,7 +2345,7 @@ namespace Business.ResourceExamineManagement
|
|
|
var leadTime = iCItemLeadTimes.Find(x => x.item_id == returnlist.item_id);
|
|
|
var supplier = supplierList.Find(x => x.icitem_id == returnlist.item_id);//默认取第一个供应商
|
|
|
var plan = planList.Find(x => x.icitem_id == returnlist.item_id);
|
|
|
- if(leadTime==null || supplier==null || plan==null)
|
|
|
+ if (leadTime == null || supplier == null || plan == null)
|
|
|
{
|
|
|
throw new NotImplementedException("未找到物料ic_factory_details或ic_item_pur或ic_plan信息!");
|
|
|
}
|