|
|
@@ -393,6 +393,9 @@ namespace Business.ResourceExamineManagement
|
|
|
SnowFlake snow = new SnowFlake();
|
|
|
long bangid = snow.NextId();
|
|
|
|
|
|
+ string bom_number = "BOM00042070";
|
|
|
+ int packages = 1000;
|
|
|
+
|
|
|
input.tenantId = 102;
|
|
|
input.factoryId = 10201;
|
|
|
|
|
|
@@ -403,12 +406,18 @@ namespace Business.ResourceExamineManagement
|
|
|
//await SyncData(input.tenantId, input.factoryId, bangid);
|
|
|
|
|
|
//产能检查
|
|
|
- //await ProductiveExamine(1353957529328291842, 1000);
|
|
|
- var id = Save(input.tenantId, input.factoryId);
|
|
|
- await GenerateMorder(id);
|
|
|
+ await ProductiveExamine(bom_number, packages);
|
|
|
+ //var id = Save(input.tenantId, input.factoryId);
|
|
|
+ //await GenerateMorder(id);
|
|
|
return null;
|
|
|
throw new NotImplementedException();
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 测试使用新增销售订单数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="tenantId"></param>
|
|
|
+ /// <param name="factoryId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public long Save(long tenantId, long factoryId)
|
|
|
{
|
|
|
//销售订单
|
|
|
@@ -574,14 +583,14 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
#region 1、数据准备
|
|
|
//1.1、获取工艺路径数据
|
|
|
- mes_technique tech = _mes_technique.Find(p => p.bom == bom_number).Result.FirstOrDefault();
|
|
|
+ mes_technique tech = _mes_technique.Find(p => p.bom == bom_number && p.IsDeleted == false).Result.FirstOrDefault();
|
|
|
if (tech == null)
|
|
|
{
|
|
|
throw new NotImplementedException("请先配置工艺路径!");
|
|
|
}
|
|
|
|
|
|
//1.2、获取工艺路径关联工序数据
|
|
|
- List<mes_tech_process> tech_Processes = await _mes_tech_process.GetManyByCondition(x => x.tech_id == tech.Id);
|
|
|
+ List<mes_tech_process> tech_Processes = await _mes_tech_process.GetManyByCondition(p => p.tech_id == tech.Id && p.IsDeleted == false);
|
|
|
if (tech_Processes.Count == 0)
|
|
|
{
|
|
|
throw new NotImplementedException("请先配置工序!");
|
|
|
@@ -591,11 +600,11 @@ namespace Business.ResourceExamineManagement
|
|
|
//FilterDefinition<mes_process> filter = Builders<mes_process>.Filter.In(s => s.Id, tech_Processes.Select(m => m.proc_id).ToList());
|
|
|
//List<mes_process> process = await _mes_process.GetManyByIds(filter);
|
|
|
List<long> procIds = tech_Processes.Select(m => m.proc_id).ToList();
|
|
|
- List<mes_process> process = await _mes_process.GetManyByCondition(p => procIds.Contains(p.Id));
|
|
|
+ List<mes_process> process = await _mes_process.GetManyByCondition(p => procIds.Contains(p.Id) && p.IsDeleted == false);
|
|
|
|
|
|
//1.3、获取工艺工序关联工位信息
|
|
|
List<long> techProcIds = tech_Processes.Select(m => m.Id).ToList();
|
|
|
- List<mes_tech_proc_workshop> tech_Proc_Workshops = await _mes_tech_proc_workshop.GetManyByCondition(p => techProcIds.Contains(p.tech_proc_id));
|
|
|
+ List<mes_tech_proc_workshop> tech_Proc_Workshops = await _mes_tech_proc_workshop.GetManyByCondition(p => techProcIds.Contains(p.tech_proc_id) && p.IsDeleted == false);
|
|
|
#endregion
|
|
|
|
|
|
#region 计算产能,得到耗时
|
|
|
@@ -735,6 +744,7 @@ namespace Business.ResourceExamineManagement
|
|
|
mes_Morder.planner_num = seorderentry.planner_no;
|
|
|
mes_Morder.planner_name = seorderentry.planner_name;
|
|
|
mes_Morder.morder_date = DateTime.Now.Date;
|
|
|
+ //mes_Morder.morder_fstate = "计划";
|
|
|
//TODO:目前没有取值位置
|
|
|
mes_Morder.moentry_prd = null;
|
|
|
mes_Morder.moentry_prdname = null;
|
|
|
@@ -759,24 +769,12 @@ namespace Business.ResourceExamineManagement
|
|
|
mes_Moentry.need_number = seorderentry.qty;
|
|
|
mes_Moentry.remaining_number = 0;
|
|
|
mes_Moentry.factory_id = seorderentry.factory_id;
|
|
|
- using (TransactionScope scope = new TransactionScope())
|
|
|
- {
|
|
|
- await _mes_morder.InsertOne(mes_Morder);
|
|
|
- await _mes_moentry.InsertOne(mes_Moentry);
|
|
|
- scope.Complete();
|
|
|
- }
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 将decimal转换成日期格式
|
|
|
- /// </summary>
|
|
|
- /// <param name="date">yyyyMMddHHmmss</param>
|
|
|
- /// <returns>yyyy-MM-dd HH:mm:ss</returns>
|
|
|
- public static string TransDecimalToDateTime(string date)
|
|
|
- {
|
|
|
- DateTimeFormatInfo dtfi = new CultureInfo("zh-CN", false).DateTimeFormat;
|
|
|
- DateTime dateTime = DateTime.Now;
|
|
|
- DateTime.TryParseExact(date, "yyyyMMddHHmmss", dtfi, DateTimeStyles.None, out dateTime);
|
|
|
- return dateTime.ToString("yyyy-MM-dd HH:mm:ss"); ;
|
|
|
+ //using (TransactionScope scope = new TransactionScope())
|
|
|
+ // {
|
|
|
+ await _mes_morder.InsertOne(mes_Morder);
|
|
|
+ await _mes_moentry.InsertOne(mes_Moentry);
|
|
|
+ //scope.Complete();
|
|
|
+ //}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 检查成品库存
|
|
|
@@ -813,7 +811,7 @@ namespace Business.ResourceExamineManagement
|
|
|
/// <param name="DeliverDate">交付日期</param>
|
|
|
/// <param name="seorderentry_id">销售订单子表ID</param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<List<mes_morder>> CheckMorder(string bomNumber, decimal? Quantity, DateTime DeliverDate, long seorderentry_id)
|
|
|
+ public async Task<bool> CheckMorder(string bomNumber, decimal? Quantity, DateTime DeliverDate, long seorderentry_id)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(bomNumber) || Quantity != null)
|
|
|
{
|
|
|
@@ -853,7 +851,8 @@ namespace Business.ResourceExamineManagement
|
|
|
if (morderListData.Count == 0)
|
|
|
{
|
|
|
//TODO:后期处理无在制工单返回内容
|
|
|
- throw new NotImplementedException("无可用在制工单!");
|
|
|
+ //throw new NotImplementedException("无可用在制工单!");
|
|
|
+ return false;
|
|
|
}
|
|
|
List<mes_mooccupy> mes_Mooccupies = new List<mes_mooccupy>();
|
|
|
decimal? number = Quantity;
|
|
|
@@ -870,7 +869,7 @@ namespace Business.ResourceExamineManagement
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return morderList;
|
|
|
+ return true;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 拼接工单占用表
|
|
|
@@ -901,13 +900,15 @@ namespace Business.ResourceExamineManagement
|
|
|
mes_Mooccupy.moo_mo = item.morder_no;
|
|
|
//占用量=生产计划数量-入库数量-已被占用数量
|
|
|
mes_Mooccupy.moo_qty = item.morder_production_number - item.inventory_number - Sumqty;
|
|
|
- mes_Mooccupy.moo_stime = DateTime.Now;
|
|
|
+ mes_Mooccupy.moo_stime = DateTime.Now.Date;
|
|
|
mes_Mooccupy.moo_etime = DateTime.Now;//日期来源需确定
|
|
|
mes_Mooccupy.moo_state = 1;
|
|
|
mes_Mooccupy.moo_cbr = string.Empty;
|
|
|
//mes_Mooccupy.moo_ctime = ;
|
|
|
mes_Mooccupy.moo_creason = string.Empty;
|
|
|
mes_Mooccupy.tenant_id = seorderentry.tenant_id;//取销售子表企业ID
|
|
|
+ mes_Mooccupy.factory_id = seorderentry.factory_id;
|
|
|
+ mes_Mooccupy.factory_id = seorderentry.factory_id;
|
|
|
return mes_Mooccupy;
|
|
|
}
|
|
|
/// <summary>
|